Skip to content

Commit

Permalink
bump kernel headers to 4.4.2-2
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed May 27, 2019
1 parent 1cbc523 commit 2543b7c
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ci/docker/mips-unknown-linux-musl/Dockerfile
Expand Up @@ -9,7 +9,7 @@ RUN mkdir /toolchain
# Note that this originally came from:
# https://downloads.openwrt.org/snapshots/targets/ar71xx/generic/openwrt-sdk-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz
RUN curl --retry 5 -L https://downloads.openwrt.org/snapshots/targets/ar71xx/generic/openwrt-sdk-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz | \
tar xf - -C /toolchain --strip-components=1
tar xf -J - -C /toolchain --strip-components=1

ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-7.4.0_musl.Linux-x86_64/bin \
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
Expand Down
7 changes: 4 additions & 3 deletions ci/install-musl.sh
Expand Up @@ -58,11 +58,12 @@ cd ..
rm -rf $MUSL

# Download, configure, build, and install musl-sanitized kernel headers:
KERNEL_HEADER_VER="4.4.2-2"
curl --retry 5 -L \
https://github.com/sabotage-linux/kernel-headers/archive/v4.4.2-1.tar.gz | \
"https://github.com/sabotage-linux/kernel-headers/archive/v${KERNEL_HEADER_VER}.tar.gz" | \
tar xzf -
(
cd kernel-headers-4.4.2-1
cd kernel-headers-${KERNEL_HEADER_VER}
make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4
)
rm -rf kernel-headers-4.4.2-1
rm -rf kernel-headers-${KERNEL_HEADER_VER}
15 changes: 10 additions & 5 deletions libc-test/build.rs
Expand Up @@ -2130,6 +2130,7 @@ fn test_linux(target: &str) {
"linux/fs.h",
"linux/futex.h",
"linux/genetlink.h",
"linux/if.h",
"linux/if_addr.h",
"linux/if_alg.h",
"linux/if_ether.h",
Expand All @@ -2152,11 +2153,6 @@ fn test_linux(target: &str) {
"sys/auxv.h",
}

// FIXME: https://github.com/sabotage-linux/kernel-headers/issues/16
if !musl {
headers!{ cfg: "linux/if.h" }
}

// note: aio.h must be included before sys/mount.h
headers! { cfg:
"sys/xattr.h",
Expand Down Expand Up @@ -2305,6 +2301,9 @@ fn test_linux(target: &str) {
// `linux_termios.rs` below:
"BOTHER" => true,

// FIXME: on musl the pthread types are defined a little differently
// - these constants are used by the glibc implementation.
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
_ => false,
}
});
Expand Down Expand Up @@ -2332,6 +2331,12 @@ fn test_linux(target: &str) {
// test the XSI version below.
"strerror_r" => true,

// FIXME: Our API is unsound. The Rust API allows aliasing
// pointers, but the C API requires pointers not to alias.
// We should probably be at least using `&`/`&mut` here, see:
// https://github.com/gnzlbg/ctest/issues/68
"lio_listio" if musl => true,

_ => false,
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/unix/notbsd/android/mod.rs
Expand Up @@ -1924,6 +1924,10 @@ f! {
}

extern {
pub fn getrlimit64(resource: ::c_int,
rlim: *mut rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::c_int,
rlim: *const rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
Expand Down
4 changes: 4 additions & 0 deletions src/unix/notbsd/emscripten/mod.rs
Expand Up @@ -1688,6 +1688,10 @@ f! {
}

extern {
pub fn getrlimit64(resource: ::c_int,
rlim: *mut rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::c_int,
rlim: *const rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
Expand Down
16 changes: 16 additions & 0 deletions src/unix/notbsd/linux/mips/mod.rs
Expand Up @@ -6,6 +6,7 @@ pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
pub type rlim_t = c_ulong;
pub type __priority_which_t = ::c_uint;
pub type __rlimit_resource_t = ::c_uint;

s! {
pub struct glob64_t {
Expand Down Expand Up @@ -906,6 +907,21 @@ f! {

#[link(name = "util")]
extern {
pub fn getrlimit64(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit) -> ::c_int;
pub fn prlimit(pid: ::pid_t,
resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
old_limit: *mut ::rlimit) -> ::c_int;
pub fn prlimit64(pid: ::pid_t,
resource: ::__rlimit_resource_t,
new_limit: *const ::rlimit64,
old_limit: *mut ::rlimit64) -> ::c_int;
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
Expand Down
11 changes: 0 additions & 11 deletions src/unix/notbsd/linux/mod.rs
Expand Up @@ -2265,17 +2265,6 @@ extern {
flags: ::c_int) -> ::c_int;
pub fn pthread_setschedprio(native: ::pthread_t,
priority: ::c_int) -> ::c_int;
pub fn getrlimit(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit) -> ::c_int;
pub fn prlimit(pid: ::pid_t,
resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
old_limit: *mut ::rlimit) -> ::c_int;
pub fn prlimit64(pid: ::pid_t,
resource: ::__rlimit_resource_t,
new_limit: *const ::rlimit64,
old_limit: *mut ::rlimit64) -> ::c_int;
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
pub fn process_vm_readv(pid: ::pid_t,
local_iov: *const ::iovec,
Expand Down
16 changes: 16 additions & 0 deletions src/unix/notbsd/linux/musl/mod.rs
Expand Up @@ -332,6 +332,22 @@ pub const SO_PEEK_OFF: ::c_int = 42;
pub const SO_BUSY_POLL: ::c_int = 46;

extern {
pub fn getrlimit64(resource: ::c_int,
rlim: *mut ::rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::c_int,
rlim: *const ::rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::c_int,
rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::c_int,
rlim: *const ::rlimit) -> ::c_int;
pub fn prlimit(pid: ::pid_t,
resource: ::c_int, new_limit: *const ::rlimit,
old_limit: *mut ::rlimit) -> ::c_int;
pub fn prlimit64(pid: ::pid_t,
resource: ::c_int,
new_limit: *const ::rlimit64,
old_limit: *mut ::rlimit64) -> ::c_int;

pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
Expand Down
16 changes: 16 additions & 0 deletions src/unix/notbsd/linux/other/mod.rs
@@ -1,5 +1,6 @@
pub type pthread_t = c_ulong;
pub type __priority_which_t = ::c_uint;
pub type __rlimit_resource_t = ::c_uint;

s! {
pub struct aiocb {
Expand Down Expand Up @@ -949,6 +950,21 @@ f! {
}

extern {
pub fn getrlimit64(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit) -> ::c_int;
pub fn prlimit(pid: ::pid_t,
resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
old_limit: *mut ::rlimit) -> ::c_int;
pub fn prlimit64(pid: ::pid_t,
resource: ::__rlimit_resource_t,
new_limit: *const ::rlimit64,
old_limit: *mut ::rlimit64) -> ::c_int;
pub fn utmpxname(file: *const ::c_char) -> ::c_int;
pub fn getutxent() -> *mut utmpx;
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
Expand Down
17 changes: 17 additions & 0 deletions src/unix/notbsd/linux/s390x/mod.rs
@@ -1,5 +1,6 @@
use ::pthread_mutex_t;

pub type __rlimit_resource_t = ::c_uint;
pub type pthread_t = c_ulong;
pub type blkcnt_t = i64;
pub type blksize_t = i64;
Expand Down Expand Up @@ -1316,6 +1317,22 @@ pub const SYS_newfstatat: ::c_long = 293;

#[link(name = "util")]
extern {
pub fn getrlimit64(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::__rlimit_resource_t,
rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::__rlimit_resource_t,
rlim: *const ::rlimit) -> ::c_int;
pub fn prlimit(pid: ::pid_t,
resource: ::__rlimit_resource_t, new_limit: *const ::rlimit,
old_limit: *mut ::rlimit) -> ::c_int;
pub fn prlimit64(pid: ::pid_t,
resource: ::__rlimit_resource_t,
new_limit: *const ::rlimit64,
old_limit: *mut ::rlimit64) -> ::c_int;

pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
Expand Down
5 changes: 0 additions & 5 deletions src/unix/notbsd/mod.rs
Expand Up @@ -4,7 +4,6 @@ pub type tcflag_t = ::c_uint;
pub type clockid_t = ::c_int;
pub type key_t = ::c_int;
pub type id_t = ::c_uint;
pub type __rlimit_resource_t = ::c_uint;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
Expand Down Expand Up @@ -1305,8 +1304,6 @@ extern {
pub fn fstatat64(dirfd: ::c_int, pathname: *const c_char,
buf: *mut stat64, flags: ::c_int) -> ::c_int;
pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
pub fn getrlimit64(resource: ::__rlimit_resource_t,
rlim: *mut rlimit64) -> ::c_int;
pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
pub fn mmap64(addr: *mut ::c_void,
Expand Down Expand Up @@ -1335,8 +1332,6 @@ extern {
pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
result: *mut *mut ::dirent64) -> ::c_int;
pub fn setrlimit64(resource: ::__rlimit_resource_t,
rlim: *const rlimit64) -> ::c_int;
pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int;

Expand Down

6 comments on commit 2543b7c

@neoeinstein
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking API change, and it broke the build for the published version of sccache (0.2.8), which uses setrlimit. The problem is that RLIMIT_CORE is a c_int, but the newly introduced __rlimit_resource_t is a c_uint. Should RLIMIT_CORE and associated constants be redefined as __rlimit_resource_t on the appropriate targets, or should we be manually casting (libc::setrlimit(libc::RLIMIT_CORE as __rlimit_resource_t, …))? Note that this code was removed in sccache master, but it seemed like something to consider.

@gnzlbg
Copy link
Contributor Author

@gnzlbg gnzlbg commented on 2543b7c May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the report.

Should RLIMIT_CORE and associated constants be redefined as __rlimit_resource_t on the appropriate targets, or should we be manually casting (libc::setrlimit(libc::RLIMIT_CORE as __rlimit_resource_t, …))?

Yes, the associated constants should use the appropriate type on master. Which type is used depends on whether the target is gnu or musl.

@gnzlbg
Copy link
Contributor Author

@gnzlbg gnzlbg commented on 2543b7c May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1382 should fix that


or should we be manually casting (libc::setrlimit(libc::RLIMIT_CORE as __rlimit_resource_t, …))?

Note that just foo as _ will always work correctly, but this should not be necessary.

@gnzlbg
Copy link
Contributor Author

@gnzlbg gnzlbg commented on 2543b7c May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neoeinstein should be fixed in 0.2.57. Could you try again and verify that this was the only issue?

@neoeinstein
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see another potential error, this one with pthread_t. I'll put in an issue and see if I can track down the commit.

@aidanhs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this is still broken after 0.2.57 for RLIMIT_NOFILE and RLIMIT_NPROC:

use libc;

fn main() {
    println!("Hello, world!");
}

fn foo() {
    unsafe {
        let _ = libc::setrlimit(libc::RLIMIT_NPROC, panic!());
        let _ = libc::setrlimit(libc::RLIMIT_NPROC, panic!());
    }
}

Please sign in to comment.