about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2024-07-16Rollup merge of #127512 - eggyal:newline-terminate-print-linkargs, ↵Trevor Gross-1/+1
r=compiler-errors Terminate `--print link-args` output with newline Fixes #127507
2024-07-16Rollup merge of #124033 - bjorn3:ar_archive_writer_0_3_0, r=davidtwcoTrevor Gross-13/+12
Sync ar_archive_writer to LLVM 18.1.3 From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files.
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-1/+1
2024-07-09Terminate `--print link-args` output with newlineAlan Egerton-1/+1
2024-07-07Fix review commentsbjorn3-1/+1
2024-07-07Sync ar_archive_writer to LLVM 18.1.3bjorn3-13/+12
From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files.
2024-07-07use "bootstrap" instead of "rustbuild" in comments and docsonur-ozkan-1/+1
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-02linker: Link dylib crates by pathVadim Petrochenkov-85/+94
2024-07-01linker: Bail out of rpath logic early if the target doesn't support rpathVadim Petrochenkov-10/+4
2024-07-01linker: Refactor interface for passing arguments to linkerVadim Petrochenkov-373/+314
2024-06-25Rollup merge of #126943 - Urgau:dedup-all, r=petrochenkovMatthias Krüger-5/+2
De-duplicate all consecutive native libs regardless of their options Address https://github.com/rust-lang/rust/pull/126913#issuecomment-2188184011 by no longer de-duplicating based on the "options" but by only looking at the generated link args, as to avoid consecutive libs that originated from different native-lib with different options (like `raw-dylib` on Windows) but isn't relevant for `--print=native-static-libs`. r? ``@petrochenkov``
2024-06-25De-duplicate all consecutive native libs regardless of their optionsUrgau-5/+2
2024-06-24Rollup merge of #124712 - Enselic:deprecate-inline-threshold, r=pnkfelixMichael Goulet-2/+0
Deprecate no-op codegen option `-Cinline-threshold=...` This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago. Recommend using `-Cllvm-args=--inline-threshold=...` instead. Closes #89742 which is E-help-wanted.
2024-06-19Rollup merge of #126594 - zetanumbers:fix-cross-crate-async-drop-glue, r=oli-obkLeón Orell Valerian Liehr-10/+13
Make async drop code more consistent with regular drop code Fixes #126573 Relates to #126482 r? ````@petrochenkov````
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-8/+15
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18Apply suggestions from oli-obk's reviewDaria Sukhonina-10/+4
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2024-06-18Make async drop code more consistent with regular drop codeDaria Sukhonina-5/+14
Fixes #126573
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-5/+5
2024-06-14rustc_codegen_ssa: Remove unused ModuleConfig::inline_thresholdMartin Nordholts-2/+0
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-1/+1
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-05Rollup merge of #125861 - name1e5s:fix/rpath_null_panic, r=michaelwoeristerMatthias Krüger-0/+21
rustc_codegen_ssa: fix `get_rpath_relative_to_output` panic when lib only contains file name <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> When compiles program with `-C rpath=yes` but with no output filename specified, or with filename ONLY, we will get an ICE for now. Fix it by treat empty `output` path in `get_rpath_relative_to_output` as current dir. Before this patch: ```bash rustc -C prefer_dynamic=yes -C rpath=yes -O h.rs # ICE, no output filename specified rustc -o hello -C prefer_dynamic=yes -C rpath=yes -O h.rs # ICE, output filename has no path rustc -o ./hello -C prefer_dynamic=yes -C rpath=yes -O h.rs # Works ``` All those examples work after the patch. Close #119571. Close #125785.
2024-06-04Auto merge of #122597 - pacak:master, r=bjorn3bors-0/+23
Show files produced by `--emit foo` in json artifact notifications Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`. Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477 Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: https://github.com/hintron/computer-enhance/issues/35 This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files. Most users won't notice this behavior, to be affected by it all of the following must hold: - user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything) - user must specify both `--emit xxx` and `--json artifacts` - user must refuse to handle unknown artifact types - user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
2024-06-02rustc_codegen_ssa: fix get_rpath_relative_to_output panic when lib only ↵Hai-Hsin-0/+21
contains file name
2024-05-24Auto merge of #125463 - GuillaumeGomez:rollup-287wx4y, r=GuillaumeGomezbors-2/+19
Rollup of 6 pull requests Successful merges: - #125263 (rust-lld: fallback to rustc's sysroot if there's no path to the linker in the target sysroot) - #125345 (rustc_codegen_llvm: add support for writing summary bitcode) - #125362 (Actually use TAIT instead of emulating it) - #125412 (Don't suggest adding the unexpected cfgs to the build-script it-self) - #125445 (Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs`) - #125452 (Cleanup check-cfg handling in core and std) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-23Rollup merge of #125345 - durin42:thin-link-bitcode, r=bjorn3Guillaume Gomez-1/+10
rustc_codegen_llvm: add support for writing summary bitcode Typical uses of ThinLTO don't have any use for this as a standalone file, but distributed ThinLTO uses this to make the linker phase more efficient. With clang you'd do something like `clang -flto=thin -fthin-link-bitcode=foo.indexing.o -c foo.c` and then get both foo.o (full of bitcode) and foo.indexing.o (just the summary or index part of the bitcode). That's then usable by a two-stage linking process that's more friendly to distributed build systems like bazel, which is why I'm working on this area. I talked some to `@teresajohnson` about naming in this area, as things seem to be a little confused between various blog posts and build systems. "bitcode index" and "bitcode summary" tend to be a little too ambiguous, and she tends to use "thin link bitcode" and "minimized bitcode" (which matches the descriptions in LLVM). Since the clang option is thin-link-bitcode, I went with that to try and not add a new spelling in the world. Per `@dtolnay,` you can work around the lack of this by using `lld --thinlto-index-only` to do the indexing on regular .o files of bitcode, but that is a bit wasteful on actions when we already have all the information in rustc and could just write out the matching minimized bitcode. I didn't test that at all in our infrastructure, because by the time I learned that I already had this patch largely written.
2024-05-23Rollup merge of #125263 - lqd:lld-fallback, r=petrochenkovGuillaume Gomez-1/+9
rust-lld: fallback to rustc's sysroot if there's no path to the linker in the target sysroot As seen in #125246, some sysroots don't expect to contain `rust-lld` and want to keep it that way, so we fallback to the default rustc sysroot if there is no path to the linker in any of the sysroot tools search paths. This is how we locate codegen-backends' dylibs already. People also have requested an error if none of these search paths contain the self-contained linker directory, so there's also an error in that case. r? `@petrochenkov` cc `@ehuss` `@RalfJung` I'm not sure where we check for `rust-lld`'s existence on the targets where we use it by default, and if we just ignore it when missing or emit a warning (as I assume we don't emit an error), so I just checked for the existence of `gcc-ld`, where `cc` will look for the lld-wrapper binaries. <sub>*Feel free to point out better ways to do this, it's the middle of the night here.*</sub> Fixes #125246
2024-05-23Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726bors-0/+5
Remove more `#[macro_use] extern crate tracing` Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. Continuing the work from #124511 and #124914. r? `@jackh726`
2024-05-23cleanup: standardize on summary over index in namesAugie Fackler-3/+3
I did this in the user-facing logic, but I noticed while fixing a minor defect that I had missed it in a few places in the internal details.
2024-05-23thinlto: only build summary file if neededAugie Fackler-1/+1
If we don't do this, some versions of LLVM (at least 17, experimentally) will double-emit some error messages, which is how I noticed this. Given that it seems to be costing some extra work, let's only request the summary bitcode production if we'll actually bother writing it down, otherwise skip it.
2024-05-23emit an error if we can't find a path to the self-contained linkerRémy Rakic-3/+3
2024-05-23rust-lld: fallback to the default default sysroot where rustc is currently ↵Rémy Rakic-1/+9
located
2024-05-23Rollup merge of #125438 - tbu-:pr_rm_to_string_lossy, r=jieyouxuMatthias Krüger-4/+4
Remove unneeded string conversion
2024-05-23Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obkMatthias Krüger-1/+1
rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_codegen_ssa`.Nicholas Nethercote-0/+5
2024-05-23Remove unneeded string conversionTobias Bucher-4/+4
2024-05-22rustc_codegen_llvm: add support for writing summary bitcodeAugie Fackler-0/+9
Typical uses of ThinLTO don't have any use for this as a standalone file, but distributed ThinLTO uses this to make the linker phase more efficient. With clang you'd do something like `clang -flto=thin -fthin-link-bitcode=foo.indexing.o -c foo.c` and then get both foo.o (full of bitcode) and foo.indexing.o (just the summary or index part of the bitcode). That's then usable by a two-stage linking process that's more friendly to distributed build systems like bazel, which is why I'm working on this area. I talked some to @teresajohnson about naming in this area, as things seem to be a little confused between various blog posts and build systems. "bitcode index" and "bitcode summary" tend to be a little too ambiguous, and she tends to use "thin link bitcode" and "minimized bitcode" (which matches the descriptions in LLVM). Since the clang option is thin-link-bitcode, I went with that to try and not add a new spelling in the world. Per @dtolnay, you can work around the lack of this by using `lld --thinlto-index-only` to do the indexing on regular .o files of bitcode, but that is a bit wasteful on actions when we already have all the information in rustc and could just write out the matching minimized bitcode. I didn't test that at all in our infrastructure, because by the time I learned that I already had this patch largely written.
2024-05-22self-contained linker: retry without -fuse-ld=lld on older GCCsRémy Rakic-0/+21
2024-05-22rustc: Use `tcx.used_crates(())` moreVadim Petrochenkov-1/+1
And explain when it should be used.
2024-05-21Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvallebors-1/+4
Relax restrictions on multiple sanitizers Most combinations of LLVM sanitizers are legal-enough to enable simultaneously. This change will allow simultaneously enabling ASAN and shadow call stacks on supported platforms. I used this python script to generate the mutually-exclusive sanitizer combinations: ```python #!/usr/bin/python3 import subprocess flags = [ ["-fsanitize=address"], ["-fsanitize=leak"], ["-fsanitize=memory"], ["-fsanitize=thread"], ["-fsanitize=hwaddress"], ["-fsanitize=cfi", "-flto", "-fvisibility=hidden"], ["-fsanitize=memtag", "--target=aarch64-linux-android", "-march=armv8a+memtag"], ["-fsanitize=shadow-call-stack"], ["-fsanitize=kcfi", "-flto", "-fvisibility=hidden"], ["-fsanitize=kernel-address"], ["-fsanitize=safe-stack"], ["-fsanitize=dataflow"], ] for i in range(len(flags)): for j in range(i): command = ["clang++"] + flags[i] + flags[j] + ["-o", "main.o", "-c", "main.cpp"] completed = subprocess.run(command, stderr=subprocess.DEVNULL) if completed.returncode != 0: first = flags[i][0][11:].replace('-', '').upper() second = flags[j][0][11:].replace('-', '').upper() print(f"(SanitizerSet::{first}, SanitizerSet::{second}),") ```
2024-05-15Don't link lsan rt if asan or hwasan are enabledDavid Koloski-1/+4
2024-05-03rustc: Don't pass `-fuse-ld=lld` on wasm targetsAlex Crichton-1/+7
This argument isn't necessary for WebAssembly targets since `wasm-ld` is the only linker for the targets. Passing it otherwise interferes with Clang's linker selection on `wasm32-wasip2` so avoid it altogether.
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+5
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+41
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-22Auto merge of #115120 - icedrocket:ignore-strip-on-msvc, r=michaelwoeristerbors-42/+35
Ignore `-C strip` on MSVC tl;dr - Define `-Cstrip` to only ever affect the binary; no other build artifacts. This is necessary to improve cross-platform behavior consistency: if someone wanted debug information to be contained only in separate files on all platforms, they would set `-Cstrip=symbols` and `-Csplit-debuginfo=packed`, but this would result in no PDB files on MSVC. Resolves #114215
2024-04-19Show files produced by --emit foo in json artifact notificationsMichael Baikov-0/+23
2024-04-17Use non-exhaustive matches for TyKindDaria Sukhonina-1/+1
Also no longer export noop async_drop_in_place_raw
2024-04-17Rollup merge of #122723 - bjorn3:archive_writer_fixes, r=nnethercoteMatthias Krüger-8/+19
Use same file permissions for ar_archive_writer as the LLVM archive writer This is required to switch to ar_archive_writer in the future without regressions. In addition to this PR support for reading thin archives needs to be added (https://github.com/rust-lang/rust/issues/107407) to fix all known regressions. Fixes https://github.com/rust-lang/rust/issues/107495
2024-04-17Use the default file permissions when writingbjorn3-8/+19
static libraries with ar_archive_writer Fixes #107495
2024-04-16Rollup merge of #124023 - pacak:less-splody, r=jieyouxuGuillaume Gomez-8/+5
Allow workproducts without object files. This pull request partially reverts changes from e16c3b4a4421 Original motivation for this assert was described with "A WorkProduct without a saved file is useless" which was true at the time but now it is possible to have work products with other types of files (llvm-ir, asm, etc) and there are bugreports for this failure: For example: https://github.com/rust-lang/rust/issues/123695 Fixes https://github.com/rust-lang/rust/issues/123234 Now existing `assert` and `.unwrap_or_else` are unified into a single check that emits slightly more user friendly error message if an object files was meant to be produced but it's missing
2024-04-16Add simple async drop glue generationzetanumbers-0/+41
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801