Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ jobs:
# FIXME(ppc): SIGILL running tests, see
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
# - target: powerpc-unknown-linux-gnu
- target: aarch64-apple-ios-sim
os: macos-26
cargo-apple-runner: true
simulator: "iPhone 17"
env: { CARGO_TARGET_AARCH64_APPLE_IOS_SIM_RUNNER: cargo-apple-runner }
Comment on lines +243 to +247

@madsmtm madsmtm Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could add tests for tvOS, watchOS and visionOS here too, if you'd like?

View changes since the review

runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }}
timeout-minutes: 25
env:
Expand All @@ -261,6 +266,16 @@ jobs:
jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV
shell: bash

- name: Install `cargo-apple-runner`
if: matrix.cargo-apple-runner
uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8
with:
tool: cargo-apple-runner

@madsmtm madsmtm Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unsure if this is how you'll want this to be installed?

View changes since the review


- name: Start simulator
if: matrix.simulator
run: xcrun simctl boot "${{ matrix.simulator }}"

- name: Run natively
if: runner.os != 'Linux'
run: ./ci/run.sh ${{ matrix.target }}
Expand Down
4 changes: 2 additions & 2 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ The remaining architectures look like:
the generated binary to actually verify the tests pass.
* The MUSL build just has to download a MUSL compiler and target libraries and
then otherwise runs tests normally.
* iOS builds need an extra linker flag currently, but beyond that they're built
as standard as everything else.
* iOS is tested using [`cargo-apple-runner`][cargo-apple-runner].
* The BSD builds, currently OpenBSD and FreeBSD, use QEMU to boot up a system
and compile/run tests. More information on that below.

[Actions config]: https://github.com/rust-lang/libc/tree/HEAD/.github/workflows
[android-docker]: https://github.com/rust-lang/libc/blob/HEAD/ci/docker/x86_64-linux-android/Dockerfile
[cargo-apple-runner]: https://github.com/madsmtm/cargo-apple-runner

## QEMU

Expand Down
187 changes: 0 additions & 187 deletions ci/ios/deploy_and_run_on_ios_simulator.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ case "$target" in
# FIXME(android): unit tests fail to start on Android
*android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
*s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
# ctest's own tests don't work on Apple devices, since these don't have
# host tooling such as `rustc` or a C compiler.
*ios*|*tvos*|*watchos*|*visionos*) cmd="$cmd --workspace --exclude ctest" ;;
# For all other platforms, test everything in the workspace
*) cmd="$cmd --workspace" ;;
esac
Expand Down
57 changes: 41 additions & 16 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ fn test_apple(target: &str) {
assert!(target.contains("apple"));
let x86_64 = target.contains("x86_64");
let i686 = target.contains("i686");
let macos = target.contains("darwin") || target.contains("macos");
let tvos = target.contains("tvos");
let watchos = target.contains("watchos");

let mut cfg = ctest_cfg();

Expand Down Expand Up @@ -236,27 +239,29 @@ fn test_apple(target: &str) {
"ifaddrs.h",
"langinfo.h",
"libgen.h",
"libproc.h",
(macos, "libproc.h"),
"limits.h",
"locale.h",
"mach/mach.h",
"malloc/malloc.h",
"net/bpf.h",
"net/dlil.h",
(macos, "net/bpf.h"),
(macos, "net/dlil.h"),
"net/if.h",
"net/if_arp.h",
(macos, "net/if_arp.h"),
"net/if_dl.h",
"net/if_mib.h",
"net/if_utun.h",
(macos, "net/if_mib.h"),
(macos, "net/if_utun.h"),
"net/if_var.h",
"net/ndrv.h",
"net/route.h",
(macos, "net/ndrv.h"),
(macos, "net/route.h"),
"netdb.h",
"netinet/if_ether.h",
(macos, "netinet/if_ether.h"),
"netinet/in.h",
"netinet/ip.h",
"netinet/tcp.h",
"netinet/udp.h",
"netinet6/in6_var.h",
"netinet6/scope6_var.h",
(macos, "netinet6/in6_var.h"),
"os/clock.h",
"os/lock.h",
"os/signpost.h",
Expand Down Expand Up @@ -287,20 +292,20 @@ fn test_apple(target: &str) {
"sys/file.h",
"sys/ioctl.h",
"sys/ipc.h",
"sys/kern_control.h",
(macos, "sys/kern_control.h"),
"sys/mman.h",
"sys/mount.h",
"sys/proc_info.h",
"sys/ptrace.h",
(macos, "sys/proc_info.h"),
(macos, "sys/ptrace.h"),
"sys/quota.h",
"sys/random.h",
(macos, "sys/random.h"),
"sys/resource.h",
"sys/sem.h",
"sys/shm.h",
"sys/socket.h",
"sys/stat.h",
"sys/statvfs.h",
"sys/sys_domain.h",
(macos, "sys/sys_domain.h"),
"sys/sysctl.h",
"sys/time.h",
"sys/times.h",
Expand All @@ -321,7 +326,7 @@ fn test_apple(target: &str) {
"utmpx.h",
"wchar.h",
"xlocale.h",
(x86_64, "crt_externs.h"),
"crt_externs.h",
);

cfg.skip_struct(move |s| {
Expand Down Expand Up @@ -377,6 +382,26 @@ fn test_apple(target: &str) {
"close" if x86_64 => true,
// FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766
"res_init" => true,
// Marked available everywhere, but the `sys/random.h` header only
// exists on the macOS SDK.
// FIXME(madsmtm): Filed as FB23000895.
"getentropy" => !macos,
// Prohibited on iOS, tvOS, watchOS and visionOS.
// FIXME(madsmtm): Perhaps we should just not expose this symbol?
"system" => !macos,
// Marked unavailable on iOS, tvOS, watchOS and visionOS.
// FIXME(madsmtm): Perhaps we should just not expose these symbols?
"pthread_jit_write_protect_np"
| "pthread_jit_write_protect_supported_np"
| "pthread_jit_write_with_callback_np"
| "pthread_jit_write_freeze_callbacks_np"
| "gethostuuid" => !macos,
// Marked as unavailable on tvOS and watchOS.
// FIXME(madsmtm): Perhaps we should just not expose this symbol?
"execl" | "execle" | "execlp" | "execv" | "execve" | "execvp" | "execvP" | "fork"
| "sigaltstack" | "syscall" | "daemon" | "brk" | "sbrk" | "task_set_info"
| "exchangedata" => tvos || watchos,
ident if ident.starts_with("posix_spawn") => tvos || watchos,
_ => false,
}
});
Expand Down
Loading