Skip to content

Commit 3541306

Browse files
committed
added support for GNU/Hurd
1 parent ae9c330 commit 3541306

36 files changed

+625
-35
lines changed

compiler/rustc_data_structures/src/flock/unix.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ impl Lock {
2121
let lock_type = if exclusive { libc::F_WRLCK } else { libc::F_RDLCK };
2222

2323
let mut flock: libc::flock = unsafe { mem::zeroed() };
24-
flock.l_type = lock_type as libc::c_short;
25-
flock.l_whence = libc::SEEK_SET as libc::c_short;
24+
#[cfg(not(all(target_os = "hurd", target_arch = "x86")))]
25+
{
26+
flock.l_type = lock_type as libc::c_short;
27+
flock.l_whence = libc::SEEK_SET as libc::c_short;
28+
}
29+
#[cfg(all(target_os = "hurd", target_arch = "x86"))]
30+
{
31+
flock.l_type = lock_type as libc::c_int;
32+
flock.l_whence = libc::SEEK_SET as libc::c_int;
33+
}
2634
flock.l_start = 0;
2735
flock.l_len = 0;
2836

@@ -39,8 +47,16 @@ impl Lock {
3947
impl Drop for Lock {
4048
fn drop(&mut self) {
4149
let mut flock: libc::flock = unsafe { mem::zeroed() };
42-
flock.l_type = libc::F_UNLCK as libc::c_short;
43-
flock.l_whence = libc::SEEK_SET as libc::c_short;
50+
#[cfg(not(all(target_os = "hurd", target_arch = "x86")))]
51+
{
52+
flock.l_type = libc::F_UNLCK as libc::c_short;
53+
flock.l_whence = libc::SEEK_SET as libc::c_short;
54+
}
55+
#[cfg(all(target_os = "hurd", target_arch = "x86"))]
56+
{
57+
flock.l_type = libc::F_UNLCK as libc::c_int;
58+
flock.l_whence = libc::SEEK_SET as libc::c_int;
59+
}
4460
flock.l_start = 0;
4561
flock.l_len = 0;
4662

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+
}
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+
}
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

+4
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),

library/std/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn main() {
3838
|| target.contains("vita")
3939
|| target.contains("nto")
4040
|| target.contains("xous")
41+
|| target.contains("hurd")
4142
// See src/bootstrap/synthetic_targets.rs
4243
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
4344
{

0 commit comments

Comments
 (0)