Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/libc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.2.150
Choose a base ref
...
head repository: rust-lang/libc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.2.151
Choose a head ref
Loading
Showing with 3,998 additions and 640 deletions.
  1. +7 −4 .github/PULL_REQUEST_TEMPLATE.md
  2. +5 −15 .github/workflows/bors.yml
  3. +1 −1 .github/workflows/main.yml
  4. +1 −1 CONTRIBUTING.md
  5. +2 −1 Cargo.toml
  6. +3 −3 build.rs
  7. +5 −35 ci/android-install-ndk.sh
  8. +10 −12 ci/build.sh
  9. +3 −2 ci/docker/aarch64-linux-android/Dockerfile
  10. +1 −1 ci/docker/aarch64-unknown-linux-musl/Dockerfile
  11. +5 −4 ci/docker/arm-linux-androideabi/Dockerfile
  12. +5 −4 ci/docker/i686-linux-android/Dockerfile
  13. +0 −10 ci/docker/mips-unknown-linux-gnu/Dockerfile
  14. +0 −25 ci/docker/mips-unknown-linux-musl/Dockerfile
  15. +0 −11 ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
  16. +0 −15 ci/docker/mips64-unknown-linux-muslabi64/Dockerfile
  17. +0 −11 ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile
  18. +0 −15 ci/docker/mips64el-unknown-linux-muslabi64/Dockerfile
  19. +0 −25 ci/docker/mipsel-unknown-linux-musl/Dockerfile
  20. +0 −22 ci/docker/mipsel-unknown-linux-uclibc/Dockerfile
  21. +1 −1 ci/docker/s390x-unknown-linux-musl/Dockerfile
  22. +6 −5 ci/docker/x86_64-linux-android/Dockerfile
  23. +0 −14 ci/install-musl.sh
  24. +1 −9 ci/install-rust.sh
  25. +4 −4 ci/run-docker.sh
  26. +4 −3 libc-test/Cargo.toml
  27. +199 −38 libc-test/build.rs
  28. +0 −1 libc-test/semver/TODO-unix.txt
  29. +20 −0 libc-test/semver/android.txt
  30. +5 −0 libc-test/semver/apple.txt
  31. +3 −0 libc-test/semver/freebsd.txt
  32. +2 −0 libc-test/semver/fuchsia.txt
  33. +23 −0 libc-test/semver/linux-gnu.txt
  34. +24 −0 libc-test/semver/linux-musl.txt
  35. +279 −0 libc-test/semver/linux.txt
  36. +57 −0 libc-test/semver/netbsd-aarch64.txt
  37. +24 −0 libc-test/semver/netbsd-x86_64.txt
  38. +15 −0 libc-test/semver/netbsd.txt
  39. +16 −0 libc-test/semver/openbsd.txt
  40. +4 −1 src/fuchsia/mod.rs
  41. +6 −0 src/macros.rs
  42. +6 −0 src/teeos/mod.rs
  43. +1 −1 src/unix/aix/mod.rs
  44. +11 −1 src/unix/bsd/apple/mod.rs
  45. +5 −0 src/unix/bsd/freebsdlike/freebsd/mod.rs
  46. +4 −0 src/unix/bsd/netbsdlike/mod.rs
  47. +59 −0 src/unix/bsd/netbsdlike/netbsd/aarch64.rs
  48. +59 −0 src/unix/bsd/netbsdlike/netbsd/arm.rs
  49. +18 −28 src/unix/bsd/netbsdlike/netbsd/mod.rs
  50. +27 −0 src/unix/bsd/netbsdlike/netbsd/x86_64.rs
  51. +23 −1 src/unix/bsd/netbsdlike/openbsd/mod.rs
  52. +19 −0 src/unix/bsd/netbsdlike/openbsd/riscv64.rs
  53. +2 −2 src/unix/haiku/mod.rs
  54. +122 −0 src/unix/haiku/native.rs
  55. +2 −0 src/unix/hurd/b32.rs
  56. +2 −0 src/unix/hurd/b64.rs
  57. +1,840 −260 src/unix/hurd/mod.rs
  58. +173 −1 src/unix/linux_like/android/mod.rs
  59. +1 −1 src/unix/linux_like/emscripten/mod.rs
  60. +28 −0 src/unix/linux_like/linux/arch/generic/mod.rs
  61. +28 −0 src/unix/linux_like/linux/arch/mips/mod.rs
  62. +28 −0 src/unix/linux_like/linux/arch/powerpc/mod.rs
  63. +28 −0 src/unix/linux_like/linux/arch/sparc/mod.rs
  64. +109 −0 src/unix/linux_like/linux/gnu/mod.rs
  65. +527 −13 src/unix/linux_like/linux/mod.rs
  66. +111 −0 src/unix/linux_like/linux/musl/mod.rs
  67. +1 −1 src/unix/linux_like/linux/uclibc/mod.rs
  68. +3 −7 src/unix/linux_like/mod.rs
  69. +9 −23 src/unix/mod.rs
  70. +1 −1 src/unix/nto/mod.rs
  71. +1 −1 src/unix/redox/mod.rs
  72. +7 −4 src/unix/solarish/mod.rs
  73. +2 −2 src/vxworks/mod.rs
11 changes: 7 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Thanks for considering submitting a PR!

We have the [contribution guide](https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md). Please read it if you're new here!

Here's a checklist for things that will be checked during review or continuous integration.

- \[ ] Edit corresponding file(s) under `libc-test/semver` when you add/remove item(s)
- \[ ] Your PR doesn't contain any *unstable* values like `*LAST` or `*MAX` (see [#3131](https://github.com/rust-lang/libc/issues/3131))
- \[ ] If your PR increments version number, it must not contain any other changes
- \[ ] `rustc ci/style.rs && ./style src`
- \[ ] Edit corresponding file(s) under `libc-test/semver` when you add/remove item(s), e.g. edit `linux.txt` if you add an item to `src/unix/linux_like/linux/mod.rs`
- \[ ] Your PR doesn't contain any private or *unstable* values like `*LAST` or `*MAX` (see [#3131](https://github.com/rust-lang/libc/issues/3131))
- \[ ] If your PR has a breaking change, please clarify it
- \[ ] If your PR increments version number, it must NOT contain any other changes (otherwise a release could be delayed)
- \[ ] Make sure `ci/style.sh` passes
- \[ ] `cd libc-test && cargo test`
- (this might fail on your env due to environment difference between your env and CI. Ignore failures if you are not sure)

20 changes: 5 additions & 15 deletions .github/workflows/bors.yml
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ jobs:
contents: read # to fetch code (actions/checkout)

name: macOS
runs-on: macos-12
runs-on: macos-13
strategy:
fail-fast: true
matrix:
@@ -125,24 +125,14 @@ jobs:
max-parallel: 12
matrix:
target: [
# FIXME: Mysterious failures in CI, see
# https://github.com/rust-lang/libc/issues/2081
# aarch64-linux-android,
aarch64-linux-android,
aarch64-unknown-linux-gnu,
aarch64-unknown-linux-musl,
arm-linux-androideabi,
arm-unknown-linux-gnueabihf,
arm-unknown-linux-musleabihf,
asmjs-unknown-emscripten,
i686-linux-android,
i686-unknown-linux-musl,
mips-unknown-linux-gnu,
mips-unknown-linux-musl,
# FIXME: Somehow failed on CI
# https://github.com/rust-lang/libc/runs/1659882216
# mips64-unknown-linux-gnuabi64,
# mips64el-unknown-linux-gnuabi64,
mipsel-unknown-linux-musl,
powerpc-unknown-linux-gnu,
powerpc64-unknown-linux-gnu,
powerpc64le-unknown-linux-gnu,
@@ -269,9 +259,9 @@ jobs:
max-parallel: 4
matrix:
target:
- { toolchain: stable, os: macos-12 }
- { toolchain: beta, os: macos-12 }
- { toolchain: nightly, os: macos-12 }
- { toolchain: stable, os: macos-13 }
- { toolchain: beta, os: macos-13 }
- { toolchain: nightly, os: macos-13 }
# Use macOS 11 for older toolchains as newer Xcode donesn't work well.
# FIXME: Disabled due to:
# error: failed to parse registry's information for: serde
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ jobs:

macos:
name: macOS
runs-on: macos-12
runs-on: macos-13
strategy:
fail-fast: true
matrix:
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ We have two automated tests running on [GitHub Actions](https://github.com/rust-
- `cd libc-test && cargo test`
- Use the `skip_*()` functions in `build.rs` if you really need a workaround.
2. Style checker
- `rustc ci/style.rs && ./style src`
- [`sh ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh)

## Breaking change policy

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libc"
version = "0.2.150"
version = "0.2.151"
authors = ["The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
@@ -19,6 +19,7 @@ Raw FFI bindings to platform libraries like libc.
features = ["const-extern-fn", "extra_traits"]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"aarch64-apple-darwin",
"aarch64-apple-ios",
"aarch64-linux-android",
"aarch64-pc-windows-msvc",
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -59,15 +59,15 @@ fn main() {
);
}

// The ABI of libc used by libstd is backward compatible with FreeBSD 10.
// The ABI of libc used by std is backward compatible with FreeBSD 12.
// The ABI of libc from crates.io is backward compatible with FreeBSD 11.
//
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
// running tests to ensure that the ABI is correct.
match which_freebsd() {
Some(10) if libc_ci || rustc_dep_of_std => set_cfg("freebsd10"),
Some(10) if libc_ci => set_cfg("freebsd10"),
Some(11) if libc_ci => set_cfg("freebsd11"),
Some(12) if libc_ci => set_cfg("freebsd12"),
Some(12) if libc_ci || rustc_dep_of_std => set_cfg("freebsd12"),
Some(13) if libc_ci => set_cfg("freebsd13"),
Some(14) if libc_ci => set_cfg("freebsd14"),
Some(_) | None => set_cfg("freebsd11"),
40 changes: 5 additions & 35 deletions ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
@@ -2,40 +2,10 @@

set -ex

NDK=android-ndk-r21d
wget --tries=20 -q https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip
unzip -q ${NDK}-linux-x86_64.zip
NDK=android-ndk-r26b
wget --tries=20 -q https://dl.google.com/android/repository/${NDK}-linux.zip
unzip -q ${NDK}-linux.zip

case "$1" in
arm)
arch=arm
api=28
;;
armv7)
arch=arm
api=28
;;
aarch64)
arch=arm64
api=28
;;
i686)
arch=x86
api=28
;;
x86_64)
arch=x86_64
api=28
;;
*)
echo "invalid arch: $1"
exit 1
;;
esac;
mv ./${NDK}/toolchains/llvm/prebuilt/linux-x86_64 /android

python3 ${NDK}/build/tools/make_standalone_toolchain.py \
--install-dir "/android/ndk-${1}" \
--arch "${arch}" \
--api ${api}

rm -rf ./${NDK}-linux-x86_64.zip ./${NDK}
rm -rf ./${NDK}-linux.zip ./${NDK}
22 changes: 10 additions & 12 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -39,16 +39,16 @@ test_target() {
done
fi

# Test that libc builds without any default features (no libstd)
# Test that libc builds without any default features (no std)
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --no-default-features --target "${TARGET}"
else
# FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc -vv --no-default-features --target "${TARGET}"
fi
# Test that libc builds with default features (e.g. libstd)
# if the target supports libstd
# Test that libc builds with default features (e.g. std)
# if the target supports std
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" -vv --target "${TARGET}"
else
@@ -112,14 +112,6 @@ x86_64-unknown-linux-musl \
x86_64-unknown-netbsd \
"

# FIXME: builds of MIPS targets are currently broken on nightly.
# mips-unknown-linux-gnu \
# mips-unknown-linux-musl \
# mips64-unknown-linux-gnuabi64 \
# mips64el-unknown-linux-gnuabi64 \
# mipsel-unknown-linux-gnu \
# mipsel-unknown-linux-musl \

RUST_GT_1_13_LINUX_TARGETS="\
arm-unknown-linux-musleabi \
arm-unknown-linux-musleabihf \
@@ -238,9 +230,15 @@ i686-unknown-haiku \
i686-unknown-netbsd \
i686-unknown-openbsd \
i686-wrs-vxworks \
mipsel-sony-psp \
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 \
5 changes: 3 additions & 2 deletions ci/docker/aarch64-linux-android/Dockerfile
Original file line number Diff line number Diff line change
@@ -19,9 +19,9 @@ WORKDIR /android/
COPY android* /android/

ENV ANDROID_ARCH=aarch64
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools
ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools

RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
RUN sh /android/android-install-ndk.sh
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
RUN mv /root/.android /tmp
RUN chmod 777 -R /tmp/.android
@@ -31,6 +31,7 @@ ENV PATH=$PATH:/rust/bin \
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android28-clang \
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \
CC_aarch64_linux_android=aarch64-linux-android28-clang \
AR_aarch64_linux_android=llvm-ar \
HOME=/tmp

ADD runtest-android.rs /tmp/runtest.rs
2 changes: 1 addition & 1 deletion ci/docker/aarch64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY install-musl.sh /
RUN sh /install-musl.sh aarch64

# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std?
ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \
CC_aarch64_unknown_linux_musl=musl-gcc \
RUSTFLAGS='-Clink-args=-lgcc -L /musl-aarch64/lib' \
9 changes: 5 additions & 4 deletions ci/docker/arm-linux-androideabi/Dockerfile
Original file line number Diff line number Diff line change
@@ -19,18 +19,19 @@ WORKDIR /android/
COPY android* /android/

ENV ANDROID_ARCH=arm
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools
ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools

RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
RUN sh /android/android-install-ndk.sh
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
RUN mv /root/.android /tmp
RUN chmod 777 -R /tmp/.android
RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/*

ENV PATH=$PATH:/rust/bin \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi28-clang \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \
CC_arm_linux_androideabi=arm-linux-androideabi-gcc \
CC_arm_linux_androideabi=armv7a-linux-androideabi28-clang \
AR_arm_linux_androideabi=llvm-ar \
HOME=/tmp

ADD runtest-android.rs /tmp/runtest.rs
9 changes: 5 additions & 4 deletions ci/docker/i686-linux-android/Dockerfile
Original file line number Diff line number Diff line change
@@ -19,18 +19,19 @@ WORKDIR /android/
COPY android* /android/

ENV ANDROID_ARCH=i686
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools
ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools

RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
RUN sh /android/android-install-ndk.sh
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
RUN mv /root/.android /tmp
RUN chmod 777 -R /tmp/.android
RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/*

ENV PATH=$PATH:/rust/bin \
CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \
CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android28-clang \
CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=/tmp/runtest \
CC_i686_linux_android=i686-linux-android-gcc \
CC_i686_linux_android=i686-linux-android28-clang \
AR_i686_linux_android=llvm-ar \
HOME=/tmp

ADD runtest-android.rs /tmp/runtest.rs
10 changes: 0 additions & 10 deletions ci/docker/mips-unknown-linux-gnu/Dockerfile

This file was deleted.

25 changes: 0 additions & 25 deletions ci/docker/mips-unknown-linux-musl/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions ci/docker/mips64-unknown-linux-muslabi64/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions ci/docker/mips64el-unknown-linux-muslabi64/Dockerfile

This file was deleted.

Loading