Commit graph

93 commits

Author SHA1 Message Date
Gary Guo ebdfcd93a3 Stabilise c_unwind 2024-06-19 13:54:51 +01:00
Mads Marquart fa22863f1b Fix unwinding on 32-bit watchOS ARM
The code is written in a way to support 32-bit iOS and tvOS ARM devices,
for future compatibility even though we currently only have a target for
32-bit iOS ARM.
2024-05-05 15:41:55 +02:00
Chris Denton b1f1039d8b
Replace libc::c_int with core::ffi::c_int
And remove the libc crate when it isn't needed
2024-04-14 07:11:51 +00:00
Guillaume Gomez 74a5bc6c9e
Rollup merge of #121419 - agg23:xrOS-pr, r=davidtwco
Add aarch64-apple-visionos and aarch64-apple-visionos-sim tier 3 targets

Introduces `aarch64-apple-visionos` and `aarch64-apple-visionos-sim` as tier 3 targets. This allows native development for the Apple Vision Pro's visionOS platform.

This work has been tracked in https://github.com/rust-lang/compiler-team/issues/642. There is a corresponding `libc` change https://github.com/rust-lang/libc/pull/3568 that is not required for merge.

Ideally we would be able to incorporate [this change](https://github.com/gimli-rs/object/pull/626) to the `object` crate, but the author has stated that a release will not be cut for quite a while. Therefore, the two locations that would reference the xrOS constant from `object` are hardcoded to their MachO values of 11 and 12, accompanied by TODOs to mark the code as needing change. I am open to suggestions on what to do here to get this checked in.

# Tier 3 Target Policy

At this tier, the Rust project provides no official support for a target, so we place minimal requirements on the introduction of targets.

> 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/apple-visionos.md](e88379034a/src/doc/rustc/src/platform-support/apple-visionos.md)

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

This naming scheme matches `$ARCH-$VENDOR-$OS-$ABI` which is matches the iOS Apple Silicon simulator (`aarch64-apple-ios-sim`) and other Apple targets.

> 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 besubject 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 contribution is fully available under the standard Rust license with no additional legal restrictions whatsoever. This PR does not introduce any new dependency less permissive than the Rust license policy.

The new targets do not depend on proprietary libraries.

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

This new target mirrors the standard library for watchOS and iOS, with minor divergences.

> 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 in [src/doc/rustc/src/platform-support/apple-visionos.md](e88379034a/src/doc/rustc/src/platform-support/apple-visionos.md)

> 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 that they are met.

This target does not touch any existing tier 2 or tier 1 targets and should not break any other targets.
2024-04-05 22:33:25 +02:00
Alex Crichton 2758435a8e Fix compile of wasm64-unknown-unknown target
This target is a Tier 3 target so it's not tested on CI, and it's broken
since last used so this commit fixes a small unwind-related issue that
cropped up in the meantime.
2024-03-20 14:55:02 -07:00
Mark Rousskov 02f1930595 step cfgs 2024-03-20 08:49:13 -04:00
Adam Gastineau 4f6f433745 Support for visionOS 2024-03-18 20:45:45 -07:00
Jubilee 1279830068
Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper
std support for wasm32 panic=unwind

Tracking issue: #118168

This adds std support for `-Cpanic=unwind` on wasm, and with it slightly more fleshed out rustc support. Now, the stable default is still panic=abort without exception-handling, but if you `-Zbuild-std` with `RUSTFLAGS=-Cpanic=unwind`, you get wasm exception-handling try/catch blocks in the binary:

```rust
#[no_mangle]
pub fn foo_bar(x: bool) -> *mut u8 {
    let s = Box::<str>::from("hello");
    maybe_panic(x);
    Box::into_raw(s).cast()
}

#[inline(never)]
#[no_mangle]
fn maybe_panic(x: bool) {
    if x {
        panic!("AAAAA");
    }
}
```
```wat
;; snip...
(try $label$5
 (do
  (call $maybe_panic
   (local.get $0)
  )
  (br $label$1)
 )
 (catch_all
  (global.set $__stack_pointer
   (local.get $1)
  )
  (call $__rust_dealloc
   (local.get $2)
   (i32.const 5)
   (i32.const 1)
  )
  (rethrow $label$5)
 )
)
;; snip...
```
2024-03-11 09:29:34 -07:00
Noa c7fcf437f1
Don't codegen wasm.throw unless with -Zbuild-std 2024-02-26 11:56:48 -06:00
Matthias Krüger e13f454874
Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb
Stabilize `cfg_target_abi`

This stabilizes the `cfg` option called `target_abi`:

```rust
#[cfg(target_abi = "eabihf")]
```

Tracking issue: #80970

fixes #78791
resolves #80970
2024-02-25 17:05:19 +01:00
Chris Denton 93ec0e6299
Stabilize cfg_target_abi 2024-02-24 17:52:03 -03:00
Pavel Grigorenko ff187a92d8
library: use addr_of! 2024-02-24 16:02:17 +03:00
Noa 125b26acf6
Use Itanium ABI for thrown exceptions 2024-02-22 17:39:49 -06:00
Nathan Reller adce3fd99b Enable Static Builds for FreeBSD
Enable crt-static for FreeBSD to enable statically compiled binaries.
2024-01-11 15:26:16 +00:00
Sean Cross ee870d6c82 unwind: add support for using unwinding crate
The `unwinding` crate supports processing unwinding data, and is written
entirely in Rust. This allows it to be ported to new platforms more
easily than using the llvm-based `libunwind`.

While `libunwind` is very well supported on major targets, it is
difficult to use on other targets. SGX is an example of this where Rust
carries custom patches in order to enable backtrace support.

This adds an alternative for supported architectures. Rather than
providing a custom target, `unwinding` allows for a solution that is
completely written in Rust.

This adds `xous` as the first consumer, and forthcoming patches will
modify libstd to take advantage of this.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-11-16 15:23:09 +08:00
Peter Collingbourne 654288bbb7 Remove obsolete support for linking unwinder on Android
Linking libgcc is no longer supported (see #103673), so remove the
related link attributes and the check in unwind's build.rs. The check
was the last remaining significant piece of logic in build.rs, so
remove build.rs as well.
2023-11-02 18:06:35 -07:00
niluxv e7a3c341dd
Use pointers instead of usize addresses for landing pads
This bring unwind and personality code more in line with strict-provenance
2023-10-10 09:59:39 +02:00
Qiu Chaofan 14d29be03c Support AIX in Rust standard library 2023-10-09 14:02:57 +08:00
Samuel Thibault dcea7709f2 added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
Mark Rousskov 0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
Dirreke d16409fe22 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08: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
chenx97 d3727148a0 support for mips32r6 as a target_arch value 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
Thom Chiovoloni bdc3db944c
wip: Support Apple tvOS in libstd 2023-06-21 14:59:37 -07: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
zhaixiaojuan 50be2a30cb library/unwind: Add definitions for loongarch64 2023-04-04 17:05:08 +08:00
Amanieu d'Antras e3968be331 Add OpenHarmony targets
- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`
2023-03-28 16:01:13 +01:00
est31 999405059c Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
Florian Bartels 3ce2cd059f
Add QNX Neutrino support to libstd
Co-authored-by: gh-tr <troach@qnx.com>
2023-02-28 15:59:47 +01:00
jonathanCogan db47071df2 Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
Dylan DPC 20d6a44334
Rollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc
Reduce exceptions overallocation on non Windows x86_64

Addressing https://github.com/rust-lang/rust/pull/103894#discussion_r1020950196
2022-11-22 16:36:37 +05:30
Mateusz Mikuła 10d0f1466b Reduce exceptions overallocation on non Windows x86_64
Addressing https://github.com/rust-lang/rust/pull/103894#discussion_r1020950196
2022-11-15 23:24:21 +01:00
Mateusz Mikuła c82353790a Fix building of aarch64-pc-windows-gnullvm
That change had been lost during rebase
2022-11-15 20:54:04 +01:00
bjorn3 53852ee4eb Move most of unwind's build script to lib.rs
Only the android libunwind detection remains in the build script

* Reduces dependence on build scripts for building the standard library
* Reduces dependence on exact target names in favor of using semantic
  cfg(target_*) usage.
* Keeps almost all code related to linking of the unwinder in one file
2022-11-14 14:24:12 +00:00
Manish Goregaokar c9fc5cbeb5
Rollup merge of #103744 - palfrey:unwind-upgrade-cc, r=Mark-Simulacrum
Upgrade cc for working is_flag_supported on cross-compiles

https://github.com/rust-lang/rust/pull/85806 fixed unwind v.s gcc support on later Android ndks using `is_flag_supported`. However, due to https://github.com/rust-lang/cc-rs/issues/675, this didn't work properly on cross-compiles. 3eeb50b391 fixes this, and was released in cc 1.0.74, hence the upgrade
2022-11-13 21:49:24 -05:00
bors 7b513af6c4 Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomcc
Change the way libunwind is linked for *-windows-gnullvm targets

I have no idea why previous way works for `x86_64-fortanix-unknown-sgx` (assuming it actually works...) but not for `gnullvm`. It fails when linking libtest during Rust build (unless somebody adds `RUSTFLAGS='-Clinkarg=-lunwind'`).
Also fixes exception handling on AArch64.
2022-11-13 21:12:48 +00:00
Mateusz Mikuła 2a902a8857 Bump unwinder private data size for AArch64 Windows
This fixes unwinding on `aarch64-*-windows-gnu*`.
2022-11-12 12:19:14 +01:00
Tom Parker-Shemilt 18129b67a0 Upgrade cc to 1.0.76 2022-11-09 21:52:10 +00: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
Collin Baker dfab01b6e0 Remove std's transitive dependency on cfg-if 0.1
After rust-lang/rust#101946 this completes the move to cfg-if 1.0 by:
* Updating getrandom 0.1.14->0.1.16
* Updating panic_abort, panic_unwind, and unwind to cfg-if 1.0
2022-11-02 18:01:20 -04:00
Mateusz Mikuła 68c5939722 Change the way libunwind is linked for *-windows-gnullvm targets 2022-11-01 12:22:30 +01:00
Tom Parker-Shemilt 8dbd817af1 Upgrade cc for working is_flag_supported on cross-compiles 2022-10-29 22:46:19 +01:00
Ralf Jung 63113c8b0c unwind: don't build dependency when building for Miri 2022-08-15 12:54:12 -04:00
Bryanskiy 874ee5bede add crt-static for android 2022-08-10 19:42:24 +03:00
Dylan DPC 90c59e736b
Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomcc
stdlib support for Apple WatchOS

This is a follow-up to https://github.com/rust-lang/rust/pull/95243 (Add Apple WatchOS compiler targets) that adds stdlib support for Apple WatchOS.

`@deg4uss3r`
`@nagisa`
2022-07-20 16:17:17 +05:30
Vladimir Michael Eatwell 439d64a83c Library changes for Apple WatchOS 2022-07-20 08:57:36 +01:00
Pietro Albini 6b2d3d5f3c
update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
Vadim Petrochenkov a8ee1f3a4f Stabilize the bundle native library modifier 2022-06-09 23:12:58 +04:00
Jack Huey 410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00