Skip to content

Commit cabdde5

Browse files
committed
Add GNU/Hurd target
The actual support will follow once the stage0 compiler has caught up with this definition.
1 parent 01ce2d0 commit cabdde5

File tree

10 files changed

+84
-3
lines changed

10 files changed

+84
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use crate::spec::{cvs, RelroLevel, TargetOptions};
2+
3+
pub fn opts() -> TargetOptions {
4+
TargetOptions {
5+
os: "hurd".into(),
6+
dynamic_linking: true,
7+
families: cvs!["unix"],
8+
has_rpath: true,
9+
position_independent_executables: true,
10+
relro_level: RelroLevel::Full,
11+
has_thread_local: true,
12+
crt_static_respected: true,
13+
..Default::default()
14+
}
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use crate::spec::TargetOptions;
2+
3+
pub fn opts() -> TargetOptions {
4+
TargetOptions { env: "gnu".into(), ..super::hurd_base::opts() }
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};
2+
3+
pub fn target() -> Target {
4+
let mut base = super::hurd_gnu_base::opts();
5+
base.cpu = "pentiumpro".into();
6+
base.max_atomic_width = Some(64);
7+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
8+
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };
9+
10+
Target {
11+
llvm_target: "i686-unknown-hurd-gnu".into(),
12+
pointer_width: 32,
13+
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14+
f64:32:64-f80:32-n8:16:32-S128"
15+
.into(),
16+
arch: "x86".into(),
17+
options: base,
18+
}
19+
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ mod freebsd_base;
7171
mod fuchsia_base;
7272
mod haiku_base;
7373
mod hermit_base;
74+
mod hurd_base;
75+
mod hurd_gnu_base;
7476
mod illumos_base;
7577
mod l4re_base;
7678
mod linux_base;
@@ -1367,6 +1369,8 @@ supported_targets! {
13671369
("i686-unknown-haiku", i686_unknown_haiku),
13681370
("x86_64-unknown-haiku", x86_64_unknown_haiku),
13691371

1372+
("i686-unknown-hurd-gnu", i686_unknown_hurd_gnu),
1373+
13701374
("aarch64-apple-darwin", aarch64_apple_darwin),
13711375
("x86_64-apple-darwin", x86_64_apple_darwin),
13721376
("x86_64h-apple-darwin", x86_64h_apple_darwin),

src/bootstrap/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
133133
// #[cfg(bootstrap)]
134134
(Some(Mode::Std), "target_vendor", Some(&["unikraft"])),
135135
(Some(Mode::Std), "target_env", Some(&["libnx"])),
136-
(Some(Mode::Std), "target_os", Some(&["teeos"])),
136+
// #[cfg(bootstrap)] hurd
137+
(Some(Mode::Std), "target_os", Some(&["teeos", "hurd"])),
137138
// #[cfg(bootstrap)] mips32r6, mips64r6
138139
(
139140
Some(Mode::Std),

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md)
2929
- [\*-android and \*-androideabi](platform-support/android.md)
3030
- [\*-linux-ohos](platform-support/openharmony.md)
31+
- [\*-hurd-gnu](platform-support/hurd.md)
3132
- [aarch64-unknown-teeos](platform-support/aarch64-unknown-teeos.md)
3233
- [\*-esp-espidf](platform-support/esp-idf.md)
3334
- [\*-unknown-fuchsia](platform-support/fuchsia.md)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ target | std | host | notes
268268
`i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.7+, Lion+)
269269
`i686-pc-windows-msvc` | * | | 32-bit Windows XP support
270270
`i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku
271+
[`i686-unknown-hurd-gnu`](platform-support/hurd.md) | ✓ | ✓ | 32-bit GNU/Hurd
271272
[`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 with SSE2
272273
[`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD
273274
`i686-uwp-windows-gnu` | ? | |
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# `i686-unknown-hurd-gnu`
2+
3+
**Tier: 3**
4+
5+
[GNU/Hurd] is the GNU Hurd is the GNU project's replacement for the Unix kernel.
6+
7+
## Target maintainers
8+
9+
- Samuel Thibault, `[email protected]`, https://github.com/sthibaul/
10+
11+
## Requirements
12+
13+
The target supports host tools.
14+
15+
The GNU/Hurd target supports `std` and uses the standard ELF file format.
16+
17+
## Building the target
18+
19+
This target can be built by adding `i686-unknown-hurd-gnu` as target in the rustc list.
20+
21+
## Building Rust programs
22+
23+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
24+
this target, you will either need to build Rust with the target enabled (see
25+
"Building the target" above), or build your own copy of `core` by using
26+
`build-std` or similar.
27+
28+
## Testing
29+
30+
Tests can be run in the same way as a regular binary.
31+
32+
## Cross-compilation toolchains and C code
33+
34+
The target supports C code, the GNU toolchain calls the target
35+
`i686-unknown-gnu`.

tests/ui/check-cfg/values-target-json.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")]
66
| |
77
| help: there is a expected value with a similar name: `"linux"`
88
|
9-
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
9+
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: 1 warning emitted

tests/ui/check-cfg/well-known-values.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")]
66
| |
77
| help: there is a expected value with a similar name: `"linux"`
88
|
9-
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
9+
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value

0 commit comments

Comments
 (0)