about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2024-03-05Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwcobors-8/+8
Diagnostic renaming 2 A sequel to #121489. r? `@davidtwco`
2024-03-05Fix some out-of-date comments.Nicholas Nethercote-4/+4
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-4/+4
2024-03-04Remove some depgraph edges on the HIR by invoking the intrinsic query ↵Oli Scherer-2/+1
instead of checking the attribute
2024-03-04Add a scheme for moving away from `extern "rust-intrinsic"` entirelyOli Scherer-0/+5
2024-03-01Add initial support for DataFlowSanitizerRamon de C Valle-0/+8
Adds initial support for DataFlowSanitizer to the Rust compiler. It currently supports `-Zsanitizer-dataflow-abilist`. Additional options for it can be passed to LLVM command line argument processor via LLVM arguments using `llvm-args` codegen option (e.g., `-Cllvm-args=-dfsan-combine-pointer-labels-on-load=false`).
2024-03-01Rollup merge of #121730 - ecnelises:aix_pgo, r=wesleywiserMatthias Krüger-1/+3
Add profiling support to AIX AIX ld needs special option to merge objects with profiling. Also, profiler_builtins should include builtins for AIX from compiler-rt.
2024-02-29Rollup merge of #121464 - alexcrichton:fix-wasm64, r=wesleywiserMatthias Krüger-50/+46
rustc: Fix wasm64 metadata object files It looks like LLD will detect object files being either 32 or 64-bit depending on any memory present. LLD will additionally reject 32-bit objects during a 64-bit link. Previously metadata objects did not have any memories in them which led LLD to conclude they were 32-bit objects which broke 64-bit targets for wasm. This commit fixes this by ensuring that for 64-bit targets there's a memory object present to get LLD to detect it's a 64-bit target. Additionally this commit moves away from a hand-crafted wasm encoder to the `wasm-encoder` crate on crates.io as the complexity grows for the generated object file. Closes #121460
2024-02-29Rename `DiagCtxt::with_emitter` as `DiagCtxt::new`.Nicholas Nethercote-1/+1
Because it's now the only constructor.
2024-02-28Add profiling support to AIXQiu Chaofan-1/+3
AIX ld needs special option to merge objects with profiling. Also, profiler_builtins should include builtins for AIX from compiler-rt.
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-3/+3
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-3/+3
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-28Rename `SubDiagnostic` as `Subdiag`.Nicholas Nethercote-1/+1
Note the change of the `D` to `d`, to match all the other names that have `Subdiag` in them, such as `SubdiagnosticMessage` and `derive(Subdiagnostic)`.
2024-02-28Rename `Diagnostic` as `DiagInner`.Nicholas Nethercote-3/+3
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
2024-02-27Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, ↵bors-4/+4
r=nnethercote Remove useless lifetime of ArchiveBuilder `trait ArchiveBuilder<'a>` has a seemingly useless lifetime a, so I remove it. If this is intentional, please reject this PR. ```rust pub trait ArchiveBuilder<'a> { fn add_file(&mut self, path: &Path); fn add_archive( &mut self, archive: &Path, skip: Box<dyn FnMut(&str) -> bool + 'static>, ) -> io::Result<()>; fn build(self: Box<Self>, output: &Path) -> bool; } ```
2024-02-26remove useless lifetime of ArchiveBuilder823984418-4/+4
2024-02-23rustc: Fix wasm64 metadata object filesAlex Crichton-50/+46
It looks like LLD will detect object files being either 32 or 64-bit depending on any memory present. LLD will additionally reject 32-bit objects during a 64-bit link. Previously metadata objects did not have any memories in them which led LLD to conclude they were 32-bit objects which broke 64-bit targets for wasm. This commit fixes this by ensuring that for 64-bit targets there's a memory object present to get LLD to detect it's a 64-bit target. Additionally this commit moves away from a hand-crafted wasm encoder to the `wasm-encoder` crate on crates.io as the complexity grows for the generated object file. Closes #121460
2024-02-23remove repetitive wordscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-02-22Auto merge of #121129 - nnethercote:codegen-Diags, r=estebankbors-29/+61
Improve codegen diagnostic handling Clarify the workings of the temporary `Diagnostic` type used to send diagnostics from codegen threads to the main thread. r? `@estebank`
2024-02-22Remove `SharedEmitterMessage::AbortIfErrors`.Nicholas Nethercote-5/+1
It's always paired wth `SharedEmitterMessage::Diagnostic`, so the two can be merged.
2024-02-22Overhaul `rustc_codegen_ssa::back::write::Diagnostic`.Nicholas Nethercote-22/+58
- Make it more closely match `rustc_errors::Diagnostic`, by making the field names match, and adding `children`, which requires adding `rustc_codegen_ssa::back::write::Subdiagnostic`. - Check that we aren't missing important info when converting diagnostics. - Add better comments. - Tweak `rustc_errors::Diagnostic::replace_args` so that we don't need to do any cloning when converting diagnostics.
2024-02-22Overhaul `Diagnostic` args.Nicholas Nethercote-6/+6
First, introduce a typedef `DiagnosticArgMap`. Second, make the `args` field public, and remove the `args` getter and `replace_args` setter. These were necessary previously because the getter had a `#[allow(rustc::potential_query_instability)]` attribute, but that was removed in #120931 when the args were changed from `FxHashMap` to `FxIndexMap`. (All the other `Diagnostic` fields are public.)
2024-02-21Rollup merge of #121399 - psumbera:solaris-strip-debug, r=petrochenkovMatthias Krüger-1/+1
Solaris linker does not support --strip-debug Fixes #121381
2024-02-22Replace unnecessary `abort_if_errors`.Nicholas Nethercote-6/+3
Replace `abort_if_errors` calls that are certain to abort -- because we emit an error immediately beforehand -- with `FatalErro.raise()`.
2024-02-22Inline and remove `Session::compile_status`.Nicholas Nethercote-1/+3
Because it's now simple enough that it doesn't provide much benefit.
2024-02-21Solaris linker does not support --strip-debugPetr Sumbera-1/+1
Fixes #121381
2024-02-20wasm: Store rlib metadata in wasm object filesAlex Crichton-20/+68
The goal of this commit is to remove warnings using LLVM tip-of-tree `wasm-ld`. In llvm/llvm-project#78658 the `wasm-ld` LLD driver no longer looks at archive indices and instead looks at all the objects in archives. Previously `lib.rmeta` files were simply raw rustc metadata bytes, not wasm objects, meaning that `wasm-ld` would emit a warning indicating so. WebAssembly targets previously passed `--fatal-warnings` to `wasm-ld` by default which meant that if Rust were to update to LLVM 18 then all wasm targets would not work. This immediate blocker was resolved in rust-lang/rust#120278 which removed `--fatal-warnings` which enabled a theoretical update to LLVM 18 for wasm targets. This current state is ok-enough for now because rustc squashes all linker output by default if it doesn't fail. This means, for example, that rustc squashes all the linker warnings coming out of `wasm-ld` about `lib.rmeta` files with LLVM 18. This again isn't a pressing issue because the information is all hidden, but it runs the risk of being annoying if another linker error were to happen and then the output would have all these unrelated warnings that couldn't be fixed. Thus, this PR comes into the picture. The goal of this PR is to resolve these warnings by using the WebAssembly object file format on wasm targets instead of using raw rustc metadata. When I first implemented the rlib-in-objects scheme in #84449 I remember either concluding that `wasm-ld` would either include the metadata in the output or I thought we didn't have to do anything there at all. I think I was wrong on both counts as `wasm-ld` does not include the metadata in the final output unless the object is referenced and we do actually need to do something to resolve these warnings. This PR updates the object file format containing rustc metadata on WebAssembly targets to be an actual WebAssembly file. This enables the `wasm` feature of the `object` crate to be able to read the custom section in the same manner as other platforms, but currently `object` doesn't support writing wasm object files so a handwritten encoder is used instead. The only caveat I know of with this is that if `wasm-ld` does indeed look at the object file then the metadata will be included in the final output. I believe the only thing that could cause that at this time is `--whole-archive` which I don't think is passed for rlibs. I would clarify that I'm not 100% certain about this, however.
2024-02-20Reduce capabilities of `Diagnostic`.Nicholas Nethercote-3/+1
Currently many diagnostic modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`. This commit removes most of them from `Diagnostic`. To minimize the diff size, it keeps them within `diagnostic.rs` but changes the surrounding `impl Diagnostic` block to `impl DiagnosticBuilder`. (I intend to move things around later, to give a more sensible code layout.) `Diagnostic` keeps a few methods that it still needs, like `sub`, `arg`, and `replace_args`. The `forward!` macro, which defined two additional methods per call (e.g. `note` and `with_note`), is replaced by the `with_fn!` macro, which defines one additional method per call (e.g. `with_note`). It's now also only used when necessary -- not all modifier methods currently need a `with_*` form. (New ones can be easily added as necessary.) All this also requires changing `trait AddToDiagnostic` so its methods take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`. There are three subdiagnostics -- `DelayedAtWithoutNewline`, `DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` -- that are created within the diagnostics machinery and appended to external diagnostics. These are handled at the `Diagnostic` level, which means it's now hard to construct them via `derive(Diagnostic)`, so instead we construct them by hand. This has no effect on what they look like when printed. There are lots of new `allow` markers for `untranslatable_diagnostics` and `diagnostics_outside_of_impl`. This is because `#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic` modifier methods, but missing from the `DiagnosticBuilder` modifier methods. They're now present.
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-19/+15
2024-02-09Turn the "no saved object file in work product" ICE into a translatable ↵Ben Kimock-1/+3
fatal error
2024-02-05Make `Emitter::emit_diagnostic` consuming.Nicholas Nethercote-1/+1
All the other `emit`/`emit_diagnostic` methods were recently made consuming (e.g. #119606), but this one wasn't. But it makes sense to. Much of this is straightforward, and lots of `clone` calls are avoided. There are a couple of tricky bits. - `Emitter::primary_span_formatted` no longer takes a `Diagnostic` and returns a pair. Instead it takes the two fields from `Diagnostic` that it used (`span` and `suggestions`) as `&mut`, and modifies them. This is necessary to avoid the cloning of `diag.children` in two emitters. - `from_errors_diagnostic` is rearranged so various uses of `diag` occur before the consuming `emit_diagnostic` call.
2024-02-03Use `DiagnosticArgName` in a few more places.Nicholas Nethercote-2/+1
2024-02-03Remove some unnecessary `clone` calls.Nicholas Nethercote-1/+1
2024-01-30Rollup merge of #120485 - chenyukang:yukang-add-query-instability-check, ↵Guillaume Gomez-0/+1
r=michaelwoerister add missing potential_query_instability for keys and values in hashmap From https://github.com/rust-lang/rust/pull/120435#discussion_r1468883787, These API are also returning iterator, so we need add `potential_query_instability` for them?
2024-01-30Remove the lifetime from `DiagnosticArgName`.Nicholas Nethercote-1/+1
Because it's always 'static.
2024-01-30Remove `DiagnosticArgName` from `rustc_codegen_ssa`.Nicholas Nethercote-8/+9
It's identical to the one in `rustc_errors`; use that instead. Also remove some `rustc_errors::` qualifiers.
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-2/+2
Because it's almost always static. This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial, which is nice. There are a few diagnostics constructed in `compiler/rustc_mir_build/src/check_unsafety.rs` and `compiler/rustc_mir_transform/src/errors.rs` that now need symbols converted to `String` with `to_string` instead of `&str` with `as_str`, but that' no big deal, and worth it for the simplifications elsewhere.
2024-01-30add missing potential_query_instability for keys and values in hashmapyukang-0/+1
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-2/+2
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-24linker: Fix Rust dylib crate extension on windows-msvcVadim Petrochenkov-1/+5
2024-01-24linker: Cleanup implementations of `link_staticlib_*`Vadim Petrochenkov-23/+24
2024-01-24linker: Merge `link_staticlib_*` and `link_whole_staticlib_*`Vadim Petrochenkov-130/+86
2024-01-24linker: Do not collect search paths unless necessaryVadim Petrochenkov-21/+29
2024-01-24linker: Group library linking methods together and sort them consistentlyVadim Petrochenkov-171/+180
2024-01-24linker: Refactor APIs for linking static librariesVadim Petrochenkov-69/+114
Rename `link(_whole)(staticlib,rlib)` to something more suitable.
2024-01-24linker: Refactor APIs for linking dynamic librariesVadim Petrochenkov-93/+33
Rename `link_(dylib,framework)`, remove `link_rust_dylib`.
2024-01-14Rework how diagnostic lints are stored.Nicholas Nethercote-2/+2
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not.
2024-01-13Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, ↵bors-1/+1
r=Nilstrieb Suggest Upgrading Compiler for Gated Features This PR addresses #117318 I have a few questions: 1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag a. How can I handle the changing message in the tests? 3. Do we want to only show this message when the compiler is old? a. How can we determine when the compiler is old? I'll wait until we figure out the message to bless the tests
2024-01-13Auto merge of #119409 - Kobzol:rustc-codegen-ssa-query-instability, r=Nilstriebbors-2/+14
rustc_codegen_ssa: Enforce `rustc::potential_query_instability` lint Part of https://github.com/rust-lang/rust/issues/84447.
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-1/+1