Commit Graph

1091 Commits

Author SHA1 Message Date
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
ChoKyuWon
3bd54c14bc
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.

Signed-off-by: ChoKyuWon <kyuwoncho18@gmail.com>
2023-08-18 01:52:40 +09:00
Guillaume Gomez
f92974189b
Rollup merge of #114711 - lqd:linker-inference, r=petrochenkov
Infer `Lld::No` linker hint when the linker stem is a generic compiler driver

This PR basically reverts the temporary solution in https://github.com/rust-lang/rust/pull/113631 to a more long-term solution.

r? ``@petrochenkov``

In [this comment](https://github.com/rust-lang/rust/pull/113631#issuecomment-1634598238), you had ideas about a long-term solution:

> I wonder what a good non-temporary solution for the inference would look like.
>
>     * If the default is `(Cc::No, Lld::Yes)` (e.g. `rust-lld`)
>
>       * and we switch to some specific platform compiler (e.g. `-C linker=arm-none-eabi-gcc`), should we change to `Lld::No`? Maybe yes?
>       * and we switch to some non-default but generic compiler `-C linker=clang`? Then maybe not?
>
>     * If the default is `(Cc::Yes, Lld::Yes)` (e.g. future x86_64 linux with default LLD)
>
>       * and we switch to some specific platform compiler (e.g. `-C linker=arm-none-eabi-gcc`), should we change to `Lld::No`? Maybe yes?
>       * and we switch to some non-default but generic compiler `-C linker=clang`? Then maybe not?
>

I believe that we should infer the `Lld::No` linker hint for any `-Clinker` override, and all the cases above:
- the linker drivers have their own defaults, so in my mind `-Clinker` is a signal to use its default linker / flavor, rather than ours or the target's. In the case of generic compilers, it's more likely than not going to be `Lld::No`. I would expect this to be the case in general, even when including platform-specific compilers.
- the guess will be wrong if the linker driver uses lld by default (and we also don't want to search for `-fuse-ld` link args), but will work in the more common cases. And the minority of other cases can fix the wrong guess by opting into the precise linker flavor.
- this also ensures backwards-compatibility: today, even on targets with an lld default and overriding the linker, rustc will not use lld. That includes `thumbv6m-none-eabi` where issue #113597 happened.

It looks like the simplest option, and the one with least churn: we maintain the current behavior in ambiguous cases.

I've tested that this works on #113597, as expected from the failure.

(I also have a no-std `run-make` test using a custom target json spec: basically simulating a future `x86_64-unknown-linux-gnu` using an lld flavor by default, to check that  e.g. `-Clinker=clang` doesn't use lld. I could add that test to this PR, but IIUC such a custom target requires `cargo -Z build-std` and we have no tests depending on this cargo feature yet. Let me know if you want to add this test of the linker inference for such targets.)

What do you think ?
2023-08-15 14:29:45 +02:00
bors
fd9525adb0 Auto merge of #114717 - loongarch-rs:rust-lld, r=b-naber
Switch to LLD as default linker for loongarch64-unknown-none*

The [LLD already supports LoongArch](6084ee7420), it's time to switch to LLD as default linker for `loongarch64-unknown-none*`.
2023-08-15 08:50:35 +00:00
dirreke
74817b7053 Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
Dirreke
184a9afffb add details for csky-unknown-linux-gnuabiv2 and add docs 2023-08-14 23:02:37 +08:00
Dirreke
8c51e28bd5 add rustc_codegen_ssa support for csky and correct some code 2023-08-14 23:02:36 +08:00
Dirreck
8ed7aa16bd Update compiler/rustc_target/src/abi/call/csky.rs
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-08-14 23:02:36 +08:00
Dirreke
d16409fe22 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
WANG Rui
815868d803 Switch to LLD as default linker for loongarch64-unknown-none* 2023-08-11 10:04:37 +08:00
Rémy Rakic
498d6562c3 infer no use of lld when using a generic linker driver 2023-08-10 20:36:25 +00:00
bors
307c573d57 Auto merge of #114614 - RalfJung:offset-of-sanity, r=cjgillot
offset_of: guard against invalid use (with unsized fields)
2023-08-10 07:54:05 +00:00
Matthias Krüger
7d78885a8e
Rollup merge of #111891 - rustbox:feat/riscv-isr-cconv, r=jackh726
feat: `riscv-interrupt-{m,s}` calling conventions

Similar to prior support added for the mips430, avr, and x86 targets this change implements the rough equivalent of clang's [`__attribute__((interrupt))`][clang-attr] for riscv targets, enabling e.g.

```rust
static mut CNT: usize = 0;

pub extern "riscv-interrupt-m" fn isr_m() {
    unsafe {
        CNT += 1;
    }
}
```

to produce highly effective assembly like:

```asm
pub extern "riscv-interrupt-m" fn isr_m() {
420003a0:       1141                    addi    sp,sp,-16
    unsafe {
        CNT += 1;
420003a2:       c62a                    sw      a0,12(sp)
420003a4:       c42e                    sw      a1,8(sp)
420003a6:       3fc80537                lui     a0,0x3fc80
420003aa:       63c52583                lw      a1,1596(a0) # 3fc8063c <_ZN12esp_riscv_rt3CNT17hcec3e3a214887d53E.0>
420003ae:       0585                    addi    a1,a1,1
420003b0:       62b52e23                sw      a1,1596(a0)
    }
}
420003b4:       4532                    lw      a0,12(sp)
420003b6:       45a2                    lw      a1,8(sp)
420003b8:       0141                    addi    sp,sp,16
420003ba:       30200073                mret
```

(disassembly via `riscv64-unknown-elf-objdump -C -S --disassemble ./esp32c3-hal/target/riscv32imc-unknown-none-elf/release/examples/gpio_interrupt`)

This outcome is superior to hand-coded interrupt routines which, lacking visibility into any non-assembly body of the interrupt handler, have to be very conservative and save the [entire CPU state to the stack frame][full-frame-save]. By instead asking LLVM to only save the registers that it uses, we defer the decision to the tool with the best context: it can more accurately account for the cost of spills if it knows that every additional register used is already at the cost of an implicit spill.

At the LLVM level, this is apparently [implemented by] marking every register as "[callee-save]," matching the semantics of an interrupt handler nicely (it has to leave the CPU state just as it found it after its `{m|s}ret`).

This approach is not suitable for every interrupt handler, as it makes no attempt to e.g. save the state in a user-accessible stack frame. For a full discussion of those challenges and tradeoffs, please refer to [the interrupt calling conventions RFC][rfc].

Inside rustc, this implementation differs from prior art because LLVM does not expose the "all-saved" function flavor as a calling convention directly, instead preferring to use an attribute that allows for differentiating between "machine-mode" and "superivsor-mode" interrupts.

Finally, some effort has been made to guide those who may not yet be aware of the differences between machine-mode and supervisor-mode interrupts as to why no `riscv-interrupt` calling convention is exposed through rustc, and similarly for why `riscv-interrupt-u` makes no appearance (as it would complicate future LLVM upgrades).

[clang-attr]: https://clang.llvm.org/docs/AttributeReference.html#interrupt-risc-v
[full-frame-save]: 9281af2ecf/src/lib.rs (L440-L469)
[implemented by]: b7fb2a3fec/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (L61-L67)
[callee-save]: 973f1fe7a8/llvm/lib/Target/RISCV/RISCVCallingConv.td (L30-L37)
[rfc]: https://github.com/rust-lang/rfcs/pull/3246
2023-08-09 22:59:58 +02:00
Seth Pellegrino
897c7bb23b feat: riscv-interrupt-{m,s} calling conventions
Similar to prior support added for the mips430, avr, and x86 targets
this change implements the rough equivalent of clang's
[`__attribute__((interrupt))`][clang-attr] for riscv targets, enabling
e.g.

```rust
static mut CNT: usize = 0;

pub extern "riscv-interrupt-m" fn isr_m() {
    unsafe {
        CNT += 1;
    }
}
```

to produce highly effective assembly like:

```asm
pub extern "riscv-interrupt-m" fn isr_m() {
420003a0:       1141                    addi    sp,sp,-16
    unsafe {
        CNT += 1;
420003a2:       c62a                    sw      a0,12(sp)
420003a4:       c42e                    sw      a1,8(sp)
420003a6:       3fc80537                lui     a0,0x3fc80
420003aa:       63c52583                lw      a1,1596(a0) # 3fc8063c <_ZN12esp_riscv_rt3CNT17hcec3e3a214887d53E.0>
420003ae:       0585                    addi    a1,a1,1
420003b0:       62b52e23                sw      a1,1596(a0)
    }
}
420003b4:       4532                    lw      a0,12(sp)
420003b6:       45a2                    lw      a1,8(sp)
420003b8:       0141                    addi    sp,sp,16
420003ba:       30200073                mret
```

(disassembly via `riscv64-unknown-elf-objdump -C -S --disassemble ./esp32c3-hal/target/riscv32imc-unknown-none-elf/release/examples/gpio_interrupt`)

This outcome is superior to hand-coded interrupt routines which, lacking
visibility into any non-assembly body of the interrupt handler, have to
be very conservative and save the [entire CPU state to the stack
frame][full-frame-save]. By instead asking LLVM to only save the
registers that it uses, we defer the decision to the tool with the best
context: it can more accurately account for the cost of spills if it
knows that every additional register used is already at the cost of an
implicit spill.

At the LLVM level, this is apparently [implemented by] marking every
register as "[callee-save]," matching the semantics of an interrupt
handler nicely (it has to leave the CPU state just as it found it after
its `{m|s}ret`).

This approach is not suitable for every interrupt handler, as it makes
no attempt to e.g. save the state in a user-accessible stack frame. For
a full discussion of those challenges and tradeoffs, please refer to
[the interrupt calling conventions RFC][rfc].

Inside rustc, this implementation differs from prior art because LLVM
does not expose the "all-saved" function flavor as a calling convention
directly, instead preferring to use an attribute that allows for
differentiating between "machine-mode" and "superivsor-mode" interrupts.

Finally, some effort has been made to guide those who may not yet be
aware of the differences between machine-mode and supervisor-mode
interrupts as to why no `riscv-interrupt` calling convention is exposed
through rustc, and similarly for why `riscv-interrupt-u` makes no
appearance (as it would complicate future LLVM upgrades).

[clang-attr]: https://clang.llvm.org/docs/AttributeReference.html#interrupt-risc-v
[full-frame-save]: 9281af2ecf/src/lib.rs (L440-L469)
[implemented by]: b7fb2a3fec/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (L61-L67)
[callee-save]: 973f1fe7a8/llvm/lib/Target/RISCV/RISCVCallingConv.td (L30-L37)
[rfc]: https://github.com/rust-lang/rfcs/pull/3246
2023-08-08 18:09:56 -07:00
Matthias Krüger
088763643f
Rollup merge of #113480 - Sword-Destiny:master, r=petrochenkov
add aarch64-unknown-teeos target

TEEOS is a mini os run in TrustZone, for trusted/security apps. The libc of TEEOS is a part of musl. The kernel of TEEOS is micro kernel.

This MR is to add a target for teeos.

MRs for libc and rust-std are in progress.

Compiler team MCP: [MCP](https://github.com/rust-lang/compiler-team/issues/652)
2023-08-08 21:44:42 +02:00
Ralf Jung
9215346d35 offset_of: guard against invalid use (with unsized fields) 2023-08-08 10:34:08 +02:00
Matthias Krüger
6f36f1ffbd
Rollup merge of #114497 - taiki-e:revert-riscv-atomic, r=Amanieu
Revert #98333 "Re-enable atomic loads and stores for all RISC-V targets"

This reverts #98333.

As said in https://github.com/rust-lang/rust/pull/98333#issuecomment-1666375293, `forced-atomics` target feature is also needed to enable atomic load/store on these targets (otherwise, libcalls are generated): https://godbolt.org/z/433qeG7vd

However, `forced-atomics` target feature is currently broken (https://github.com/rust-lang/rust/issues/114153), so AFAIK, there is currently no way to enable atomic load/store (via core::intrinsics) on these targets properly.

r? `@Amanieu`
2023-08-08 03:30:55 +02:00
Nikita Popov
ad7ea8b7e6 Update powerpc data layouts
Function pointer alignment is specified since https://reviews.llvm.org/D147016.
2023-08-07 20:35:55 +02:00
Matthias Krüger
06daa9e263
Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk
stabilize abi_thiscall

Closes https://github.com/rust-lang/rust/issues/42202, stabilizing the use of the "thiscall" ABI.

FCP was substituted by a poll, and the poll has been accepted.
2023-08-07 16:47:57 +02:00
Matthias Krüger
9b1f9433db
Rollup merge of #114496 - taiki-e:sparc32-atomic, r=Amanieu
Set max_atomic_width for sparc-unknown-linux-gnu to 32

This is currently set to 64

90f0b24ad3/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs (L8)

However, AFAIK, this architecture doesn't support 64-bit atomics, and LLVM generates libcalls: https://godbolt.org/z/chzThWGG1

(Currently, attempts to run `cargo test` for this target result in "undefined reference to `__sync_val_compare_and_swap_8'" error. 02efe1e74f)

r? `@Amanieu`
2023-08-07 16:47:56 +02:00
Benedikt Radtke
3f3262e592 stabilize abi_thiscall 2023-08-07 14:11:03 +02:00
Taiki Endo
b47e4a46c6 Revert "Auto merge of #98333 - SimonSapin:riscv-atomic, r=Amanieu"
This reverts commit 90f0b24ad3, reversing
changes made to e173a8e663.
2023-08-05 13:18:47 +09:00
Taiki Endo
4d4df88934 Set max_atomic_width for sparc-unknown-linux-gnu to 32 2023-08-05 13:01:15 +09:00
Taiki Endo
c9e83c02a2 Set max_atomic_width for AVR to 16 2023-08-05 12:47:46 +09:00
bors
90f0b24ad3 Auto merge of #98333 - SimonSapin:riscv-atomic, r=Amanieu
Re-enable atomic loads and stores for all RISC-V targets

This roughly reverts PR https://github.com/rust-lang/rust/pull/66548

Atomic "CAS" are still disabled for targets without the *“A” Standard Extension for Atomic Instructions*. However this extension only adds instructions for operations more complex than simple loads and stores, which are always atomic when aligned.

In the [Unprivileged Spec v. 20191213](https://riscv.org/technical/specifications/) section 2.6 *Load and Store Instructions* of chapter 2 *RV32I Base Integer Instruction Set* (emphasis mine):

> Even when misaligned loads and stores complete successfully, these accesses might run extremely slowly depending on the implementation (e.g., when implemented via an invisible trap). Further-more, whereas **naturally aligned loads and stores are guaranteed to execute atomically**, misaligned loads and stores might not, and hence require additional synchronization to ensure atomicity.

Unfortunately PR https://github.com/rust-lang/rust/pull/66548 did not provide much details on the bug that motivated it, but https://github.com/rust-lang/rust/issues/66240 and https://github.com/rust-lang/rust/issues/85736 appear related and happen with targets that do have the A extension.
2023-08-05 01:53:32 +00:00
Nilstrieb
5830ca216d Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
bors
aa8462b6df Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser
WASI threads, implementation of wasm32-wasi-preview1-threads target

This PR adds a target proposed in https://github.com/rust-lang/compiler-team/issues/574 by `@abrown` and implementation of `std:🧵:spawn` for the target `wasm32-wasi-preview1-threads`

### Tier 3 Target Policy
As tier 3 targets, the new targets are required to adhere to [the tier 3 target policy](https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-3-target-policy) requirements. This section quotes each requirement in entirety and describes how they are met.
> - 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.)

See [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - 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.
> - 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.
If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

The target is using the same name for $ARCH=wasm32 and $OS=wasi as existing Rust targets. The suffix `preview1` introduced to accurately set expectations because eventually this target will be deprecated and follows [MCP 607](https://github.com/rust-lang/compiler-team/issues/607). The suffix `threads` indicates that it’s an extension that enables threads to the existing target and it follows [MCP 574](https://github.com/rust-lang/compiler-team/issues/574) which describes the rationale behind introducing a separate target.

> - 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.
> - The target must not introduce license incompatibilities.
> - Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
> - 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.
> - 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.
> - "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.

This PR does not introduce any new dependency.
The new target doesn’t support building host tools.
> 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.

The full standard library is available for this target as it’s an extension to an existing target that has already supported it.
> 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.

Only manual test running is supported at the moment with some tweaks in the test runner codebase. For build and running tests see [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - 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.
> - 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.
> - 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.
> - 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.
> - 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.
> - 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 acknowledge these requirements and intend to ensure they are met.
2023-08-02 01:01:48 +00:00
Georgii Rylov
5697f1620d Add wasm32-wasi-threads target + WASI threads 2023-07-29 16:37:50 +01:00
Chris Wailes
0081d64e4b Add definitions for riscv64_linux_android target 2023-07-26 11:46:48 -07:00
天命剑主
72dd53c8e5 add aarch64-unknown-teeos target
Signed-off-by: 袁浩 <yuanhao34@huawei.com>
2023-07-26 21:39:40 +08:00
bors
d24c4da1d6 Auto merge of #113411 - unikraft:unikraft, r=wesleywiser
Add `x86_64-unikraft-linux-musl` target

This introduces `x86_64-unikraft-linux-musl` as the first Rust target for the [Unikraft] Unikernel Development Kit.

[Unikraft]: https://unikraft.org/

Unikraft imitates Linux and uses musl as libc.
It is extremely configurable, and does not even provide a `poll` implementation or a network stack, unless enabled by the end user who compiles the application.

Our approach for integrating the build process with `rustc` is to hide the build process as well as the actual final linking step behind a linker-shim (`kraftld`, see https://github.com/unikraft/kraftkit/issues/612).

## Tier 3 target 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 will be the target maintainer.

> - 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.
>   - 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.
>   - If possible, use only letters, numbers, dashes and underscores for the name.
>     Periods (`.`) are known to cause issues in Cargo.

The target name `x86_64-unikraft-linux-musl` was derived from `x86_64-unknown-linux-musl`, setting Unikraft as vendor.
Unikraft exactly imitates Linux + musl.

> - 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.
>   - The target must not introduce license incompatibilities.
>   - Anything added to the Rust repository must be under the standard Rust
>     license (`MIT OR Apache-2.0`).
>   - 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.
>   - 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.
>   - "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.

No dependencies were added to Rust.
Requirements for linking are [Unikraft] and [KraftKit] (both BSD-3-Clause), but none of these are added to Rust.

[KraftKit]: https://github.com/unikraft/kraftkit

> - 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.
>   - 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.

Understood.
I am not a member of a Rust team.

> - 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.

Understood.
`std` is supported.

> - 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 the platform support doc.
It will be updated once proper `kraftld` support has landed.

> - 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.
>   - 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.
>   - 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 don't think this PR breaks anything.

r? compiler-team
2023-07-25 03:41:56 +00:00
Martin Kröning
bb77aa845b
compiler: Add x86_64-unikraft-linux-musl target
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 18:24:50 +02:00
Matthias Krüger
4d2f98d306
Rollup merge of #113992 - chrisnc:arm-none-fixups, r=oli-obk
arm-none fixups

- Remove "-unknown" from `llvm_target` for arm\*v7r-none-eabi\* targets.
- Remove redundant `c_enum_min_bits` option from the thumbv4t-none-eabi target.
- Fix comments about GCC/Clang's enum width for arm-none targets.

Previously part of #110482, which is a larger change to add a new target.
These nits were found along the way.
2023-07-24 17:47:09 +02:00
Simon Schöning
3003fe2d80
compiler: Add riscv64gc-unknown-hermit target
Co-authored-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 10:36:05 +02:00
Martin Kröning
636804e032
compiler: Hermit targets: Use functional update syntax
instead of mutating the base.

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 10:36:05 +02:00
Martin Kröning
a4e1bf416d
compiler: Hermit targets: Sort base fields by declaration
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 10:36:05 +02:00
Martin Kröning
2676637666
compiler: Hermit targets: Remove pre-link args.
These pre-link args are remains from Hermit's old C version.
We don't need them and we have no reason to override the defaults here.
See ld [1] for details.

[1]: https://sourceware.org/binutils/docs/ld/Options.html

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24 10:36:04 +02:00
Chris Copeland
8e54caba04
Fix comments about GCC/Clang's enum width for arm-none targets.
GCC uses the `-fshort-enums` ABI for arm-none and the `int`-sized enum
ABI for arm-linux.
Clang uses the `int`-sized enum ABI for all arm targets.

Both options are permitted by AAPCS.

Rust is matching GCC's behavior for these targets, as interop with code
code compiled by GCC is desirable in the bare-metal context. See #87917.
2023-07-23 20:19:38 -07:00
Chris Copeland
ef8994827e
Remove redundant c_enum_min_bits option from the thumbv4t-none-eabi target.
This option is the same as the `thumb_base` defaults used by this target.
2023-07-23 20:19:26 -07:00
Chris Copeland
a8f1b72f08
Remove "-unknown" from llvm_target for arm*v7r-none-eabi* targets. 2023-07-23 20:19:04 -07:00
David Tolnay
5bbf0a8306
Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"
This reverts commit 557359f925, reversing
changes made to 1e6c09a803.
2023-07-21 22:35:57 -07:00
bors
c3c5a5c5f7 Auto merge of #113922 - matthiaskrgr:rollup-90cj2vv, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #113887 (new solver: add a separate cache for coherence)
 - #113910 (Add FnPtr ty to SMIR)
 - #113913 (error/E0691: include alignment in error message)
 - #113914 (rustc_target: drop duplicate code)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-21 16:52:21 +00:00
David Rheinsberg
3e0389561b rustc_target: drop duplicate code
Drop duplicate helper methods on `Layout`, which are already implemented
on `LayoutS`. Note that `Layout` has a `Deref` implementation to
`LayoutS`, so all accessors are automatically redirected.

The methods are identical and have been copied to `rustc_abi` in:

    commit 390a637e29
    Author: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
    Date:   Mon Nov 7 00:36:11 2022 +0330

        move things from rustc_target::abi to rustc_abi

This commit left behind the original implementation. Drop it now.

Signed-off-by: David Rheinsberg <david@readahead.eu>
2023-07-21 10:31:01 +02:00
Moulins
403f34b599 Don't treat ref. fields with non-null niches as dereferenceable_or_null 2023-07-21 03:31:46 +02:00
chenx97
d3727148a0 support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00
chenx97
a132b3ec03 merge patterns 2023-07-18 18:58:18 +08:00
chenx97
c6e03cd951 support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
bors
745efcc7d9 Auto merge of #113061 - Amanieu:x86_64-ohos, r=compiler-errors
Add x86_64-unknown-linux-ohos target

This complements the existing `aarch64-unknown-linux-ohos` and `armv7-unknown-linux-ohos` targets.

This should be covered by the existing MCP (https://github.com/rust-lang/compiler-team/issues/568), but I can also create a new MCP if that is preferred.
2023-07-18 00:19:18 +00:00
Matthias Krüger
e31ebae35a
Rollup merge of #113535 - jonathanpallant:sparc-bare-metal, r=jackh726
Add a sparc-unknown-none-elf target.

# `sparc-unknown-none-elf`

**Tier: 3**

Rust for bare-metal 32-bit SPARC V7 and V8 systems, e.g. the Gaisler LEON3.

## Target maintainers

- Jonathan Pallant, `jonathan.pallant@ferrous-systems.com`, https://ferrous-systems.com

## Requirements

> Does the target support host tools, or only cross-compilation?

Only cross-compilation.

> Does the target support std, or alloc (either with a default allocator, or if the user supplies an allocator)?

Only tested with `libcore` but I see no reason why you couldn't also support `liballoc`.

> Document the expectations of binaries built for the target. Do they assume
specific minimum features beyond the baseline of the CPU/environment/etc? What
version of the OS or environment do they expect?

Tested by linking with a standard SPARC bare-metal toolchain - specifically I used the [BCC2] toolchain from Gaisler (both GCC and clang variants, both pre-compiled for x64 Linux and compiling my own SPARC GCC from source to run on `aarch64-apple-darwin`).

The target is set to use the lowest-common-denominator `SPARC V7` architecture (yes, they started at V7 - see [Wikipedia](https://en.wikipedia.org/wiki/SPARC#History)).

[BCC2]: https://www.gaisler.com/index.php/downloads/compilers

> Are there notable `#[target_feature(...)]` or `-C target-feature=` values that
programs may wish to use?

`-Ctarget-cpu=v8` adds the instructions added in V8.

`-Ctarget-cpu=leon3` adds the V8 instructions and sets up scheduling to suit the Gaisler LEON3.

> What calling convention does `extern "C"` use on the target?

I believe this is defined by the SPARC architecture reference manuals and V7, V8 and V9 are all compatible.

> What format do binaries use by default? ELF, PE, something else?

ELF

## Building the target

> If Rust doesn't build the target by default, how can users build it? Can users
just add it to the `target` list in `config.toml`?

Yes. I did:

```toml
target = ["aarch64-apple-darwin", "sparc-unknown-none-elf"]
```

## Building Rust programs

> Rust does not yet ship pre-compiled artifacts for this target. To compile for
this target, you will either need to build Rust with the target enabled (see
"Building the target" above), or build your own copy of `core` by using
`build-std` or similar.

Correct.

## Testing

> Does the target support running binaries, or do binaries have varying
expectations that prevent having a standard way to run them?

No - it's a bare metal platform.

> If users can run binaries, can they do so in some common emulator, or do they need native
hardware?

But if you use [BCC2] as the linker, you get default memory map suitable for the LEON3, and a default BSP for the LEON3, and so you can run the binaries in the `tsim-leon3` simulator from Gaisler.

```console
$ cat .cargo/config.toml | grep runner
runner = "tsim-leon3 -c sim-commands.txt"
$ cat sim-commands.txt
run
quit
$ cargo +sparcrust run --targe=sparc-unknown-none-elf
   Compiling sparc-demo-rust v0.1.0 (/work/sparc-demo-rust)
    Finished dev [unoptimized + debuginfo] target(s) in 3.44s
     Running `tsim-leon3 -c sim-commands.txt target/sparc-unknown-none-elf/debug/sparc-demo-rust`

 TSIM3 LEON3 SPARC simulator, version 3.1.9 (evaluation version)

 Copyright (C) 2023, Frontgrade Gaisler - all rights reserved.
 This software may only be used with a valid license.
 For latest updates, go to https://www.gaisler.com/
 Comments or bug-reports to support@gaisler.com

 This TSIM evaluation version will expire 2023-11-28

Number of CPUs: 2
system frequency: 50.000 MHz
icache: 1 * 4 KiB, 16 bytes/line (4 KiB total)
dcache: 1 * 4 KiB, 16 bytes/line (4 KiB total)
Allocated 8192 KiB SRAM memory, in 1 bank at 0x40000000
Allocated 32 MiB SDRAM memory, in 1 bank at 0x60000000
Allocated 8192 KiB ROM memory at 0x00000000
section: .text, addr: 0x40000000, size: 104400 bytes
section: .rodata, addr: 0x400197d0, size: 15616 bytes
section: .data, addr: 0x4001d4d0, size: 1176 bytes
read 1006 symbols

  Initializing and starting from 0x40000000
Hello, this is Rust!
PANIC: PanicInfo { payload: Any { .. }, message: Some(I am a panic), location: Location { file: "src/main.rs", line: 33, col: 5 }, can_unwind: true }

  Program exited normally on CPU 0.
```

> Does the target support running the Rust testsuite?

I don't think so, the testsuite requires `libstd` IIRC.

## Cross-compilation toolchains and C code

> Does the target support C code?

Yes.

> If so, what toolchain target should users use to build compatible C code? (This may match the target triple, or it may be a toolchain for a different target triple, potentially with specific options or caveats.)

I suggest [BCC2] from Gaisler. It comes in both GCC and Clang variants.
2023-07-17 12:58:53 +02:00
Erik Desjardins
2daacf5af9 i686-windows: make requested alignment > 4 special case apply transitively 2023-07-14 17:48:13 -04:00
Jonathan Pallant (Ferrous Systems)
d30294e33c
Add a sparc-unknown-none-elf target.
Tested with the Gaisler bcc2 toolchain (both gcc and clang) and the Leon3 simulator.
2023-07-11 15:36:42 +01:00
Erik Desjardins
d1e764cb3b aarch64-linux: properly handle 128bit aligned aggregates 2023-07-10 19:19:40 -04:00
Erik Desjardins
7e933b4e26 repr(align) <= 4 should still be byval 2023-07-10 19:19:40 -04:00
Erik Desjardins
00b3eca0df move has_repr to layout, handle repr(transparent) properly 2023-07-10 19:19:39 -04:00
Erik Desjardins
ed317e4a47 i686-windows: pass arguments with requested alignment > 4 indirectly 2023-07-10 19:19:38 -04:00
Erik Desjardins
a07eb0abbd implement vector-containing aggregate alignment for x86 darwin 2023-07-10 19:19:36 -04:00
Patrick Walton
0becc89d4a rustc_target: Add alignment to indirectly-passed by-value types, correcting the
alignment of `byval` on x86 in the process.

Commit 88e4d2c291 from five years ago removed
support for alignment on indirectly-passed arguments because of problems with
the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I
recently added to LLVM 16 depend on this to forward `memcpy`s. This commit
attempts to fix the problems with `byval` parameters on that target and now
correctly adds the `align` attribute.

The problem is summarized in [this comment] by @eddyb. Briefly, 32-bit x86 has
special alignment rules for `byval` parameters: for the most part, their
alignment is forced to 4. This is not well-documented anywhere but in the Clang
source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate
it here. The relevant methods in that file are
`X86_32ABIInfo::getIndirectResult()` and
`X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute
for `byval` parameters in LLVM must match the platform ABI, or miscompilations
will occur. Note that this doesn't use the approach suggested by eddyb, because
I felt it was overkill to store the alignment in `on_stack` when special
handling is really only needed for 32-bit x86.

As a side effect, this should fix #80127, because it will make the `align`
parameter attribute for `byval` parameters match the platform ABI on LLVM
x86-64.

[this comment]: https://github.com/rust-lang/rust/pull/80822#issuecomment-829985417
2023-07-10 19:19:30 -04:00
Havard Eidnes
6cc37bbee0 Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd. 2023-07-05 13:49:01 +00:00
David Wood
eddfce53c1
abi: avoid ice for non-ffi-safe fn ptrs
Remove an `unwrap` that assumed FFI-safe types in foreign fn-ptr types.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-07-03 13:40:20 +01:00
Rémy Rakic
38dca73456 require -Zunstable-options to use new link-self-contained values and
linker flavors

- only the stable values for `-Clink-self-contained` can be used on stable until we
have more feedback on the interface
- `-Zunstable-options` is required to use unstable linker flavors
2023-06-30 21:11:42 +00:00
Rémy Rakic
051e94d50e implement -C linker-flavor modern flavors 2023-06-30 21:10:12 +00:00
Rémy Rakic
5ea0f63733 add whether LinkerFlavor invokes the linker via a C/C++ compiler 2023-06-30 20:28:46 +00:00
Rémy Rakic
99605a0389 add whether LinkerFlavor uses lld 2023-06-30 20:28:46 +00:00
bors
af9df2fd91 Auto merge of #106619 - agausmann:avr-object-file, r=nagisa
Fix unset e_flags in ELF files generated for AVR targets

Closes #106576

~~Sort-of blocked by gimli-rs/object#500~~ (merged)

I'm not sure whether the list of AVR CPU names is okay here. Maybe it could be moved out-of-line to improve the readability of the function.
2023-06-30 08:55:56 +00:00
Amanieu d'Antras
5d46bd995d Add x86_64-unknown-linux-ohos target
This complements the existing `aarch64-unknown-linux-ohos` and
`armv7-unknown-linux-ohos` targets.
2023-06-26 16:50:36 +01:00
Matthias Krüger
f6d58eaad3
Rollup merge of #111326 - he32:netbsd-aarch64-be, r=oli-obk
Add support for NetBSD/aarch64-be (big-endian arm64).
2023-06-26 11:58:43 +02:00
Augie Fackler
34d0cffcdf switch to using a target property to control plt default 2023-06-22 14:29:22 -04:00
Thom Chiovoloni
b80e0b7f53
Reorder tvos_* functions in apple_base.rs to avoid breaking sorted order 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
b18ff59690
Fix rustc_target::spec:🍎:tests 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
abb1911682
Fix the tvOS targets to use the right LLVM target and respect the deployment target environment variables 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
3785a17dd9
Fix busted data_layout (mismatch vs LLVM) in x86_64 tvOS simulator target 2023-06-21 14:59:39 -07:00
WANG Rui
22a45258d9 loongarch64-none*: Remove environment component from llvm target 2023-06-13 20:24:22 +08:00
bors
4bd4e2ea82 Auto merge of #112386 - loongarch-rs:reloc-static, r=eholk
loongarch64-unknown-none*: Set default relocation model to static

This PR sets the default relocation model to `static` for `loongarch64-unknown-none*` targets. This change aims to streamline the development of the bare-metal project by removing the need for the executable program loader to implement relocation.
2023-06-13 09:13:03 +00:00
bors
f383703e32 Auto merge of #111698 - Amanieu:force-static-lib, r=petrochenkov
Force all native libraries to be statically linked when linking a static binary

Previously, `#[link]` without an explicit `kind = "static"` would confuse the linker and end up producing a dynamically linked library because of the `-Bdynamic` flag. However this binary would not work correctly anyways since it was linked with startup code for a static binary.

This PR solves this by forcing all native libraries to be statically linked when the output is a static binary that cannot link to dynamic libraries anyways.

Fixes #108878
Fixes #102993
2023-06-07 22:02:24 +00:00
Amanieu d'Antras
0304e0a5b0 Force all native libraries to be statically linked when linking a static binary 2023-06-07 19:30:37 +01:00
WANG Rui
37b465ff9c loongarch64-unknown-none*: Set default relocation model to static 2023-06-07 22:34:51 +08:00
bors
b3dd578767 Auto merge of #111819 - nikarh:vita-improved, r=Amanieu
Improved std support for ps vita target

Fixed a couple of things in std support for ps vita via Vita SDK newlib oss implementation:

- Added missing hardware features to target spec
- Compile in thumb by default (newlib is also compiled in thumb)
- Fixed fs calls. Vita newlib has a not-very-posix dirent. Also vita does not expose inodes, it's stubbed as 0 in stat, and I'm stubbing it here for dirent (because vita newlibs's dirent doesn't even have that field)
- Enabled signal handlers for panic unwinding
- Dropped static link requirement from the platform support md. Also, rearranged sections to better stick with the template.
2023-06-07 03:20:15 +00:00
bors
afab3662eb Auto merge of #112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #111250 (Add Terminator conversion from MIR to SMIR, part #2)
 - #112310 (Add new Tier-3 targets: `loongarch64-unknown-none*`)
 - #112334 (Add myself to highfive rotation)
 - #112340 (remove `TyCtxt::has_error_field` helper method)
 - #112343 (Prevent emitting `missing_docs` for `pub extern crate`)
 - #112350 (Avoid duplicate type sanitization of local decls in borrowck)
 - #112356 (Fix comment for `get_region_var_origins`)
 - #112358 (Remove default visitor impl in region constraint generation)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-06 21:28:34 +00:00
WANG Rui
bd32075934 Add new Tier-3 targets: loongarch64-unknown-none*
MCP: https://github.com/rust-lang/compiler-team/issues/628
2023-06-06 10:55:52 +08:00
Nikolay Arhipov
50117af409 Std support improvement for ps vita target 2023-06-05 19:14:09 +03:00
Victor Gil
1f5361b40c Added custom risc32-imac for esp-espidf target 2023-06-04 15:49:04 +02:00
bors
8ebf04225d Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #111670 (Require that const param tys implement `ConstParamTy`)
 - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…)
 - #112030 (Migrate `item_trait_alias` to Askama)
 - #112150 (Support 128-bit atomics on all x86_64 Apple targets)
 - #112174 (Fix broken link)
 - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.)
 - #112193 (Check tuple elements are `Sized` in `offset_of`)

Failed merges:

 - #112071 (Group rfcs tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-02 07:57:21 +00:00
Michael Goulet
71982341b4
Rollup merge of #112174 - cuishuang:master, r=jyn514
Fix broken link

The previous link is no longer accessible.

Use the latest link.
2023-06-01 23:07:39 -07:00
Michael Goulet
fc557576a4
Rollup merge of #112150 - taiki-e:apple-atomic-128, r=Amanieu
Support 128-bit atomics on all x86_64 Apple targets

On x86_64, we currently set `max_atomic_width` to 128 only on macOS.

ad8304a0d5/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs (L8)

However, other x86_64 Apple targets (iOS, tvOS, and watchOS) are also core2+ and support cmpxchg16b.

ad8304a0d5/compiler/rustc_target/src/spec/apple_base.rs (L71-L76)

```console
# Script to get targets that support cmpxchg16b by default:
$ (for target in $(rustc --print target-list); do [[ $target == "x86_64"* ]] && rustc --print cfg --target "$target" | grep -q cmpxchg16b && echo "$target"; done)
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
```

r? `@Amanieu`
2023-06-01 23:07:38 -07:00
cui fliter
bbfadf067c Fix broken link
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-02 09:36:01 +08:00
Deadbeef
4f83717cf7 Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
bors
9af3865dec Auto merge of #110807 - petrochenkov:strictflavor, r=lqd,wesleywiser
linker: Report linker flavors incompatible with the current target

The linker flavor is checked for target compatibility even if linker is never used (e.g. we are producing a rlib).
If it causes trouble, we can move the check to `link.rs` so it will run if the linker (flavor) is actually used.

And also feature gate explicitly specifying linker flavors for tier 3 targets.

The next step is supporting all the internal linker flavors in user-visible interfaces (command line and json).
2023-05-31 22:40:25 +00:00
Taiki Endo
0a61bc4d36 Support 128-bit atomics on all x86_64 Apple targets 2023-06-01 03:27:16 +09:00
Vadim Petrochenkov
b0ce4164f0 linker: Report linker flavors incompatible with the current target
Previously they would be reported as link time errors about unknown linker options
2023-05-29 19:58:11 +03:00
Vadim Petrochenkov
2013ccc218 rustc_target: Refactor linker flavor inference
Go through an intermediate pair of `cc`and `lld` hints instead of mapping CLI options to `LinkerFlavor` directly, and use the target's default linker flavor as a reference.
2023-05-29 19:58:11 +03:00
Ximin Luo
b65c2afdfd
Fix linkage for large binaries on mips64 platforms ...
... by enabling xgot feature

Co-Authored-By: Zixing Liu <zixing.liu@canonical.com>
2023-05-29 10:57:03 -06:00
David Carlier
1cae91e9f6 compiler: update solaris and illumos spec to support TSAN. 2023-05-28 13:46:23 +01:00
Wesley Wiser
019d75b44e Add SafeStack support to rustc
Adds support for LLVM [SafeStack] which provides backward edge control
flow protection by separating the stack into two parts: data which is
only accessed in provable safe ways is allocated on the normal stack
(the "safe stack") and all other data is placed in a separate allocation
(the "unsafe stack").

SafeStack support is enabled by passing `-Zsanitizer=safestack`.

[SafeStack]: https://clang.llvm.org/docs/SafeStack.html
2023-05-26 15:18:54 -04:00
Matthias Krüger
42c7b8a7de
Rollup merge of #111384 - bmisiak:issue-106021-fix, r=petrochenkov
Fix linking Mac Catalyst by including LC_BUILD_VERSION in object files

Hello. My first rustc PR!

Issue #106021 prevents Rust code from being linked into Mac Catalyst applications. Apple's LD has started requiring object files to contain version information about the platform they were built for, such as:
* the "deployment target" (minimum supported OS version),
* the SDK version
* the type of the platform (macOS/iOS/catalyst/tvOS/watchOS all have a different number).

This is currently only enforced when building for Mac Catalyst.

Rust uses the `object` crate which added support for including this information starting with `0.31.0`. ~~I upgraded it along with `thorin-dwp` so that everything depends on 0.31.
Apparently 0.31 [pulls in](https://github.com/gimli-rs/object/issues/463) `ruzstd` due to a [new ELF standard](https://maskray.me/blog/2022-09-09-zstd-compressed-debug-sections) because its `compression` feature is enabled by thorin. If you find this objectionable, let me know what the best way to avoid pulling in those dependencies might be.~~

**(`object` upgraded in https://github.com/rust-lang/rust/pull/111413)**

I then added two commits:
* The first one adds very basic, hard-coded support for calling `set_macho_build_version` for `-macabi` (Catalyst) targets, where it claims deployment target of Catalyst 14.0 and SDK of 16.2.
* The second weaves the versioning through `rust_target::spec::TargetOptions`, so that we can stick to specifying all target-related info in one place.

Kudos to ``@ara4n`` for writing [this gist](https://gist.github.com/ara4n/320a53ea768aba51afad4c9ed2168536).
2023-05-26 08:24:07 +02:00
Brian M
a61f026182 Mac Catalyst: specify 14.0 deployment taregt in llvm_target 2023-05-25 11:24:00 -07:00
bors
0b011b7b7e Auto merge of #111933 - matthiaskrgr:rollup-m10k3ts, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #95198 (Add slice::{split_,}{first,last}_chunk{,_mut})
 - #109899 (Use apple-m1 as target CPU for aarch64-apple-darwin.)
 - #111624 (Emit diagnostic for privately uninhabited uncovered witnesses.)
 - #111875 (Don't leak the function that is called on drop)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-25 06:02:11 +00:00
Matthias Krüger
87bb7d8ac7
Rollup merge of #109899 - daxpedda:patch-1, r=jackh726
Use apple-m1 as target CPU for aarch64-apple-darwin.

This updates the target CPU for the `aarch64-apple-darwin` target to `apple-m1`, which is the first generation of CPUs with this target anyway.

This wasn't able to be done before because of the minimum supported version of LLVM being 12, now that it was updated to 13 (in fact we are already at 14), this is available.

See previous update: https://github.com/rust-lang/rust/pull/90478.
See LLVM update: https://github.com/rust-lang/rust/pull/100460.
2023-05-25 08:01:07 +02:00
Alex Gaynor
12fd46d691
Enable sanitizers and profiler for aarch64-unknown-linux-musl 2023-05-22 14:13:23 -07:00
Adam Gausmann
a7158ecfa9 rustc_codegen_ssa: Set e_flags for AVR architecture based on target CPU 2023-05-21 16:56:57 -05:00
WANG Rui
d58863fe43 asm: loongarch64: Drop efiapi 2023-05-12 17:22:47 +08:00
Michael Goulet
691a5f3883
Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3
CFI: Fix SIGILL reached via trait objects

Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-11 17:43:07 -07:00
Ramon de C Valle
7c7b22e62c CFI: Fix SIGILL reached via trait objects
Fix #106547 by transforming the concrete self into a reference to a
trait object before emitting type metadata identifiers for trait
methods.
2023-05-09 20:04:19 +00:00
Yuki Okushi
2a8adcc966
Rollup merge of #111332 - loongarch-rs:inline-asm, r=Amanieu
Improve inline asm for LoongArch

This PR is a sub-part of https://github.com/rust-lang/rust/pull/111235, to improve inline asm for LoongArch.

r? `@Amanieu`
2023-05-08 19:41:51 +09:00
Yuki Okushi
4df84a1e4e
Rollup merge of #110638 - nikarh:vita, r=Mark-Simulacrum
STD support for PSVita

This PR adds std support for `armv7-sony-vita-newlibeabihf` target.

The work here is fairly similar to #95897, just for a different target platform.

This depends on the following pull requests:

rust-lang/backtrace-rs#523
rust-lang/libc#3209
2023-05-08 19:41:49 +09:00
Yuki Okushi
c9b4c63e01
Rollup merge of #110377 - chrisnc:armv7-atomic-64, r=cjgillot
Update max_atomic_width of armv7r and armv7_sony_vita targets to 64.

All armv7a and armv7r implementations support `ldrexd`/`strexd`, only armv7m does not.
2023-05-08 19:41:48 +09:00
Yuki Okushi
e3eb6a87bf
Rollup merge of #105354 - BlackHoleFox:apple-deployment-printer, r=oli-obk
Add deployment-target --print flag for Apple targets

This is very useful for crates that need to know what the Apple OS deployment target is for their build scripts or inside of a build environment. Right now, the defaults just get copy/pasted around the ecosystem since they've been stable for so long. But with #104385 in progress, that won't be true anymore and everything will need to move. Ideally whenever it happens again, this could be less painful as everything can ask the compiler what its default is instead.

To show examples of the copy/paste proliferation, here's some crates and/or apps that do:
- [cc](https://github.com/rust-lang/cc-rs/pull/708/files), Soon
-  [mac-notification-sys](https://github.com/h4llow3En/mac-notification-sys/pull/46/files#diff-d0d98998092552a1d3259338c2c71e118a5b8343dd4703c0c7f552ada7f9cb42R10-R12)
- [PyO3](ccb02d1aa1/src/target.rs (L755-L758))
- [Anki](613b5c1034/build/runner/src/bundle/artifacts.rs (L49-L54))
- [jsc-rs](3776726756/xtask/src/build.rs (L402-L405))
... and probably more that a simple GitHub codesearch didn't see
2023-05-08 19:41:48 +09:00
WANG Rui
c5382adc65 Simplify match statement since variable arch that is predictable 2023-05-08 11:08:09 +08:00
Havard Eidnes
6ef377cc41 Add support for NetBSD/aarch64-be (big-endian arm64). 2023-05-07 18:35:35 +00:00
Nilstrieb
f2645776dc Use smaller ints for bitflags 2023-05-07 18:24:46 +02:00
Nikolay Arhipov
3ba3df3764 PS Vita std support 2023-05-07 18:57:43 +03:00
BlackHoleFox
a427d418fd Add deployment-target --print flag for Apple targets 2023-05-05 01:22:17 -05:00
WANG Rui
08fc451771 asm: loongarch64: Implementation of clobber_abi 2023-05-05 14:21:13 +08:00
Gary Guo
c9a0be27ac Change ABI order in is_stable 2023-04-29 13:01:46 +01:00
Gary Guo
723aee2e56 Partial stabilisation of c_unwind 2023-04-29 13:01:44 +01:00
zhaixiaojuan
5f2fa4c11d Add loongarch64 asm! support 2023-04-25 14:15:31 +08:00
klensy
3338ee3ca7 drop unused deps, gate libc under unix for one crate 2023-04-22 15:22:21 +03:00
bors
3128fd8ddf Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109949 (rustdoc: migrate `document_type_layout` to askama)
 - #110622 (Stable hash tag (discriminant) of `GenericArg`)
 - #110635 (More `IS_ZST` in `library`)
 - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020)
 - #110657 (nit: consistent naming for SimplifyConstCondition)
 - #110659 (rustdoc: clean up JS)
 - #110660 (Print ty placeholders pretty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-22 05:35:08 +00:00
John Paul Adrian Glaubitz
b0692a626b compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020
Atomic operations require 68020 or later on m68k-linux-gnu.
2023-04-21 13:27:13 +02:00
DrMeepster
511e457c4b offset_of 2023-04-21 02:14:02 -07:00
Matthias Krüger
7dc211f5ce
Rollup merge of #108795 - thomcc:x86_64h-target, r=wesleywiser
Add support for the x86_64h-apple-darwin target

See https://github.com/rust-lang/compiler-team/issues/599 for MCP.

r? compiler-team

CC `@BlackHoleFox` who recently overhauled the apple target code in `rustc-target`.

## Target Support Checklist

> - 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'm the designated developer.

> - 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 uses the same naming conventions used for the other macOS targets (`-apple-darwin`), combined with the convention used by LLVM for the `x86_64h` targets. LLVM's convention matches the architecture name used when invoking various tools such as `lipo`, `arch`, and (IMO) there's not really a compelling reason to depart from it.

> - 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 don't think this is especially likely, although I suppose someone could mistake it for `x86_64-apple-darwin`.

> - If possible, use only letters, numbers, dashes and underscores for the name.
>   Periods (`.`) are known to cause issues in Cargo.

👍

> - 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.
>   - The target must not introduce license incompatibilities.

It does not.

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

It is.

> - 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 that don't also apply to `x86_64-apple-darwin`.

> - 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.

This has the same requirements as the other macOS targets (e.g. `x86_64-apple-darwin` and similar).

> - "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.

No change here.

> - 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.

👍

> - 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.

👍

> - 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.

The standard library tests seem to pass.

> - 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.

Documentation is provided.

> - 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.

Noted. This target is nearly identical to `x86_64-apple-darwin`, so this is
unlikely to cause issues anyway.

> - 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.

👍

> - 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.
>   - 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.

👍
2023-04-20 17:59:53 +02:00
Josh Soref
e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
Chris Copeland
bf264c7cfc
Update max_atomic_width of armv7r and armv7_sony_vita targets to 64. 2023-04-15 15:40:16 -07:00
bors
e14b81f10d Auto merge of #109989 - ids1024:m68k-asm, r=Amanieu
Add inline assembly support for m68k

I believe this should be correct, to the extent I understand the logic around inline assembly. M68k is fairly straightforward here, other than having separate address registers.
2023-04-13 11:41:57 +00:00
Ian Douglas Scott
2ac8dee44f Add inline assembly support for m68k 2023-04-12 17:58:15 -07:00
Matthias Krüger
331e7c3659
Rollup merge of #110153 - DaniPopes:compiler-typos, r=Nilstrieb
Fix typos in compiler

I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory.

Refs #110150
2023-04-12 20:56:21 +02:00
Michael Goulet
4a24aab220
Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiser
Initial support for loongarch64-unknown-linux-gnu

Hi, We hope to add a new port in rust for LoongArch.

LoongArch intro
LoongArch is a RISC style ISA which is independently designed by Loongson
Technology in China. It is divided into two versions, the 32-bit version (LA32)
and the 64-bit version (LA64). LA64 applications have application-level
backward binary compatibility with LA32 applications. LoongArch is composed of
a basic part (Loongson Base) and an expanded part. The expansion part includes
Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD
EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX).

Currently the LA464 processor core supports LoongArch ISA and the Loongson
3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit
high-performance processor core. It can be used as a single core for high-end
embedded and desktop applications, or as a basic processor core to form an
on-chip multi-core system for server and high-performance machine applications.

Documentations:
ISA:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html
ABI:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
More docs can be found at:
https://loongson.github.io/LoongArch-Documentation/README-EN.html

Since last year, we have locally adapted two versions of rust, rust1.41 and rust1.57, and completed the test locally.
I'm not sure if I'm submitting all the patches at once, so I split up the patches and here's one of the commits
2023-04-11 20:28:45 -07:00
DaniPopes
677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00
Nilstrieb
5853c28a7f Simply Abi::fmt 2023-04-09 23:22:14 +02:00
bors
709a97fffe Auto merge of #109173 - flba-eb:add-i586-qnx70-target, r=compiler-errors
Add tier 3 no_std x86 support for QNX Neutrino RTOS, version 7.0

This PR adds the target `i586-pc-nto-qnx700`, which targets QNX Neutrino RTOS version 7.0 on x86 32-bit targets.

cc: `@flba-eb` `@gh-tr`

This target falls under the umbrella of Tier 3 QNX Neutrino RTOS support documented in `nto-qnx.md` and previously started with #102701.
2023-04-09 07:36:53 +00:00
zhaixiaojuan
ad26dab27c Initial support for loongarch64-unknown-linux-gnu 2023-04-04 17:05:07 +08:00
Amanieu d'Antras
69e3f7a30d Disable has_thread_local on OpenHarmony
OpenHarmony uses emulated TLS, which doesn't link properly when using
thread-local variables across crate boundaries with `-C prefer-dynamic`.
This PR makes thread_local! use pthreads directly instead.
2023-04-04 02:42:42 +01:00
daxpedda
0f90aed45f
Use apple-m1 as target CPU for aarch64-apple-darwin. 2023-04-03 18:01:15 +02:00
bors
87e6b621a2 Auto merge of #109721 - QuinnPainter:armv4t-lld, r=petrochenkov
Switch to LLD as default linker for {arm,thumb}v4t-none-eabi

The LLVM 16 update brought ARMv4t support to LLD. We should use it by default so users don't need to install an external linker.

cc `@Lokathor`
2023-04-01 01:55:16 +00:00
Sam Kearney
47d7dd0c0c Add QNX 7.0 x86 target 2023-03-29 17:42:47 -07:00
bors
17c1167216 Auto merge of #108996 - pnkfelix:rollback-part-of-pr-104137-that-broke-wasm-linker-overriding, r=petrochenkov
Rollback part of pr 104137 that broke wasm linker overriding

This is a quick fix to address #108910
2023-03-29 19:18:46 +00:00
bors
f98598c6cd Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3
Support TLS access into dylibs on Windows

This allows access to `#[thread_local]`  in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it.

`convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls.

A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms.

This fixes https://github.com/rust-lang/rust/issues/84933.
2023-03-29 16:20:37 +00:00
Quinn Painter
3811275f09 Switch to LLD as default linker for {arm,thumb}v4t-none-eabi 2023-03-29 12:51:11 +01:00
John Kåre Alsaker
0d89c6a2d4 Support TLS access into dylibs on Windows 2023-03-29 08:55:21 +02:00
Amanieu d'Antras
e3968be331 Add OpenHarmony targets
- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`
2023-03-28 16:01:13 +01:00
Matthias Krüger
2a39cf560f
Rollup merge of #109231 - Zoxc:fs-non-canon, r=eholk
Add `try_canonicalize` to `rustc_fs_util` and use it over `fs::canonicalize`

This adds `try_canonicalize` which tries to call `fs::canonicalize`, but falls back to `std::path::absolute` if it fails. Existing `canonicalize` calls are replaced with it. `fs::canonicalize` is not guaranteed to work on Windows.
2023-03-23 19:55:45 +01:00
John Kåre Alsaker
4f7cd3d459 Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
Taiki Endo
fb916a0132 Fix riscv64 fuchsia LLVM target name 2023-03-15 12:55:37 +09:00
Matthias Krüger
e006ee9be8
Rollup merge of #108722 - petrhosek:fuchsia-riscv, r=petrochenkov
Support for Fuchsia RISC-V target

Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.
2023-03-14 17:40:03 +01:00
Felix S. Klock II
e919f0f20e the fix
(fixed build by adding missing import.)
2023-03-14 11:44:08 -04:00
Thom Chiovoloni
9684c38450
Add support for the x86_64h-apple-darwin target 2023-03-05 17:11:58 -08:00
Petr Hosek
c0afabbb42 Support for Fuchsia RISC-V target
Fuchsia is in the process of implementing the RISC-V support. This
change implements the minimal Rust compiler support. The support for
building runtime libraries will be implemented in follow up changes
once Fuchsia SDK has the RISC-V support.
2023-03-04 20:50:09 +00:00
Michael Woerister
ee8bc5b0b2 Use FxIndexSet instead of FxHashSet for asm_target_features query. 2023-03-01 10:19:26 +01:00
bors
6d819a4b8f Auto merge of #106476 - keith:ks/add-sanitizer-support-for-modern-ios-platforms, r=badboy
Add sanitizer support for modern iOS platforms

asan and tsan generally support iOS, but that previously wasn't configured in rust. This only adds support for the simulator architectures, and arm64 device architecture, not the older 32 bit architectures.
2023-02-18 05:58:41 +00:00
bors
fabfd1fd93 Auto merge of #99679 - repnop:kernel-address-sanitizer, r=cuviper
Add `kernel-address` sanitizer support for freestanding targets

This PR adds support for KASan (kernel address sanitizer) instrumentation in freestanding targets. I included the minimal set of `x86_64-unknown-none`, `riscv64{imac, gc}-unknown-none-elf`, and `aarch64-unknown-none` but there's likely other targets it can be added to. (`linux_kernel_base.rs`?) KASan uses the address sanitizer attributes but has the `CompileKernel` parameter set to `true` in the pass creation.
2023-02-18 03:05:11 +00:00
Matthias Krüger
e0aa5613d8
Rollup merge of #107592 - workingjubilee:use-16-bit-enum-on-16-bit-targets, r=WaffleLapkin
Default `repr(C)` enums to `c_int` size

This is what ISO C strongly implies this is correct, and
many processor-specific ABIs imply or mandate this size, so
"everyone" (LLVM, gcc...) defaults to emitting enums this way.
However, this is by no means guaranteed by ISO C,
and the bare-metal Arm targets show it can be overridden,
which rustc supports via `c-enum-min-bits` in a target.json.

The override is a flag named `-fshort-enums` in clang and gcc,
but introducing a CLI flag is probably unnecessary for rustc.
This flag can be used by non-Arm microcontroller targets,
like AVR and MSP430, but it is not enabled for them by default.
Rust programmers who know the size of a target's enums
can use explicit reprs, which also lets them match C23 code.

This change is most relevant to 16-bit targets: AVR and MSP430.
Most of rustc's targets use 32-bit ints, but ILP64 does exist.
Regardless, rustc should now correctly handle enums for
both very small and very large targets.

Thanks to William for confirming MSP430 behavior,
and to Waffle for better style and no-core `size_of` asserts.

Fixes rust-lang/rust#107361
Fixes rust-lang/rust#77806
2023-02-17 12:39:05 +01:00
Jubilee Young
2edf6c8784 Default repr(C) enums to c_int size
This is what ISO C strongly implies this is correct, and
many processor-specific ABIs imply or mandate this size, so
"everyone" (LLVM, gcc...) defaults to emitting enums this way.
However, this is by no means guaranteed by ISO C,
and the bare-metal Arm targets show it can be overridden,
which rustc supports via `c-enum-min-bits` in a target.json.

The override is a flag named `-fshort-enums` in clang and gcc,
but introducing a CLI flag is probably unnecessary for rustc.
This flag can be used by non-Arm microcontroller targets,
like AVR and MSP430, but it is not enabled for them by default.
Rust programmers who know the size of a target's enums
can use explicit reprs, which also lets them match C23 code.

This change is most relevant to 16-bit targets: AVR and MSP430.
Most of rustc's targets use 32-bit ints, but ILP64 does exist.
Regardless, rustc should now correctly handle enums for
both very small and very large targets.

Thanks to William for confirming MSP430 behavior,
and to Waffle for better style and no-core size_of asserts.

Co-authored-by: William D. Jones <thor0505@comcast.net>
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-02-16 15:06:17 -08:00
Dylan DPC
587e3dfa80
Rollup merge of #107968 - ian-h-chamberlain:feature/3ds-enable-thread-local, r=Nilstrieb
Enable `#[thread_local]` on armv6k-nintendo-3ds

Since [libctru 2.1.2](https://github.com/devkitPro/libctru/releases/tag/v2.1.2)  was released we should now be able to use real `#[thread_local]` without corruption issues on the 3DS target.

CC `@Meziu` `@AzureMarker` `@Techie-Pi`
https://github.com/rust3ds/ctru-rs/issues/91#issuecomment-1426821450
2023-02-15 12:24:55 +05:30
Dylan DPC
9800dbe883
Rollup merge of #107163 - mikebenfield:parameters-pr, r=TaKO8Ki
Remove some superfluous type parameters from layout.rs.

Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-02-15 12:24:54 +05:30
Wesley Norris
19714385e0 Add kernel-address sanitizer support for freestanding targets 2023-02-14 20:54:25 -05:00
Keith Smiley
aacf3213b1
Add sanitizer support for modern iOS platforms
asan and tsan generally support iOS, but that previously wasn't
configured in rust. This only adds support for the simulator
architectures, and arm64 device architecture, not the older 32 bit
architectures.
2023-02-12 16:00:31 -08:00
Ian Chamberlain
e723e43590
Enable #[thread_local] on armv6k-nintendo-3ds
Since libctru 2.1.2 was released
(https://github.com/devkitPro/libctru/releases/tag/v2.1.2) we should be
able to use real #[thread_local] without corruption issues on the 3DS
target.
2023-02-12 16:57:05 -05:00
Josh Stone
a06aaa4a9e Update the minimum external LLVM to 14 2023-02-10 16:06:25 -08:00
Oleksii Lozovskyi
8e49c84740 XRay support flag in TargetOptions
Specify where XRay is supported. I only test ARM64 and x86_64, but hey
those others should work too, right? LLVM documentation says that MIPS
and PPC are also supported, but I don't have the hardware, so I won't
pretend. Naturally, more targets can be added later with more testing.
2023-02-09 12:28:01 +09:00
bors
821b2a8e39 Auto merge of #106925 - imWildCat:imWildCat/remove-hardcoded-ios-macbi-target-version, r=wesleywiser
Remove hardcoded iOS version of clang target for Mac Catalyst

## Background

From `clang` 13.x, `-target x86_64-apple-ios13.0-macabi` fails while linking:

```
  = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'
```

<details>
<summary>Verbose output</summary>

```
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="[removed]" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-Wl,-exported_symbols_list,/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/list" "-target" "x86_64-apple-ios13.0-macabi" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/symbols.o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/[user].[user].a2ccc648-cgu.0.rcgu.o" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps" "-L" "/path/to/my/[project]/[user]/target/release/deps" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/libblake3-343c1616c8f62c66.rlib" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/libcompiler_builtins-15d4f20b641cf9ef.rlib" "-framework" "Security" "-framework" "CoreFoundation" "-framework" "Security" "-liconv" "-lSystem" "-lobjc" "-framework" "Security" "-framework" "Foundation" "-lc" "-lm" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-Wl,-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "-o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/lib[user].dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs"
  = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'

warning: `[user]` (lib) generated 6 warnings
error: could not compile `[user]` due to previous error; 6 warnings emitted
```
</details>

### Minimal example

C code:

```c
#include <stdio.h>
void main() {
    int a = 1;
    int b = 2;
    int c = a + b;
    printf("%d", c);
}
```

`clang` command sample:

```
➜  202301 clang -target x86_64-apple-ios13.0-macabi main.c
clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi'
➜  202301 clang -target x86_64-apple-ios14.0-macabi main.c
main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main() {
^
main.c:2:1: note: change return type to 'int'
void main() {
^~~~
int
1 warning generated.
➜  202301 clang -target x86_64-apple-ios15.0-macabi main.c
main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main() {
^
main.c:2:1: note: change return type to 'int'
void main() {
^~~~
int
1 warning generated.
➜  202301 clang -target x86_64-apple-ios-macabi main.c
main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
void main() {
^
main.c:2:1: note: change return type to 'int'
void main() {
^~~~
int
1 warning generated.

➜  202301 clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```

This PR is a simplified version of #96392, inspired by https://github.com/rust-lang/cc-rs/pull/727
2023-02-02 05:26:09 +00:00
imWildCat
5209d6f5fd Remove hardcoded clang target: ios13 or ios14 for Mac Catalyst [fixed] 2023-01-26 23:29:08 -08:00
Matthias Krüger
a8b5e5d9db
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
abi: add AddressSpace field to Primitive::Pointer

...and remove it from `PointeeInfo`, which isn't meant for this.

There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string (and various other changes),
which will be done in a followup.
(That is, if it's actually worth it to support multiple different pointer sizes.
There is a lot of code that would be affected by that.)

Fixes #106367

r? ``@oli-obk``
cc ``@Patryk27``
2023-01-26 06:15:27 +01:00
Yuki Okushi
9e79642a7b
Rollup merge of #106796 - vadorovsky:revert-105708-enable-atomic-cas-bpf, r=bjorn3
BPF: Disable atomic CAS

Enabling CAS for BPF targets (https://github.com/rust-lang/rust/pull/105708) breaks the build of core library.
The failure occurs both when building rustc for BPF targets and when
building crates for BPF targets with the current nightly.

The LLVM BPF backend does not correctly lower all `atomicrmw` operations
and crashes for unsupported ones.

Before we can enable CAS for BPF in Rust, we need to fix the LLVM BPF
backend first.

Fixes #106795

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-23 19:29:58 +09:00
Erik Desjardins
009192b01b abi: add AddressSpace field to Primitive::Pointer
...and remove it from `PointeeInfo`, which isn't meant for this.

There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string, which will be done in a followup.
2023-01-22 23:41:39 -05:00
Erik Desjardins
96f8f99589 rustc_abi: remove Primitive::{is_float,is_int}
there were fixmes for this already

i am about to remove is_ptr (since callers need to properly distinguish
between pointers in different address spaces), so might as well do this
at the same time
2023-01-22 21:02:07 -05:00
Michael Benfield
8df27d07ae Remove some superfluous type parameters from layout.rs.
Specifically remove V, which can always be VariantIdx, and F, which can
always be Layout.
2023-01-21 10:22:31 -08:00
Ulrich Weigand
492d928e44 Enable sanitizers for s390x-linux
Include sanitizers supported by LLVM on s390x (asan, lsan, msan, tsan)
in the target definition, as well as in the compiletest supported list.

Build sanitizer runtime for the target.  Enable sanitizers in the CI.
2023-01-20 18:34:24 +01:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
André Vennberg
0e65003c9e Fix some missed double spaces. 2023-01-14 18:23:40 +01:00
Michal Rostecki
651e873462 BPF: Disable atomic CAS
Enabling CAS for BPF targets (#105708) breaks the build of core library.
The failure occurs both when building rustc for BPF targets and when
building crates for BPF targets with the current nightly.

The LLVM BPF backend does not correctly lower all `atomicrmw` operations
and crashes for unsupported ones.

Before we can enable CAS for BPF in Rust, we need to fix the LLVM BPF
backend first.

Fixes #106795

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-14 22:12:11 +08:00
Nicholas Bishop
46f9e878f6 Stabilize abi_efiapi feature
Tracking issue: https://github.com/rust-lang/rust/issues/65815
2023-01-11 20:42:13 -05:00
Yuki Okushi
96e53c0c6c
Rollup merge of #106636 - djkoloski:accept_old_fuchsia_triple, r=tmandry
Accept old spelling of Fuchsia target triples

The old spelling of Fuchsia target triples was changed in #106429 to add a proper vendor. Because the old spelling is widely used, some projects may need time to migrate their uses to the new triple spelling. The old spelling may eventually be removed altogether.

r? ``@tmandry``
2023-01-10 08:05:35 +09:00
Yuki Okushi
5773e8baf0
Rollup merge of #105708 - tomerze:enable-atomic-cas-bpf, r=nagisa
Enable atomic cas for bpf targets

It seems like LLVM now supports it.

https://reviews.llvm.org/D72184 - the PR in LLVM
2023-01-10 08:05:33 +09:00
Tyler Mandry
9c23629158
Add issue number to FIXMEs 2023-01-09 13:23:50 -05:00
David Koloski
42aa075310 Accept old spelling of Fuchsia target triples
Because the old spelling is widely used, some projects may need time to
migrate their uses to the new triple spelling. The old spelling may
eventually be removed altogether.
2023-01-09 12:18:12 -05:00
fee1-dead
fd75cfef66
Rollup merge of #106061 - ilovepi:fuchsia-scs, r=oli-obk
Enable Shadow Call Stack for Fuchsia on AArch64

Fuchsia already uses SCS by default for C/C++ code on ARM hardware. This patch allows SCS to be used for Rust code as well.
2023-01-09 23:35:28 +08:00
Paul Kirth
c5bde0699f Enable Shadow Call Stack for Fuchsia on AArch64
Fuchsia already uses SCS by default for C/C++ code on ARM hardware.
This patch allows SCS to be used for Rust code as well.
2023-01-06 17:42:20 +00:00
bors
afe8c4537c Auto merge of #106474 - erikdesjardins:noalias, r=bjorn3
cleanup: handle -Zmutable-noalias like -Zbox-noalias

r? `@bjorn3`

cc `@RalfJung` this will conflict with #106180
2023-01-06 15:20:58 +00:00
bors
ce8fbe7901 Auto merge of #106429 - djkoloski:add_vendor_to_fuchsia_target_triple, r=nagisa
Add vendor to Fuchsia's target triple

Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia and aarch64-fuchsia. However, they should technically contain vendor information. This CL changes Fuchsia's target triples to include the "unknown" vendor since Clang now does normalization and handles all triple spellings.

This was previously attempted in #90510, which was closed due to inactivity.
2023-01-06 06:05:40 +00:00
nils
fd7a159710 Fix uninlined_format_args for some compiler crates
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
David Koloski
f6ef039775 Add vendor to Fuchsia's target triple
Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia
and aarch64-fuchsia. However, they should technically contain vendor
information. This CL changes Fuchsia's target triples to include the
"unknown" vendor since Clang now does normalization and handles all
triple spellings.

This was previously attempted in #90510, which was closed due to
inactivity.
2023-01-05 09:34:22 -05:00
Erik Desjardins
d165a6d708 cleanup: handle -Zmutable-noalias like -Zbox-noalias 2023-01-04 19:24:42 -05:00
bors
fbe8292872 Auto merge of #105712 - amg98:feat/vita-support, r=wesleywiser
PlayStation Vita support

Just the compiler definitions for no-std projects and std support using newlib

Earlier PR: https://github.com/rust-lang/rust/pull/105606
2023-01-03 23:38:28 +00:00
KaDiWa
7b371d2ad9
fix some typos 2022-12-25 00:43:50 +01:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
Nilstrieb
8bfd6450c7 A few small cleanups for newtype_index
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.

Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Nilstrieb
b4d739ef12 Use #[derive] instead of custom syntax in all newtype_index 2022-12-18 20:53:08 +01:00
Matthias Krüger
de59844c98 more clippy::complexity fixes 2022-12-15 00:09:10 +01:00
Andrés Martínez
76430c39f0 Added PlayStation Vita support 2022-12-14 19:39:16 +01:00
Tomer Zeitune
11331b1030 Enable atomic cas for bpf targets 2022-12-14 19:37:28 +02:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Matthias Krüger
947fe7e341
Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
Add LLVM KCFI support to the Rust compiler

This PR adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.)

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Thank you again, `@bjorn3,` `@eddyb,` `@nagisa,` and `@ojeda,` for all the help!
2022-12-10 09:24:43 +01:00
Matthias Krüger
f78babd6c4
Rollup merge of #105489 - eltociear:patch-17, r=Dylan-DPC
Fix typo in apple_base.rs

erronous -> erroneous
2022-12-09 22:31:58 +01:00
Matthias Krüger
320d018268
Rollup merge of #105468 - sunfishcode:sunfishcode/main-void-wasi, r=estebank
Mangle "main" as "__main_void" on wasm32-wasi

On wasm, the age-old C trick of having a main function which can either have no arguments or argc+argv doesn't work, because wasm requires caller and callee signatures to match. WASI's current strategy is to have compilers mangle main's name to indicate which signature they're using. Rust uses the no-argument form, which should be mangled as `__main_void`.

This is needed on wasm32-wasi as of #105395.
2022-12-09 22:31:57 +01:00
Ikko Ashimine
f41576bd3d
Fix typo in apple_base.rs
erronous -> erroneous
2022-12-09 18:09:32 +09:00
Ramon de C Valle
65698ae9f3 Add LLVM KCFI support to the Rust compiler
This commit adds LLVM Kernel Control Flow Integrity (KCFI) support to
the Rust compiler. It initially provides forward-edge control flow
protection for operating systems kernels for Rust-compiled code only by
aggregating function pointers in groups identified by their return and
parameter types. (See llvm/llvm-project@cff5bef.)

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by identifying C char and integer type uses at the
time types are encoded (see Type metadata in the design document in the
tracking issue #89653).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-12-08 17:24:39 -08:00
Dan Gohman
98ae83daae Mangle "main" as "__main_void" on wasm32-wasi
On wasm, the age-old C trick of having a main function which can either have
no arguments or argc+argv doesn't work, because wasm requires caller and
callee signatures to match. WASI's current strategy is to have compilers
mangle main's name to indicate which signature they're using. Rust uses the
no-argument form, which should be mangled as `__main_void`.

This is needed on wasm32-wasi as of #105395.
2022-12-08 13:15:40 -08:00
Matthias Krüger
4d5a2f3d81
Rollup merge of #105405 - sunfishcode:sunfishcode/export-dynamic, r=TaKO8Ki
Stop passing -export-dynamic to wasm-ld.

-export-dynamic was a temporary hack added in the early days of the Rust wasm32 target when Rust didn't have a way to specify wasm exports in the source code. This flag causes all global symbols, and some compiler-internal symbols, to be exported, which is often more than needed.

Rust now does have a way to specify exports in the source code: `#[export_name = "..."]`.

So as the original comment suggests, -export-dynamic can now be removed, allowing users to have smaller binaries and better encapsulation in their wasm32-unknown-unknown modules.

It's possible that this change will require existing wasm32-unknown-unknown users will to add explicit `#[export_name = "..."]` directives to exporrt the symbols that their programs depend on having exported.
2022-12-08 12:57:30 +01:00
Dan Gohman
3a07aa9b5e Stop passing -export-dynamic to wasm-ld.
-export-dynamic was a temporary hack added in the early days of the Rust
wasm32 target when Rust didn't have a way to specify wasm exports in the
source code. This flag causes all global symbols, and some compiler-internal
symbols, to be exported, which is often more than needed.

Rust now does have a way to specify exports in the source code:
`#[export_name = "..."]`.

So as the original comment suggests, -export-dynamic can now be removed,
allowing users to have smaller binaries and better encapsulation in
their wasm32-unknown-unknown modules.

It's possible that this change will require existing wasm32-unknown-unknown
users will to add explicit `#[export_name = "..."]` directives to
exporrt the symbols that their programs depend on having exported.
2022-12-06 16:50:29 -08:00
Matthias Krüger
7fe9597775
Rollup merge of #105123 - BlackHoleFox:fixing-the-macos-deployment, r=oli-obk
Fix passing MACOSX_DEPLOYMENT_TARGET to the linker

I messed up in https://github.com/rust-lang/rust/pull/103929 when merging the two base files together and as a result, started ignoring `MACOSX_DEPLOYMENT_TARGET` at the linker level. This ended up being the cause of nighty builds not running on older macOS versions.

My original hope with the previous PR was that CI would have caught something like that but there were only tests checking the compiler target definitions in codegen tests. Because of how badly this sucks to break, I put together a new test via `run-make` that actually confirms the deployment target set makes it to the linker instead of just LLVM.

Closes https://github.com/rust-lang/rust/issues/104570 (for real this time)
2022-12-04 11:38:51 +01:00
Matthias Krüger
1a2f79b82c
Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514
Remove useless borrows and derefs

They are nothing more than noise.
<sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
2022-12-03 17:37:42 +01:00
BlackHoleFox
56592d310f Fix passing MACOSX_DEPLOYMENT_TARGET to the linker 2022-12-02 18:12:16 -06:00
Maybe Waffle
f2b97a8bfe Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
hkalbasi
56126fb149 Extract llvm datalayout parsing out of spec module 2022-11-30 21:13:54 +03:30
Matthias Krüger
3e9a2233d0
Rollup merge of #104523 - flba-eb:fix_nto_target_name, r=wesleywiser
Don't use periods in target names

Using a period in the target name can cause issues in e.g. cargo, see also https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Running.20tests.20on.20remote.20target
2022-11-29 22:43:17 +01:00
Maybe Waffle
1d42936b18 Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
hkalbasi
390a637e29 move things from rustc_target::abi to rustc_abi 2022-11-24 16:26:13 +03:30
hkalbasi
27fb904d68 move some layout logic to rustc_target::abi::layout 2022-11-24 16:26:12 +03:30
hkalbasi
09a384643e make rustc_target usable outside of rustc 2022-11-24 16:26:12 +03:30
Yuki Okushi
b162bb4270
Rollup merge of #102293 - ecnelises:aix.initial, r=davidtwco
Add powerpc64-ibm-aix as Tier-3 target

This is part of the effort mentioned in https://github.com/rust-lang/compiler-team/issues/553.

A reference to these options are definitions from [clang](ad6fe32032/clang/lib/Basic/Targets/PPC.h (L414-L448)) and [llvm](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp).

AIX has a system `ld` but [its options and behaviors](https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command) are different from GNU ld. Thanks to ``@bzEq`` for contributing the linking args.
2022-11-23 06:40:22 +09:00
Dylan DPC
aeeac5dd0c
Rollup merge of #104001 - Ayush1325:custom-entry, r=bjorn3
Improve generating Custom entry function

This commit is aimed at making compiler-generated entry functions (Basically just C `main` right now) more generic so other targets can do similar things for custom entry. This was initially implemented as part of https://github.com/rust-lang/rust/pull/100316.

Currently, this moves the entry function name and Call convention to the target spec.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-19 11:54:43 +05:30
bors
83356b78c4 Auto merge of #104361 - vladimir-ea:watchos_fix_linking, r=oli-obk
[watchos] Dynamic linking is not allowed for watchos targets

Dynamic linking of all apple targets was (re-) enabled in PR #100636. However, dynamic linking is not allowed on WatchOS so this broke the build of standard library for WatchOS.

This change disables dynamic linking for WatchOS non-simulator targets.
2022-11-17 17:15:31 +00:00
Florian Bartels
9c3555d5c2 Remove periods from QNX/nto target names 2022-11-17 11:25:28 +01:00
Qiu Chaofan
aef3d938e4 Add powerpc64-ibm-aix as Tier-3 target 2022-11-17 16:36:54 +08:00
Matthias Krüger
fbcd751ea1
Rollup merge of #104137 - StackDoubleFlow:err-lsc-unsupported, r=bjorn3
Issue error when -C link-self-contained option is used on unsupported platforms

The documentation was also updated to reflect this.

I'm assuming the supported platforms are the same as initially written in [RELEASES.md](https://github.com/rust-lang/rust/blob/master/RELEASES.md#compiler-17).

Fixes #103576
2022-11-16 15:39:45 +01:00
StackDoubleFlow
0b6dce4309
Issue error when -C link-self-contained option is used on unsupported platforms
Document supported targets for `-C link-self-contained`

Move `LinkSelfContainedDefault::True` from wasm_base to wasm32_wasi
2022-11-14 22:21:24 -06:00
Matthias Krüger
5763fa74f0
Rollup merge of #104349 - rustaceanclub:master, r=oli-obk
fix some typos in comments
2022-11-14 19:26:18 +01:00
Matthias Krüger
8076b5903a
Rollup merge of #104357 - RalfJung:is-sized, r=cjgillot
add is_sized method on Abi and Layout, and use it

This avoids the double negation of `!is_unsized()` that we have quite a lot.
2022-11-13 17:37:38 +01:00
Vladimir Michael Eatwell
db99a89e38 [watchos] Dynamic linking is not allowed for watchos targets 2022-11-13 13:57:31 +00:00
Ralf Jung
c78021709a add is_sized method on Abi and Layout, and use it 2022-11-13 12:23:53 +01:00
cui fliter
442f848d74 fix some typos in comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-13 15:26:17 +08:00
Florian Bartels
84e1fbcadf Add no_std AArch64 support for the QNX Neutrino (nto) 7.1 RTOS
This change allows to compile no_std applications for the QNX Neutrino
realtime operating system for ARM 64 bit CPUs.
Tested with QNX Neutrino 7.1.
2022-11-11 10:44:48 +01:00
Ayush Singh
9f0a8620bd
Improve generating Custom entry function
This commit is aimed at making compiler generated entry functions
(Basically just C `main` right now) more generic so other targets can do
similar things for custom entry. This was initially implemented as part
of https://github.com/rust-lang/rust/pull/100316.

Currently, this moves the entry function name and Call convention to the
target spec.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-11 01:04:39 +05:30
Manish Goregaokar
8f2c1f8469
Rollup merge of #104077 - nicholasbishop:bishop-uefi-aapcs, r=nagisa
Use aapcs for efiapi calling convention on arm

On arm, [llvm treats the C calling convention as `aapcs` on soft-float targets and `aapcs-vfp` on hard-float targets](https://github.com/rust-lang/compiler-builtins/issues/116#issuecomment-261057422). UEFI specifies in the arm calling convention that [floating point extensions aren't used](https://uefi.org/specs/UEFI/2.10/02_Overview.html#detailed-calling-convention), so always translate `efiapi` to `aapcs` on arm.

https://github.com/rust-lang/rust/issues/65815
2022-11-10 10:47:39 -05:00
Manish Goregaokar
a7cd4f2edf
Rollup merge of #101939 - zhaixiaojuan:loongarch64-abi, r=oli-obk
Add loongarch64 abi support
2022-11-10 10:47:36 -05:00
Manish Goregaokar
bfd637a3cf
Rollup merge of #104020 - nicholasbishop:bishop-limit-efiapi, r=nagisa
Limit efiapi calling convention to supported arches

Supported architectures in UEFI are described here:
https://uefi.org/specs/UEFI/2.10/02_Overview.html#calling-conventions

https://github.com/rust-lang/rust/issues/65815
2022-11-09 15:39:05 -05:00
Manish Goregaokar
67c0bff934
Rollup merge of #104015 - alex:remove-kernel, r=oli-obk
Remove linuxkernel targets

These are not used by the actual Rust-for-Linux project, so they're mostly just confusing.
2022-11-09 15:39:05 -05:00
Manish Goregaokar
017c9aa4a0
Rollup merge of #103929 - BlackHoleFox:apple-targets-cleanup, r=petrochenkov
Cleanup Apple-related code in rustc_target

While working on https://github.com/rust-lang/rust/pull/103455, the consistency of the `rustc_target` code for Apple's platforms was "kind of bad." There were two "base" files (`apple_base.rs` and `apple_sdk_base.rs`) that the targets each pulled some parts out of, each and all of them were written slightly differently, and sometimes missed comments other implementations had.

So to hopefully make future maintenance, like implementing https://github.com/rust-lang/compiler-team/issues/556, easier, this makes all of them use similar patterns and the same target base logic everywhere instead of picking bits from both. This also has some other smaller upsides like less stringly-typed functions.
2022-11-09 15:39:04 -05:00
Dylan DPC
2b9e099a83
Rollup merge of #104067 - jeremyd2019:patch-1, r=davidtwco
fix debuginfo for windows_gnullvm_base.rs

These lines (including the FIXME comment) were added to windows_gnu_base.rs in cf2c492ef8 but windows_gnullvm_base.rs was not updated.  This resulted in an error `LLVM ERROR: dwo only supported with ELF and Wasm` attempting to build on aarch64-pc-windows-gnullvm.

See also https://github.com/msys2/MINGW-packages/pull/13921#issuecomment-1304391707

/cc ```@mati865``` ```@davidtwco```

r? ```@davidtwco```
2022-11-08 11:23:53 +05:30
jeremyd2019
6994651b6c fix debuginfo for windows_gnullvm_base.rs
These lines (including the FIXME comment) were added to windows_gnu_base.rs in cf2c492ef8 but windows_gnullvm_base.rs was not updated.  This resulted in an error `LLVM ERROR: dwo only supported with ELF and Wasm` attempting to build on aarch64-pc-windows-gnullvm.

Signed-off-by: Jeremy Drake <github@jdrake.com>
2022-11-06 17:29:14 -08:00
Nicholas Bishop
42cbb40157 Use aapcs for efiapi calling convention on arm
On arm, llvm treats the C calling convention as `aapcs` on soft-float
targets and `aapcs-vfp` on hard-float targets [1]. UEFI specifies in the
arm calling convention that floating point extensions aren't used [2],
so always translate `efiapi` to `aapcs` on arm.

[1]: https://github.com/rust-lang/compiler-builtins/issues/116#issuecomment-261057422
[2]: https://uefi.org/specs/UEFI/2.10/02_Overview.html#detailed-calling-convention

https://github.com/rust-lang/rust/issues/65815
2022-11-06 18:05:24 -05:00
Nicholas Bishop
16edaa56ba Limit efiapi calling convention to supported arches
Supported architectures in UEFI are described here:
https://uefi.org/specs/UEFI/2.10/02_Overview.html#calling-conventions

Changes to tests modeled on 8240e7aa10.

https://github.com/rust-lang/rust/issues/65815
2022-11-06 17:04:42 -05:00
Tim Neumann
f414715ebf LLVM 16: Update RISCV data layout 2022-11-06 19:03:22 +00:00
BlackHoleFox
ae948c6380 Cleanup Apple target specifications 2022-11-05 17:57:32 -05:00
BlackHoleFox
de0ab1cee6 Merge apple_base and apple_sdk_base into one module 2022-11-05 17:56:21 -05:00
Alex Gaynor
c33ee13391
Remove linuxkernel targets
These are not used by the actual Rust-for-Linux project, so they're mostly just confusing.
2022-11-05 12:30:28 -04:00
bors
ce1a7e41f9 Auto merge of #103455 - BlackHoleFox:apple-sim-abi-consistency, r=davidtwco
Fixed consistency of Apple simulator target's ABI

Currently there's a few Apple device simulator targets that are inconsistent since some set `target_abi = "sim"` (the correct thing to do) while a bunch of others don't set anything (`""`). Due to this its very hard to reliability check if some Rust code is running inside a simulator. This changes all of them to do the same thing and set `sim` as their `target_abi`.

The new way to identity a simulator during compilation is as simple as `cfg(all(target_vendor="apple", target_abi = "sim"))` or even `cfg(target_abi = "sim")` being less pedantic about it.

The issues with the current form (and inspiration for this) are also summarized in `@thomcc's` [Tweet](https://twitter.com/at_tcsc/status/1576685244702691328).
2022-11-03 03:07:31 +00:00
Michael Howell
16ca46297b
Rollup merge of #102689 - ayrtonm:master, r=cjgillot
Add a tier 3 target for the Sony PlayStation 1

This adds a tier 3 target, `mipsel-sony-psx`, for the Sony PlayStation 1. I've tested it pretty thoroughly with [this SDK](https://github.com/ayrtonm/psx-sdk-rs) I wrote for it.

From the [tier 3 target policy](https://doc.rust-lang.org/rustc/target-tier-policy.html#tier-3-target-policy) (I've omitted the subpoints for brevity, but read over everything)
> 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'd be the designated developer

> 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.

The target name follows the conventions of the existing PSP target (`mipsel-sony-psp`) and uses `psx` following the convention of the broader [PlayStation homebrew community](https://psx-spx.consoledev.net/).

> 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.

No legal issues with this target.

> 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.

👍

> 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.

The psx supports `core` and `alloc`, but will likely not support `std` anytime soon.

> 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.

This target has an SDK and a `cargo-psx` tool for formatting binaries as psx executables. Documentation and examples are provided in the [psx-sdk-rs README](https://github.com/ayrtonm/psx-sdk-rs#psx-sdk-rs), the SDK and cargo tool are both available through crates.io and docs.rs has [SDK documentation](https://docs.rs/psx/latest/psx/).

> 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.

👍

> 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.

No problem
2022-10-30 19:31:38 -07:00
Soveu
ba847cad6d Enable varargs support for calling conventions other than C or cdecl
This patch makes it possible to use varargs for calling conventions,
which are either based on C (like efiapi) or C is based
on them (for example sysv64 and win64).
2022-10-23 18:46:16 -04:00
BlackHoleFox
ffccfa1eed Fix x86_64-apple-watchos-sim target to use the correct target_abi 2022-10-23 16:39:30 -05:00
BlackHoleFox
d2a3784780 Fix x86_64-apple-tvos target to use the correct target_abi 2022-10-23 15:46:43 -05:00
BlackHoleFox
79eedef984 Fix x86_64-apple-ios target to use the correct target_abi 2022-10-23 15:44:58 -05:00