summary refs log tree commit diff
path: root/compiler/rustc_session/src/session.rs
AgeCommit message (Collapse)AuthorLines
2024-10-10Avoid redundant additions to PATH when linkingMads Marquart-0/+2
2024-10-01Replace -Z default-hidden-visibility with -Z default-visibilityDavid Lattimore-5/+7
MCP: https://github.com/rust-lang/compiler-team/issues/782 Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-09-15Rollup merge of #129897 - RalfJung:soft-float-ignored, r=UrgauMatthias Krüger-0/+10
deprecate -Csoft-float because it is unsound (and not fixable) See https://github.com/rust-lang/rust/issues/129893 for details. The general sentiment there seems to be that this flag has no use and sound alternatives exist, so let's add this warning and see if anyone out there disagrees. Also show a different warning on targets where it does nothing (as documented since https://github.com/rust-lang/rust/pull/36261): it seems to correspond to `-mfloat-abi` in GCC/clang, which is an ARM-specific option. To be really sure it does nothing, only forward the flag to LLVM for eabihf targets. This should not change behavior but makes me sleep better ;)
2024-09-10Add -Z small-data-thresholdPaul Menage-2/+10
This flag allows specifying the threshold size above which LLVM should not consider placing small objects in a .sdata or .sbss section. Support is indicated in the target options via the small-data-threshold-support target option, which can indicate either an LLVM argument or an LLVM module flag. To avoid duplicate specifications in a large number of targets, the default value for support is DefaultForArch, which is translated to a concrete value according to the target's architecture.
2024-09-03deprecate -Csoft-float because it is unsound (and not fixable)Ralf Jung-0/+10
2024-08-27Rollup merge of #129418 - petrochenkov:libsearch2, r=jieyouxuTrevor Gross-14/+2
rustc: Simplify getting sysroot library directory It was very non-obvious that `sess.target_tlib_path`, `make_target_lib_path(...)`, and `sess.target_filesearch(...).search_paths()` result in the same sysroot library directory paths. They are however, indeed the same, because `sess.target_tlib_path` is initialized to `make_target_lib_path(...)` on `Session` creation, and they are used interchangeably. There are still some redundant calls to `make_target_lib_path` and other inconsistent ways to obtain sysroot directories, but fixing that requires some behavior changes, while this PR is a pure refactoring. Some places in the compiler even disagree on the number of sysroots - 1 (explicit `--sysroot` *or* default sysroot), 2 (explicit `--sysroot` *and* default sysroot), or an unclear number of `sysroot_candidates` every of which is considered. The logic currently using `sess.target_tlib_path` or equivalents assumes one sysroot.
2024-08-27Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwcoTrevor Gross-2/+16
Implement `-Z embed-source` (DWARFv5 source code embedding extension) Implement https://github.com/rust-lang/compiler-team/issues/764 MCP which adds an unstable flag that exposes LLVM's [DWARFv5 source code embedding](https://dwarfstd.org/issues/180201.1.html) support.
2024-08-22rustc: Simplify getting sysroot library directoryVadim Petrochenkov-14/+2
2024-08-15Rollup merge of #128348 - ↵Matthias Krüger-1/+6
dingxiangfei2009:allow-shadow-call-stack-sanitizer, r=tmandry Unconditionally allow shadow call-stack sanitizer for AArch64 It is possible to do so whenever `-Z fixed-x18` is applied. cc ``@Darksonn`` for context The reasoning is that, as soon as reservation on `x18` is forced through the flag `fixed-x18`, on AArch64 the option to instrument with [Shadow Call Stack sanitizer](https://clang.llvm.org/docs/ShadowCallStack.html) is then applicable regardless of the target configuration. At the every least, we would like to relax the restriction on specifically `aarch64-unknonw-none`. For this option, we can include a documentation change saying that users of compiled objects need to ensure that they are linked to runtime with Shadow Call Stack instrumentation support. Related: #121972
2024-08-09unconditionally allow shadow call-stack for AArch64 whenever fixed-x18 is ↵Ding Xiang Fei-1/+6
applied
2024-08-08review commentsEsteban Küber-2/+2
2024-08-08Split `ColorConfig` off of `HumanReadableErrorType`Esteban Küber-13/+17
The previous setup tied two unrelated things together. Splitting these two is a better model.
2024-08-06-Zembed-source: Don't try to warn about incompatible codegen backendsMrmaxmeier-7/+0
2024-07-29Add `-Z embed-source=yes` to embed source code in DWARF debug infoMrmaxmeier-2/+23
2024-07-29Reformat `use` declarations.Nicholas Nethercote-24/+22
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-18Auto merge of #126623 - oli-obk:do_not_count_errors, r=davidtwcobors-13/+13
Replace all `&DiagCtxt` with a `DiagCtxtHandle<'_>` wrapper type r? `@davidtwco` This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle Basically I will add a field to the `DiagCtxtHandle` that refers back to the `InferCtxt`'s (and others) `Option<ErrorHandled>`, allowing us to immediately taint these contexts when emitting an error and not needing manual tainting anymore (which is easy to forget and we don't do in general anyway)
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-12/+12
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18Prefer `dcx` methods over fields or fields' methodsOli Scherer-1/+1
2024-06-17coverage: Add debugging flag `-Zcoverage-options=no-mir-spans`Zalathar-0/+5
When set, this flag skips the code that normally extracts coverage spans from MIR statements and terminators. That sometimes makes it easier to debug branch coverage and MC/DC coverage, because the coverage output is less noisy. For internal debugging only. If other code changes would make it hard to keep supporting this flag, remove it.
2024-05-30coverage: Add CLI support for `-Zcoverage-options=condition`Dorian Péron-0/+5
2024-05-23Rollup merge of #125263 - lqd:lld-fallback, r=petrochenkovGuillaume Gomez-8/+17
rust-lld: fallback to rustc's sysroot if there's no path to the linker in the target sysroot As seen in #125246, some sysroots don't expect to contain `rust-lld` and want to keep it that way, so we fallback to the default rustc sysroot if there is no path to the linker in any of the sysroot tools search paths. This is how we locate codegen-backends' dylibs already. People also have requested an error if none of these search paths contain the self-contained linker directory, so there's also an error in that case. r? `@petrochenkov` cc `@ehuss` `@RalfJung` I'm not sure where we check for `rust-lld`'s existence on the targets where we use it by default, and if we just ignore it when missing or emit a warning (as I assume we don't emit an error), so I just checked for the existence of `gcc-ld`, where `cc` will look for the lld-wrapper binaries. <sub>*Feel free to point out better ways to do this, it's the middle of the night here.*</sub> Fixes #125246
2024-05-23rust-lld: fallback to the default default sysroot where rustc is currently ↵Rémy Rakic-8/+17
located
2024-05-21Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvallebors-11/+3
Relax restrictions on multiple sanitizers Most combinations of LLVM sanitizers are legal-enough to enable simultaneously. This change will allow simultaneously enabling ASAN and shadow call stacks on supported platforms. I used this python script to generate the mutually-exclusive sanitizer combinations: ```python #!/usr/bin/python3 import subprocess flags = [ ["-fsanitize=address"], ["-fsanitize=leak"], ["-fsanitize=memory"], ["-fsanitize=thread"], ["-fsanitize=hwaddress"], ["-fsanitize=cfi", "-flto", "-fvisibility=hidden"], ["-fsanitize=memtag", "--target=aarch64-linux-android", "-march=armv8a+memtag"], ["-fsanitize=shadow-call-stack"], ["-fsanitize=kcfi", "-flto", "-fvisibility=hidden"], ["-fsanitize=kernel-address"], ["-fsanitize=safe-stack"], ["-fsanitize=dataflow"], ] for i in range(len(flags)): for j in range(i): command = ["clang++"] + flags[i] + flags[j] + ["-o", "main.o", "-c", "main.cpp"] completed = subprocess.run(command, stderr=subprocess.DEVNULL) if completed.returncode != 0: first = flags[i][0][11:].replace('-', '').upper() second = flags[j][0][11:].replace('-', '').upper() print(f"(SanitizerSet::{first}, SanitizerSet::{second}),") ```
2024-05-15Relax restrictions on multiple sanitizersDavid Koloski-11/+3
Most combinations of LLVM sanitizers are legal-enough to enable simultaneously. This change will allow simultaneously enabling ASAN and shadow call stacks on supported platforms.
2024-04-29coverage: Replace boolean options with a `CoverageLevel` enumZalathar-4/+6
2024-04-19coverage. Add coverage-options=mcdc as gate for MC/DC instrumentzhuyunxing-0/+4
2024-04-16Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkinGuillaume Gomez-27/+7
Move `SourceMap` initialization So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward. r? `@WaffleLapkin`
2024-04-16Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-SimulacrumGuillaume Gomez-1/+1
sess: stabilize `-Zrelro-level` as `-Crelro-level` Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-16Move `initialize_checked_jobserver`.Nicholas Nethercote-10/+4
Currently it's a method on `EarlyDiagCtxt`, which is not the right place for it at all -- `EarlyDiagCtxt` is used to issue diagnostics, but shouldn't be doing any of the actual checking. This commit moves it into a standalone function that takes an `EarlyDiagCtxt` as an argument, which is more sensible. This does require adding `EarlyDiagCtxt::early_struct_warn`, so a warning can be returned and then modified with a note. (And that likely explains why somebody put `initialize_checked_jobserver` into `EarlyDiagCtxt` in the first place.)
2024-04-16Construct `SourceMap` at the same time as `SessionGlobals`.Nicholas Nethercote-17/+3
Currently `SourceMap` is constructed slightly later than `SessionGlobals`, and inserted. This commit changes things so they are done at the same time. Benefits: - `SessionGlobals::source_map` changes from `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still optional, but mutability isn't required because it's initialized at construction. - `set_source_map` is removed, simplifying `run_compiler`, which is good because that's a critical function and it's nice to make it simpler. This requires moving things around a bit, so the necessary inputs are available when `SessionGlobals` is created, in particular the `loader` and `hash_kind`, which are no longer computed by `build_session`. These inputs are captured by the new `SourceMapInputs` type, which is threaded through various places.
2024-04-06Put checks that detect UB under their own flag below debug_assertionsBen Kimock-0/+4
2024-03-30Rollup merge of #123200 - maurer:kcfi-abort, r=compiler-errorsMatthias Krüger-0/+5
KCFI: Require -C panic=abort While the KCFI scheme is not incompatible with unwinding, LLVM's `invoke` instruction does not currently support KCFI bundles. While it likely will in the near future, we won't be able to assume that in Rust for a while. We encountered this problem while [turning on closure support](https://github.com/rust-lang/rust/pull/123106#issuecomment-2027436640). r? ``@workingjubilee``
2024-03-29KCFI: Require -C panic=abortMatthew Maurer-0/+5
While the KCFI scheme is not incompatible with unwinding, LLVM's `invoke` instruction does not currently support KCFI bundles. While it likely will in the near future, we won't be able to assume that in Rust for a while.
2024-03-28Replace Session should_remap_filepaths with filename_display_preferenceUrgau-3/+14
2024-03-28Introduce `FileNameMapping::to_real_filename` and use it everywhereUrgau-2/+1
2024-03-28Make local_crate_source_file return a RealFileNameUrgau-7/+3
so it can be remapped (or not) by callers
2024-03-28Replace `RemapFileNameExt::for_codegen` with explicit callsUrgau-24/+5
2024-03-28Simplify trim-paths feature by merging all debuginfo options togetherUrgau-31/+1
2024-03-21Rename some `target_cfg` variables as `target`.Nicholas Nethercote-5/+4
Because the underlying type is called `Target`. (There is also a separate type called `TargetCfg`.)
2024-03-13coverage: Add `-Zcoverage-options` for fine control of coverageZalathar-0/+4
This new nightly-only flag can be used to toggle fine-grained flags that control the details of coverage instrumentation. Currently the only supported flag value is `branch` (or `no-branch`), which is a placeholder for upcoming support for branch coverage. Other flag values can be added in the future, to prototype proposed new behaviour, or to enable special non-default behaviour.
2024-03-13coverage: Remove all unstable values of `-Cinstrument-coverage`Zalathar-12/+0
2024-03-12sess: stabilize relro-levelDavid Wood-1/+1
Signed-off-by: David Wood <david@davidtw.co>
2024-03-11Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillotJubilee-7/+2
Allow targets to override default codegen backend Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-7/+3
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-3/+3
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-06Rollup merge of #121959 - sundeep-kokkonda:patch-2, r=davidtwcoMatthias Krüger-13/+0
Removing absolute path in proc-macro With rust 1.75 the absolute build path name is embedding into proc-macro (.rustc section) and which causes reproducibility issues. Detailed issue description is here - https://github.com/rust-lang/rust/issues/120825#issuecomment-1964307219 With this change the 'absolute path' changed back to '/rust/$hash' format as in earlier revisions.
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-0/+2
r=davidtwco Rework `untranslatable_diagnostic` lint Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`. r? ``@davidtwco``
2024-03-06Change the documented implicit value of `-C instrument-coverage` to `=yes`Zalathar-1/+1
2024-03-06Add missing `#[rustc_lint_diagnostics]` attributes.Nicholas Nethercote-0/+1
Prior to the previous commit, `#[rust_lint_diagnostics]` attributes could only be used on methods with an `impl Into<{D,Subd}iagMessage>` parameter. But there are many other nearby diagnostic methods (e.g. `Diag::span`) that don't take such a parameter and should have the attribute. This commit adds the missing attribute to these `Diag` methods. This requires adding some missing `#[allow(rustc::diagnostic_outside_of_impl)]` markers at call sites to these methods.