From eef435d5c6e4632d9d52a231132118a666d39616 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 18:51:53 -0400 Subject: [PATCH 01/37] Upgrade all dependencies to latest (backport ) (cherry picked from commit 1b84fd8fdc3487ae037b4bc16e32f03351ccefd6) [ `cargo update` run after the cherry pick - Trevor ] --- Cargo.lock | 32 ++++++++++++++++---------------- libc-test/Cargo.toml | 14 +++++++------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 512d405c94c07..30d8813e9114a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -23,9 +23,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "askama" @@ -90,9 +90,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "ctest" @@ -120,9 +120,9 @@ checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" [[package]] name = "glob" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "itoa" @@ -184,9 +184,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -207,9 +207,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "rustc-hash" @@ -316,9 +316,9 @@ checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-width" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "winnow" diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index f761bab3a4dde..a1b54af127ae2 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -9,20 +9,20 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" [dependencies] -cfg-if = "1.0.1" -libc = { path = "..", version = "0.2.171", default-features = false } +cfg-if = "1.0.4" +libc = { path = "..", version = "0.2.177", default-features = false } [dev-dependencies] -syn = { version = "2.0.104", features = ["full", "visit"] } -proc-macro2 = { version = "1.0.95", features = ["span-locations"] } -glob = "0.3.2" +syn = { version = "2.0.108", features = ["full", "visit"] } +proc-macro2 = { version = "1.0.103", features = ["span-locations"] } +glob = "0.3.3" annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] -cc = "1.2.29" +cc = "1.2.43" # Use the in-tree `ctest` from the `main` branch via crates.io ctest = "0.5.0-beta.1" -regex = "1.11.1" +regex = "1.12.2" [features] default = ["std"] From 307297bf17d89ef28ac75d5ff62b860fb2d807af Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 18:17:01 -0400 Subject: [PATCH 02/37] ci: Simplify job matrix with defaults Default jobs to ubuntu-24.04 but allow for overrides, and decide whether or not to run in Docker based on the target OS being Linux (rather than needing to specify). (backport ) (cherry picked from commit c239dce2feae85b70643cc4a2b60bf68ec290745) --- .github/workflows/ci.yaml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 70b3fbd1e2cee..16fa73e1f9d26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,23 +93,15 @@ jobs: matrix: include: - target: i686-unknown-linux-gnu - docker: true - os: ubuntu-24.04 - target: i686-unknown-linux-gnu - docker: true - os: ubuntu-24.04 artifact-tag: offset-bits64 env: RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 - target: i686-unknown-linux-gnu - docker: true - os: ubuntu-24.04 artifact-tag: time-bits64 env: RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 - target: x86_64-unknown-linux-gnu - docker: true - os: ubuntu-24.04 - target: aarch64-apple-darwin os: macos-15 - target: x86_64-pc-windows-gnu @@ -126,7 +118,7 @@ jobs: # ARCH: i686 - target: i686-pc-windows-msvc os: windows-2025 - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 env: TARGET: ${{ matrix.target }} @@ -146,10 +138,10 @@ jobs: shell: bash - name: Run natively - if: "!matrix.docker" + if: runner.os != 'Linux' run: ./ci/run.sh ${{ matrix.target }} - name: Run in Docker - if: "matrix.docker" + if: runner.os == 'Linux' run: ./ci/run-docker.sh ${{ matrix.target }} - name: Create CI artifacts @@ -166,7 +158,7 @@ jobs: # Unlike `main` this job doesn't have `needs`, in order to speed up backports a bit test_tier2: name: Test tier2 - runs-on: ubuntu-24.04 + needs: [test_tier1, style_check] strategy: fail-fast: true max-parallel: 12 @@ -239,6 +231,7 @@ jobs: # env: # RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 # artifact-tag: time-bits64 + runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 env: TARGET: ${{ matrix.target }} @@ -257,7 +250,11 @@ jobs: jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV shell: bash - - name: Execute run-docker.sh + - name: Run natively + if: runner.os != 'Linux' + run: ./ci/run.sh ${{ matrix.target }} + - name: Run in Docker + if: runner.os == 'Linux' run: ./ci/run-docker.sh ${{ matrix.target }} - name: Create CI artifacts From fcee6972161da7600d40f83aa5417b81d98ed52d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 18:33:35 -0400 Subject: [PATCH 03/37] ci: Sort the tier1 targets (backport ) (cherry picked from commit 49c300a3370ea374be2a88a1ab0f01b8b4e8fae2) --- .github/workflows/ci.yaml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 16fa73e1f9d26..8e29f8275ee66 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -92,6 +92,13 @@ jobs: strategy: matrix: include: + - target: aarch64-apple-darwin + os: macos-15 + # FIXME: It currently causes segfaults. + #- target: i686-pc-windows-gnu + # env: { ARCH_BITS: 32, ARCH: i686 } + - target: i686-pc-windows-msvc + os: windows-2025 - target: i686-unknown-linux-gnu - target: i686-unknown-linux-gnu artifact-tag: offset-bits64 @@ -101,23 +108,12 @@ jobs: artifact-tag: time-bits64 env: RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 - - target: x86_64-unknown-linux-gnu - - target: aarch64-apple-darwin - os: macos-15 - target: x86_64-pc-windows-gnu os: windows-2025 - env: - ARCH_BITS: 64 - ARCH: x86_64 + env: { ARCH_BITS: 64, ARCH: x86_64 } - target: x86_64-pc-windows-msvc os: windows-2025 - # FIXME: It currently causes segfaults. - #- target: i686-pc-windows-gnu - # env: - # ARCH_BITS: 32 - # ARCH: i686 - - target: i686-pc-windows-msvc - os: windows-2025 + - target: x86_64-unknown-linux-gnu runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 env: From d4f893a029d663786d4c8105bfd0708a82a59a1e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 18:35:38 -0400 Subject: [PATCH 04/37] ci: Update the tier1 jobs aarch64-windows and aarch64-linux are now both tier 1, so promote them in CI. (backport ) (cherry picked from commit 3655bfdbfd8832dfb71559c7528a576891fc59aa) --- .github/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8e29f8275ee66..6f6e0831a637f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -94,6 +94,10 @@ jobs: include: - target: aarch64-apple-darwin os: macos-15 + - target: aarch64-pc-windows-msvc + os: windows-11-arm + - target: aarch64-unknown-linux-gnu + os: ubuntu-24.04-arm # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu # env: { ARCH_BITS: 32, ARCH: i686 } @@ -164,7 +168,6 @@ jobs: # it first to make sure it gets a head start. - sparc64-unknown-linux-gnu - aarch64-linux-android - - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl - arm-linux-androideabi - arm-unknown-linux-musleabihf From 757cb1d5398cf7c6d958b79618e5e76194af900b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 18:41:50 -0400 Subject: [PATCH 05/37] ci: Switch tier2 to use `include` style There isn't really any reason to use both `include` and the default matrix with `target` separately. This requires adding an artifact tag to the musl jobs. Additionally, flatten some bulky env options and prepare the Tier 2 VM targets to have more operating systems. (backport ) (cherry picked from commit 8b300eb9b7d6cf4d36213889784eff36542ebdf4) --- .github/workflows/ci.yaml | 102 ++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6f6e0831a637f..076db50c5e4f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -106,12 +106,10 @@ jobs: - target: i686-unknown-linux-gnu - target: i686-unknown-linux-gnu artifact-tag: offset-bits64 - env: - RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 + env: { RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 } - target: i686-unknown-linux-gnu artifact-tag: time-bits64 - env: - RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 + env: { RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 } - target: x86_64-pc-windows-gnu os: windows-2025 env: { ARCH_BITS: 64, ARCH: x86_64 } @@ -163,72 +161,67 @@ jobs: fail-fast: true max-parallel: 12 matrix: - target: + include: # FIXME(sparc): this takes much longer to run than any other job, put # it first to make sure it gets a head start. - - sparc64-unknown-linux-gnu - - aarch64-linux-android - - aarch64-unknown-linux-musl - - arm-linux-androideabi - - arm-unknown-linux-musleabihf - # FIXME(#4297): Disabled due to spurious failueSome android jobs are disabled because of high rates of - # - i686-linux-android - - i686-unknown-linux-musl - - loongarch64-unknown-linux-gnu - - loongarch64-unknown-linux-musl - - powerpc64-unknown-linux-gnu - - powerpc64le-unknown-linux-gnu - - powerpc64le-unknown-linux-musl - - riscv64gc-unknown-linux-gnu - - s390x-unknown-linux-gnu - - wasm32-unknown-emscripten - - wasm32-wasip1 - - wasm32-wasip2 - - x86_64-linux-android - # FIXME: Exec format error (os error 8) - # - x86_64-unknown-linux-gnux32 - - x86_64-unknown-linux-musl - # FIXME: It seems some items in `src/unix/mod.rs` - # aren't defined on redox actually. - # - x86_64-unknown-redox - include: + - target: sparc64-unknown-linux-gnu + - target: aarch64-linux-android + - target: aarch64-unknown-linux-musl + - target: aarch64-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: arm-linux-androideabi - target: arm-unknown-linux-gnueabihf - target: arm-unknown-linux-gnueabihf - env: - RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 + env: { RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 } artifact-tag: offset-bits64 - target: arm-unknown-linux-gnueabihf - env: - RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 + env: { RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 } artifact-tag: time-bits64 - - target: aarch64-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 - target: arm-unknown-linux-musleabihf - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: arm-unknown-linux-musleabihf + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + # FIXME(#4297): Disabled due to spurious failue + # - target: i686-linux-android - target: i686-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: i686-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: loongarch64-unknown-linux-gnu + - target: loongarch64-unknown-linux-musl - target: loongarch64-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: powerpc64-unknown-linux-gnu + - target: powerpc64le-unknown-linux-gnu - target: powerpc64le-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: powerpc64le-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + - target: riscv64gc-unknown-linux-gnu + - target: s390x-unknown-linux-gnu + - target: wasm32-unknown-emscripten + - target: wasm32-wasip1 + - target: wasm32-wasip2 + - target: x86_64-linux-android + # FIXME: Exec format error (os error 8) + # - target: x86_64-unknown-linux-gnux32 - target: x86_64-unknown-linux-musl - env: - RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: x86_64-unknown-linux-musl + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + artifact-tag: new-musl + # FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually. + # - target: x86_64-unknown-redox + # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu # - target: powerpc-unknown-linux-gnu - # env: - # RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 + # env: { RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 } # artifact-tag: offset-bits64 # - target: powerpc-unknown-linux-gnu - # env: - # RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 + # env: { RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 } # artifact-tag: time-bits64 runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 @@ -273,13 +266,14 @@ jobs: strategy: fail-fast: true matrix: - target: - - x86_64-pc-solaris + include: + - target: x86_64-pc-solaris timeout-minutes: 25 steps: - uses: actions/checkout@v5 - name: test on Solaris uses: vmactions/solaris-vm@v1.1.5 + if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" usesh: true From 0cc7293ca1392b4e8bcc6a415dd43e58ec5215e6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 18:48:09 -0400 Subject: [PATCH 06/37] ci: Increase tier 2 max-parallel We have gained quite a few tier 2 jobs. Increase max-parallel so they don't take quite as long. (backport ) (cherry picked from commit e3cbac6363ac866d4b68f87cfc825adf83540bd1) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 076db50c5e4f0..3b96f4e8990bb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -159,7 +159,7 @@ jobs: needs: [test_tier1, style_check] strategy: fail-fast: true - max-parallel: 12 + max-parallel: 16 matrix: include: # FIXME(sparc): this takes much longer to run than any other job, put From 79fd792cd09f1d5c6958264909ee975944e4aff7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 19:13:54 -0400 Subject: [PATCH 07/37] ci: Don't retry the s390x job We no longer use the flaky qemu-system runner, so there shouldn't be any need to keep the retry. (backport ) (cherry picked from commit bad4627c6c6be3527ef5c305f15ed94a74578497) --- ci/run.sh | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 0938b695d403d..6ec25f5c70a5e 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -25,39 +25,9 @@ case "$target" in *) cmd="$cmd --workspace" ;; esac -if [ "$target" = "s390x-unknown-linux-gnu" ]; then - # FIXME: s390x-unknown-linux-gnu often fails to test due to timeout, - # so we retry this N times. - N=5 - n=0 - passed=0 - until [ $n -ge $N ]; do - if [ "$passed" = "0" ]; then - # shellcheck disable=SC2086 - if $cmd --no-default-features -- $test_flags; then - passed=$((passed + 1)) - continue - fi - elif [ "$passed" = "1" ]; then - # shellcheck disable=SC2086 - if $cmd -- $test_flags; then - passed=$((passed + 1)) - continue - fi - elif [ "$passed" = "2" ]; then - # shellcheck disable=SC2086 - if $cmd --features extra_traits -- $test_flags; then - break - fi - fi - n=$((n + 1)) - sleep 1 - done -else - # shellcheck disable=SC2086 - $cmd --no-default-features -- $test_flags - # shellcheck disable=SC2086 - $cmd -- $test_flags - # shellcheck disable=SC2086 - $cmd --features extra_traits -- $test_flags -fi +# shellcheck disable=SC2086 +$cmd --no-default-features -- $test_flags +# shellcheck disable=SC2086 +$cmd -- $test_flags +# shellcheck disable=SC2086 +$cmd --features extra_traits -- $test_flags From d968de32c8d78f70fac83a4428a1eb1f84d98f75 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 19:02:53 -0400 Subject: [PATCH 08/37] ci: Add an x86_64-apple job I'm not sure why this was missing: possibly because it was only previously only possible to test with macos-13. GHA now has macos-15-intel which makes this easier, so add the job back. (backport ) (cherry picked from commit eb88448be3e3aa07179bb48ee06343cfb8656c8b) --- .github/workflows/ci.yaml | 2 ++ libc-test/build.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b96f4e8990bb..0effac4922c1e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -204,6 +204,8 @@ jobs: - target: wasm32-unknown-emscripten - target: wasm32-wasip1 - target: wasm32-wasip2 + - target: x86_64-apple-darwin + os: macos-15-intel - target: x86_64-linux-android # FIXME: Exec format error (os error 8) # - target: x86_64-unknown-linux-gnux32 diff --git a/libc-test/build.rs b/libc-test/build.rs index 51457f3b4f6e3..54636a7503038 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -317,7 +317,7 @@ fn test_apple(target: &str) { (x86_64, "crt_externs.h"), ); - cfg.skip_struct(|s| { + cfg.skip_struct(move |s| { match s.ident() { // FIXME(union): actually a union "sigval" => true, @@ -326,6 +326,9 @@ fn test_apple(target: &str) { // it is a moving target, changing through versions // also contains bitfields members "tcp_connection_info" => true, + + // FIXME(macos): The size is changed in recent macOSes. + "malloc_introspection_t" if x86_64 => true, _ => false, } }); @@ -351,6 +354,8 @@ fn test_apple(target: &str) { match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, + // close calls the close_nocancel system call on x86 + "close" if x86_64 => true, // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, _ => false, From 20c1d859443c72fcc23bde543cf6daf80867eea7 Mon Sep 17 00:00:00 2001 From: Kartik Agarwala Date: Sun, 26 Oct 2025 06:21:36 +0000 Subject: [PATCH 09/37] Add missing defines/functions needed by rust stdlib (backport ) (cherry picked from commit 0cd50326719a4eb541e39f24e871f7b1f54fb035) --- src/vxworks/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index ce6c91678caf4..ecaba54b1cdcf 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -952,6 +952,11 @@ pub const SI_MESGQ: c_int = -5; pub const SI_CHILD: c_int = -6; pub const SI_KILL: c_int = SI_USER; +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; +pub const AT_REMOVEDIR: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; + // vxParams.h definitions pub const _PARM_NAME_MAX: c_int = 255; pub const _PARM_PATH_MAX: c_int = 1024; @@ -1017,6 +1022,7 @@ pub const RTP_ID_ERROR: crate::RTP_ID = -1; // h/public/unistd.h pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; // Via unistd.h +pub const _SC_HOST_NAME_MAX: c_int = 22; pub const _SC_PAGESIZE: c_int = 39; pub const O_ACCMODE: c_int = 3; pub const O_CLOEXEC: c_int = 0x100000; // fcntlcom @@ -1166,6 +1172,7 @@ extern "C" { pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, n: size_t) -> size_t; pub fn strerror(n: c_int) -> *mut c_char; pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; @@ -1250,6 +1257,13 @@ extern "C" { pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + #[link_name = "_rtld_dlopen"] pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; From e6525330e1bdb87e13a3caa7405f162b0c5a7b8c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 21:37:30 -0400 Subject: [PATCH 10/37] ci: Switch `verify-build` to a python script It would be nice to do a few more things with this script that are starting to get cumbersome in bash. Switch to python so we gain some flexibility. There are some target inaccuracies in the lists here, but fixing these is left for a future change. (backport ) (cherry picked from commit f82e7fae815f20e1274c455fad8325b3e8541636) --- .github/workflows/ci.yaml | 4 +- README.md | 2 +- ci/verify-build.py | 362 ++++++++++++++++++++++++++++++++++++++ ci/verify-build.sh | 344 ------------------------------------ 4 files changed, 365 insertions(+), 347 deletions(-) create mode 100755 ci/verify-build.py delete mode 100755 ci/verify-build.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0effac4922c1e..9857aeb8bec2c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -78,12 +78,12 @@ jobs: - name: Target size after restoring cache run: du -sh target | sort -k 2 || true - - name: Execute build.sh + - name: Execute build check run: | set -eux # Remove `-Dwarnings` at the MSRV since lints may be different [ "${{ matrix.toolchain }}" = "1.63.0" ] && export RUSTFLAGS="" - ./ci/verify-build.sh + python3 ci/verify-build.py --toolchain "$TOOLCHAIN" - name: Target size after job completion run: du -sh target | sort -k 2 diff --git a/README.md b/README.md index c616d8b29f52b..607bf308d01eb 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ but this is not guaranteed. You can see the platform(target)-specific docs on [docs.rs], select a platform you want to see. -See [`ci/verify-build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.sh) for +See [`ci/verify-build.py`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.py) for the platforms on which `libc` is guaranteed to build for each Rust toolchain. The test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which `libc` tests are run. diff --git a/ci/verify-build.py b/ci/verify-build.py new file mode 100755 index 0000000000000..09d185658f7ed --- /dev/null +++ b/ci/verify-build.py @@ -0,0 +1,362 @@ +#!/usr/bin/env python3 + +import re +import os +import argparse +import subprocess as sp +import sys +import platform +from typing import Optional +from enum import Enum, IntEnum +from dataclasses import dataclass, field + + +ESC_CYAN = "\033[1;36m" +ESC_END = "\033[0m" + + +class Os(Enum): + LINUX = "Linux" + WINDOWS = "Windows" + DARWIN = "Darwin" + + +class Toolchain(IntEnum): + OTHER = 0 # msrv + STABLE = 1 + BETA = 2 + NIGHTLY = 3 + + +@dataclass +class Cfg: + toolchain_name: str + toolchain: Toolchain = field(init=False) + host_target: str = field(init=False) + os_: Os = field(init=False) + + def __post_init__(self): + rustc_output = check_output(["rustc", f"+{self.toolchain_name}", "-vV"]) + self.host_target = re.findall(r"host: (.*)", rustc_output)[0] + if "nightly" in self.toolchain_name: + self.toolchain = Toolchain.NIGHTLY + elif "beta" in self.toolchain_name: + self.toolchain = Toolchain.BETA + elif "stable" in self.toolchain_name: + self.toolchain = Toolchain.STABLE + else: + self.toolchain = Toolchain.OTHER + self.os_ = Os(platform.system()) + eprint(f"Testing Rust {self.toolchain_name} on {self.os_}") + + def nightly(self) -> bool: + return self.toolchain == Toolchain.NIGHTLY + + +@dataclass +class Target: + name: str + dist: bool = True + min_toolchain: Toolchain = Toolchain.OTHER + + def __post_init__(self): + if not self.dist: + # We will need to use build-std + self.min_toolchain = Toolchain.NIGHTLY + + def run_on(self) -> Os: + """MacOS CI runs all apple targets, Windows CI runs all Windows targets, + Linux CI handles everything else.""" + + if "apple" in self.name: + return Os.DARWIN + elif "windows" in self.name: + return Os.WINDOWS + return Os.LINUX + + +FREEBSD_VERSIONS = [11, 12, 13, 14, 15] + +TARGETS = [ + # linux + Target("aarch64-linux-android"), + Target("aarch64-unknown-linux-gnu"), + Target("aarch64-unknown-linux-musl"), + Target("arm-linux-androideabi"), + Target("arm-unknown-linux-gnueabi"), + Target("arm-unknown-linux-gnueabihf"), + Target("arm-unknown-linux-musleabi"), + Target("arm-unknown-linux-musleabihf"), + Target("armv7-linux-androideabi"), + Target("armv7-unknown-linux-gnueabihf"), + Target("armv7-unknown-linux-musleabihf"), + Target("i586-unknown-linux-gnu"), + Target("i586-unknown-linux-musl"), + Target("i686-linux-android"), + Target("i686-unknown-freebsd"), + Target("i686-unknown-linux-gnu"), + Target("i686-unknown-linux-musl"), + Target("powerpc-unknown-linux-gnu"), + Target("powerpc64-unknown-linux-gnu"), + Target("powerpc64le-unknown-linux-gnu"), + Target("s390x-unknown-linux-gnu"), + Target("sparc64-unknown-linux-gnu"), + Target("sparcv9-sun-solaris"), + Target("wasm32-unknown-emscripten"), + Target("wasm32-unknown-unknown"), + # Target was renamed + Target("wasm32-wasip1", min_toolchain=Toolchain.STABLE), + Target("wasm32-wasip2", min_toolchain=Toolchain.STABLE), + Target("x86_64-linux-android"), + Target("x86_64-unknown-freebsd"), + Target("x86_64-unknown-linux-gnu"), + Target("x86_64-unknown-linux-musl"), + Target("x86_64-unknown-netbsd"), + # nightly linux + # FIXME(powerpc64le): powerpc64le-unknown-linux-musl is tier 2 since 1.85 and + # can be moved to rust_linux_targets once MSRV is increased + Target("aarch64-unknown-fuchsia", min_toolchain=Toolchain.NIGHTLY), + Target("armv5te-unknown-linux-gnueabi", min_toolchain=Toolchain.NIGHTLY), + Target("armv5te-unknown-linux-musleabi", min_toolchain=Toolchain.NIGHTLY), + Target("i686-pc-windows-gnu", min_toolchain=Toolchain.NIGHTLY), + Target("powerpc64le-unknown-linux-musl", min_toolchain=Toolchain.NIGHTLY), + Target("riscv64gc-unknown-linux-gnu", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-fortanix-unknown-sgx", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-pc-solaris", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-pc-windows-gnu", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-unknown-fuchsia", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-unknown-illumos", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-unknown-linux-gnux32", min_toolchain=Toolchain.NIGHTLY), + Target("x86_64-unknown-redox", min_toolchain=Toolchain.NIGHTLY), + # apple + Target("aarch64-apple-darwin"), + Target("aarch64-apple-ios"), + # windows + Target("x86_64-pc-windows-msvc"), + Target("x86_64-pc-windows-gnu"), + Target("i686-pc-windows-msvc"), + # linux nodist + # Targets which are not available via rustup and must be built with -Zbuild-std + # FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has + # duplicate symbol errors from `compiler_builtins`. + Target("aarch64-pc-windows-msvc", dist=False), + Target("aarch64-unknown-freebsd", dist=False), + Target("aarch64-unknown-hermit", dist=False), + Target("aarch64-unknown-netbsd", dist=False), + Target("aarch64-unknown-openbsd", dist=False), + Target("aarch64-wrs-vxworks", dist=False), + Target("armebv7r-none-eabi", dist=False), + Target("armebv7r-none-eabihf", dist=False), + Target("armv7-wrs-vxworks-eabihf", dist=False), + Target("armv7r-none-eabi", dist=False), + Target("armv7r-none-eabihf", dist=False), + Target("i686-pc-windows-msvc", dist=False), + Target("i686-unknown-haiku", dist=False), + Target("i686-unknown-netbsd", dist=False), + Target("i686-unknown-openbsd", dist=False), + Target("i686-wrs-vxworks", dist=False), + Target("mips-unknown-linux-gnu", dist=False), + Target("mips-unknown-linux-musl", dist=False), + Target("mips64-unknown-linux-gnuabi64", dist=False), + Target("mips64-unknown-linux-muslabi64", dist=False), + Target("mips64el-unknown-linux-gnuabi64", dist=False), + Target("mips64el-unknown-linux-muslabi64", dist=False), + Target("mipsel-unknown-linux-gnu", dist=False), + Target("mipsel-unknown-linux-musl", dist=False), + Target("nvptx64-nvidia-cuda", dist=False), + Target("powerpc-unknown-linux-gnuspe", dist=False), + Target("powerpc-unknown-netbsd", dist=False), + Target("powerpc-wrs-vxworks", dist=False), + Target("powerpc-wrs-vxworks-spe", dist=False), + Target("powerpc64-unknown-freebsd", dist=False), + Target("powerpc64-wrs-vxworks", dist=False), + Target("riscv32i-unknown-none-elf", dist=False), + Target("riscv32imac-unknown-none-elf", dist=False), + Target("riscv32imc-unknown-none-elf", dist=False), + Target("riscv32gc-unknown-linux-gnu", dist=False), + Target("riscv32-wrs-vxworks", dist=False), + Target("riscv64gc-unknown-freebsd", dist=False), + Target("riscv64gc-unknown-hermit", dist=False), + Target("riscv64gc-unknown-linux-musl", dist=False), + Target("riscv64gc-unknown-none-elf", dist=False), + Target("riscv64imac-unknown-none-elf", dist=False), + Target("riscv64-wrs-vxworks", dist=False), + Target("s390x-unknown-linux-musl", dist=False), + Target("sparc-unknown-linux-gnu", dist=False), + Target("sparc64-unknown-netbsd", dist=False), + Target("thumbv6m-none-eabi", dist=False), + Target("thumbv7em-none-eabi", dist=False), + Target("thumbv7em-none-eabihf", dist=False), + Target("thumbv7m-none-eabi", dist=False), + Target("thumbv7neon-linux-androideabi", dist=False), + Target("thumbv7neon-unknown-linux-gnueabihf", dist=False), + Target("thumbv8m.main-none-eabi", dist=False), + Target("x86_64-pc-windows-msvc", dist=False), + Target("x86_64-unknown-dragonfly", dist=False), + Target("x86_64-unknown-haiku", dist=False), + Target("x86_64-unknown-hermit", dist=False), + Target("x86_64-unknown-l4re-uclibc", dist=False), + Target("x86_64-unknown-openbsd", dist=False), + Target("x86_64-wrs-vxworks", dist=False), + # apple nodist + Target("armv7s-apple-ios", dist=False), + Target("i686-apple-darwin", dist=False), + Target("i386-apple-ios", dist=False), +] + + +def eprint(*args, **kw): + print(*args, file=sys.stderr, **kw) + + +def xtrace(args: list[str], /, env: Optional[dict[str, str]]): + """Print commands before running them.""" + astr = " ".join(args) + if env is None: + eprint(f"+ {astr}") + else: + envdiff = set(env.items()) - set(os.environ.items()) + estr = " ".join(f"{k}='{v}'" for (k, v) in envdiff) + eprint(f"+ {estr} {astr}") + + +def check_output(args: list[str], /, env: Optional[dict[str, str]] = None) -> str: + xtrace(args, env=env) + return sp.check_output(args, env=env, encoding="utf8") + + +def run(args: list[str], /, env: Optional[dict[str, str]] = None): + xtrace(args, env=env) + sp.run(args, env=env, check=True) + + +def test_target(cfg: Cfg, target: Target): + env = os.environ.copy() + env.setdefault("RUSTFLAGS", "") + + tname = target.name + target_cfg = check_output(["rustc", "--print=cfg", "--target", tname]) + target_env = re.findall(r'target_env="(.*)"', target_cfg) + target_os = re.findall(r'target_os="(.*)"', target_cfg) + target_bits = re.findall(r'target_pointer_width="(.*)"', target_cfg)[0] + assert target_bits in ["32", "64"] + eprint(f"env {target_env}, os {target_os}, bits {target_bits}") + + cmd = ["cargo", f"+{cfg.toolchain_name}", "build", "--target", tname] + + if not target.dist: + # If we can't download a `core`, we need to build it + cmd += ["-Zbuild-std=core"] + # FIXME: With `build-std` feature, `compiler_builtins` emits a lot of lint warnings. + env["RUSTFLAGS"] += " -Aimproper_ctypes_definitions" + else: + run(["rustup", "target", "add", tname, "--toolchain", cfg.toolchain_name]) + + # Test with expected combinations of features + run(cmd, env=env) + run(cmd + ["--features=extra_traits"], env=env) + + # Check with different env for 64-bit time_t + if target_os == "linux" and target_bits == "32": + # Equivalent of __USE_TIME_BITS64 + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64": "1"}) + + if "gnu" in target_env and target_bits == "32": + # Equivalent of _FILE_OFFSET_BITS=64 + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS": "64"}) + # Equivalent of _TIME_BITS=64 + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_TIME_BITS": "64"}) + + # Test again without default features, i.e. without `std` + run(cmd + ["--no-default-features"]) + run(cmd + ["--no-default-features", "--features=extra_traits"]) + + # Ensure the crate will build when used as a dependency of `std` + if cfg.nightly(): + run(cmd + ["--no-default-features", "--features=rustc-dep-of-std"]) + + # For freebsd targets, check with the different versions we support + # if on nightly or stable + if "freebsd" in tname and cfg.toolchain >= Toolchain.STABLE: + for version in FREEBSD_VERSIONS: + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_FREEBSD_VERSION": str(version)}) + run( + cmd + ["--no-default-features"], + env=env | {"RUST_LIBC_UNSTABLE_FREEBSD_VERSION": str(version)}, + ) + + is_stable = cfg.toolchain == Toolchain.STABLE + # FIXME(semver): can't pass `--target` to `cargo-semver-checks` so we restrict to + # the host target + is_host = tname == cfg.host_target + if is_stable and is_host: + eprint("Running semver checks") + run( + [ + "cargo", + "semver-checks", + "--only-explicit-features", + "--features=std,extra_traits", + ] + ) + else: + eprint("Skipping semver checks") + + eprint(f"Finished checking target {tname}") + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("--toolchain", required=True, help="Rust toolchain") + p.add_argument("--only", help="only targets matching this regex") + p.add_argument("--skip", help="skip targets matching this regex") + args = p.parse_args() + + cfg = Cfg(toolchain_name=args.toolchain) + eprint(f"Config: {cfg}") + eprint("Python version: ", sys.version) + + if cfg.nightly(): + # Needed for build-std + run(["rustup", "component", "add", "rust-src"]) + + targets = TARGETS + eprint(f"Total checked targets across platforms: {len(targets)}") + + if not cfg.nightly(): + # Non-dist targets need nightly for build-std + targets = [t for t in targets if t.dist] + + # Filter to targets supported on the current toolchain + targets = [t for t in targets if cfg.toolchain >= t.min_toolchain] + eprint(f"Targets checkable with this toolchain: {len(targets)}") + + # Targets get split among the diferent CI runners + targets = [t for t in targets if t.run_on() == cfg.os_] + eprint(f"Targets checked on this OS: {len(targets)}") + + # Apply filtering + if args.only: + targets = [t for t in targets if re.match(args.only, t.name)] + if args.skip: + targets = [t for t in targets if not re.match(args.skip, t.name)] + + total = len(targets) + eprint(f"Targets to run: {total}") + assert total > 0, "some tests should be run" + + for i, target in enumerate(targets): + # HACK: We need to install the toolchain by name for most Windows toolchains, + # but not when cross compiling. + if cfg.os_ == Os.WINDOWS and "aarch64" not in target.name: + run( + ["sh", "./ci/install-rust.sh"], env=os.environ | {"TARGET": target.name} + ) + + eprint(f"::group::Target: {target.name} ({i}/{total})") + eprint(f"{ESC_CYAN}Checking target {target} ({i}/{total}){ESC_END}") + test_target(cfg, target) + eprint("::endgroup::") + + +main() diff --git a/ci/verify-build.sh b/ci/verify-build.sh deleted file mode 100755 index e833de2e04c5b..0000000000000 --- a/ci/verify-build.sh +++ /dev/null @@ -1,344 +0,0 @@ -#!/usr/bin/env sh - -# Checks that libc builds properly for all supported targets on a particular -# Rust version: -# The FILTER environment variable can be used to select which target(s) to build. -# For example: set FILTER to vxworks to select the targets that has vxworks in name - -set -eux - -: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}" - -rust="$TOOLCHAIN" -filter="${FILTER:-}" -host_target=$(rustc -vV | awk '/^host/ { print $2 }') - -case "$(uname -s)" in - Linux*) os=linux ;; - Darwin*) os=macos ;; - MINGW*) os=windows ;; - *) - echo "Unknown system $(uname -s)" - exit 1 - ;; -esac - -echo "Testing Rust $rust on $os" - -if [ "$TOOLCHAIN" = "nightly" ]; then - # For build-std - rustup component add rust-src -fi - -# Print GHA workflow commands -echo_if_ci() { - # Discard stderr so the "set -x" trace doesn't show up - { [ -n "${CI:-}" ] && echo "$1"; } 2> /dev/null -} - -# Run the tests for a specific target -test_target() { - target="$1" - no_dist="$2" - - RUSTFLAGS="${RUSTFLAGS:-}" - - # The basic command that is run each time - cmd="cargo +$rust build --target $target" - - if [ "${no_dist}" != "0" ]; then - # If we can't download a `core`, we need to build it - cmd="$cmd -Zbuild-std=core" - - # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. - RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" - export RUSTFLAGS - else - # Otherwise it is available for download; fetch it: - - # FIXME: rustup often fails to download some artifacts due to network - # issues, so we retry this N times. - N=5 - n=0 - until [ $n -ge $N ]; do - if rustup target add "$target" --toolchain "$rust"; then - break - fi - n=$((n + 1)) - sleep 1 - done - fi - - # Test with expected combinations of features - $cmd - $cmd --features extra_traits - - if [ "$os" = "linux" ]; then - # Test with the equivalent of __USE_TIME_BITS64 - RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd - case "$target" in - arm*-gnu* | i*86*-gnu | powerpc-*-gnu* | mips*-gnu | sparc-*-gnu | thumb-*gnu*) - # Test with the equivalent of _FILE_OFFSET_BITS=64 - RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd - # Test with the equivalent of _TIME_BITS=64 - RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd - ;; - esac - fi - - # Test again without default features, i.e. without "std" - $cmd --no-default-features - $cmd --no-default-features --features extra_traits - - # Ensure the crate will build when used with `std` - if [ "$rust" = "nightly" ]; then - $cmd --no-default-features --features rustc-dep-of-std - fi - - # For tier 2 freebsd targets, check with the different versions we support - # if on nightly or stable - case "$rust-$target" in - stable-x86_64-*freebsd*) do_freebsd_checks=1 ;; - nightly-i686*freebsd*) do_freebsd_checks=1 ;; - esac - - if [ -n "${do_freebsd_checks:-}" ]; then - for version in $freebsd_versions; do - export RUST_LIBC_UNSTABLE_FREEBSD_VERSION="$version" - $cmd - $cmd --no-default-features - done - fi - - # FIXME(semver): can't pass `--target` to `cargo-semver-checks` - if [ "$rust" = "stable" ] && [ "$target" = "$host_target" ]; then - # Run semver checks on the stable channel - cargo semver-checks --only-explicit-features \ - --features std,extra_traits - fi -} - -freebsd_versions="\ -11 \ -12 \ -13 \ -14 \ -15 \ -" - -rust_linux_targets="\ -aarch64-linux-android \ -aarch64-unknown-linux-gnu \ -aarch64-unknown-linux-musl \ -arm-linux-androideabi \ -arm-unknown-linux-gnueabi \ -arm-unknown-linux-gnueabihf \ -arm-unknown-linux-musleabi \ -arm-unknown-linux-musleabihf \ -armv7-linux-androideabi \ -armv7-unknown-linux-gnueabihf \ -armv7-unknown-linux-musleabihf \ -i586-unknown-linux-gnu \ -i586-unknown-linux-musl \ -i686-linux-android \ -i686-unknown-freebsd \ -i686-unknown-linux-gnu \ -i686-unknown-linux-musl \ -powerpc-unknown-linux-gnu \ -powerpc64-unknown-linux-gnu \ -powerpc64le-unknown-linux-gnu \ -s390x-unknown-linux-gnu \ -sparc64-unknown-linux-gnu \ -sparcv9-sun-solaris \ -wasm32-unknown-emscripten \ -wasm32-unknown-unknown \ -wasm32-wasip1 \ -wasm32-wasip2 \ -x86_64-linux-android \ -x86_64-unknown-freebsd \ -x86_64-unknown-linux-gnu \ -x86_64-unknown-linux-musl \ -x86_64-unknown-netbsd \ -" - -# FIXME(powerpc64le): powerpc64le-unknown-linux-musl is tier 2 since 1.85 and -# can be moved to rust_linux_targets once MSRV is increased -rust_nightly_linux_targets="\ -aarch64-unknown-fuchsia \ -armv5te-unknown-linux-gnueabi \ -armv5te-unknown-linux-musleabi \ -i686-pc-windows-gnu \ -powerpc64le-unknown-linux-musl \ -riscv64gc-unknown-linux-gnu \ -x86_64-fortanix-unknown-sgx \ -x86_64-pc-solaris \ -x86_64-pc-windows-gnu \ -x86_64-unknown-fuchsia \ -x86_64-unknown-illumos \ -x86_64-unknown-linux-gnux32 \ -x86_64-unknown-redox \ -" - -rust_apple_targets="\ -aarch64-apple-darwin \ -aarch64-apple-ios \ -x86_64-apple-darwin \ -x86_64-apple-ios \ -" - -rust_nightly_apple_targets="\ -" - -# Must start with `x86_64-pc-windows-msvc` first. -rust_nightly_windows_targets="\ -x86_64-pc-windows-msvc \ -x86_64-pc-windows-gnu \ -i686-pc-windows-msvc \ -" - -# Targets which are not available via rustup and must be built with -Zbuild-std -# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has -# duplicate symbol errors from `compiler_builtins`. -rust_linux_no_dist_targets="\ -aarch64-pc-windows-msvc \ -aarch64-unknown-freebsd \ -aarch64-unknown-hermit \ -aarch64-unknown-netbsd \ -aarch64-unknown-openbsd \ -aarch64-wrs-vxworks \ -armebv7r-none-eabi \ -armebv7r-none-eabihf \ -armv7-wrs-vxworks-eabihf \ -armv7r-none-eabi \ -armv7r-none-eabihf \ -i686-pc-windows-msvc \ -i686-unknown-haiku \ -i686-unknown-netbsd \ -i686-unknown-openbsd \ -i686-wrs-vxworks \ -mips-unknown-linux-gnu \ -mips-unknown-linux-musl \ -mips64-unknown-linux-gnuabi64 \ -mips64-unknown-linux-muslabi64 \ -mips64el-unknown-linux-gnuabi64 \ -mips64el-unknown-linux-muslabi64 \ -mipsel-unknown-linux-gnu \ -mipsel-unknown-linux-musl \ -mipsel-sony-psp \ -nvptx64-nvidia-cuda \ -powerpc-unknown-linux-gnuspe \ -powerpc-unknown-netbsd \ -powerpc-wrs-vxworks \ -powerpc-wrs-vxworks-spe \ -powerpc64-unknown-freebsd \ -powerpc64-wrs-vxworks \ -riscv32i-unknown-none-elf \ -riscv32imac-unknown-none-elf \ -riscv32imc-unknown-none-elf \ -riscv32gc-unknown-linux-gnu \ -riscv32-wrs-vxworks \ -riscv64gc-unknown-freebsd \ -riscv64gc-unknown-hermit \ -riscv64gc-unknown-linux-musl \ -riscv64gc-unknown-none-elf \ -riscv64imac-unknown-none-elf \ -riscv64-wrs-vxworks \ -s390x-unknown-linux-musl \ -sparc-unknown-linux-gnu \ -sparc64-unknown-netbsd \ - -thumbv6m-none-eabi \ -thumbv7em-none-eabi \ -thumbv7em-none-eabihf \ -thumbv7m-none-eabi \ -thumbv7neon-linux-androideabi \ -thumbv7neon-unknown-linux-gnueabihf \ -thumbv8m.main-none-eabi \ -x86_64-pc-windows-msvc \ -x86_64-unknown-dragonfly \ -x86_64-unknown-haiku \ -x86_64-unknown-hermit \ -x86_64-unknown-l4re-uclibc \ -x86_64-unknown-openbsd \ -x86_64-wrs-vxworks \ -" - -rust_apple_no_dist_targets="\ -armv7s-apple-ios \ -i686-apple-darwin \ -i386-apple-ios \ -" - -# The targets are listed here alphabetically -if [ "$os" = "linux" ]; then - targets="$rust_linux_targets" - nightly_targets="$rust_nightly_linux_targets" - no_dist_targets="$rust_linux_no_dist_targets" -elif [ "$os" = "macos" ]; then - targets="$rust_apple_targets" - nightly_targets="$rust_nightly_apple_targets" - no_dist_targets="$rust_apple_no_dist_targets" -elif [ "$os" = "windows" ]; then - targets=${rust_nightly_windows_targets} -else - exit 1 -fi - -if [ "$rust" = "nightly" ]; then - targets="$targets ${nightly_targets:-}" -else - # build-std requires nightly - no_dist_targets="" -fi - -case "$rust" in - "stable") supports_wasi_pn=1 ;; - "beta") supports_wasi_pn=1 ;; - "nightly") supports_wasi_pn=1 ;; - *) supports_wasi_pn=0 ;; -esac - -some_tests_run=0 - -# Apply the `FILTER` variable, do OS-specific tasks, and run a target -filter_and_run() { - target="$1" - no_dist="${2:-0}" - - if echo "$target" | grep -q "$filter"; then - if [ "$os" = "windows" ]; then - TARGET="$target" ./ci/install-rust.sh - fi - - # `wasm32-wasip1` was renamed from `wasm32-wasi` - if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then - target="wasm32-wasi" - fi - - # `wasm32-wasip2` only exists in recent versions of Rust - if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then - return - fi - - test_target "$target" "$no_dist" - some_tests_run=1 - fi -} - -for target in $targets; do - echo_if_ci "::group::Target: $target" - filter_and_run "$target" - echo_if_ci "::endgroup::" -done - -for target in ${no_dist_targets:-}; do - echo_if_ci "::group::Target: $target" - filter_and_run "$target" 1 - echo_if_ci "::endgroup::" -done - -# Make sure we didn't accidentally filter everything -if [ "$some_tests_run" != 1 ]; then - echo "No tests were run" - exit 1 -fi From 5df6fdf907c0745c997ea8b174203a72da8c3c7a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 03:50:03 -0400 Subject: [PATCH 11/37] ci: Update targets in verify-build Do a few things: * Update the list to reflect current target tiers. * Add some missing T2 targets (includes ohos and gnullvm). * Remove unneeded `dist = False` and minimum toolchain config. * Delete some `-none-` targets, which don't make use of libc. * Add a check for duplicates. * Re-group and sort the lists. (backport ) (cherry picked from commit 24d00496c7a8ef2087a8065ca739952eb6857ba1) --- ci/verify-build.py | 127 +++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 56 deletions(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index 09d185658f7ed..a5f14a0df363b 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -77,81 +77,90 @@ def run_on(self) -> Os: FREEBSD_VERSIONS = [11, 12, 13, 14, 15] +# FIXME(ohos): CI fails with warnings TARGETS = [ - # linux - Target("aarch64-linux-android"), + # Tier 1 + Target("aarch64-apple-darwin"), + Target("aarch64-pc-windows-msvc"), Target("aarch64-unknown-linux-gnu"), + Target("i686-pc-windows-msvc"), + Target("i686-unknown-linux-gnu"), + Target("x86_64-pc-windows-gnu"), + Target("x86_64-pc-windows-msvc"), + Target("x86_64-unknown-linux-gnu"), + # + # Tier 2 with host tools + Target("aarch64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), Target("aarch64-unknown-linux-musl"), - Target("arm-linux-androideabi"), + # Target("aarch64-unknown-linux-ohos"), Target("arm-unknown-linux-gnueabi"), Target("arm-unknown-linux-gnueabihf"), + Target("armv7-unknown-linux-gnueabihf"), + # Target("armv7-unknown-linux-ohos"), + Target("i686-pc-windows-gnu"), + Target("loongarch64-unknown-linux-gnu", min_toolchain=Toolchain.STABLE), + Target("loongarch64-unknown-linux-musl", min_toolchain=Toolchain.STABLE), + Target("powerpc-unknown-linux-gnu"), + Target("powerpc64-unknown-linux-gnu"), + Target("powerpc64le-unknown-linux-gnu"), + Target("powerpc64le-unknown-linux-musl", min_toolchain=Toolchain.STABLE), + Target("riscv64gc-unknown-linux-gnu"), + Target("s390x-unknown-linux-gnu"), + Target("sparcv9-sun-solaris"), + Target("x86_64-apple-darwin"), + Target("x86_64-pc-solaris"), + Target("x86_64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), + Target("x86_64-unknown-freebsd"), + Target("x86_64-unknown-illumos"), + Target("x86_64-unknown-linux-musl"), + # Target("x86_64-unknown-linux-ohos"), + Target("x86_64-unknown-netbsd"), + # + # Tier 2 without host tools + Target("aarch64-apple-ios"), + Target("aarch64-linux-android"), + Target("aarch64-unknown-fuchsia", min_toolchain=Toolchain.STABLE), + Target("arm-linux-androideabi"), Target("arm-unknown-linux-musleabi"), Target("arm-unknown-linux-musleabihf"), + Target("armv5te-unknown-linux-gnueabi"), + Target("armv5te-unknown-linux-musleabi"), Target("armv7-linux-androideabi"), - Target("armv7-unknown-linux-gnueabihf"), Target("armv7-unknown-linux-musleabihf"), Target("i586-unknown-linux-gnu"), Target("i586-unknown-linux-musl"), Target("i686-linux-android"), Target("i686-unknown-freebsd"), - Target("i686-unknown-linux-gnu"), Target("i686-unknown-linux-musl"), - Target("powerpc-unknown-linux-gnu"), - Target("powerpc64-unknown-linux-gnu"), - Target("powerpc64le-unknown-linux-gnu"), - Target("s390x-unknown-linux-gnu"), Target("sparc64-unknown-linux-gnu"), - Target("sparcv9-sun-solaris"), Target("wasm32-unknown-emscripten"), Target("wasm32-unknown-unknown"), - # Target was renamed Target("wasm32-wasip1", min_toolchain=Toolchain.STABLE), Target("wasm32-wasip2", min_toolchain=Toolchain.STABLE), + Target("x86_64-fortanix-unknown-sgx"), Target("x86_64-linux-android"), - Target("x86_64-unknown-freebsd"), - Target("x86_64-unknown-linux-gnu"), - Target("x86_64-unknown-linux-musl"), - Target("x86_64-unknown-netbsd"), - # nightly linux - # FIXME(powerpc64le): powerpc64le-unknown-linux-musl is tier 2 since 1.85 and - # can be moved to rust_linux_targets once MSRV is increased - Target("aarch64-unknown-fuchsia", min_toolchain=Toolchain.NIGHTLY), - Target("armv5te-unknown-linux-gnueabi", min_toolchain=Toolchain.NIGHTLY), - Target("armv5te-unknown-linux-musleabi", min_toolchain=Toolchain.NIGHTLY), - Target("i686-pc-windows-gnu", min_toolchain=Toolchain.NIGHTLY), - Target("powerpc64le-unknown-linux-musl", min_toolchain=Toolchain.NIGHTLY), - Target("riscv64gc-unknown-linux-gnu", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-fortanix-unknown-sgx", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-pc-solaris", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-pc-windows-gnu", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-unknown-fuchsia", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-unknown-illumos", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-unknown-linux-gnux32", min_toolchain=Toolchain.NIGHTLY), - Target("x86_64-unknown-redox", min_toolchain=Toolchain.NIGHTLY), - # apple - Target("aarch64-apple-darwin"), - Target("aarch64-apple-ios"), - # windows - Target("x86_64-pc-windows-msvc"), - Target("x86_64-pc-windows-gnu"), - Target("i686-pc-windows-msvc"), - # linux nodist - # Targets which are not available via rustup and must be built with -Zbuild-std - # FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has - # duplicate symbol errors from `compiler_builtins`. - Target("aarch64-pc-windows-msvc", dist=False), + Target("x86_64-unknown-fuchsia", min_toolchain=Toolchain.STABLE), + Target("x86_64-unknown-linux-gnux32"), + Target("x86_64-unknown-redox"), + # + # Libc has historically checked that a number of tier 3 targets build. Technically + # there is no need to do this given the target tier policy, but the cost is small + # and the saved churn from accidental breakage is significant, so we keep it around. Target("aarch64-unknown-freebsd", dist=False), Target("aarch64-unknown-hermit", dist=False), + Target("aarch64-unknown-illumos", dist=False), Target("aarch64-unknown-netbsd", dist=False), Target("aarch64-unknown-openbsd", dist=False), Target("aarch64-wrs-vxworks", dist=False), - Target("armebv7r-none-eabi", dist=False), Target("armebv7r-none-eabihf", dist=False), Target("armv7-wrs-vxworks-eabihf", dist=False), - Target("armv7r-none-eabi", dist=False), Target("armv7r-none-eabihf", dist=False), - Target("i686-pc-windows-msvc", dist=False), + Target("armv7s-apple-ios", dist=False), + 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), + Target("i686-unknown-hurd-gnu", dist=False), Target("i686-unknown-netbsd", dist=False), Target("i686-unknown-openbsd", dist=False), Target("i686-wrs-vxworks", dist=False), @@ -168,40 +177,35 @@ def run_on(self) -> Os: Target("powerpc-unknown-netbsd", dist=False), Target("powerpc-wrs-vxworks", dist=False), Target("powerpc-wrs-vxworks-spe", dist=False), + Target("powerpc64-ibm-aix", dist=False), Target("powerpc64-unknown-freebsd", dist=False), Target("powerpc64-wrs-vxworks", dist=False), + Target("riscv32-wrs-vxworks", dist=False), + Target("riscv32gc-unknown-linux-gnu", dist=False), Target("riscv32i-unknown-none-elf", dist=False), Target("riscv32imac-unknown-none-elf", dist=False), Target("riscv32imc-unknown-none-elf", dist=False), - Target("riscv32gc-unknown-linux-gnu", dist=False), - Target("riscv32-wrs-vxworks", dist=False), + Target("riscv64-wrs-vxworks", dist=False), + Target("riscv64a23-unknown-linux-gnu", dist=False), Target("riscv64gc-unknown-freebsd", dist=False), Target("riscv64gc-unknown-hermit", dist=False), Target("riscv64gc-unknown-linux-musl", dist=False), Target("riscv64gc-unknown-none-elf", dist=False), Target("riscv64imac-unknown-none-elf", dist=False), - Target("riscv64-wrs-vxworks", dist=False), Target("s390x-unknown-linux-musl", dist=False), Target("sparc-unknown-linux-gnu", dist=False), Target("sparc64-unknown-netbsd", dist=False), - Target("thumbv6m-none-eabi", dist=False), - Target("thumbv7em-none-eabi", dist=False), Target("thumbv7em-none-eabihf", dist=False), Target("thumbv7m-none-eabi", dist=False), Target("thumbv7neon-linux-androideabi", dist=False), Target("thumbv7neon-unknown-linux-gnueabihf", dist=False), Target("thumbv8m.main-none-eabi", dist=False), - Target("x86_64-pc-windows-msvc", dist=False), Target("x86_64-unknown-dragonfly", dist=False), Target("x86_64-unknown-haiku", dist=False), Target("x86_64-unknown-hermit", dist=False), Target("x86_64-unknown-l4re-uclibc", dist=False), Target("x86_64-unknown-openbsd", dist=False), Target("x86_64-wrs-vxworks", dist=False), - # apple nodist - Target("armv7s-apple-ios", dist=False), - Target("i686-apple-darwin", dist=False), - Target("i386-apple-ios", dist=False), ] @@ -230,6 +234,16 @@ def run(args: list[str], /, env: Optional[dict[str, str]] = None): sp.run(args, env=env, check=True) +def check_dup_targets(): + all = set() + duplicates = set() + for target in TARGETS: + if target.name in all: + duplicates.add(target.name) + all.add(target.name) + assert len(duplicates) == 0, f"duplicate targets: {duplicates}" + + def test_target(cfg: Cfg, target: Target): env = os.environ.copy() env.setdefault("RUSTFLAGS", "") @@ -315,6 +329,7 @@ def main(): cfg = Cfg(toolchain_name=args.toolchain) eprint(f"Config: {cfg}") eprint("Python version: ", sys.version) + check_dup_targets() if cfg.nightly(): # Needed for build-std From 5cff45f93553b45eeb6ab57da8fd5c83cd04c7b6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 04:09:25 -0400 Subject: [PATCH 12/37] ci: Always run verify-build on Linux Most of the targets are cross compiled anyway, and there isn't any advantage to running on native platforms. Start running everything on Linux which is the fastest and cheapest runner. As part of this, introduce a way to run only half of the target list from a single invocation. This is used to split the nightly job in two, each now only taking about as long as the stable job. (backport ) (cherry picked from commit 56b916db7e237d9259b697741550abcab9a0db29) --- .github/workflows/ci.yaml | 19 ++++++++++++++----- ci/verify-build.py | 38 +++++++++++++++----------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9857aeb8bec2c..62b7c5e56e56e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,12 +51,18 @@ jobs: name: Verify build strategy: matrix: - toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-24.04, macos-15, windows-2025] + toolchain: [stable, 1.63.0] include: + # Nightly has a lot of targets, so split it in half + - toolchain: nightly + half: 1 + - toolchain: nightly + half: 2 - toolchain: beta - os: ubuntu-24.04 - runs-on: ${{ matrix.os }} + only: '(aarch64|x86_64)' # just a spot check for beta + - toolchain: stable + - toolchain: 1.63.0 # msrv + runs-on: ubuntu-24.04 timeout-minutes: 25 env: TOOLCHAIN: ${{ matrix.toolchain }} @@ -83,7 +89,10 @@ jobs: set -eux # Remove `-Dwarnings` at the MSRV since lints may be different [ "${{ matrix.toolchain }}" = "1.63.0" ] && export RUSTFLAGS="" - python3 ci/verify-build.py --toolchain "$TOOLCHAIN" + python3 ci/verify-build.py \ + --toolchain "$TOOLCHAIN" \ + ${{ matrix.only && format('--only "{0}"', matrix.only) }} \ + ${{ matrix.half && format('--half "{0}"', matrix.half) }} - name: Target size after job completion run: du -sh target | sort -k 2 diff --git a/ci/verify-build.py b/ci/verify-build.py index a5f14a0df363b..f27fde35e50c6 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -64,16 +64,6 @@ def __post_init__(self): # We will need to use build-std self.min_toolchain = Toolchain.NIGHTLY - def run_on(self) -> Os: - """MacOS CI runs all apple targets, Windows CI runs all Windows targets, - Linux CI handles everything else.""" - - if "apple" in self.name: - return Os.DARWIN - elif "windows" in self.name: - return Os.WINDOWS - return Os.LINUX - FREEBSD_VERSIONS = [11, 12, 13, 14, 15] @@ -324,6 +314,12 @@ def main(): p.add_argument("--toolchain", required=True, help="Rust toolchain") p.add_argument("--only", help="only targets matching this regex") p.add_argument("--skip", help="skip targets matching this regex") + p.add_argument( + "--half", + type=int, + choices=[1, 2], + help="specify 1 or 2 to run half of the targets", + ) args = p.parse_args() cfg = Cfg(toolchain_name=args.toolchain) @@ -346,30 +342,26 @@ def main(): targets = [t for t in targets if cfg.toolchain >= t.min_toolchain] eprint(f"Targets checkable with this toolchain: {len(targets)}") - # Targets get split among the diferent CI runners - targets = [t for t in targets if t.run_on() == cfg.os_] - eprint(f"Targets checked on this OS: {len(targets)}") - # Apply filtering if args.only: targets = [t for t in targets if re.match(args.only, t.name)] if args.skip: targets = [t for t in targets if not re.match(args.skip, t.name)] + # Allow splitting the targets in half for time improvements + if args.half == 1: + targets = targets[0::2] + elif args.half == 2: + targets = targets[1::2] + total = len(targets) eprint(f"Targets to run: {total}") assert total > 0, "some tests should be run" for i, target in enumerate(targets): - # HACK: We need to install the toolchain by name for most Windows toolchains, - # but not when cross compiling. - if cfg.os_ == Os.WINDOWS and "aarch64" not in target.name: - run( - ["sh", "./ci/install-rust.sh"], env=os.environ | {"TARGET": target.name} - ) - - eprint(f"::group::Target: {target.name} ({i}/{total})") - eprint(f"{ESC_CYAN}Checking target {target} ({i}/{total}){ESC_END}") + at = i + 1 + eprint(f"::group::Target: {target.name} ({at}/{total})") + eprint(f"{ESC_CYAN}Checking target {target} ({at}/{total}){ESC_END}") test_target(cfg, target) eprint("::endgroup::") From 6c3d7d24801774a62452e01edd70f7485e3cd3d1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 04:46:55 -0400 Subject: [PATCH 13/37] ci: Print elapsed time as part of verify-build (backport ) (cherry picked from commit 5e95452b38e4051d458fe3639d64a8ca64fe5cc3) --- ci/verify-build.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index f27fde35e50c6..9c7e272bc8c94 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 -import re -import os import argparse +import os +import platform +import re import subprocess as sp import sys -import platform -from typing import Optional -from enum import Enum, IntEnum +import time from dataclasses import dataclass, field +from enum import Enum, IntEnum +from typing import Optional ESC_CYAN = "\033[1;36m" @@ -235,6 +236,7 @@ def check_dup_targets(): def test_target(cfg: Cfg, target: Target): + start = time.time() env = os.environ.copy() env.setdefault("RUSTFLAGS", "") @@ -306,7 +308,8 @@ def test_target(cfg: Cfg, target: Target): else: eprint("Skipping semver checks") - eprint(f"Finished checking target {tname}") + elapsed = round(time.time() - start, 2) + eprint(f"Finished checking target {tname} in {elapsed} seconds") def main(): @@ -326,6 +329,7 @@ def main(): eprint(f"Config: {cfg}") eprint("Python version: ", sys.version) check_dup_targets() + start = time.time() if cfg.nightly(): # Needed for build-std @@ -365,5 +369,8 @@ def main(): test_target(cfg, target) eprint("::endgroup::") + elapsed = round(time.time() - start, 2) + eprint(f"Checked {total} targets in {elapsed} seconds") + main() From 4b11b927d6be04b98c8737864c034e95bb4b3080 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 04:54:02 -0400 Subject: [PATCH 14/37] ci: Launch create-artifacts.py with python We have occasional CI failures on Windows where the environment variables don't get set so the artifact upload fails. Looking at the logs, it doesn't even appear the create-artifact job ran (but there are no errors). The Windows runners sometimes have trouble launching python scripts via `./`, so switch to using the python3 executable in hopes that this helps. (backport ) (cherry picked from commit 962b985cfd3101715742c24f36f4c0cef4613dee) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62b7c5e56e56e..6e8253afd5bd8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -154,7 +154,7 @@ jobs: - name: Create CI artifacts id: create_artifacts if: always() - run: ./ci/create-artifacts.py + run: python3 ci/create-artifacts.py - uses: actions/upload-artifact@v4 if: always() && steps.create_artifacts.outcome == 'success' with: From bfaae4f3d613bdf4eed73d9d43c37420346437d0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 04:59:58 -0400 Subject: [PATCH 15/37] aix: Resolve function comparison and `unnecessary_transmutes` warnings (backport ) (cherry picked from commit c81917388181e50c58c285b24488e7cef70fc897) --- src/unix/aix/mod.rs | 2 ++ src/unix/aix/powerpc64.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b699a3c8001c8..8fe62e4e540c3 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -326,6 +326,8 @@ s! { pub cmsg_type: c_int, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigevent { pub sigev_value: crate::sigval, pub sigev_signo: c_int, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 1b62859ae1633..f3a4419efb38f 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -448,7 +448,7 @@ cfg_if! { impl hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { - let d: u64 = unsafe { mem::transmute(self.d) }; + let d: u64 = self.d.to_bits(); d.hash(state); } } From d16571a7e7f23256ddcc8171d42fe2099db13e91 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 05:31:30 -0400 Subject: [PATCH 16/37] ci: For no-dist targets, do a check rather than a full build (backport ) (cherry picked from commit a53f4bc2964bbb1b594c628627cb9396ee48ba69) --- ci/verify-build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index 9c7e272bc8c94..c5eb22dbd770f 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -248,7 +248,15 @@ def test_target(cfg: Cfg, target: Target): assert target_bits in ["32", "64"] eprint(f"env {target_env}, os {target_os}, bits {target_bits}") - cmd = ["cargo", f"+{cfg.toolchain_name}", "build", "--target", tname] + # Usually we do a full build to make sure we don't run into any crashes or link + # problems. If we need to use build-std, though, only do a check to speed + # things up. + if target.dist: + action = "build" + else: + action = "check" + + cmd = ["cargo", f"+{cfg.toolchain_name}", action, "--target", tname] if not target.dist: # If we can't download a `core`, we need to build it From 5e1a49673df7b6f617926195ef99db4ab0263d32 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 02:56:31 -0400 Subject: [PATCH 17/37] macros: Allow `s!` and `s_no_extra_traits!` to take private items Occasionally we need to define structs that keep the expected set of traits but aren't crate-public. Add support to the macros to do this. (backport ) (cherry picked from commit cdcc46679ade1254d310b9db46224befefb9fe46) --- src/macros.rs | 60 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index a5359db0f62c5..14ec3b53402f2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -142,16 +142,16 @@ macro_rules! prelude { macro_rules! s { ($( $(#[$attr:meta])* - pub $t:ident $i:ident { $($field:tt)* } + $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s!(it: $(#[$attr])* pub $t $i { $($field)* }); + s!(it: $(#[$attr])* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead"); ); - (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] #[cfg_attr( @@ -165,7 +165,7 @@ macro_rules! s { )] #[allow(deprecated)] $(#[$attr])* - pub struct $i { $($field)* } + $pub struct $i { $($field)* } } ); } @@ -202,17 +202,17 @@ macro_rules! s_paren { macro_rules! s_no_extra_traits { ($( $(#[$attr:meta])* - pub $t:ident $i:ident { $($field:tt)* } + $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); + s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] $(#[$attr])* - pub union $i { $($field)* } + $pub union $i { $($field)* } } impl ::core::fmt::Debug for $i { @@ -222,7 +222,7 @@ macro_rules! s_no_extra_traits { } ); - (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( + (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] #[::core::prelude::v1::derive( @@ -231,7 +231,7 @@ macro_rules! s_no_extra_traits { ::core::fmt::Debug, )] $(#[$attr])* - pub struct $i { $($field)* } + $pub struct $i { $($field)* } } ); } @@ -529,3 +529,41 @@ mod tests { TypeId::of::() } } + +#[cfg(test)] +#[allow(unused)] +mod macro_checks { + s! { + pub struct S1 { + pub a: u32, + b: u32, + } + + struct S1Priv { + pub a: u32, + b: u32, + } + } + + s_no_extra_traits! { + pub struct S2 { + pub a: u32, + b: u32, + } + + struct S2Priv { + pub a: u32, + b: u32, + } + + pub union U2 { + pub a: u32, + b: f32, + } + + union U2Priv { + pub a: u32, + b: f32, + } + } +} From 681779fe68953f2e9b4acfe4f599de9e8ebfafa5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 05:51:09 -0400 Subject: [PATCH 18/37] ci: Pass the `MUSL_V1_2_3` env in docker This was being set as part of CI but not forwarded to the jobs. Start passing it now. (backport ) (cherry picked from commit ab130bf6df0cd664d474c6ee93a98ae3d7cad66c) --- ci/run-docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/run-docker.sh b/ci/run-docker.sh index db10c3b061ba8..c34bcff6ed786 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -45,6 +45,7 @@ run() { --env LIBC_CI_ZBUILD_STD \ --env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \ --env RUST_LIBC_UNSTABLE_GNU_TIME_BITS \ + --env RUST_LIBC_UNSTABLE_MUSL_V1_2_3 \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --volume "$CARGO_HOME":/cargo \ From 3bd6f96be2179494baa266e230d031d17932f7fe Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 26 Oct 2025 05:51:09 -0400 Subject: [PATCH 19/37] musl: Fix skips with recent versions It appeared that tests with the constants here were passing in CI with new versions of musl before, but that was only because the correct config wasn't being set. Go back to our original configuration (with some cleanup) to resolve this. Fixes: dd44cb603e77 ("test: linux: Unskip types and constants that are now available") (backport ) (cherry picked from commit 075c1184bc803fdfc9ced147eefc318dccb53a90) --- libc-test/build.rs | 125 ++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 54636a7503038..d23b0d6876813 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4084,8 +4084,14 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "mnt_ns_info" => true, - // Struct has changed for new musl versions - "tcp_info" if old_musl => true, + // FIXME(musl): Struct has changed for new musl versions + "tcp_info" if musl => true, + + // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. + "statx" | "statx_timestamp" if musl => true, + + // FIXME(musl): New fields in newer versions + "utmpx" if !old_musl => true, _ => false, } @@ -4139,35 +4145,26 @@ fn test_linux(target: &str) { if name.starts_with("NI_IDN") { return true; } - // FIXME(musl): Not in musl yet - if name == "SO_NETNS_COOKIE" - || name == "SO_BUF_LOCK" - || name == "SO_RESERVE_MEM" - || name == "SO_TXREHASH" - || name == "SO_RCVMARK" - || name == "SO_PASSPIDFD" - || name == "SO_PEERPIDFD" - || name == "SO_DEVMEM_LINEAR" - || name == "SO_DEVMEM_DMABUF" - || name == "SO_DEVMEM_DONTNEED" - { - return true; - } - // FIXME(musl): Not in musl yet - if name == "SCM_DEVMEM_LINEAR" || name == "SCM_DEVMEM_DMABUF" { - return true; - } - // FIXME: Does not exist on non-x86 architectures, slated for removal - // in libc in 1.0 - if ppc64 && name == "MAP_32BIT" { - return true; - } - } - if old_musl { - // Constants that don't exist on the old version of musl we test with, but do exist - // on newer versions. + match name { - "FAN_EVENT_INFO_TYPE_ERROR" + // FIXME: Does not exist on non-x86 architectures, slated for removal + // in libc in 1.0 + "MAP_32BIT" if ppc64 => return true, + + // FIXME(musl): None of these are actually defined in musl, they should be removed. + "SO_NETNS_COOKIE" + | "SO_BUF_LOCK" + | "SO_RESERVE_MEM" + | "SO_TXREHASH" + | "SO_RCVMARK" + | "SO_PASSPIDFD" + | "SO_PEERPIDFD" + | "SO_DEVMEM_LINEAR" + | "SO_DEVMEM_DMABUF" + | "SO_DEVMEM_DONTNEED" + | "SCM_DEVMEM_LINEAR" + | "SCM_DEVMEM_DMABUF" + | "FAN_EVENT_INFO_TYPE_ERROR" | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" | "FAN_FS_ERROR" @@ -4180,21 +4177,39 @@ fn test_linux(target: &str) { | "FAN_REPORT_TARGET_FID" | "FAN_RESPONSE_INFO_AUDIT_RULE" | "FAN_RESPONSE_INFO_NONE" - | "IPPROTO_ETHERNET" - | "IPPROTO_MPTCP" | "PR_GET_MDWE" | "PR_MDWE_NO_INHERIT" | "PR_MDWE_REFUSE_EXEC_GAIN" | "PR_SET_MDWE" - | "RLIM_NLIMITS" + | "IPPROTO_ETHERNET" + | "IPPROTO_MPTCP" | "SI_DETHREAD" - | "SO_BUSY_POLL_BUDGET" - | "SO_PREFER_BUSY_POLL" => return true, - // Values changed in newer musl versions on these arches + | "PR_SET_VMA" + | "PR_SET_VMA_ANON_NAME" + | "PR_SCHED_CORE" + | "PR_SCHED_CORE_CREATE" + | "PR_SCHED_CORE_GET" + | "PR_SCHED_CORE_MAX" + | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" + | "PR_SCHED_CORE_SCOPE_THREAD" + | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" + | "PR_SCHED_CORE_SHARE_FROM" + | "PR_SCHED_CORE_SHARE_TO" => return true, + + /* Added in versions more recent than what we test */ + // Since 1.2.3 + "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" => return true, + + // FIXME(musl): value was updated in new musl + "RLIM_NLIMITS" => return true, + + // FIXME(musl): Values changed in newer musl versions on these arches "O_LARGEFILE" if riscv64 || x86_64 => return true, + _ => (), } } + match name { // These constants are not available if gnu headers have been included // and can therefore not be tested here @@ -4307,23 +4322,6 @@ fn test_linux(target: &str) { // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, - // Not present on old musl - "PR_SET_VMA" - | "PR_SET_VMA_ANON_NAME" - | "PR_SCHED_CORE" - | "PR_SCHED_CORE_CREATE" - | "PR_SCHED_CORE_GET" - | "PR_SCHED_CORE_MAX" - | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD" - | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" - | "PR_SCHED_CORE_SHARE_FROM" - | "PR_SCHED_CORE_SHARE_TO" - if old_musl => - { - true - } - // Not present in glibc "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, @@ -4514,20 +4512,22 @@ fn test_linux(target: &str) { // assume it's a int instead. "getnameinfo" if uclibc => true, - // FIXME(musl): This needs musl 1.2.2 or later. - "gettid" if old_musl => true, + // FIXME(musl): This needs musl 1.2.2 or later, which is newer than what we test with + // on CI. + "gettid" | "reallocarray" if musl => true, + // Needs musl 1.2.3 or later. + "pthread_getname_np" if musl => true, + // Added in musl 1.2.5 + "preadv2" | "pwritev2" if musl => true, + // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. + "statx" if musl => true, // Needs glibc 2.33 or later. "mallinfo2" => true, - "reallocarray" if old_musl => true, - // Not defined in uclibc as of 1.0.34 "gettid" if uclibc => true, - // Needs musl 1.2.3 or later. - "pthread_getname_np" if old_musl => true, - // pthread_sigqueue uses sigval, which was initially declared // as a struct but should be defined as a union. However due // to the issues described here: https://github.com/rust-lang/libc/issues/2816 @@ -4553,9 +4553,6 @@ fn test_linux(target: &str) { // FIXME(linux): function pointers changed since Ubuntu 23.10 "strtol" | "strtoll" | "strtoul" | "strtoull" | "fscanf" | "scanf" | "sscanf" => true, - // Added in musl 1.2.5 - "preadv2" | "pwritev2" if musl => true, - _ => false, } }); @@ -4665,7 +4662,7 @@ fn test_linux(target: &str) { // the `xsk_tx_metadata_union` field is an anonymous union (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || // After musl 1.2.0, the type becomes `int` instead of `long`. - (old_musl && struct_ == "utmpx" && field == "ut_session") || + (musl && struct_ == "utmpx" && field == "ut_session") || // `frames` is a flexible array member (struct_ == "bcm_msg_head" && field == "frames") || // FAM From 4c464c905ad351f759b8a9e8bc5bf1be0e37aa83 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 04:02:48 -0400 Subject: [PATCH 20/37] ci: Also check builds with `musl_v1_2_3` (backport ) (cherry picked from commit 7b9f8fd059a9cc4d64be801aced0019a4b62a119) --- ci/verify-build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/verify-build.py b/ci/verify-build.py index c5eb22dbd770f..2d57bd81bcea9 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -281,6 +281,10 @@ def test_target(cfg: Cfg, target: Target): # Equivalent of _TIME_BITS=64 run(cmd, env=env | {"RUST_LIBC_UNSTABLE_GNU_TIME_BITS": "64"}) + if "musl" in target_env: + # Check with breaking changes from musl, including 64-bit time_t on 32-bit + run(cmd, env=env | {"RUST_LIBC_UNSTABLE_MUSL_V1_2_3": "1"}) + # Test again without default features, i.e. without `std` run(cmd + ["--no-default-features"]) run(cmd + ["--no-default-features", "--features=extra_traits"]) From ad2d7dfcd969310557d0d6117253604a1d894fe4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 20:54:30 -0400 Subject: [PATCH 21/37] ci: Run gnu env tests as part of the main job Since glibc supports both 32- and 64-bit time_t and off_t without different setup (just a header define in libc-test), these don't have any need to be standalone jobs. Switch glibc config variants to be checked as part of `run.sh`, which means we are now covering all 32-bit platforms by default. (backport ) (cherry picked from commit cbf2b8a94129b1ae857a0588de8465e46fd53572) --- .github/workflows/ci.yaml | 18 ------------------ ci/run.sh | 12 ++++++++++++ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6e8253afd5bd8..6bbd53bda9043 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -113,12 +113,6 @@ jobs: - target: i686-pc-windows-msvc os: windows-2025 - target: i686-unknown-linux-gnu - - target: i686-unknown-linux-gnu - artifact-tag: offset-bits64 - env: { RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 } - - target: i686-unknown-linux-gnu - artifact-tag: time-bits64 - env: { RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 } - target: x86_64-pc-windows-gnu os: windows-2025 env: { ARCH_BITS: 64, ARCH: x86_64 } @@ -181,12 +175,6 @@ jobs: artifact-tag: new-musl - target: arm-linux-androideabi - target: arm-unknown-linux-gnueabihf - - target: arm-unknown-linux-gnueabihf - env: { RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 } - artifact-tag: offset-bits64 - - target: arm-unknown-linux-gnueabihf - env: { RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 } - artifact-tag: time-bits64 - target: arm-unknown-linux-musleabihf - target: arm-unknown-linux-musleabihf env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } @@ -228,12 +216,6 @@ jobs: # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu - # - target: powerpc-unknown-linux-gnu - # env: { RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 } - # artifact-tag: offset-bits64 - # - target: powerpc-unknown-linux-gnu - # env: { RUST_LIBC_UNSTABLE_GNU_TIME_BITS: 64 } - # artifact-tag: time-bits64 runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 env: diff --git a/ci/run.sh b/ci/run.sh index 6ec25f5c70a5e..8a7abf2e20f77 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -25,9 +25,21 @@ case "$target" in *) cmd="$cmd --workspace" ;; esac +env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')" +bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')" + # shellcheck disable=SC2086 $cmd --no-default-features -- $test_flags # shellcheck disable=SC2086 $cmd -- $test_flags # shellcheck disable=SC2086 $cmd --features extra_traits -- $test_flags + +# On relevant platforms, also test with our optional settings + +if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then + # shellcheck disable=SC2086 + RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags + # shellcheck disable=SC2086 + RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags +fi From 507a73e50b6493d7c88741a17275d86c0553e1a4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 04:58:00 -0400 Subject: [PATCH 22/37] ci: Only test against one of two musl versions Commonize to always build 1.2.5 for tests that require a newer musl, rather than either 1.2.3 or 1.2.5 based on the version. (backport ) (cherry picked from commit 03e32e84eb6a006f8d90a5b7d8ca883d252cd735) --- ci/install-musl.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ci/install-musl.sh b/ci/install-musl.sh index f5516553707d2..d43e29470dabd 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -5,12 +5,15 @@ set -eux +old_musl=1.1.24 +new_musl=1.2.5 + case ${1} in - loongarch64) - musl_version=1.2.5 - ;; + loongarch64) musl_version="$new_musl" ;; *) - [ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && musl_version=1.2.3 || musl_version=1.1.24 + [ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && + musl_version="$new_musl" || + musl_version="$old_musl" ;; esac From 4e71247296ada10e54c382447d2cd39a976e3077 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Mon, 27 Oct 2025 09:24:27 -0400 Subject: [PATCH 23/37] Change errno EWOULDBLOCK to make it an alias of EAGAIN. (backport ) (cherry picked from commit 095aae8e6f0878b3dfb8f010cd8b699c5dd2d31f) --- libc-test/build.rs | 8 +++----- src/unix/aix/mod.rs | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d23b0d6876813..fb8b08f95b147 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5354,11 +5354,9 @@ fn test_aix(target: &str) { // Skip 'sighandler_t' assignments. "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, - // _ALL_SOURCE defines these errno values as aliases of other errno - // values, but POSIX requires each errno to be unique. Skip these - // values because non-unique values are being used which will - // fail the test when _ALL_SOURCE is defined. - "EWOULDBLOCK" | "ENOTEMPTY" => true, + // _ALL_SOURCE defines ENOTEMPTY as an alias of EEXIST, but POSIX + // requires its value to be unique. Skip. + "ENOTEMPTY" => true, // FIXME(ctest): These constants are intended for use as the 'int request' argument // to 'ioctl()'. However, the AIX headers do not explicitly define their types. If a diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 8fe62e4e540c3..f4dd26f6aba37 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1275,7 +1275,8 @@ pub const ENOLCK: c_int = 49; pub const ENOCONNECT: c_int = 50; pub const ESTALE: c_int = 52; pub const EDIST: c_int = 53; -pub const EWOULDBLOCK: c_int = 54; +// POSIX allows EWOULDBLOCK to be the same value as EAGAIN. +pub const EWOULDBLOCK: c_int = EAGAIN; pub const EINPROGRESS: c_int = 55; pub const EALREADY: c_int = 56; pub const ENOTSOCK: c_int = 57; From 05c7505746c5a6c30681cbe69ec4575b9724519a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:22:55 +0000 Subject: [PATCH 24/37] build(deps): bump actions/upload-artifact from 4 to 5 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit bf2bd19d07f1fb35fa0ee2fd956962b17ad15dba) --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6bbd53bda9043..4014d75b07805 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -149,7 +149,7 @@ jobs: id: create_artifacts if: always() run: python3 ci/create-artifacts.py - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} @@ -246,7 +246,7 @@ jobs: id: create_artifacts if: always() run: ./ci/create-artifacts.py - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 if: always() && steps.create_artifacts.outcome == 'success' with: name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }} From fa6360a10c0adfeade183f0f18d35fd672518723 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 18:25:06 -0400 Subject: [PATCH 25/37] Add an `offset_of` macro We can't yet use the standard library's macro since it isn't in our MSRV, but there are a couple of applicatons for having `offset_of` available. Add a polyfill for now. (backport ) (cherry picked from commit 18083938f28c39908f487624bd96ed9a6c0c24e0) --- src/macros.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 14ec3b53402f2..6f0adb9d46084 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -427,6 +427,23 @@ macro_rules! deprecated_mach { } } +/// Polyfill for std's `offset_of`. +// FIXME(msrv): stabilized in std in 1.77 +macro_rules! offset_of { + ($Ty:path, $field:ident) => {{ + // Taken from bytemuck, avoids accidentally calling on deref + #[allow(clippy::unneeded_field_pattern)] + let $Ty { $field: _, .. }; + let data = core::mem::MaybeUninit::<$Ty>::uninit(); + let ptr = data.as_ptr(); + // SAFETY: computed address is inbounds since we have a stack alloc for T + let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) }; + let off = (fptr as usize).checked_sub(ptr as usize).unwrap(); + assert!(off <= core::mem::size_of::<$Ty>()); + off + }}; +} + #[cfg(test)] mod tests { use core::any::TypeId; @@ -528,6 +545,26 @@ mod tests { fn type_id_of_val(_: &T) -> TypeId { TypeId::of::() } + + #[test] + fn test_offset_of() { + #[repr(C)] + struct Off1 { + a: u8, + b: u32, + c: Off2, + d: u64, + } + + #[repr(C)] + #[repr(align(128))] + struct Off2 {} + + assert_eq!(core::mem::offset_of!(Off1, a), offset_of!(Off1, a)); + assert_eq!(core::mem::offset_of!(Off1, b), offset_of!(Off1, b)); + assert_eq!(core::mem::offset_of!(Off1, c), offset_of!(Off1, c)); + assert_eq!(core::mem::offset_of!(Off1, d), offset_of!(Off1, d)); + } } #[cfg(test)] From 5796438454c5f284ede4a3b6dd2666affa353735 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 02:13:38 -0400 Subject: [PATCH 26/37] ci: Commonize dockerfile style Split all dependencies to new lines and sort them, and use consistent indentation across all files. (backport ) (cherry picked from commit 2e208d03fe34ef7fe4e68e46ea7e6de227d83b4f) --- ci/docker/aarch64-linux-android/Dockerfile | 40 +++++++++---------- .../aarch64-unknown-linux-gnu/Dockerfile | 9 ++++- .../aarch64-unknown-linux-musl/Dockerfile | 13 +++++- ci/docker/arm-linux-androideabi/Dockerfile | 40 +++++++++---------- .../arm-unknown-linux-gnueabihf/Dockerfile | 9 ++++- .../arm-unknown-linux-musleabihf/Dockerfile | 13 +++++- .../Dockerfile | 11 ++++- ci/docker/asmjs-unknown-emscripten/Dockerfile | 9 ++--- ci/docker/i686-linux-android/Dockerfile | 40 +++++++++---------- ci/docker/i686-unknown-linux-gnu/Dockerfile | 5 ++- ci/docker/i686-unknown-linux-musl/Dockerfile | 12 +++++- .../loongarch64-unknown-linux-gnu/Dockerfile | 10 +++-- .../loongarch64-unknown-linux-musl/Dockerfile | 13 +++++- .../powerpc-unknown-linux-gnu/Dockerfile | 10 +++-- .../powerpc64-unknown-linux-gnu/Dockerfile | 10 +++-- .../powerpc64le-unknown-linux-gnu/Dockerfile | 10 +++-- .../powerpc64le-unknown-linux-musl/Dockerfile | 13 +++++- .../riscv64gc-unknown-linux-gnu/Dockerfile | 11 +++-- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 13 +++--- ci/docker/s390x-unknown-linux-musl/Dockerfile | 13 +++--- .../sparc64-unknown-linux-gnu/Dockerfile | 19 ++++++--- .../wasm32-unknown-emscripten/Dockerfile | 19 +++++---- ci/docker/x86_64-linux-android/Dockerfile | 15 ++++--- ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 9 +++-- .../x86_64-unknown-linux-gnux32/Dockerfile | 8 ++-- .../x86_64-unknown-linux-musl/Dockerfile | 14 +++++-- 26 files changed, 247 insertions(+), 141 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 8ed15a5234d1e..0e5baf0854238 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu:25.04 RUN dpkg --add-architecture i386 -RUN apt-get update -RUN apt-get install -y --no-install-recommends libc6-dev gcc -RUN apt-get install -y --no-install-recommends \ - file \ - wget \ - ca-certificates \ - python3 \ - unzip \ - expect \ - openjdk-8-jre \ - libstdc++6:i386 \ - libpulse0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + expect \ + file \ + gcc \ + libc6-dev \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre \ + python3 \ + unzip \ + wget WORKDIR /android/ COPY android* /android/ @@ -35,12 +35,12 @@ ENV PATH=$PATH:/rust/bin \ ADD runtest-android.rs /tmp/runtest.rs ENTRYPOINT [ \ - "bash", \ - "-c", \ - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ - exec \"$@\"", \ - "--" \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ ] diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index a4faeb4a8b96b..e6b1798b1cfbf 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,8 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates \ - gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user + ca-certificates \ + gcc \ + gcc-aarch64-linux-gnu \ + libc6-dev \ + libc6-dev-arm64-cross \ + qemu-user + ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index f57c5fa6055c2..3bbf58aa3b8b6 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -1,8 +1,17 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - gcc-aarch64-linux-gnu qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-aarch64-linux-gnu \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh aarch64 diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index e81623f7bf0e7..23afe49970e71 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu:25.04 RUN dpkg --add-architecture i386 -RUN apt-get update -RUN apt-get install -y --no-install-recommends libc6-dev gcc -RUN apt-get install -y --no-install-recommends \ - file \ - wget \ - ca-certificates \ - python3 \ - unzip \ - expect \ - openjdk-8-jre \ - libstdc++6:i386 \ - libpulse0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + expect \ + file \ + gcc \ + libc6-dev \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre \ + python3 \ + unzip \ + wget WORKDIR /android/ COPY android* /android/ @@ -35,12 +35,12 @@ ENV PATH=$PATH:/rust/bin \ ADD runtest-android.rs /tmp/runtest.rs ENTRYPOINT [ \ - "bash", \ - "-c", \ - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ - exec \"$@\"", \ - "--" \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ ] diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 8f2d3ea80d065..e6cdf778d78c0 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -4,8 +4,13 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates \ - gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user + ca-certificates \ + gcc \ + gcc-arm-linux-gnueabihf \ + libc6-dev \ + libc6-dev-armhf-cross \ + qemu-user + ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \ PATH=$PATH:/rust/bin diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index c6bd116b6f1cb..e4628e8befbd0 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -4,8 +4,17 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - gcc-arm-linux-gnueabihf qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-arm-linux-gnueabihf \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh arm diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile index 330493f54a1d1..284389360ac2c 100644 --- a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -4,8 +4,15 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates qemu-system-arm curl \ - xz-utils patch file + ca-certificates \ + curl \ + file \ + gcc \ + libc6-dev \ + patch \ + qemu-system-arm \ + qemu-user \ + xz-utils RUN mkdir /toolchain diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index c8fb40cc3d3c0..312eca1146dba 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -4,9 +4,8 @@ FROM ubuntu:25.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -RUN apt-get install -y --no-install-recommends tzdata -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ + bzip2 \ ca-certificates \ curl \ gcc \ @@ -14,8 +13,8 @@ RUN apt-get install -y --no-install-recommends \ libc6-dev \ libxml2 \ python3 \ - xz-utils \ - bzip2 + tzdata \ + xz-utils COPY emscripten.sh / RUN /emscripten.sh diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index 24d15872efd07..96507d7fc2275 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -1,18 +1,18 @@ FROM ubuntu:25.04 RUN dpkg --add-architecture i386 -RUN apt-get update -RUN apt-get install -y --no-install-recommends libc6-dev gcc -RUN apt-get install -y --no-install-recommends \ - file \ - wget \ - ca-certificates \ - python3 \ - unzip \ - expect \ - openjdk-8-jre \ - libstdc++6:i386 \ - libpulse0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + expect \ + gcc \ + libc6-dev \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre \ + python3 \ + unzip \ + wget \ + file WORKDIR /android/ COPY android* /android/ @@ -35,12 +35,12 @@ ENV PATH=$PATH:/rust/bin \ ADD runtest-android.rs /tmp/runtest.rs ENTRYPOINT [ \ - "bash", \ - "-c", \ - # set SHELL so android can detect a 64bits system, see - # http://stackoverflow.com/a/41789144 - "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ - exec \"$@\"", \ - "--" \ + "bash", \ + "-c", \ + # set SHELL so android can detect a 64bits system, see + # http://stackoverflow.com/a/41789144 + "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \ + rustc /tmp/runtest.rs -o /tmp/runtest && \ + exec \"$@\"", \ + "--" \ ] diff --git a/ci/docker/i686-unknown-linux-gnu/Dockerfile b/ci/docker/i686-unknown-linux-gnu/Dockerfile index fae0b566d33fc..5a2f4c9dd43ec 100644 --- a/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ b/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -1,10 +1,11 @@ FROM ubuntu:23.10 - # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc-multilib libc6-dev ca-certificates + ca-certificates \ + gcc-multilib \ + libc6-dev ENV PATH=$PATH:/rust/bin diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index 287f325e9151f..82f2b786eda20 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -5,8 +5,16 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ dpkg --add-architecture i386 && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 \ - xz-utils patch rsync + ca-certificates \ + curl \ + gcc-multilib \ + git \ + libc6-dev \ + libc6-i386 \ + make \ + patch \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh i686 diff --git a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile index 138b9a195adb8..359a40b5f33d6 100644 --- a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile @@ -1,9 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-14-loongarch64-linux-gnu libc6-dev-loong64-cross \ - linux-headers-generic + ca-certificates \ + gcc \ + gcc-14-loongarch64-linux-gnu \ + libc6-dev \ + libc6-dev-loong64-cross \ + linux-headers-generic \ + qemu-user ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=loongarch64-linux-gnu-gcc-14 \ CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-loongarch64 -L /usr/loongarch64-linux-gnu" \ diff --git a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile index ec632c33f7af3..dcf75b428a290 100644 --- a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile @@ -1,8 +1,17 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates curl gcc gcc-14-loongarch64-linux-gnu git libc6-dev \ - make qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-14-loongarch64-linux-gnu \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh loongarch64 diff --git a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 535202951d2ce..99c5f13892095 100644 --- a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -4,9 +4,13 @@ FROM ubuntu:23.10 RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \ - qemu-system-ppc + ca-certificates \ + gcc \ + gcc-powerpc-linux-gnu \ + libc6-dev \ + libc6-dev-powerpc-cross \ + qemu-system-ppc \ + qemu-user ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \ diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index a8a9dd8c92263..f7907a32347ac 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -1,9 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \ - qemu-system-ppc + ca-certificates \ + gcc \ + gcc-powerpc64-linux-gnu \ + libc6-dev \ + libc6-dev-ppc64-cross \ + qemu-system-ppc \ + qemu-user ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ diff --git a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 0d6110f39149f..f2f0a6e20c7b2 100644 --- a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -1,9 +1,13 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \ - qemu-system-ppc + ca-certificates \ + gcc \ + gcc-powerpc64le-linux-gnu \ + libc6-dev \ + libc6-dev-ppc64el-cross \ + qemu-system-ppc \ + qemu-user ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -L /usr/powerpc64le-linux-gnu" \ diff --git a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile index 40a661149f7d8..c21ce6a3d5097 100644 --- a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile @@ -1,8 +1,17 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - gcc-powerpc64le-linux-gnu qemu-user xz-utils patch rsync + ca-certificates \ + curl \ + gcc \ + gcc-powerpc64le-linux-gnu \ + git \ + libc6-dev \ + make \ + patch \ + qemu-user \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh powerpc64le diff --git a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile index 43138af5da234..1750f8fd0f70e 100644 --- a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile @@ -1,9 +1,14 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc libc6-dev qemu-user ca-certificates \ - gcc-riscv64-linux-gnu libc6-dev-riscv64-cross \ - qemu-system-riscv64 linux-headers-generic + ca-certificates \ + gcc \ + gcc-riscv64-linux-gnu \ + libc6-dev \ + libc6-dev-riscv64-cross \ + linux-headers-generic \ + qemu-system-riscv64 \ + qemu-user ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc \ CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="qemu-riscv64 -L /usr/riscv64-linux-gnu" \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index aa3490228c4db..4e0e3e7d514f9 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,11 +1,14 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc libc6-dev \ - gcc-s390x-linux-gnu libc6-dev-s390x-cross \ - qemu-system-s390x \ - cpio + ca-certificates \ + cpio \ + curl \ + gcc \ + gcc-s390x-linux-gnu \ + libc6-dev \ + libc6-dev-s390x-cross \ + qemu-system-s390x COPY linux-s390x.sh / RUN /linux-s390x.sh diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index 0dfad20fb7a1d..58133e216c840 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -1,11 +1,14 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc \ - gcc-s390x-linux-gnu \ - qemu-user \ - xz-utils patch rsync + curl \ + ca-certificates \ + gcc \ + gcc-s390x-linux-gnu \ + qemu-user \ + xz-utils \ + patch \ + rsync COPY install-musl.sh / RUN /install-musl.sh s390x diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index c55d57105a114..67889b139488d 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,11 +1,20 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ - curl ca-certificates \ - gcc libc6-dev \ - gcc-sparc64-linux-gnu libc6-dev-sparc64-cross \ - qemu-system-sparc64 openbios-sparc seabios ipxe-qemu \ - p7zip-full cpio linux-libc-dev-sparc64-cross qemu-user + ca-certificates \ + cpio \ + curl \ + gcc \ + gcc-sparc64-linux-gnu \ + ipxe-qemu \ + libc6-dev \ + libc6-dev-sparc64-cross \ + linux-libc-dev-sparc64-cross \ + openbios-sparc \ + p7zip-full \ + qemu-system-sparc64 \ + qemu-user \ + seabios ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-sparc64 -L /usr/sparc64-linux-gnu" \ diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 969a0ffca0be3..e068ad59f94c2 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -4,24 +4,23 @@ FROM ubuntu:25.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -RUN apt-get install -y --no-install-recommends tzdata -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ + bzip2 \ ca-certificates \ - g++ \ - make \ - file \ + cmake \ curl \ + file \ + g++ \ gcc \ + gdb \ git \ libc6-dev \ libxml2 \ + make \ python3 \ - cmake \ + tzdata \ sudo \ - gdb \ - xz-utils \ - bzip2 + xz-utils RUN ln -s /usr/bin/python3 /usr/bin/python & \ ln -s /usr/bin/pip3 /usr/bin/pip diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 950c2a9fdc612..76b80a894b2bb 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -1,13 +1,12 @@ FROM ubuntu:25.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - wget \ - gcc \ - libc-dev \ - python3 \ - unzip +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc \ + libc-dev \ + python3 \ + unzip \ + wget WORKDIR /android/ ENV ANDROID_ARCH=x86_64 diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 3e94948095024..6ebf7bdcfc8de 100644 --- a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,8 +1,11 @@ FROM ubuntu:25.04 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates linux-headers-generic +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + g++ \ + gcc \ + libc6-dev \ + linux-headers-generic RUN apt search linux-headers RUN ls /usr/src diff --git a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile index 92a92b1dfe98d..0d5cdd7daafb0 100644 --- a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile @@ -1,6 +1,8 @@ FROM ubuntu:25.04 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc-multilib libc6-dev ca-certificates +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc-multilib \ + libc6-dev + ENV PATH=$PATH:/rust/bin diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 194a6e7847f55..5b524c31eff79 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -1,9 +1,15 @@ FROM ubuntu:25.04 -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates \ - xz-utils patch rsync +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + gcc \ + git \ + libc6-dev \ + make \ + patch \ + rsync \ + xz-utils COPY install-musl.sh / RUN /install-musl.sh x86_64 From f54c82288999950849f34df48f8f768006440f86 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 29 Oct 2025 02:28:57 -0500 Subject: [PATCH 27/37] ci: Remove unused dependency installs `linux-headers-generic` isn't needed, sparc no longer needs the dependencies to prepare for using qemu-system, and g++ isn't needed for platforms that have a C-only libc. (backport ) (cherry picked from commit 584c1d348ca24982601568f8f46c550c0d44abbd) --- ci/docker/loongarch64-unknown-linux-gnu/Dockerfile | 1 - ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile | 1 - ci/docker/sparc64-unknown-linux-gnu/Dockerfile | 9 +-------- ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 4 +--- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile index 359a40b5f33d6..ab13f33f1187d 100644 --- a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile @@ -6,7 +6,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-14-loongarch64-linux-gnu \ libc6-dev \ libc6-dev-loong64-cross \ - linux-headers-generic \ qemu-user ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=loongarch64-linux-gnu-gcc-14 \ diff --git a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile index 1750f8fd0f70e..10395b72406b0 100644 --- a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile @@ -6,7 +6,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-riscv64-linux-gnu \ libc6-dev \ libc6-dev-riscv64-cross \ - linux-headers-generic \ qemu-system-riscv64 \ qemu-user diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index 67889b139488d..728586f119545 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -2,19 +2,12 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ - cpio \ - curl \ gcc \ gcc-sparc64-linux-gnu \ - ipxe-qemu \ libc6-dev \ libc6-dev-sparc64-cross \ - linux-libc-dev-sparc64-cross \ - openbios-sparc \ - p7zip-full \ qemu-system-sparc64 \ - qemu-user \ - seabios + qemu-user ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-sparc64 -L /usr/sparc64-linux-gnu" \ diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 6ebf7bdcfc8de..ed9734ca2b6f8 100644 --- a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -2,10 +2,8 @@ FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ - g++ \ gcc \ - libc6-dev \ - linux-headers-generic + libc6-dev RUN apt search linux-headers RUN ls /usr/src From a1d1c3f9fa40645049953aad8710221ff5e5cd0a Mon Sep 17 00:00:00 2001 From: Bhavya Gautam Date: Wed, 15 Oct 2025 08:44:45 +0000 Subject: [PATCH 28/37] Adding defines and functions required for vxworks Co-authored-by: Immad Mir (backport ) (cherry picked from commit 2bee2f363b53935c9f1432ad62a582e9cb7fcb10) --- build.rs | 19 + libc-test/build.rs | 58 ++- libc-test/semver/vxworks.txt | 817 +++++++++++++++++++++++++++++++++++ src/vxworks/mod.rs | 426 +++++++++++++++++- 4 files changed, 1307 insertions(+), 13 deletions(-) create mode 100644 libc-test/semver/vxworks.txt diff --git a/build.rs b/build.rs index 0d1cef6440570..e41c7aa21cd3a 100644 --- a/build.rs +++ b/build.rs @@ -21,6 +21,7 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", + "vxworks_lt_25_09", ]; // Extra values to allow for check-cfg. @@ -85,6 +86,12 @@ fn main() { _ => (), } + match vxworks_version_code() { + Some(v) if (v < (25, 9)) => set_cfg("vxworks_lt_25_09"), + // VxWorks version >= 25.09 + _ => (), + } + let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); // loongarch64 and ohos have already updated @@ -274,6 +281,18 @@ fn emcc_version_code() -> Option { Some(major * 10000 + minor * 100 + patch) } +fn vxworks_version_code() -> Option<(u32, u32)> { + // Retrieve the VxWorks release version from the environment variable set by the VxWorks build environment + let version = env::var("WIND_RELEASE_ID").ok()?; + + let mut pieces = version.trim().split(['.']); + + let major: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let minor: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + + Some((major, minor)) +} + fn set_cfg(cfg: &str) { assert!( ALLOWED_CFGS.contains(&cfg), diff --git a/libc-test/build.rs b/libc-test/build.rs index fb8b08f95b147..c31fa7e3fb5df 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -106,7 +106,7 @@ fn do_semver() { // maintain a file for Android. // NOTE: AIX doesn't include the unix file because there are definitions // missing on AIX. It is easier to maintain a file for AIX. - if family != os && !matches!(os.as_str(), "android" | "aix") { + if family != os && !matches!(os.as_str(), "android" | "aix") && os != "vxworks" { process_semver_file(&mut output, &mut semver_root, &family); } // We don't do semver for unknown targets. @@ -3477,13 +3477,33 @@ fn test_neutrino(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } +fn which_vxworks() -> Option<(u32, u32)> { + let version = env::var("WIND_RELEASE_ID").ok()?; // When in VxWorks setup, WIND_RELEASE_ID is + // always set as the version of the release. + + let mut pieces = version.trim().split(['.']); + + let major: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let minor: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + + Some((major, minor)) +} + fn test_vxworks(target: &str) { assert!(target.contains("vxworks")); let mut cfg = ctest_cfg(); + + let vxworks_ver = which_vxworks(); + + if vxworks_ver < Some((25, 9)) { + cfg.cfg("vxworks_lt_25_09", None); + } + headers!( cfg, "vxWorks.h", + "semLibCommon.h", "yvals.h", "nfs/nfsCommon.h", "rtpLibCommon.h", @@ -3500,13 +3520,11 @@ fn test_vxworks(target: &str) { "elf.h", "fcntl.h", "grp.h", - "sys/poll.h", "ifaddrs.h", "langinfo.h", "limits.h", "link.h", "locale.h", - "sys/stat.h", "netdb.h", "pthread.h", "pwd.h", @@ -3518,6 +3536,9 @@ fn test_vxworks(target: &str) { "stdio.h", "stdlib.h", "string.h", + "sys/select.h", + "sys/stat.h", + "sys/poll.h", "sys/file.h", "sys/ioctl.h", "sys/socket.h", @@ -3528,7 +3549,14 @@ fn test_vxworks(target: &str) { "sys/un.h", "sys/utsname.h", "sys/wait.h", + "sys/ttycom.h", + "sys/utsname.h", + "sys/resource.h", + "sys/mman.h", "netinet/tcp.h", + "netinet/udp.h", + "netinet/in.h", + "netinet6/in6.h", "syslog.h", "termios.h", "time.h", @@ -3537,16 +3565,22 @@ fn test_vxworks(target: &str) { "utime.h", "wchar.h", "errno.h", - "sys/mman.h", "pathLib.h", "mqueue.h", + "fnmatch.h", + "sioLibCommon.h", + "net/if.h", ); // FIXME(vxworks) cfg.skip_const(move |constant| match constant.ident() { // sighandler_t weirdness "SIG_DFL" | "SIG_ERR" | "SIG_IGN" - // This is not defined in vxWorks - | "RTLD_DEFAULT" => true, + // These are not defined in VxWorks + | "RTLD_DEFAULT" | "PRIO_PROCESS" + // Sticky bits not supported + | "S_ISVTX" + // The following are obsolete for VxWorks + | "SIGIO" | "SIGWINCH" | "SIGLOST" => true, _ => false, }); // FIXME(vxworks) @@ -3557,7 +3591,12 @@ fn test_vxworks(target: &str) { cfg.skip_struct_field_type( move |struct_, field| match (struct_.ident(), field.ident()) { - ("siginfo_t", "si_value") | ("stat", "st_size") | ("sigaction", "sa_u") => true, + ("siginfo_t", "si_value") + | ("stat", "st_size") + // sighandler_t type is super weird + | ("sigaction", "sa_sigaction") + // sa_u_t type is not defined in vxworks + | ("sigaction", "sa_u") => true, _ => false, }, ); @@ -3576,11 +3615,16 @@ fn test_vxworks(target: &str) { "sigqueue" | "_sigqueue" // sighandler_t | "signal" + // This is used a realpath and not _realpath + | "_realpath" // not used in static linking by default | "dlerror" => true, _ => false, }); + // Not defined in vxworks. Just a crate specific union type. + cfg.skip_union(move |u| u.ident() == "sa_u_t"); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } diff --git a/libc-test/semver/vxworks.txt b/libc-test/semver/vxworks.txt new file mode 100644 index 0000000000000..bb5f32ccc608f --- /dev/null +++ b/libc-test/semver/vxworks.txt @@ -0,0 +1,817 @@ +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +AT_FDCWD +AT_REMOVEDIR +AT_SYMLINK_FOLLOW +AT_SYMLINK_NOFOLLOW +B0 +B110 +B115200 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B230400 +B2400 +B300 +B38400 +B4800 +B50 +B57600 +B600 +B75 +B9600 +BRKINT +CLOCAL +CLOCK_MONOTONIC +CLOCK_REALTIME +CREAD +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTOPB +DIR +DT_BLK +DT_CHR +DT_DIR +DT_FIFO +DT_LNK +DT_REG +DT_SOCK +Dl_info +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOE +ECHOK +ECHONL +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +ELOOP +EMFILE +EMLINK +EMSGSIZE +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSYS +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTTY +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EROFS +ESHUTDOWN +ESPIPE +ESRCH +ESTALE +ETIMEDOUT +ETXTBSY +EWOULDBLOCK +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +FD_CLOEXEC +FILE +FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_OK +F_SETFD +F_SETFL +F_SETLK +F_SETLKW +HUPCL +ICANON +ICRNL +IEXTEN +IFNAMSIZ +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INLCR +INPCK +INT_MAX +INT_MIN +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_TCP +IPPROTO_UDP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +ISIG +ISTRIP +IXOFF +IXON +LOG_ALERT +LOG_AUTH +LOG_CONS +LOG_CRIT +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NI_MAXHOST +NOFLSH +OCRNL +ONLCR +OPOST +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_EXCL +O_NONBLOCK +O_RDONLY +O_RDWR +O_TRUNC +O_WRONLY +PARENB +PARMRK +PARODD +PATH_MAX +PF_INET +PF_INET6 +PF_UNIX +PF_UNSPEC +POLLERR +POLLHUP +POLLIN +POLLNVAL +POLLOUT +POLLPRI +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PTHREAD_COND_INITIALIZER +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_RWLOCK_INITIALIZER +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_NOW +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_ONSTACK +SA_RESETHAND +SA_RESTART +SA_SIGINFO +SEEK_CUR +SEEK_END +SEEK_SET +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGKILL +SIGPIPE +SIGPROF +SIGQUIT +SIGSEGV +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SOCK_DGRAM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SO_ACCEPTCONN +SO_BROADCAST +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_LINGER +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TYPE +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TCIFLUSH +TCP_NODELAY +TCSADRAIN +TCSAFLUSH +TCSANOW +TIOCGWINSZ +TIOCSWINSZ +VEOF +VERASE +VINTR +VKILL +VMIN +VQUIT +VTIME +WCONTINUED +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +X_OK +_PC_CHOWN_RESTRICTED +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_VDISABLE +_SC_ARG_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_HOST_NAME_MAX +_SC_NGROUPS_MAX +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_TTY_NAME_MAX +_SC_TZNAME_MAX +_SC_VERSION +_exit +abort +accept +access +addrinfo +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +bind +blkcnt_t +blksize_t +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +chdir +chmod +chown +clock_gettime +clock_t +clockid_t +close +closedir +closelog +confstr +connect +creat +dev_t +dirent +dladdr +dlclose +dlerror +dlopen +dlsym +dup +dup2 +exit +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fdopen +feof +ferror +fflush +fgetc +fgetpos +fgets +fileno +flock +fnmatch +fopen +fpathconf +fpos_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freopen +fscanf +fseek +fseeko +fsetpos +fstat +fsync +ftell +ftello +ftruncate +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcwd +getegid +getenv +geteuid +getgid +getgroups +gethostname +getlogin +getopt +getpeername +getpid +getppid +getprotobyname +getprotobynumber +getservbyname +getsockname +getsockopt +gettimeofday +getuid +gid_t +gmtime +gmtime_r +group +hostent +in6_addr +in_addr +in_addr_t +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +kill +lconv +linger +link +linkat +listen +localtime +localtime_r +lseek +lstat +malloc +memccpy +memchr +memcmp +memcpy +memmove +memset +mkdir +mkdtemp +mkfifo +mkstemp +mktime +mlock +mlockall +mmap +mode_t +mprotect +msync +munlock +munlockall +munmap +nanosleep +nfds_t +nlink_t +off_t +open +opendir +openlog +pathconf +pclose +perror +pid_t +pipe +poll +pollfd +posix_memalign +pread +printf +protoent +pthread_attr_destroy +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_attr_t +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_init +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_t +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_init +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_init +pthread_rwlockattr_t +pthread_self +pthread_setspecific +pthread_t +ptrdiff_t +putchar +putchar_unlocked +putenv +puts +pwrite +raise +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +remove +rename +rewind +rewinddir +rlim_t +rlimit +rmdir +rusage +sa_family_t +scanf +sched_yield +send +sendto +servent +setbuf +setegid +setenv +seteuid +setgid +setlocale +setlogmask +setpgid +setsockopt +setuid +setvbuf +shm_open +shm_unlink +shutdown +sigaction +sigaddset +sigdelset +sigemptyset +sigfillset +sighandler_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigval +size_t +sleep +snprintf +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socklen_t +speed_t +sprintf +sscanf +ssize_t +stat +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strlen +strncat +strncmp +strncpy +strnlen +strpbrk +strrchr +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +symlink +symlinkat +sysconf +syslog +system +tcflag_t +tcflush +tcgetattr +tcsendbreak +tcsetattr +termios +time +time_t +timegm +times +timespec +timeval +tm +tmpfile +tmpnam +tms +tolower +toupper +ttyname +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +umask +uname +ungetc +unlink +unlinkat +unsetenv +usleep +utimbuf +utime +utimensat +utimes +utsname +wait +waitpid +wchar_t +wcslen +wcstombs +winsize +wmemchr +write +writev diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index ecaba54b1cdcf..fcb74e26135bd 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -16,6 +16,10 @@ pub type intptr_t = isize; pub type ptrdiff_t = isize; pub type size_t = crate::uintptr_t; pub type ssize_t = intptr_t; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type clock_t = c_long; +pub type cc_t = c_uchar; pub type pid_t = c_int; pub type in_addr_t = u32; @@ -215,8 +219,17 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_size: off_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_atim: timespec, + #[cfg(vxworks_lt_25_09)] pub st_atime: crate::time_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_mtim: timespec, + #[cfg(vxworks_lt_25_09)] pub st_mtime: crate::time_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_ctim: timespec, + #[cfg(vxworks_lt_25_09)] pub st_ctime: crate::time_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, @@ -235,6 +248,15 @@ s! { // b_struct__Sched_param.h pub struct sched_param { + pub sched_priority: c_int, /* scheduling priority */ + pub sched_ss_low_priority: c_int, /* low scheduling priority */ + pub sched_ss_repl_period: crate::timespec, /* replenishment period */ + pub sched_ss_init_budget: crate::timespec, /* initial budget */ + pub sched_ss_max_repl: c_int, /* max pending replenishment */ + } + + // b_struct__Sched_param.h + pub struct _Sched_param { pub sched_priority: c_int, /* scheduling priority */ pub sched_ss_low_priority: c_int, /* low scheduling priority */ pub sched_ss_repl_period: crate::_Timespec, /* replenishment period */ @@ -254,13 +276,16 @@ s! { pub threadAttrSchedpolicy: c_int, pub threadAttrName: *mut c_char, pub threadAttrOptions: c_int, - pub threadAttrSchedparam: crate::sched_param, + pub threadAttrSchedparam: crate::_Sched_param, } // signal.h pub struct sigaction { + #[cfg(vxworks_lt_25_09)] pub sa_u: crate::sa_u_t, + #[cfg(not(vxworks_lt_25_09))] + pub sa_sigaction: crate::sighandler_t, pub sa_mask: crate::sigset_t, pub sa_flags: c_int, } @@ -325,6 +350,20 @@ s! { pub tm_isdst: c_int, } + // sys/times.h + pub struct tms { + pub tms_utime: crate::clock_t, + pub tms_stime: crate::clock_t, + pub tms_cutime: crate::clock_t, + pub tms_cstime: crate::clock_t, + } + + // utime.h + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + // in.h pub struct in_addr { pub s_addr: in_addr_t, @@ -360,6 +399,30 @@ s! { pub ai_next: *mut crate::addrinfo, } + // netdb.h + pub struct servent { + pub s_name: *mut c_char, + pub s_aliases: *mut *mut c_char, + pub s_port: c_int, + pub s_proto: *mut c_char, + } + + // netdb.h + pub struct protoent { + pub p_name: *mut c_char, + pub p_aliases: *mut *mut c_char, + pub p_proto: c_int, + } + + // netdb.h + pub struct hostent { + pub h_name: *mut c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: c_int, + pub h_length: c_int, + pub h_addr_list: *mut *mut c_char, + } + // in.h pub struct sockaddr_in { pub sin_len: u8, @@ -392,6 +455,98 @@ s! { pub mq_flags: c_long, pub mq_curmsgs: c_long, } + + pub struct winsize { + pub ws_row: c_ushort, + pub ws_col: c_ushort, + pub ws_xpixel: c_ushort, + pub ws_ypixel: c_ushort, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long, + } + + pub struct lconv { + pub currency_symbol: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_grouping: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub negative_sign: *mut c_char, + pub positive_sign: *mut c_char, + pub frac_digits: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub n_sign_posn: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub int_frac_digits: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub decimal_point: *mut c_char, + pub grouping: *mut c_char, + pub thousands_sep: *mut c_char, + pub _Frac_grouping: *mut c_char, + pub _Frac_sep: *mut c_char, + pub _False: *mut c_char, + pub _True: *mut c_char, + + pub _No: *mut c_char, + pub _Yes: *mut c_char, + } + + // grp.h + pub struct group { + pub gr_name: *mut c_char, + pub gr_passwd: *mut c_char, + pub gr_gid: c_int, + pub gr_mem: *mut *mut c_char, + } + + pub struct utsname { + pub sysname: [c_char; 80], + pub nodename: [c_char; 256], + pub release: [c_char; 80], + pub version: [c_char; 256], + pub machine: [c_char; 256], + pub endian: [c_char; 80], + pub kernelversion: [c_char; 80], + pub releaseversion: [c_char; 80], + pub processor: [c_char; 80], + pub bsprevision: [c_char; 80], + pub builddate: [c_char; 80], + } } s_no_extra_traits! { @@ -496,6 +651,9 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; +pub const INT_MAX: c_int = 0x7fffffff; +pub const INT_MIN: c_int = -INT_MAX - 1; + // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); @@ -683,12 +841,22 @@ const objErrorBase: c_int = 0x003d0000; pub const S_taskLib_NAME_NOT_FOUND: c_int = taskErrorBase + 0x0065; pub const S_taskLib_TASK_HOOK_TABLE_FULL: c_int = taskErrorBase + 0x0066; pub const S_taskLib_TASK_HOOK_NOT_FOUND: c_int = taskErrorBase + 0x0067; -pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068; +pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x006D; // FIXME(vxworks): could also be useful for TASK_DESC type pub const VX_TASK_NAME_LENGTH: c_int = 31; pub const VX_TASK_RENAME_LENGTH: c_int = 16; +pub const TCIFLUSH: c_int = 0; + +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; + // semLibCommon.h pub const S_semLib_INVALID_STATE: c_int = semErrorBase + 0x0065; pub const S_semLib_INVALID_OPTION: c_int = semErrorBase + 0x0066; @@ -702,9 +870,28 @@ pub const S_objLib_OBJ_DELETED: c_int = objErrorBase + 0x0003; pub const S_objLib_OBJ_TIMEOUT: c_int = objErrorBase + 0x0004; pub const S_objLib_OBJ_NO_METHOD: c_int = objErrorBase + 0x0005; -// in.h +// netinet/in.h pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_ICMP: c_int = 1; +pub const IPPROTO_TCP: c_int = 6; pub const IPPROTO_IPV6: c_int = 41; +pub const IPPROTO_ICMPV6: c_int = 58; + +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +// netinet6/in6.h +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], +}; +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; + +// udp.h +pub const IPPROTO_UDP: c_int = 17; pub const IP_TTL: c_int = 4; pub const IP_MULTICAST_IF: c_int = 9; @@ -713,6 +900,9 @@ pub const IP_MULTICAST_LOOP: c_int = 11; pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; +// netdb.h +pub const NI_MAXHOST: c_int = 1025; + // in6.h pub const IPV6_V6ONLY: c_int = 1; pub const IPV6_UNICAST_HOPS: c_int = 4; @@ -813,8 +1003,12 @@ pub const MSG_COMPAT: c_int = 0x8000; pub const AF_UNSPEC: c_int = 0; pub const AF_LOCAL: c_int = 1; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_UNSPEC: c_int = AF_UNSPEC; pub const AF_UNIX: c_int = AF_LOCAL; pub const AF_INET: c_int = 2; +pub const PF_INET: c_int = AF_INET; pub const AF_NETLINK: c_int = 16; pub const AF_ROUTE: c_int = 17; pub const AF_LINK: c_int = 18; @@ -822,17 +1016,111 @@ pub const AF_PACKET: c_int = 19; pub const pseudo_AF_KEY: c_int = 27; pub const AF_KEY: c_int = pseudo_AF_KEY; pub const AF_INET6: c_int = 28; +pub const PF_INET6: c_int = AF_INET6; pub const AF_SOCKDEV: c_int = 31; pub const AF_TIPC: c_int = 33; pub const AF_MIPC: c_int = 34; pub const AF_MIPC_SAFE: c_int = 35; -pub const AF_MAX: c_int = 37; +pub const AF_MAX: c_int = 39; + +// termios.h +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 50; +pub const B75: crate::speed_t = 75; +pub const B110: crate::speed_t = 110; +pub const B134: crate::speed_t = 134; +pub const B150: crate::speed_t = 150; +pub const B200: crate::speed_t = 200; +pub const B300: crate::speed_t = 300; +pub const B600: crate::speed_t = 600; +pub const B1200: crate::speed_t = 1200; +pub const B1800: crate::speed_t = 1800; +pub const B2400: crate::speed_t = 2400; +pub const B4800: crate::speed_t = 4800; +pub const B9600: crate::speed_t = 9600; +pub const B19200: crate::speed_t = 19200; +pub const B38400: crate::speed_t = 38400; +pub const B57600: crate::speed_t = 57600; +pub const B115200: crate::speed_t = 115200; +pub const B230400: crate::speed_t = 230400; + +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNCR: crate::tcflag_t = 0x00000200; +pub const IGNPAR: crate::tcflag_t = 0x00000000; +pub const INPCK: crate::tcflag_t = 0x00000020; +pub const ISTRIP: crate::tcflag_t = 0x00000040; +pub const INLCR: crate::tcflag_t = 0x00000100; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const IXOFF: crate::tcflag_t = 0x00010000; +pub const IXON: crate::tcflag_t = 0x00002000; +pub const PARMRK: crate::tcflag_t = 0x00000000; +pub const NOFLSH: crate::tcflag_t = 0x00000000; +pub const NCCS: usize = 20; + +pub const OPOST: crate::tcflag_t = 0x00000001; +pub const ONLCR: crate::tcflag_t = 0x00000004; +pub const ECHO: crate::tcflag_t = 0x00000010; +pub const OCRNL: crate::tcflag_t = 0x00000010; +pub const ECHOE: crate::tcflag_t = 0x00000020; +pub const ECHOK: crate::tcflag_t = 0x00000040; +pub const ECHONL: crate::tcflag_t = 0x00000100; + +// net/if.h +pub const IFNAMSIZ: size_t = 16; +pub const IF_NAMESIZE: size_t = IFNAMSIZ; + +// sioLibCommon.h +pub const CLOCAL: crate::tcflag_t = 0x1; +pub const CREAD: crate::tcflag_t = 0x2; +pub const CS5: crate::tcflag_t = 0x0; +pub const CS6: crate::tcflag_t = 0x4; +pub const CS7: crate::tcflag_t = 0x8; +pub const CS8: crate::tcflag_t = 0xc; +pub const CSTOPB: crate::tcflag_t = 0x20; +pub const CSIZE: crate::tcflag_t = 0xc; + +pub const PARODD: crate::tcflag_t = 0x80; +pub const PARENB: crate::tcflag_t = 0x40; + +pub const DT_FIFO: c_uchar = 1; +pub const DT_CHR: c_uchar = 2; +pub const DT_DIR: c_uchar = 4; +pub const DT_BLK: c_uchar = 6; +pub const DT_REG: c_uchar = 8; +pub const DT_LNK: c_uchar = 10; +pub const DT_SOCK: c_uchar = 12; + +pub const FNM_NOMATCH: c_int = 1; +pub const FNM_NOESCAPE: c_int = 1; +pub const FNM_PATHNAME: c_int = 2; +pub const FNM_PERIOD: c_int = 4; +pub const FNM_CASEFOLD: c_int = 16; + +pub const F_OK: c_int = 0; +pub const X_OK: c_int = 1; +pub const W_OK: c_int = 2; + +pub const _PC_CHOWN_RESTRICTED: c_int = 4; +pub const _PC_LINK_MAX: c_int = 6; +pub const _PC_MAX_CANON: c_int = 7; +pub const _PC_MAX_INPUT: c_int = 8; +pub const _PC_NAME_MAX: c_int = 9; +pub const _PC_NO_TRUNC: c_int = 10; +pub const _PC_PATH_MAX: c_int = 11; +pub const _PC_PIPE_BUF: c_int = 12; +pub const _PC_VDISABLE: c_int = 20; + +pub const HUPCL: crate::tcflag_t = 0x10; pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; pub const SHUT_RDWR: c_int = 2; -pub const IPPROTO_TCP: c_int = 6; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const ICRNL: crate::tcflag_t = 0x00000400; +pub const IEXTEN: crate::tcflag_t = 0x00000000; + pub const TCP_NODELAY: c_int = 1; pub const TCP_MAXSEG: c_int = 2; pub const TCP_NOPUSH: c_int = 3; @@ -840,6 +1128,10 @@ pub const TCP_KEEPIDLE: c_int = 4; pub const TCP_KEEPINTVL: c_int = 5; pub const TCP_KEEPCNT: c_int = 6; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + // ioLib.h pub const FIONREAD: c_int = 0x40040001; pub const FIOFLUSH: c_int = 2; @@ -888,6 +1180,48 @@ pub const F_SETLK: c_int = 8; pub const F_SETLKW: c_int = 9; pub const F_DUPFD_CLOEXEC: c_int = 14; +pub const LOG_EMERG: c_int = 0; +pub const LOG_ALERT: c_int = 1; +pub const LOG_CRIT: c_int = 2; +pub const LOG_ERR: c_int = 3; +pub const LOG_WARNING: c_int = 4; +pub const LOG_NOTICE: c_int = 5; +pub const LOG_INFO: c_int = 6; +pub const LOG_DEBUG: c_int = 7; + +pub const LOG_KERN: c_int = 0 << 3; +pub const LOG_USER: c_int = 1 << 3; +pub const LOG_MAIL: c_int = 2 << 3; +pub const LOG_DAEMON: c_int = 3 << 3; +pub const LOG_AUTH: c_int = 4 << 3; +pub const LOG_SYSLOG: c_int = 5 << 3; +pub const LOG_LPR: c_int = 6 << 3; +pub const LOG_NEWS: c_int = 7 << 3; +pub const LOG_UUCP: c_int = 8 << 3; +pub const LOG_LOCAL0: c_int = 16 << 3; +pub const LOG_LOCAL1: c_int = 17 << 3; +pub const LOG_LOCAL2: c_int = 18 << 3; +pub const LOG_LOCAL3: c_int = 19 << 3; +pub const LOG_LOCAL4: c_int = 20 << 3; +pub const LOG_LOCAL5: c_int = 21 << 3; +pub const LOG_LOCAL6: c_int = 22 << 3; +pub const LOG_LOCAL7: c_int = 23 << 3; + +pub const LOG_PID: c_int = 0x01; +pub const LOG_CONS: c_int = 0x02; +pub const LOG_ODELAY: c_int = 0x04; +pub const LOG_NDELAY: c_int = 0x08; +pub const LOG_NOWAIT: c_int = 0x10; + +pub const LOG_PRIMASK: c_int = 0x7; +pub const LOG_FACMASK: c_int = 0x3f8; + +// dlfcn.h +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_GLOBAL: c_int = 256; + // signal.h pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; @@ -964,6 +1298,7 @@ pub const _PARM_PATH_MAX: c_int = 1024; // WAIT STUFF pub const WNOHANG: c_int = 0x01; pub const WUNTRACED: c_int = 0x02; +pub const WCONTINUED: c_int = 0x04; const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t { mutexAttrStatus: PTHREAD_INITIALIZED_OBJ, @@ -1021,9 +1356,22 @@ pub const VX_RTP_NAME_LENGTH: c_int = 255; pub const RTP_ID_ERROR: crate::RTP_ID = -1; // h/public/unistd.h -pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; // Via unistd.h +// h/public/unistd.h +pub const R_OK: c_int = 4; +pub const _SC_ARG_MAX: c_int = 4; // Via unistd.h +pub const _SC_CHILD_MAX: c_int = 12; +pub const _SC_CLK_TCK: c_int = 13; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; pub const _SC_HOST_NAME_MAX: c_int = 22; +pub const _SC_NGROUPS_MAX: c_int = 36; +pub const _SC_OPEN_MAX: c_int = 37; +pub const _SC_PAGE_SIZE: c_int = 38; pub const _SC_PAGESIZE: c_int = 39; +pub const _SC_STREAM_MAX: c_int = 59; +pub const _SC_SYMLOOP_MAX: c_int = 60; +pub const _SC_TTY_NAME_MAX: c_int = 87; +pub const _SC_TZNAME_MAX: c_int = 89; +pub const _SC_VERSION: c_int = 94; pub const O_ACCMODE: c_int = 3; pub const O_CLOEXEC: c_int = 0x100000; // fcntlcom pub const O_EXCL: c_int = 0x0800; @@ -1048,8 +1396,16 @@ pub const MAP_ANONYMOUS: c_int = MAP_ANON; pub const MAP_FIXED: c_int = 0x0010; pub const MAP_CONTIG: c_int = 0x0020; +pub const MS_SYNC: c_int = 0x0001; +pub const MS_ASYNC: c_int = 0x0002; +pub const MS_INVALIDATE: c_int = 0x0004; + pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; +// sys/ttycom.h +pub const TIOCGWINSZ: c_int = 0x1740087468; +pub const TIOCSWINSZ: c_int = -0x7ff78b99; + extern_ty! { pub enum FILE {} pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct @@ -1155,6 +1511,10 @@ extern "C" { pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t; + pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; @@ -1183,8 +1543,39 @@ extern "C" { pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn times(buf: *mut crate::tms) -> crate::clock_t; + pub fn tcflush(fd: c_int, action: c_int) -> c_int; + pub fn pclose(stream: *mut crate::FILE) -> c_int; + pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + + pub fn linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + + pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; + + // netdb.h + pub fn getprotobyname(name: *const c_char) -> *mut protoent; + pub fn getprotobynumber(proto: c_int) -> *mut protoent; + pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; + + pub fn fchownat( + dirfd: c_int, + pathname: *const c_char, + owner: crate::uid_t, + group: crate::gid_t, + flags: c_int, + ) -> c_int; } extern "C" { @@ -1246,6 +1637,7 @@ extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; pub fn pthread_exit(value: *mut c_void) -> !; pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int; pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; @@ -1292,6 +1684,7 @@ extern "C" { pub fn usleep(secs: crate::useconds_t) -> c_int; pub fn putenv(string: *mut c_char) -> c_int; pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + pub fn localeconv() -> *mut lconv; pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; pub fn sigpending(set: *mut sigset_t) -> c_int; @@ -1309,7 +1702,19 @@ extern "C" { pub fn setlogmask(maskpri: c_int) -> c_int; pub fn syslog(priority: c_int, message: *const c_char, ...); pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; + pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; + pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t; + pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int; + + pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; + + // sys/stat.h + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; + // utime.h + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; } extern "C" { @@ -1719,6 +2124,9 @@ extern "C" { // unistd.h pub fn getppid() -> pid_t; + // unistd.h + pub fn setpgid(pid: pid_t, pgid: pid_t) -> pid_t; + // wait.h pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; @@ -1823,6 +2231,9 @@ extern "C" { // signal.h pub fn sigemptyset(__set: *mut sigset_t) -> c_int; + pub fn sigfillset(set: *mut sigset_t) -> c_int; + pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; + pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int; // pthread.h for kernel // signal.h for user @@ -1941,6 +2352,9 @@ safe_f! { pub const fn WEXITSTATUS(status: c_int) -> c_int { status & 0xFF } + pub const fn WIFCONTINUED(status: c_int) -> c_int { + (status >> 24) & 0xFF + } pub const fn WTERMSIG(status: c_int) -> c_int { (status >> 8) & 0xFF } From d597864924ed9a42a8f4150407376809a8c159a5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 29 Oct 2025 03:28:44 -0500 Subject: [PATCH 29/37] VxWorks: Mention that the release ID represents minor+patch Link: https://github.com/rust-lang/libc/pull/4781#discussion_r2471685324 (backport ) (cherry picked from commit 5a1ced6e3b45e3012ef983dd8baeea40433cf135) --- build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index e41c7aa21cd3a..b2c63f673c4db 100644 --- a/build.rs +++ b/build.rs @@ -281,8 +281,10 @@ fn emcc_version_code() -> Option { Some(major * 10000 + minor * 100 + patch) } +/// Retrieve the VxWorks release version from the environment variable set by the VxWorks build +/// environment, in `(minor, patch)` form. Currently the only major version supported by Rust +/// is 7. fn vxworks_version_code() -> Option<(u32, u32)> { - // Retrieve the VxWorks release version from the environment variable set by the VxWorks build environment let version = env::var("WIND_RELEASE_ID").ok()?; let mut pieces = version.trim().split(['.']); From 0f00b8c238329558dc38baad4510b1df8dd376e5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 17:54:47 -0400 Subject: [PATCH 30/37] doc: Fix rustdoc `bare_urls` warnings (backport ) (cherry picked from commit 91fc98caa6ac1120db4bd82469398995a7775c33) --- src/new/apple_libc/signal.rs | 2 +- src/new/apple_xnu/arm/_mcontext.rs | 2 +- src/new/apple_xnu/i386/_mcontext.rs | 2 +- src/new/apple_xnu/mach/arm/_structs.rs | 2 +- src/new/apple_xnu/mach/i386/_structs.rs | 2 +- src/new/apple_xnu/mach/machine/_structs.rs | 2 +- src/new/apple_xnu/mach/mod.rs | 2 +- src/new/apple_xnu/sys/mod.rs | 2 +- src/new/apple_xnu/sys/signal.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/new/apple_libc/signal.rs b/src/new/apple_libc/signal.rs index 971c47318c041..b5f8d59b2d7f3 100644 --- a/src/new/apple_libc/signal.rs +++ b/src/new/apple_libc/signal.rs @@ -1,5 +1,5 @@ //! Header: `signal.h` //! -//! https://github.com/apple-oss-distributions/Libc/blob/main/include/signal.h +//! pub use crate::sys::signal::*; diff --git a/src/new/apple_xnu/arm/_mcontext.rs b/src/new/apple_xnu/arm/_mcontext.rs index e57bc4f8adb09..ae22f7a4ec777 100644 --- a/src/new/apple_xnu/arm/_mcontext.rs +++ b/src/new/apple_xnu/arm/_mcontext.rs @@ -1,6 +1,6 @@ //! Header: `arm/_mcontext.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/arm/_mcontext.h +//! pub use crate::mach::machine::_structs::*; diff --git a/src/new/apple_xnu/i386/_mcontext.rs b/src/new/apple_xnu/i386/_mcontext.rs index 8ca3b116d9f26..2b07ad1bf6e64 100644 --- a/src/new/apple_xnu/i386/_mcontext.rs +++ b/src/new/apple_xnu/i386/_mcontext.rs @@ -1,6 +1,6 @@ //! Header: `i386/_mcontext.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/i386/_mcontext.h +//! pub use crate::mach::machine::_structs::*; diff --git a/src/new/apple_xnu/mach/arm/_structs.rs b/src/new/apple_xnu/mach/arm/_structs.rs index d8d3b958ad5dd..c0ebce437aedd 100644 --- a/src/new/apple_xnu/mach/arm/_structs.rs +++ b/src/new/apple_xnu/mach/arm/_structs.rs @@ -1,6 +1,6 @@ //! Header: `arm/_structs.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h +//! #[cfg(target_arch = "arm")] use crate::prelude::*; diff --git a/src/new/apple_xnu/mach/i386/_structs.rs b/src/new/apple_xnu/mach/i386/_structs.rs index ea274e26a6885..15822f7710de8 100644 --- a/src/new/apple_xnu/mach/i386/_structs.rs +++ b/src/new/apple_xnu/mach/i386/_structs.rs @@ -1,6 +1,6 @@ //! Header: `i386/_structs.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/i386/_structs.h +//! use crate::prelude::*; diff --git a/src/new/apple_xnu/mach/machine/_structs.rs b/src/new/apple_xnu/mach/machine/_structs.rs index 47df1005c86f8..6acae8d9acbd7 100644 --- a/src/new/apple_xnu/mach/machine/_structs.rs +++ b/src/new/apple_xnu/mach/machine/_structs.rs @@ -1,6 +1,6 @@ //! Header: `mach/machine/_structs.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/machine/_structs.h +//! cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { diff --git a/src/new/apple_xnu/mach/mod.rs b/src/new/apple_xnu/mach/mod.rs index d5fbee83e970e..90751260a7a7c 100644 --- a/src/new/apple_xnu/mach/mod.rs +++ b/src/new/apple_xnu/mach/mod.rs @@ -1,6 +1,6 @@ //! Directory: `mach/` //! -//! https://github.com/apple-oss-distributions/xnu/tree/main/osfmk/mach +//! /// Directory: `mach/arm` #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] diff --git a/src/new/apple_xnu/sys/mod.rs b/src/new/apple_xnu/sys/mod.rs index 8fdbe2846b58b..5a75457926690 100644 --- a/src/new/apple_xnu/sys/mod.rs +++ b/src/new/apple_xnu/sys/mod.rs @@ -1,6 +1,6 @@ //! Directory: `sys/` //! -//! https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys +//! pub(crate) mod signal; diff --git a/src/new/apple_xnu/sys/signal.rs b/src/new/apple_xnu/sys/signal.rs index 8399c830dc8cd..844793e119b31 100644 --- a/src/new/apple_xnu/sys/signal.rs +++ b/src/new/apple_xnu/sys/signal.rs @@ -1,6 +1,6 @@ //! Header: `sys/signal.h` //! -//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/signal.h +//! pub use crate::machine::_mcontext::*; pub use crate::sys::_types::_ucontext::*; From b06e47537575383b92f64452e9b64df5e2622d4d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 17:47:44 -0400 Subject: [PATCH 31/37] reorg: Introduce a posix/unistd module Create a module for common Posix-specified definitions in `unistd.h`, which are then reexported by relevant targets. Populate this with the `STD{IN,OUT,ERR}_FILENO` constants to start, which have posix-specified values. Link: https://pubs.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html (backport ) (cherry picked from commit 9cf1a1c1ce89669860e3e45a28f6e8dea6573cb1) --- src/fuchsia/mod.rs | 3 -- src/new/aix/mod.rs | 2 ++ src/new/aix/unistd.rs | 7 +++++ src/new/apple_libc/mod.rs | 3 ++ src/new/apple_libc/unistd.rs | 7 +++++ src/new/bionic_libc/mod.rs | 1 + src/new/bionic_libc/unistd.rs | 7 +++++ src/new/common/mod.rs | 13 +++++---- src/new/common/posix/mod.rs | 2 ++ src/new/common/posix/unistd.rs | 9 ++++++ src/new/cygwin/mod.rs | 2 ++ src/new/cygwin/unistd.rs | 7 +++++ src/new/dragonfly/mod.rs | 2 ++ src/new/dragonfly/unistd.rs | 7 +++++ src/new/emscripten/mod.rs | 2 ++ src/new/emscripten/unistd.rs | 7 +++++ src/new/freebsd/mod.rs | 2 ++ src/new/freebsd/unistd.rs | 7 +++++ src/new/fuchsia/mod.rs | 2 ++ src/new/fuchsia/unistd.rs | 7 +++++ src/new/glibc/mod.rs | 2 ++ src/new/glibc/unistd.rs | 7 +++++ src/new/haiku/mod.rs | 2 ++ src/new/haiku/unistd.rs | 7 +++++ src/new/illumos/mod.rs | 2 ++ src/new/illumos/unistd.rs | 7 +++++ src/new/mod.rs | 52 +++++++++++++++++++-------------- src/new/musl/mod.rs | 2 ++ src/new/musl/unistd.rs | 7 +++++ src/new/netbsd/mod.rs | 2 ++ src/new/netbsd/unistd.rs | 7 +++++ src/new/newlib/mod.rs | 2 ++ src/new/newlib/unistd.rs | 7 +++++ src/new/nto/mod.rs | 2 ++ src/new/nto/unistd.rs | 7 +++++ src/new/nuttx/mod.rs | 2 ++ src/new/nuttx/unistd.rs | 7 +++++ src/new/openbsd/mod.rs | 2 ++ src/new/openbsd/unistd.rs | 7 +++++ src/new/relibc/mod.rs | 2 ++ src/new/relibc/unistd.rs | 7 +++++ src/new/sgx/mod.rs | 2 +- src/new/sgx/unistd.rs | 7 +++++ src/new/solaris/mod.rs | 2 ++ src/new/solaris/unistd.rs | 7 +++++ src/new/uclibc/mod.rs | 2 ++ src/new/uclibc/unistd.rs | 7 +++++ src/new/vita/mod.rs | 2 ++ src/new/vita/unistd.rs | 7 +++++ src/new/vxworks/mod.rs | 2 ++ src/new/vxworks/unistd.rs | 7 +++++ src/unix/aix/mod.rs | 3 -- src/unix/bsd/apple/mod.rs | 3 -- src/unix/bsd/freebsdlike/mod.rs | 3 -- src/unix/bsd/netbsdlike/mod.rs | 3 -- src/unix/cygwin/mod.rs | 3 -- src/unix/haiku/mod.rs | 3 -- src/unix/hurd/mod.rs | 3 -- src/unix/linux_like/mod.rs | 3 -- src/unix/newlib/mod.rs | 4 --- src/unix/nto/mod.rs | 4 --- src/unix/nuttx/mod.rs | 3 -- src/unix/redox/mod.rs | 3 -- src/unix/solarish/mod.rs | 3 -- src/vxworks/mod.rs | 4 --- 65 files changed, 254 insertions(+), 77 deletions(-) create mode 100644 src/new/aix/unistd.rs create mode 100644 src/new/apple_libc/unistd.rs create mode 100644 src/new/bionic_libc/unistd.rs create mode 100644 src/new/common/posix/unistd.rs create mode 100644 src/new/cygwin/unistd.rs create mode 100644 src/new/dragonfly/unistd.rs create mode 100644 src/new/emscripten/unistd.rs create mode 100644 src/new/freebsd/unistd.rs create mode 100644 src/new/fuchsia/unistd.rs create mode 100644 src/new/glibc/unistd.rs create mode 100644 src/new/haiku/unistd.rs create mode 100644 src/new/illumos/unistd.rs create mode 100644 src/new/musl/unistd.rs create mode 100644 src/new/netbsd/unistd.rs create mode 100644 src/new/newlib/unistd.rs create mode 100644 src/new/nto/unistd.rs create mode 100644 src/new/nuttx/unistd.rs create mode 100644 src/new/openbsd/unistd.rs create mode 100644 src/new/relibc/unistd.rs create mode 100644 src/new/sgx/unistd.rs create mode 100644 src/new/solaris/unistd.rs create mode 100644 src/new/uclibc/unistd.rs create mode 100644 src/new/vita/unistd.rs create mode 100644 src/new/vxworks/unistd.rs diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 5a3d0784c434c..134a2faf87966 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -1468,9 +1468,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; diff --git a/src/new/aix/mod.rs b/src/new/aix/mod.rs index 79645f12d7360..c99b206b71688 100644 --- a/src/new/aix/mod.rs +++ b/src/new/aix/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers are not public //! * Manual pages: (under "Technical reference" for that version) + +pub(crate) mod unistd; diff --git a/src/new/aix/unistd.rs b/src/new/aix/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/aix/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/apple_libc/mod.rs b/src/new/apple_libc/mod.rs index f53b8baa38ea1..d7fcc90d12ff8 100644 --- a/src/new/apple_libc/mod.rs +++ b/src/new/apple_libc/mod.rs @@ -1,3 +1,6 @@ //! Entrypoint for Apple headers, usually found as part of the Xcode SDK. +//! +//! pub(crate) mod signal; +pub(crate) mod unistd; diff --git a/src/new/apple_libc/unistd.rs b/src/new/apple_libc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/apple_libc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/bionic_libc/mod.rs b/src/new/bionic_libc/mod.rs index 2863b72cc2ed9..b608e2f123c96 100644 --- a/src/new/bionic_libc/mod.rs +++ b/src/new/bionic_libc/mod.rs @@ -3,3 +3,4 @@ //! pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/src/new/bionic_libc/unistd.rs b/src/new/bionic_libc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/bionic_libc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/common/mod.rs b/src/new/common/mod.rs index cb0588ca26100..acb18917c8998 100644 --- a/src/new/common/mod.rs +++ b/src/new/common/mod.rs @@ -16,7 +16,7 @@ target_os = "netbsd", target_os = "openbsd", ))] -mod bsd; +pub(crate) mod bsd; #[cfg(any( target_os = "android", @@ -24,15 +24,16 @@ mod bsd; target_os = "l4re", target_os = "linux", ))] -mod linux_like; +pub(crate) mod linux_like; #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] -mod freebsd_like; +pub(crate) mod freebsd_like; #[cfg(any(target_os = "netbsd", target_os = "openbsd"))] -mod netbsd_like; +pub(crate) mod netbsd_like; #[cfg(any(target_os = "illumos", target_os = "solaris"))] -mod solarish; +pub(crate) mod solarish; -mod posix; +#[cfg(target_family = "unix")] +pub(crate) mod posix; diff --git a/src/new/common/posix/mod.rs b/src/new/common/posix/mod.rs index cb33296a9c656..454b840404c95 100644 --- a/src/new/common/posix/mod.rs +++ b/src/new/common/posix/mod.rs @@ -1 +1,3 @@ //! POSIX APIs that are used by a number of platforms + +pub(crate) mod unistd; diff --git a/src/new/common/posix/unistd.rs b/src/new/common/posix/unistd.rs new file mode 100644 index 0000000000000..0c02cbaa699f4 --- /dev/null +++ b/src/new/common/posix/unistd.rs @@ -0,0 +1,9 @@ +//! Header: `unistd.h` +//! +//! + +use crate::prelude::*; + +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; diff --git a/src/new/cygwin/mod.rs b/src/new/cygwin/mod.rs index 29d62f02f9fee..356ae587653df 100644 --- a/src/new/cygwin/mod.rs +++ b/src/new/cygwin/mod.rs @@ -1,3 +1,5 @@ //! Cygwin libc. //! //! * Headers: + +pub(crate) mod unistd; diff --git a/src/new/cygwin/unistd.rs b/src/new/cygwin/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/cygwin/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/dragonfly/mod.rs b/src/new/dragonfly/mod.rs index 9ea26f522be66..4a1b2c4998d07 100644 --- a/src/new/dragonfly/mod.rs +++ b/src/new/dragonfly/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers: //! * Manual pages: + +pub(crate) mod unistd; diff --git a/src/new/dragonfly/unistd.rs b/src/new/dragonfly/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/dragonfly/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/emscripten/mod.rs b/src/new/emscripten/mod.rs index e58a3aceada16..fec0fe3bfdd43 100644 --- a/src/new/emscripten/mod.rs +++ b/src/new/emscripten/mod.rs @@ -1,3 +1,5 @@ //! Emscripten libc. //! //! * Headers: + +pub(crate) mod unistd; diff --git a/src/new/emscripten/unistd.rs b/src/new/emscripten/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/emscripten/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/freebsd/mod.rs b/src/new/freebsd/mod.rs index a1241c7a68cef..87c2e487560be 100644 --- a/src/new/freebsd/mod.rs +++ b/src/new/freebsd/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers: //! * Symbol map: + +pub(crate) mod unistd; diff --git a/src/new/freebsd/unistd.rs b/src/new/freebsd/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/freebsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/fuchsia/mod.rs b/src/new/fuchsia/mod.rs index c1d275c95b3f6..b3a908349bf3b 100644 --- a/src/new/fuchsia/mod.rs +++ b/src/new/fuchsia/mod.rs @@ -1,2 +1,4 @@ //! Fuschia libc. // FIXME(fuchsia): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/fuchsia/unistd.rs b/src/new/fuchsia/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/fuchsia/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 8714820906414..9c4c11412dcc5 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers: (official) //! * Headers: (mirror) + +pub(crate) mod unistd; diff --git a/src/new/glibc/unistd.rs b/src/new/glibc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/glibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/haiku/mod.rs b/src/new/haiku/mod.rs index c119b67376269..a565afe10d9ce 100644 --- a/src/new/haiku/mod.rs +++ b/src/new/haiku/mod.rs @@ -1,2 +1,4 @@ //! Haiku OS libc. // FIXME(haiku): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/haiku/unistd.rs b/src/new/haiku/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/haiku/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/illumos/mod.rs b/src/new/illumos/mod.rs index 66f6cb1ffd3c8..83d15da8801f2 100644 --- a/src/new/illumos/mod.rs +++ b/src/new/illumos/mod.rs @@ -1,2 +1,4 @@ //! Illumos libc. // FIXME(illumos): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/illumos/unistd.rs b/src/new/illumos/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/illumos/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/mod.rs b/src/new/mod.rs index 27f232cb56882..f83339ecf0fd1 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -43,7 +43,7 @@ mod common; cfg_if! { if #[cfg(target_os = "aix")] { mod aix; - // pub(crate) use aix::*; + pub(crate) use aix::*; } else if #[cfg(target_os = "android")] { mod bionic_libc; pub(crate) use bionic_libc::*; @@ -54,25 +54,25 @@ cfg_if! { pub(crate) use apple_xnu::*; } else if #[cfg(target_os = "cygwin")] { mod cygwin; - // pub(crate) use cygwin::*; + pub(crate) use cygwin::*; } else if #[cfg(target_os = "dragonfly")] { mod dragonfly; - // pub(crate) use dragonfly::*; + pub(crate) use dragonfly::*; } else if #[cfg(target_os = "emscripten")] { mod emscripten; - // pub(crate) use emscripten::*; + pub(crate) use emscripten::*; } else if #[cfg(target_os = "espidf")] { mod espidf; // pub(crate) use espidf::*; } else if #[cfg(target_os = "freebsd")] { mod freebsd; - // pub(crate) use freebsd::*; + pub(crate) use freebsd::*; } else if #[cfg(target_os = "fuchsia")] { mod fuchsia; - // pub(crate) use fuchsia::*; + pub(crate) use fuchsia::*; } else if #[cfg(target_os = "haiku")] { mod haiku; - // pub(crate) use haiku::*; + pub(crate) use haiku::*; } else if #[cfg(target_os = "hermit")] { mod hermit_abi; // pub(crate) use hermit_abi::*; @@ -84,7 +84,7 @@ cfg_if! { // pub(crate) use hurd::*; } else if #[cfg(target_os = "illumos")] { mod illumos; - // pub(crate) use illumos::*; + pub(crate) use illumos::*; } else if #[cfg(target_os = "l4re")] { mod l4re; // pub(crate) use l4re::*; @@ -93,25 +93,25 @@ cfg_if! { pub(crate) use linux_uapi::*; } else if #[cfg(target_os = "netbsd")] { mod netbsd; - // pub(crate) use netbsd::*; + pub(crate) use netbsd::*; } else if #[cfg(target_os = "nto")] { mod nto; - // pub(crate) use nto::*; + pub(crate) use nto::*; } else if #[cfg(target_os = "nuttx")] { mod nuttx; - // pub(crate) use nuttx::*; + pub(crate) use nuttx::*; } else if #[cfg(target_os = "openbsd")] { mod openbsd; - // pub(crate) use openbsd::*; + pub(crate) use openbsd::*; } else if #[cfg(target_os = "redox")] { mod redox; // pub(crate) use redox::*; } else if #[cfg(target_os = "rtems")] { mod rtems; - // pub(crate) use rtems::*; + pub(crate) use rtems::*; } else if #[cfg(target_os = "solaris")] { mod solaris; - // pub(crate) use solaris::*; + pub(crate) use solaris::*; } else if #[cfg(target_os = "solid_asp3")] { mod solid; // pub(crate) use solid::*; @@ -126,7 +126,7 @@ cfg_if! { // pub(crate) use vita::*; } else if #[cfg(target_os = "vxworks")] { mod vxworks; - // pub(crate) use vxworks::*; + pub(crate) use vxworks::*; } else if #[cfg(target_os = "wasi")] { mod wasi; // pub(crate) use wasi::*; @@ -141,24 +141,29 @@ cfg_if! { // Multi-platform libc cfg_if! { - if #[cfg(target_env = "gnu")] { + // FIXME(vxworks): vxworks sets `target_env = "gnu"` but maybe shouldn't. + if #[cfg(all( + target_family = "unix", + target_env = "gnu", + not(target_os = "vxworks") + ))] { mod glibc; - // pub(crate) use glibc::*; - } else if #[cfg(target_env = "musl")] { + pub(crate) use glibc::*; + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { mod musl; - // pub(crate) use musl::*; + pub(crate) use musl::*; } else if #[cfg(target_env = "newlib")] { mod newlib; - // pub(crate) use newlib::*; + pub(crate) use newlib::*; } else if #[cfg(target_env = "relibc")] { mod relibc; - // pub(crate) use relibc::*; + pub(crate) use relibc::*; } else if #[cfg(target_env = "sgx")] { mod sgx; // pub(crate) use sgx::*; } else if #[cfg(target_env = "uclibc")] { mod uclibc; - // pub(crate) use uclibc::*; + pub(crate) use uclibc::*; } } @@ -176,3 +181,6 @@ cfg_if! { pub use signal::*; } } + +#[cfg(target_family = "unix")] +pub use unistd::*; diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index 49f9abae21fb7..7b1f31e340a1f 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers: (official) //! * Headers: (mirror) + +pub(crate) mod unistd; diff --git a/src/new/musl/unistd.rs b/src/new/musl/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/musl/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs index 14b6a5f869e8f..b43e7aeb088d2 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -1,3 +1,5 @@ //! NetBSD libc. //! //! * Manual pages: + +pub(crate) mod unistd; diff --git a/src/new/netbsd/unistd.rs b/src/new/netbsd/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/netbsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/newlib/mod.rs b/src/new/newlib/mod.rs index d5564cafcfd50..b5c7e3dc73a0a 100644 --- a/src/new/newlib/mod.rs +++ b/src/new/newlib/mod.rs @@ -1,2 +1,4 @@ //! Newlib libc. // FIXME(newlib): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/newlib/unistd.rs b/src/new/newlib/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/newlib/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/nto/mod.rs b/src/new/nto/mod.rs index 8fa2d814eb8df..df8ec183bd789 100644 --- a/src/new/nto/mod.rs +++ b/src/new/nto/mod.rs @@ -1,2 +1,4 @@ //! QNX Neutrino libc. // FIXME(nto): link to manpages needed. + +pub(crate) mod unistd; diff --git a/src/new/nto/unistd.rs b/src/new/nto/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/nto/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/nuttx/mod.rs b/src/new/nuttx/mod.rs index 89b9c05e849bd..513c945dbfd9b 100644 --- a/src/new/nuttx/mod.rs +++ b/src/new/nuttx/mod.rs @@ -1,2 +1,4 @@ //! RTEMS libc. // FIXME(nuttx): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/nuttx/unistd.rs b/src/new/nuttx/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/nuttx/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/openbsd/mod.rs b/src/new/openbsd/mod.rs index f97044effe76c..d5debb80f3928 100644 --- a/src/new/openbsd/mod.rs +++ b/src/new/openbsd/mod.rs @@ -2,3 +2,5 @@ //! //! * Headers: //! * Manual pages: + +pub(crate) mod unistd; diff --git a/src/new/openbsd/unistd.rs b/src/new/openbsd/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/openbsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/relibc/mod.rs b/src/new/relibc/mod.rs index baf26912ec7f0..d2449123218a1 100644 --- a/src/new/relibc/mod.rs +++ b/src/new/relibc/mod.rs @@ -1,3 +1,5 @@ //! Redox OS libc. //! //! * Headers: + +pub(crate) mod unistd; diff --git a/src/new/relibc/unistd.rs b/src/new/relibc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/relibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/sgx/mod.rs b/src/new/sgx/mod.rs index 8b137891791fe..8c15dadb4a0b8 100644 --- a/src/new/sgx/mod.rs +++ b/src/new/sgx/mod.rs @@ -1 +1 @@ - +//! Fortanix SGX. diff --git a/src/new/sgx/unistd.rs b/src/new/sgx/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/sgx/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/solaris/mod.rs b/src/new/solaris/mod.rs index b5d55492995de..97ae47333deb4 100644 --- a/src/new/solaris/mod.rs +++ b/src/new/solaris/mod.rs @@ -1,3 +1,5 @@ //! Solaris libc. //! //! * Manual pages: (under "Reference Manuals") + +pub(crate) mod unistd; diff --git a/src/new/solaris/unistd.rs b/src/new/solaris/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/solaris/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs index eda4b01d92d2c..4cb25389c91bf 100644 --- a/src/new/uclibc/mod.rs +++ b/src/new/uclibc/mod.rs @@ -2,3 +2,5 @@ //! //! * About: //! * Headers: (mirror) + +pub(crate) mod unistd; diff --git a/src/new/uclibc/unistd.rs b/src/new/uclibc/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/uclibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/vita/mod.rs b/src/new/vita/mod.rs index 21205ebd046fb..38783a3f19fbc 100644 --- a/src/new/vita/mod.rs +++ b/src/new/vita/mod.rs @@ -1,2 +1,4 @@ //! VITASDK system library. // FIXME(vita): link to headers or manpages needed. + +pub(crate) mod unistd; diff --git a/src/new/vita/unistd.rs b/src/new/vita/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/vita/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/new/vxworks/mod.rs b/src/new/vxworks/mod.rs index a3116fce03803..65630565e53e0 100644 --- a/src/new/vxworks/mod.rs +++ b/src/new/vxworks/mod.rs @@ -1,2 +1,4 @@ //! VxWorks libc. // FIXME(vxworks): link to headers needed. + +pub(crate) mod unistd; diff --git a/src/new/vxworks/unistd.rs b/src/new/vxworks/unistd.rs new file mode 100644 index 0000000000000..8d55ee5823315 --- /dev/null +++ b/src/new/vxworks/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index f4dd26f6aba37..0b91a22cae8cc 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2275,9 +2275,6 @@ pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 11; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 12; // unistd.h -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const _POSIX_VDISABLE: c_int = 0xff; pub const _PC_LINK_MAX: c_int = 11; pub const _PC_MAX_CANON: c_int = 12; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index ec05791d9aed0..e85323c73227a 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2932,9 +2932,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 453d3e0734f05..98996f260709f 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -572,9 +572,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 294d334490bc1..dc5e4528cf299 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -191,9 +191,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 028ac80cb52d3..0e5faff17fb8f 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1325,9 +1325,6 @@ pub const X_OK: c_int = 1; pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const _SC_ARG_MAX: c_int = 0; pub const _SC_CHILD_MAX: c_int = 1; pub const _SC_CLK_TCK: c_int = 2; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 98764c497f0f6..7c3f07e0ad9be 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -746,9 +746,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index acd0981b1a8b2..a0be74022e251 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1172,9 +1172,6 @@ pub const SHM_REMAP: c_int = 0o40000; pub const SHM_LOCK: c_int = 11; pub const SHM_UNLOCK: c_int = 12; // unistd.h -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const __FD_SETSIZE: usize = 256; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 0b1f376233a62..15e3597614e84 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -540,9 +540,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 0193083f4e63b..abec6d4991c37 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -557,10 +557,6 @@ cfg_if! { pub const RTLD_LAZY: c_int = 0x1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; - pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index a81c210c80cf3..0ac1e682268f8 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -1054,10 +1054,6 @@ pub const X_OK: c_int = 1; pub const W_OK: c_int = 2; pub const R_OK: c_int = 4; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; - pub const SIGHUP: c_int = 1; pub const SIGINT: c_int = 2; pub const SIGQUIT: c_int = 3; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index fe7c6ecb3007a..79e3f170e0c1f 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -509,9 +509,6 @@ pub const TCP_NODELAY: i32 = 0x10; pub const FIONBIO: i32 = 0x30a; // unistd.h -pub const STDIN_FILENO: i32 = 0; -pub const STDOUT_FILENO: i32 = 1; -pub const STDERR_FILENO: i32 = 2; pub const _SC_PAGESIZE: i32 = 0x36; pub const _SC_THREAD_STACK_MIN: i32 = 0x58; pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 55a8c15a234e2..9567099e59c42 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1066,9 +1066,6 @@ pub const _IONBF: c_int = 2; pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const _PC_LINK_MAX: c_int = 0; pub const _PC_MAX_CANON: c_int = 1; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index f78b09a3db63a..fd52e353ef1d6 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1146,9 +1146,6 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; pub const F_TLOCK: c_int = 2; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index fcb74e26135bd..5f22a7cee7297 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -640,10 +640,6 @@ cfg_if! { } } -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; - pub const EXIT_SUCCESS: c_int = 0; pub const EXIT_FAILURE: c_int = 1; From 2d42e177ead341b2013c01822df6466ee9936632 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 8 Jul 2025 04:04:58 +0000 Subject: [PATCH 32/37] 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. (backport ) (cherry picked from commit 0399c4ed2ae4d3f7c3c6728b894881cd338e9520) --- 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 afd9fe3396180..b877fc296d5d1 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -153,27 +153,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 9a1041de30cc0e1f47165550fb82b24d1b1e3628 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 30 Oct 2025 03:17:03 -0500 Subject: [PATCH 33/37] ci: Skip hexagon-unknown-linux-musl This hits an error about a duplicate fma symbol while building std. (backport ) (cherry picked from commit 5a9e1db32bb09a0b23e257b65e5b5ccdf754d00e) --- 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), From 8f2e6a73299c684ff6b444d7fd2af631f3f2ff9a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 30 Oct 2025 15:08:02 -0500 Subject: [PATCH 34/37] ci: Re-enable ohos check builds (backport ) (cherry picked from commit 4bc2673628b515e75f660b6d6d101d066b92a972) --- ci/verify-build.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index 7e52e749440b5..483dc5cfa96fb 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -68,7 +68,6 @@ def __post_init__(self): FREEBSD_VERSIONS = [11, 12, 13, 14, 15] -# FIXME(ohos): CI fails with warnings TARGETS = [ # Tier 1 Target("aarch64-apple-darwin"), @@ -83,11 +82,11 @@ def __post_init__(self): # Tier 2 with host tools Target("aarch64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), Target("aarch64-unknown-linux-musl"), - # Target("aarch64-unknown-linux-ohos"), + Target("aarch64-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), Target("arm-unknown-linux-gnueabi"), Target("arm-unknown-linux-gnueabihf"), Target("armv7-unknown-linux-gnueabihf"), - # Target("armv7-unknown-linux-ohos"), + Target("armv7-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), Target("i686-pc-windows-gnu"), Target("loongarch64-unknown-linux-gnu", min_toolchain=Toolchain.STABLE), Target("loongarch64-unknown-linux-musl", min_toolchain=Toolchain.STABLE), @@ -104,7 +103,7 @@ def __post_init__(self): Target("x86_64-unknown-freebsd"), Target("x86_64-unknown-illumos"), Target("x86_64-unknown-linux-musl"), - # Target("x86_64-unknown-linux-ohos"), + Target("x86_64-unknown-linux-ohos", min_toolchain=Toolchain.STABLE), Target("x86_64-unknown-netbsd"), # # Tier 2 without host tools From 31ead46a7e4d2def4498297004dd2943a6d53549 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 30 Oct 2025 15:08:02 -0500 Subject: [PATCH 35/37] ohos: Don't emit duplicate lfs64 definitions The musl module is enabled on ohos, so these are duplicates. (backport ) (cherry picked from commit b30e7144278263f9fe12ad6d22c9713eeeb5dd5c) --- src/unix/linux_like/linux/mod.rs | 4 ++-- src/unix/linux_like/mod.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 45031ab2aa32c..3d2f21a53062e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1187,7 +1187,7 @@ s! { size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T], } - #[cfg(not(target_env = "musl"))] + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] #[repr(align(8))] pub struct fanotify_event_metadata { pub event_len: __u32, @@ -6752,7 +6752,7 @@ extern "C" { // // * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones cfg_if! { - if #[cfg(not(target_env = "musl"))] { + if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] { extern "C" { pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 15e3597614e84..b431643dfa3e4 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -2071,7 +2071,11 @@ extern "C" { // * musl and Emscripten has 64-bit versions only so aliases the LFS64 symbols to the standard ones // * ulibc doesn't have preadv64/pwritev64 cfg_if! { - if #[cfg(not(any(target_env = "musl", target_os = "emscripten")))] { + if #[cfg(not(any( + target_env = "musl", + target_env = "ohos", + target_os = "emscripten", + )))] { extern "C" { pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; @@ -2131,7 +2135,8 @@ cfg_if! { if #[cfg(not(any( target_env = "uclibc", target_env = "musl", - target_os = "emscripten" + target_env = "ohos", + target_os = "emscripten", )))] { extern "C" { pub fn preadv64( From 04ca756e451dabb93bcf5c87e039e4f641942bec Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 8 Jul 2025 02:38:40 +0000 Subject: [PATCH 36/37] musl: Switch to the new structure for `socket.h` Move `struct msghdr`, `struct cmsghdr`, `sendmmsg`, and `recvmmsg` over at this time, as well as two `SOCK_*` constants that were in the musl module. Link: https://github.com/kraj/musl/blob/9f204467e88c75e36105d1359951c5857c20fe0b/include/sys/socket.h (backport ) (cherry picked from commit 564e0efe817e8d2e147c21fe2227c2d78eff44ff) --- src/new/mod.rs | 10 ++- src/new/musl/arch/generic/mod.rs | 7 +++ src/new/musl/arch/mips/bits/socket.rs | 4 ++ src/new/musl/arch/mips/mod.rs | 7 +++ src/new/musl/arch/mips64/bits/socket.rs | 4 ++ src/new/musl/arch/mips64/mod.rs | 7 +++ src/new/musl/arch/mod.rs | 10 +++ src/new/musl/mod.rs | 24 +++++++ src/new/musl/sys/socket.rs | 63 +++++++++++++++++++ src/unix/linux_like/linux/mod.rs | 14 +++-- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 3 - src/unix/linux_like/linux/musl/b32/hexagon.rs | 2 - .../linux_like/linux/musl/b32/mips/mod.rs | 3 - src/unix/linux_like/linux/musl/b32/mod.rs | 16 ----- src/unix/linux_like/linux/musl/b32/powerpc.rs | 3 - .../linux_like/linux/musl/b32/riscv32/mod.rs | 2 - src/unix/linux_like/linux/musl/b32/x86/mod.rs | 3 - .../linux_like/linux/musl/b64/aarch64/mod.rs | 3 - .../linux/musl/b64/loongarch64/mod.rs | 3 - src/unix/linux_like/linux/musl/b64/mips64.rs | 3 - src/unix/linux_like/linux/musl/b64/mod.rs | 28 --------- .../linux_like/linux/musl/b64/powerpc64.rs | 3 - .../linux_like/linux/musl/b64/riscv64/mod.rs | 3 - src/unix/linux_like/linux/musl/b64/s390x.rs | 3 - .../linux_like/linux/musl/b64/wasm32/mod.rs | 3 - .../linux_like/linux/musl/b64/x86_64/mod.rs | 3 - src/unix/linux_like/linux/musl/mod.rs | 14 ----- 27 files changed, 144 insertions(+), 104 deletions(-) create mode 100644 src/new/musl/arch/generic/mod.rs create mode 100644 src/new/musl/arch/mips/bits/socket.rs create mode 100644 src/new/musl/arch/mips/mod.rs create mode 100644 src/new/musl/arch/mips64/bits/socket.rs create mode 100644 src/new/musl/arch/mips64/mod.rs create mode 100644 src/new/musl/arch/mod.rs create mode 100644 src/new/musl/sys/socket.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 35a493df4b152..1846ada479fba 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -150,6 +150,7 @@ cfg_if! { mod glibc; pub(crate) use glibc::*; } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + // OhOS also uses the musl libc mod musl; pub(crate) use musl::*; } else if #[cfg(target_env = "newlib")] { @@ -167,7 +168,7 @@ cfg_if! { } } -// Headers we export +// Per-OS headers we export cfg_if! { if #[cfg(target_os = "android")] { pub use sys::socket::*; @@ -184,5 +185,12 @@ cfg_if! { } } +// Per-env headers we export +cfg_if! { + if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub use sys::socket::*; + } +} + #[cfg(target_family = "unix")] pub use unistd::*; diff --git a/src/new/musl/arch/generic/mod.rs b/src/new/musl/arch/generic/mod.rs new file mode 100644 index 0000000000000..ac02505c882bf --- /dev/null +++ b/src/new/musl/arch/generic/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/generic/` +//! +//! + +pub(crate) mod bits { + // Currently unused +} diff --git a/src/new/musl/arch/mips/bits/socket.rs b/src/new/musl/arch/mips/bits/socket.rs new file mode 100644 index 0000000000000..77b53e489c3d8 --- /dev/null +++ b/src/new/musl/arch/mips/bits/socket.rs @@ -0,0 +1,4 @@ +use crate::prelude::*; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; diff --git a/src/new/musl/arch/mips/mod.rs b/src/new/musl/arch/mips/mod.rs new file mode 100644 index 0000000000000..2f02036d254ce --- /dev/null +++ b/src/new/musl/arch/mips/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/mips/` +//! +//! + +pub(crate) mod bits { + pub(crate) mod socket; +} diff --git a/src/new/musl/arch/mips64/bits/socket.rs b/src/new/musl/arch/mips64/bits/socket.rs new file mode 100644 index 0000000000000..77b53e489c3d8 --- /dev/null +++ b/src/new/musl/arch/mips64/bits/socket.rs @@ -0,0 +1,4 @@ +use crate::prelude::*; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; diff --git a/src/new/musl/arch/mips64/mod.rs b/src/new/musl/arch/mips64/mod.rs new file mode 100644 index 0000000000000..6a45b067b998e --- /dev/null +++ b/src/new/musl/arch/mips64/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/mips64/` +//! +//! + +pub(crate) mod bits { + pub(crate) mod socket; +} diff --git a/src/new/musl/arch/mod.rs b/src/new/musl/arch/mod.rs new file mode 100644 index 0000000000000..514d7b4bdfea7 --- /dev/null +++ b/src/new/musl/arch/mod.rs @@ -0,0 +1,10 @@ +//! Source directory: `arch/` +//! +//! + +pub(crate) mod generic; + +#[cfg(target_arch = "mips")] +pub(crate) mod mips; +#[cfg(target_arch = "mips64")] +pub(crate) mod mips64; diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index 7b1f31e340a1f..d6297a8d27dd8 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -3,4 +3,28 @@ //! * Headers: (official) //! * Headers: (mirror) +// The musl build system includes `arch/$(ARCH)` (preferred if it exists) and `arch/generic` (used +// as the fallback). We can't exactly mirror this with glob exports, so instead we selectively +// reexport in a new module. +mod arch; + +pub(crate) mod bits { + cfg_if! { + if #[cfg(target_arch = "mips")] { + pub(crate) use super::arch::mips::bits::socket; + } else if #[cfg(target_arch = "mips64")] { + pub(crate) use super::arch::mips64::bits::socket; + } else { + // Reexports from generic will live here once we need them. + } + } +} + +/// Directory: `sys/` +/// +/// +pub(crate) mod sys { + pub(crate) mod socket; +} + pub(crate) mod unistd; diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs new file mode 100644 index 0000000000000..f7105c9bbca16 --- /dev/null +++ b/src/new/musl/sys/socket.rs @@ -0,0 +1,63 @@ +//! Header: `sys/socket.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + __pad1: c_int, + pub msg_iovlen: c_int, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + __pad1: c_int, + pub msg_control: *mut c_void, + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + __pad2: c_int, + pub msg_controllen: crate::socklen_t, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + __pad2: c_int, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + pub __pad1: c_int, + pub cmsg_len: crate::socklen_t, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + pub __pad1: c_int, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } +} + +extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + pub use crate::bits::socket::{ + SOCK_DGRAM, + SOCK_STREAM, + }; + } else { + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + } +} diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 3d2f21a53062e..ebbc9a44818e0 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5739,16 +5739,20 @@ f! { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); } - pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as usize) < size_of::() { - return core::ptr::null_mut::(); + pub fn CMSG_NXTHDR( + mhdr: *const crate::msghdr, + cmsg: *const crate::cmsghdr, + ) -> *mut crate::cmsghdr { + if ((*cmsg).cmsg_len as usize) < size_of::() { + return core::ptr::null_mut::(); } - let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; + let next = + (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut crate::cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.wrapping_offset(1)) as usize > max || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max { - core::ptr::null_mut::() + core::ptr::null_mut::() } else { next } diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index a04f05ea50db8..189a294ea624f 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -272,9 +272,6 @@ pub const MAP_NONBLOCK: c_int = 0x010000; pub const MAP_STACK: c_int = 0x020000; pub const MAP_SYNC: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; pub const ENOLCK: c_int = 37; diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index b687953554184..1c29114338adb 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -244,8 +244,6 @@ pub const SIGXFSZ: c_int = 25; pub const SIG_SETMASK: c_int = 2; // FIXME(musl) check these pub const SIG_BLOCK: c_int = 0x000000; pub const SIG_UNBLOCK: c_int = 0x01; -pub const SOCK_DGRAM: c_int = 2; -pub const SOCK_STREAM: c_int = 1; pub const SOL_CAIF: c_int = 278; pub const SOL_IUCV: c_int = 277; pub const SOL_KCM: c_int = 281; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 7564dcf612f9c..d8c3ee9d54736 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -338,9 +338,6 @@ pub const ENOTRECOVERABLE: c_int = 166; pub const EHWPOISON: c_int = 168; pub const ERFKILL: c_int = 167; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 8; pub const SA_NOCLDWAIT: c_int = 0x10000; diff --git a/src/unix/linux_like/linux/musl/b32/mod.rs b/src/unix/linux_like/linux/musl/b32/mod.rs index 00b3d7705090f..ac76d3c659700 100644 --- a/src/unix/linux_like/linux/musl/b32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mod.rs @@ -15,22 +15,6 @@ s! { __val: [c_ulong; 32], } - pub struct msghdr { - pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, - pub msg_iov: *mut crate::iovec, - pub msg_iovlen: c_int, - pub msg_control: *mut c_void, - pub msg_controllen: crate::socklen_t, - pub msg_flags: c_int, - } - - pub struct cmsghdr { - pub cmsg_len: crate::socklen_t, - pub cmsg_level: c_int, - pub cmsg_type: c_int, - } - pub struct sem_t { __val: [c_int; 4], } diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index a07dfda17794e..60305b3041013 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -223,9 +223,6 @@ pub const MAP_SYNC: c_int = 0x080000; pub const PTRACE_SYSEMU: c_int = 0x1d; pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 0x1e; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; pub const ENOLCK: c_int = 37; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index d78df7528d26f..04ecf1b46c42d 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -207,8 +207,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 4; pub const SA_NOCLDWAIT: c_int = 2; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index ae8b7d761dd6f..43ea2e88ff467 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -314,9 +314,6 @@ pub const MAP_NONBLOCK: c_int = 0x010000; pub const MAP_STACK: c_int = 0x020000; pub const MAP_SYNC: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const EDEADLK: c_int = 35; pub const ENAMETOOLONG: c_int = 36; pub const ENOLCK: c_int = 37; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 67151a8d37116..087e39001e84f 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -279,9 +279,6 @@ pub const MAP_STACK: c_int = 0x020000; pub const MAP_HUGETLB: c_int = 0x040000; pub const MAP_SYNC: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 6ae9637cb58c6..c151b0ec32046 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -573,9 +573,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 95dd37c889804..4d40637c0cb99 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -584,9 +584,6 @@ pub const MAP_NONBLOCK: c_int = 0x20000; pub const MAP_STACK: c_int = 0x40000; pub const MAP_HUGETLB: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000008; pub const SA_NOCLDWAIT: c_int = 0x00010000; diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 1bfd812ab2a34..35545402d11d1 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -48,34 +48,6 @@ s! { __pad2: c_ulong, } - pub struct msghdr { - pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, - pub msg_iov: *mut crate::iovec, - #[cfg(target_endian = "big")] - __pad1: c_int, - pub msg_iovlen: c_int, - #[cfg(target_endian = "little")] - __pad1: c_int, - pub msg_control: *mut c_void, - #[cfg(target_endian = "big")] - __pad2: c_int, - pub msg_controllen: crate::socklen_t, - #[cfg(target_endian = "little")] - __pad2: c_int, - pub msg_flags: c_int, - } - - pub struct cmsghdr { - #[cfg(target_endian = "big")] - pub __pad1: c_int, - pub cmsg_len: crate::socklen_t, - #[cfg(target_endian = "little")] - pub __pad1: c_int, - pub cmsg_level: c_int, - pub cmsg_type: c_int, - } - pub struct sem_t { __val: [c_int; 8], } diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index bbcd382211dfd..34d56192a585a 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -214,9 +214,6 @@ pub const MAP_SYNC: c_int = 0x080000; pub const PTRACE_SYSEMU: c_int = 0x1d; pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 0x1e; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index cd93ef706deeb..29e950cc372f9 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -567,9 +567,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 490d130c65bc4..c0332205a7948 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -165,9 +165,6 @@ pub const SIGSTKSZ: size_t = 0x2000; pub const MINSIGSTKSZ: size_t = 2048; pub const SIG_SETMASK: c_int = 2; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const O_NOCTTY: c_int = 256; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index 00dc4e5b97f2d..903bd48a37323 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -584,9 +584,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index ce8319f015e97..ebb8084468b66 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -818,9 +818,6 @@ pub const VEOF: usize = 4; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4bc11449145c7..813bba693097d 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -848,20 +848,6 @@ cfg_if! { } extern "C" { - pub fn sendmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - ) -> c_int; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - timeout: *mut crate::timespec, - ) -> c_int; - pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; pub fn prlimit( From 85d7416dfd6e652b9fa3fcde0bf54eed058e66b5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 03:27:26 -0600 Subject: [PATCH 37/37] Flip `Copy` and `PartialEq, Hash` derives for packed struct support 1.63 doesn't support deriving `PartialEq` on non-`Copy` packed structs and will error out here because it doesn't realize `Copy` is added later. Swapping the order of the derives resolves this issue and enables us to derive `extra_traits` even on packed structs. (backport ) (cherry picked from commit 79d1bdbb07b0b782cdb7b482c6a26a81dc044fc3) --- src/macros.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 6f0adb9d46084..eec90c7e44cc1 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -154,15 +154,15 @@ macro_rules! s { (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] - #[cfg_attr( - feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) - )] #[::core::prelude::v1::derive( ::core::clone::Clone, ::core::marker::Copy, ::core::fmt::Debug, )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] #[allow(deprecated)] $(#[$attr])* $pub struct $i { $($field)* }