zig/ci/drone/linux_script_build
Michael Dusan 4e590fadb5 ci drone: enable more testsuite
Upstream LLVM fixes #8597, no longer need `-Dskip-debug` and others.

Additionally, due to the nature of drone.io server pool, it is
beneficial to know which aarch64 CPU brand is in use.

- drop `-Dskip-debug` and others
- invoke `lscpu` prior to build
- enable more testsuite consistent with ci azure
- remove workaround for (already closed) #6830

closes #8597
2021-10-04 19:18:19 -04:00

66 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
. ./ci/drone/linux_script_base
# Probe CPU/brand details.
# TODO: `lscpu` is changing package names in EDGE to `util-linux-misc`
apk update
apk add util-linux
echo "lscpu:"
lscpu | sed 's,^, : ,'
PREFIX="/deps/local"
ZIG="$PREFIX/bin/zig"
TARGET="$TRIPLEARCH-linux-musl"
MCPU="baseline"
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
# The `CMAKE_AR` parameter will consider any spaces to
# be part of the executable path rather than CLI args, so we have
# to create wrapper scripts for `zig ar` and zig ranlib`.
cat <<'ENDFILE' >$PREFIX/bin/ar
#!/bin/sh
/deps/local/bin/zig ar $@
ENDFILE
cat <<'ENDFILE' >$PREFIX/bin/ranlib
#!/bin/sh
/deps/local/bin/zig ranlib $@
ENDFILE
chmod +x $PREFIX/bin/ar
chmod +x $PREFIX/bin/ranlib
# Make the `zig version` number consistent.
# This will affect the cmake command below.
git config core.abbrev 9
git fetch --unshallow || true
git fetch --tags
mkdir build
cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX="$DISTDIR" \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_AR="$PREFIX/bin/ar" \
-DCMAKE_RANLIB="$PREFIX/bin/ranlib" \
-DZIG_TARGET_TRIPLE="$TARGET" \
-DZIG_TARGET_MCPU="$MCPU" \
-DZIG_STATIC=ON \
-GNinja
# Now CMake will use Zig as the C/C++ compiler. We reset the environment variables
# so that installation and testing do not get affected by them.
unset CC
unset CXX
samu install
# Here we rebuild Zig but this time using the Zig binary we just now produced to
# build zig1.o rather than relying on the one built with stage0. See
# https://github.com/ziglang/zig/issues/6830 for more details.
cmake .. -DZIG_EXECUTABLE="$DISTDIR/bin/zig"
samu install