about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2025-01-27Change `collect_and_partition_mono_items` tuple return type to a structOli Scherer-1/+1
2025-01-25Shorten linker output even more when `--verbose` is not presentjyn-1/+17
- Don't show environment variables. Seeing PATH is almost never useful, and it can be extremely long. - For .rlibs in the sysroot, replace crate hashes with a `"-*"` string. This will expand to the full crate name when pasted into the shell. - Move `.rlib` to outside the glob. - Abbreviate the sysroot path to `<sysroot>` wherever it appears in the arguments. This also adds an example of the linker output as a run-make test. Currently it only runs on x86_64-unknown-linux-gnu, because each platform has its own linker arguments. So that it's stable across machines, pass BUILD_ROOT as an argument through compiletest through to run-make tests. - Only use linker-flavor=gnu-cc if we're actually going to compare the output. It doesn't exist on MacOS.
2025-01-25Auto merge of #119286 - jyn514:linker-output, r=bjorn3bors-13/+63
show linker output even if the linker succeeds Show stderr and stderr by default, controlled by a new `linker_messages` lint. fixes https://github.com/rust-lang/rust/issues/83436. fixes https://github.com/rust-lang/rust/issues/38206. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134 <!-- try-job: dist-x86_64-msvc --> try-job: aarch64-apple r? `@bjorn3`
2025-01-24Make CodegenCx and Builder genericManuel Drehwald-3/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2025-01-24Silence progress messages from MSVC link.exejyn-12/+29
These cannot be silenced with a CLI flag, and are not useful to warn about. They can still be viewed for debugging purposes using `RUSTC_LOG=rustc_codegen_ssa::link::back`.
2025-01-20Don't require `--verbose` to show linker stdoutjyn-4/+7
2025-01-20make it possible to silence linker warnings with a crate-level attributejyn-7/+14
this was slightly complicated because codegen_ssa doesn't have access to a tcx.
2025-01-20show linker warnings even if it returns 0jyn-2/+25
2025-01-13Fix emscripten-wasm-eh with unwind=abortHood Chatham-3/+3
If we build the standard library with wasm-eh then we need to link with `-fwasm-exceptions` even if we compile with `panic=abort` Without this change, linking a `panic=abort` crate fails with: `undefined symbol: __cpp_exception`. Followup to #131830.
2025-01-06Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubileeJacob Pratt-3/+5
Add support for wasm exception handling to Emscripten target This is a draft because we need some additional setting for the Emscripten target to select between the old exception handling and the new exception handling. I don't know how to add a setting like that, would appreciate advice from Rust folks. We could maybe choose to use the new exception handling if `Ctarget-feature=+exception-handling` is passed? I tried this but I get errors from llvm so I'm not doing it right.
2025-01-06Add support for wasm exception handling to Emscripten targetHood Chatham-3/+5
Gated behind an unstable `-Z emscripten-wasm-eh` flag
2025-01-04Auto merge of #133955 - bjorn3:cc_pass_arch_only, r=ChrisDentonbors-8/+3
Pass the arch rather than full target name to windows_registry::find_tool The full target name can be anything with custom target specs. Passing just the arch wasn't possible before cc 1.2, but is now thanks to https://github.com/rust-lang/cc-rs/pull/1285. try-job: i686-msvc
2025-01-02Pass objcopy args for stripping on OSXNoratrieb-18/+7
When `-Cstrip` was changed to use the bundled rust-objcopy instead of /usr/bin/strip on OSX, strip-like arguments were preserved. But strip and objcopy are, while being the same binary, different, they have different defaults depending on which binary they are. Notably, strip strips everything by default, and objcopy doesn't strip anything by default. Additionally, `-S` actually means `--strip-all`, so debuginfo stripped everything and symbols didn't strip anything. We now correctly pass `--strip-debug` and `--strip-all`.
2025-01-01upstream rustc_codegen_llvm changes for enzyme/autodiffManuel Drehwald-0/+21
2024-12-29review fixes: Adjust whitespacePiotr Osiewicz-0/+3
2024-12-29rustc_codegen_ssa: Buffer file writes in link_rlibPiotr Osiewicz-5/+5
This makes this step take ~25ms on my machine (M3 Max 64GB) for Zed repo instead of ~150ms. Additionally it takes down the time needed for a clean cargo build of ripgrep from ~6.1s to 5.9s. This change is mostly relevant for crates with multiple large CGUs.
2024-12-20Rollup merge of #134561 - bjorn3:less_fatal_error_raise, r=compiler-errorsMatthias Krüger-6/+6
Reduce the amount of explicit FatalError.raise() Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These guarantee that an error actually happened previously and thus we don't silently abort.
2024-12-20Reduce the amount of explicit FatalError.raise()bjorn3-6/+6
Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These guarantee that an error actually happened previously and thus we don't silently abort.
2024-12-20Review commentsbjorn3-3/+2
2024-12-19Make DependencyList an IndexVecbjorn3-11/+6
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-5/+4
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-2/+3
2024-12-15Rollup merge of #133633 - jyn514:hide-linker-args, r=bjorn3,jyn514Stuart Cook-2/+2
don't show the full linker args unless `--verbose` is passed the linker arguments can be *very* long, especially for crates with many dependencies. often they are not useful. omit them unless the user specifically requests them. split out from https://github.com/rust-lang/rust/pull/119286. fixes https://github.com/rust-lang/rust/issues/109979. r? `@bjorn3` try-build: i686-mingw
2024-12-14don't show the full linker args unless `--verbose` is passedjyn-2/+2
the linker arguments can be *very* long, especially for crates with many dependencies. some parts of them are not very useful. unless specifically requested: - omit object files specific to the current invocation - fold rlib files into a single braced argument (in shell expansion format) this shortens the output significantly without removing too much information.
2024-12-13Make dependency_formats an FxIndexMap rather than a list of tuplesbjorn3-22/+14
It is treated as a map already. This is using FxIndexMap rather than UnordMap because the latter doesn't provide an api to pick a single value iff all values are equal, which each_linked_rlib depends on.
2024-12-13Remove jobserver from Sessionbjorn3-5/+2
It is effectively a global resource and the jobserver::Client in Session was a clone of GLOBAL_CLIENT anyway.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-13/+8
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-12-11Rollup merge of #134139 - mustartt:pgo-linker-flag, r=saethlinJacob Pratt-0/+2
[AIX] keep profile-rt symbol alive Clang passes `-u __llvm_profile_runtime` on AIX. https://reviews.llvm.org/D136192 We want to preserve the symbol in the case there are no instrumented object files.
2024-12-10Rollup merge of #133967 - daltenty:daltenty/bnoipath, r=jieyouxuLeón Orell Valerian Liehr-0/+9
[AIX] Pass -bnoipath when adding rust upstream dynamic crates Unlike ELF linkers, AIX doesn't feature `DT_SONAME` to override the dependency name when outputing a shared library, which is something we rely on for dylib crates. See for reference: https://github.com/rust-lang/rust/blob/bc145cec4565a97a1b08df52d26ddf48ce3d7d0a/compiler/rustc_codegen_ssa/src/back/linker.rs#L464) Thus, `ld` on AIX will use the full path to shared libraries as the dependency if passed it by default unless `noipath` is passed, so pass it here so we don't end up with full path dependencies for dylib crates.
2024-12-08Pass the arch rather than full target name to windows_registry::find_toolbjorn3-8/+3
The full target name can be anything with custom target specs. Passing just the arch wasn't possible before cc 1.2, but is now.
2024-12-06Remove all threading through of ErrorGuaranteed from the driverbjorn3-32/+24
It was inconsistently done (sometimes even within a single function) and most of the rest of the compiler uses fatal errors instead, which need to be caught using catch_with_exit_code anyway. Using fatal errors instead of ErrorGuaranteed everywhere in the driver simplifies things a bit.
2024-12-06Store a single copy of the error registry in DiagCtxtbjorn3-1/+5
And pass this to the individual emitters when necessary.
2024-12-06Move some timers aroundbjorn3-2/+0
2024-12-06Clarify commentDavid Tenty-2/+4
2024-12-06Pass -bnoipath when adding rust upstream dynamic cratesKai Luo-0/+7
2024-12-03keep profile-rt symbol aliveHenry Jiang-0/+2
2024-12-03Rollup merge of #133041 - madsmtm:print-deployment-target-env-var, r=davidtwcoMatthias Krüger-1/+1
Print name of env var in `--print=deployment-target` The deployment target environment variable is OS-specific, and if you're in a place where you're asking `rustc` for the deployment target, you're likely to also wanna know the name of the environment variable. I myself wanted this for some code I'm working on in bootstrap, for example. Behaviour before this PR: ```console $ rustc --print=deployment-target --target=aarch64-apple-darwin deployment_target=11.0 $ rustc --print=deployment-target --target=aarch64-apple-visionos deployment_target=1.0 ``` Behaviour after this PR: ```console $ rustc --print=deployment-target --target=aarch64-apple-darwin MACOSX_DEPLOYMENT_TARGET=11.0 $ rustc --print=deployment-target --target=aarch64-apple-visionos XROS_DEPLOYMENT_TARGET=1.0 ``` My _belief_ is that this option is extremely rarely used in general, and a GitHub search for "rustc print deployment-target" seems to confirm this, it revealed only the following actual pieces of code using this: - https://github.com/PyO3/maturin/blob/b292ef69349f2a56cb8ab1b59fda0be3d3b9f138/src/build_context.rs#L1199-L1220 - https://github.com/rust-lang/cc-rs/blob/daab9244b03e244c4f2511944870d719c443f61f/src/lib.rs#L3422-L3426 `maturin` does `.split('=').last()`, so it will continue to work after this change, but `cc v1.0.84` did `.strip_prefix("deployment_target=")` since [this PR](https://github.com/rust-lang/cc-rs/pull/848), so it would break. That's _probably_ fine though, it was broken in a lot of scenarios anyway, and [got](https://github.com/rust-lang/cc-rs/pull/901) [reverted](https://github.com/rust-lang/cc-rs/pull/943) in `v1.0.85`. So while this is _technically_ a breaking change, I really doubt that anyone is going to observe it, so it's probably fine. ``@BlackHoleFox`` wdyt? ``@rustbot`` label O-apple r? compiler
2024-12-01Rollup merge of #132974 - madsmtm:linker-arguments-with-commas, r=petrochenkovMatthias Krüger-61/+82
Properly pass linker arguments that contain commas When linking with the system C compiler, we sometimes want to forward certain arguments unchanged to the linker. This can be done with `-Wl,arg1,arg2` or `-Xlinker arg1 -Xlinker arg2`. `-Wl` is used when possible, since it is more compact, but it does not support commas in the argument itself - in those cases, we need to use `-Xlinker`, and that is what this PR implements. This also fixes using sanitizers on macOS with `-Clinker-flavor=ld`, as those were previously manually using `-Wl`/`-Xlinker` (probably since the support wasn't present in the `link_args` function). Note that there has been [a previous PR for this](https://github.com/rust-lang/rust/pull/38798), but it only implemented this in certain cases when passing `-rpath`. r? compiler
2024-11-28Share inline(never) generics across cratesMark Rousskov-1/+11
This reduces code sizes and better respects programmer intent when marking inline(never). Previously such a marking was essentially ignored for generic functions, as we'd still inline them in remote crates.
2024-11-26Pass end position of span through inline ASM cookiebeetrees-13/+8
2024-11-25Rollup merge of #133297 - DianQK:embed-bitcode-ios, r=nikic许杰友 Jieyou Xu (Joe)-4/+2
Remove legacy bitcode for iOS Follow #117364.
2024-11-24Remove forces_embed_bitcodeDianQK-4/+2
2024-11-24Remove unnecessary 0 link args optimizationMads Marquart-14/+3
2024-11-24Support rpath with -Clinker-flavor=ldMads Marquart-47/+21
Using `cc_args` panics when using `-Clinker-flavor=ld`, because the arguments are in a form tailored for `-Clinker-flavor=gcc`. So instead, we use `link_args` and let that wrap the arguments with the appropriate `-Wl` or `-Xlinker` when needed.
2024-11-24Support linker arguments that contain commasMads Marquart-9/+67
2024-11-23Rollup merge of #133217 - xingxue-ibm:fix-strip, r=compiler-errors许杰友 Jieyou Xu (Joe)-10/+12
[AIX] Add option -X32_64 to the "strip" command The AIX `strip` utility requires option `-X` to specify the object mode. This patch adds the `-X32_64` option to the `strip` command so that it can handle both 32-bit and 64-bit objects. The parameter `option` of function `strip_symbols_with_external_utility`, previously a single string, has been changed to `options`, an array of string slices, to accommodate multiple `strip` options.
2024-11-22Print env var in --print=deployment-targetMads Marquart-1/+1
The deployment target environment variable is OS-specific, and if you're in a place where you're asking `rustc` for the deployment target, you're likely to also wanna know the environment variable.
2024-11-21Auto merge of #132362 - mustartt:aix-dylib-detection, r=jieyouxubors-2/+39
[AIX] change system dynamic library format Historically on AIX, almost all dynamic libraries are distributed in `.a` Big Archive Format which can consists of both static and shared objects in the same archive (e.g. `libc++abi.a(libc++abi.so.1)`). During the initial porting process, the dynamic libraries are kept as `.a` to simplify the migration, but semantically having an XCOFF object under the archive extension is wrong. For crate type `cdylib` we want to be able to distribute the libraries as archives as well. We are migrating to archives with the following format: ``` $ ar -t lib<name>.a lib<name>.so ``` where each archive contains a single member that is a shared XCOFF object that can be loaded.
2024-11-21Change to pass "strip" options in an array of string slices and add option ↵Xing Xue-10/+12
"-X32_64" for AIX.
2024-11-21aix: fix archive formatHenry Jiang-2/+39
fmt fix cfg for windows remove unused imports address comments update libc to 0.2.164 fmt remove unused imports