Commit graph

172 commits

Author SHA1 Message Date
Mads Marquart
328846c6eb Rename is_like_osx to is_like_darwin 2025-03-25 21:53:52 +01:00
bjorn3
530ab61c0e Also check for compiler-builtins in linked_symbols
Otherwise the linker complains about EC symbols missing when compiling
for arm64ec.
2025-03-21 14:06:34 +00:00
bjorn3
63cfd47cb1 Don't attempt to export compiler-builtins symbols from rust dylibs
They are marked with hidden visibility to prevent them from getting
exported, so we shouldn't ask the linker to export them anyway. The only
thing that does it cause a warning on macOS.
2025-03-21 13:59:51 +00:00
Yotam Ofek
36f6bc5e3d Flatten ifs in rustc_codegen_ssa 2025-03-17 18:56:52 +00:00
Jacob Pratt
19b6743d95
Rollup merge of #137337 - dalvescb:master, r=petrochenkov
Add verbatim linker to AIXLinker

This adds support for the "verbatim" native link modifier on AIX, will successfully pass the `native-link-modifier-verbatim-linker test case`
2025-03-07 21:57:47 -05:00
usamoi
123062bfd9 pass optimization level to llvm-bitcode-linker 2025-02-21 19:38:00 +08:00
Curtis D'Alves
917d2eb78a add verbatim linker to AIXLinker 2025-02-20 14:31:19 -05:00
Patryk Wychowaniec
78ddabf31d
Create a generic AVR target: avr-none
This commit removes the `avr-unknown-gnu-atmega328` target and replaces
it with a more generic `avr-none` variant that must be specialized with
the `-C target-cpu` flag (e.g. `-C target-cpu=atmega328p`).
2025-02-19 19:01:51 +01:00
Jacob Pratt
20004d4bdd
Rollup merge of #135909 - Flakebi:amdgpu-kd, r=jieyouxu,workingjubilee
Export kernel descriptor for amdgpu kernels

The host runtime (HIP or HSA) expects a kernel descriptor object for each kernel in the ELF file. The amdgpu LLVM backend generates the object. It is created as a symbol with the name of the kernel plus a `.kd` suffix.

Add it to the exported symbols in the linker script, so that it can be found.

For reference, the symbol is created here in LLVM: d5457e4c16/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (L966)
I wrote [a test](6a9115b121) for this as well, I’ll add that once the target is merged and working.
With this, all PRs to get working code for amdgpu are open (this + the target + the two patches adding addrspacecasts for alloca and global variables).

Tracking issue: #135024

r? `@workingjubilee`
2025-02-16 00:51:24 -05:00
clubby789
2966256133 Make -O mean -C opt-level=3 2025-02-13 19:47:55 +00:00
Flakebi
99ec64c34c
Export kernel descriptor for amdgpu kernels
The host runtime (HIP or HSA) expects a kernel descriptor object for
each kernel in the ELF file. The amdgpu LLVM backend generates the
object. It is created as a symbol with the name of the kernel plus a
`.kd` suffix.

Add it to the exported symbols in the linker script, so that it can be
found.
2025-02-12 22:44:39 +01:00
bors
2a8af4f7c8 Auto merge of #133955 - bjorn3:cc_pass_arch_only, r=ChrisDenton
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-04 15:42:31 +00:00
bjorn3
7e6be13647 Make DependencyList an IndexVec 2024-12-19 15:30:32 +00:00
Nicholas Nethercote
2620eb42d7 Re-export more rustc_span::symbol things from rustc_span.
`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-18 13:38:53 +11:00
bjorn3
3198496385 Make dependency_formats an FxIndexMap rather than a list of tuples
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-13 11:29:15 +00:00
bjorn3
5e66869c65 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.
2024-12-08 16:59:30 +00:00
Henry Jiang
f4933ffbf1 keep profile-rt symbol alive 2024-12-03 13:04:52 -05:00
Mads Marquart
6bbf832cf2 Remove unnecessary 0 link args optimization 2024-11-24 01:23:19 +01:00
Mads Marquart
45791dde8e Support linker arguments that contain commas 2024-11-24 01:20:28 +01:00
daxpedda
f37d021d6c
Account for wasm32v1-none when exporting TLS symbols 2024-11-20 14:02:25 +01:00
bjorn3
9e6d2da83d Reduce dependence on the target name
The target name can be anything with custom target specs. Matching on
fields inside the target spec is much more robust than matching on the
target name.
2024-11-03 18:29:01 +00:00
Noratrieb
a26450cf81 Rename target triple to target tuple in many places in the compiler
This changes the naming to the new naming, used by `--print
target-tuple`.
It does not change all locations, but many.
2024-11-02 21:29:59 +01:00
Mads Marquart
d6aaf7b036 Avoid redundant -Wl,-dylib flag when linking 2024-10-10 03:51:11 +02:00
Josh Stone
f46057bf1c Only add an automatic SONAME for Rust dylibs 2024-09-27 15:53:26 -07:00
Josh Stone
0999b019f8 Dogfood feature(file_buffered) 2024-09-24 14:25:16 -07:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Matthias Krüger
d5a081981d
Rollup merge of #130458 - nnethercote:rustc_codegen_ssa-cleanups, r=jieyouxu
`rustc_codegen_ssa` cleanups

Just some minor improvements I found while reading through this code.

r? ``@jieyouxu``
2024-09-17 17:28:35 +02:00
Nicholas Nethercote
bdacdfe95f Minimize visibilities.
This makes it much clearer which things are used outside the crate.
2024-09-17 16:24:33 +10:00
Matthias Krüger
eac6f07380
Rollup merge of #123436 - 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-16 18:34:00 +02:00
Stuart Cook
3ba12756d3
Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoerister
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-12 20:37:16 +10:00
Michael Goulet
af8d911d63 Also fix if in else 2024-09-11 17:24:01 -04:00
Eduardo Sánchez Muñoz
0b20ffcb63 Remove needless returns detected by clippy in the compiler 2024-09-09 13:32:22 +02:00
L. E. Segovia
98481be353 MsvcLinker: allow linking dynamically to Meson and MinGW-style named libraries
Fixes #122455
2024-09-08 11:40:28 -03:00
Vadim Petrochenkov
05bd36de50 linker: Better support alternative static library naming on MSVC
Previously `libname.a` naming was supported as a fallback when producing rlibs, but not when producing executables or dynamic libraries
2024-08-27 22:13:31 +03:00
Michael Goulet
0b2525c787 Simplify some redundant field names 2024-08-21 01:31:42 -04:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
onur-ozkan
48192701e0 use "bootstrap" instead of "rustbuild" in comments and docs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-07 00:07:08 +03:00
Vadim Petrochenkov
565ddfb48c linker: Link dylib crates by path 2024-07-02 11:43:17 +03:00
Vadim Petrochenkov
af31c338fc linker: Refactor interface for passing arguments to linker 2024-07-01 14:19:51 +03:00
Nicholas Nethercote
8ae0694fcb Remove #[macro_use] extern crate tracing from rustc_codegen_ssa. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote
99e036bd21 Remove extern crate rustc_middle from numerous crates. 2024-04-29 14:50:45 +10:00
bors
7f2fc33da6 Auto merge of #115120 - icedrocket:ignore-strip-on-msvc, r=michaelwoerister
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-22 12:05:39 +00:00
Vadim Petrochenkov
ed62b57c86 linker: Remove laziness and caching from native search directory walks
It shouldn't be necessary for performance now.
2024-04-12 17:28:00 +03:00
icedrocket
e82f46ab72 Ignore -C strip on MSVC 2024-04-05 08:18:01 +09:00
bors
c5b571310d Auto merge of #121297 - michaelwoerister:set-pdb-alt-path, r=wesleywiser
link.exe: Don't embed full path to PDB file in binary.

This PR makes `rustc` unconditionally pass `/PDBALTPATH:%_PDB%` to MSVC-style linkers, causing the linker to only embed the filename of the PDB in the binary instead of the full path. This will help implement the [trim-paths RFC](https://github.com/rust-lang/rust/issues/111540) for `*-msvc` targets.

Passing `/PDBALTPATH:%_PDB%` to the linker is already done by many projects that need reproducible builds and [debugger's should still be able to find the PDB](https://learn.microsoft.com/cpp/build/reference/pdbpath) if it is in the same directory as the binary.

r? `@ghost`

Fixes https://github.com/rust-lang/rust/issues/87825
2024-03-15 14:14:34 +00:00
Matthias Krüger
68ca795286
Rollup merge of #117118 - bzEq:aix-linker, r=wesleywiser
[AIX] Remove AixLinker's debuginfo() implementation

AIX ld's `-s` option doesn't perfectly fit` debuginfo()`'s semantics and may unexpectedly remove metadata in shared libraries. Remove the implementation of `AixLinker` and suggest user to use `strip` utility instead.
2024-03-14 20:00:17 +01:00
Michael Wörister
3c49fe0cbd link.exe: don't embed full path to PDB file in binary. 2024-03-14 09:54:29 +01:00
Kjetil Kjeka
43f2055af5 LLVM Bitcode Linker: Add as a linker known to the compiler 2024-03-11 13:35:35 +01:00
Kai Luo
aa692a577e [AIX] Remove AixLinker's debuginfo() implementation
`-s` option doesn't perfectly fit into debuginfo()'s semantics and may unexpectedly
remove metadata in shared libraries. Remove the implementation and suggest user to
use `strip` utility instead.
2024-03-05 15:10:12 +08:00
Qiu Chaofan
9d71386252 Add profiling support to AIX
AIX ld needs special option to merge objects with profiling. Also,
profiler_builtins should include builtins for AIX from compiler-rt.
2024-02-28 17:41:12 +08:00