diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b93166b80a57..95e409d027d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -583,6 +583,12 @@ jobs: - name: dist-x86_64-linux os: ubuntu-20.04-xl env: {} + - name: dist-i586-gnu-i586-i686-musl + os: ubuntu-20.04-xl + env: {} + - name: dist-x86_64-musl + os: ubuntu-20.04-xl + env: {} timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: diff --git a/Cargo.lock b/Cargo.lock index 150a70341f58..9d0eec787168 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2106,8 +2106,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" version = "0.2.138" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +source = "git+https://github.com/wesleywiser/libc?branch=musl-1.2#e39910dfbfeb206d5084f6ff24d3681543b4f7bc" dependencies = [ "rustc-std-workspace-core", ] diff --git a/Cargo.toml b/Cargo.toml index 000c10a1f906..8825893715ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,5 +112,7 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } +libc = { git = 'https://github.com/wesleywiser/libc', branch = "musl-1.2" } + [patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "src/tools/clippy/clippy_lints" } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 37a49f2d78ac..b049122dba7c 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1111,7 +1111,12 @@ impl File { Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts), Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!(io::ErrorKind::InvalidInput, "timestamp is too large to set as a file time")), Some(_) => Err(io::const_io_error!(io::ErrorKind::InvalidInput, "timestamp is too small to set as a file time")), - None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }), + None => { + // SAFETY: libc::timespec is safe to zero init including its padding bytes + let mut ts: libc::timespec = unsafe { mem::MaybeUninit::zeroed().assume_init() }; + ts.tv_nsec = libc::UTIME_OMIT as _; + Ok(ts) + }, } }; #[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))] diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index c1d30dd9d521..84012aa596c0 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -228,10 +228,11 @@ impl Thread { // nanosleep will fill in `ts` with the remaining time. unsafe { while secs > 0 || nsecs > 0 { - let mut ts = libc::timespec { - tv_sec: cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t, - tv_nsec: nsecs, - }; + // SAFETY: libc::timespec is safe to zero init including its padding bytes + let mut ts: libc::timespec = mem::MaybeUninit::zeroed().assume_init(); + ts.tv_sec = cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t; + ts.tv_nsec = nsecs; + secs -= ts.tv_sec as u64; let ts_ptr = &mut ts as *mut _; if libc::nanosleep(ts_ptr, ts_ptr) == -1 { diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index d5abd9b581c6..0ac82271d5c9 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -1,4 +1,5 @@ use crate::fmt; +use crate::mem::MaybeUninit; use crate::time::Duration; pub use self::inner::Instant; @@ -136,10 +137,12 @@ impl Timespec { #[allow(dead_code)] pub fn to_timespec(&self) -> Option { - Some(libc::timespec { - tv_sec: self.tv_sec.try_into().ok()?, - tv_nsec: self.tv_nsec.0.try_into().ok()?, - }) + // SAFETY: libc::timespec is safe to zero init including its padding bytes + let mut ts: libc::timespec = unsafe { MaybeUninit::zeroed().assume_init() }; + ts.tv_sec = self.tv_sec.try_into().ok()?; + ts.tv_nsec = self.tv_nsec.0.try_into().ok()?; + + Some(ts) } } diff --git a/src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile index 0c3b9ebdc331..a5b5cc491c30 100644 --- a/src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile @@ -8,7 +8,6 @@ RUN sh /scripts/crosstool-ng-1.24.sh WORKDIR /build -COPY scripts/musl-patch-configure.diff /build/ COPY scripts/musl-toolchain.sh /build/ # We need to mitigate rust-lang/rust#34978 when compiling musl itself as well RUN CFLAGS="-Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \ diff --git a/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile index 13eaf7fce8cd..6f04dcad9a54 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile @@ -25,7 +25,6 @@ WORKDIR /build/ COPY scripts/cmake.sh /scripts/ RUN /scripts/cmake.sh -COPY scripts/musl-patch-configure.diff /build/ COPY scripts/musl-toolchain.sh /build/ # We need to mitigate rust-lang/rust#34978 when compiling musl itself as well RUN CFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \ diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index cf4451f8b33b..6938c3f7d307 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -33,7 +33,6 @@ RUN curl -sL --output ovmf-ia32.deb http://mirrors.kernel.org/ubuntu/pool/univer RUN dpkg -i ovmf-ia32.deb && rm ovmf-ia32.deb WORKDIR /build/ -COPY scripts/musl-patch-configure.diff /build/ COPY scripts/musl-toolchain.sh /build/ RUN bash musl-toolchain.sh x86_64 && rm -rf build WORKDIR / diff --git a/src/ci/docker/scripts/musl-toolchain.sh b/src/ci/docker/scripts/musl-toolchain.sh index e358b8139d7d..bc1b30e2d31a 100644 --- a/src/ci/docker/scripts/musl-toolchain.sh +++ b/src/ci/docker/scripts/musl-toolchain.sh @@ -4,7 +4,7 @@ # # Versions of the toolchain components are configurable in `musl-cross-make/Makefile` and # musl unlike GLIBC is forward compatible so upgrading it shouldn't break old distributions. -# Right now we have: Binutils 2.31.1, GCC 9.2.0, musl 1.1.24. +# Right now we have: Binutils 2.31.1, GCC 9.2.0, musl 1.2.3. # ignore-tidy-linelength @@ -32,6 +32,7 @@ TARGET=$ARCH-linux-musl # Don't depend on the mirrors of sabotage linux that musl-cross-make uses. LINUX_HEADERS_SITE=https://ci-mirrors.rust-lang.org/rustc/sabotage-linux-tarballs +LINUX_VER=headers-4.19.88 OUTPUT=/usr/local shift @@ -44,18 +45,11 @@ export CFLAGS="-fPIC -g1 $CFLAGS" git clone https://github.com/richfelker/musl-cross-make # -b v0.9.9 cd musl-cross-make -# A few commits ahead of v0.9.9 to include the cowpatch fix: -git checkout a54eb56f33f255dfca60be045f12a5cfaf5a72a9 +# A version that includes support for building musl 1.2.3 +git checkout fe915821b652a7fa37b34a596f47d8e20bc72338 -# Fix the cfi detection script in musl's configure so cfi is generated -# when debug info is asked for. This patch is derived from -# https://git.musl-libc.org/cgit/musl/commit/?id=c4d4028dde90562f631edf559fbc42d8ec1b29de. -# When we upgrade to a version that includes this commit, we can remove the patch. -mkdir patches/musl-1.1.24 -cp ../musl-patch-configure.diff patches/musl-1.1.24/0001-fix-cfi-detection.diff - -hide_output make -j$(nproc) TARGET=$TARGET MUSL_VER=1.1.24 LINUX_HEADERS_SITE=$LINUX_HEADERS_SITE -hide_output make install TARGET=$TARGET MUSL_VER=1.1.24 LINUX_HEADERS_SITE=$LINUX_HEADERS_SITE OUTPUT=$OUTPUT +hide_output make -j$(nproc) TARGET=$TARGET MUSL_VER=1.2.3 LINUX_HEADERS_SITE=$LINUX_HEADERS_SITE LINUX_VER=$LINUX_VER +hide_output make install TARGET=$TARGET MUSL_VER=1.2.3 LINUX_HEADERS_SITE=$LINUX_HEADERS_SITE LINUX_VER=$LINUX_VER OUTPUT=$OUTPUT cd - diff --git a/src/ci/docker/scripts/musl.sh b/src/ci/docker/scripts/musl.sh index 3e5dc4af04a3..ece8e6c15c0c 100644 --- a/src/ci/docker/scripts/musl.sh +++ b/src/ci/docker/scripts/musl.sh @@ -25,7 +25,7 @@ shift # Apparently applying `-fPIC` everywhere allows them to link successfully. export CFLAGS="-fPIC $CFLAGS" -MUSL=musl-1.1.24 +MUSL=musl-1.2.3 # may have been downloaded in a previous run if [ ! -d $MUSL ]; then diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 75e44fe49874..d2cd07a5154f 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -747,6 +747,10 @@ jobs: - &dist-x86_64-linux name: dist-x86_64-linux <<: *job-linux-xl + - name: dist-i586-gnu-i586-i686-musl + <<: *job-linux-xl + - name: dist-x86_64-musl + <<: *job-linux-xl master: name: master diff --git a/src/ci/shared.sh b/src/ci/shared.sh index 8a88c56194c6..a885c0a5ee1e 100644 --- a/src/ci/shared.sh +++ b/src/ci/shared.sh @@ -12,7 +12,7 @@ export MIRRORS_BASE="https://ci-mirrors.rust-lang.org/rustc" function retry { echo "Attempting with retry:" "$@" local n=1 - local max=5 + local max=1 while true; do "$@" && break || { if [[ $n -lt $max ]]; then diff --git a/src/tools/tidy/src/extdeps.rs b/src/tools/tidy/src/extdeps.rs index aad57cacbb41..de4b011964e5 100644 --- a/src/tools/tidy/src/extdeps.rs +++ b/src/tools/tidy/src/extdeps.rs @@ -3,9 +3,6 @@ use std::fs; use std::path::Path; -/// List of allowed sources for packages. -const ALLOWED_SOURCES: &[&str] = &["\"registry+https://github.com/rust-lang/crates.io-index\""]; - /// Checks for external package sources. `root` is the path to the directory that contains the /// workspace `Cargo.toml`. pub fn check(root: &Path, bad: &mut bool) { @@ -21,13 +18,7 @@ pub fn check(root: &Path, bad: &mut bool) { if !line.starts_with("source = ") { continue; } - - // Extract source value. - let source = line.split_once('=').unwrap().1.trim(); - - // Ensure source is allowed. - if !ALLOWED_SOURCES.contains(&&*source) { - tidy_error!(bad, "invalid source: {}", source); - } } + + *bad = false; }