Skip to content

Commit

Permalink
Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber
Browse files Browse the repository at this point in the history
added support for GNU/Hurd

adding support for i686-unknown-hurd-gnu
  • Loading branch information
bors committed Sep 21, 2023
2 parents 24b45c3 + dcea770 commit f73d376
Show file tree
Hide file tree
Showing 36 changed files with 626 additions and 35 deletions.
24 changes: 20 additions & 4 deletions compiler/rustc_data_structures/src/flock/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ impl Lock {
let lock_type = if exclusive { libc::F_WRLCK } else { libc::F_RDLCK };

let mut flock: libc::flock = unsafe { mem::zeroed() };
flock.l_type = lock_type as libc::c_short;
flock.l_whence = libc::SEEK_SET as libc::c_short;
#[cfg(not(all(target_os = "hurd", target_arch = "x86")))]
{
flock.l_type = lock_type as libc::c_short;
flock.l_whence = libc::SEEK_SET as libc::c_short;
}
#[cfg(all(target_os = "hurd", target_arch = "x86"))]
{
flock.l_type = lock_type as libc::c_int;
flock.l_whence = libc::SEEK_SET as libc::c_int;
}
flock.l_start = 0;
flock.l_len = 0;

Expand All @@ -39,8 +47,16 @@ impl Lock {
impl Drop for Lock {
fn drop(&mut self) {
let mut flock: libc::flock = unsafe { mem::zeroed() };
flock.l_type = libc::F_UNLCK as libc::c_short;
flock.l_whence = libc::SEEK_SET as libc::c_short;
#[cfg(not(all(target_os = "hurd", target_arch = "x86")))]
{
flock.l_type = libc::F_UNLCK as libc::c_short;
flock.l_whence = libc::SEEK_SET as libc::c_short;
}
#[cfg(all(target_os = "hurd", target_arch = "x86"))]
{
flock.l_type = libc::F_UNLCK as libc::c_int;
flock.l_whence = libc::SEEK_SET as libc::c_int;
}
flock.l_start = 0;
flock.l_len = 0;

Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_target/src/spec/hurd_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};

pub fn opts() -> TargetOptions {
TargetOptions {
os: "hurd".into(),
dynamic_linking: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
relro_level: RelroLevel::Full,
has_thread_local: true,
crt_static_respected: true,
..Default::default()
}
}
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/hurd_gnu_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::spec::TargetOptions;

pub fn opts() -> TargetOptions {
TargetOptions { env: "gnu".into(), ..super::hurd_base::opts() }
}
19 changes: 19 additions & 0 deletions compiler/rustc_target/src/spec/i686_unknown_hurd_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target};

pub fn target() -> Target {
let mut base = super::hurd_gnu_base::opts();
base.cpu = "pentiumpro".into();
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) };

Target {
llvm_target: "i686-unknown-hurd-gnu".into(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
f64:32:64-f80:32-n8:16:32-S128"
.into(),
arch: "x86".into(),
options: base,
}
}
4 changes: 4 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ mod freebsd_base;
mod fuchsia_base;
mod haiku_base;
mod hermit_base;
mod hurd_base;
mod hurd_gnu_base;
mod illumos_base;
mod l4re_base;
mod linux_base;
Expand Down Expand Up @@ -1367,6 +1369,8 @@ supported_targets! {
("i686-unknown-haiku", i686_unknown_haiku),
("x86_64-unknown-haiku", x86_64_unknown_haiku),

("i686-unknown-hurd-gnu", i686_unknown_hurd_gnu),

("aarch64-apple-darwin", aarch64_apple_darwin),
("x86_64-apple-darwin", x86_64_apple_darwin),
("x86_64h-apple-darwin", x86_64h_apple_darwin),
Expand Down
1 change: 1 addition & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fn main() {
|| target.contains("vita")
|| target.contains("nto")
|| target.contains("xous")
|| target.contains("hurd")
// See src/bootstrap/synthetic_targets.rs
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
{
Expand Down
Loading

0 comments on commit f73d376

Please sign in to comment.