From e39c4b94d330d9884ae7cdfb765f8f95698ba383 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 8 Jul 2025 04:04:58 +0000 Subject: [PATCH 1/2] glibc: Initial setup of source reorganization Establish the basic source reorganization for glibc, and seed it with a `net/route.h` definition. Glibc has the same headers in various locations, then copies or (I believe) combines them in the install location based on the target platform. To mirror this, our source primarily mirrors the glibc source tree, then reexports things in `src/new/glibc.rs` in the same way that glibc does when it creates an install. --- src/new/glibc/mod.rs | 21 ++++++++++++- src/new/glibc/{ => posix}/unistd.rs | 2 ++ src/new/glibc/sysdeps/unix/linux/mod.rs | 10 +++++++ src/new/glibc/sysdeps/unix/linux/net/route.rs | 30 +++++++++++++++++++ src/new/glibc/sysdeps/unix/mod.rs | 6 ++++ src/new/mod.rs | 2 ++ src/unix/linux_like/linux/gnu/mod.rs | 21 ------------- 7 files changed, 70 insertions(+), 22 deletions(-) rename src/new/glibc/{ => posix}/unistd.rs (64%) create mode 100644 src/new/glibc/sysdeps/unix/linux/mod.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/net/route.rs create mode 100644 src/new/glibc/sysdeps/unix/mod.rs diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 9c4c11412dcc5..534aba86a493a 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -2,5 +2,24 @@ //! //! * Headers: (official) //! * Headers: (mirror) +//! +//! This module structure is modeled after glibc's source tree. Its build system selects headers +//! from different locations based on the platform, which we mimic here with reexports. + +/// Source directory: `posix/` +/// +/// +mod posix { + pub(crate) mod unistd; +} + +/// Source directory: `sysdeps/` +/// +/// +mod sysdeps { + pub(crate) mod unix; +} -pub(crate) mod unistd; +pub(crate) use posix::*; +#[cfg(target_os = "linux")] +pub(crate) use sysdeps::unix::linux::*; diff --git a/src/new/glibc/unistd.rs b/src/new/glibc/posix/unistd.rs similarity index 64% rename from src/new/glibc/unistd.rs rename to src/new/glibc/posix/unistd.rs index 8d55ee5823315..907066c458df2 100644 --- a/src/new/glibc/unistd.rs +++ b/src/new/glibc/posix/unistd.rs @@ -1,4 +1,6 @@ //! Header: `unistd.h` +//! +//! pub use crate::new::common::posix::unistd::{ STDERR_FILENO, diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs new file mode 100644 index 0000000000000..0ecee596c5b12 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -0,0 +1,10 @@ +//! Source directory: `sysdeps/unix/sysv/linux` (the `sysv` is flattened). +//! +//! + +/// Directory: `net/` +/// +/// Source directory: `sysdeps/unix/sysv/linux/net` +pub(crate) mod net { + pub(crate) mod route; +} diff --git a/src/new/glibc/sysdeps/unix/linux/net/route.rs b/src/new/glibc/sysdeps/unix/linux/net/route.rs new file mode 100644 index 0000000000000..2851451652df0 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/net/route.rs @@ -0,0 +1,30 @@ +//! Header: `net/route.h` +//! +//! Source header: `sysdeps/unix/sysv/linux/net/route.h` +//! + +use crate::prelude::*; + +s! { + pub struct rtentry { + pub rt_pad1: c_ulong, + pub rt_dst: crate::sockaddr, + pub rt_gateway: crate::sockaddr, + pub rt_genmask: crate::sockaddr, + pub rt_flags: c_ushort, + pub rt_pad2: c_short, + pub rt_pad3: c_ulong, + pub rt_tos: c_uchar, + pub rt_class: c_uchar, + // FIXME(1.0): private padding fields + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: c_short, + pub rt_metric: c_short, + pub rt_dev: *mut c_char, + pub rt_mtu: c_ulong, + pub rt_window: c_ulong, + pub rt_irtt: c_ushort, + } +} diff --git a/src/new/glibc/sysdeps/unix/mod.rs b/src/new/glibc/sysdeps/unix/mod.rs new file mode 100644 index 0000000000000..55a895d4d0de2 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/mod.rs @@ -0,0 +1,6 @@ +//! Source directory: `sysdeps/unix/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod linux; diff --git a/src/new/mod.rs b/src/new/mod.rs index f83339ecf0fd1..35a493df4b152 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -177,6 +177,8 @@ cfg_if! { pub use linux::can::raw::*; pub use linux::can::*; pub use linux::keyctl::*; + #[cfg(target_env = "gnu")] + pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { pub use signal::*; } diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 206d352a67b7b..93f3a94d94cf4 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -131,27 +131,6 @@ s! { pub nm_gid: u32, } - pub struct rtentry { - pub rt_pad1: c_ulong, - pub rt_dst: crate::sockaddr, - pub rt_gateway: crate::sockaddr, - pub rt_genmask: crate::sockaddr, - pub rt_flags: c_ushort, - pub rt_pad2: c_short, - pub rt_pad3: c_ulong, - pub rt_tos: c_uchar, - pub rt_class: c_uchar, - #[cfg(target_pointer_width = "64")] - pub rt_pad4: [c_short; 3usize], - #[cfg(not(target_pointer_width = "64"))] - pub rt_pad4: c_short, - pub rt_metric: c_short, - pub rt_dev: *mut c_char, - pub rt_mtu: c_ulong, - pub rt_window: c_ulong, - pub rt_irtt: c_ushort, - } - pub struct ntptimeval { pub time: crate::timeval, pub maxerror: c_long, From 7eeb2670a9bf6b9ca60bb8a274752dd8f0dc0565 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 30 Oct 2025 03:17:03 -0500 Subject: [PATCH 2/2] ci: Skip hexagon-unknown-linux-musl This hits an error about a duplicate fma symbol while building std. --- ci/verify-build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index 2d57bd81bcea9..7e52e749440b5 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -147,7 +147,8 @@ def __post_init__(self): Target("armv7-wrs-vxworks-eabihf", dist=False), Target("armv7r-none-eabihf", dist=False), Target("armv7s-apple-ios", dist=False), - Target("hexagon-unknown-linux-musl", dist=False), + # FIXME(hexagon): hits "error: symbol 'fma' is already defined" error + # Target("hexagon-unknown-linux-musl", dist=False), Target("i386-apple-ios", dist=False), Target("i686-apple-darwin", dist=False), Target("i686-unknown-haiku", dist=False),