about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-03-05Change signature of `target_features_cfg`.Nicholas Nethercote-31/+37
Currently it is called twice, once with `allow_unstable` set to true and once with it set to false. This results in some duplicated work. Most notably, for the LLVM backend, `LLVMRustHasFeature` is called twice for every feature, and it's moderately slow. For very short running compilations on platforms with many features (e.g. a `check` build of hello-world on x86) this is a significant fraction of runtime. This commit changes `target_features_cfg` so it is only called once, and it now returns a pair of feature sets. This halves the number of `LLVMRustHasFeature` calls.
2025-03-03Rollup merge of #137741 - cuviper:const_str-raw_entry, r=Mark-SimulacrumMatthias Krüger-1/+1
Stop using `hash_raw_entry` in `CodegenCx::const_str` That unstable feature (#56167) completed fcp-close, so the compiler needs to be migrated away to allow its removal. In this case, `cg_llvm` and `cg_gcc` were using raw entries to optimize their `const_str_cache` lookup and insertion. We can change that to separate `get` and (on miss) `insert` calls, so we still have the fast path avoiding string allocation when the cache hits.
2025-02-27Stop using `hash_raw_entry` in `CodegenCx::const_str`Josh Stone-1/+1
That unstable feature completed fcp-close, so the compiler needs to be migrated away to allow its removal. In this case, `cg_llvm` and `cg_gcc` were using raw entries to optimize their `const_str_cache` lookup and insertion. We can change that to separate `get` and (on miss) `insert` calls, so we still have the fast path avoiding string allocation when the cache hits.
2025-02-23Save pre-link bitcode to `ModuleCodegen`DianQK-1/+1
2025-02-13Make `-O` mean `-C opt-level=3`clubby789-1/+1
2025-01-28ABI-required target features: warn when they are missing in base CPU (rather ↵Ralf Jung-2/+3
than silently enabling them)
2025-01-24Rollup merge of #135581 - EnzymeAD:refactor-codgencx, r=oli-obkMatthias Krüger-1/+0
Separate Builder methods from tcx As part of the autodiff upstreaming we noticed, that it would be nice to have various builder methods available without the TypeContext, which prevents the normal CodegenCx to be passed around between threads. We introduce a SimpleCx which just owns the llvm module and llvm context, to encapsulate them. The previous CodegenCx now implements deref and forwards access to the llvm module or context to it's SimpleCx sub-struct. This gives us a bit more flexibility, because now we can pass (or construct) the SimpleCx in locations where we don't have enough information to construct a CodegenCx, or are not able to pass it around due to the tcx lifetimes (and it not implementing send/sync). This also introduces an SBuilder, similar to the SimpleCx. The SBuilder uses a SimpleCx, whereas the existing Builder uses the larger CodegenCx. I will push updates to make implementations generic (where possible) to be implemented once and work for either of the two. I'll also clean up the leftover code. `call` is a bit tricky, because it requires a tcx, I probably need to duplicate it after all. Tracking: - https://github.com/rust-lang/rust/issues/124509
2025-01-24Make CodegenCx and Builder genericManuel Drehwald-1/+0
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2025-01-13Merge commit '59a81c2ca1edc88ad3ac4b27a8e03977ffb8e73a' into ↵Antoni Boucher-18/+20
subtree-update_cg_gcc_2025_01_12
2025-01-01upstream rustc_codegen_llvm changes for enzyme/autodiffManuel Drehwald-0/+10
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-1/+1
2024-12-14target_features: control separately whether enabling and disabling a target ↵Ralf Jung-2/+2
feature is allowed
2024-12-11generalize 'forbidden feature' concept so that even (un)stable feature can ↵Ralf Jung-5/+6
be invalid to toggle Also rename some things for extra clarity
2024-11-09Add a default implementation for CodegenBackend::linkbjorn3-13/+1
As a side effect this should add raw-dylib support to cg_gcc as the default ArchiveBuilderBuilder that is used implements create_dll_import_lib. I haven't tested if the raw-dylib support actually works however.
2024-11-04mark some target features as 'forbidden' so they cannot be (un)setRalf Jung-1/+2
For now, this is just a warning, but should become a hard error in the future
2024-10-08cg_gcc: Factor out rustc_target::abiJubilee Young-0/+1
2024-09-27Merge commit '3187d32079b817522cc17413ec9185b130daf693' into subtree-updateGuillaume Gomez-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-02Use sysroot crates maximally in `rustc_codegen_gcc`.Nicholas Nethercote-2/+8
This shrinks `compiler/rustc_codegen_gcc/Cargo.lock` quite a bit. The only remaining dependencies in `compiler/rustc_codegen_gcc/Cargo.lock` are `gccjit`, `lang_tester`, and `boml`, all of which aren't used in any other compiler crates. The commit also reorders and adds comments to the `extern crate` items so they match those in miri.
2024-08-07Refactor and fill out target feature listsCaleb Zulawski-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-10Merge commit '98ed962c7d3eebe12c97588e61245273d265e72f' into masterGuillaume Gomez-36/+59
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-12/+9
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-05-23rustc_codegen_gcc: fix changed method signatureAugie Fackler-1/+1
2024-05-22rustc_codegen_llvm: add support for writing summary bitcodeAugie Fackler-0/+4
Typical uses of ThinLTO don't have any use for this as a standalone file, but distributed ThinLTO uses this to make the linker phase more efficient. With clang you'd do something like `clang -flto=thin -fthin-link-bitcode=foo.indexing.o -c foo.c` and then get both foo.o (full of bitcode) and foo.indexing.o (just the summary or index part of the bitcode). That's then usable by a two-stage linking process that's more friendly to distributed build systems like bazel, which is why I'm working on this area. I talked some to @teresajohnson about naming in this area, as things seem to be a little confused between various blog posts and build systems. "bitcode index" and "bitcode summary" tend to be a little too ambiguous, and she tends to use "thin link bitcode" and "minimized bitcode" (which matches the descriptions in LLVM). Since the clang option is thin-link-bitcode, I went with that to try and not add a new spelling in the world. Per @dtolnay, you can work around the lack of this by using `lld --thinlto-index-only` to do the indexing on regular .o files of bitcode, but that is a bit wasteful on actions when we already have all the information in rustc and could just write out the matching minimized bitcode. I didn't test that at all in our infrastructure, because by the time I learned that I already had this patch largely written.
2024-05-01Step bootstrap cfgsMark Rousskov-1/+0
2024-03-19Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obkbors-1/+1
Stabilize associated type bounds (RFC 2289) This PR stabilizes associated type bounds, which were laid out in [RFC 2289]. This gives us a shorthand to express nested type bounds that would otherwise need to be expressed with nested `impl Trait` or broken into several `where` clauses. ### What are we stabilizing? We're stabilizing the associated item bounds syntax, which allows us to put bounds in associated type position within other bounds, i.e. `T: Trait<Assoc: Bounds...>`. See [RFC 2289] for motivation. In all position, the associated type bound syntax expands into a set of two (or more) bounds, and never anything else (see "How does this differ[...]" section for more info). Associated type bounds are stabilized in four positions: * **`where` clauses (and APIT)** - This is equivalent to breaking up the bound into two (or more) `where` clauses. For example, `where T: Trait<Assoc: Bound>` is equivalent to `where T: Trait, <T as Trait>::Assoc: Bound`. * **Supertraits** - Similar to above, `trait CopyIterator: Iterator<Item: Copy> {}`. This is almost equivalent to breaking up the bound into two (or more) `where` clauses; however, the bound on the associated item is implied whenever the trait is used. See #112573/#112629. * **Associated type item bounds** - This allows constraining the *nested* rigid projections that are associated with a trait's associated types. e.g. `trait Trait { type Assoc: Trait2<Assoc2: Copy>; }`. * **opaque item bounds (RPIT, TAIT)** - This allows constraining associated types that are associated with the opaque without having to *name* the opaque. For example, `impl Iterator<Item: Copy>` defines an iterator whose item is `Copy` without having to actually name that item bound. The latter three are not expressible in surface Rust (though for associated type item bounds, this will change in #120752, which I don't believe should block this PR), so this does represent a slight expansion of what can be expressed in trait bounds. ### How does this differ from the RFC? Compared to the RFC, the current implementation *always* desugars associated type bounds to sets of `ty::Clause`s internally. Specifically, it does *not* introduce a position-dependent desugaring as laid out in [RFC 2289], and in particular: * It does *not* desugar to anonymous associated items in associated type item bounds. * It does *not* desugar to nested RPITs in RPIT bounds, nor nested TAITs in TAIT bounds. This position-dependent desugaring laid out in the RFC existed simply to side-step limitations of the trait solver, which have mostly been fixed in #120584. The desugaring laid out in the RFC also added unnecessary complication to the design of the feature, and introduces its own limitations to, for example: * Conditionally lowering to nested `impl Trait` in certain positions such as RPIT and TAIT means that we inherit the limitations of RPIT/TAIT, namely lack of support for higher-ranked opaque inference. See this code example: https://github.com/rust-lang/rust/pull/120752#issuecomment-1979412531. * Introducing anonymous associated types makes traits no longer object safe, since anonymous associated types are not nameable, and all associated types must be named in `dyn` types. This last point motivates why this PR is *not* stabilizing support for associated type bounds in `dyn` types, e.g, `dyn Assoc<Item: Bound>`. Why? Because `dyn` types need to have *concrete* types for all associated items, this would necessitate a distinct lowering for associated type bounds, which seems both complicated and unnecessary compared to just requiring the user to write `impl Trait` themselves. See #120719. ### Implementation history: Limited to the significant behavioral changes and fixes and relevant PRs, ping me if I left something out-- * #57428 * #108063 * #110512 * #112629 * #120719 * #120584 Closes #52662 [RFC 2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html
2024-03-08Stabilize associated type boundsMichael Goulet-1/+1
2024-03-05Merge commit 'b385428e3ddf330805241e7758e773f933357c4b' into ↵Guillaume Gomez-82/+158
subtree-update_cg_gcc_2024-03-05
2024-02-17Make `CodegenBackend::join_codegen` infallible.Nicholas Nethercote-5/+3
Because they all are, in practice.
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-01-13add avx512fp16 to x86 target featuresusamoi-1/+1
2024-01-10Rename `{create,emit}_warning` as `{create,emit}_warn`.Nicholas Nethercote-1/+1
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`, all of which use an abbreviated form.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-5/+5
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-4/+4
2023-12-14Move rustc_codegen_ssa target features to rustc_targetUrgau-2/+3
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+1
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-19Pass TyCtxt by valueAntoni Boucher-2/+2
2023-11-19Merge commit '2e8386e9fb3506cef991d04f8b3bc78f9a0c2630' into ↵Antoni Boucher-5/+23
subtree-update_cg_gcc_2023-11-17
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-11-12target_feature: make it more clear what that 'Option' meansRalf Jung-1/+1
2023-10-26Merge commit 'e4fe941b11a55c5005630696e9b6d81c65f7bd04' into ↵Antoni Boucher-2/+4
subtree-update_cg_gcc_2023-10-25
2023-10-16docs: add Rust logo to more compiler cratesMichael Howell-0/+2
c6e6ecb1afea9695a42d0f148ce153536b279eb5 added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.
2023-10-09Use IntoDynSyncSendAntoni Boucher-6/+14
2023-10-09Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into ↵Antoni Boucher-71/+113
subtree-update_cg_gcc_2023-10-09
2023-09-22Have a single struct for queries and hookOli Scherer-3/+2
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-1/+2
2023-07-31Use standard Rust capitalization rules for names containing "LTO".Nicholas Nethercote-4/+4