3833 Commits

Author SHA1 Message Date
Jacob Pratt 433e106dd2 Rollup merge of #152457 - pmur:murp/mcount-link-pg, r=davidtwco
Pass -pg to linker when using -Zinstrument-mcount

This selects a slightly different crt on gnu targets which enables the profiler within glibc.

This makes using gprof a little easier with Rust binaries. Otherwise, rustc must be passed `-Clink-args=-pg` to ensure the correct startup code is linked.
2026-03-27 02:30:06 -04:00
Jonathan Brouwer 6e6e266520 Rollup merge of #153857 - RalfJung:cfg-abi, r=Mark-Simulacrum
Rename `target.abi` to `target.cfg_abi` and enum-ify llvm_abiname

See [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/De-spaghettifying.20ABI.20controls/with/578893542) for more context. Discussed a bit in https://github.com/rust-lang/rust/pull/153769#discussion_r2934399038 too.

This renames `target.abi` to `target.cfg_abi` to make it less likely that someone will use it to determine things about the actual ccABI, i.e. the calling convention used on the target. `target.abi` does not control that calling convention, it just *sometimes* informs the user about that calling convention (and also about other aspects of the ABI).

Also turn llvm_abiname into an enum to make it more natural to match on.
Cc @workingjubilee @madsmtm
2026-03-23 12:14:54 +01:00
Ralf Jung 6b1487698c enum-ify llvm_abiname 2026-03-22 10:34:32 +01:00
Ralf Jung 40ebcc031d target specs: rename abi to cfg_abi 2026-03-22 10:34:32 +01:00
teor 55d9f7cb6c Fix typos and outdated comments 2026-03-20 11:22:53 +10:00
Stuart Cook c0172a38cd Rollup merge of #153580 - mati865:elf-raw-dylib-static-and-tls, r=bjorn3
Handle statics and TLS in raw-dylib for ELF

Follow-up to https://github.com/rust-lang/rust/pull/153090
2026-03-18 21:26:32 +11:00
Mateusz Mikuła ed4afa5989 Set symbols value in raw-dylib for ELF
With this change LLD finally produces working binaries with static
relocation model.
2026-03-17 21:29:11 +01:00
Mateusz Mikuła 36381555bb Put statics in .data section in raw-dylib for ELF
This fixes issues with statics when using static relocation model and
linking with GNU ld. Other linkers don't work yet.
2026-03-17 21:25:32 +01:00
Mateusz Mikuła f3654324e6 Set symbol size in raw-dylib for ELF 2026-03-17 21:23:16 +01:00
Mateusz Mikuła 82727b0c0f Refactor DllImport to better differentiate types 2026-03-17 21:21:25 +01:00
Jonathan Brouwer f4cc98ae79 Rollup merge of #153920 - folkertdev:track-caller-abi-error, r=JonathanBrouwer
improve `#[track_caller]` invalid ABI error

Niche but we can provide more context by emitting the error earlier.
2026-03-17 17:51:34 +01:00
N1ark 11c673b405 Remove InvalidMonomorphization::FloatingPointType 2026-03-16 21:49:06 +00:00
Folkert de Vries cd4fd289cd suggest valid features when target feature is invalid 2026-03-16 17:44:16 +01:00
Folkert de Vries 461038f0c9 improve #[track_caller] invalid ABI error 2026-03-15 17:17:36 +01:00
Stuart Cook 59f98f0e3d Rollup merge of #153769 - RalfJung:target-spec-abi-checks, r=madsmtm
target specs: stricter checks for LLVM ABI values, and correlate that with cfg(target_abi)

This tightens the checks for `llvm_abiname`, `llvm_floatabi` and `rustc_abi` in our target specs. Those are the fields that actually control the ccABI. With this commit, we now have an allowlist of value for these fields for all architectures (we previously only had that for some architectures). We also check that `cfg(target_abi)` suitably correlates with the actual ccABI. I based this check on our in-tree targets. For all ccABIs where we had a bunch of "random" values that don't directly correlate to the ccABI (like "uwp"), I also allowed  `cfg(target_abi)`  to remain empty, and whenever it is allowed to be empty I also allowed arbitrary other values for JSON targets. However, there's still a risk that JSON targets will fail this new check -- the idea is that we'll then get bugreports and can adjust the check as needed.

I had to adjust the target specs for non-ARM32 Apple targets as those were all setting `llvm_floatabi`, which to my knowledge makes no sense -- LLVM only actually does anything with that field on ARM32. I also adjusted the target specs for MIPS32 targets: one of them was setting llvm_abiname, and then it seems safer and more consistent to set that for all targets, so I set it to "o32" everywhere which seems to be the default.

Cc @workingjubilee
2026-03-14 23:30:10 +11:00
Ralf Jung 2662303112 mips: require LLVM ABI to be explicitly set, but also allow n32 2026-03-14 11:58:42 +01:00
Paul Murphy 87c25522c6 Link extra libraries when using mcount on *-windows-gnu targets
libgmon needs to be linked. This also requires readding a few
other system libraries to satisfy its dependencies.
2026-03-12 14:40:54 -05:00
Guillaume Gomez 862729e745 Rename rustc_middle::lint::diag_lint_level into emit_lint_base 2026-03-12 18:37:00 +01:00
Paul Murphy 84a2d2a92c Pass -pg to linker when using -Zinstrument-mcount
Clang and gcc use this option to control linking behavior too. Some
targets need to be linked against a special crt which enables
profiling at runtime.

This makes using gprof a little easier with Rust binaries. Otherwise,
rustc must be passed `-Clink-args=-pg` to ensure the correct startup
code is linked.
2026-03-11 11:04:10 -05:00
Ralf Jung fe1f92af4b de-duplicate LayoutError formatting 2026-03-11 13:55:03 +01:00
朝倉水希 d81cc6846c fix: add EII function aliases to exported symbols 2026-03-11 20:41:57 +08:00
Jonathan Brouwer 4b1bcac87e Rollup merge of #153676 - folkertdev:target-feature-plus-diagnostic, r=JonathanBrouwer
improve target feature diagnostic

And convert the test to use `minicore` so that it runs regardless of the target. This is the only test for many of these target feature diagnostics, so it's nice that it runs anywhere.

r? JonathanBrouwer

The test here is mostly for legal places for the attribute, is that still how that should be tested?
2026-03-11 09:34:47 +01:00
bors b2fabe39bd Auto merge of #153673 - JonathanBrouwer:rollup-cGOKonI, r=JonathanBrouwer
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#153560 (Introduce granular tidy_ctx's check in extra_checks)
 - rust-lang/rust#153666 (Add a regression test for rust-lang/rust#153599)
 - rust-lang/rust#153493 (Remove `FromCycleError` trait)
 - rust-lang/rust#153549 (tests/ui/binop: add annotations for reference rules)
 - rust-lang/rust#153641 (Move `Spanned`.)
 - rust-lang/rust#153663 (Remove `TyCtxt::node_lint` method and `rustc_middle::lint_level` function)
 - rust-lang/rust#153664 (Add test for rust-lang/rust#109804)
2026-03-11 05:12:10 +00:00
Folkert de Vries de94c5cd34 improve target feature diagnostic 2026-03-10 23:29:16 +01:00
Jonathan Brouwer 3ed43bb774 Rollup merge of #153663 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Remove `TyCtxt::node_lint` method and `rustc_middle::lint_level` function

Part of https://github.com/rust-lang/rust/issues/153099.

With this PR, we can finally get rid of `lint_level`. \o/

r? @JonathanBrouwer
2026-03-10 22:46:57 +01:00
Nicholas Nethercote c12ab08c14 Move Spanned.
It's defined in `rustc_span::source_map` which doesn't make any sense
because it has nothing to do with source maps. This commit moves it to
the crate root, a more sensible spot for something this basic.
2026-03-11 06:25:23 +11:00
Guillaume Gomez 916d760c47 Replace TyCtxt::node_lint call with TyCtxt::emit_node_lint in rustc_codegen_ssa 2026-03-10 17:14:01 +01:00
David Wood db5e2dc248 abi: s/ScalableVector/SimdScalableVector
Renaming to remove any ambiguity as to what "vector" refers to in this
context
2026-03-10 11:52:22 +00:00
Jonathan Brouwer 35152ef343 Rollup merge of #153561 - Zalathar:try-mark-green, r=nnethercote
Replace the `try_mark_green` hook with direct calls to `tcx.dep_graph`

All of the existing call sites are directly touching `tcx.dep_graph` anyway, so the extra layer of indirection provides no real benefit.

There should be no change to compiler behaviour.

r? nnethercote (or compiler)
2026-03-08 19:04:37 +01:00
Zalathar 985b41d387 Remove the rustc_data_structures::assert_matches! re-exports 2026-03-08 22:02:23 +11:00
Zalathar 0a369a799f Replace the try_mark_green hook with direct calls to tcx.dep_graph
All of the existing call sites are directly touching `tcx.dep_graph` anyway, so
the extra layer of indirection provides no real benefit.
2026-03-08 21:53:13 +11:00
Josh Stone 32bae1353e Update cfg(bootstrap) 2026-03-07 10:42:02 -08:00
Taiki Endo e0d9940c1e rustc_codegen_ssa: Define ELF flag value for sparc-unknown-linux-gnu 2026-03-07 21:53:18 +09:00
Jonathan Brouwer 783c9d3de0 Rollup merge of #149937 - jyn514:linker-info, r=mati865
spliit out `linker-info` from `linker-messages`

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/149937)*

Helps with https://github.com/rust-lang/rust/issues/136096.
2026-03-07 01:42:35 +01:00
Jonathan Brouwer 69dc318464 Rollup merge of #153452 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Cleanup unused diagnostic emission methods

Part of https://github.com/rust-lang/rust/issues/153099.

To remove `lint_level`, we need to remove all functions calling it. One of them is `TyCtxt::node_span_lint`, so removing it.

r? @JonathanBrouwer
2026-03-06 18:49:51 +01:00
Jynn Nelson 20404bf4a6 Split out linker-info from linker-messages
- Hide common linker output behind `linker-info`
- Add tests
- Account for different capitalization on windows-gnu when removing
  "warning" prefix
- Add some more comments
- Add macOS deployment-target test
- Ignore linker warnings from trying to statically link glibc

  I don't know what's going on in `nofile-limit.rs` but I want no part
  of it.

- Use a fake linker so tests are platform-independent
2026-03-06 10:38:21 +01:00
Guillaume Gomez 140ad033e7 Remove TyCtxt::node_span_lint usage from rustc_codegen_ssa 2026-03-05 23:53:54 +01:00
bors 64b72a1fa5 Auto merge of #150447 - WaffleLapkin:maybe-dangling-semantics, r=RalfJung
Implement `MaybeDangling` compiler support



Tracking issue: https://github.com/rust-lang/rust/issues/118166



cc @RalfJung
2026-03-05 12:21:27 +00:00
Waffle Lapkin 312055fad5 refactor PointeeInfo
Make `size`/`align` always correct rather than conditionally on the
`safe` field. This makes it less error prone and easier to work with for
`MaybeDangling` / potential future pointer kinds like `Aligned<_>`.
2026-03-05 11:53:38 +01:00
Jynn Nelson bbc45c16c4 Split report_linker_output into its own function 2026-03-05 11:15:39 +01:00
Jynn Nelson a995d48931 Split is_msvc_link_exe into a function 2026-03-05 11:15:35 +01:00
Jonathan Brouwer fb488de2aa Rollup merge of #153361 - folkertdev:tail-call-indirect-on-stack-true, r=WaffleLapkin
enable `PassMode::Indirect { on_stack: true, .. }` tail call arguments

tracking issue: https://github.com/rust-lang/rust/issues/112788
fixes https://github.com/rust-lang/rust/issues/144855

And add a bunch of tests for tail call target support.

r? WaffleLapkin
2026-03-05 06:31:36 +01:00
Folkert de Vries 391a7554f3 enable PassMode::Indirect { on_stack: true } tail call arguments 2026-03-04 19:43:12 +01:00
bjorn3 6ea5244ebf Move some methods to WriteBackendMethods 2026-03-03 15:26:30 +00:00
bjorn3 eff0d4c6f4 Fuse codegen into LTO optimize methods 2026-03-03 15:25:43 +00:00
bjorn3 22d4bb2592 Move print_pass_timings and print_statistics calls to rustc_interface 2026-03-03 15:25:42 +00:00
bjorn3 9e917ee7a6 Replace spawn_named_thread method with thread_profiler 2026-03-03 15:25:00 +00:00
bjorn3 dc3db2373c Slightly simplify write_bitcode_to_file handling
This also causes bitcode to be saved for the allocator shim with
-Csave-temps.
2026-03-03 15:24:16 +00:00
bjorn3 5aa980e6dc Replace CodegenResults with CompiledModules
This is already CodegenResults without CrateInfo. The driver can
calculate the CrateInfo and pass it by-ref to the backend. Using
CompiledModules makes it a bit easier to move some other things out of
the backend as will be necessary for moving LTO to the link phase.
2026-03-02 16:39:41 +00:00
bjorn3 a192c617ec Use CompiledModules inside CodegenResults
In preparation for fully replacing CodegenResults with CompiledModules.
2026-03-02 16:39:13 +00:00