about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2025-08-12make no_mangle explicit on foreign itemsJana Dönszelmann-1/+1
2025-08-11Always attempt to invoke xcrun to get the Apple SDKMads Marquart-4/+8
The exact reasoning why we do not always pass the SDK root when linking on macOS eludes me, but I suspect it's because we want to support compiler drivers which do not support the `-isysroot` option. Since we now pass the SDK root via the environment variable SDKROOT, compiler drivers that don't support it can just ignore it. Similarly, since we only warn when xcrun fails, users that expect their compiler driver to provide the SDK location can do so now.
2025-08-11Only warn when invoking xcrunMads Marquart-3/+21
To allow using zig-cc or similar as the compiler driver.
2025-08-11Pass Apple SDK root to compiler driver via SDKROOT env varMads Marquart-8/+36
This is more in-line with what Apple's tooling expects, and allows us to better support custom compiler drivers (such as certain Homebrew and Nixpkgs compilers) that prefer their own `-isysroot` flag. Effectively, we now invoke the compiler driver as-if it was invoked as `xcrun -sdk $sdk_name $tool`.
2025-08-11Simplify `add_apple_sdk`Mads Marquart-25/+20
Reduce indentation and avoid needless checks (checking the target OS and vendor is unnecessary).
2025-08-09Rollup merge of #141828 - Fulgen301:status-stack-buffer-overrun-diagnostic, ↵Stuart Cook-0/+8
r=wesleywiser Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code `STATUS_STACK_BUFFER_OVERRUN` is also used for fast abnormal program termination, e.g. by abort(). Emit a special diagnostic to let people know that this most likely doesn't indicate a stack buffer overrun. This doesn't look up the crash report in the event log to determine what the fast fail error code is. This is due to the way crashes are logged: When a process crash happens, the system logs an "Application Error" event, which contains the exit code and the process ID, but not the fast fail error code. A second event by Windows Error Reporting does contain that fast fail code, but not the process ID - but that event is not emitted at process exit, but when WER has dealt with it (on my system, it happens roughly two seconds later), so querying the code would have to read the `IntegratorReportId`, wait two seconds or potentially longer for the WER event with the same `ReportID`, and read out the code. (Also, that second event doesn't happen if WER is disabled.) Fixes rust-lang/rust#100519.
2025-08-08Add target_env = "macabi" and target_env = "sim"Mads Marquart-6/+6
2025-08-08Remove bitcode_llvm_cmdlinebjorn3-2/+0
It used to be necessary on Apple platforms to ship with the App Store, but XCode 15 has stopped embedding LLVM bitcode and the App Store no longer accepts apps with bitcode embedded.
2025-08-08Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only beingGeorge Tokmaji-0/+8
used for stack buffer overruns if link.exe exits with that exit code `STATUS_STACK_BUFFER_OVERRUN` is also used for fast abnormal program termination, e.g. by abort(). Emit a special diagnostic to let people know that this most likely doesn't indicate a stack buffer overrun.
2025-08-07Move metadata symbol export from exported_non_generic_symbols to ↵bjorn3-24/+10
exported_symbols The metadata symbol must not be encoded in the crate metadata, and must be exported from proc-macros. Handling the export of the metadata symbol in exported_symbols handles both things at once without requiring manual fixups elsewhere.
2025-08-06Remove unused field from ModuleConfigbjorn3-5/+1
2025-08-06Include allocator module in LLVM_passes timerbjorn3-6/+1
2025-08-02update flags for consistencyKivooeo-2/+3
2025-07-31Rollup merge of #144726 - jdonszelmann:move-attr-data-structures, r=lcnrJana Dönszelmann-1/+1
merge rustc_attr_data_structures into rustc_hir this move was discussed on zulip: [#t-compiler > attribute parsing rework @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/528530091) Many PRs in the attribute rework depend on this move.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+1
2025-07-31Rollup merge of #136840 - Flakebi:linker-plugin-lto-fat, r=dianqkSamuel Tardieu-1/+3
Fix linker-plugin-lto only doing thin lto When rust provides LLVM bitcode files to lld and the bitcode contains function summaries as used for thin lto, lld defaults to using thin lto. This prevents some optimizations that are only applied for fat lto. We solve this by not creating function summaries when fat lto is enabled. The bitcode for the module is just directly written out. An alternative solution would be to set the `ThinLTO=0` module flag to signal lld to do fat lto. The code in clang that sets this flag is here: https://github.com/llvm/llvm-project/blob/560149b5e3c891c64899e9912e29467a69dc3a4c/clang/lib/CodeGen/BackendUtil.cpp#L1150 The code in LLVM that queries the flag and defaults to thin lto if not set is here: https://github.com/llvm/llvm-project/blob/e258bca9505f35e0a22cb213a305eea9b76d11ea/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4441-L4446 try-job: x86_64-gnu-debug try-job: aarch64-gnu-debug
2025-07-31Fix linker-plugin-lto only doing thin ltoFlakebi-1/+3
When rust provides LLVM bitcode files to lld and the bitcode contains function summaries as used for thin lto, lld defaults to using thin lto. This prevents some optimizations that are only applied for fat lto. We solve this by not creating function summaries when fat lto is enabled. The bitcode for the module is just directly written out. An alternative solution would be to set the `ThinLTO=0` module flag to signal lld to do fat lto. The code in clang that sets this flag is here: https://github.com/llvm/llvm-project/blob/560149b5e3c891c64899e9912e29467a69dc3a4c/clang/lib/CodeGen/BackendUtil.cpp#L1150 The code in LLVM that queries the flag and defaults to thin lto if not set is here: https://github.com/llvm/llvm-project/blob/e258bca9505f35e0a22cb213a305eea9b76d11ea/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4441-L4446
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-1/+1
2025-07-28Auto merge of #144562 - matthiaskrgr:rollup-mlvn7qo, r=matthiaskrgrbors-64/+27
Rollup of 7 pull requests Successful merges: - rust-lang/rust#144072 (update `Atomic*::from_ptr` and `Atomic*::as_ptr` docs) - rust-lang/rust#144151 (`tests/ui/issues/`: The Issues Strike Back [1/N]) - rust-lang/rust#144300 (Clippy fixes for miropt-test-tools) - rust-lang/rust#144399 (Add a ratchet for moving all standard library tests to separate packages) - rust-lang/rust#144472 (str: Mark unstable `round_char_boundary` feature functions as const) - rust-lang/rust#144503 (Various refactors to the codegen coordinator code (part 3)) - rust-lang/rust#144530 (coverage: Infer `instances_used` from `pgo_func_name_var_map`) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-28use let chains in ast, borrowck, codegen, const_evalKivooeo-6/+6
2025-07-26Remove support for -Zcombine-cgubjorn3-36/+6
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-25Improve coordinator channel handlingbjorn3-28/+21
Remove usage of Any, reduce visibility of fields and remove unused backend arguments.
2025-07-24Auto merge of #144398 - fmease:rollup-z6vq7mi, r=fmeasebors-28/+106
Rollup of 15 pull requests Successful merges: - rust-lang/rust#143374 (Unquerify extern_mod_stmt_cnum.) - rust-lang/rust#143838 (std: net: uefi: Add support to query connection data) - rust-lang/rust#144014 (don't link to the nightly version of the Edition Guide in stable lints) - rust-lang/rust#144094 (Ensure we codegen the main fn) - rust-lang/rust#144218 (Use serde for target spec json deserialize) - rust-lang/rust#144221 (generate elf symbol version in raw-dylib) - rust-lang/rust#144240 (Add more test case to check if the false note related to sealed trait suppressed) - rust-lang/rust#144247 (coretests/num: use ldexp instead of hard-coding a power of 2) - rust-lang/rust#144276 (Use less HIR in check_private_in_public.) - rust-lang/rust#144278 (add Rev::into_inner) - rust-lang/rust#144317 (pass build.npm from bootstrap to tidy and use it for npm install) - rust-lang/rust#144320 (rustdoc: avoid allocating a temp String for aliases in search index) - rust-lang/rust#144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion) - rust-lang/rust#144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding) - rust-lang/rust#144358 (Stop using the old `validate_attr` logic for stability attributes) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-24Rollup merge of #144221 - usamoi:versym, r=bjorn3León Orell Valerian Liehr-28/+106
generate elf symbol version in raw-dylib For link names like `aaa@bbb`, it generates a symbol named `aaa` and a version named `bbb`. For link names like `aaa\0bbb`, `aaa@`@bbb`` or `aa@bb@cc`, it emits errors. It adds a test that the executable is linked with glibc using raw-dylib. cc rust-lang/rust#135694
2025-07-24Auto merge of #144062 - bjorn3:lto_refactors2, r=davidtwcobors-105/+170
Various refactors to the LTO handling code (part 2) Continuing from https://github.com/rust-lang/rust/pull/143388 this removes a bit of dead code and moves the LTO symbol export calculation from individual backends to cg_ssa.
2025-07-24generate elf symbol version in raw-dylibusamoi-28/+106
2025-07-21Remove each_linked_rlib_for_lto from CodegenContextbjorn3-12/+29
2025-07-21Move exported_symbols_for_lto out of CodegenContextbjorn3-8/+21
2025-07-21Merge exported_symbols computation into exported_symbols_for_ltobjorn3-80/+62
And move exported_symbols_for_lto call from backends to cg_ssa.
2025-07-21Move LTO symbol export calculation from backends to cg_ssabjorn3-0/+83
2025-07-21Remove worker idbjorn3-56/+19
It isn't used anywhere. Also inline free_worker into the only call site.
2025-07-21Merge modules and cached_modules for fat LTObjorn3-4/+11
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-18add -Zoffload=Enable flag behind -Zunstable-options, to enable gpu (host) ↵Manuel Drehwald-0/+2
code generation
2025-07-18Rollup merge of #143846 - usamoi:gc, r=bjorn3Matthias Krüger-39/+1
pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests Exported symbols are added as GC roots in linking, so `--gc-sections` won't hurt `-Zexport-executable-symbols`. Fixes the run-make test to work on Linux. Enable the ui test on more targets. cc rust-lang/rust#84161
2025-07-17remove no_gc_sectionsusamoi-35/+0
2025-07-17Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errorsLeón Orell Valerian Liehr-137/+97
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-13pass --gc-sections if -Zexport-executable-symbols is enabled and improve testsusamoi-6/+3
2025-07-10Rollup merge of #143446 - usamoi:export-executable-symbols, r=bjorn3,oli-obkMatthias Krüger-16/+25
use `--dynamic-list` for exporting executable symbols closes rust-lang/rust#101610 cc rust-lang/rust#84161 https://sourceware.org/binutils/docs-2.39/ld/VERSION.html: > --dynamic-list=dynamic-list-file Specify the name of a dynamic list file to the linker. This is typically used when creating shared libraries to specify a list of global symbols whose references shouldn’t be bound to the definition within the shared library, or creating dynamically linked executables to specify a list of symbols which should be added to the symbol table in the executable. This option is only meaningful on ELF platforms which support shared libraries. `ld.lld --help`: > --dynamic-list=<file>: Similar to --export-dynamic-symbol-list. When creating a shared object, this additionally implies -Bsymbolic but does not set DF_SYMBOLIC > --export-dynamic-symbol-list=file: Read a list of dynamic symbol patterns. Apply --export-dynamic-symbol on each pattern > --export-dynamic-symbol=glob: (executable) Put matched symbols in the dynamic symbol table. (shared object) References to matched non-local STV_DEFAULT symbols shouldn't be bound to definitions within the shared object. Does not imply -Bsymbolic. > --export-dynamic: Put symbols in the dynamic symbol table Use `--dynamic-list` because it's older than `--export-dynamic-symbol-list` (binutils 2.35) try-job: dist-i586-gnu-i586-i686-musl
2025-07-09use `--dynamic-list` for exporting executable symbolsusamoi-16/+25
2025-07-08remove `-znostart-stop-gc` workaroundRémy Rakic-29/+0
Now that `#[used(linker)]` is the default on ELF, we don't need to use the `-znostart-stop-gc` link-arg workaround to match bfd's behavior when using lld.
2025-07-08stabilize `-Clinker-features=-lld` on x64 linuxRémy Rakic-1/+1
This stabilizes a subset of the `-Clinker-features` components on x64 linux: the lld opt-out. The opt-in is not stabilized, as interactions with other stable flags require more internal work, but are not needed for stabilizing using rust-lld by default. Similarly, since we only switch to rust-lld on x64 linux, the opt-out is only stabilized there. Other targets still require `-Zunstable-options` to use it.
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-1/+1
default data address space
2025-07-03Merge run_fat_lto, optimize_fat and autodiff into run_and_optimize_fat_ltobjorn3-11/+1
2025-07-03Remove unused config param from WriteBackendMethods::autodiffbjorn3-2/+1
2025-07-03Remove unnecessary check for fat LTObjorn3-1/+1
2025-07-03Move run_fat_lto call into execute_fat_lto_work_itembjorn3-32/+36
This will allow merging all fat LTO steps together. In addition it reduces the amount of work done on the coordinator thread without jobserver token.
2025-07-03Pass in autodiff items when starting the coordinator threadbjorn3-12/+4
As opposed to sending a message to the coordinator thread.
2025-07-03Split generate_lto_work between fat and thin-LTO casesbjorn3-49/+63
2025-07-03Fat LTO always produces a single object file, so -Zcombine-cgu has no effectbjorn3-1/+3
2025-07-03Move dcx creation into WriteBackendMethods::codegenbjorn3-5/+2