Skip to content

Commit

Permalink
Merge pull request #4134 from tgross35/fix-constness
Browse files Browse the repository at this point in the history
fix: make sure the `const-extern-fn` feature is enabled
  • Loading branch information
tgross35 authored Nov 25, 2024
2 parents aff3132 + 19e9e6a commit 79afdce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ cargo-args = ["-Zbuild-std=core"]
rustc-std-workspace-core = { version = "1.0.0", optional = true }

[features]
default = ["std"]
default = ["const-extern-fn", "std"]
std = []
rustc-dep-of-std = ["rustc-std-workspace-core"]
extra_traits = []
Expand Down
55 changes: 22 additions & 33 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ mirrors_url="https://ci-mirrors.rust-lang.org/libc"

target="$1"

export RUST_BACKTRACE="${RUST_BACKTRACE:-1}"

# If we're going to run tests inside of a qemu image, then we don't need any of
# the scripts below. Instead, download the image, prepare a filesystem which has
# the current state of this repository, and then run the image.
Expand Down Expand Up @@ -78,6 +80,20 @@ if [ -n "${QEMU:-}" ]; then
exec grep -E "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log"
fi

cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}"

# Run tests in the `libc` crate
case "$target" in
# FIXME(android): unit tests fail to start on Android
# FIXME(s390x): unit tests fail to locate glibc
*android*) ;;
*s390x*) ;;
*) $cmd
esac

# Everything else is in `libc-test`
cmd="$cmd --manifest-path libc-test/Cargo.toml"

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.
Expand All @@ -86,52 +102,25 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then
passed=0
until [ $n -ge $N ]; do
if [ "$passed" = "0" ]; then
if cargo test \
--no-default-features \
--manifest-path libc-test/Cargo.toml \
--target "$target" \
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
then
if $cmd --no-default-features; then
passed=$((passed+1))
continue
fi
elif [ "$passed" = "1" ]; then
if cargo test \
--manifest-path libc-test/Cargo.toml \
--target "$target" \
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
then
if $cmd; then
passed=$((passed+1))
continue
fi
elif [ "$passed" = "2" ]; then
if cargo test \
--features extra_traits \
--manifest-path libc-test/Cargo.toml \
--target "$target" \
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
then
if $cmd --features extra_traits; then
break
fi
fi
n=$((n+1))
sleep 1
done
else
cargo test \
--no-default-features \
--manifest-path libc-test/Cargo.toml \
--target "$target" \
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}

cargo test \
--manifest-path libc-test/Cargo.toml \
--target "$target" \
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}

RUST_BACKTRACE=1 cargo test \
--features extra_traits \
--manifest-path libc-test/Cargo.toml \
--target "$target" \
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
$cmd --no-default-features
$cmd
$cmd --features extra_traits
fi
3 changes: 3 additions & 0 deletions tests/const_fn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#[cfg(target_os = "linux")]
const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) };
//^ if CMSG_SPACE is not const, this will fail to compile

0 comments on commit 79afdce

Please sign in to comment.