summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
AgeCommit message (Collapse)AuthorLines
2024-10-11Rollup merge of #129079 - Zoxc:thinlto_imp_symbols, r=wesleywiserMatthias Krüger-1/+7
Create `_imp__` symbols also when doing ThinLTO When generating a rlib crate on Windows we create `dllimport` / `_imp__` symbols for each global. This effectively makes the rlib contain an import library for itself and allows them to both be dynamically and statically linked. However when doing ThinLTO we do not generate these and thus we end up with missing symbols. Microsoft's `link` can fix these up (and emits warnings), but `lld` seems to currently be unable to. This PR also does this generation for ThinLTO avoiding those issues with `lld` and also avoids the warnings on `link`. This is an workaround for https://github.com/rust-lang/rust/issues/81408. cc `@lqd`
2024-10-10Rollup merge of #131480 - madsmtm:macos-fix-strip-binary, r=nnethercoteMatthias Krüger-1/+3
Fix hardcoded strip path when cross-compiling from Linux to Darwin Fixes https://github.com/rust-lang/rust/issues/131206. I fear that https://github.com/rust-lang/rust/pull/131405 might end up taking some time, so opening this PR to resolve the regression. `@rustbot` label O-apple
2024-10-10Fix hardcoded strip path when cross-compiling from Linux to DarwinMads Marquart-1/+3
2024-10-10Avoid redundant -Wl,-dylib flag when linkingMads Marquart-3/+5
2024-10-07Convert `Option<&Lrc<T>>` return types to `Option<&T>`.Nicholas Nethercote-3/+2
It's simpler and more concise.
2024-10-02Rollup merge of #131016 - madsmtm:no-sdk-version-in-object, r=jieyouxuMatthias Krüger-10/+48
Apple: Do not specify an SDK version in `rlib` object files This was added in https://github.com/rust-lang/rust/pull/114114, but is unnecessary, since it ends up being overwritten when linking anyhow, and it feels wrong to embed some arbitrary SDK version in here. The object files produced by LLVM also do not set this, and the tooling shows `n/a` when it's `0`, so it seems to genuinely be optional in object files. I've also added a test for the different places the SDK version shows up, and documented a bit more in the code how SDK versions work. See https://github.com/rust-lang/rust/issues/129432 for the bigger picture. Tested with (excludes the same few targets as in https://github.com/rust-lang/rust/pull/130435): ```console ./x test tests/run-make/apple-sdk-version --target aarch64-apple-darwin,aarch64-apple-ios,aarch64-apple-ios-macabi,aarch64-apple-ios-sim,aarch64-apple-tvos,aarch64-apple-tvos-sim,aarch64-apple-visionos,aarch64-apple-visionos-sim,aarch64-apple-watchos,aarch64-apple-watchos-sim,arm64_32-apple-watchos,armv7k-apple-watchos,armv7s-apple-ios,x86_64-apple-darwin,x86_64-apple-ios,x86_64-apple-ios-macabi,x86_64-apple-tvos,x86_64-apple-watchos-sim,x86_64h-apple-darwin IPHONEOS_DEPLOYMENT_TARGET=10.0 ./x test tests/run-make/apple-sdk-version --target=i386-apple-ios ``` CC `@BlackHoleFox,` you [originally commented on these values](https://github.com/rust-lang/rust/pull/114114#discussion_r1300599445). `@rustbot` label O-apple
2024-09-29Do not specify an SDK version in object filesMads Marquart-3/+7
This is unnecessary, since it ends up being overwritten when linking anyhow, and it feels wrong to embed some arbitrary SDK version in here.
2024-09-29Document a bit more how the SDK version actually worksMads Marquart-7/+41
2024-09-27Only add an automatic SONAME for Rust dylibsJosh Stone-15/+70
2024-09-26Move Apple linker args from `rustc_target` to `rustc_codegen_ssa`Mads Marquart-1/+132
They are dependent on the deployment target and SDK version, but having these in `rustc_target` makes it hard to introduce that dependency.
2024-09-25Rollup merge of #130781 - monkeydbobo:mdb/fix_up_cross_compile_osx, r=davidtwcoMatthias Krüger-3/+4
Fix up setting strip = true in Cargo.toml makes build scripts fail in… Fix issue: https://github.com/rust-lang/rust/issues/110536 Strip binary is PATH dependent which breaks builds in MacOS. For example, on my Mac, the output of 'which strip' is '/opt/homebrew/opt/binutils/bin/strip', which leads to incorrect 'strip' results. Therefore, just like on other systems, it is also necessary to specify 'stripcmd' on macOS. However, it seems that there is a bug in binutils [bugzilla-Bug 31571](https://sourceware.org/bugzilla/show_bug.cgi?id=31571), which leads to the problem mentioned above.
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-8/+7
2024-09-24Fix up setting strip = true in Cargo.toml makes build scripts fail in ↵monkeydbobo-3/+4
release mode on MacOS
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-137/+98
2024-09-22Create _imp__ symbols also when doing ThinLTOJohn Kåre Alsaker-1/+7
2024-09-18Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukangMatthias Krüger-2/+2
Implement a Method to Seal `DiagInner`'s Suggestions This PR adds a method on `DiagInner` called `.seal_suggestions()` to prevent new suggestions from being added while preserving existing suggestions. This is useful because currently there is no way to prevent new suggestions from being added to a diagnostic. `.disable_suggestions()` is the closest but it gets rid of all suggestions before and after the call. Therefore, `.seal_suggestions()` can be used when, for example, misspelled keyword is detected and reported. In such cases, we may want to prevent other suggestions from being added to the diagnostic, as they would likely be meaningless once the misspelled keyword is identified. For context: https://github.com/rust-lang/rust/pull/129899#discussion_r1741307132 To store an additional state, the type of the `suggestions` field in `DiagInner` was changed into a three variant enum. While this change affects files across different crates, care was taken to preserve the existing code's semantics. This is validated by the fact that all UI tests pass without any modifications. r? chenyukang
2024-09-17Rollup merge of #130458 - nnethercote:rustc_codegen_ssa-cleanups, r=jieyouxuMatthias Krüger-68/+76
`rustc_codegen_ssa` cleanups Just some minor improvements I found while reading through this code. r? ``@jieyouxu``
2024-09-17Minimize visibilities.Nicholas Nethercote-68/+76
This makes it much clearer which things are used outside the crate.
2024-09-16Rollup merge of #123436 - ↵Matthias Krüger-2/+10
amyspark:allow-msvc-to-use-meson-and-mingw-import-libraries, r=petrochenkov linker: Allow MSVC to use import libraries following the Meson/MinGW convention Hi all, This PR implements support for `MsvcLinker` to use import libraries following Meson and the MinGW toolchain's naming convention. Meson [follows the `libfoo.dll.a` naming convention](https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa) to disambiguate between static and import libraries. This support already existed for static libraries (see #100101), but not for dynamic libraries. The latter case was added by duplicating the logic in `native_libs::find_native_static_library`, but a separate case was added in `link_dylib_by_name` for the Windows CRT libraries which must be handled by the linker itself. See for prerequisites #129366, #126094, and #128370. All feedback is appreciated! Fixes #122455 cc `@sdroege` `@nirbheek`
2024-09-14Fix SDKROOT ignore on macOSMads Marquart-1/+1
2024-09-12Implement a Method to Seal `DiagInner`'s SuggestionsVeera-2/+2
2024-09-12Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoeristerStuart Cook-25/+15
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
2024-09-11Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errorsJubilee-8/+7
Remove needless returns detected by clippy in the compiler
2024-09-11Also fix if in elseMichael Goulet-25/+15
2024-09-09Rollup merge of #129981 - nnethercote:rm-serialize_bitcode, r=antoyo,tmiaskoJubilee-8/+4
Remove `serialized_bitcode` from `LtoModuleCodegen`. It's unused. r? ``@bjorn3``
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-8/+7
2024-09-09Remove `serialized_bitcode` from `LtoModuleCodegen`.Nicholas Nethercote-8/+4
It's unused.
2024-09-08MsvcLinker: allow linking dynamically to Meson and MinGW-style named librariesL. E. Segovia-2/+10
Fixes #122455
2024-09-05Apple: Refactor deployment target version parsingMads Marquart-9/+24
- Merge minimum OS version list into one function (makes it easier to see the logic in it). - Parse patch deployment target versions. - Consistently specify deployment target in LLVM target (previously omitted on `aarch64-apple-watchos`).
2024-08-31Rollup merge of #129366 - petrochenkov:libsearch, r=jieyouxuMatthias Krüger-50/+25
linker: Synchronize native library search in rustc and linker Also search for static libraries with alternative naming (`libname.a`) on MSVC when producing executables or dynamic libraries, and not just rlibs. This unblocks https://github.com/rust-lang/rust/pull/123436. try-job: x86_64-msvc
2024-08-29Rollup merge of #128970 - DianQK:lint-llvm-ir, r=nikicGuillaume Gomez-0/+2
Add `-Zlint-llvm-ir` This flag is similar to `-Zverify-llvm-ir` and allows us to lint the generated IR. r? compiler
2024-08-29Add `-Zlint-llvm-ir`DianQK-0/+2
2024-08-27linker: Better support alternative static library naming on MSVCVadim Petrochenkov-4/+10
Previously `libname.a` naming was supported as a fallback when producing rlibs, but not when producing executables or dynamic libraries
2024-08-27linker: Synchronize native library search in rustc and linkerVadim Petrochenkov-46/+15
2024-08-27Rollup merge of #129418 - petrochenkov:libsearch2, r=jieyouxuTrevor Gross-16/+11
rustc: Simplify getting sysroot library directory It was very non-obvious that `sess.target_tlib_path`, `make_target_lib_path(...)`, and `sess.target_filesearch(...).search_paths()` result in the same sysroot library directory paths. They are however, indeed the same, because `sess.target_tlib_path` is initialized to `make_target_lib_path(...)` on `Session` creation, and they are used interchangeably. There are still some redundant calls to `make_target_lib_path` and other inconsistent ways to obtain sysroot directories, but fixing that requires some behavior changes, while this PR is a pure refactoring. Some places in the compiler even disagree on the number of sysroots - 1 (explicit `--sysroot` *or* default sysroot), 2 (explicit `--sysroot` *and* default sysroot), or an unclear number of `sysroot_candidates` every of which is considered. The logic currently using `sess.target_tlib_path` or equivalents assumes one sysroot.
2024-08-27Rollup merge of #126013 - nnethercote:unreachable_pub, r=UrgauMatthias Krüger-3/+3
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
2024-08-24Fix `elided_named_lifetimes` in codePavel Grigorenko-1/+1
2024-08-22rustc: Simplify getting sysroot library directoryVadim Petrochenkov-16/+11
2024-08-22Auto merge of #129257 - ChrisDenton:rename-null-descriptor, r=jieyouxubors-1/+5
Allow rust staticlib to work with MSVC's /WHOLEARCHIVE This fixes #129020 by renaming the `__NULL_IMPORT_DESCRIPTOR` to prevent conflicts. try-job: dist-i686-msvc
2024-08-21Simplify some redundant field namesMichael Goulet-2/+2
2024-08-20Make import libraries compatible with wholearchiveChris Denton-1/+5
2024-08-17Always use ar_archive_writer for import libsChris Denton-3/+83
2024-08-16Add `warn(unreachable_pub)` to `rustc_codegen_ssa`.Nicholas Nethercote-3/+3
2024-08-15Auto merge of #128936 - bjorn3:fix_thin_archive_reading, r=jieyouxubors-4/+9
Support reading thin archives in ArArchiveBuilder And switch to using ArArchiveBuilder with the LLVM backend too now that all regressions are fixed. Fixes https://github.com/rust-lang/rust/issues/107407 Fixes https://github.com/rust-lang/rust/issues/107162 https://github.com/rust-lang/rust/issues/107495 has been fixed in a previous PR already.
2024-08-12Rollup merge of #128978 - compiler-errors:assert-matches, r=jieyouxuGuillaume Gomez-1/+2
Use `assert_matches` around the compiler more It's a useful assertion, especially since it actually prints out the LHS.
2024-08-11Use assert_matches around the compilerMichael Goulet-1/+2
2024-08-11Fix review comments and other improvementsbjorn3-4/+2
2024-08-10Auto merge of #128400 - petrochenkov:nowhole3, r=bjorn3bors-10/+1
linker: Remove the "`--whole-archive` in test mode" backcompat hack Fixes https://github.com/rust-lang/rust/issues/116910.
2024-08-10Support reading thin archives in ArArchiveBuilderbjorn3-4/+11
2024-08-07Rollup merge of #128772 - glaubitz:sparc-elf-fix, r=nagisaMatthias Krüger-0/+1
rustc_codegen_ssa: Set architecture for object crate for 32-bit SPARC The `object` crate was recently updated to recognize the 32-bit SPARC ELF targets `EM_SPARC` and `EM_SPARC32PLUS`, so the proper architecture for 32-bit SPARC can now be set in `rustc_codegen_ssa`. r? nagisa