about summary refs log tree commit diff
path: root/compiler/rustc_session/src/config.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-4/+11
2023-12-18Rename many `EarlyDiagCtxt` arguments.Nicholas Nethercote-117/+117
2023-12-18Rename `UnstableOptions::diagnostic_handler_flags` as ↵Nicholas Nethercote-1/+1
`UnstableOptions::dcx_flags`.
2023-12-18Rename `HandlerFlags` as `DiagCtxtFlags`.Nicholas Nethercote-3/+3
2023-12-18Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.Nicholas Nethercote-30/+24
2023-12-15NFC don't convert types to identical typesMatthias Krüger-1/+1
2023-12-14Rollup merge of #118908 - Urgau:check-cfg-target-features, ↵Jubilee-4/+6
r=TaKO8Ki,GuillaumeGomez,workingjubilee Add all known `target_feature` configs to check-cfg This PR adds all the known `target_feature` from ~~`rustc_codegen_ssa`~~ `rustc_target` to the well known list of check-cfg. It does so by moving the list from `rustc_codegen_ssa` to `rustc_target` ~~`rustc_session` (I not sure about this, but some of the moved function take a `Session`)~~, then using it the `fill_well_known` function. This already proved to be useful since portable-simd had a bad cfg. cc `@nnethercote` (since we discussed it in https://github.com/rust-lang/rust/pull/118494)
2023-12-14rename `-Ztrait-solver` to `-Znext-solver`lcnr-12/+13
2023-12-14Don't forget pure rustc target features in check-cfgUrgau-2/+6
2023-12-14Use all the known features in check-cfgUrgau-4/+2
2023-12-11Auto merge of #118494 - nnethercote:default_configuration-fill_well_known, ↵bors-154/+175
r=Mark-Simulacrum Rearrange `default_configuration` and `CheckCfg::fill_well_known`. There are comments saying these two functions should be kept in sync, but they have very different structures, process symbols in different orders, and there are some inconsistencies. This commit reorders them so they're both mostly processing symbols in alphabetical order, which makes cross-checking them a lot easier. The commit also adds some macros to factor out repetitive code patterns. The commit also moves the handling of `sym::test` out of `build_configuration` into `default_configuration`, where all the other symbols are handled. r? `@bjorn3`
2023-12-11Rearrange `default_configuration` and `CheckCfg::fill_well_known`.Nicholas Nethercote-154/+175
There are comments saying these two functions should be kept in sync, but they have very different structures, process symbols in different orders, and there are some inconsistencies. This commit reorders them so they're both mostly processing symbols in alphabetical order, which makes cross-checking them a lot easier. The commit also adds some macros to factor out repetitive code patterns. Plus it adds `sanitizer_cfi_normalize_{integers,pointers}` to `fill_well_known`, which were missing. The commit also moves the handling of `sym::test` out of `build_configuration` into `default_configuration`, where all the other symbols are handled.
2023-12-10Auto merge of #118368 - GuillaumeGomez:env-flag, r=Nilstriebbors-1/+39
Implement `--env` compiler flag (without `tracked_env` support) Part of https://github.com/rust-lang/rust/issues/80792. Implementation of https://github.com/rust-lang/compiler-team/issues/653. Not an implementation of https://github.com/rust-lang/rfcs/pull/2794. It adds the `--env` compiler flag option which allows to set environment values used by `env!` and `option_env!`. Important to note: When trying to retrieve an environment variable value, it will first look into the ones defined with `--env`, and if there isn't one, then only it will look into the environment variables. So if you use `--env PATH=a`, then `env!("PATH")` will return `"a"` and not the actual `PATH` value. As mentioned in the title, `tracked_env` support is not added here. I'll do it in a follow-up PR. r? rust-lang/compiler
2023-12-10Implement `--env` compiler flagGuillaume Gomez-1/+39
2023-12-09Strengthen well known check-cfg names and values testUrgau-0/+3
2023-12-09Auto merge of #117873 - quininer:android-emutls, r=Amanieubors-1/+1
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2023-12-08Fuel is incompatible with incremental compilationTomasz Miąsko-1/+5
2023-12-07Inline check_thread_count implementationTomasz Miąsko-11/+7
2023-12-07Add emulated TLS supportquininer-1/+1
Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls.
2023-12-02Rename `Handler::delay_good_path_bug` as `Handler::good_path_delayed_bug`.Nicholas Nethercote-3/+6
In line with the previous commits.
2023-12-01Auto merge of #118472 - nnethercote:rustc_session, r=bjorn3bors-46/+52
`rustc_session` cleanups r? `@bjorn3`
2023-12-01Move `WasiExecModel`.Nicholas Nethercote-1/+7
All the other option enums are defined in `config.rs`.
2023-12-01Reduce `pub` exposure.Nicholas Nethercote-1/+1
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-3/+15
This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30Inline and remove `select_debuginfo_compression`.Nicholas Nethercote-9/+1
It's trivial and has a single callsite.
2023-11-30Sort `PRINT_KINDS`.Nicholas Nethercote-13/+15
Alphabetical order is nicer than random order.
2023-11-30Improve integer interning in `default_configuration`.Nicholas Nethercote-10/+9
We have `sym::integer` for interning integers. Using it lets us use symbols directy, and not have to explicitly go through strings.
2023-11-30Move `is_ascii_ident` to where it's used.Nicholas Nethercote-2/+13
2023-11-30Reorder some `use` items.Nicholas Nethercote-10/+6
2023-11-26Serialize OutputFilenames into rmeta filebjorn3-3/+3
This ensures that linking will use the correct crate name even when `#![crate_name = "..."]` is used to specify the crate name.
2023-11-22Auto merge of #118071 - Urgau:check-cfg-cargo-feature, r=petrochenkovbors-2/+1
Remove `feature` from the list of well known check-cfg name This PR removes `feature` from the list of well known check-cfg. This is done for multiple reasons: - Cargo is the source of truth, rustc shouldn't have any knowledge of it - It creates a conflict between Cargo and rustc when there are no features defined. In this case Cargo won't pass any `--check-cfg` for `feature` since no feature will ever be passed, but rustc by having in it's list adds a implicit `cfg(feature, values(any()))` which is completely wrong. Having any cfg `feature` is unexpected not allow any `feature` value. While doing this, I took the opportunity to specialise the diagnostic a bit for the case above. r? `@petrochenkov`
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21Remove `feature` from the list of well known check-cfg nameUrgau-2/+1
2023-11-17change smir to StableMirOğuz Ağcayazı-7/+7
2023-11-17emit basic smirOğuz Ağcayazı-3/+7
2023-11-11Auto merge of #115694 - clarfonthey:std-hash-private, r=dtolnaybors-2/+1
Add `std::hash::{DefaultHasher, RandomState}` exports (needs FCP) This implements rust-lang/libs-team#267 to move the libstd hasher types to `std::hash` where they belong, instead of `std::collections::hash_map`. <details><summary>The below no longer applies, but is kept for clarity.</summary> This is a small refactor for #27242, which moves the definitions of `RandomState` and `DefaultHasher` into `std::hash`, but in a way that won't be noticed in the public API. I've opened rust-lang/libs-team#267 as a formal ACP to move these directly into the root of `std::hash`, but for now, they're at least separated out from the collections code in a way that will make moving that around easier. I decided to simply copy the rustdoc for `std::hash` from `core::hash` since I think it would be ideal for the two to diverge longer-term, especially if the ACP is accepted. However, I would be willing to factor them out into a common markdown document if that's preferred. </details>
2023-11-08Rollup merge of #117650 - saethlin:inline-me-please, r=davidtwcoMatthias Krüger-4/+18
Add -Zcross-crate-inline-threshold=yes ``@thomcc`` says this would be useful for > seeing if it makes a difference in some code if i do it when building the sysroot, since -Zbuild-std + lto helps more than it seems like it should And I've changed the possible values as a reference to ``@Manishearth`` saying > LLVM's inlining heuristic is "yes".
2023-11-07Add -Zcross-crate-inline-threshold=yesBen Kimock-4/+18
2023-11-08rustc: minor changes suggested by clippy perf lints.Nicholas Nethercote-1/+1
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-3/+2
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-02Add insta-stable std::hash::{DefaultHasher, RandomState} exportsltdk-2/+1
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-3/+2
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-11-02Remove support for alias `-Z symbol-mangling-version`Zalathar-21/+12
2023-10-30Make `Cfg` and `CheckCfg` non-generic.Nicholas Nethercote-21/+10
They now only ever contains symbols.
2023-10-30Change cfg parsers to produce symbols instead of strings.Nicholas Nethercote-31/+1
2023-10-28Change `Cfg<T>` to an `FxIndexSet`.Nicholas Nethercote-2/+5
Despite what I claimed in an earlier commit, the ordering does matter to some degree. Using `FxIndexSet` prevents changes to the error message order in `tests/ui/check-cfg/mix.rs`.
2023-10-28Clean up config mess.Nicholas Nethercote-25/+22
`parse_cfgspecs` and `parse_check_cfg` run very early, before the main interner is running. They each use a short-lived interner and convert all interned symbols to strings in their output data structures. Once the main interner starts up, these data structures get converted into new data structures that are identical except with the strings converted to symbols. All is not obvious from the current code, which is a mess, particularly with inconsistent naming that obscures the parallel string/symbol data structures. This commit clean things up a lot. - The existing `CheckCfg` type is generic, allowing both `CheckCfg<String>` and `CheckCfg<Symbol>` forms. This is really useful, but it defaults to `String`. The commit removes the default so we have to use `CheckCfg<String>` and `CheckCfg<Symbol>` explicitly, which makes things clearer. - Introduces `Cfg`, which is generic over `String` and `Symbol`, similar to `CheckCfg`. - Renames some things. - `parse_cfgspecs` -> `parse_cfg` - `CfgSpecs` -> `Cfg<String>`, plus it's used in more places, rather than the underlying `FxHashSet` type. - `CrateConfig` -> `Cfg<Symbol>`. - `CrateCheckConfig` -> `CheckCfg<Symbol>` - Adds some comments explaining the string-to-symbol conversions. - `to_crate_check_config`, which converts `CheckCfg<String>` to `CheckCfg<Symbol>`, is inlined and removed and combined with the overly-general `CheckCfg::map_data` to produce `CheckCfg::<String>::intern`. - `build_configuration` now does the `Cfg<String>`-to-`Cfg<Symbol>` conversion, so callers don't need to, which removes the need for `to_crate_config`. The diff for two of the fields in `Config` is a good example of the improved clarity: ``` - pub crate_cfg: FxHashSet<(String, Option<String>)>, - pub crate_check_cfg: CheckCfg, + pub crate_cfg: Cfg<String>, + pub crate_check_cfg: CheckCfg<String>, ``` Compare that with the diff for the corresponding fields in `ParseSess`, and the relationship to `Config` is much clearer than before: ``` - pub config: CrateConfig, - pub check_config: CrateCheckConfig, + pub config: Cfg<Symbol>, + pub check_config: CheckCfg<Symbol>, ```
2023-10-26The value of `-Cinstrument-coverage=` doesn't need to be `Option`Zalathar-7/+5
Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`.
2023-10-25Remove support for alias `-Z instrument-coverage`Zalathar-22/+17
This flag was stabilized in rustc 1.60.0 as `-C instrument-coverage`, but the old unstable flag was kept around as an alias to ease migration.
2023-10-24Introduce `-C instrument-coverage=branch` to gate branch coverageArpad Borsos-1/+7
This flag has to be used in combination with `-Zunstable-options`, and is added in advance of adding branch coverage instrumentation.