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

ci: make scripts more uniform #4042

Merged
merged 2 commits into from
Nov 16, 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
1 change: 1 addition & 0 deletions .github/workflows/full_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
types: [opened, synchronize, reopened]

env:
CARGO_TERM_VERBOSE: true
LIBC_CI: 1

jobs:
Expand Down
10 changes: 5 additions & 5 deletions ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -ex

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

mv ./${NDK}/toolchains/llvm/prebuilt/linux-x86_64 /android
mv "./${ndk}/toolchains/llvm/prebuilt/linux-x86_64" /android

rm -rf ./${NDK}-linux.zip ./${NDK}
rm -rf "./${ndk}-linux.zip" "./${ndk}"
8 changes: 4 additions & 4 deletions ci/android-install-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ set -ex
# located in https://github.com/appunite/docker by just wrapping it in a script
# which apparently magically accepts the licenses.

SDK=6609375
sdk=6609375
mkdir -p sdk/cmdline-tools
wget -q --tries=20 https://dl.google.com/android/repository/commandlinetools-linux-${SDK}_latest.zip
unzip -q -d sdk/cmdline-tools commandlinetools-linux-${SDK}_latest.zip
wget -q --tries=20 "https://dl.google.com/android/repository/commandlinetools-linux-${sdk}_latest.zip"
unzip -q -d sdk/cmdline-tools "commandlinetools-linux-${sdk}_latest.zip"

case "$1" in
arm | armv7)
Expand Down Expand Up @@ -69,4 +69,4 @@ echo "no" |
--name "${1}" \
--package "${image}" | grep -v = || true

rm -rf commandlinetools-linux-${SDK}_latest.zip emulator-linux_x64-9058569.zip
rm -rf "commandlinetools-linux-${sdk}_latest.zip" emulator-linux_x64-9058569.zip
167 changes: 91 additions & 76 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,27 @@ set -ex
: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}"
: "${OS?The OS environment variable must be set.}"

RUST=${TOOLCHAIN}
VERBOSE=-v
rust="$TOOLCHAIN"

echo "Testing Rust ${RUST} on ${OS}"
echo "Testing Rust $rust on $OS"

if [ "${TOOLCHAIN}" = "nightly" ] ; then
if [ "$TOOLCHAIN" = "nightly" ] ; then
rustup component add rust-src
fi

test_target() {
BUILD_CMD="${1}"
TARGET="${2}"
NO_STD="${3}"
build_cmd="${1}"
target="${2}"
no_std="${3}"

# If there is a std component, fetch it:
if [ "${NO_STD}" != "1" ]; then
if [ "${no_std}" != "1" ]; then
# FIXME: rustup often fails to download some artifacts due to network
# issues, so we retry this N times.
N=5
n=0
until [ $n -ge $N ]
do
if rustup target add "${TARGET}" --toolchain "${RUST}" ; then
until [ $n -ge $N ]; do
if rustup target add "$target" --toolchain "$rust" ; then
break
fi
n=$((n+1))
Expand All @@ -41,56 +39,75 @@ test_target() {
fi

# Test that libc builds without any default features (no std)
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" "$VERBOSE" --no-default-features --target "${TARGET}"
if [ "$no_std" != "1" ]; then
cargo "+$rust" "$build_cmd" --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 "$VERBOSE" --no-default-features --target "${TARGET}"
RUSTFLAGS="-A improper_ctypes_definitions" \
cargo "+$rust" "$build_cmd" \
-Z build-std=core,alloc \
--no-default-features \
--target "$target"
fi

# Test that libc builds with default features (e.g. std)
# if the target supports std
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" "$VERBOSE" --target "${TARGET}"
if [ "$no_std" != "1" ]; then
cargo "+$rust" "$build_cmd" --target "$target"
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc "$VERBOSE" --target "${TARGET}"
RUSTFLAGS="-A improper_ctypes_definitions" \
cargo "+$rust" "${build_cmd}" \
-Z build-std=core,alloc \
--target "$target"
fi

# Test that libc builds with the `extra_traits` feature
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" "$VERBOSE" --no-default-features --target "${TARGET}" \
--features extra_traits
if [ "$no_std" != "1" ]; then
cargo "+$rust" "$build_cmd" \
--no-default-features \
--features extra_traits \
--target "$target"
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc "$VERBOSE" --no-default-features \
--target "${TARGET}" --features extra_traits
RUSTFLAGS="-A improper_ctypes_definitions" \
cargo "+$rust" "$build_cmd" \
-Z build-std=core,alloc \
--no-default-features \
--features extra_traits \
--target "$target"
fi

# Test the 'const-extern-fn' feature on nightly
if [ "${RUST}" = "nightly" ]; then
if [ "${NO_STD}" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" "$VERBOSE" --no-default-features --target "${TARGET}" \
--features const-extern-fn
if [ "${rust}" = "nightly" ]; then
if [ "${no_std}" != "1" ]; then
cargo "+$rust" "$build_cmd" \
--no-default-features \
--features const-extern-fn \
--target "$target"
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc "$VERBOSE" --no-default-features \
--target "${TARGET}" --features const-extern-fn
RUSTFLAGS="-A improper_ctypes_definitions" \
cargo "+$rust" "$build_cmd" \
-Z build-std=core,alloc \
--no-default-features \
--features const-extern-fn \
--target "$target"
fi
fi

# Also test that it builds with `extra_traits` and default features:
if [ "$NO_STD" != "1" ]; then
cargo "+${RUST}" "${BUILD_CMD}" "$VERBOSE" --target "${TARGET}" \
if [ "$no_std" != "1" ]; then
cargo "+$rust" "$build_cmd" \
--target "$target" \
--features extra_traits
else
RUSTFLAGS="-A improper_ctypes_definitions" cargo "+${RUST}" "${BUILD_CMD}" \
-Z build-std=core,alloc "$VERBOSE" --target "${TARGET}" \
RUSTFLAGS="-A improper_ctypes_definitions" \
cargo "+$rust" "$build_cmd" \
-Z build-std=core,alloc \
--target "$target" \
--features extra_traits
fi
}

RUST_LINUX_TARGETS="\
rust_linux_targets="\
aarch64-linux-android \
aarch64-unknown-linux-gnu \
arm-linux-androideabi \
Expand All @@ -113,24 +130,24 @@ x86_64-unknown-linux-musl \
x86_64-unknown-netbsd \
"

RUST_GT_1_13_LINUX_TARGETS="\
rust_gt_1_13_linux_targets="\
arm-unknown-linux-musleabi \
arm-unknown-linux-musleabihf \
armv7-unknown-linux-musleabihf \
sparc64-unknown-linux-gnu \
wasm32-unknown-emscripten \
x86_64-linux-android \
"
RUST_GT_1_19_LINUX_TARGETS="\
rust_gt_1_19_linux_targets="\
aarch64-unknown-linux-musl \
sparcv9-sun-solaris \
wasm32-unknown-unknown \
"
RUST_GT_1_24_LINUX_TARGETS="\
rust_gt_1_24_linux_targets="\
i586-unknown-linux-musl \
"

RUST_NIGHTLY_LINUX_TARGETS="\
rust_nightly_linux_targets="\
aarch64-unknown-fuchsia \
armv5te-unknown-linux-gnueabi \
armv5te-unknown-linux-musleabi \
Expand All @@ -145,73 +162,71 @@ x86_64-unknown-linux-gnux32 \
x86_64-unknown-redox \
"

RUST_APPLE_TARGETS="\
rust_apple_targets="\
aarch64-apple-ios \
"

RUST_NIGHTLY_APPLE_TARGETS="\
rust_nightly_apple_targets="\
aarch64-apple-darwin \
"

# Must start with `x86_64-pc-windows-msvc` first.
RUST_NIGHTLY_WINDOWS_TARGETS="\
rust_nightly_windows_targets="\
x86_64-pc-windows-msvc \
x86_64-pc-windows-gnu \
i686-pc-windows-msvc \
"

# The targets are listed here alphabetically
TARGETS=""
targets=""
case "${OS}" in
linux*)
TARGETS="${RUST_LINUX_TARGETS}"
targets="$rust_linux_targets"

if [ "${RUST}" != "1.13.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}"
if [ "${RUST}" != "1.19.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}"
if [ "${RUST}" != "1.24.0" ]; then
TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}"
if [ "$rust" != "1.13.0" ]; then
targets="$targets $rust_gt_1_13_linux_targets"
if [ "$rust" != "1.19.0" ]; then
targets="$targets $rust_gt_1_19_linux_targets"
if [ "${rust}" != "1.24.0" ]; then
targets="$targets $rust_gt_1_24_linux_targets"
fi
fi
fi

if [ "${RUST}" = "nightly" ]; then
TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}"
if [ "$rust" = "nightly" ]; then
targets="$targets $rust_nightly_linux_targets"
fi

;;
macos*)
TARGETS="${RUST_APPLE_TARGETS}"
targets="$rust_apple_targets"

if [ "${RUST}" = "nightly" ]; then
TARGETS="${TARGETS} ${RUST_NIGHTLY_APPLE_TARGETS}"
if [ "$rust" = "nightly" ]; then
targets="$targets $rust_nightly_apple_targets"
fi

;;
windows*)
TARGETS=${RUST_NIGHTLY_WINDOWS_TARGETS}

;;
*)
targets=${rust_nightly_windows_targets}
;;
*) ;;
esac

for TARGET in $TARGETS; do
if echo "$TARGET"|grep -q "$FILTER"; then
for target in $targets; do
if echo "$target" | grep -q "$FILTER"; then
if [ "${OS}" = "windows" ]; then
TARGET="$TARGET" sh ./ci/install-rust.sh
test_target build "$TARGET"
TARGET="$target" sh ./ci/install-rust.sh
test_target build "$target"
else
test_target build "$TARGET"
test_target build "$target"
fi
fi
done

# Targets which are not available via rustup and must be built with -Zbuild-std
# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has
# duplicate symbol errors from `compiler_builtins`.
RUST_LINUX_NO_CORE_TARGETS="\
rust_linux_no_core_targets="\
aarch64-pc-windows-msvc \
aarch64-unknown-freebsd \
aarch64-unknown-hermit \
Expand Down Expand Up @@ -275,24 +290,24 @@ x86_64-unknown-openbsd \
x86_64-wrs-vxworks \
"

if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then
for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do
if echo "$TARGET"|grep -q "$FILTER"; then
test_target build "$TARGET" 1
if [ "${rust}" = "nightly" ] && [ "${OS}" = "linux" ]; then
for target in $rust_linux_no_core_targets; do
if echo "$target" | grep -q "$FILTER"; then
test_target build "$target" 1
fi
done
fi

RUST_APPLE_NO_CORE_TARGETS="\
rust_apple_no_core_targets="\
armv7s-apple-ios \
i686-apple-darwin \
i386-apple-ios \
"

if [ "${RUST}" = "nightly" ] && [ "${OS}" = "macos" ]; then
for TARGET in $RUST_APPLE_NO_CORE_TARGETS; do
if echo "$TARGET" | grep -q "$FILTER"; then
test_target build "$TARGET" 1
if [ "${rust}" = "nightly" ] && [ "${OS}" = "macos" ]; then
for target in $rust_apple_no_core_targets; do
if echo "$target" | grep -q "$FILTER"; then
test_target build "$target" 1
fi
done
fi
10 changes: 5 additions & 5 deletions ci/docker/wasm32-unknown-emscripten/node-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -e

me=$1
me="$1"
shift
dir=$(dirname $me)
file=$(basename $me)
dir=$(dirname "$me")
file=$(basename "$me")

cd $dir
exec node $file "$@"
cd "$dir"
exec node "$file" "$@"
6 changes: 3 additions & 3 deletions ci/emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ set -ex

# Note: keep in sync with:
# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh
EMSDK_VERSION=3.1.68
emsdk_version=3.1.68

git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
cd /emsdk-portable
./emsdk install "${EMSDK_VERSION}"
./emsdk activate "${EMSDK_VERSION}"
./emsdk install "$emsdk_version"
./emsdk activate "$emsdk_version"

# Compile and cache libc
# shellcheck disable=SC1091
Expand Down
Loading