From 9a27cd50ecf0379aa7e1e1de4a2e3546ecae4647 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 10 Feb 2024 05:00:42 +0000 Subject: [PATCH 1/6] macOs various updates. - CI only for macOs arm64. - Fixing build issues for macOs arm64. - Adding macos cpu to arch api. --- .github/workflows/full_ci.yml | 12 ++++++------ ci/build.sh | 2 -- libc-test/build.rs | 8 ++++++++ src/fixed_width_ints.rs | 7 ++++++- src/unix/bsd/apple/mod.rs | 8 +------- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index 4389a54375ba8..806ac251867c1 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -31,12 +31,12 @@ jobs: contents: read # to fetch code (actions/checkout) name: macOS - runs-on: macos-13 + runs-on: macos-14 strategy: fail-fast: true matrix: target: [ - x86_64-apple-darwin, + aarch64-apple-darwin, ] steps: - uses: actions/checkout@v4 @@ -218,10 +218,10 @@ jobs: max-parallel: 4 matrix: target: - - { toolchain: stable, os: macos-13 } - - { toolchain: beta, os: macos-13 } - - { toolchain: nightly, os: macos-13 } - - { toolchain: 1.71.0, os: macos-13 } + - { toolchain: stable, os: macos-14 } + - { toolchain: beta, os: macos-14 } + - { toolchain: nightly, os: macos-14 } + - { toolchain: 1.71.0, os: macos-14 } runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 diff --git a/ci/build.sh b/ci/build.sh index e22b893222312..696a23eb534d8 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -147,8 +147,6 @@ x86_64-unknown-redox \ RUST_APPLE_TARGETS="\ aarch64-apple-ios \ -x86_64-apple-darwin \ -x86_64-apple-ios \ " RUST_NIGHTLY_APPLE_TARGETS="\ diff --git a/libc-test/build.rs b/libc-test/build.rs index 767a4baf49b74..e6e5fcb535b09 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -294,6 +294,8 @@ fn test_apple(target: &str) { "tcp_connection_info" => true, // FIXME: The size is changed in recent macOSes. "malloc_introspection_t" => true, + // sonoma changes the padding `rmx_filler` field. + "rt_metrics" => true, _ => false, } @@ -2215,6 +2217,12 @@ fn test_freebsd(target: &str) { // should've been used anywhere anyway. "TDF_UNUSED23" => true, + // Removed in FreeBSD 15 + "TDF_CANSWAP" | "TDF_SWAPINREQ" => true, + + // Unaccessible in FreeBSD 15 + "TDI_SWAPPED" | "P_SWAPPINGOUT" | "P_SWAPPINGIN" => true, + // Removed in FreeBSD 14 (git a6b55ee6be1) "IFF_KNOWSEPOCH" => true, diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index 7a6f6cfaedb9b..da4619051e8cd 100644 --- a/src/fixed_width_ints.rs +++ b/src/fixed_width_ints.rs @@ -20,7 +20,7 @@ pub type uint32_t = u32; pub type uint64_t = u64; cfg_if! { - if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { + if #[cfg(all(target_arch = "aarch64", not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))))] { // This introduces partial support for FFI with __int128 and // equivalent types on platforms where Rust's definition is validated // to match the standard C ABI of that platform. @@ -92,5 +92,10 @@ cfg_if! { // static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); // static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); + } else if #[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))] { + /// C __int128_t (alternate name for [__int128][]) + pub type __int128_t = i128; + /// C __uint128_t (alternate name for [__uint128][]) + pub type __uint128_t = u128; } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d19c0e9dd9cea..ff3326475970d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -493,8 +493,7 @@ s! { pub rmx_rtt: u32, pub rmx_rttvar: u32, pub rmx_pksent: u32, - pub rmx_state: u32, - pub rmx_filler: [u32; 3], + pub rmx_filler: [u32; 4], } pub struct rt_msghdr { @@ -6296,7 +6295,6 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> ::kern_return_t; - pub static mut mach_task_self_: ::mach_port_t; pub fn task_for_pid( host: ::mach_port_t, pid: ::pid_t, @@ -6413,10 +6411,6 @@ extern "C" { ) -> ::c_int; } -pub unsafe fn mach_task_self() -> ::mach_port_t { - mach_task_self_ -} - cfg_if! { if #[cfg(target_os = "macos")] { extern "C" { From 3e022584930e81e9a5a53e39c31cb213f9e1006d Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 5 Aug 2024 19:50:47 -0700 Subject: [PATCH 2/6] Remove tier 3 targets from CI These targets seem to regularly break unrelated PRs, and in general we shouldn't gate PRs on tier 3 targets (per the target tier policy). --- .github/workflows/full_ci.yml | 41 ----------------------------------- 1 file changed, 41 deletions(-) diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index 806ac251867c1..042d81b158c0c 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -140,45 +140,6 @@ jobs: - name: Execute run-docker.sh run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }} - # These targets are tier 3 or otherwise need to have CI build std via -Zbuild-std. - # Because of this, only the nightly compiler can be used on these targets. - docker_linux_build_std: - permissions: - contents: read # to fetch code (actions/checkout) - - if: ${{ false }} # This is currently broken - name: Docker Linux Build-Std Targets - needs: [docker_linux_tier1, style_check] - runs-on: ubuntu-22.04 - strategy: - fail-fast: true - max-parallel: 12 - matrix: - target: [ - armv7-unknown-linux-uclibceabihf - ] - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: TOOLCHAIN=nightly INSTALL_RUST_SRC=1 sh ./ci/install-rust.sh - - name: Execute run-docker.sh - run: LIBC_CI=1 TOOLCHAIN=nightly LIBC_CI_ZBUILD_STD=1 sh ./ci/run-docker.sh ${{ matrix.target }} - - # devkitpro's pacman needs to be connected from Docker. - docker_switch: - permissions: - contents: read # to fetch code (actions/checkout) - - name: Docker Switch - needs: [docker_linux_tier1, style_check] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: sh ./ci/install-rust.sh - - name: Execute run-docker.sh - run: LIBC_CI=1 sh ./ci/run-docker.sh switch - build_channels_linux: permissions: contents: read # to fetch code (actions/checkout) @@ -275,11 +236,9 @@ jobs: needs: [ docker_linux_tier1, docker_linux_tier2, - #docker_linux_build_std, macos, windows, style_check, - docker_switch, build_channels_linux, build_channels_macos, build_channels_windows, From cc2fa87d8ecb74aab0a789e9f1e1fe4909a8fd7d Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Wed, 7 Aug 2024 19:56:51 -0400 Subject: [PATCH 3/6] Allow unused_unsafe for wasi --- src/wasi.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wasi.rs b/src/wasi.rs index f0155e74442ad..6b8177aa86cb2 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -369,10 +369,15 @@ pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; pub const _SC_IOV_MAX: c_int = 60; pub const _SC_SYMLOOP_MAX: c_int = 173; +// unsafe code here is required in the stable, but not in nightly +#[allow(unused_unsafe)] pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; +#[allow(unused_unsafe)] pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; +#[allow(unused_unsafe)] pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; +#[allow(unused_unsafe)] pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; From 5ef157d9bf6da7bf70dda03a854ce6514e8491c3 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 10 Feb 2024 05:00:42 +0000 Subject: [PATCH 4/6] macOs various updates. - CI only for macOs arm64. - Fixing build issues for macOs arm64. - Adding macos cpu to arch api. --- .github/workflows/full_ci.yml | 12 ++++++------ ci/build.sh | 2 -- libc-test/build.rs | 2 ++ src/fixed_width_ints.rs | 7 ++++++- src/unix/bsd/apple/mod.rs | 8 +------- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index 4389a54375ba8..806ac251867c1 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -31,12 +31,12 @@ jobs: contents: read # to fetch code (actions/checkout) name: macOS - runs-on: macos-13 + runs-on: macos-14 strategy: fail-fast: true matrix: target: [ - x86_64-apple-darwin, + aarch64-apple-darwin, ] steps: - uses: actions/checkout@v4 @@ -218,10 +218,10 @@ jobs: max-parallel: 4 matrix: target: - - { toolchain: stable, os: macos-13 } - - { toolchain: beta, os: macos-13 } - - { toolchain: nightly, os: macos-13 } - - { toolchain: 1.71.0, os: macos-13 } + - { toolchain: stable, os: macos-14 } + - { toolchain: beta, os: macos-14 } + - { toolchain: nightly, os: macos-14 } + - { toolchain: 1.71.0, os: macos-14 } runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 diff --git a/ci/build.sh b/ci/build.sh index e22b893222312..696a23eb534d8 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -147,8 +147,6 @@ x86_64-unknown-redox \ RUST_APPLE_TARGETS="\ aarch64-apple-ios \ -x86_64-apple-darwin \ -x86_64-apple-ios \ " RUST_NIGHTLY_APPLE_TARGETS="\ diff --git a/libc-test/build.rs b/libc-test/build.rs index 767a4baf49b74..20cb56e9869ad 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -294,6 +294,8 @@ fn test_apple(target: &str) { "tcp_connection_info" => true, // FIXME: The size is changed in recent macOSes. "malloc_introspection_t" => true, + // sonoma changes the padding `rmx_filler` field. + "rt_metrics" => true, _ => false, } diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index 7a6f6cfaedb9b..f24fa5dd2d1d7 100644 --- a/src/fixed_width_ints.rs +++ b/src/fixed_width_ints.rs @@ -20,7 +20,7 @@ pub type uint32_t = u32; pub type uint64_t = u64; cfg_if! { - if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { + if #[cfg(all(target_arch = "aarch64", not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))))] { // This introduces partial support for FFI with __int128 and // equivalent types on platforms where Rust's definition is validated // to match the standard C ABI of that platform. @@ -92,5 +92,10 @@ cfg_if! { // static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); // static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); + } else if #[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))] { + /// /// C `__int128_t` + pub type __int128_t = i128; + /// /// C `__uint128_t` + pub type __uint128_t = u128; } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d19c0e9dd9cea..ff3326475970d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -493,8 +493,7 @@ s! { pub rmx_rtt: u32, pub rmx_rttvar: u32, pub rmx_pksent: u32, - pub rmx_state: u32, - pub rmx_filler: [u32; 3], + pub rmx_filler: [u32; 4], } pub struct rt_msghdr { @@ -6296,7 +6295,6 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> ::kern_return_t; - pub static mut mach_task_self_: ::mach_port_t; pub fn task_for_pid( host: ::mach_port_t, pid: ::pid_t, @@ -6413,10 +6411,6 @@ extern "C" { ) -> ::c_int; } -pub unsafe fn mach_task_self() -> ::mach_port_t { - mach_task_self_ -} - cfg_if! { if #[cfg(target_os = "macos")] { extern "C" { From fa686c1ac9661e42e6cc44c86348de90b9dcd0ed Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 8 Aug 2024 20:05:04 +0100 Subject: [PATCH 5/6] Fix FreeBSD 15 CI --- libc-test/build.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 20cb56e9869ad..e6e5fcb535b09 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2217,6 +2217,12 @@ fn test_freebsd(target: &str) { // should've been used anywhere anyway. "TDF_UNUSED23" => true, + // Removed in FreeBSD 15 + "TDF_CANSWAP" | "TDF_SWAPINREQ" => true, + + // Unaccessible in FreeBSD 15 + "TDI_SWAPPED" | "P_SWAPPINGOUT" | "P_SWAPPINGIN" => true, + // Removed in FreeBSD 14 (git a6b55ee6be1) "IFF_KNOWSEPOCH" => true, From 9cdf6616c70aee29244827bd379b996e99efc251 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Thu, 8 Aug 2024 18:13:16 -0400 Subject: [PATCH 6/6] Revert "macOs various updates." This reverts commit 9a27cd50ecf0379aa7e1e1de4a2e3546ecae4647. --- .github/workflows/full_ci.yml | 12 ++++++------ ci/build.sh | 2 ++ libc-test/build.rs | 8 -------- src/fixed_width_ints.rs | 7 +------ src/unix/bsd/apple/mod.rs | 8 +++++++- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index 042d81b158c0c..d22084889d292 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -31,12 +31,12 @@ jobs: contents: read # to fetch code (actions/checkout) name: macOS - runs-on: macos-14 + runs-on: macos-13 strategy: fail-fast: true matrix: target: [ - aarch64-apple-darwin, + x86_64-apple-darwin, ] steps: - uses: actions/checkout@v4 @@ -179,10 +179,10 @@ jobs: max-parallel: 4 matrix: target: - - { toolchain: stable, os: macos-14 } - - { toolchain: beta, os: macos-14 } - - { toolchain: nightly, os: macos-14 } - - { toolchain: 1.71.0, os: macos-14 } + - { toolchain: stable, os: macos-13 } + - { toolchain: beta, os: macos-13 } + - { toolchain: nightly, os: macos-13 } + - { toolchain: 1.71.0, os: macos-13 } runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 diff --git a/ci/build.sh b/ci/build.sh index 696a23eb534d8..e22b893222312 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -147,6 +147,8 @@ x86_64-unknown-redox \ RUST_APPLE_TARGETS="\ aarch64-apple-ios \ +x86_64-apple-darwin \ +x86_64-apple-ios \ " RUST_NIGHTLY_APPLE_TARGETS="\ diff --git a/libc-test/build.rs b/libc-test/build.rs index e6e5fcb535b09..767a4baf49b74 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -294,8 +294,6 @@ fn test_apple(target: &str) { "tcp_connection_info" => true, // FIXME: The size is changed in recent macOSes. "malloc_introspection_t" => true, - // sonoma changes the padding `rmx_filler` field. - "rt_metrics" => true, _ => false, } @@ -2217,12 +2215,6 @@ fn test_freebsd(target: &str) { // should've been used anywhere anyway. "TDF_UNUSED23" => true, - // Removed in FreeBSD 15 - "TDF_CANSWAP" | "TDF_SWAPINREQ" => true, - - // Unaccessible in FreeBSD 15 - "TDI_SWAPPED" | "P_SWAPPINGOUT" | "P_SWAPPINGIN" => true, - // Removed in FreeBSD 14 (git a6b55ee6be1) "IFF_KNOWSEPOCH" => true, diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index da4619051e8cd..7a6f6cfaedb9b 100644 --- a/src/fixed_width_ints.rs +++ b/src/fixed_width_ints.rs @@ -20,7 +20,7 @@ pub type uint32_t = u32; pub type uint64_t = u64; cfg_if! { - if #[cfg(all(target_arch = "aarch64", not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))))] { + if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { // This introduces partial support for FFI with __int128 and // equivalent types on platforms where Rust's definition is validated // to match the standard C ABI of that platform. @@ -92,10 +92,5 @@ cfg_if! { // static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); // static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); - } else if #[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))] { - /// C __int128_t (alternate name for [__int128][]) - pub type __int128_t = i128; - /// C __uint128_t (alternate name for [__uint128][]) - pub type __uint128_t = u128; } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index ff3326475970d..d19c0e9dd9cea 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -493,7 +493,8 @@ s! { pub rmx_rtt: u32, pub rmx_rttvar: u32, pub rmx_pksent: u32, - pub rmx_filler: [u32; 4], + pub rmx_state: u32, + pub rmx_filler: [u32; 3], } pub struct rt_msghdr { @@ -6295,6 +6296,7 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> ::kern_return_t; + pub static mut mach_task_self_: ::mach_port_t; pub fn task_for_pid( host: ::mach_port_t, pid: ::pid_t, @@ -6411,6 +6413,10 @@ extern "C" { ) -> ::c_int; } +pub unsafe fn mach_task_self() -> ::mach_port_t { + mach_task_self_ +} + cfg_if! { if #[cfg(target_os = "macos")] { extern "C" {