about summary refs log tree commit diff
path: root/compiler/rustc_session/src/session.rs
AgeCommit message (Collapse)AuthorLines
2025-10-02Fix backtraces with `-C panic=abort` on linux; emit unwind tables by defaultMartin Nordholts-1/+2
The linux backtrace unwinder relies on unwind tables to work properly, and generating and printing a backtrace is done by for example the default panic hook. Begin emitting unwind tables by default again with `-C panic=abort` (see history below) so that backtraces work. History ======= Backtraces with `-C panic=abort` used to work in Rust 1.22 but broke in Rust 1.23, because in 1.23 we stopped emitting unwind tables with `-C panic=abort` (see 24cc38e3b00). In 1.45 (see cda994633ee) a workaround in the form of `-C force-unwind-tables=yes` was added. `-C panic=abort` was added in [Rust 1.10](https://blog.rust-lang.org/2016/07/07/Rust-1.10/#what-s-in-1-10-stable) and the motivation was binary size and compile time. But given how confusing that behavior has turned out to be, it is better to make binary size optimization opt-in with `-C force-unwind-tables=no` rather than default since the current default breaks backtraces. Besides, if binary size is a primary concern, there are many other tricks that can be used that has a higher impact.
2025-09-21Add panic=immediate-abortBen Kimock-4/+6
2025-09-18Set lto="fat" automatically when compiling with RUSTFLAGS="-Zautodiff=Enable".Haidong Zhang-0/+7
2025-09-08fixup limit handling codeJana Dönszelmann-60/+2
2025-08-24Support lints in early attribute parsingJana Dönszelmann-1/+16
2025-08-19mention lint group in default level lint noteKarol Zwolak-2/+19
2025-08-17Add `-Zindirect-branch-cs-prefix` optionMiguel Ojeda-0/+6
This is intended to be used for Linux kernel RETPOLINE builds. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-08-06coverage: Remove all unstable support for MC/DC instrumentationZalathar-5/+0
2025-08-04coverage: Simplify access to debug/testing `-Zcoverage-options` flagsZalathar-5/+7
2025-08-04coverage: Remove `-Zcoverage-options=no-mir-spans`Zalathar-5/+0
This flag turned out to be less useful than anticipated, and interferes with work towards expansion support.
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-5/+5
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in mir, resolve, targetKivooeo-5/+5
2025-07-25Allow pretty printing paths with `-Zself-profile-events=args`Jakub Beránek-0/+1
2025-07-07compiler: Deduplicate `must_emit_unwind_tables()` commentsMartin Nordholts-1/+8
There is one comment at a call site and one comment in the function definition that are mostly saying the same thing. Fold the call site comment into the function definition comment to reduce duplication. There are actually some inaccuracies in the comments but let's deduplicate before we address the inaccuracies.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-06-24rustc_session: Add a structure for keeping both explicit and default sysrootsVadim Petrochenkov-8/+8
Also avoid creating and cloning sysroot unnecessarily.
2025-06-19Extract Translator structCameron Steffen-24/+20
2025-06-16Add infrastructure for emitting timing sectionsJakub Beránek-0/+7
2025-06-15Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, ↵León Orell Valerian Liehr-7/+0
r=workingjubilee,saethlin Move metadata object generation for dylibs to the linker code This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time. Prerequisite of https://github.com/rust-lang/rust/issues/96708.
2025-06-05Replace all uses of sysroot_candidates with get_or_default_sysrootbjorn3-5/+1
Before this change we had two different ways to attempt to locate the sysroot which are inconsistently used: * get_or_default_sysroot which tries to locate based on the 0th cli argument and if that doesn't work falls back to locating it using the librustc_driver.so location and returns a single path., * sysroot_candidates which takes the former and additionally does another attempt at locating using librustc_driver.so except without linux multiarch handling and then returns both paths., The latter was originally introduced to be able to locate the codegen backend back when cg_llvm was dynamically linked even for a custom driver when the --sysroot passed in does not contain a copy of cg_llvm. Back then get_or_default_sysroot did not attempt to locate the sysroot based on the location of librustc_driver.so yet. Because that is now done, the only case where removing sysroot_candidates can break things is if you have a custom driver inside what looks like a sysroot including the lib/rustlib directory, but which is missing some parts of the full sysroot like eg rust-lld.
2025-06-03Move metadata object generation for dylibs to the linker codebjorn3-7/+0
This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.
2025-05-27coverage: Revert "unused local file IDs" due to empty function namesZalathar-5/+0
This reverts commit 3b22c21dd8c30f499051fe7a758ca0e5d81eb638, reversing changes made to 5f292eea6d63abbd26f1e6e00a0b8cf21d828d7d.
2025-05-10coverage: Detect unused local file IDs to avoid an LLVM assertionZalathar-0/+5
This case can't actually happen yet (other than via a testing flag), because currently all of a function's spans must belong to the same file and expansion. But this will be an important edge case when adding expansion region support.
2025-04-14Stabilize `-Zdwarf-version` as `-Cdwarf-version`Wesley Wiser-2/+8
2025-04-07Prepend temp files with a string per invocation of rustcMichael Goulet-0/+17
2025-04-06Auto merge of #138947 - madsmtm:refactor-apple-versions, r=Noratriebbors-1/+40
Refactor Apple version handling in the compiler Move various Apple version handling code in the compiler out `rustc_codegen_ssa` and into a place where it can be accessed by `rustc_attr_parsing`, which I found to be necessary when doing https://github.com/rust-lang/rust/pull/136867. Thought I'd split it out to make it easier to land, and to make further changes like https://github.com/rust-lang/rust/pull/131477 have fewer conflicts / PR dependencies. There should be no functional changes in this PR. `@rustbot` label O-apple r? rust-lang/compiler
2025-04-05KCFI: Add KCFI arity indicator supportRamon de C Valle-0/+9
Adds KCFI arity indicator support to the Rust compiler (see rust-lang/rust#138311, https://github.com/llvm/llvm-project/pull/121070, and https://lore.kernel.org/lkml/CANiq72=3ghFxy8E=AU9p+0imFxKr5iU3sd0hVUXed5BA+KjdNQ@mail.gmail.com/).
2025-04-04refactor: Move env parsing of deployment target to rustc_sessionMads Marquart-1/+40
2025-03-25rustc_session: Add a helper function for obtaining staticlib prefix and suffixVadim Petrochenkov-0/+8
2025-03-12Remove unused host_tlib_path fieldbjorn3-2/+1
2025-03-07Remove highlighting of spans on `-Zteach`Esteban Küber-1/+0
`-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
2025-03-03Use default field values for `ErrorOutputType`Esteban Küber-2/+2
Remove manual `Default` impl from `config::ErrorOutputType`.
2025-02-25Teach structured errors to display short `Ty`Esteban Küber-2/+2
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to. ``` error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)`` --> long.rs:7:5 | 6 | fn foo(x: D) { //~ `x` has type `(... | - `x` has type `((..., ..., ..., ...), ..., ..., ...)` 7 | x(); //~ ERROR expected function, found `(... | ^-- | | | call expression requires function | = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt' = note: consider using `--verbose` to print the full type name to the console ```
2025-02-22Fix binding mode problemsMichael Goulet-2/+1
2025-02-17Add `pattern_complexity_limit` to `Limits`.Nicholas Nethercote-0/+7
It's similar to the other limits, e.g. obtained via `get_limit`. So it makes sense to handle it consistently with the other limits. We now use `Limit`/`usize` in most places instead of `Option<usize>`, so we use `Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work. The commit also adds `Limit::unlimited`.
2025-02-09Emit an error if `-Zdwarf-version=1` is requestedWesley Wiser-1/+2
DWARF 1 is very different than DWARF 2+ (see the commentary in https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf) and LLVM does not really seem to support DWARF 1 as Clang does not offer a `-gdwarf-1` flag and `llc` will just generate DWARF 2 with the version set to 1: https://godbolt.org/z/s85d87n3a. Since this isn't actually supported (and it's not clear it would be useful anyway), report that DWARF 1 is not supported if it is requested. Also add a help message to the error saying which versions are supported.
2025-02-06Construct DiagCtxt a bit earlier in build_sessionbjorn3-12/+6
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-14/+12
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-03Contracts core intrinsics.Felix S. Klock II-0/+4
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-14/+12
2025-02-02Some cleanups around EarlyDiagCtxtbjorn3-11/+4
All callers of EarlyDiagCtxt::early_error now emit a fatal error.
2025-01-29Clean up uses of the unstable `dwarf_version` optionWesley Wiser-2/+6
- Consolidate calculation of the effective value. - Check the target `DebuginfoKind` instead of using `is_like_msvc`.
2025-01-25Auto merge of #119286 - jyn514:linker-output, r=bjorn3bors-3/+6
show linker output even if the linker succeeds Show stderr and stderr by default, controlled by a new `linker_messages` lint. fixes https://github.com/rust-lang/rust/issues/83436. fixes https://github.com/rust-lang/rust/issues/38206. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134 <!-- try-job: dist-x86_64-msvc --> try-job: aarch64-apple r? `@bjorn3`
2025-01-23Remove the need to manually call set_using_internal_featuresbjorn3-2/+2
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
2024-12-29make -Csoft-float have an effect on all ARM targetsRalf Jung-1/+1
2024-12-19coverage: Add a synthetic test for when all spans are discardedZalathar-0/+5
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-06Store a single copy of the error registry in DiagCtxtbjorn3-9/+6
And pass this to the individual emitters when necessary.