Commit e882bd22 authored by Roman Shaposhnik's avatar Roman Shaposhnik Committed by Ariadne Conill
Browse files

Accounting for gcc requiring explicit -latomic in bootstrap.sh



On some architectures rograms which use C11 or C++11 atomics,
like #include <atomic>, generally must link against -latomic
explicitly.

For now the check is only against riscv64, but the list may grow.
Signed-off-by: default avatarRoman Shaposhnik <rvs@zededa.com>
parent a57e081a
Pipeline #83537 passed with stages
in 10 minutes and 34 seconds
......@@ -94,6 +94,16 @@ msg "Cross building base system"
# Implicit dependencies for early targets
EXTRADEPENDS_TARGET="libgcc libstdc++ musl-dev"
# On a few architectures like riscv64 we need to account for
# gcc requiring -ltomic to be set explicitly if a C[++]11 program
# uses atomics (e.g. #include <atomic>):
# https://github.com/riscv/riscv-gnu-toolchain/issues/183#issuecomment-253721765
# The reason gcc itself is needed is because .so is in that package,
# not in libatomic.
if [ "$TARGET_ARCH" = "riscv64" ]; then
NEEDS_LIBATOMIC="yes"
fi
# ordered cross-build
for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \
openssl ca-certificates libmd \
......@@ -111,7 +121,10 @@ for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \
libxml2 pax-utils llvm11 community/rust \
$KERNEL_PKG ; do
EXTRADEPENDS_TARGET="$EXTRADEPENDS_TARGET" \
if [ "$NEEDS_LIBATOMIC" = "yes" ]; then
EXTRADEPENDS_BUILD="libatomic gcc-$TARGET_ARCH g++-$TARGET_ARCH"
fi
EXTRADEPENDS_TARGET="$EXTRADEPENDS_TARGET" EXTRADEPENDS_BUILD="$EXTRADEPENDS_BUILD" \
CHOST=$TARGET_ARCH BOOTSTRAP=bootimage APKBUILD=$(apkbuildname $PKG) abuild -r
case "$PKG" in
......@@ -119,6 +132,11 @@ for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \
# Additional implicit dependencies once built
EXTRADEPENDS_TARGET="$EXTRADEPENDS_TARGET $PKG"
;;
gcc)
if [ "$NEEDS_LIBATOMIC" = "yes" ]; then
EXTRADEPENDS_TARGET="libatomic gcc $EXTRADEPENDS_TARGET"
fi
;;
build-base)
# After build-base, that alone is sufficient dependency in the target
EXTRADEPENDS_TARGET="busybox $PKG"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment