Skip to content

[0.2] Backports #4393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8e77cc5
Make triagebot aware of labels related to `ctest`
tgross35 Apr 3, 2025
704a28c
Add links to common header sources in the PR template
tgross35 Apr 3, 2025
a96d454
Define Linux ioctl codes on more architectures.
sunfishcode Apr 6, 2025
f7f3c7c
FreeBSD: Deprecate TCP_PCAP_OUT and TCP_PCAP_IN
tgross35 Apr 4, 2025
232dabc
ci: Use $PWD instead of $(pwd) in run-docker
snogge Dec 11, 2024
e45d8e0
ci: Add matrix env variables to the environment
snogge Mar 14, 2025
4aba8ad
ci: Always upload successfully created artifacts
snogge Mar 14, 2025
aed5b56
gnu: build settings for _FILE_OFFSET_BITS=64
snogge Mar 14, 2025
4d009b4
gnu: Set up the CI for _FILE_OFFSET_BITS=64
snogge Mar 14, 2025
399f983
gnu: Handle basic file types for 32bit with _FILE_OFFSET_BITS=64
snogge Dec 16, 2024
c2501a6
gnu: Update F_GETLK for gnu_file_offset_bits64
snogge Mar 20, 2023
d788f3a
gnu: Update F_SETLK and F_SETLKW for gnu_file_offset_bits64
snogge Mar 20, 2023
d4fe9e6
gnu: Set RLIM_INFINITY for mips with gnu_file_offset_bits64
snogge Mar 11, 2025
c6a40ea
gnu: Use _FILE_OFFSET_BITS=64 versions of glibc symbols
snogge Nov 21, 2024
25d4c0a
gnu powerpc: Use a separate stat struct for powerpc
snogge Mar 18, 2025
e620284
gnu sparc: Use a separate stat struct for 32bit powerpc
snogge Mar 20, 2025
a8df758
gnu: Adapt struct stat for gnu_file_offset_bits64
snogge Dec 19, 2024
0789132
gnu: Adapt stat64 for gnu_file_offset_bits64
snogge Mar 18, 2025
4c67438
gnu: Correct the struct stat64 padding for 32bit mips
snogge Mar 20, 2025
b6ad135
gnu: Correct struct stat64 for sparc
snogge Mar 20, 2025
8da4161
gnu: Add the __f_unused field to struct statvfs for sparc
snogge Mar 17, 2025
f5dc070
gnu: Add missing f_flags field to struct statfs for sparc
snogge Mar 18, 2025
394f97f
gnu: Add proper structs for fpos_t and fpos64_t
snogge Nov 21, 2024
c553ad5
gnu: Update struct aiocb for gnu_file_offset_bits64
snogge Mar 20, 2023
dca8f09
gnu: Adapt struct flock on mips for gnu_file_offset_bits64
snogge Mar 11, 2025
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
16 changes: 14 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,20 @@ Please fill out the below template.

# Sources

<!-- All API changes must have links to headers and/or documentation,
preferably both -->
<!-- All API changes must have permalinks to headers. Common sources:

* Linux uapi https://github.com/torvalds/linux/tree/master/include/uapi
* Glibc https://github.com/bminor/glibc
* Musl https://github.com/bminor/musl
* Apple XNU https://github.com/apple-oss-distributions/xnu
* Android https://cs.android.com/android/platform/superproject/main

After navigating to the relevant file, click the triple dots and select "copy
permalink" if on GitHub, or l-r (links->commit) for the Android source to get a
link to the current version of the header.

If sources are closed, link to documentation or paste relevant C definitions.
-->

# Checklist

Expand Down
45 changes: 39 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ jobs:
- 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: x86_64-unknown-linux-gnu
docker: true
os: ubuntu-24.04
Expand Down Expand Up @@ -108,6 +114,13 @@ jobs:
with:
key: ${{ matrix.target }}

- name: Add matrix env variables to the environment
if: matrix.env
run: |
echo '${{ toJson(matrix.env) }}' |
jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV
shell: bash

- name: Run natively
if: "!matrix.docker"
run: ./ci/run.sh ${{ matrix.target }}
Expand All @@ -116,11 +129,13 @@ jobs:
run: ./ci/run-docker.sh ${{ matrix.target }}

- name: Create CI artifacts
id: create_artifacts
if: always()
run: ./ci/create-artifacts.py
- uses: actions/upload-artifact@v4
if: always() && steps.create_artifacts.outcome == 'success'
with:
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }}
path: ${{ env.ARCHIVE_PATH }}
retention-days: 5

Expand All @@ -140,15 +155,11 @@ jobs:
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- arm-linux-androideabi
- arm-unknown-linux-gnueabihf
- arm-unknown-linux-musleabihf
- i686-linux-android
- i686-unknown-linux-musl
- loongarch64-unknown-linux-gnu
- loongarch64-unknown-linux-musl
# FIXME(ppc): SIGILL running tests, see
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
# - powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
Expand All @@ -163,6 +174,19 @@ jobs:
# FIXME: It seems some items in `src/unix/mod.rs`
# aren't defined on redox actually.
# - x86_64-unknown-redox
include:
- target: arm-unknown-linux-gnueabihf
- target: arm-unknown-linux-gnueabihf
env:
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
artifact-tag: offset-bits64
# 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
timeout-minutes: 25
env:
TARGET: ${{ matrix.target }}
Expand All @@ -174,15 +198,24 @@ jobs:
with:
key: ${{ matrix.target }}

- name: Add matrix env variables to the environment
if: matrix.env
run: |
echo '${{ toJson(matrix.env) }}' |
jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV
shell: bash

- name: Execute run-docker.sh
run: ./ci/run-docker.sh ${{ matrix.target }}

- name: Create CI artifacts
id: create_artifacts
if: always()
run: ./ci/create-artifacts.py
- uses: actions/upload-artifact@v4
if: always() && steps.create_artifacts.outcome == 'success'
with:
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }}
path: ${{ env.ARCHIVE_PATH }}
retention-days: 5

Expand Down
23 changes: 23 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"freebsd13",
"freebsd14",
"freebsd15",
// Corresponds to `_FILE_OFFSET_BITS=64` in glibc
"gnu_file_offset_bits64",
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
"libc_const_extern_fn",
"libc_deny_warnings",
Expand Down Expand Up @@ -44,6 +46,10 @@ fn main() {
let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly();
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
let libc_ci = env::var("LIBC_CI").is_ok();
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default();
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();

// 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.
Expand Down Expand Up @@ -85,6 +91,23 @@ fn main() {
if linux_time_bits64 {
set_cfg("linux_time_bits64");
}
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS");
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
Ok(val) if val == "64" => {
if target_env == "gnu"
&& target_os == "linux"
&& target_ptr_width == "32"
&& target_arch != "riscv32"
&& target_arch != "x86_64"
{
set_cfg("gnu_file_offset_bits64");
}
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
}
_ => {}
}

// On CI: deny all warnings
if libc_ci {
Expand Down
5 changes: 3 additions & 2 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ run() {
--user "$(id -u)":"$(id -g)" \
--env LIBC_CI \
--env LIBC_CI_ZBUILD_STD \
--env RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--volume "$CARGO_HOME":/cargo \
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
--volume "$(pwd)"/target:/checkout/target \
--volume "$PWD":/checkout:ro \
--volume "$PWD"/target:/checkout/target \
$kvm \
--init \
--workdir /checkout \
Expand Down
9 changes: 7 additions & 2 deletions ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ test_target() {
if [ "$os" = "linux" ]; then
# Test with the equivalent of __USE_TIME_BITS64
RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd
case "$target" in
# Test with the equivalent of __FILE_OFFSET_BITS=64
arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*)
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd;;
esac
fi

# Test again without default features, i.e. without "std"
Expand All @@ -92,7 +97,7 @@ test_target() {
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"
Expand Down Expand Up @@ -300,7 +305,7 @@ filter_and_run() {
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
return
fi

test_target "$target" "$no_dist"
some_tests_run=1
fi
Expand Down
31 changes: 31 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2855,6 +2855,9 @@ fn test_freebsd(target: &str) {
"CAP_UNUSED0_44" | "CAP_UNUSED0_57" | "CAP_UNUSED1_22" | "CAP_UNUSED1_57"
| "CAP_ALL0" | "CAP_ALL1" => true,

// FIXME(freebsd): Removed in FreeBSD 15, deprecated in libc
"TCP_PCAP_OUT" | "TCP_PCAP_IN" => true,

_ => false,
}
});
Expand Down Expand Up @@ -3661,6 +3664,26 @@ fn test_vxworks(target: &str) {
cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs");
}

fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) {
match env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS") {
Ok(val) if val == "64" => {
if target.contains("gnu")
&& target.contains("linux")
&& !target.ends_with("x32")
&& !target.contains("riscv32")
&& env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
{
cfg.define("_FILE_OFFSET_BITS", Some("64"));
cfg.cfg("gnu_file_offset_bits64", None);
}
}
Ok(val) if val != "32" => {
panic!("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS may only be set to '32' or '64'")
}
_ => {}
}
}

fn test_linux(target: &str) {
assert!(target.contains("linux"));

Expand Down Expand Up @@ -3704,6 +3727,8 @@ fn test_linux(target: &str) {
// glibc versions older than 2.29.
cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None);

config_gnu_bits(target, &mut cfg);

headers! { cfg:
"ctype.h",
"dirent.h",
Expand Down Expand Up @@ -4866,6 +4891,7 @@ fn test_linux_like_apis(target: &str) {
if linux || android || emscripten {
// test strerror_r from the `string.h` header
let mut cfg = ctest_cfg();
config_gnu_bits(target, &mut cfg);
cfg.skip_type(|_| true).skip_static(|_| true);

headers! { cfg: "string.h" }
Expand All @@ -4882,6 +4908,7 @@ fn test_linux_like_apis(target: &str) {
// test fcntl - see:
// http://man7.org/linux/man-pages/man2/fcntl.2.html
let mut cfg = ctest_cfg();
config_gnu_bits(target, &mut cfg);

if musl {
cfg.header("fcntl.h");
Expand Down Expand Up @@ -4911,6 +4938,7 @@ fn test_linux_like_apis(target: &str) {
if (linux && !wali) || android {
// test termios
let mut cfg = ctest_cfg();
config_gnu_bits(target, &mut cfg);
cfg.header("asm/termbits.h");
cfg.header("linux/termios.h");
cfg.skip_type(|_| true)
Expand All @@ -4935,6 +4963,7 @@ fn test_linux_like_apis(target: &str) {
if linux || android {
// test IPV6_ constants:
let mut cfg = ctest_cfg();
config_gnu_bits(target, &mut cfg);
headers! {
cfg:
"linux/in6.h"
Expand Down Expand Up @@ -4966,6 +4995,7 @@ fn test_linux_like_apis(target: &str) {
// "resolve.h" defines a `p_type` macro that expands to `__p_type`
// making the tests for these fails when both are included.
let mut cfg = ctest_cfg();
config_gnu_bits(target, &mut cfg);
cfg.header("elf.h");
cfg.skip_fn(|_| true)
.skip_static(|_| true)
Expand All @@ -4985,6 +5015,7 @@ fn test_linux_like_apis(target: &str) {
if (linux && !wali) || android {
// Test `ARPHRD_CAN`.
let mut cfg = ctest_cfg();
config_gnu_bits(target, &mut cfg);
cfg.header("linux/if_arp.h");
cfg.skip_fn(|_| true)
.skip_static(|_| true)
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3771,7 +3771,9 @@ pub const TCP_PERF_INFO: c_int = 78;
pub const TCP_LRD: c_int = 79;
pub const TCP_KEEPINIT: c_int = 128;
pub const TCP_FASTOPEN: c_int = 1025;
#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")]
pub const TCP_PCAP_OUT: c_int = 2048;
#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")]
pub const TCP_PCAP_IN: c_int = 4096;
pub const TCP_FUNCTION_BLK: c_int = 8192;
pub const TCP_FUNCTION_ALIAS: c_int = 8193;
Expand Down
Loading
Loading