Skip to content

Move uclibc under linux #1975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,7 @@ fn test_linux(target: &str) {
let gnuabihf = target.contains("gnueabihf");
let x86_64_gnux32 = target.contains("gnux32") && x86_64;
let riscv64 = target.contains("riscv64");
let uclibc = target.contains("uclibc");

let mut cfg = ctest_cfg();
cfg.define("_GNU_SOURCE", None);
Expand Down Expand Up @@ -2377,7 +2378,8 @@ fn test_linux(target: &str) {
[!(x32 || musl || gnu)]: "sys/sysctl.h",
// <execinfo.h> is not supported by musl:
// https://www.openwall.com/lists/musl/2015/04/09/3
[!musl]: "execinfo.h",
// <execinfo.h> is not present on uclibc.
[!(musl || uclibc)]: "execinfo.h",
}

// Include linux headers at the end:
Expand Down Expand Up @@ -2419,16 +2421,18 @@ fn test_linux(target: &str) {
"linux/sockios.h",
"linux/vm_sockets.h",
"linux/wait.h",
"sys/auxv.h",
"sys/fanotify.h",
// <sys/auxv.h> is not present on uclibc
[!uclibc]: "sys/auxv.h",
}

// note: aio.h must be included before sys/mount.h
headers! {
cfg:
"sys/xattr.h",
"sys/sysinfo.h",
"aio.h",
// AIO is not supported by uclibc:
[!uclibc]: "aio.h",
}

cfg.type_name(move |ty, is_struct, is_union| {
Expand Down Expand Up @@ -2651,6 +2655,15 @@ fn test_linux(target: &str) {
| "CAN_RAW_FILTER_MAX"
| "CAN_NPROTO" => true,

"MS_RMT_MASK" if uclibc => true, // updated in glibc 2.22 and musl 1.1.13

// These are not defined in uclibc but will be passed through to the kernel
// so they will be supported if the kernel supports them. Otherwise the
// kernel will return runtime errors. Since they're required for tokio
// support, we except them from the tests here.
// See https://github.com/rust-lang/libc/pull/2019#issuecomment-754351482
"EPOLLEXCLUSIVE" | "EPOLLWAKEUP" if uclibc => true,

// FIXME: Requires recent kernel headers (5.8):
"STATX_MNT_ID" => true,

Expand Down Expand Up @@ -2698,6 +2711,31 @@ fn test_linux(target: &str) {
// FIXME: It now takes c_void instead of timezone since glibc 2.31.
"gettimeofday" if gnu => true,

// These are all implemented as static inline functions in uclibc, so
// they cannot be linked against.
// If implementations are required, they might need to be implemented
// in this crate.
"posix_spawnattr_init" if uclibc => true,
"posix_spawnattr_destroy" if uclibc => true,
"posix_spawnattr_getsigdefault" if uclibc => true,
"posix_spawnattr_setsigdefault" if uclibc => true,
"posix_spawnattr_getsigmask" if uclibc => true,
"posix_spawnattr_setsigmask" if uclibc => true,
"posix_spawnattr_getflags" if uclibc => true,
"posix_spawnattr_setflags" if uclibc => true,
"posix_spawnattr_getpgroup" if uclibc => true,
"posix_spawnattr_setpgroup" if uclibc => true,
"posix_spawnattr_getschedpolicy" if uclibc => true,
"posix_spawnattr_setschedpolicy" if uclibc => true,
"posix_spawnattr_getschedparam" if uclibc => true,
"posix_spawnattr_setschedparam" if uclibc => true,
"posix_spawn_file_actions_init" if uclibc => true,
"posix_spawn_file_actions_destroy" if uclibc => true,

// uclibc defines the flags type as a uint, but dependent crates
// assume it's a int instead.
"getnameinfo" if uclibc => true,

_ => false,
}
});
Expand Down
35 changes: 30 additions & 5 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ s! {
__re_nsub: ::size_t,
__bitfield: u8,
}

pub struct Elf64_Chdr {
pub ch_type: ::Elf64_Word,
pub ch_reserved: ::Elf64_Word,
pub ch_size: ::Elf64_Xword,
pub ch_addralign: ::Elf64_Xword,
}

pub struct Elf32_Chdr {
pub ch_type: ::Elf32_Word,
pub ch_size: ::Elf32_Word,
pub ch_addralign: ::Elf32_Word,
}
}

impl siginfo_t {
Expand Down Expand Up @@ -620,6 +633,22 @@ pub const TCP_FASTOPEN: ::c_int = 23;
pub const TCP_TIMESTAMP: ::c_int = 24;
pub const TCP_FASTOPEN_CONNECT: ::c_int = 30;

pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;

pub const AF_IB: ::c_int = 27;
pub const AF_MPLS: ::c_int = 28;
pub const AF_NFC: ::c_int = 39;
pub const AF_VSOCK: ::c_int = 40;
pub const AF_XDP: ::c_int = 44;
pub const PF_IB: ::c_int = AF_IB;
pub const PF_MPLS: ::c_int = AF_MPLS;
pub const PF_NFC: ::c_int = AF_NFC;
pub const PF_VSOCK: ::c_int = AF_VSOCK;
pub const PF_XDP: ::c_int = AF_XDP;

/* DCCP socket options */
pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
Expand All @@ -646,6 +675,7 @@ pub const SIGEV_THREAD_ID: ::c_int = 4;
pub const BUFSIZ: ::c_uint = 8192;
pub const TMP_MAX: ::c_uint = 238328;
pub const FOPEN_MAX: ::c_uint = 16;
pub const FILENAME_MAX: ::c_uint = 4096;
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
Expand Down Expand Up @@ -857,11 +887,6 @@ pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
pub const PTRACE_LISTEN: ::c_uint = 0x4208;
pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;

pub const EPOLLWAKEUP: ::c_int = 0x20000000;

pub const SEEK_DATA: ::c_int = 3;
pub const SEEK_HOLE: ::c_int = 4;

// linux/fs.h

// Flags for preadv2/pwritev2
Expand Down
Loading