Skip to content
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

fix: make sure the const-extern-fn feature is enabled #4134

Merged
merged 4 commits into from
Nov 25, 2024
Merged
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
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