summary refs log tree commit diff
path: root/compiler/rustc_target/src
AgeCommit message (Collapse)AuthorLines
2024-06-06Improve naming and path operations in crate loaderNilstrieb-9/+5
Simplify the path operation with `join`, clarify some of the names.
2024-05-28Rollup merge of #117671 - kjetilkjeka:nvptx_c_abi_avoid_direct, r=davidtwcoMatthias Krüger-5/+4
NVPTX: Avoid PassMode::Direct for args in C abi Fixes #117480 I must admit that I'm confused about `PassMode` altogether, is there a good sum-up threads for this anywhere? I'm especially confused about how "indirect" and "byval" goes together. To me it seems like "indirect" basically means "use a indirection through a pointer", while "byval" basically means "do not use indirection through a pointer". The return used to keep `PassMode::Direct` for small aggregates. It turns out that `make_indirect` messes up the tests and one way to fix it is to keep `PassMode::Direct` for all aggregates. I have mostly seen this PassMode mentioned for args. Is it also a problem for returns? When experimenting with `byval` as an alternative i ran into [this assert](https://github.com/rust-lang/rust/blob/61a3eea8043cc1c7a09c2adda884e27ffa8a1172/compiler/rustc_codegen_llvm/src/abi.rs#L463C22-L463C22) I have added tests for the same kind of types that is already tested for the "ptx-kernel" abi. The tests cannot be enabled until something like #117458 is completed and merged. CC: ``@RalfJung`` since you seem to be the expert on this and have already helped me out tremendously CC: ``@RDambrosio016`` in case this influence your work on `rustc_codegen_nvvm` ``@rustbot`` label +O-NVPTX
2024-05-24Stop using the avx512er and avx512pf x86 target featuresHans Wennborg-2/+0
They are no longer supported by LLVM 19. Fixes #125492
2024-05-21Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvallebors-0/+35
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-21Rollup merge of #124772 - madsmtm:apple-platform-support-docs, r=oli-obkMatthias Krüger-0/+5
Refactor documentation for Apple targets Refactor the documentation for Apple targets in `rustc`'s platform support page to make it clear what the supported OS version is and which environment variables are being read (`*_DEPLOYMENT_TARGET` and `SDKROOT`). This fixes https://github.com/rust-lang/rust/issues/124215. Note that I've expanded the `aarch64-apple-ios-sim` maintainers `@badboy` and `@deg4uss3r` to include being maintainer of all `*-apple-ios-*` targets. If you do not wish to be so, please state that, then I'll explicitly note that in the docs. Additionally, I've added myself as co-maintainer of most of these targets. r? `@thomcc` I think the documentation you've previously written on tvOS is great, have mostly modified it to have a more consistent formatting with the rest of the Apple target. I recognize that there's quite a few changes here, feel free to ask about any of them! --- CC `@simlay` `@Nilstrieb` `@rustbot` label O-apple
2024-05-17Add source for mutually-exclusive listDavid Koloski-0/+2
2024-05-16enable rust-lld on `x86_64-unknown-linux-gnu` when requestedRémy Rakic-0/+13
the `rust.lld` config enables rustc's `CFG_USE_SELF_CONTAINED_LINKER` env var, and we: - set the linker-flavor to use lld - enable the self-contained linker this makes the target use the rust-lld linker by default
2024-05-15Improved the documentation of the FnAbi structMichał Kostrubiec-4/+9
2024-05-15Sort mutually-exclusive pairs, update fixed testsDavid Koloski-23/+23
2024-05-15Relax restrictions on multiple sanitizersDavid Koloski-0/+33
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.
2024-05-11Add x86_64-unknown-linux-none targetFederico Maria Morrone-0/+28
2024-05-11Auto merge of #124762 - madsmtm:refactor-apple-target-abi, r=lcnr,BlackHoleFoxbors-97/+103
Refactor Apple `target_abi` This was bundled together with `Arch`, which complicated a few code paths and meant we had to do more string matching than necessary. CC `@BlackHoleFox` as you've worked on the Apple target spec before Related: Is there a reason why `Target`/`TargetOptions` use `StaticCow` for so many things, instead of an enum with defined values (and perhaps a catch-all case for custom target json files)? Tagging `@Nilstrieb,` as you might know?
2024-05-11Rollup merge of #124233 - mati865:fix-support-for-upcoming-mingw-w64, ↵许杰友 Jieyou Xu (Joe)-0/+3
r=petrochenkov Add `-lmingwex` second time in `mingw_libs` Upcoming mingw-w64 releases will contain small math functions refactor which moved implementation around. As a result functions like `lgamma` now depend on libraries in this order: `libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`. Fixes #124221
2024-05-10NVPTX: Avoid PassMode::Direct for args in C abiKjetil Kjeka-5/+4
2024-05-10Rollup merge of #124797 - beetrees:primitive-float, r=davidtwcoMatthias Krüger-14/+16
Refactor float `Primitive`s to a separate `Float` type Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`. As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-05-10Rollup merge of #124915 - nnethercote:rustc_target-cleanups, r=bjorn3Matthias Krüger-17/+5
`rustc_target` cleanups Minor improvement I found while looking at this code. r? ```@lqd```
2024-05-09Remove unused `LinkSelfContainedDefault::is_linker_enabled` method.Nicholas Nethercote-13/+0
2024-05-08Auto merge of #124858 - alexcrichton:some-wasi-changes, r=michaelwoeristerbors-2/+7
rustc: Some small changes for the wasm32-wasip2 target This commit has a few changes for the wasm32-wasip2 target. The first two are aimed at improving the compatibility of using `clang` as an external linker driver on this target. The default target to LLVM is updated to match the Rust target and additionally the `-fuse-ld=lld` argument is dropped since that otherwise interferes with clang's own linker detection. The only linker on wasm targets is LLD but on the wasip2 target a wrapper around LLD, `wasm-component-ld`, is used to drive the process and perform steps necessary for componentization. The final commit changes the output of all objects on the wasip2 target to being PIC by default. This improves compatibilty with shared libaries but notably does not mean that there's a turnkey solution for shared libraries. The hope is that by having the standard libray work both with and without dynamic libraries will make experimentation easier.
2024-05-08Remove unused `step_trait` feature.Nicholas Nethercote-4/+5
Also sort the features.
2024-05-07rustc: Change wasm32-wasip2 to PIC-by-defaultAlex Crichton-1/+6
This commit changes the new `wasm32-wasip2` target to being PIC by default rather than the previous non-PIC by default. This change is intended to make it easier for the standard library to be used in a shared object in its precompiled form. This comes with a hypothetical modest slowdown but it's expected that this is quite minor in most use cases or otherwise wasm compilers and/or optimizing runtimes can elide the cost.
2024-05-06Adjust 64-bit ARM data layouts for LLVM updateMatthew Maurer-40/+40
LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid C++ accidentally underaligning functions when trying to comply with member function ABIs. This should only affect Rust in cases where we had a similar bug (I don't believe we have one), but our data layout must match to generate code. As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32` gets voided from the data layout. See llvm/llvm-project#90415
2024-05-06Refactor float `Primitive`s to a separate `Float` typebeetrees-14/+16
2024-05-05Document all Apple targets in rustc's platform supportMads Marquart-0/+5
- Fixed std support in top-level docs. - Added `*-apple-darwin` docs. - Added `i686-apple-darwin` docs. - Moved `aarch64-apple-ios-sim` to `*-apple-ios` and document all the iOS targets there. - Added `*-apple-ios-macabi` docs. - Add myself (madsmtm) as co-maintainer of most of these targets.
2024-05-05Refactor Apple `target_abi`Mads Marquart-97/+103
This was bundled together with `Arch`, which complicated a few code paths and meant we had to do more string matching than necessary.
2024-05-04Rollup merge of #124677 - djkoloski:set_fuchsia_frame_pointer, r=tmandryMatthias Krüger-1/+4
Set non-leaf frame pointers on Fuchsia targets This is part of our work to enable shadow call stack sanitization on Fuchsia, see [this Fuchsia issue](https://g-issues.fuchsia.dev/issues/327643884). r? ``@tmandry``
2024-05-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-0/+8
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-03rustc: Change LLVM target for the wasm32-wasip2 Rust targetAlex Crichton-1/+1
This commit changes the LLVM target of for the Rust `wasm32-wasip2` target to `wasm32-wasip2` as well. LLVM does a bit of detection on the target string to know when to call `wasm-component-ld` vs `wasm-ld` so otherwise clang is invoking the wrong linker.
2024-05-03Set non-leaf frame pointers on Fuchsia targetsDavid Koloski-1/+4
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-0/+8
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-3/+1
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-26/+8
2024-04-21Add `-lmingwex` second time in `mingw_libs`Mateusz Mikuła-0/+3
Upcoming mingw-w64 releases will contain small math functions refactor which moved implementation around. As a result functions like `lgamma` now depend on libraries in this order: `libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`. Fixes #124221
2024-04-21Auto merge of #117457 - daxpedda:wasm-nontrapping-fptoint, r=wesleywiserbors-4/+5
Stabilize Wasm target features that are in phase 4 and 5 This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](https://github.com/WebAssembly/proposals/tree/04fa8c810e1dc99ab399e41052a6e427ee988180). Feature stabilized: - [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) - [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global) - [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops) - [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations) - [Extended Constant Expressions](https://github.com/WebAssembly/extended-const) Features not stabilized: - [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` #73755. - [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without #103516. - [Threads](https://github.com/webassembly/threads): requires rebuilding `std` #77839. - [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR #117468. - [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented. See https://github.com/rust-lang/rust/pull/117457#issuecomment-1787648070 for more context. Documentation: https://github.com/rust-lang/reference/pull/1420 Tracking issue: https://github.com/rust-lang/rust/issues/44839
2024-04-19Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiserbors-37/+34
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: https://github.com/rust-lang/compiler-team/issues/703 Tracking issue: https://github.com/rust-lang/rust/issues/122532
2024-04-18Stabilize Wasm phase 4 & 5 proposalsdaxpedda-4/+5
2024-04-18Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstriebbors-1/+1
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-1/+1
We want to run them on all 64-bit platforms.
2024-04-17llvm: update riscv target feature to match LLVM 19Augie Fackler-1/+1
In llvm/llvm-project@9067070d91e9d8cdd8509ffa56a076f08a3d7281 they ended up largely reverting llvm/llvm-project@e81796671890b59c110f8e41adc7ca26f8484d20. This means the change we did in rust-lang/rust@b378059e6b2573c5356423fa31d184a89a3b6029 is now only corrct for LLVM 18...so we have to adjust again. @rustbot label: +llvm-main
2024-04-16Remove `default_hidden_visibility: false` from wasm targetsAlex Crichton-3/+0
To the best of my ability I believe that this is no longer necessary. I don't fully recall why this was first added but I believe it had to do with symbols all being exported by default and this was required to undo that. Regardless nowadays the default output of rustc seems suitable so it seems best to keep wasm in line with other targets.
2024-04-16Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwcoGuillaume Gomez-0/+1
Various visionOS fixes A few small mistakes was introduced in https://github.com/rust-lang/rust/pull/121419, probably after the rename from `xros` to `visionos`. See the commits for details. CC `@agg23` Since you reviewed https://github.com/rust-lang/rust/pull/121419 r? davidtwco
2024-04-13Auto merge of #123656 - lqd:linker-features, r=petrochenkovbors-0/+74
Linker flavors next steps: linker features This is my understanding of the first step towards `@petrochenkov's` vision for the future of linker flavors, described in https://github.com/rust-lang/rust/pull/119906#issuecomment-1895693162 and the discussion that followed. To summarize: having `Cc` and `Lld` embedded in linker flavors creates tension about naming, and a combinatorial explosion of flavors for each new linker feature we'd want to use. Linker features are an extension mechanism that is complementary to principal flavors, with benefits described in #119906. The most immediate use of this flag would be to turn self-contained linking on and off via features instead of flavors. For example, `-Clinker-features=+/-lld` would toggle using lld instead of selecting a precise flavor, and would be "generic" and work cross-platform (whereas linker flavors are currently more tied to targets). Under this scheme, MCP510 is expected to be `-Clink-self-contained=+linker -Zlinker-features=+lld -Zunstable-options` (though for the time being, the original flags using lld-cc flavors still work). I purposefully didn't add or document CLI support for `+/-cc`, as it would be a noop right now. I only expect that we'd initially want to stabilize `+/-lld` to begin with. r? `@petrochenkov` You had requested that minimal churn would be done to the 230 target specs and this does none yet: the linker features are inferred from the flavor since they're currently isomorphic. We of course expect this to change sooner rather than later. In the future, we can allow targets to define linker features independently from their flavor, and remove the cc and lld components from the flavors to use the features instead, this actually doesn't need to block stabilization, as we discussed. (Best reviewed per commit)
2024-04-13Auto merge of #123257 - ChrisDenton:enable-tls, r=fmeasebors-4/+0
Re-enable `has_thread_local` for i686-msvc A few years back, `has_thread_local` was disabled as a workaround for a compiler issue. While the exact cause was never tracked down, it was suspected to be caused by the compiler inlining a thread local access across a dylib boundary. This should be fixed now so let's try again.
2024-04-12make CLI linker features influence the linker flavorRémy Rakic-0/+22
While they're isomorphic, we can flip the lld component where applicable, so that downstream doesn't have to check both the flavor and the linker features.
2024-04-12introduce `LinkerFeatures`Rémy Rakic-0/+52
They are a flexible complementary mechanism to linker flavors, that also avoid the combinatorial explosion of mapping linking features to actual linker flavors.
2024-04-11Rollup merge of #123740 - veera-sivarajan:reduce-size-of-modifierinfo, ↵Matthias Krüger-3/+3
r=petrochenkov Reduce Size of `ModifierInfo` I added `ModifierInfo` in #121940 and had used a `u64` for the `size` field even though the largest value it holds is `512`. This PR changes the type of the `size` field to `u16`.
2024-04-10Reduce size of `ModifierInfo`Veera-3/+3
2024-04-10Add support for Arm64EC inline assemblyDaniel Paoliello-24/+48
2024-04-10Allow specifying SDKROOT as containing XRSimulator.platformMads Marquart-0/+1
Checking this was missing from the `link_env_remove` function, so compilation might fail if set when compiling for macOS
2024-04-08force_array -> is_consecutiveNikita Popov-56/+49
The actual ABI implication here is that in some cases the values are required to be "consecutive", i.e. must either all be passed in registers or all on stack (without padding). Adjust the code to either use Uniform::new() or Uniform::consecutive() depending on which behavior is needed. Then, when lowering this in LLVM, skip the [1 x i128] to i128 simplification if is_consecutive is set. i128 is the only case I'm aware of where this is problematic right now. If we find other cases, we can extend this (either based on target information or possibly just by not simplifying for is_consecutive entirely).
2024-04-08Fix argument ABI for overaligned structs on ppc64leNikita Popov-32/+58
When passing a 16 (or higher) aligned struct by value on ppc64le, it needs to be passed as an array of `i128` rather than an array of `i64`. This will force the use of an even starting register. For the case of a 16 byte struct with alignment 16 it is important that `[1 x i128]` is used instead of `i128` -- apparently, the latter will get treated similarly to `[2 x i64]`, not exhibiting the correct ABI. Add a `force_array` flag to `Uniform` to support this. The relevant clang code can be found here: https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L878-L884 https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L780-L784 I think the corresponding psABI wording is this: > Fixed size aggregates and unions passed by value are mapped to as > many doublewords of the parameter save area as the value uses in > memory. Aggregrates and unions are aligned according to their > alignment requirements. This may result in doublewords being > skipped for alignment. In particular the last sentence. Fixes https://github.com/rust-lang/rust/issues/122767.