about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2025-01-20don't ICE when emitting linker errors during `-Z link-only`jyn-3/+6
note that this still ICEs when passed `-Z link-only --error-format json` because i can't be bothered to fix it right now
2025-01-20Rollup merge of #135330 - bjorn3:respect_sysroot_in_version_printing, r=lqdMatthias Krüger-2/+6
Respect --sysroot for rustc -vV and -Cpasses=list This is necessary when the specified codegen backend is in a custom sysroot. Fixes https://github.com/rust-lang/rust/issues/135165
2025-01-20Respect --target in get_backend_from_raw_matchesbjorn3-2/+6
2025-01-20Rollup merge of #135747 - ehuss:filename-quote, r=SparrowLii许杰友 Jieyou Xu (Joe)-1/+1
Rename FileName::QuoteExpansion to CfgSpec I believe this variant name was used incorrectly. The timeline is roughly: * `FileName::cfg_spec_source_code` was added in https://github.com/rust-lang/rust/pull/54517. However, it used `FileName::Quote` instead of `FileName::CfgSpec` which I believe was a mistake. * Quote stuff was removed in https://github.com/rust-lang/rust/pull/51285, but did not remove `FileName::Quote`. * `FileName::CfgSpec` was removed in https://github.com/rust-lang/rust/pull/116474 because it was unused. This restores it so that the `--cfg` variant uses a name that makes more sense with how it is used, and restores what I think is the original intent.
2025-01-19Rename FileName::QuoteExpansion to CfgSpecEric Huss-1/+1
I believe this variant name was used incorrectly. The timeline is roughly: * `FileName::cfg_spec_source_code` was added in https://github.com/rust-lang/rust/pull/54517. However, it used `FileName::Quote` instead of `FileName::CfgSpec` which I believe was a mistake. * Quote stuff was removed in https://github.com/rust-lang/rust/pull/51285, but did not remove `FileName::Quote`. * `FileName::CfgSpec` was removed in https://github.com/rust-lang/rust/pull/116474 because it was unused. This restores it so that the `--cfg` variant uses a name that makes more sense with how it is used, and restores what I think is the original intent.
2025-01-19Manual cleanup of some `is_{or_none|some_and}` usagesYotam Ofek-2/+2
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2025-01-16Update docs for `-Clink-dead-code` to discourage its useZalathar-8/+1
2025-01-11Rollup merge of #134030 - folkertdev:min-fn-align, r=workingjubileeMatthias Krüger-0/+21
add `-Zmin-function-alignment` tracking issue: https://github.com/rust-lang/rust/issues/82232 This PR adds the `-Zmin-function-alignment=<align>` flag, that specifies a minimum alignment for all* functions. ### Motivation This feature is requested by RfL [here](https://github.com/rust-lang/rust/issues/128830): > i.e. the equivalents of `-fmin-function-alignment` ([GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fmin-function-alignment_003dn), Clang does not support it) / `-falign-functions` ([GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-falign-functions), [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-falign-functions)). > > For the Linux kernel, the behavior wanted is that of GCC's `-fmin-function-alignment` and Clang's `-falign-functions`, i.e. align all functions, including cold functions. > > There is [`feature(fn_align)`](https://github.com/rust-lang/rust/issues/82232), but we need to do it globally. ### Behavior The `fn_align` feature does not have an RFC. It was decided at the time that it would not be necessary, but maybe we feel differently about that now? In any case, here are the semantics of this flag: - `-Zmin-function-alignment=<align>` specifies the minimum alignment of all* functions - the `#[repr(align(<align>))]` attribute can be used to override the function alignment on a per-function basis: when `-Zmin-function-alignment` is specified, the attribute's value is only used when it is higher than the value passed to `-Zmin-function-alignment`. - the target may decide to use a higher value (e.g. on x86_64 the minimum that LLVM generates is 16) - The highest supported alignment in rust is `2^29`: I checked a bunch of targets, and they all emit the `.p2align 29` directive for targets that align functions at all (some GPU stuff does not have function alignment). *: Only with `build-std` would the minimum alignment also be applied to `std` functions. --- cc `@ojeda` r? `@workingjubilee` you were active on the tracking issue
2025-01-10add `-Zmin-function-alignment`Folkert de Vries-0/+21
2025-01-06Rollup merge of #135126 - klensy:deprecated-and-do-nothing, r=jieyouxuJacob Pratt-9/+39
mark deprecated option as deprecated in rustc_session to remove copypasta and small refactor This marks deprecated options as deprecated via flag in options table in rustc_session, which removes copypasted deprecation text from rustc_driver_impl. This also adds warning for deprecated `-C ar` option, which didn't emitted any warnings before. Makes `inline_threshold` `[UNTRACKED]`, as it do nothing. Adds few tests. See individual commits.
2025-01-06Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubileeJacob Pratt-0/+7
Add support for wasm exception handling to Emscripten target This is a draft because we need some additional setting for the Emscripten target to select between the old exception handling and the new exception handling. I don't know how to add a setting like that, would appreciate advice from Rust folks. We could maybe choose to use the new exception handling if `Ctarget-feature=+exception-handling` is passed? I tried this but I get errors from llvm so I'm not doing it right.
2025-01-06add deprecated and do nothing flag to options tableklensy-9/+39
inline_threshold mark deprecated no-stack-check print deprecation message for -Car too inline_threshold deprecated and do nothing: make in untracked make OptionDesc struct from tuple
2025-01-06Add support for wasm exception handling to Emscripten targetHood Chatham-0/+7
Gated behind an unstable `-Z emscripten-wasm-eh` flag
2025-01-02Make the `test` cfg a "userspace" check-cfgUrgau-2/+5
2024-12-29make -Csoft-float have an effect on all ARM targetsRalf Jung-1/+1
2024-12-23Use `#[derive(Default)]` instead of manually implementing itEsteban Küber-7/+2
2024-12-20Rollup merge of #134561 - bjorn3:less_fatal_error_raise, r=compiler-errorsMatthias Krüger-9/+6
Reduce the amount of explicit FatalError.raise() Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These guarantee that an error actually happened previously and thus we don't silently abort.
2024-12-20Reduce the amount of explicit FatalError.raise()bjorn3-9/+6
Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These guarantee that an error actually happened previously and thus we don't silently abort.
2024-12-20Rollup merge of #134514 - bjorn3:more_driver_refactors, r=jieyouxuDianQK-1/+1
Improve dependency_format a bit * Make `DependencyList` an `IndexVec` rather than emulating one using a `Vec` (which was off-by-one as LOCAL_CRATE was intentionally skipped) * Update some comments for the fact that we now use `#[global_allocator]` rather than `extern crate alloc_system;`/`extern crate alloc_jemalloc;` for specifying which allocator to use. We still use a similar mechanism for the panic runtime, so refer to the panic runtime in those comments instead. * An unrelated refactor to `create_and_enter_global_ctxt` I forgot to include in https://github.com/rust-lang/rust/pull/134302. This refactor is too small to be worth it's own PR.
2024-12-19Update commentsbjorn3-1/+1
2024-12-19coverage: Add a synthetic test for when all spans are discardedZalathar-2/+14
2024-12-18Rollup merge of #134420 - Integral-Tech:pathbuf-refactor, r=compiler-errors许杰友 Jieyou Xu (Joe)-1/+1
refactor: replace &PathBuf with &Path to enhance generality - According to [style.md](https://github.com/rust-lang/rust/blob/master/src/tools/rust-analyzer/docs/dev/style.md#useless-types): > More generally, always prefer types on the left ```rust // GOOD BAD &[T] &Vec<T> &str &String Option<&T> &Option<T> &Path &PathBuf ```
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-6/+4
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-18refactor: replace &PathBuf with &Path to enhance generalityIntegral-1/+1
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-32/+0
2024-12-14Rollup merge of #134251 - bjorn3:various_cleanups2, r=oli-obkMatthias Krüger-10/+0
A bunch of cleanups (part 2) Just like https://github.com/rust-lang/rust/pull/133567 these were all found while looking at the respective code, but are not blocking any other changes I want to make in the short term.
2024-12-13Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubileebors-1/+1
forbid toggling x87 and fpregs on hard-float targets Part of https://github.com/rust-lang/rust/issues/116344, follow-up to https://github.com/rust-lang/rust/pull/129884: The `x87` target feature on x86 and the `fpregs` target feature on ARM must not be disabled on a hardfloat target, as that would change the float ABI. However, *enabling* `fpregs` on ARM is [explicitly requested](https://github.com/rust-lang/rust/issues/130988) as it seems to be useful. Therefore, we need to refine the distinction of "forbidden" target features and "allowed" target features: all (un)stable target features can determine on a per-target basis whether they should be allowed to be toggled or not. `fpregs` then checks whether the current target has the `soft-float` feature, and if yes, `fpregs` is permitted -- otherwise, it is not. (Same for `x87` on x86). Also fixes https://github.com/rust-lang/rust/issues/132351. Since `fpregs` and `x87` can be enabled on some builds and disabled on others, it would make sense that one can query it via `cfg`. Therefore, I made them behave in `cfg` like any other unstable target feature. The first commit prepares the infrastructure, but does not change behavior. The second commit then wires up `fpregs` and `x87` with that new infrastructure. r? `@workingjubilee`
2024-12-13Remove registered_lints field from Sessionbjorn3-4/+0
It only exists to pass some information from one part of the driver to another part. We can directly pass this information to the function that needs it to reduce the amount of mutation of the Session.
2024-12-13Remove jobserver from Sessionbjorn3-6/+0
It is effectively a global resource and the jobserver::Client in Session was a clone of GLOBAL_CLIENT anyway.
2024-12-13Auto merge of #133899 - scottmcm:strip-mir-debuginfo, r=oli-obkbors-4/+26
We don't need `NonNull::as_ptr` debuginfo In order to stop pessimizing the use of local variables in core, skip debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.
2024-12-11generalize 'forbidden feature' concept so that even (un)stable feature can ↵Ralf Jung-1/+1
be invalid to toggle Also rename some things for extra clarity
2024-12-10We don't need `NonNull::as_ptr` debuginfoScott McMurray-4/+26
Stop pessimizing the use of local variables in core by skipping debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.
2024-12-09Rollup merge of #133567 - bjorn3:various_cleanups, r=cjgillotMatthias Krüger-9/+6
A bunch of cleanups These are all extracted from a branch I have to get rid of driver queries. Most of the commits are not directly necessary for this, but were found in the process of implementing the removal of driver queries. Previous PR: https://github.com/rust-lang/rust/pull/132410
2024-12-06Remove polymorphizationBen Kimock-2/+0
2024-12-06Store a single copy of the error registry in DiagCtxtbjorn3-9/+6
And pass this to the individual emitters when necessary.
2024-12-06Rollup merge of #130777 - azhogin:azhogin/reg-struct-return, r=workingjubileeMatthias Krüger-0/+12
rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973) Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux. This flag enables the same behavior as the `abi_return_struct_as_int` target spec key. - Tracking issue: https://github.com/rust-lang/rust/issues/116973
2024-12-04Rollup merge of #133847 - nnethercote:rm-Z-show-span, r=compiler-errorsMatthias Krüger-2/+0
Remove `-Zshow-span`. It's very old (added in #12087). It's strange, and it's not clear what its use cases are. It only works with the crate root file because it runs before expansion. I suspect it won't be missed. r? `@estebank`
2024-12-04Remove `-Zshow-span`.Nicholas Nethercote-2/+0
It's very old (added in #12087). It's strange, and it's not clear what its use cases are. It only works with the crate root file because it runs before expansion. I suspect it won't be missed.
2024-12-03Rollup merge of #133545 - clubby789:symbol-intern-lit, r=jieyouxuMatthias Krüger-1/+1
Lint against Symbol::intern on a string literal Disabled in tests where this doesn't make much sense
2024-12-03Auto merge of #104342 - mweber15:add_file_location_to_more_types, r=wesleywiserbors-0/+2
Require `type_map::stub` callers to supply file information This change attaches file information (`DIFile` reference and line number) to struct debug info nodes. Before: ``` ; foo.ll ... !5 = !DIFile(filename: "<unknown>", directory: "") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0") ... ``` After: ``` ; foo.ll ... !3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f") ... ``` Fixes #98678 r? `@wesleywiser`
2024-12-02`impl Default for EarlyDiagCtxt`jyn-0/+6
for small rustc_driver programs, most of their imports will currently be related to diagnostics. this change simplifiers their code so it's more clear what in the driver is modified from the default. this is especially important for external drivers which are out of tree and not updated in response to breaking changes. for these drivers, each import is a liability for future code, since it can be broken when refactors happen. here is an example driver which is simplified by these changes: ``` diff --git a/src/main.rs b/src/main.rs index f81aa3e..11e5f18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,8 @@ #![feature(rustc_private)] extern crate rustc_driver; extern crate rustc_interface; -extern crate rustc_errors; -extern crate rustc_session; use rustc_driver::Callbacks; -use rustc_errors::{emitter::HumanReadableErrorType, ColorConfig}; use rustc_interface::interface; -use rustc_session::config::ErrorOutputType; -use rustc_session::EarlyDiagCtxt; struct DisableSafetyChecks; @@ -26,11 +18,7 @@ fn main() { "https://github.com/jyn514/jyn514.github.io/issues/new", |_| (), ); - let handler = EarlyDiagCtxt::new(ErrorOutputType::HumanReadable( - HumanReadableErrorType::Default, - ColorConfig::Auto, - )); - rustc_driver::init_rustc_env_logger(&handler); + rustc_driver::init_rustc_env_logger(&Default::default()); std::process::exit(rustc_driver::catch_with_exit_code(move || { let args: Vec<String> = std::env::args().collect(); rustc_driver::RunCompiler::new(&args, &mut DisableSafetyChecks).run() ```
2024-12-02rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973)Andrew Zhogin-0/+12
2024-11-29Update `-Zshow-span` help message.Nicholas Nethercote-1/+1
To clarify how it works.
2024-11-29Rename `-Zparse-only`.Nicholas Nethercote-4/+5
I was surprised to find that running with `-Zparse-only` only parses the crate root file. Other files aren't parsed because that happens later during expansion. This commit renames the option and updates the help message to make this clearer.
2024-11-28Replace `Symbol::intern` calls with preinterned symbolsclubby789-1/+1
2024-11-26Remove -Zfuel.Camille GILLOT-92/+1
2024-11-22Rollup merge of #133159 - Zalathar:unstable-options-no-value, r=jieyouxuMichael Goulet-19/+29
Don't allow `-Zunstable-options` to take a value Passing an explicit boolean value (`-Zunstable-options=on`, `off` etc.) sometimes appears to work, but actually puts the compiler into an unintended state where unstable _options_ are still forbidden, but unstable values of _some_ stable options are allowed. This is a result of `-Zunstable-options` being checked in multiple different places, in slightly different ways. Fixing the checks in `config::nightly_options` to understand boolean values would be non-trivial, so for now it's easier to make things consistent by forbidding values in the `-Z` parser. --- There were a few uses of this in tests, which happened to work because they were tests of unstable values.
2024-11-21Rollup merge of #130236 - yaahc:unstable-feature-usage, r=estebankMatthias Krüger-2/+2
unstable feature usage metrics example output ``` test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1 ❯ cat src/lib.rs ───────┬─────────────────────────────────────────────────────── │ File: src/lib.rs ───────┼─────────────────────────────────────────────────────── 1 │ #![feature(unix_set_mark)] 2 │ pub fn add(left: u64, right: u64) -> u64 { 3 │ left + right 4 │ } 5 │ 6 │ #[cfg(test)] 7 │ mod tests { 8 │ use super::*; 9 │ 10 │ #[test] 11 │ fn it_works() { 12 │ let result = add(2, 2); 13 │ assert_eq!(result, 4); 14 │ } 15 │ } ───────┴─────────────────────────────────────────────────────── test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1 ❯ cargo +stage1 rustc -- -Zmetrics-dir=$PWD/metrics Compiling test-lib v0.1.0 (/home/yaahc/tmp/test-lib) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1 ❯ cat metrics/unstable_feature_usage.json ───────┬───────────────────────────────────────────────────────────────────── │ File: metrics/unstable_feature_usage.json ───────┼───────────────────────────────────────────────────────────────────── 1 │ {"lib_features":[{"symbol":"unix_set_mark"}],"lang_features":[]} ``` related to https://github.com/rust-lang/rust/issues/129485
2024-11-20unstable feature usage metricsJane Losare-Lusby-2/+2