Skip to content

Commit a033dab

Browse files
authored
Rollup merge of #126192 - bjorn3:redox_patches, r=petrochenkov
Various Redox OS fixes and add i686 Redox OS target All of these come from the fork used by Redox OS available at https://gitlab.redox-os.org/redox-os/rust/-/commits/redox-2024-05-11/?ref_type=heads. cc `@jackpot51`
2 parents a1f48b6 + 742a923 commit a033dab

File tree

9 files changed

+96
-3
lines changed

9 files changed

+96
-3
lines changed

compiler/rustc_data_structures/src/flock.rs

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ cfg_match! {
99
mod linux;
1010
use linux as imp;
1111
}
12+
cfg(target_os = "redox") => {
13+
mod linux;
14+
use linux as imp;
15+
}
1216
cfg(unix) => {
1317
mod unix;
1418
use unix as imp;

compiler/rustc_target/src/spec/base/redox.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{cvs, RelroLevel, TargetOptions};
1+
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelroLevel, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
44
TargetOptions {
@@ -12,6 +12,8 @@ pub fn opts() -> TargetOptions {
1212
has_thread_local: true,
1313
crt_static_default: true,
1414
crt_static_respected: true,
15+
crt_static_allows_dylibs: true,
16+
late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-lgcc"]),
1517
..Default::default()
1618
}
1719
}

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@ supported_targets! {
16471647
("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),
16481648

16491649
("aarch64-unknown-redox", aarch64_unknown_redox),
1650+
("i686-unknown-redox", i686_unknown_redox),
16501651
("x86_64-unknown-redox", x86_64_unknown_redox),
16511652

16521653
("i386-apple-ios", i386_apple_ios),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target};
2+
3+
pub fn target() -> Target {
4+
let mut base = base::redox::opts();
5+
base.cpu = "pentiumpro".into();
6+
base.plt_by_default = false;
7+
base.max_atomic_width = Some(64);
8+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
9+
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
10+
base.stack_probes = StackProbeType::Call;
11+
12+
Target {
13+
llvm_target: "i686-unknown-redox".into(),
14+
metadata: crate::spec::TargetMetadata {
15+
description: None,
16+
tier: None,
17+
host_tools: None,
18+
std: None,
19+
},
20+
pointer_width: 32,
21+
data_layout:
22+
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128"
23+
.into(),
24+
arch: "x86".into(),
25+
options: base,
26+
}
27+
}

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
- [*-unknown-hermit](platform-support/hermit.md)
7272
- [\*-unknown-netbsd\*](platform-support/netbsd.md)
7373
- [*-unknown-openbsd](platform-support/openbsd.md)
74+
- [*-unknown-redox](platform-support/redox.md)
7475
- [\*-unknown-uefi](platform-support/unknown-uefi.md)
7576
- [wasm32-wasip1](platform-support/wasm32-wasip1.md)
7677
- [wasm32-wasip1-threads](platform-support/wasm32-wasip1-threads.md)

src/doc/rustc/src/platform-support.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ target | std | notes
203203
`x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27)
204204
[`x86_64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | x86_64 OpenHarmony
205205
[`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat
206-
`x86_64-unknown-redox` | ✓ | Redox OS
206+
[`x86_64-unknown-redox`](platform-support/redox.md) | ✓ | Redox OS
207207
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 64-bit UEFI
208208

209209
[^x86_32-floats-x87]: Floating-point support on `i586` targets is non-compliant: the `x87` registers and instructions used for these targets do not provide IEEE-754-compliant behavior, in particular when it comes to rounding and NaN payload bits. See [issue #114479][x86-32-float-issue].
@@ -258,7 +258,7 @@ target | std | host | notes
258258
`aarch64-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (ILP32 ABI)
259259
[`aarch64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD
260260
[`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD
261-
`aarch64-unknown-redox` | ? | | ARM64 Redox OS
261+
[`aarch64-unknown-redox`](platform-support/redox.md) | | | ARM64 Redox OS
262262
`aarch64-uwp-windows-msvc` | ✓ | |
263263
`aarch64-wrs-vxworks` | ? | |
264264
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
@@ -300,6 +300,7 @@ target | std | host | notes
300300
[`i686-unknown-hurd-gnu`](platform-support/hurd.md) | ✓ | ✓ | 32-bit GNU/Hurd [^x86_32-floats-return-ABI]
301301
[`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 with SSE2 [^x86_32-floats-return-ABI]
302302
[`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD [^x86_32-floats-return-ABI]
303+
[`i686-unknown-redox`](platform-support/redox.md) | ✓ | | i686 Redox OS
303304
`i686-uwp-windows-gnu` | ✓ | | [^x86_32-floats-return-ABI]
304305
`i686-uwp-windows-msvc` | ✓ | | [^x86_32-floats-return-ABI]
305306
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# `*-unknown-redox`
2+
3+
**Tier: 2/3**
4+
5+
Targets for the [Redox OS](https://redox-os.org/) operating
6+
system.
7+
8+
Target triplets available so far:
9+
10+
- `x86_64-unknown-redox` (tier 2)
11+
- `aarch64-unknown-redox` (tier 3)
12+
- `i686-unknown-redox` (tier 3)
13+
14+
## Target maintainers
15+
16+
- Jeremy Soller ([@jackpot51](https://github.com/jackpot51))
17+
18+
## Requirements
19+
20+
These targets are natively compiled and can be cross-compiled. Std is fully supported.
21+
22+
The targets are only expected to work with the latest version of Redox OS as the ABI is not yet stable.
23+
24+
`extern "C"` uses the official calling convention of the respective architectures.
25+
26+
Redox OS binaries use ELF as file format.
27+
28+
## Building the target
29+
30+
You can build Rust with support for the targets by adding it to the `target` list in `config.toml`. In addition a copy of [relibc] needs to be present in the linker search path.
31+
32+
```toml
33+
[build]
34+
build-stage = 1
35+
target = [
36+
"<HOST_TARGET>",
37+
"x86_64-unknown-redox",
38+
"aarch64-unknown-redox",
39+
"i686-unknown-redox",
40+
]
41+
```
42+
43+
[relibc]: https://gitlab.redox-os.org/redox-os/relibc
44+
45+
## Building Rust programs and testing
46+
47+
Rust does not yet ship pre-compiled artifacts for Redox OS except for x86_64-unknown-redox.
48+
49+
The easiest way to build and test programs for Redox OS is using [redoxer](https://gitlab.redox-os.org/redox-os/redoxer) which sets up the required compiler toolchain for building as well as runs programs inside a Redox OS VM using QEMU.
50+
51+
## Cross-compilation toolchains and C code
52+
53+
The target supports C code. Pre-compiled C toolchains can be found at <https://static.redox-os.org/toolchain/>.

src/tools/build-manifest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static TARGETS: &[&str] = &[
103103
"i686-unknown-freebsd",
104104
"i686-unknown-linux-gnu",
105105
"i686-unknown-linux-musl",
106+
"i686-unknown-redox",
106107
"i686-unknown-uefi",
107108
"loongarch64-unknown-linux-gnu",
108109
"loongarch64-unknown-none",

tests/assembly/targets/targets-elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@
228228
//@ revisions: i686_unknown_openbsd
229229
//@ [i686_unknown_openbsd] compile-flags: --target i686-unknown-openbsd
230230
//@ [i686_unknown_openbsd] needs-llvm-components: x86
231+
//@ revisions: i686_unknown_redox
232+
//@ [i686_unknown_redox] compile-flags: --target i686-unknown-redox
233+
//@ [i686_unknown_redox] needs-llvm-components: x86
231234
//@ revisions: i686_wrs_vxworks
232235
//@ [i686_wrs_vxworks] compile-flags: --target i686-wrs-vxworks
233236
//@ [i686_wrs_vxworks] needs-llvm-components: x86

0 commit comments

Comments
 (0)