about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2023-08-15stabilize combining +bundle and +whole-archive link modifiersBe Wilson-15/+1
Currently, combining +bundle and +whole-archive works only with #![feature(packed_bundled_libs)] This crate feature is independent of the -Zpacked-bundled-libs command line option. This commit stabilizes the #![feature(packed_bundled_libs)] crate feature and implicitly enables it only when the +bundle and +whole-archive link modifiers are combined. This allows rlib crates to use the +whole-archive link modifier with native libraries and have all symbols included in the linked library to be included in downstream staticlib crates that use the rlib as a dependency. Other cases requiring the packed_bundled_libs behavior still require the -Zpacked-bundled-libs command line option, which can be stabilized independently in the future. Per discussion on https://github.com/rust-lang/rust/issues/108081 there is no risk of regression stabilizing the crate feature in this way because the combination of +bundle,+whole-archive link modifiers was previously not allowed.
2023-08-15Rollup merge of #114711 - lqd:linker-inference, r=petrochenkovGuillaume Gomez-17/+2
Infer `Lld::No` linker hint when the linker stem is a generic compiler driver This PR basically reverts the temporary solution in https://github.com/rust-lang/rust/pull/113631 to a more long-term solution. r? ``@petrochenkov`` In [this comment](https://github.com/rust-lang/rust/pull/113631#issuecomment-1634598238), you had ideas about a long-term solution: > I wonder what a good non-temporary solution for the inference would look like. > > * If the default is `(Cc::No, Lld::Yes)` (e.g. `rust-lld`) > > * and we switch to some specific platform compiler (e.g. `-C linker=arm-none-eabi-gcc`), should we change to `Lld::No`? Maybe yes? > * and we switch to some non-default but generic compiler `-C linker=clang`? Then maybe not? > > * If the default is `(Cc::Yes, Lld::Yes)` (e.g. future x86_64 linux with default LLD) > > * and we switch to some specific platform compiler (e.g. `-C linker=arm-none-eabi-gcc`), should we change to `Lld::No`? Maybe yes? > * and we switch to some non-default but generic compiler `-C linker=clang`? Then maybe not? > I believe that we should infer the `Lld::No` linker hint for any `-Clinker` override, and all the cases above: - the linker drivers have their own defaults, so in my mind `-Clinker` is a signal to use its default linker / flavor, rather than ours or the target's. In the case of generic compilers, it's more likely than not going to be `Lld::No`. I would expect this to be the case in general, even when including platform-specific compilers. - the guess will be wrong if the linker driver uses lld by default (and we also don't want to search for `-fuse-ld` link args), but will work in the more common cases. And the minority of other cases can fix the wrong guess by opting into the precise linker flavor. - this also ensures backwards-compatibility: today, even on targets with an lld default and overriding the linker, rustc will not use lld. That includes `thumbv6m-none-eabi` where issue #113597 happened. It looks like the simplest option, and the one with least churn: we maintain the current behavior in ambiguous cases. I've tested that this works on #113597, as expected from the failure. (I also have a no-std `run-make` test using a custom target json spec: basically simulating a future `x86_64-unknown-linux-gnu` using an lld flavor by default, to check that e.g. `-Clinker=clang` doesn't use lld. I could add that test to this PR, but IIUC such a custom target requires `cargo -Z build-std` and we have no tests depending on this cargo feature yet. Let me know if you want to add this test of the linker inference for such targets.) What do you think ?
2023-08-14Upgrade Object and related depsdirreke-3/+3
2023-08-14add details for csky-unknown-linux-gnuabiv2 and add docsDirreke-6/+42
2023-08-14add `rustc_codegen_ssa` support for csky and correct some codeDirreke-0/+21
2023-08-12Remove unnecessary feature gatesJacob Pratt-1/+0
2023-08-11Use the same DISubprogram for each instance of the same inlined function ↵Daniel Paoliello-4/+14
within the caller
2023-08-10Revert "make MCP510 behavior explicitly opt-in"Rémy Rakic-17/+2
This reverts commit 2b61a5e17a6bcb552889966f8f932aa680826ab6.
2023-08-09rustc: Move `stable_crate_id` from `Session` to `GlobalCtxt`Vadim Petrochenkov-1/+1
Removes a piece of mutable state. Follow up to #114578.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-24/+23
Removes a piece of mutable state. Follow up to #114578.
2023-08-09Auto merge of #114470 - ↵bors-3/+22
pnkfelix:dont-export-no-mangle-from-proc-macros-issue-99978, r=bjorn3 Restrict linker version script of proc-macro crates to just its two symbols Restrict linker version script of proc-macro crates to just the two symbols of each proc-macro crate. The main known effect of doing this is to stop including `#[no_mangle]` symbols in the linker version script. Background: The combination of a proc-macro crate with an import of another crate that itself exports a no_mangle function was broken for a period of time, because: * In PR #99944 we stopped exporting no_mangle symbols from proc-macro crates; proc-macro crates have a very limited interface and are meant to be treated as a blackbox to everything except rustc itself. However: he constructed linker version script still referred to them, but resolving that discrepancy was left as a FIXME in the code, tagged with issue #99978. * In PR #108017 we started telling the linker to check (via the`--no-undefined-version` linker invocation flag) that every symbol referenced in the "linker version script" is provided as linker input. So the unresolved discrepancy from #99978 started surfacing as a compile-time error (e.g. #111888). Fix #111888 Fix #99978.
2023-08-08Rollup merge of #114500 - taiki-e:arm-crypto, r=AmanieuMatthias Krüger-1/+0
Remove arm crypto target feature Follow-up to https://github.com/rust-lang/stdarch/pull/1407. LLVM has moved away from a combined `crypto` feature on both aarch64 and arm, and we did the same on aarch64, but were deferred from doing the same on arm due to compatibility with older LLVM. As the minimum LLVM version has increased, we can now remove this (unstable) target feature on arm. r? `@Amanieu`
2023-08-08Rollup merge of #114376 - ↵Matthias Krüger-9/+0
inferiorhumanorgans:rustc-codegen-ssa-duplicate-export, r=wesleywiser Avoid exporting __rust_alloc_error_handler_should_panic more than once. Exporting `__rust_alloc_error_handler_should_panic` multiple times causes `ld.gold` to balk with: `error: version script assignment of to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined` Specifically this breaks builds of 1.70.0 and newer on DragonFly and YoctoProject with `ld.gold`. Builds with `ld.bfd` and `lld` should be unaffected. http://errors.yoctoproject.org/Errors/Details/708194/
2023-08-07Review feedback: return empty iff !should_codegen, and use simpler ↵Felix S. Klock II-12/+5
unconditional logic otherwise.
2023-08-06Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJungMatthias Krüger-1/+1
Add documentation to has_deref Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose. cc https://github.com/rust-lang/rust/issues/114401 r? `@RalfJung`
2023-08-06cleanup misinformation regarding has_derefouz-a-1/+1
2023-08-05Remove arm crypto target featureTaiki Endo-1/+0
2023-08-04Auto merge of #112117 - bryangarza:track-caller-feature-gate, r=compiler-errorsbors-2/+7
Add separate feature gate for async fn track caller This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
2023-08-04special-case proc-macro crates in ↵Felix S. Klock II-3/+29
rustc_codegen_ssa::back::linker::exported_symbols to only export the two symbols that proc-macros need.
2023-08-04Rollup merge of #114427 - Enselic:rustc_codegen_ssa-fixme, r=NilstriebMatthias Krüger-32/+39
Handle non-utf8 rpaths (fix FIXME) Removes a FIXME for #9639 which is closed since long ago. Part of #44366 which is E-help-wanted. (Also see https://github.com/rust-lang/rust/pull/114377)
2023-08-04Rollup merge of #114431 - ehuss:ssa-test, r=est31Matthias Krüger-3/+0
Enable tests on rustc_codegen_ssa This enables unittests in rustc_codegen_ssa. There are some tests, primarily in [`back/rpath/tests.rs`](https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs) that haven't ever been running since the unittests are disabled. From what I can tell, this was just a consequence of how things evolved. When testing was initially added in https://github.com/rust-lang/rust/pull/33282, `librustc_trans` had test=false because it didn't have any tests. `rustc_codegen_ssa` eventually split off from that (https://github.com/rust-lang/rust/pull/55627), and the rpath module eventually got merged in too (from `librustc_back` where it used to live). That migration didn't enable the tests. This also includes some fluent diagnostic tests, though I'm not sure what exactly they are testing.
2023-08-03Enable tests on rustc_codegen_ssaEric Huss-3/+0
2023-08-03Handle non-utf8 rpaths (fix FIXME)Martin Nordholts-32/+39
2023-08-03Forbid old-style `simd_shuffleN` intrinsicsOli Scherer-2/+2
2023-08-02Add separate feature gate for async fn track callerBryan Garza-2/+7
This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
2023-08-02Avoid exporting symbols more than once.Alex Zepeda-9/+0
Exporting `__rust_alloc_error_handler_should_panic` multiple times causes ld.gold to balk with: `error: version script assignment of to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined` Specifically this breaks builds on DragonFly and YoctoProject with ld.gold. Builds with ld.bfd should be unaffected.
2023-08-01Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3bors-169/+44
cleanup: remove pointee types This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.) I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup. As a followup, this will enable #96242 to be resolved. r? `@ghost` `@rustbot` label S-blocked
2023-07-31Rollup merge of #113717 - cuishuang:master, r=NilstriebMatthias Krüger-1/+1
remove repetitive words
2023-07-31remove repetitive wordscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31Remove unnecessary semicolon.Nicholas Nethercote-1/+1
2023-07-31Clean up `generate_lto_work`.Nicholas Nethercote-22/+23
This function has some shared code for the thin LTO and fat LTO cases, but those cases have so little in common that it's actually clearer to treat them fully separately.
2023-07-31Fix LLVM thread names on Windows.Nicholas Nethercote-3/+3
PR #112946 tweaked the naming of LLVM threads, but messed things up slightly, resulting in threads on Windows having names like `optimize module {} regex.f10ba03eb5ec7975-cgu.0`. This commit removes the extraneous `{} `.
2023-07-31Introduce `running_with_any_token` closure.Nicholas Nethercote-7/+10
It makes things a little clearer.
2023-07-31Use standard Rust capitalization rules for names containing "LTO".Nicholas Nethercote-11/+11
2023-07-31Tweak structure of the message loop.Nicholas Nethercote-17/+20
The main loop has a *very* complex condition, which includes two mentions of `codegen_state`. The body of the loop then immediately switches on the `codegen_state`. I find it easier to understand if it's a `loop` and we check for exit conditions after switching on `codegen_state`. We end up with a tiny bit of code duplication, but it's clear that (a) we never exit in the `Ongoing` case, (b) we exit in the `Completed` state only if several things are true (and there's interaction with LTO there), and (c) we exit in the `Aborted` state if a couple of things are true. Also, the exit conditions are all simple conjunctions.
2023-07-31Tweak a loop condition.Nicholas Nethercote-7/+11
This loop condition involves `codegen_state`, `work_items`, and `running_with_own_token`. But the body of the loop cannot modify `codegen_state`, so repeatedly checking it is unnecessary.
2023-07-31Move `maybe_start_llvm_timer`'s body into `spawn_work`.Nicholas Nethercote-26/+18
The two functions are alway called together. This commit factors out the repeated code.
2023-07-31Remove `CodegenContext::worker`.Nicholas Nethercote-24/+12
`CodegenContext` is immutable except for the `worker` field - we clone `CodegenContext` in multiple places, changing the `worker` field each time. It's simpler to move the `worker` field out of `CodegenContext`.
2023-07-31Remove `ExtraBackendMethods::spawn_thread`.Nicholas Nethercote-9/+0
It's no longer used, and `spawn_named_thread` is preferable, because naming threads is helpful when profiling.
2023-07-31Give the coordinator thread a name.Nicholas Nethercote-3/+4
This is useful when profiling with a profiler like Samply.
2023-07-31Remove some unused values in `codegen_crate`.Nicholas Nethercote-3/+0
2023-07-31Remove an unnecessary `pub`.Nicholas Nethercote-1/+1
2023-07-31Rename `MainThreadWorkerState`.Nicholas Nethercote-25/+25
The `Worker` is unnecessary, and just makes it longer than necessary.
2023-07-31Rename things related to the main thread's operations.Nicholas Nethercote-30/+46
It took me some time to understand how the main thread can lend a jobserver token to an LLVM thread. This commit renames a couple of things to make it clearer. - Rename the `LLVMing` variant as `Lending`, because that is a clearer description of what is happening. - Rename `running` as `running_with_own_token`, which makes it clearer that there might be one additional LLVM thread running (with a loaned token). Also add a comment to its definition.
2023-07-31Add some assertions.Nicholas Nethercote-0/+4
- Thin and fat LTO can't happen together. - `NeedsLink` and (non-allocator) `Compiled` work item results can't happen together.
2023-07-31Add comments to `WorkItemResult`.Nicholas Nethercote-4/+14
And rename the `Compiled` variant as `Finished`, because that name makes it clearer there is nothing left to do, contrasting nicely with the `Needs*` variants.
2023-07-31Inline and remove `submit_pre_codegened_module_to_llvm`.Nicholas Nethercote-15/+9
It has a single callsite, and provides little value.
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-82/+75
2023-07-29cg_ssa: remove pointee types and pointercast/bitcast-of-ptrErik Desjardins-169/+44
2023-07-27Rollup merge of #113872 - nnethercote:tweak-cgu-sorting, r=pnkfelixMatthias Krüger-2/+3
Tweak CGU sorting in a couple of places. In `base.rs`, tweak how the CGU size interleaving works. Since #113777, it's much more common to have multiple CGUs with identical sizes. With the existing code these same-sized items ended up in the opposite-to-desired order due to the stable sorting. The code now starts with a reverse sort (like is done in `partitioning.rs`) which gives the behaviour we want. This doesn't matter much for perf, but makes profiles in `samply` look more like what we expect. In `partitioning.rs`, we can use `sort_by_key` instead of `sort_by_cached_key` because `CGU::size_estimate()` is cheap. (There is an identical CGU sort earlier in that function that already uses `sort_by_key`.) r? `@pnkfelix`