about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+0
2025-07-26Remove support for -Zcombine-cgubjorn3-8/+0
Nobody seems to actually use this, while still adding some extra complexity to the already rather complex codegen coordinator code. It is also not supported by any backend other than the LLVM backend.
2025-07-21Remove each_linked_rlib_for_lto from CodegenContextbjorn3-2/+5
2025-07-21Move exported_symbols_for_lto out of CodegenContextbjorn3-0/+4
2025-07-21Merge modules and cached_modules for fat LTObjorn3-2/+1
The modules vec can already contain serialized modules and there is no need to distinguish between cached and non-cached cgus at LTO time.
2025-07-18Merge commit 'f682d09eefc6700b9e5851ef193847959acf4fac' into ↵Guillaume Gomez-2/+5
subtree-update_cg_gcc_2025-07-18
2025-07-17Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errorsLeón Orell Valerian Liehr-23/+10
Various refactors to the LTO handling code In particular reducing the sharing of code paths between fat and thin-LTO and making the fat LTO implementation more self-contained. This also moves some autodiff handling out of cg_ssa into cg_llvm given that Enzyme only works with LLVM anyway and an implementation for another backend may do things entirely differently. This will also make it a bit easier to split LTO handling out of the coordinator thread main loop into a separate loop, which should reduce the complexity of the coordinator thread.
2025-07-07Remove unused allow attrsYotam Ofek-1/+0
2025-07-05Make tempfile a normal dependencyDiggory Blake-4/+2
2025-07-05Use `object` crate from crates.io to fix windows build errorDiggory Blake-1/+0
2025-07-03Merge run_fat_lto, optimize_fat and autodiff into run_and_optimize_fat_ltobjorn3-17/+6
2025-07-03Remove unused config param from WriteBackendMethods::autodiffbjorn3-1/+0
2025-07-03Move dcx creation into WriteBackendMethods::codegenbjorn3-2/+1
2025-07-03Remove LtoModuleCodegenbjorn3-3/+3
Most uses of it either contain a fat or thin lto module. Only WorkItem::LTO could contain both, but splitting that enum variant doesn't complicate things much.
2025-06-19cg_gcc: properly populate cfg(target_features) with -Ctarget-featuresRalf Jung-22/+17
2025-06-19move cfg(target_feature) computation into shared placeRalf Jung-37/+22
2025-06-18Merge commit 'fda0bb9588912a3e0606e880ca9f6e913cf8a5a4' into ↵Guillaume Gomez-7/+15
subtree-update_cg_gcc_2025-06-18
2025-06-15Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, ↵León Orell Valerian Liehr-15/+2
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-08Remove all unused feature gates from the compilerbjorn3-1/+1
2025-06-03Move metadata object generation for dylibs to the linker codebjorn3-4/+2
This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.
2025-06-03Only borrow EncodedMetadata in codegen_cratebjorn3-13/+2
And move passing it to the linker to the driver code.
2025-05-28Mark all optimize methods and the codegen method as safebjorn3-3/+3
There is no safety contract and I don't think any of them can actually cause UB in more ways than passing malicious source code to rustc can. While LtoModuleCodegen::optimize says that the returned ModuleCodegen points into the LTO module, the LTO module has already been dropped by the time this function returns, so if the returned ModuleCodegen indeed points into the LTO module, we would have seen crashes on every LTO compilation, which we don't. As such the comment is outdated.
2025-05-19Rollup merge of #140874 - mejrs:rads, r=WaffleLapkinStuart Cook-1/+1
make `rustc_attr_parsing` less dominant in the rustc crate graph It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly. Previous graph: ![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd) Graph with this PR: ![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a) The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*. The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-1/+1
2025-05-14Merge commit '6ba33f5e1189a5ae58fb96ce3546e76b13d090f5' into ↵Guillaume Gomez-2/+2
subtree-update_cg_gcc_2025-05-14
2025-04-27Implement the internal feature `cfg_target_has_reliable_f16_f128`Trevor Gross-8/+14
Support for `f16` and `f128` is varied across targets, backends, and backend versions. Eventually we would like to reach a point where all backends support these approximately equally, but until then we have to work around some of these nuances of support being observable. Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which provides the following new configuration gates: * `cfg(target_has_reliable_f16)` * `cfg(target_has_reliable_f16_math)` * `cfg(target_has_reliable_f128)` * `cfg(target_has_reliable_f128_math)` `reliable_f16` and `reliable_f128` indicate that basic arithmetic for the type works correctly. The `_math` versions indicate that anything relying on `libm` works correctly, since sometimes this hits a separate class of codegen bugs. These options match configuration set by the build script at [1]. The logic for LLVM support is duplicated as-is from the same script. There are a few possible updates that will come as a follow up. The config introduced here is not planned to ever become stable, it is only intended to replace the build scripts for `std` tests and `compiler-builtins` that don't have any way to configure based on the codegen backend. MCP: https://github.com/rust-lang/compiler-team/issues/866 Closes: https://github.com/rust-lang/compiler-team/issues/866 [1]: https://github.com/rust-lang/rust/blob/555e1d0386f024a8359645c3217f4b3eae9be042/library/std/build.rs#L84-L186
2025-04-25Merge commit '4f83a4258deb99f3288a7122c0d5a78200931c61' into ↵Antoni Boucher-1/+1
subtree-update_cg_gcc_2025-04-25
2025-04-18Merge commit 'db1a31c243a649e1fe20f5466ba181da5be35c14' into ↵Guillaume Gomez-2/+2
subtree-update_cg_gcc_2025-04-18
2025-03-17Remove implicit #[no_mangle] for #[rustc_std_internal_symbol]bjorn3-0/+1
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.