Commit Graph

932 Commits

Author SHA1 Message Date
Rémy Rakic
6f54cbf754 add IntoIterator impl for self-contained linking components 2023-10-08 21:57:39 +00:00
Rémy Rakic
2ce46f8e8c move single component parsing to dedicated function
this will prevent parsing when expecting more than a single component
to be parsed, and prepare for the symetric variant-to-name function to
be added
2023-10-08 21:57:39 +00:00
Rémy Rakic
acc3b61c5e move LinkSelfContainedComponents to rustc_target 2023-10-08 21:57:38 +00:00
Rémy Rakic
71285c1da0 prepare stabilization of modern linker-flavors
fix a few comments
2023-10-08 21:57:36 +00:00
Vadim Petrochenkov
7ecb09d05c linker: Remove unstable legacy CLI linker flavors 2023-10-07 21:57:53 +03:00
bors
2c9b0de8ea Auto merge of #116269 - Veykril:rustc-abi, r=WaffleLapkin
Bring back generic parameters for indices in rustc_abi and make it compile on stable

This effectively reverses https://github.com/rust-lang/rust/pull/107163, allowing rust-analyzer to depend on this crate again,

It also moves some glob imports / expands them in the first commit because they made it more difficult for me to reason about things.
2023-10-06 00:03:56 +00:00
Lukas Wirth
6d141c11c0 Implement Deref<LayoutS> for Layout 2023-10-02 21:31:16 +02:00
Lukas Wirth
e8a2673159 Add VariantIdx back 2023-10-02 21:31:16 +02:00
Lukas Wirth
f14b7c9443 Move FieldIdx and Layout to rustc_target 2023-10-02 21:31:16 +02:00
Lukas Wirth
b47ad3b744 Bring back generic FieldIdx 2023-10-02 21:31:11 +02:00
cui fliter
6ef3fd7138 Fix broken links
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-30 10:26:04 +08:00
bors
70a7fe1743 Auto merge of #116076 - chriswailes:android-riscv-extension-update, r=cjgillot
Add Zba, Zbb, and Zbs as target features for riscv64-linux-android

This pull request adds the Zba, Zbb, and Zbs target features to the `riscv64-linux-android` target specification.  These features have been enabled and tested internally in Android infrastructure.
2023-09-24 11:40:45 +00:00
bors
c7224e3c95 Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubilee
Add Minimal Std implementation for UEFI

# Implemented modules:
1. alloc
2. os_str
3. env
4. math

# Related Links
Tracking Issue: https://github.com/rust-lang/rust/issues/100499
API Change Proposal: https://github.com/rust-lang/libs-team/issues/87

# Additional Information
This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR.

The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-24 09:47:30 +00:00
bors
42ca6e4e57 Auto merge of #104385 - BlackHoleFox:apple-minimum-bumps, r=petrochenkov
Raise minimum supported Apple OS versions

This implements the proposal to raise the minimum supported Apple OS versions as laid out in the now-completed MCP (https://github.com/rust-lang/compiler-team/issues/556).

As of this PR, rustc and the stdlib now support these versions as the baseline:
- macOS: 10.12 Sierra
- iOS: 10
- tvOS: 10
- watchOS: 5 (Unchanged)

In addition to everything this breaks indirectly, these changes also erase the `armv7-apple-ios` target (currently tier 3) because the oldest supported iOS device now uses ARMv7s. Not sure what the policy around tier3 target removal is but shimming it is not an option due to the linker refusing.

[Per comment](https://github.com/rust-lang/compiler-team/issues/556#issuecomment-1297175073), this requires a FCP to merge. cc `@wesleywiser.`
2023-09-24 02:35:05 +00:00
BlackHoleFox
2044a2d7fa Raise minimum supported tvOS version to 10.0 2023-09-23 19:14:25 -05:00
BlackHoleFox
3b52befdce Raise minimum supported iOS version to 10.0
Drop the armv7-apple-ios target too because its no longer supported
with the hardware iOS 10 requires.
2023-09-23 19:14:25 -05:00
BlackHoleFox
58bbca958d Raise minimum supported macOS to 10.12 2023-09-23 19:14:25 -05:00
Chris Wailes
09c5f983e3 Add Zba, Zbb, and Zbs as target features for riscv64-linux-android 2023-09-22 13:34:05 -07:00
Ayush Singh
48c6ae0611
Add Minimal Std implementation for UEFI
Implemented modules:
1. alloc
2. os_str
3. env
4. math

Tracking Issue: https://github.com/rust-lang/rust/issues/100499
API Change Proposal: https://github.com/rust-lang/libs-team/issues/87

This was originally part of https://github.com/rust-lang/rust/pull/100316. Since
that PR was becoming too unwieldy and cluttered, and with suggestion
from @dvdhrm, I have extracted a minimal std implementation to this PR.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:30 +05:30
bors
f73d376fb6 Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber
added support for GNU/Hurd

adding support for i686-unknown-hurd-gnu
2023-09-21 19:24:01 +00:00
Samuel Thibault
dcea7709f2 added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
WANG Rui
0163768e0d rustc_target/loongarch: Fix passing of transparent unions with only one non-ZST member
This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed
through an `extern "C"` function.

Fixes https://github.com/rust-lang/rust/issues/115509
2023-09-20 09:22:02 +08:00
msizanoen
751ecde064 rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member
This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed
through an `extern "C"` function.

Fixes https://github.com/rust-lang/rust/issues/115481.
2023-09-19 12:06:33 +02:00
danakj
4eb1b52794 Enable ASAN/LSAN/TSAN for *-apple-ios-macabi
The -macabi targets are iOS running on MacOS, and they use the runtime
libraries for MacOS, thus they have the same sanitizers available as the
*-apple-darwin targets.
2023-09-18 09:38:12 -04:00
Dylan DPC
0c5f5b6db7
Rollup merge of #115654 - RalfJung:pass-mode-cast, r=compiler-errors
improve PassMode docs
2023-09-17 11:23:25 +00:00
Matthias Krüger
ab90d708da
Rollup merge of #115860 - Soveu:varargs2, r=WaffleLapkin
Enable varargs support for AAPCS calling convention

Welp, I was looking for a reason why this shouldn't be stabilized after so long... and here it is.
2023-09-16 15:18:23 +02:00
Boxy
71cab64079 special case TyAndLayout debug impl 2023-09-15 22:57:07 +02:00
Ralf Jung
89139d4c46 clarify PassMode::Indirect as well 2023-09-15 10:43:44 +02:00
Ralf Jung
7740476a43 explain PassMode::Cast 2023-09-15 10:43:44 +02:00
Soveu
eea6149e03 Enable varargs support for AAPCS calling convention
This is the default calling convention for ARM - it is used for extern "C",
therefore it supports varargs.
2023-09-14 23:21:39 +02:00
Ralf Jung
60091fe924 add helper method for finding the one non-1-ZST field 2023-09-12 20:52:05 +02:00
Matthias Krüger
8e157ecd65
Rollup merge of #115687 - mati865:i686-pc-windows-gnullvm-triple, r=wesleywiser
Add `i686-pc-windows-gnullvm` triple

With various fixes that are already present in the code, a fully working i686 target can join other targets in `*-windows-gnullvm` family. Again this will be mostly useful for MSYS2 right now but I plan to open MCP for providing at least prebuilt std for `windows-gnullvm` as the next step which will expand usability of these targets.

Tier 3 policy:

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I pledge to do my best maintaining it, MSYS2 is one of interested consumers. Previously added `gnullvm` triples proved there is not much maintenance required.

 > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

This triple name is consistent with other targets and was discussed at [`t-compiler/LLVM+mingw-w64 Windows targets`](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/LLVM.2Bmingw-w64.20Windows.20targets)

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I think the explanation in platform support doc is enough to make this aspect clear.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

It's using open source tools only.

> The target must not introduce license incompatibilities.

It's even more liberal than already existing `*-pc-windows-gnu`.

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Understood.

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

There are no new dependencies/features required.

> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

As previously said it's using open source tools only.

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

There are no such terms present.

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

I'm not the reviewer here.

> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Again I'm not the reviewer here.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

It seems to work, at least for cross compilation.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Building is described in platform support doc, running tests doesn't work right now (without hacks) because Rust's build system doesn't seem to support testing targets built from `.json`.
Docs will be updated once this lands in beta allowing master branch to build and run tests without `.json` files.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Understood.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Understood.

 > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

I believe I didn't break any other target.

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I think there are no such problems in this PR.
2023-09-12 06:34:45 +02:00
Ralf Jung
254e13d9f9 fix homogeneous_aggregate not ignoring some 1-ZST 2023-09-10 07:38:03 +02:00
Mateusz Mikuła
32c45317a1 Add i686-pc-windows-gnullvm triple 2023-09-09 00:32:45 +02:00
Ralf Jung
b0cf4c28ea turns out Layout has some more things to worry about -- move ABI comparison into helper function
like is_bool, and some special magic extra fields
2023-09-08 09:14:07 +02:00
Ralf Jung
28d152935e the wasm ABI behavior is a bug 2023-09-08 09:14:07 +02:00
Ralf Jung
c3e14edd8b accept some differences for rustc_abi(assert_eq), so that we can test more things to be compatible 2023-09-08 08:59:55 +02:00
Ralf Jung
c981026195 extend comments around PassMode::Direct 2023-09-07 09:14:02 +02:00
bors
84a9f4c6e6 Auto merge of #114114 - keith:ks/always-add-lc_build_version-for-metadata-object-files, r=wesleywiser
Always add LC_BUILD_VERSION for metadata object files

As of Xcode 15 Apple's linker has become a bit more strict about the warnings it produces. One of those new warnings requires all valid Mach-O object files in an archive to have a LC_BUILD_VERSION load command:

```
ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator
```

This was already being done for Mac Catalyst so this change expands this logic to include it for all Apple platforms. I filed this behavior change as FB12546320 and was told it was the new intentional behavior.
2023-08-29 21:17:13 +00:00
bors
f3284dc3ad Auto merge of #115260 - scottmcm:not-quite-so-cold, r=WaffleLapkin
Use `preserve_mostcc` for `extern "rust-cold"`

As experimentation in #115242 has shown looks better than `coldcc`.  Notably, clang exposes `preserve_most` (https://clang.llvm.org/docs/AttributeReference.html#preserve-most) but not `cold`, so this change should put us on a better-supported path.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse. (See comment in the code.)

cc tracking issue #97544
2023-08-29 02:23:43 +00:00
Nikita Popov
1b7cf24d80 Revert "Auto merge of #106511 - MaskRay:gotpcrelx, r=nikic"
This reverts commit 4410868798, reversing
changes made to 249595b752.

This causes linker failures with the binutils version used by
cross (#115239), as well as miscompilations when using the mold
linker.
2023-08-27 11:22:20 +02:00
Scott McMurray
754f488d46 Use preserve_mostcc for extern "rust-cold"
As experimentation in 115242 has shown looks better than `coldcc`.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse.

cc tracking issue 97544
2023-08-26 17:42:59 -07:00
bors
8a6b67f988 Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur
Update bootstrap compiler to 1.73.0 beta
2023-08-24 11:10:52 +00:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
Fangrui Song
f3d81917fc Default relax_elf_relocations to true
This option tells LLVM to emit relaxable relocation types
R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX/R_386_GOT32X in applicable cases. True
matches Clang's CMake default since 2020-08 [1] and latest LLVM default[2].

This also works around a GNU ld<2.41 issue[3] when using
general-dynamic/local-dynamic TLS models in `-Z plt=no` mode with latest LLVM.

[1]: c41a18cf61
[2]: 2aedfdd9b8
[3]: https://sourceware.org/bugzilla/show_bug.cgi?id=24784
2023-08-23 11:12:30 -07:00
Keith Smiley
2939e8534a
Add comment about unused sdk versions 2023-08-22 08:55:51 -07:00
Keith Smiley
f988cbb065
Use target.abi instead of string matching llvm_target 2023-08-21 13:32:27 -07:00
Keith Smiley
d37fdc95d4
Always add LC_BUILD_VERSION for metadata object files
As of Xcode 15 Apple's linker has become a bit more strict about the
warnings it produces. One of those new warnings requires all valid
Mach-O object files in an archive to have a LC_BUILD_VERSION load
command:

```
ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator
```

This was already being done for Mac Catalyst so this change expands this
logic to include it for all Apple platforms. I filed this behavior
change as FB12546320 and was told it was the new intentional behavior.
2023-08-21 13:31:57 -07:00
Luca Barbato
c0394c8ac0 Add the relocation_model to the cfg
This way is possible to write inline assembly code aware of it.
2023-08-18 19:57:28 +02:00
bors
2ceed0b6cb Auto merge of #113814 - ChoKyuWon:master, r=davidtwco
Replace the \01__gnu_mcount_nc to LLVM intrinsic for ARM

Current `-Zinstrument-mcount` for ARM32 use the `\01__gnu_mcount_nc` directly for its instrumentation function.

However, the LLVM does not use this mcount function directly, but it wraps it to intrinsic, `llvm.arm.gnu.eabi.mcount` and the transform pass also only handle the intrinsic.

As a result, current `-Zinstrument-mcount` not work on ARM32. Refer: https://github.com/namhyung/uftrace/issues/1764

This commit replaces the mcount name from native function to the LLVM intrinsic so that the transform pass can handle it.
2023-08-18 13:20:37 +00:00