diff --git a/0-Preparation b/0-Preparation index 05aa2d6..3004fc0 100644 --- a/0-Preparation +++ b/0-Preparation @@ -96,31 +96,41 @@ case $(uname -m) in export CMLFS_ARCH="x86" export CMLFS_CPU="x86-64" export MCA="x86_64" + export LARCH="X86" + export MUSSA="x86-64" ;; i686) export CMLFS_TARGET="i686-cmlfs-linux-musl" export TARGET_TUPLE="i686-pc-linux-musl" export CMLFS_ARCH="x86" export CMLFS_CPU="i686" export MCA="i386" + export LARCH="X86" + export MUSSA="i686" ;; aarch64 ) export CMLFS_TARGET="aarch64-cmlfs-linux-musl" export TARGET_TUPLE="aarch64-pc-linux-musl" export CMLFS_ARCH="arm64" export CMLFS_CPU="armv8-a" export MCA="aarch64" + export LARCH="AArch64" + export MUSSA="aarch64" ;; arm7*) export CMLFS_TARGET="armv7l-cmlfs-linux-musleabihf" export TARGET_TUPLE="armv7l-pc-linux-musleabihf" export CMLFS_ARCH="arm" export CMLFS_CPU="armv7-a" export MCA="arm" + export LARCH="ARM" + export MUSSA="armv7" ;; arm6*) export CMLFS_TARGET="armv6l-cmlfs-linux-musleabihf" export TARGET_TUPLE="armv6l-pc-linux-musleabihf" export CMLFS_ARCH="arm" export CMLFS_CPU="armv6zk" - export MCA="arm" + export MCA="arm" + export LARCH="ARM" + export MUSSA="arm6kz" ;; esac @@ -132,7 +142,7 @@ export CMLFS_HOST="${CMLFS_HOST}" \ CMLFS_TARGET="${CMLFS_TARGET}" \ CMLFS_ARCH="${CMLFS_ARCH}" \ CMLFS_CPU="${CMLFS_CPU}" \ - TARGET_TUPLE="${TARGET_TUPLE}" - MCA="${MCA}" + TARGET_TUPLE="${TARGET_TUPLE}" \ + MCA="${MCA}" LARCH="${LARCH}" MUSSA="${MUSSA}" EOF source ~/.bashrc diff --git a/1-Stage0/0-Build-Notes b/1-Stage0/00-Build-Notes similarity index 100% rename from 1-Stage0/0-Build-Notes rename to 1-Stage0/00-Build-Notes diff --git a/1-Stage0/1-Mussel b/1-Stage0/01-Mussel similarity index 88% rename from 1-Stage0/1-Mussel rename to 1-Stage0/01-Mussel index c05f5cc..c0959ef 100644 --- a/1-Stage0/1-Mussel +++ b/1-Stage0/01-Mussel @@ -37,10 +37,15 @@ patch -Np1 -i ../patches/mussel-add-missing-symlinks.patch # to build kernel headers patch -Np1 -i ../patches/mussel-LLVM_for_headers.patch -# Build toolchain. Amend PATH to include /cgnutools/bin +# Build toolchain. A few notes: # o Ommit -p if not building in parallel to use all # the host's CPU cores -sudo PATH=/cgnutools/bin:$PATH ./mussel.sh x86_64 -l -o -k -p +# o If building with clang, add CC=clang CXX=clang++ +# o Building with clang on CMLFS system is unstable, best to use GCC +# o Building with clang on MLFS system has yet to be tested +# o PATH is hard-coded in script. Will need to patch (line 219) + +sudo PATH=/cgnutools/bin:$PATH ./mussel.sh ${MUSSA} -l -o -k -p # Make sure cgnutools is owned by cmlfs sudo chown -vR cmlfs $CMLFS/cgnutools diff --git a/1-Stage0/2-kernel-headers b/1-Stage0/02-kernel-headers similarity index 100% rename from 1-Stage0/2-kernel-headers rename to 1-Stage0/02-kernel-headers diff --git a/1-Stage0/03-musl b/1-Stage0/03-musl new file mode 100644 index 0000000..4a77806 --- /dev/null +++ b/1-Stage0/03-musl @@ -0,0 +1,45 @@ +# llvmtools: Musl libc +# Build as cmlfs + +# Configure with freshly built GCC +ARCH=${MCA} CC=${TARGET_TUPLE}-gcc \ +CROSS_COMPILE=${TARGET_TUPLE}- \ +LIBCC=/cgnutools/lib/gcc/${TARGET_TUPLE}/${MCGV}/libgcc.a \ +./configure --host=$TARGET_TUPLE --prefix=/ + +# Compile +make AR=${TARGET_TUPLE}-ar \ +RANLIB=${TARGET_TUPLE}-ranlib + +# Install +make AR=${TARGET_TUPLE}-ar \ +RANLIB=${TARGET_TUPLE}-ranlib \ +DESTDIR=/llvmtools install + +# Fix a symlink +rm -v /llvmtools/lib/ld-musl-${MCA}.so.1 +ln -sv libc.so /llvmtools/lib/ld-musl-${MCA}.so.1 + +# Create a symlink that can be used to print +# the required shared objects of a program or +# shared object +mkdir /llvmtools/{etc,bin} +ln -sv ../lib/libc.so /llvmtools/bin/ldd + +# Configure the dynamic linker +cat > /llvmtools/etc/ld-musl-${MCA}.path <\nint main(){}\n" > dummy.c +${TARGET_TUPLE}-gcc dummy.c +readelf -l a.out | grep ld + +# Should output: +# [Requesting program interpreter: /llvmtools/lib/ld-musl-x86_64.so.1] +# If matching, clean up: +rm -rf a.out dummy.c diff --git a/1-Stage0/4-zlib-ng b/1-Stage0/04-zlib-ng similarity index 59% rename from 1-Stage0/4-zlib-ng rename to 1-Stage0/04-zlib-ng index 2d8ed2d..06fb855 100644 --- a/1-Stage0/4-zlib-ng +++ b/1-Stage0/04-zlib-ng @@ -3,12 +3,16 @@ CC=${TARGET_TUPLE}-gcc \ CXX=${TARGET_TUPLE}-g++ \ +AR=${TARGET_TUPLE}-ar \ +RANLIB=${TARGET_TUPLE}-ranlib \ ./configure --prefix=/llvmtools \ --libdir=/llvmtools/lib \ --zlib-compat -make +make AR=${TARGET_TUPLE}-ar \ +RANLIB=${TARGET_TUPLE}-ranlib -make install +make AR=${TARGET_TUPLE}-ar \ +RANLIB=${TARGET_TUPLE}-ranlib install ln -sv libz.so.1.3.0.zlib-ng /llvmtools/lib/libz.so.1.3.11 diff --git a/1-Stage0/5-libatomic-chimera b/1-Stage0/05-libatomic-chimera similarity index 70% rename from 1-Stage0/5-libatomic-chimera rename to 1-Stage0/05-libatomic-chimera index 252267b..26ea313 100644 --- a/1-Stage0/5-libatomic-chimera +++ b/1-Stage0/05-libatomic-chimera @@ -9,4 +9,8 @@ RANLIB=${TARGET_TUPLE}-ranlib \ make PREFIX="/llvmtools" # Install to llvmtools +CC=${TARGET_TUPLE}-gcc \ +CXX=${TARGET_TUPLE}-g++ \ +AR=${TARGET_TUPLE}-ar \ +RANLIB=${TARGET_TUPLE}-ranlib \ make PREFIX="/llvmtools" install diff --git a/1-Stage0/6-libunwind b/1-Stage0/06-libunwind similarity index 93% rename from 1-Stage0/6-libunwind rename to 1-Stage0/06-libunwind index 0e2240e..3a66fa2 100644 --- a/1-Stage0/6-libunwind +++ b/1-Stage0/06-libunwind @@ -33,6 +33,11 @@ patch -Np1 -i ../patches/llvm-17.0.5-chimera/0024-clang-link-libcxxabi-on-linux- patch -Np1 -i ../patches/llvm-17.0.5-chimera/0025-Get-rid-of-spurious-trailing-space-in-__clang_versio.patch patch -Np1 -i ../patches/llvm-17.0.5-chimera/ifunc-fail-if-not-supported.patch +# For llvm-17.0.6, additional patches: +patch -Np1 -i ../patches/llvm-17.0.6-chimera/libcpp-pointer-traits-sfinae.patch +patch -Np1 -i ../patches/llvm-17.0.6-chimera/stdc-predef-preinclude.patch +patch -Np1 -i ../patches/llvm-17.0.6-chimera/string-sso-constant.patch + # Musl doesn't support strtoll_l(), so replace it with a simple strtoll() call. # Apply patches to allow localization of libc++: #patch -Np1 -i ../patches/llvm1506-cmlfs/libcxx-use-strtoll_strtoul.patch @@ -42,7 +47,7 @@ patch -Np1 -i ../patches/llvm-17.0.5-chimera/ifunc-fail-if-not-supported.patch # Since, libunwind is for cgnutools, modify the cross-gcc specs to set the dynamic # loader as /cgnutools/lib/ld-musl-${MCA}.so.1 -export MCGV=$(/cgnutools/bin/gcc --version | sed 1q | cut -d' ' -f3- ) +export MCGV=$(/cgnutools/bin/${TARGET_TUPLE}-gcc --version | sed 1q | cut -d' ' -f3- ) /cgnutools/bin/${TARGET_TUPLE}-gcc -dumpspecs | sed 's/\/lib\/ld-musl/\/cgnutools\/lib\/ld-musl/g' > /cgnutools/lib/gcc/${TARGET_TUPLE}/$MCGV/specs export CFLAGS="-fPIC " @@ -65,7 +70,7 @@ cmake -G Ninja -B build -S libunwind -Wno-dev \ -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS}" \ -DLIBUNWIND_INSTALL_HEADERS=ON \ -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON \ - -DLIBUNWIND_ENABLE_STATIC=OFF \ + -DLIBUNWIND_ENABLE_STATIC=ON \ -DLIBUNWIND_HIDE_SYMBOLS=ON $CT # compile diff --git a/1-Stage0/07-Clang_lld.stage0 b/1-Stage0/07-Clang_lld.stage0 new file mode 100644 index 0000000..d859f2d --- /dev/null +++ b/1-Stage0/07-Clang_lld.stage0 @@ -0,0 +1,169 @@ +# cgnutools: Stage0 Clang+lld+llvm-base +# Build as cmlfs +# +# o Reuse llvm-project source tree from before +# o stage 0 Clang will depend on cross-gcc headers & libraries. +# It will build stage1 w/o libgcc_s & cross-gcc +# o Stage 0 clang will install in cgnutools, but Sysroot will be llvmtools. This will +# avoid duplicate building of packages. + +# Force clang to use dynamic linux loader in /llvmtools +patch -Np1 -i ../patches/llvm-cmlfs/modify-toolchain-dynamic-loader.llvmtools.patch +patch -Np1 -i ../patches/llvm-cmlfs/modify-test-dynamic-loader.llvmtools.patch + +# Built llvm-tblgen will need libstdc++.so.6 & libgcc_s.so.1. +# Set the rpath +export CFLAGS="-fPIC -I/cgnutools/include -Wl,-rpath=/cgnutools/${TARGET_TUPLE}/lib " +export CXXFLAGS=$CFLAGS + +# Set the compiler and linker flags... +export CT="-DCMAKE_C_COMPILER=${TARGET_TUPLE}-gcc " +export CT+="-DCMAKE_CXX_COMPILER=${TARGET_TUPLE}-g++ " +export CT+="-DCMAKE_AR=/cgnutools/bin/${TARGET_TUPLE}-ar " +export CT+="-DCMAKE_NM=/cgnutools/bin/${TARGET_TUPLE}-nm " +export CT+="-DCMAKE_RANLIB=/cgnutools/bin/${TARGET_TUPLE}-ranlib " +export CT+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " + +# Set the tuples & build target ... +export CTG="-DLLVM_HOST_TRIPLE=${TARGET_TUPLE} " +export CTG+="-DLLVM_TARGETS_TO_BUILD=${LARCH} " +export CTG+="-DLLVM_TARGET_ARCH=${LARCH} " +export CTG+="-DLLVM_TARGETS_TO_BUILD=Native;host;${LARCH} " + +# Set the paths ... +export CP="-DCMAKE_INSTALL_PREFIX=/cgnutools " +export CP+="-DDEFAULT_SYSROOT=/llvmtools " + +# Set LLVM options +# + Enable Exception handling and Runtime Type Info +export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " + +# Turn off LLVM options +# + Turn off features host may have +export COFF="-DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBPFM=OFF " + +# Just build clang & lld to use cross-gcc's headers & libstdcxx +cmake -B build0 -G Ninja -Wno-dev -S llvm -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="clang;lld" -DCLANG_VENDOR="cgnutools 4.0.1" \ + -DLLVM_INCLUDE_TESTS=OFF -DLIBCLANG_BUILD_STATIC=ON $CT $CP $CLLVM $COFF $CTG + +# Compile +ninja -C build0 + +# For trouble shooting: +ninja -C build0 llvm-tblgen # 264 ................................. PASS +ninja -C build0 llvm-lib # 356 .................................... PASS +ninja -C build0 lld # 1092 ........................................ PASS +ninja -C build0 clang # 1107 ...................................... PASS +ninja -C build0 # 979 ............................................. PASS + + +# Install +cmake --install build0 --strip + +# Install llvm-lit iscript for buidling standalone LLVM projects +cp -va build0/bin/llvm-lit /cgnutools/bin/ + +# Configure stage0 clang... to use cross-gcc header's and libraries. +# Once libc++ is installed in llvmtools, this config will be modified +cat > /cgnutools/bin/${TARGET_TUPLE}.cfg <> /llvmtools/etc/ld-musl-${MCA}.path + +# Test stage0 Clang +cd $CMLFS/sources +echo "int main(){}" > dummy.c +/cgnutools/bin/clang dummy.c -v -Wl,--verbose &> dummy.log +readelf -l a.out | grep ': /llvmtools' + +# Shoud output: +# [Requesting program interpreter: /llvmtools/lib/ld-musl-x86_64.so.1 + +# Check if the correct start files are used +grep 'crt[1in].o' dummy.log | grep 'ld.lld: ' +# ld.lld /llvmtools/lib/Scrt1.o +# ld.lld /llvmtools/lib/crti.o +# ld.lld /llvmtools/lib/crtn.o + +# Verify that stage0 clang is searching for the correct header files: +grep -B3 -A3 '^ /llvmtools/include' dummy.log +##include <...> search starts here: +# /cgnutools/i686-pc-linux-musl/include/c++/13.2.0 +# /cgnutools/i686-pc-linux-musl/include/c++/13.2.0/i686-pc-linux-musl +# /llvmtools/include +# /cgnutools/bin/../lib/gcc/i686-pc-linux-musl/13.2.0/../../../../i686-pc-linux-musl/include +# /mnt/cmlfs/cgnutools/lib/clang/17/include +# NOTE: The libstdcxx headers should be searched first before any other header directories. +# NOTE: Above will differ sligthly if compiling for a different arch + +# Check if stage0 clang++ [in llvmtools] has atomics. +cat > atomics-test.cpp << "EOF" +#include +std::atomic x; +std::atomic y; +std::atomic z; +int main() { + ++z; + ++y; + return ++x; +} +EOF + +/cgnutools/bin/clang++ \ +atomics-test.cpp -v -Wl,--verbose &> atomics-test.log + +# Check for errors during compile or link: +grep error: atomics-test.log +# Should return nothing if there are no errors. + +# Test if stage0 clang support C++11 +cat > cxx11-test.cpp << "EOF" +#include + #if __cplusplus==201402L + std::cout << "C++14" << std::endl; + #elif __cplusplus==201103L + std::cout << "C++11" << std::endl; + #else + std::cout << "C++" << std::endl; + #endif + + return 0; +} +EOF + +/cgnutools/bin/clang++ cxx11-test.cpp -v -Wl,--verbose &> cxx11-test.log + +# Check for errors during compile or link: +grep error: cxx11-test.log +# Should return nothing if there are no errors. +# If there is an error, this is not critical. Once libc++ is installed, this test should not fail with errors. + +# Execute the binary. Should output "C++" ... which may be a problem later. +./a.out + +# Check if stage 0 clang supports exception handling: +/cgnutools/bin/clang++ files/eh-test.cpp -v -Wl,--verbose &> eh-test.log +grep error: eh-test.log +# Should return nothing (this means no compilation errors) + +# Execute compiled binary with an argumet, say an interger: +./a.out 4 +# Should return: +# Error: Exception requested by caller +# ... which means exception handling is supported + +# Stage 0 Clang is now configured & tested to use libgcc (not compiler-rt) and libstdcxx (not libc++) + +# If all is good, remove build directory. Sourc tree will be re-used later +rm -rf build dummy.* atomics-test.* cxx11-test.* eh-test.log +unset CT CTG CP CRT CLG CLCPP CLCPPA CUW CLLVM COFF CFLAGS CXXFLAGS LINKERFLAGS diff --git a/1-Stage0/08-libcxx-headers.stage1 b/1-Stage0/08-libcxx-headers.stage1 new file mode 100644 index 0000000..8461d3a --- /dev/null +++ b/1-Stage0/08-libcxx-headers.stage1 @@ -0,0 +1,69 @@ +# cgnutools: Stage1 libc++abi & libc++ headers +# Build as cmlfs +# +# o Reuse llvm-project source tree from before +# o Install libc++abi & libc++ headers for llvmtools + +# Set the rpath +export CFLAGS="-fPIC -I/cgnutools/include " +export CXXFLAGS=$CFLAGS + +# Set the compiler and linker flags to use stage 0 clang ... +export CT="-DCMAKE_C_COMPILER=/cgnutools/bin/clang " +export CT+="-DCMAKE_CXX_COMPILER=/cgnutools/bin/clang++ " +export CT+="-DCMAKE_AR=/cgnutools/bin/llvm-ar " +export CT+="-DCMAKE_NM=/cgnutools/bin/llvm-nm " +export CT+="-DCMAKE_RANLIB=/cgnutools/bin/llvm-ranlib " + +# Set the tuples & build target ... +export CTG="-DLLVM_HOST_TRIPLE=${TARGET_TUPLE} " + +# Set the paths ... +export CP="-DCMAKE_INSTALL_PREFIX=/llvmtools " +#export CP+="-DDEFAULT_SYSROOT=/llvmtools " + +# Set LLVM options +# + Enable Exception handling and Runtime Type Info +export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " + +# Turn off LLVM options +# + Turn off features host may have +export COFF="-DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_LIBEDIT=OFF " + +# Set options fo libc++abi +export CLCPPA="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " +export CLCPPA+="-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON " +export CLCPPA+="-DLIBCXXABI_USE_COMPILER_RT=OFF " + +# Set options for libc++ +export CLCPP="-DLIBCXX_HAS_MUSL_LIBC=ON " +export CLCPP+="-DLIBCXX_ENABLE_LOCALIZATION=ON " +export CLCPP+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " +export CLCPP+="-DLIBCXX_CXX_ABI=libcxxabi " +export CLCPP+="-DLIBCXX_USE_COMPILER_RT=OFF " +export CLCPP+="-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON " +export CLCPP+="-DLIBCXX_ENABLE_ASSERTIONS=ON " + +# Configure the source to install headers +cmake -B build-headers -G Ninja -Wno-dev -S runtimes -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ + -DLLVM_INCLUDE_TESTS=OFF $CT $CP $CLLVM $COFF $CTG $CLCPPA $CLCPP \ + -DLLVM_ROOT=/cgnutools + +# Install headers for libc++abi & libc++: +ninja -C build-headers install-cxxabi-headers +ninja -C build-headers install-cxx-headers + +# Reconfigure stage0 clang +mv -v /cgnutools/bin/${TARGET_TUPLE}.cfg{,.old} +cat > /cgnutools/bin/${TARGET_TUPLE}.cfg < /cgnutools/bin/${TARGET_TUPLE}.cfg < dummy.c +/cgnutools/bin/clang dummy.c -v -Wl,--verbose &> dummy.log +readelf -l a.out | grep ': /llvmtools' +# Shoud output: +# [Requesting program interpreter: /llvmtools/lib/ld-musl-x86_64.so.1 + +# Check if compiler-rt was used: +cat dummy.log | grep 'ld.lld: ' | grep '_rt' +# Should see: +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/linux/clang_rt.crtbegin-i386.o +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/linux/libclang_rt.builtins-i386.a +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/linux/libclang_rt.builtins-i386.a +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/linux/clang_rt.crtend-i386.o +# NOTE: WIll differ slightly for different CPU arches + + +# Check if the correct start files are used +grep 'crt[1in]' dummy.log | grep ld.lld: +# attempt to open /llvmtools/lib/Scrt1.o succeeded +# attempt to open /llvmtools/lib/crti.o succeeded +# attempt to open /llvmtools/lib/crtn.o succeeded + +# Verify that stage0 clang is searching for the correct header files: +grep -B1 -A2 '^ /llvmtools/include' dummy.log +# Should output: +# #include <...> search starts here: +# /llvmtools/include/c++/v1 +# /llvmtools/include +# /cgnutools/lib/clang/17/include +# End of search list. + +# Check if stage0 clang++ [in llvmtools] still has atomics: +cat > atomics-test.cpp << "EOF" +#include +std::atomic x; +std::atomic y; +std::atomic z; +int main() { + ++z; + ++y; + return ++x; +} +EOF + +/cgnutools/bin/clang++ \ +atomics-test.cpp -v -Wl,--verbose &> atomics-test.log + +# Check for errors during compile or link: +grep error: atomics-test.log +# Should return nothing if there are no errors. + +# Test if stage0 clang support C++11 +cat > cxx11-test.cpp << "EOF" +#include + +int main(){ + #if __cplusplus==201402L + std::cout << "C++14" << std::endl; + #elif __cplusplus==201103L + std::cout << "C++11" << std::endl; + #else + std::cout << "C++" << std::endl; + #endif + + return 0; +} +EOF + +/cgnutools/bin/clang++ cxx11-test.cpp -v -Wl,--verbose &> cxx11-test.log + +# Check for errors during compile or link: +grep error: cxx11-test.log +# Should return no errors. + diff --git a/1-Stage0/3-musl b/1-Stage0/3-musl deleted file mode 100644 index 8d8d7aa..0000000 --- a/1-Stage0/3-musl +++ /dev/null @@ -1,52 +0,0 @@ -# llvmtools: Musl libc -# Build as cmlfs - -# Configure with freshly built GCC -./configure \ - CROSS_COMPILE=${TARGET_TUPLE}- \ - --prefix=/ \ - --target=${TARGET_TUPLE} - -# Buid and install -make && make DESTDIR=/llvmtools install - -# Fix a symlink -rm -v /llvmtools/lib/ld-musl-$(uname -m).so.1 -ln -sv libc.so /llvmtools/lib/ld-musl-$(uname -m).so.1 - -# Create a symlink that can be used to print -# the required shared objects of a program or -# shared object -mkdir /llvmtools/{etc,bin} -ln -sv ../lib/libc.so /llvmtools/bin/ldd - -# Configure the dynamic linker -cat > /llvmtools/etc/ld-musl-${MCA}.path < /cgnutools/lib/gcc/${TARGET_TUPLE}/$MCGV/specs - -# Test the _tools toolchain: -cd $CMLFS/sources -printf "#include \nint main(){}\n" > dummy.c -${TARGET_TUPLE}-gcc dummy.c -readelf -l a.out | grep ld - -# Should output: -# [Requesting program interpreter: /llvmtools/lib/ld-musl-x86_64.so.1] -# If matching, clean up: -rm -rf a.out dummy.c diff --git a/1-Stage0/7-LLVM.stage0 b/1-Stage0/7-LLVM.stage0 deleted file mode 100644 index 59cd053..0000000 --- a/1-Stage0/7-LLVM.stage0 +++ /dev/null @@ -1,231 +0,0 @@ -# cgnutools: Stage0 Clang ( with compiler-rt,libcxx,libcxxabi,libunwind,lld) -# Build as cmlfs -# -# o Reuse llvm-project source tree from before -# o stage 0 Clang will depend on libgcc_s. It will build stage1 w/o libgcc_s -# o Stage0 wll install in cgnutools, but Sysroot will be llvmtools. This will -# avoid duplicate building of packages. - -# Force clang to use dynamic linux loader in /llvmtools -patch -Np1 -i ../patches/llvm-cmlfs/modify-toolchain-dynamic-loader.llvmtools.patch -patch -Np1 -i ../patches/llvm-cmlfs/modify-test-dynamic-loader.llvmtools.patch - -# Built llvm-tblgen will need libstdc++.so.6 & libgcc_s.so.1. -# Set the rpath -export CFLAGS='-fPIC -I/cgnutools/include -Wl,-rpath=/cgnutools/lib ' -export CXXFLAGS=$CFLAGS - -# Set the compiler and linker flags... -export CT="-DCMAKE_C_COMPILER=${TARGET_TUPLE}-gcc " -export CT+="-DCMAKE_CXX_COMPILER=${TARGET_TUPLE}-g++ " -export CT+="-DCMAKE_AR=/cgnutools/bin/${TARGET_TUPLE}-ar " -export CT+="-DCMAKE_NM=/cgnutools/bin/${TARGET_TUPLE}-nm " -export CT+="-DCMAKE_RANLIB=/cgnutools/bin/${TARGET_TUPLE}-ranlib " -export CT+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " -export CT+="-DGNU_LD_EXECUTABLE=/cgnutools/bin/${CMLFS_TARGET}-ld.bfd " - -# Set the tuples & build target ... -export CTG="-DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TUPLE} " -export CTG+="-DLLVM_HOST_TRIPLE=${TARGET_TUPLE} " -export CTG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${TARGET_TUPLE} " -export CTG+="-DLLVM_TARGETS_TO_BUILD=host " -export CTG+="-DLLVM_TARGET_ARCH=host " -export CTG+="-DLLVM_TARGETS_TO_BUILD=Native;host " - -# Set the paths ... -export CP="-DCMAKE_INSTALL_PREFIX=/cgnutools " -export CP+="-DDEFAULT_SYSROOT=/llvmtools " - -# Set options for compiler-rt -# + avoid all the optional runtimes: -export CRT="-DCOMPILER_RT_BUILD_SANITIZERS=OFF " -export CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " -export CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " -export CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " -export CRT+="-DCOMPILER_RT_BUILD_MEMPROF=OFF " -# + Avoid need for libexecinfo: -export CRT+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " -export CRT+="-DCOMPILER_RT_USE_LLVM_UNWINDER=ON " -export CRT+="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF " - -# Set options for clang -# + Set the standard C++ library that clang will use to LLVM's libc++ -# + Set compiler-rt as default runtime -export CLG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " -export CLG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " -export CLG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " -export CLG+="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " - -# Set options for libc++ -export CLCPP="-DLIBCXX_HAS_MUSL_LIBC=ON " -export CLCPP+="-DLIBCXX_ENABLE_LOCALIZATION=ON " -export CLCPP+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " -export CLCPP+="-DLIBCXX_CXX_ABI=libcxxabi " -export CLCPP+="-DLIBCXX_USE_COMPILER_RT=OFF " -export CLCPP+="-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON " -export CLCPP+="-DLIBCXX_ENABLE_ASSERTIONS=ON " - -# Set options fo libc++abi -export CLCPPA="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " -export CLCPPA+="-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON " -export CLCPPA+="-DLIBCXXABI_USE_COMPILER_RT=OFF " - -# Set options for libunwind -export CUW="-DLIBUNWIND_INSTALL_HEADERS=ON " -#export CUW+="-DLIBUNWIND_USE_COMPILER_RT=ON " - -# Set LLVM options -# + Enable Exception handling and Runtime Type Info -export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " -export CLLVM+="-DLLVM_ENABLE_ZLIB=ON " -export CLLVM+="-DLLVM_INSTALL_UTILS=ON " -export CLLVM+="-DLLVM_BUILD_LLVM_DYLIB=ON " -export CLLVM+="-DLLVM_LINK_LLVM_DYLIB=ON " -export CLLVM+="-DENABLE_LINKER_BUILD_ID=ON " -export CLLVM+="-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON " -#export CLLVM+="-DLLVM_ENABLE_LIBCXX=ON " -#export CLLVM+="-DLLVM_ENABLE_LLD=ON " - -# Turn off LLVM options -# + Turn off features host may have -export COFF="-DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_LIBEDIT=OFF " -export COFF+="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_LIBEDIT=OFF " -export COFF+="-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBPFM=OFF " - -# libunwind is now not considered as a project, but as a runtime -cmake -B build -G Ninja -Wno-dev -S llvm \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \ - -DLLVM_ENABLE_PROJECTS="clang;lld" \ - -DCLANG_VENDOR="cgnutools 4.0.0" -DLLD_VENDOR="cgnutools 4.0.0" \ - $CT $CTG $CP $CRT $CLG $CLCPP $CLCPPA $CUW $CLLVM $COFF - -# compile -ninja -C build - -# For troubleshooting, this is the breakdown of build targets: -# Note: Order from least to most deps not acertained yet. -ninja -C build lld # ............................................... PASS -ninja -C build clang # ............................................. PASS -ninja -C build llvm-tblgen # ....................................... PASS -ninja -C build llvm-lib # 1868 targets ............................. PASS -ninja -C build cxxabi # 1370 targets ............................... PASS -ninja -C build cxx # 105 targets ................................... PASS -ninja -C build libclang # 31 targets ............................... PASS -ninja -C build compiler-rt # 5 targets ............................. PASS -ninja -C build unwind # 5 targets .................................. PASS -ninja -C build builtins # 3 targets ................................ PASS -ninja -C build # 570 ............................................... PASS - -# install to cgnutools -cmake --install build --strip - -# Make LLD the default linker -rm -v /cgnutools/bin/ld -ln -sv lld /cgnutools/bin/ld - -# Disable cross-gcc ... will use stage0 clang instead -mv -v /cgnutools/lib/gcc{,-disabled} - -# Configure stage0 clang -cat > /cgnutools/bin/${TARGET_TUPLE}.cfg <> /llvmtools/etc/ld-musl-${MCA}.path - -# Test stage0 Clang -echo "int main(){}" > dummy.c -/cgnutools/bin/${TARGET_TUPLE}-clang dummy.c -v -Wl,--verbose &> dummy.log -readelf -l a.out | grep ': /llvmtools' -# Shoud output: -# [Requesting program interpreter: /llvmtools/lib/ld-musl-x86_64.so.1 - -# Check if the correct start files are used -grep 'crt[1in]' dummy.log | grep ld.lld: -# Should output: -# ld.lld: /llvmtools/lib/Scrt1.o -# ld.lld: /llvmtools/lib/crti.o -# ld.lld: /llvmtools/lib/crtn.o - -# Make sure no libraries are loaded from the host -grep ld.lld: dummy.log -# Should output: -# ld.lld: /llvmtools/lib/Scrt1.o -# ld.lld: /llvmtools/lib/crti.o -# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/x86_64-pc-linux-musl/clang_rt.crtbegin.o -# ld.lld: /tmp/dummy-ffb57c.o -# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/x86_64-pc-linux-musl/libclang_rt.builtins.a -# ld.lld: /llvmtools/lib/libunwind.so -# ld.lld: /llvmtools/lib/libatomic.so -# ld.lld: /llvmtools/lib/libc.so -# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/x86_64-pc-linux-musl/libclang_rt.builtins.a -# ld.lld: /llvmtools/lib/libunwind.so -# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/17/lib/x86_64-pc-linux-musl/clang_rt.crtend.o -# ld.lld: /llvmtools/lib/crtn.o - -# Verify that stage0 clang is searching for the correct header files: -grep -B2 -A1 '^ /llvmtools/include' dummy.log -# It should output in this order: -# /cgnutools/include/c++/v1 -# /llvmtools/include -# /mnt/cmlfs/cgnutools/lib/clang/15.0.6/include -# NOTE: The libc++ headers should be searched first before any other header directories. - -# Check if stage0 clang++ [in llvmtools] has atomics. -cat > atomics-test.cpp << "EOF" -#include -std::atomic x; -std::atomic y; -std::atomic z; -int main() { - ++z; - ++y; - return ++x; -} -EOF - -/cgnutools/bin/${TARGET_TUPLE}-clang++ \ -atomics-test.cpp -v -Wl,--verbose &> atomics-test.log - -# Check for errors during compile or link: -grep error: atomics-test.log -# Should return nothing if there are no errors. - -# Test if stage0 clang support C++11 -cat > cxx11-test.cpp << "EOF" -#include - -int main(){ - #if __cplusplus==201402L - std::cout << "C++14" << std::endl; - #elif __cplusplus==201103L - std::cout << "C++11" << std::endl; - #else - std::cout << "C++" << std::endl; - #endif - - return 0; -} -EOF - -${TARGET_TUPLE}-clang++ cxx11-test.cpp -v -Wl,--verbose &> cxx11-test.log - -# Check for errors during compile or link: -grep error: cxx11-test.log -# Should return nothing if there are no errors. - -# Execute the binary. Should output "C++" ... which may be a problem later. -./a.out - -# If all is good, remove build directory. Sourc tree will be re-used later -rm -rf build dummy.* atomics-test.* cxx11-test.* -unset CT CTG CP CRT CLG CLCPP CLCPPA CUW CLLVM COFF CFLAGS CXXFLAGS LINKERFLAGS diff --git a/2-Stage1/01-Stage1.LLVM b/2-Stage1/01-Stage1.LLVM index af46cc0..9749755 100644 --- a/2-Stage1/01-Stage1.LLVM +++ b/2-Stage1/01-Stage1.LLVM @@ -1,4 +1,4 @@ -# llvmtools: Stage1 clang (with compiler-rt,libcxx,libcxxabi,libunwind,lld) +# llvmtools: Stage1 clang (with lld) # Build as cmlfs # # o Reuse llvm-project source tree from before @@ -8,8 +8,8 @@ export CFLAGS="-fPIC -I/cgnutools/include" export CXXFLAGS=$CFLAGS # Set the compiler and linker flags... -export CT="-DCMAKE_C_COMPILER=${TARGET_TUPLE}-clang " -export CT+="-DCMAKE_CXX_COMPILER=${TARGET_TUPLE}-clang++ " +export CT="-DCMAKE_C_COMPILER=/cgnutools/bin/clang " +export CT+="-DCMAKE_CXX_COMPILER=/cgnutools/bin/clang++ " export CT+="-DCMAKE_AR=/cgnutools/bin/llvm-ar " export CT+="-DCMAKE_NM=/cgnutools/bin/llvm-nm " export CT+="-DCMAKE_RANLIB=/cgnutools/bin/llvm-ranlib " @@ -19,8 +19,8 @@ export CT+="-DCLANG_DEFAULT_LINKER=/llvmtools/bin/ld.lld " export CTG="-DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TUPLE} " export CTG+="-DLLVM_HOST_TRIPLE=${TARGET_TUPLE} " export CTG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${TARGET_TUPLE} " -export CTG+="-DLLVM_TARGET_ARCH=host " -export CTG+="-DLLVM_TARGETS_TO_BUILD=Native;host " +export CTG+="-DLLVM_TARGET_ARCH=${LARCH} " +export CTG+="-DLLVM_TARGETS_TO_BUILD=Native;host;${LARCH} " # Set the paths ... export CP="-DCMAKE_INSTALL_PREFIX=/llvmtools " @@ -86,40 +86,57 @@ export COFF+="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_LIBEDIT=OFF " export COFF+="-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBPFM=OFF " export COFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " +###################################################################################### # Configure source... -cmake -B build -G Ninja -Wno-dev -S llvm \ +cmake -B build1 -G Ninja -Wno-dev -S llvm \ -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_PROJECTS="compiler-rt;libunwind;libcxx;libcxxabi;lld;clang" \ - -DCLANG_VENDOR="llvmtools 3.0.0" -DLLD_VENDOR="llvmtools 3.0.0" \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \ + -DLLVM_ENABLE_PROJECTS="lld;clang" \ + -DCLANG_VENDOR="llvmtools 4.0.1" -DLLD_VENDOR="llvmtools 4.0.1" \ $CT $CTG $CP $CRT $CLG $CLCPP $CLCPPA $CUW $CLLVM $COFF -# libunwind is now not considered as a project, but as a runtime -cmake -B build -G Ninja -Wno-dev -S llvm \ +# compile +ninja -C build1 + +# For troubleshooting, this is the breakdown of build targets: +ninja -C build1 llvm-headers # 198 targets .................. PASS +ninja -C build1 llvm-tblgen # 68 .......................... PASS +ninja -C build1 llvm-lib # .. 1598 .......................... PASS +ninja -C build1 unwind # .... 1370 .......................... FAIL: :1:10: fatal error: 'stdc-predef.h' file not found +ninja -C build1 compiler-rt # .. 5 .......................... +ninja -C build1 builtins # ..... 3 .......................... +ninja -C build1 cxxabi # .... 1051 .......................... +ninja -C build1 cxx # ........ 103 .......................... +ninja -C build1 lld # ....................................... +ninja -C build1 clang # ..................................... +ninja -C build1 libclang # .... 31 .......................... +ninja -C build1 # ............ 508 .......................... +################################################################################################ + +# Just build stage 1 clang+lld+llvm-base +cmake -B build1 -G Ninja -Wno-dev -S llvm \ -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \ -DLLVM_ENABLE_PROJECTS="lld;clang" \ - -DCLANG_VENDOR="llvmtools 4.0.0" -DLLD_VENDOR="llvmtools 4.0.0" \ - $CT $CTG $CP $CRT $CLG $CLCPP $CLCPPA $CUW $CLLVM $COFF + -DCLANG_VENDOR="llvmtools 4.0.1" -DLLD_VENDOR="llvmtools 4.0.1" \ + $CT $CTG $CP $CLG $CLLVM $COFF +# unused : +# COMPILER_RT_DEFAULT_TARGET_TRIPLE + # compile -ninja -C build +ninja -C build1 # For troubleshooting, this is the breakdown of build targets: -ninja -C build llvm-headers # 202 targets .................. PASS -ninja -C build llvm-tblgen # 68 .......................... PASS -ninja -C build llvm-lib # .. 1598 .......................... PASS -ninja -C build unwind # .... 1370 .......................... PASS -ninja -C build compiler-rt # .. 5 .......................... PASS -ninja -C build builtins # ..... 3 .......................... PASS -ninja -C build cxxabi # .... 1051 .......................... PASS -ninja -C build cxx # ........ 103 .......................... PASS -ninja -C build lld # ....................................... PASS -ninja -C build clang # ..................................... PASS -ninja -C build libclang # .... 31 .......................... PASS -ninja -C build # ............ 508 .......................... PASS +ninja -C build1 llvm-headers # 198 targets .................. PASS +ninja -C build1 llvm-tblgen # 68 .......................... PASS +ninja -C build1 llvm-lib # .. 1598 .......................... PASS +ninja -C build1 lld # ........ 126 .......................... PASS +ninja -C build1 clang # ......1181 .......................... PASS +ninja -C build1 libclang # .... 31 .......................... PASS +ninja -C build1 # ............ 588 .......................... PASS # install to llvmtools -cmake --install build --strip +cmake --install build1 --strip # Make LLD the default linker ln -sv lld /llvmtools/bin/ld @@ -242,7 +259,7 @@ llvm-readelf -d /llvmtools/lib/libc++.so.1.0 | grep Shared | cut -b 37- # Shared library: [libc.so] llvm-readelf -d /llvmtools/lib/libc++abi.so.1.0 | grep Shared | cut -b 37- # Shared library: [libc.so] -llvm-readelf -d /llvmtools/lib/libLLVM-17.0.5.so | grep Shared | cut -b 37- +llvm-readelf -d /llvmtools/lib/libLLVM-17.0.6.so | grep Shared | cut -b 37- # Shared library: [libz.so.1] # Shared library: [libc++.so.1] # Shared library: [libc.so] diff --git a/2-Stage1/15-lsb_script b/2-Stage1/15-lsb_script index d69f6aa..1d43811 100644 --- a/2-Stage1/15-lsb_script +++ b/2-Stage1/15-lsb_script @@ -14,18 +14,18 @@ chmod -v +x /llvmtools/bin/lsb_release # Create the status of the new system with respect to the Linux Standards # Base (LSB) -cat > /llvmtools/etc/lsb-release << "EOF" +cat > /llvmtools/etc/lsb-release << EOF DISTRIB_ID="llvmtools" -DISTRIB_RELEASE="4.0.0_amd64" +DISTRIB_RELEASE="4.0.1_${CMLFS_CPU}" DISTRIB_CODENAME="17-elftool-tools" -DISTRIB_DESCRIPTION="Clang-built Musl Toolchain for CMLFS, AMD64" +DISTRIB_DESCRIPTION="Clang-built Musl Toolchain for CMLFS, ${CMLFS_CPU}" EOF # The same information but used by some graphical desktop environments: -cat > /llvmtools/etc/os-release << "EOF" +cat > /llvmtools/etc/os-release << EOF NAME="llvmtools" -VERSION="4.0.0_amd64" +VERSION="4.0.1_${CMLFS_CPU}" ID=llvmtools -PRETTY_NAME="Clang-built Musl Toolchain for CMLFS, AMD64" +PRETTY_NAME="Clang-built Musl Toolchain for CMLFS, ${CMLFS_CPU}" VERSION_CODENAME="17-elftool-tools" EOF diff --git a/3-chroot/002-Enter_Chroot b/3-chroot/002-Enter_Chroot index d40ce8e..0ea0bcc 100644 --- a/3-chroot/002-Enter_Chroot +++ b/3-chroot/002-Enter_Chroot @@ -1,6 +1,11 @@ # Enter the Chroot Environment # This section is done by root +# NOTE: If building a different arch than the host, +# Prefix chrrot with setarch. For expample, +# to enter a 32-bit chroot on a x86_64 host: +# setarch linux32 chroot + chroot "$CMLFS" /llvmtools/bin/env -i \ HOME=/root \ TERM="$TERM" \ @@ -12,15 +17,15 @@ chroot "$CMLFS" /llvmtools/bin/env -i \ case $(uname -m) in i686) export TUPLE="i686-pc-linux-musl" - export MCA="i386" ;; + export MCA="i386" LARCH="X86" ;; x86_64) export TUPLE="x86_64-pc-linux-musl" - export MCA="x86_64" ;; + export MCA="x86_64" LARCH="X86" ;; aarch64) export TUPLE="aarch64-pc-linux-musleabihf" - export MCA="aarch64" ;; + export MCA="aarch64" LARCH="AArch64" ;; armv7*) export TUPLE="armv7l-pc-linux-musleabihf" - export MCA="arm" ;; + export MCA="arm" LARCH="ARM" ;; armv6*) export TUPLE="armv6l-pc-linux-musleabihf" - export MCA="arm" ;; + export MCA="arm" LARCH="ARM" ;; esac # Set clang as the default C/C++ compiler diff --git a/3-chroot/009-Perl b/3-chroot/009-Perl index 0b2bebe..3999258 100644 --- a/3-chroot/009-Perl +++ b/3-chroot/009-Perl @@ -32,8 +32,8 @@ make # Only a few of the utilities and libraries need to be installed to toolchain cp -v perl cpan/podlators/scripts/pod2man /llvmtools/bin -mkdir -pv /llvmtools/lib/perl5/5.38.0 -cp -Rv lib/* /llvmtools/lib/perl5/5.38.0 +mkdir -pv /llvmtools/lib/perl5/5.38.2 +cp -Rv lib/* /llvmtools/lib/perl5/5.38.2 unset BUILD_ZLIB BUILD_BZIP2 CFLAGS diff --git a/3-chroot/011-Python3 b/3-chroot/011-Python3 index 676ffab..713fa27 100644 --- a/3-chroot/011-Python3 +++ b/3-chroot/011-Python3 @@ -2,7 +2,7 @@ # Build under chroot # Apply fixes to build under musl -patch -Np0 -i ../patches/python-alpine/musl-find_library.patch +patch -Np1 -i ../patches/python-alpine/musl-find_library.patch # If adding optional python-based tools to toolchain, like # meson, make sure pip3 is built diff --git a/3-chroot/016.a-tcl b/3-chroot/016.a-tcl index f6951aa..cba69c7 100644 --- a/3-chroot/016.a-tcl +++ b/3-chroot/016.a-tcl @@ -2,6 +2,10 @@ # Build and install under chroot # Can be optional: Package used for testing final system packages +# Bootstrap script still tries to use ar +# intead of llvm-ar. +ln -sv llvm-ar /llvmtools/bin/ar + # Change directories: cd unix @@ -27,4 +31,5 @@ chmod -v u+w /llvmtools/lib/libtcl8.6.so make install-private-headers ln -sv tclsh8.6 /llvmtools/bin/tclsh - +# Remove the link made earlier +rm -v /llvmtools/bin/ar diff --git a/3-chroot/017.b-Nano b/3-chroot/017.b-Nano index 19d2429..fe63981 100644 --- a/3-chroot/017.b-Nano +++ b/3-chroot/017.b-Nano @@ -15,7 +15,7 @@ RANLIB=llvm-ranlib \ LD=ld.lld \ STRIP=llvm-strip \ ./configure --build=${TUPLE} \ - --host=${TTUPLE} \ + --host=${TUPLE} \ --prefix=/llvmtools \ --enable-tiny diff --git a/4-Final_System/003-Musl b/4-Final_System/003-Musl index 249fab0..6de15a0 100644 --- a/4-Final_System/003-Musl +++ b/4-Final_System/003-Musl @@ -13,15 +13,15 @@ patch -Np1 -i ../patches/musl-mlfs/fix-utmp-wtmp-paths.patch # Harden musl libc with scudo from compiler-rt # o Extract compiler-rt -cd .. && tar xf pkgs/compiler-rt-17.0.5.src.tar.xz +cd .. && tar xf pkgs/compiler-rt-17.0.6.src.tar.xz # o Copy over scudo from compiler-rt cd - && mkdir -pv src/malloc/scudo/scudo for t in cpp h inc do - cp -rv ../compiler-rt-17.0.5.src/lib/scudo/standalone/*.$t src/malloc/scudo/ + cp -rv ../compiler-rt-17.0.6.src/lib/scudo/standalone/*.$t src/malloc/scudo/ done -cp -rv ../compiler-rt-17.0.5.src/lib/scudo/standalone/include/scudo/interface.h \ +cp -rv ../compiler-rt-17.0.6.src/lib/scudo/standalone/include/scudo/interface.h \ src/malloc/scudo/scudo/ # o Remove wrappers ... rm -v src/malloc/scudo/wrappers_c* diff --git a/4-Final_System/004-Adjust_Toolchain b/4-Final_System/004-Adjust_Toolchain index 632430f..cfaf876 100644 --- a/4-Final_System/004-Adjust_Toolchain +++ b/4-Final_System/004-Adjust_Toolchain @@ -3,8 +3,6 @@ # Create a new configuration for stage1 clang: touch /llvmtools/bin/$(uname -m)-pc-linux-musl.cfg -ln -sv clang-17 /llvmtools/bin/$(uname -m)-pc-linux-musl-clang -ln -sv clang-17 /llvmtools/bin/$(uname -m)-pc-linux-musl-clang++ # Re-configure clang to use new sysroot (/) with newly built musl Libc echo "--sysroot=/ " > \ @@ -25,10 +23,6 @@ cat >> /llvmtools/bin/$(uname -m)-pc-linux-musl.cfg << EOF -I/llvmtools/lib/clang/17/include EOF -# Update the build environment -export CC=$(uname -m)-pc-linux-musl-clang -export CXX=$(uname -m)-pc-linux-musl-clang++ - # Adjust the library search path for the dynamic loader in llvmtools: cp -v /llvmtools/etc/ld-musl-${MCA}.path{,.orig} cat > /llvmtools/etc/ld-musl-${MCA}.path < search starts here: -# /llvmtools/include/c++/v1 -# /usr/include +# /llvmtools/include/c++/v1 +# /usr/include +# /llvmtools/include +# /llvmtools/lib/clang/17/include +# End of search list. # Verify that the new linker is being used with the # correct search paths: diff --git a/4-Final_System/009-Xz-utils b/4-Final_System/009-Xz-utils index 983bd43..bf83491 100644 --- a/4-Final_System/009-Xz-utils +++ b/4-Final_System/009-Xz-utils @@ -4,7 +4,7 @@ CC=$CC CXX=$CXX \ ./configure --prefix=/usr \ --disable-static \ - --docdir=/usr/share/doc/xz-5.4.5 + --docdir=/usr/share/doc/xz-5.4.6 make && make install diff --git a/4-Final_System/011-LLVM-1.Stage2 b/4-Final_System/011-LLVM-1.Stage2 deleted file mode 100644 index e72ecde..0000000 --- a/4-Final_System/011-LLVM-1.Stage2 +++ /dev/null @@ -1,305 +0,0 @@ -# Final Stage2 clang (with compiler-rt,libcxx,libcxxabi,libunwind,lld) -# Build under chroot -# -# NOTE: Reuse llvm-project source tree from before - -# Restore default dynamic linker/loader path to /lib -patch -Np1 -i ../patches/llvm-cmlfs/modify-test-dynamic-loader.restore.patch -patch -Np1 -i ../patches/llvm-cmlfs/modify-toolchain-dynamic-loader.restore.patch - -# stage1 clang cannot find zstd headers -ln -sv /usr/include/zstd.h /llvmtools/include/ - -export CFLAGS="-fPIC " -export CXXFLAGS=$CFLAGS - -# Set the compiler and linker flags... -export CT="-DCMAKE_C_COMPILER=clang " -export CT+="-DCMAKE_CXX_COMPILER=clang++ " -export CT+="-DCMAKE_AR=/llvmtools/bin/llvm-ar " -export CT+="-DCMAKE_NM=/llvmtools/bin/llvm-nm " -export CT+="-DCMAKE_RANLIB=/llvmtools/bin/llvm-ranlib " -export CT+="-DCLANG_DEFAULT_LINKER=/usr/bin/ld.lld " - -# Set the tuples & build target ... -export CTG="-DLLVM_DEFAULT_TARGET_TRIPLE=${TUPLE} " -export CTG+="-DLLVM_HOST_TRIPLE=${TUPLE} " -export CTG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${TUPLE} " -export CTG+="-DLLVM_TARGET_ARCH=host " -export CTG+="-DLLVM_TARGETS_TO_BUILD=Native;host;AMDGPU;BPF " - -# Set the paths ... -export CP="-DCMAKE_INSTALL_PREFIX=/usr " -export CP+="-DCMAKE_INSTALL_LIBDIR=lib " - -# Set options for compiler-rt -# + avoid all the optional runtimes: -#export CRT="-DCOMPILER_RT_BUILD_SANITIZERS=OFF " -#export CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " -#export CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " -#export CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " -#export CRT+="-DCOMPILER_RT_BUILD_MEMPROF=OFF " -# + Avoid need for libexecinfo: -export CRT="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " -export CRT+="-DCOMPILER_RT_USE_LLVM_UNWINDER=ON " -export CRT+="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON " -# + Set compiler_rt to use libcxx -export CRT+="-DCOMPILER_RT_CXX_LIBRARY=libcxx " - -# Set options for clang -# + Set the standard C++ library that clang will use to LLVM's libc++ -# + Set compiler-rt as default runtime -export CLG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " -export CLG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " -export CLG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " -export CLG+="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " - -# Set options for libc++ -export CLCPP="-DLIBCXX_HAS_MUSL_LIBC=ON " -export CLCPP+="-DLIBCXX_ENABLE_LOCALIZATION=ON " -export CLCPP+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " -export CLCPP+="-DLIBCXX_CXX_ABI=libcxxabi " -export CLCPP+="-DLIBCXX_USE_COMPILER_RT=ON " -export CLCPP+="-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON " -export CLCPP+="-DLIBCXX_ENABLE_ASSERTIONS=ON " - -# Set options fo libc++abi -export CLCPPA="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " -export CLCPPA+="-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON " -export CLCPPA+="-DLIBCXXABI_USE_COMPILER_RT=ON " - -# Set options for libunwind -export CUW="-DLIBUNWIND_INSTALL_HEADERS=ON " -export CUW+="-DLIBUNWIND_USE_COMPILER_RT=ON " - -# Set LLVM options -# + Enable Exception handling and Runtime Type Info -export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " -export CLLVM+="-DLLVM_ENABLE_ZLIB=ON " -export CLLVM+="-DZLIB_INCLUDE_DIR=/usr/include " -export CLLVM+="-DZLIB_LIBRARY_RELEASE=/usr/lib/libz.so " -export CLLVM+="-DLLVM_INSTALL_UTILS=ON " -export CLLVM+="-DLLVM_BUILD_LLVM_DYLIB=ON " -export CLLVM+="-DLLVM_LINK_LLVM_DYLIB=ON " -export CLLVM+="-DENABLE_LINKER_BUILD_ID=ON " -export CLLVM+="-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON " -export CLLVM+="-DLLVM_ENABLE_LIBCXX=ON " -export CLLVM+="-DLLVM_ENABLE_LLD=ON " -export CLLVM+="-DLLVM_ENABLE_ZSTD=ON " -export CLLVM+="-DLLVM_ENABLE_TERMINFO=ON " - -# Turn off LLVM options -# + Turn off features host may have -export COFF="-DLLVM_ENABLE_LIBEDIT=OFF " -export COFF+="-DLLVM_ENABLE_LIBXML2=OFF " -export COFF+="-DLLVM_ENABLE_LIBPFM=OFF " - -# Remove more tests & docs that breaks build -export MOFF="-DCLANG_INCLUDE_TESTS=OFF " -export MOFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " -export MOFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " -export MOFF+="-DLLVM_INCLUDE_DOCS=OFF " -export MOFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " -export MOFF+="-DLLVM_INCLUDE_TESTS=OFF " - -# Configure source [to build all of LLVM] -cmake -B build -G Ninja -Wno-dev -S llvm \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_PROJECTS="lld;clang" \ - -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" \ - -DCLANG_VENDOR="CMLFS 4.0.0" -DLLD_VENDOR="CMLFS 4.0.0" \ - -DDEFAULT_SYSROOT="/usr" \ - $CT $CTG $CP $CRT $CLG $CLCPP $CLCPPA $CUW $CLLVM $COFF $MOFF \ - -DCMAKE_CXX_FLAGS="-fPIC " \ - -DCMAKE_C_FLAGS="-fPIC " - -# compile (~ 4,048 targets) -ninja -C build - -# If build fails to compile, use below to see what component failed. -# ninja -C build $TARGET -# Build target break down (still unsure of order): -# * Count is based on the x86_64-pc-linux-musl target -# -# $TARGET ......... COUNT ........ STATUS -# llvm-headers ...... 202 ......... PASS -# llvm-tblgen ........ 68 ......... PASS -# llvm-lib ......... 1812 ......... PASS -# lld ............... 126 ......... PASS -# clang ............ 1181 ......... PASS -# builtins ........... 56 ......... PASS -# cxxabi ........... 1067 ......... PASS -# cxx ............... 103 ......... PASS -# compiler-rt ....... 582 ......... PASS -# libclang ........... 31 ......... PASS -# unwind .............. 5 ......... PASS -# ....... 530 ......... PASS - -# Install -cmake --install build --strip - -# Fix the dynamic linker for the executables: -for b in bugpoint c-index-test clang-17 count diagtool dsymutil FileCheck \ - llc lld lli lli-child-target not obj2yaml opt sancov sanstats \ - split-file UnicodeNameMappingGenerator verify-uselistorder yaml2obj \ - yaml-bench amdgpu-arch nvptx-arch -do - setDL /usr/bin/$b -done - -for b in check extdef-mapping format linker-wrapper \ - offload-bundler offload-packager \ - rename repl scan-deps scan-deps tblgen -do - setDL /usr/bin/clang-$b -done - -for b in ar as bcanalyzer cat cfi-verify config cov c-test cvtres cxxdump \ - cxxfilt cxxmap debuginfod debuginfod-find diff dis dwarfdump \ - dwarfutil dwp exegesis extract gsymutil ifs jitlink jitlink-executor \ - libtool-darwin link lipo lto lto2 mc mca ml modextract mt nm objcopy \ - objdump opt-report pdbutil PerfectShuffle profdata profgen rc readobj \ - reduce remark-size-diff rtdyld sim size split stress strings \ - symbolizer tapi-diff tblgen tli-checker undname xray remarkutil \ - debuginfo-analyzer -do - setDL /usr/bin/llvm-$b -done - -# NOTE: stage2 clang loads libc shared object from llvmtools. -# Sysroot still set to /llvmtools -# Create a clang config to set sysroot to / -cat > /usr/bin/${TUPLE}.cfg << "EOF" ---sysroot=/ -EOF - -# NOTE: Stage2 clang looks for ld/lld first /llvmtools/bin -# Disable it: -mv -v /llvmtools/bin/lld{,.disabled} - -# Test stage2 Clang -echo "int main(){}" > dummy.c -/usr/bin/clang dummy.c -v -Wl,--verbose &> dummy.log -llvm-readelf -l a.out | grep ': /lib' -# Shoud output: -# [Requesting program interpreter: /lib/ld-musl-x86_64.so.1 - -# Check if the correct start files are used -grep 'crt[1in]' dummy.log | grep ld: -# Should output: -# ld: /lib/Scrt1.o -# ld: /lib/crti.o -# ld: /lib/crtn.o -# * /lib is a link to /usr/lib, therefore this is acceptable -# * ld is a link to ld.lld, therefore this is acceptable - -# Verify that stage2 clang is searching for the correct header files: -grep -B1 -A1 '^ /usr' dummy.log -# It should output: -# #include <...> search starts here: -# /usr/local/include -# /usr/include -# /usr/lib/clang/17/include -# End of search list. - -# Make sure no libraries are loaded from llvmtools -grep ld: dummy.log -# ld.lld: /lib/Scrt1.o -# ld.lld: /lib/crti.o -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/clang_rt.crtbegin.o -# ld.lld: /tmp/dummy-1f0e32.o -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/libclang_rt.builtins.a -# ld.lld: /lib/libunwind.so -# ld.lld: /lib/libatomic.so -# ld.lld: /lib/libc.so -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/libclang_rt.builtins.a -# ld.lld: /lib/libunwind.so -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/clang_rt.crtend.o -# ld.lld: /lib/crtn.o - -# Check if stage2 clang++ supports atomics. -cat > atomics-test.cpp << "EOF" -#include -std::atomic x; -std::atomic y; -std::atomic z; -int main() { - ++z; - ++y; - return ++x; -} -EOF - -/usr/bin/clang++ \ -atomics-test.cpp -v -Wl,--verbose &> atomics-test.log - -# Check for errors during compile or link: -grep error: atomics-test.log -# Should return nothing if there are no errors. - -# Make sure stage2 clang can find libc++ headers: -grep -B4 -A1 '^ /usr/lib' atomics-test.log -# It should output this order: -# #include <...> search starts here: -# /usr/bin/../include/c++/v1 -# /usr/local/include -# /usr/include -# /usr/lib/clang/17/include -# It should be in this order - -# Test if stage1 clang supports C++11 -cat > cxx11-test.cpp << "EOF" -#include - -int main(){ - #if __cplusplus==201402L - std::cout << "C++14" << std::endl; - #elif __cplusplus==201103L - std::cout << "C++11" << std::endl; - #else - std::cout << "C++" << std::endl; - #endif - - return 0; -} -EOF - -/usr/bin/clang++ cxx11-test.cpp -v -Wl,--verbose &> cxx11-test.log - -# Check for errors during compile or link: -grep error: cxx11-test.log -# Should return nothing if there are no errors. - -# Execute the binary. Should output "C++" ... perhaps test nees to be updated -./a.out - -# Check that libunwind, libc++abi, libc++ and LLVM.so are GCC-free: -llvm-readelf -d /usr/lib/libunwind.so.1.0 | grep Shared | cut -b 37- -# Shared library: [libc.so] -llvm-readelf -d /usr/lib/libc++.so.1.0 | grep Shared | cut -b 37- -# Shared library: [libc.so] -llvm-readelf -d /usr/lib/libc++abi.so.1.0 | grep Shared | cut -b 37- -# Shared library: [libc.so] -llvm-readelf -d /usr/lib/libLLVM-17.0.5.so | grep Shared | cut -b 37- -# Shared library: [libz.so.1] -# Shared library: [libzstd.so.1] -# Shared library: [libterminfo.so] -# Shared library: [libc++.so.1] -# Shared library: [libc.so] - -# If all is well, clean up -rm -rf build dummy.* atomics-test.* cxx11-test.* -unset CT CTG CP CRT CLG CLCPP CLCPPA CUW CLLVM COFF CFLAGS CXXFLAGS - -# Set the default compiler for chroot to stage2 clang: -export CC=clang CXX=clang++ - -# Set LLD as default linker -ln -sv ld.lld /usr/bin/ld - -# Many packages use the name cc to call the C compiler. To -# satisfy those packages, create a symlink -ln -sv clang-17 /usr/bin/cc - -# Create a symlink required by the FHS for "historical" reasons -ln -sv ../bin/clang-17 /usr/lib/cpp diff --git a/4-Final_System/011-LLVM-1.base b/4-Final_System/011-LLVM-1.base new file mode 100644 index 0000000..b489b11 --- /dev/null +++ b/4-Final_System/011-LLVM-1.base @@ -0,0 +1,150 @@ +# Final Stage2 clang (with lld and llvm support libraries & tools) +# Build under chroot +# +# NOTE: Reuse llvm-project source tree from before + +# Restore default dynamic linker/loader path to /lib +patch -Np1 -i ../patches/llvm-cmlfs/modify-test-dynamic-loader.restore.patch +patch -Np1 -i ../patches/llvm-cmlfs/modify-toolchain-dynamic-loader.restore.patch + +# Fix Clang config header for stage 1 clang in llvmtools +cd / +patch -Np1 -i /sources/patches/llvm-cmlfs/modify-clang-config-header.patch +cd - + +# stage1 clang cannot find zstd headers +ln -sv /usr/include/zstd.h /llvmtools/include/ + +# Build will fail as some shared objects require -fPIC +export CFLAGS="-fPIC " +export CXXFLAGS=$CFLAGS + +# Set the compiler and linker flags... +export CT="-DCMAKE_C_COMPILER=clang " +export CT+="-DCMAKE_CXX_COMPILER=clang++ " +export CT+="-DCMAKE_AR=/llvmtools/bin/llvm-ar " +export CT+="-DCMAKE_NM=/llvmtools/bin/llvm-nm " +export CT+="-DCMAKE_RANLIB=/llvmtools/bin/llvm-ranlib " +export CT+="-DCLANG_DEFAULT_LINKER=/usr/bin/ld.lld " + +# Set the tuples & build target ... +export CTG="-DLLVM_DEFAULT_TARGET_TRIPLE=${TUPLE} " +export CTG+="-DLLVM_HOST_TRIPLE=${TUPLE} " +export CTG+="-DLLVM_TARGET_ARCH=${LARCH} " +export CTG+="-DLLVM_TARGETS_TO_BUILD=AMDGPU;BPF;${LARCH} " + +# Set the paths ... +export CP="-DCMAKE_INSTALL_PREFIX=/usr " +export CP+="-DCMAKE_INSTALL_LIBDIR=lib " + +# Set options for clang +# + Set the standard C++ library that clang will use to LLVM's libc++ +# + Set compiler-rt as default runtime +export CLG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " +export CLG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " +export CLG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " +export CLG+="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " + +# Set LLVM options +# + Enable Exception handling and Runtime Type Info +export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " +export CLLVM+="-DLLVM_ENABLE_ZLIB=ON " +export CLLVM+="-DZLIB_INCLUDE_DIR=/usr/include " +export CLLVM+="-DZLIB_LIBRARY_RELEASE=/usr/lib/libz.so " +export CLLVM+="-DLLVM_INSTALL_UTILS=ON " +export CLLVM+="-DLLVM_BUILD_LLVM_DYLIB=ON " +export CLLVM+="-DLLVM_LINK_LLVM_DYLIB=ON " +export CLLVM+="-DENABLE_LINKER_BUILD_ID=ON " +export CLLVM+="-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON " +export CLLVM+="-DLLVM_ENABLE_LIBCXX=ON " +export CLLVM+="-DLLVM_ENABLE_LLD=ON " +export CLLVM+="-DLLVM_ENABLE_ZSTD=ON " +export CLLVM+="-DLLVM_ENABLE_TERMINFO=ON " + +# Turn off LLVM options +# + Turn off features host may have +export COFF="-DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_LIBXML2=OFF " +export COFF+="-DLLVM_ENABLE_LIBPFM=OFF " + +# Remove more tests & docs that breaks build +export MOFF="-DCLANG_INCLUDE_TESTS=OFF " +export MOFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " +export MOFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " +export MOFF+="-DLLVM_INCLUDE_DOCS=OFF " +export MOFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " +export MOFF+="-DLLVM_INCLUDE_TESTS=OFF " + +# Building everything at once yields lots of build errors. +# So just build clang & LLD (and LLVM support libraries & tools) +cmake -B build-base2 -G Ninja -Wno-dev -S llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="lld;clang" \ + -DCLANG_VENDOR="CMLFS 4.0.1" -DLLD_VENDOR="CMLFS 4.0.1" \ + -DDEFAULT_SYSROOT="/" \ + $CT $CTG $CP $CLG $CLLVM $COFF $MOFF + +# Compile +ninja -C build-base2 + +# For trouble shooting, targets shown: +ninja -C build-base2 llvm-headers # 198 ............ PASS +ninja -C build-base2 llvm-tblgen #.. 68 ............ PASS +ninja -C build-base2 llvm-lib #... 1812 ............ PASS +ninja -C build-base2 lld #......... 126 ............ PASS +ninja -C build-base2 clang #...... 1181 ............ PASS +ninja -C build-base2 libclang #..... 31 ............ PASS +ninja -C build-base2 # ............ 570 ............ PASS + +# Install +cmake --install build-base2 --strip + +# Fix the dynamic linker for the executables: +for b in bugpoint c-index-test clang-17 count diagtool dsymutil FileCheck \ + llc lld lli lli-child-target not obj2yaml opt sancov sanstats \ + split-file UnicodeNameMappingGenerator verify-uselistorder yaml2obj \ + yaml-bench amdgpu-arch nvptx-arch +do + setDL /usr/bin/$b +done + +for b in check extdef-mapping format linker-wrapper \ + offload-bundler offload-packager refactor \ + rename repl scan-deps tblgen +do + setDL /usr/bin/clang-$b +done + +for b in ar as bcanalyzer cat cfi-verify config cov c-test cvtres cxxdump \ + cxxfilt cxxmap debuginfod debuginfod-find diff dis dwarfdump \ + dwarfutil dwp exegesis extract gsymutil ifs jitlink jitlink-executor \ + libtool-darwin link lipo lto lto2 mc mca ml modextract mt nm objcopy \ + objdump opt-report pdbutil PerfectShuffle profdata profgen rc readobj \ + reduce remark-size-diff rtdyld sim size split stress strings \ + symbolizer tapi-diff tblgen tli-checker undname xray remarkutil debuginfo-analyzer +do + setDL /usr/bin/llvm-$b +done + +# Install llvm-lit to build the llvm runtimes seperately: +cp -v build-base2/bin/llvm-lit /usr/bin/ + +# Set LLD as default linker +ln -sv ld.lld /usr/bin/ld + +# Many packages use the name cc to call the C compiler. To +# satisfy those packages, create a symlink +ln -sv clang-17 /usr/bin/cc + +# Create a symlink required by the FHS for "historical" reasons +ln -sv ../bin/clang-17 /usr/lib/cpp + +# Since compiler-rt and libc++ & unwind headers are not yet, create links so that the +# freshly made stage2 clang can be used right away +ln -sv /llvmtools/lib/clang/17/lib /usr/lib/clang/17/ +ln -sv /llvmtools/include/c++ /usr/include/ +ln -sv /llvmtools/include/__libunwind_config.h /usr/include/ +ln -sv /llvmtools/include/unwind_itanium.h /usr/include/ + +# Clean up variables +unset CT CTG CP CLG CLLVM COFF MOFF CFLAGS CXXFLAGS diff --git a/4-Final_System/011-LLVM-2.Rebuild-Clang b/4-Final_System/011-LLVM-2.Rebuild-Clang deleted file mode 100644 index 9e6e722..0000000 --- a/4-Final_System/011-LLVM-2.Rebuild-Clang +++ /dev/null @@ -1,199 +0,0 @@ -# Stage2 clang rebuild -# Build under chroot -# -# NOTE: Reuse llvm-project source tree from before as -# there is no clang standalong build that will build -# against system-installed LLVM - -export CFLAGS="-fPIC " -export CXXFLAGS=$CFLAGS - -# Set clang options: -export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " -export COPTS+="-DCLANG_DEFAULT_RTLIB=compiler-rt " -export COPTS+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " -export COPTS+="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " -export COPTS+="-DCLANG_DEFAULT_LINKER=/usr/bin/ld.lld " -export COPTS+="-DCLANG_INCLUDE_TESTS=OFF " - -# Turn off LLVM options: -export LOFF="-DLLVM_ENABLE_OCAMLDOC=OFF " -export LOFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " -export LOFF+="-DLLVM_INCLUDE_DOCS=OFF " -export LOFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " -export LOFF+="-DLLVM_INCLUDE_TESTS=OFF " -export LOFF+="-DLLVM_BUILD_RUNTIMES=OFF " -export LOFF+="-DLLVM_BUILD_RUNTIME=OFF " -export LOFF+="-DLLVM_BUILD_TOOLS=OFF " -export LOFF+="-DLLVM_BUILD_UTILS=OFF " - -# Enable the same LLVM options used with -# previous build -export LOPTS="-DLLVM_ENABLE_RTTI=ON " -export LOPTS+="-DLLVM_ENABLE_EH=ON " -export LOPTS+="-DLLVM_DEFAULT_TARGET_TRIPLE=${TUPLE} " -export LOPTS+="-DLLVM_TARGETS_TO_BUILD=Native;host;AMDGPU;BPF " - -# Configure source to enable only the clang project: -cmake -B build -G Ninja -Wno-dev -S llvm \ - -DLLVM_ENABLE_PROJECTS=clang \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCLANG_VENDOR="CMLFS 4.0.0" \ - -DDEFAULT_SYSROOT=/ \ - $COPTS $LOFF $LOPTS - -ninja -C build - -# If build fails to compile, use below to see what component failed. -# ninja -C build $TARGET -# Build target break down (still unsure of order): -# * Count is based on the x86_64-pc-linux-musl target - -# $TARGET ........... COUNT -# ------------------------- -# llvm-headers ....... 202 -# llvm-tblgen ......... 68 -# llvm-lib ........... 691 -# clang ............. 1950 -# libclang ............ 47 -# ........ 530 - -# Install to a directory to extract clang -export BUILD=/sources/BUILD -mkdir -pv $BUILD -DESTDIR=$BUILD cmake --install build --strip - -# Extract clang to a directory. -# * No need to install the rebuilt LLVM libraries -# as both clang builds are compiled from same -# patched LLVM monorepo -export VBUILD=/sources/VBUILD -mkdir $VBUILD -mkdir -pv $VBUILD/CLANG/usr/{bin,lib,include,share} -mkdir -pv $VBUILD/CLANG/usr/lib/cmake -mkdir -pv $VBUILD/CLANG/usr/lib/clang/17 - -mv -v $BUILD/usr/bin/*clang* $VBUILD/CLANG/usr/bin/ -mv -v $BUILD/usr/bin/c-index-test $VBUILD/CLANG/usr/bin/ -mv -v $BUILD/usr/bin/diagtool $VBUILD/CLANG/usr/bin/ -mv -v $BUILD/usr/bin/cc $VBUILD/CLANG/usr/bin/ - -mv -v $BUILD/usr/include/clang $VBUILD/CLANG/usr/include/ -mv -v $BUILD/usr/include/clang-c $VBUILD/CLANG/usr/include/ -mv -v $BUILD/usr/lib/clang/17/include $VBUILD/CLANG/usr/lib/clang/17/ -mv -v $BUILD/usr/lib/cmake/clang $VBUILD/CLANG/usr/lib/cmake/ -mv -v $BUILD/usr/lib/libclang*.a $VBUILD/CLANG/usr/lib/ -mv -v $BUILD/usr/lib/libclang*.so $VBUILD/CLANG/usr/lib/ -mv -v $BUILD/usr/lib/libclang.so.* $VBUILD/CLANG/usr/lib/ -mv -v $BUILD/usr/lib/libclang-cpp.so.* $VBUILD/CLANG/usr/lib/ -mv -v $BUILD/usr/lib/cpp $VBUILD/CLANG/usr/lib/ -mv -v $BUILD/usr/share/clang $VBUILD/CLANG/usr/share/ - -# Install -cd $VBUILD -cp -ar CLANG/* / - -# Test Rebuilt Clang -echo "int main(){}" > dummy.c -/usr/bin/clang dummy.c -v -Wl,--verbose &> dummy.log -llvm-readelf -l a.out | grep ': /lib' -# Shoud output: -# [Requesting program interpreter: /lib/ld-musl-x86_64.so.1 - -# Check if the correct start files are used -grep 'crt[1in]' dummy.log | grep ld.lld: -# Should output: -# ld.lld: /lib/Scrt1.o -# ld.lld: /lib/crti.o -# ld.lld: /lib/crtn.o -# * /lib is a link to /usr/lib, therefore this is acceptable - -# Verify that stage2 rebuilt clang is searching for the correct header files: -grep -B1 -A1 '^ /usr' dummy.log -# It should output: -# #include <...> search starts here: -# /usr/local/include -# /usr/include -# /usr/lib/clang/17/include -# End of search list. - -# Make sure no libraries are loaded from llvmtools -grep ld.lld: dummy.log -# It should output: -# ld.lld: /lib/Scrt1.o -# ld.lld: /lib/crti.o -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/clang_rt.crtbegin.o -# ld.lld: /tmp/dummy-b69998.o -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/libclang_rt.builtins.a -# ld.lld: /lib/libunwind.so -# ld.lld: /lib/libatomic.so -# ld.lld: /lib/libc.so -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/libclang_rt.builtins.a -# ld.lld: /lib/libunwind.so -# ld.lld: /usr/lib/clang/17/lib/x86_64-pc-linux-musl/clang_rt.crtend.o -# ld.lld: /lib/crtn.o - - -# Check if stage2 clang++ supports atomics. -cat > atomics-test.cpp << "EOF" -#include -std::atomic x; -std::atomic y; -std::atomic z; -int main() { - ++z; - ++y; - return ++x; -} -EOF - -/usr/bin/clang++ \ -atomics-test.cpp -v -Wl,--verbose &> atomics-test.log - -# Check for errors during compile or link: -grep error: atomics-test.log -# Should return nothing if there are no errors. - -# Make sure stage2 clang can find libc++ headers: -grep -B4 -A1 '^ /usr/lib' atomics-test.log -# It should output this order: -# #include <...> search starts here: -# /usr/bin/../include/c++/v1 -# /usr/local/include -# /usr/include -# /usr/lib/clang/17/include -# End of search list. - -# Test if stage1 clang supports C++11 -cat > cxx11-test.cpp << "EOF" -#include - -int main(){ - #if __cplusplus==201402L - std::cout << "C++14" << std::endl; - #elif __cplusplus==201103L - std::cout << "C++11" << std::endl; - #else - std::cout << "C++" << std::endl; - #endif - - return 0; -} -EOF - -/usr/bin/clang++ cxx11-test.cpp -v -Wl,--verbose &> cxx11-test.log - -# Check for errors during compile or link: -grep error: cxx11-test.log -# Should return nothing if there are no errors. - -# Execute the binary. Should output "C++"... test may need to be updated as desired result was "C++14" -./a.out - -# If all is good, clean up -rm -v dummy.* atomics-test.* cxx11-test.* -cd sources -rm -rf /sources/{BUILD,VBUILD} -unset COPTS LOFF LOPTS BUILD VBUILD diff --git a/4-Final_System/011-LLVM-2.compiler-rt b/4-Final_System/011-LLVM-2.compiler-rt new file mode 100644 index 0000000..0cea065 --- /dev/null +++ b/4-Final_System/011-LLVM-2.compiler-rt @@ -0,0 +1,79 @@ +# Final Stage2 compiler-rt +# Build under chroot +# +# NOTE: Reuse llvm-project source tree from before + +export CFLAGS="-fPIC " +export CXXFLAGS=$CFLAGS + +export CT="-DCMAKE_C_COMPILER=clang " +export CT+="-DCMAKE_CXX_COMPILER=clang++ " +export CT+="-DCMAKE_AR=/usr/bin/llvm-ar " +export CT+="-DCMAKE_NM=/usr/bin/llvm-nm " +export CT+="-DCMAKE_RANLIB=/usr/bin/llvm-ranlib " + +export CTG="-DLLVM_HOST_TRIPLE=${TARGET_TUPLE} " + +export CP="-DCMAKE_INSTALL_PREFIX=/usr " + +export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " + +export COFF="-DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_TERMINFO=OFF " + +export CLCPPA="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " +export CLCPPA+="-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON " +export CLCPPA+="-DLIBCXXABI_USE_COMPILER_RT=ON " # ? + +export CLCPP="-DLIBCXX_HAS_MUSL_LIBC=ON " +export CLCPP+="-DLIBCXX_ENABLE_LOCALIZATION=ON " +export CLCPP+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " +export CLCPP+="-DLIBCXX_CXX_ABI=libcxxabi " +export CLCPP+="-DLIBCXX_USE_COMPILER_RT=ON " # ? +export CLCPP+="-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON " +export CLCPP+="-DLIBCXX_ENABLE_ASSERTIONS=ON " + +export CRT="-DCOMPILER_RT_BUILD_SANITIZERS=OFF " +export CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " +export CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " +export CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " +export CRT+="-DCOMPILER_RT_BUILD_MEMPROF=OFF " + +export CRT+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " +export CRT+="-DCOMPILER_RT_USE_LLVM_UNWINDER=ON " +export CRT+="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF " + +# Build compiler-rt as it is needed to build libc++abi +cmake -B build-crt2 -G Ninja -Wno-dev -S runtimes -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt" \ + -DLLVM_INCLUDE_TESTS=OFF $CT $CP $CLLVM $COFF $CTG $CLCPPA $CLCPP \ + -DLLVM_ROOT=/usr $CRT + +# Compile +ninja -C build-crt2 compiler-rt # 141 ......... PASS + +# Remove link made earlier +rm -v /usr/lib/clang/17/lib + +# Install +ninja -C build-crt2 install-compiler-rt-headers-stripped +ninja -C build-crt2 install-compiler-rt-stripped + +# Move misplaced files +mkdir /usr/lib/clang/17/lib +mv /usr/lib/linux /usr/lib/clang/17/lib/ + +# Check that stage2 clang uses the correct runtime: +echo "int main(){}" > dummy.c +/usr/bin/clang dummy.c -v -Wl,--verbose &> dummy.log +cat dummy.log | grep 'ld: ' | grep '_rt' +# Should see: +#ld: /usr/lib/clang/17/lib/linux/clang_rt.crtbegin-i386.o +#ld: /usr/lib/clang/17/lib/linux/libclang_rt.builtins-i386.a +#ld: /usr/lib/clang/17/lib/linux/libclang_rt.builtins-i386.a +#ld: /usr/lib/clang/17/lib/linux/clang_rt.crtend-i386.o + +# clean up +rm -v a.out dummy.* +unset CT CP CLLVM COFF CTG CLCPPA CLCPP CRT diff --git a/4-Final_System/011-LLVM-3.libcxx b/4-Final_System/011-LLVM-3.libcxx new file mode 100644 index 0000000..058d907 --- /dev/null +++ b/4-Final_System/011-LLVM-3.libcxx @@ -0,0 +1,63 @@ +# Final Stage2 libc++abi, libc++, & libunwind +# Build under chroot +# +# NOTE: Reuse llvm-project source tree from before + +export CFLAGS="-fPIC " +export CXXFLAGS=$CFLAGS + +export CT="-DCMAKE_C_COMPILER=clang " +export CT+="-DCMAKE_CXX_COMPILER=clang++ " +export CT+="-DCMAKE_AR=/usr/bin/llvm-ar " +export CT+="-DCMAKE_NM=/usr/bin/llvm-nm " +export CT+="-DCMAKE_RANLIB=/usr/bin/llvm-ranlib " + +export CTG="-DLLVM_HOST_TRIPLE=${TARGET_TUPLE} " + +export CP="-DCMAKE_INSTALL_PREFIX=/usr " + +export CLLVM="-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON " + +export COFF="-DLLVM_ENABLE_LIBEDIT=OFF " +export COFF+="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_LIBEDIT=OFF " + +export CLCPPA="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " +export CLCPPA+="-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON " + +export CLCPPA+="-DLIBCXXABI_USE_COMPILER_RT=ON " + +export CLCPP="-DLIBCXX_HAS_MUSL_LIBC=ON " +export CLCPP+="-DLIBCXX_ENABLE_LOCALIZATION=ON " +export CLCPP+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " +export CLCPP+="-DLIBCXX_CXX_ABI=libcxxabi " +export CLCPP+="-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON " +export CLCPP+="-DLIBCXX_ENABLE_ASSERTIONS=ON " + +export CLCPP+="-DLIBCXX_USE_COMPILER_RT=ON " + +# Configure the source for building just the runtimes +cmake -B build-libcxx2 -G Ninja -Wno-dev -S runtimes -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ + -DLLVM_INCLUDE_TESTS=OFF $CT $CP $CLLVM $COFF $CTG $CLCPPA $CLCPP \ + -DLLVM_ROOT=/usr + +# Just compile libc++abi, libc++, and libunwind +ninja -C build-libcxx2 unwind # 19 ....... PASS +ninja -C build-libcxx2 cxxabi # 1051 ..... PASS +ninja -C build-libcxx2 cxx # 103 ......... PASS + +# Remove links made earlier +rm -v /usr/include/c++ +rm -v /usr/include/__libunwind_config.h +rm -v /usr/include/unwind_itanium.h + +# Install +ninja -C build-libcxx2 install-cxxabi-stripped +ninja -C build-libcxx2 install-cxxabi-headers +ninja -C build-libcxx2 install-cxx-stripped +ninja -C build-libcxx2 install-cxx-headers +ninja -C build-libcxx2 install-unwind-stripped +ninja -C build-libcxx2 install-unwind-headers + +# clean up +unset CT CP CLLVM COFF CTG CLCPPA CLCPP CFLAGS CXXFLAGS diff --git a/4-Final_System/011-LLVM-4.test b/4-Final_System/011-LLVM-4.test new file mode 100644 index 0000000..8392019 --- /dev/null +++ b/4-Final_System/011-LLVM-4.test @@ -0,0 +1,95 @@ +# Final Stage2 llvm Test +# Build under chroot +# +# Before building further, make sure the current stage2 LLVM +# is functional + +cd /sources + +echo "int main(){}" > dummy.c +clang dummy.c -v -Wl,--verbose &> dummy.log +llvm-readelf -l a.out | grep Requesting +# Should output: +# [Requesting program interpreter: /lib/ld-musl-i386.so.1] +# or +# [Requesting program interpreter: /lib/ld-musl-x86_64.so.1] +#* will differ slightly depending on the current arch + +# Check if compiler-rt was used: +cat dummy.log | grep 'ld: ' | grep '_rt' +# Should output: +#ld: /usr/lib/clang/17/lib/linux/clang_rt.crtbegin-i386.o +#ld: /usr/lib/clang/17/lib/linux/libclang_rt.builtins-i386.a +#ld: /usr/lib/clang/17/lib/linux/libclang_rt.builtins-i386.a +#ld: /usr/lib/clang/17/lib/linux/clang_rt.crtend-i386.o +#* will differ slightly depending on the current arch + +# Verify that stage2 clang is searching for the correct header files: +grep -B0 -A4 'search starts here' dummy.log +# Should output: +# include "..." search starts here: +# #include <...> search starts here: +# /usr/include +# /usr/local/include +# /usr/lib/clang/17/include +# End of search list. + +# Check if stage2 clang++ still has atomics: +cat > atomics-test.cpp << "EOF" +#include +std::atomic x; +std::atomic y; +std::atomic z; +int main() { + ++z; + ++y; + return ++x; +} +EOF + +clang++ atomics-test.cpp -v -Wl,--verbose &> atomics-test.log +# Check for errors during compile or link: +grep error: atomics-test.log +# Should return nothing if there are no errors. + +# Make sure stage 2 clang is using libatomic from usr/lib +grep 'ld:' atomics-test.log | grep "libatomic" +# Should output: +# ld: /usr/lib/libatomic.so + +# Make sure correct C++ headers path is searched +grep -B0 -A5 'search starts here' atomics-test.log +# Should output +# #include "..." search starts here: +# #include <...> search starts here: +# /usr/bin/../include/c++/v1 +# /usr/local/include +# /usr/include +# /usr/lib/clang/17/include +# End of search list. + +# Test if stage2 clang support C++11 +cat > cxx11-test.cpp << "EOF" +#include + +int main(){ + #if __cplusplus==201402L + std::cout << "C++14" << std::endl; + #elif __cplusplus==201103L + std::cout << "C++11" << std::endl; + #else + std::cout << "C++" << std::endl; + #endif + + return 0; +} +EOF + +clang++ cxx11-test.cpp -v -Wl,--verbose &> cxx11-test.log + +# Check for errors during compile or link: +grep error: cxx11-test.log +# Should return no errors. + +# If all is well, clean up +rm -v a.out atomics-test.* cxx11-test.* diff --git a/4-Final_System/013-utmps b/4-Final_System/013-utmps index da70bb8..c8b5427 100644 --- a/4-Final_System/013-utmps +++ b/4-Final_System/013-utmps @@ -17,6 +17,7 @@ CC=clang CXX=clang++ \ --enable-static \ --disable-allstatic \ --enable-static-libc \ + --enable-libc-includes \ --libdir=/usr/lib \ --with-dynlib=/usr/lib \ --libexecdir="/usr/lib/utmps" \ @@ -26,9 +27,6 @@ CC=clang CXX=clang++ \ make make install -# Some packages look for utmpx.h in /usr/include -ln -sv utmps/utmpx.h /usr/include/utmpx.h - # Install pkgconfig file install -v -D -m644 /tmp/utmps.pc /usr/lib/pkgconfig diff --git a/4-Final_System/014-TimeZone-Utilities b/4-Final_System/014-TimeZone-Utilities index 907390a..937ecbe 100644 --- a/4-Final_System/014-TimeZone-Utilities +++ b/4-Final_System/014-TimeZone-Utilities @@ -5,19 +5,15 @@ export timezones="africa antarctica asia australasia europe northamerica \ southamerica etcetera backward factory" mkdir tzdb && cd tzdb && -tar xf ../pkgs/tzdata2023c.tar.gz && -tar xf ../pkgs/tzcode2023c.tar.gz && +tar xf ../pkgs/tzdata2024a.tar.gz && +tar xf ../pkgs/tzcode2024a.tar.gz && tar xf ../pkgs/posixtz-0.5.tar.xz && # Apply patches from Alpine Linux patch -Np1 -i ../patches/posixtz-alpine/0001-posixtz-ensure-the-file-offset-we-pass-to-lseek-is-o.patch patch -Np1 -i ../patches/posixtz-alpine/0002-fix-implicit-declaration-warnings-by-including-strin.patch -# Patch makefile to use llvm-ar instead of binutils' ar -# and use clang instead of cc -patch -Np1 -i ../patches/tzcode-cmlfs/change-ar-to-llvm-ar.patch - -make CFLAGS="$CFLAGS -DHAVE_STDINT_H=1" TZDIR="/usr/share/zoneinfo" +make AR=llvm-ar CFLAGS="$CFLAGS -DHAVE_STDINT_H=1" TZDIR="/usr/share/zoneinfo" make -C posixtz-0.5 posixtz ./zic -y ./yearistype -d /usr/share/zoneinfo ${timezones} diff --git a/4-Final_System/018-M4 b/4-Final_System/018-M4 index abbb936..58c8059 100644 --- a/4-Final_System/018-M4 +++ b/4-Final_System/018-M4 @@ -8,7 +8,7 @@ patch -Np1 -i ../patches/m4-alpine/musl-realpath.patch patch -Np1 -i ../patches/m4-alpine/test-posix_spawn_file_actions_addclose.patch # Configure -./configure --prefix=/usr +AR=llvm-ar ./configure --prefix=/usr # Build and install make && make install diff --git a/4-Final_System/020-Shadow b/4-Final_System/020-Shadow index 2576d95..f94d21d 100644 --- a/4-Final_System/020-Shadow +++ b/4-Final_System/020-Shadow @@ -2,10 +2,12 @@ # This section is done in Chroot environment # Apply patches from Chimera linux +patch -Np1 -i ../patches/shadow-chimera/disable-ruserok.patch +patch -Np1 -i ../patches/shadow-chimera/fix-undefined-reference.patch +patch -Np1 -i ../patches/shadow-chimera/libcrypt.patch +patch -Np1 -i ../patches/shadow-chimera/man.patch patch -Np1 -i ../patches/shadow-chimera/usermod-move-home-errmsg.patch patch -Np1 -i ../patches/shadow-chimera/xstrdup.patch -patch -Np1 -i ../patches/shadow-chimera/man.patch -patch -Np1 -i ../patches/shadow-chimera/disable-ruserok.patch # Disable the installation of the groups program and its man pages, # as Coreutils provides a better version diff --git a/4-Final_System/021-pkgconf b/4-Final_System/021-pkgconf index de33cb5..802ba12 100644 --- a/4-Final_System/021-pkgconf +++ b/4-Final_System/021-pkgconf @@ -4,7 +4,7 @@ # Configure source NM=llvm-nm AR=llvm-ar \ ./configure --prefix=/usr \ - --docdir=/usr/share/doc/pkgconf-1.9.5 \ + --docdir=/usr/share/doc/pkgconf-2.2.0 \ --sysconfdir=/etc \ --localstatedir=/var \ --with-pkg-config-dir=/usr/lib/pkgconfig:/usr/share/pkgconfig:/opt/qt5/lib/pkgconfig diff --git a/4-Final_System/022-attr b/4-Final_System/022-attr index f94613e..ddd8462 100644 --- a/4-Final_System/022-attr +++ b/4-Final_System/022-attr @@ -1,6 +1,8 @@ # Final System: Attr # This section is done in Chroot environment +patch -Np1 -i ../patches/attr-chimeara/basename.patch + CC=clang CXX=clang++ \ AR=llvm-ar NM=llvm-nm \ ./configure --prefix=/usr \ @@ -8,7 +10,7 @@ AR=llvm-ar NM=llvm-nm \ --libdir=/usr/lib \ --disable-static \ --sysconfdir=/etc \ - --docdir=/usr/share/doc/attr-2.5.1 + --docdir=/usr/share/doc/attr-2.5.2 make && make install diff --git a/4-Final_System/023-acl b/4-Final_System/023-acl index 8c5174d..a417d18 100644 --- a/4-Final_System/023-acl +++ b/4-Final_System/023-acl @@ -8,6 +8,6 @@ AR=llvm-ar NM=llvm-nm \ --disable-static \ --libexecdir=/usr/lib \ --libdir=/usr/lib \ - --docdir=/usr/share/doc/acl-2.3.1 + --docdir=/usr/share/doc/acl-2.3.2 make && make install diff --git a/4-Final_System/038-expat b/4-Final_System/038-expat index 62cc08a..0336a41 100644 --- a/4-Final_System/038-expat +++ b/4-Final_System/038-expat @@ -5,7 +5,7 @@ CC=clang CXX=clang++ \ ./configure --prefix=/usr \ --disable-static \ - --docdir=/usr/share/doc/expat-2.5.0 + --docdir=/usr/share/doc/expat-2.6.2 # Compile & install make && make install diff --git a/4-Final_System/047-Kmod b/4-Final_System/047-Kmod index 4e22c40..d502e91 100644 --- a/4-Final_System/047-Kmod +++ b/4-Final_System/047-Kmod @@ -15,7 +15,7 @@ CC=clang CXX=clang++ \ --with-xz \ --with-zlib \ --with-zstd \ - --with-openssl + --with-openssl --disable-test-modules # Compile & install make && make install diff --git a/4-Final_System/050-Python3 b/4-Final_System/050-Python3 index 145473c..ca7b72a 100644 --- a/4-Final_System/050-Python3 +++ b/4-Final_System/050-Python3 @@ -1,14 +1,32 @@ # Final System: Python 3 # This section is done in Chroot environment -# Apply patch to build under musl, from Void Linux -patch -Np0 -i ../patches/python3-void/musl-find_library.patch +# Apply patch to build under musl, from Chimera Linux +patch -Np1 -i ../patches/python3-Chimera/musl-find_library.patch +patch -Np1 -i ../patches/python3-Chimera/expat-2.6.patch +patch -Np1 -i ../patches/python3-Chimera/strictoverfl0w.patch # Remove to ensure system expat is used. rm -r Modules/expat -# Configure source -CC=clang CXX=clang++ \ +# For i686, stage 2 clang fails to build python 3 properly +# Use clang from llvmtools. +case $MCA in + i386) # First remove current clang config + mv /llvmtools/bin/${TUPLE}.cfg{,.old} + # Create new clang config for llvmtools' clang as it will + # not find headers (such as for readline) in /usr/include: + echo "-I/usr/include" > /llvmtools/bin/${TUPLE}.cfg + echo "-L/usr/lib" >> /llvmtools/bin/${TUPLE}.cfg + # Set CC & CXX + export CC=/llvmtools/bin/clang + export CXX=/llvmtools/bin/clang++ + ;; +esac + + +# Configure source +CC=$CC CXX=$CXX \ ./configure --prefix=/usr \ --enable-shared \ --with-system-expat \ @@ -29,6 +47,21 @@ make && make install chmod -v 755 /usr/lib/libpython3.12.so chmod -v 755 /usr/lib/libpython3.so +# Since llvmtools' clang was used, fix the dynamic loader for the binaries: +setDL /usr/bin/python3.12 + +# Python2 will not be built nor will any python2 code +# in the BMLFS. Remove support to convert py2 to py3 +rm -v /usr/bin/2to3 + +# Tk is not installed, as it is required to run pyhton3's IDLE(GUI) +rm -v /usr/bin/idle* +rm -rf /usr/lib/python3.12/idlelib + +# Remove tests and demo +rm -rf /usr/lib/python3.12/{turtledemo,test} +rm -v /usr/lib/python3.12/turtle.py + # Pip3 expects to find /usr/bin/python. Python2 is no longer # used nor built. # Create the missing link diff --git a/4-Final_System/052.a-Setuptools b/4-Final_System/053-Setuptools similarity index 100% rename from 4-Final_System/052.a-Setuptools rename to 4-Final_System/053-Setuptools diff --git a/4-Final_System/053.a-Ninja b/4-Final_System/054.a-Ninja similarity index 100% rename from 4-Final_System/053.a-Ninja rename to 4-Final_System/054.a-Ninja diff --git a/4-Final_System/053.b-Samurai b/4-Final_System/054.b-Samurai similarity index 100% rename from 4-Final_System/053.b-Samurai rename to 4-Final_System/054.b-Samurai diff --git a/4-Final_System/054-Meson b/4-Final_System/055-Meson similarity index 100% rename from 4-Final_System/054-Meson rename to 4-Final_System/055-Meson diff --git a/4-Final_System/055-Less b/4-Final_System/056-Less similarity index 100% rename from 4-Final_System/055-Less rename to 4-Final_System/056-Less diff --git a/4-Final_System/056-Coreutils b/4-Final_System/057-Coreutils similarity index 100% rename from 4-Final_System/056-Coreutils rename to 4-Final_System/057-Coreutils diff --git a/4-Final_System/057-Check b/4-Final_System/058-Check similarity index 100% rename from 4-Final_System/057-Check rename to 4-Final_System/058-Check diff --git a/4-Final_System/058-Diffutils b/4-Final_System/059-Diffutils similarity index 100% rename from 4-Final_System/058-Diffutils rename to 4-Final_System/059-Diffutils diff --git a/4-Final_System/059-Gawk b/4-Final_System/060-Gawk similarity index 100% rename from 4-Final_System/059-Gawk rename to 4-Final_System/060-Gawk diff --git a/4-Final_System/060-Findutils b/4-Final_System/061-Findutils similarity index 100% rename from 4-Final_System/060-Findutils rename to 4-Final_System/061-Findutils diff --git a/4-Final_System/061-Groff b/4-Final_System/062-Groff similarity index 100% rename from 4-Final_System/061-Groff rename to 4-Final_System/062-Groff diff --git a/4-Final_System/062-Bison b/4-Final_System/063-Bison similarity index 100% rename from 4-Final_System/062-Bison rename to 4-Final_System/063-Bison diff --git a/4-Final_System/063-GRUB b/4-Final_System/064-GRUB similarity index 100% rename from 4-Final_System/063-GRUB rename to 4-Final_System/064-GRUB diff --git a/4-Final_System/064-Gzip b/4-Final_System/065-Gzip similarity index 100% rename from 4-Final_System/064-Gzip rename to 4-Final_System/065-Gzip diff --git a/4-Final_System/065-IPRoute2 b/4-Final_System/066-IPRoute2 similarity index 100% rename from 4-Final_System/065-IPRoute2 rename to 4-Final_System/066-IPRoute2 diff --git a/4-Final_System/066-kbd b/4-Final_System/067-kbd similarity index 100% rename from 4-Final_System/066-kbd rename to 4-Final_System/067-kbd diff --git a/4-Final_System/067-libpipline b/4-Final_System/068-libpipline similarity index 100% rename from 4-Final_System/067-libpipline rename to 4-Final_System/068-libpipline diff --git a/4-Final_System/068-Make b/4-Final_System/069-Make similarity index 100% rename from 4-Final_System/068-Make rename to 4-Final_System/069-Make diff --git a/4-Final_System/069-Patch b/4-Final_System/070-Patch similarity index 100% rename from 4-Final_System/069-Patch rename to 4-Final_System/070-Patch diff --git a/4-Final_System/070-Tar b/4-Final_System/071-Tar similarity index 100% rename from 4-Final_System/070-Tar rename to 4-Final_System/071-Tar diff --git a/4-Final_System/071-Texinfo b/4-Final_System/072-Texinfo similarity index 100% rename from 4-Final_System/071-Texinfo rename to 4-Final_System/072-Texinfo diff --git a/4-Final_System/072-Vim b/4-Final_System/073-Vim similarity index 93% rename from 4-Final_System/072-Vim rename to 4-Final_System/073-Vim index dd0fdbd..e1db8ed 100644 --- a/4-Final_System/072-Vim +++ b/4-Final_System/073-Vim @@ -7,7 +7,7 @@ echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h # Configure with clang CC=clang CXX=clang++ \ -./configure --prefix=/usr +./configure --prefix=/usr --disable-nls # Compile & install make && make install @@ -21,7 +21,7 @@ for L in /usr/share/man/{,*/}man1/vim.1; do ln -sv vim.1 $(dirname $L)/vi.1 done mkdir -pv /usr/share/doc -ln -sv ../vim/vim90/doc /usr/share/doc/vim-9.0.2103 +ln -sv ../vim/vim90/doc /usr/share/doc/vim-9.1.0330 # Per LFS... By default, vim runs in vi-incompatible mode. # Create a default vim configuration file by running the following: diff --git a/4-Final_System/072.a-MarkupSafe b/4-Final_System/074-MarkupSafe similarity index 100% rename from 4-Final_System/072.a-MarkupSafe rename to 4-Final_System/074-MarkupSafe diff --git a/4-Final_System/072.b-Jinja2 b/4-Final_System/075-Jinja2 similarity index 100% rename from 4-Final_System/072.b-Jinja2 rename to 4-Final_System/075-Jinja2 diff --git a/4-Final_System/072.c-netbsd-utils4musl b/4-Final_System/076-netbsd-utils4musl similarity index 100% rename from 4-Final_System/072.c-netbsd-utils4musl rename to 4-Final_System/076-netbsd-utils4musl diff --git a/4-Final_System/072.d-Util-Linux b/4-Final_System/077-Util-Linux similarity index 94% rename from 4-Final_System/072.d-Util-Linux rename to 4-Final_System/077-Util-Linux index d65247d..a6f0389 100644 --- a/4-Final_System/072.d-Util-Linux +++ b/4-Final_System/077-Util-Linux @@ -11,7 +11,7 @@ sed -i '/test_mkfds/s/^/#/' tests/helpers/Makemodule.am CC=clang CXX=clang++ \ LIBS="-lutmps -lskarnet" \ ./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ - --docdir=/usr/share/doc/util-linux-2.39.2 \ + --docdir=/usr/share/doc/util-linux-2.39.4 \ --disable-chfn-chsh \ --disable-login \ --disable-nologin \ diff --git a/4-Final_System/073-Udev b/4-Final_System/078-Udev similarity index 83% rename from 4-Final_System/073-Udev rename to 4-Final_System/078-Udev index 66b6aad..c5c441d 100644 --- a/4-Final_System/073-Udev +++ b/4-Final_System/078-Udev @@ -88,28 +88,27 @@ ninja udevadm udev-hwdb \ build.ninja | awk '{ print $2 }') \ $(realpath libudev.so --relative-to .) +# Remove one udev rule file requiring a full Systemd installation: +rm rules.d/90-vconsole.rules + +cd .. + # Install -install -vm755 -d {/usr/lib,/etc}/udev/{hwdb.d,rules.d,network} -install -vm755 -d /usr/{lib,share}/pkgconfig -install -vm755 udevadm /usr/bin/ -install -vm755 udev-hwdb /usr/bin/ -ln -svfn ../bin/udevadm /usr/sbin/udevd -cp -av libudev.so{,*[0-9]} /usr/lib/ -install -vm644 ../src/libudev/libudev.h /usr/include/ -install -vm644 src/libudev/*.pc /usr/lib/pkgconfig/ -install -vm644 src/udev/*.pc /usr/share/pkgconfig/ -install -vm644 ../src/udev/udev.conf /etc/udev/ - -install -vm644 rules.d/* ../rules.d/README /usr/lib/udev/rules.d/ -install -vm644 $(find ../rules.d/*.rules \ - -not -name '*power-switch*') /usr/lib/udev/rules.d/ -install -vm644 hwdb.d/* ../hwdb.d/{*.hwdb,README} /usr/lib/udev/hwdb.d/ -install -vm755 $(find src/udev \ - -type f -not -name '*.*') /usr/lib/udev -install -vm644 ../network/99-default.link /usr/lib/udev/network - -# Remove an unnecessary udev rule: -rm -v /usr/lib/udev/rules.d/90-vconsole.rules +install -vm755 -d {/usr/lib,/etc}/udev/{hwdb,rules}.d +install -vm755 OUT/udevadm /usr/sbin/ +install -vm755 OUT/udev-hwdb /usr/sbin/ +ln -sv udevadm /usr/sbin/udevd +cp -av OUT/libudev.so{,*[0-9]} /usr/lib/ +install -vm644 src/libudev/libudev.h /usr/include/ +install -vm644 OUT/src/libudev/*.pc /usr/lib/pkgconfig/ +install -vm644 OUT/src/udev/*.pc /usr/share/pkgconfig/ +install -vm644 src/udev/udev.conf /etc/udev/ +install -vm644 OUT/hwdb.d/* hwdb.d/{*.hwdb,README} /etc/udev/hwdb.d/ +install -vm644 OUT/rules.d/* rules.d/README /usr/lib/udev/rules.d/ +install -vm644 $(find rules.d/*.rules \ + -not -name '*power-switch*') /usr/lib/udev/rules.d/ +install -vm755 $(find OUT/src/udev -type f | grep -F -v ".") /usr/lib/udev +install -vm644 network/99-default.link /usr/lib/udev/network # Information about hardware devices is maintained in the /etc/udev/hwdb.d and # /usr/lib/udev/hwdb.d directories. Udev needs that information to be compiled diff --git a/4-Final_System/074-Man-DB b/4-Final_System/079-Man-DB similarity index 100% rename from 4-Final_System/074-Man-DB rename to 4-Final_System/079-Man-DB diff --git a/4-Final_System/075-Procps-ng b/4-Final_System/080-Procps-ng similarity index 100% rename from 4-Final_System/075-Procps-ng rename to 4-Final_System/080-Procps-ng diff --git a/4-Final_System/077-E2fsprogs b/4-Final_System/081-E2fsprogs similarity index 100% rename from 4-Final_System/077-E2fsprogs rename to 4-Final_System/081-E2fsprogs diff --git a/4-Final_System/078-NSSS b/4-Final_System/082-NSSS similarity index 100% rename from 4-Final_System/078-NSSS rename to 4-Final_System/082-NSSS diff --git a/4-Final_System/079-Execline b/4-Final_System/083-Execline similarity index 100% rename from 4-Final_System/079-Execline rename to 4-Final_System/083-Execline diff --git a/4-Final_System/080-S6 b/4-Final_System/084-S6 similarity index 100% rename from 4-Final_System/080-S6 rename to 4-Final_System/084-S6 diff --git a/4-Final_System/081-S6-rc b/4-Final_System/085-S6-rc similarity index 100% rename from 4-Final_System/081-S6-rc rename to 4-Final_System/085-S6-rc diff --git a/4-Final_System/082-S6-Linux-Utils b/4-Final_System/086-S6-Linux-Utils similarity index 100% rename from 4-Final_System/082-S6-Linux-Utils rename to 4-Final_System/086-S6-Linux-Utils diff --git a/4-Final_System/086.e-GCC b/4-Final_System/086.e-GCC deleted file mode 100644 index dd67bd0..0000000 --- a/4-Final_System/086.e-GCC +++ /dev/null @@ -1,117 +0,0 @@ -# Final System: GCC (optional) -# This section is done in Chroot environment - -# NOTE: Installing GCC is optional as most packages can be built with clang. -# NOTE: GCC requires as (assembler) from binutils as LLVM's llvm-as isn't a -# 100% drop-in replacement for binutils' (unsupported arguments) - -# Set CPU flags related to target system -case $(uname -m) in - x86_64) export EXTRA_CONFIG=" --with-arch=x86-64" - ;; - i686) export EXTRA_CONFIG=" --with-arch=pentium3 --with-tune=pentium-m" - ;; - armv7l) export EXTRA_CONFIG=" --with-arch=armv7-a --with-tune=generic-armv7-a " - export EXTRA_CONFIG+="--with-fpu=vfpv3-d16 --with-float=hard " - export EXTRA_CONFIG+="--with-abi=aapcs-linux --with-mode=thumb" - ;; - armv6l) export EXTRA_CONFIG=" --with-arch=armv6zk --with-tune=arm1176jzf-s " - export EXTRA_CONFIG+="--with-fpu=vfp --with-float=hard --with-abi=aapcs-linux" - ;; - aarch64) export EXTRA_CONFIG=" --with-arch=armv8-a --with-abi=lp64 " - export EXTRA_CONFIG+="--enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419" - sed -i '/m64=/s/lib64/lib/' gcc/config/aarch64/t-aarch64-linux - ;; -esac && - -# For ARM, disable libitm because of texrels -case $(uname -m) in - arm*) export LIBITM=false ;; -esac && - -# Apply patches from glaucus -case $(uname -m) in - x86_64) patch -Np0 -i ../patches/gcc-glaucus/0001-pure64-for-x86-64.patch - ;; - aarch64) patch -Np0 -i ../patches/gcc-glaucus/0001-pure64-for-aarch64.patch - ;; -esac - -# Apply fixes from FreeBSD -patch -Np1 -i ../patches/gcc-freebsd/fix-system.h-and_explicit_includes.patch -patch -Np1 -i ../patches/gcc-freebsd/fix-ctype-def-order_v2.patch - -# Set paths for GNU libraries and headers for GCC: -export PKG_CONFIG_PATH=/opt/gnu/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig -export LIBRARY_PATH=/usr/lib:/opt/gnu/lib -export C_INCLUDE_PATH=/opt/gnu/include -export CPLUS_INCLUDE_PATH=/opt/gnu/include -export PATH=/opt/gnu/bin:/bin:/usr/bin:/sbin:/usr/sbin - -# Build in a dedicated directory -mkdir build && cd build - -# Enable useful features -export CARGS="--enable-__cxa_atexit --with-linker-hash-style=gnu " -export CARGS+="--with-ppl=yes --with-cloog=yes --enable-cloog-backend " -export CARGS+="--enable-threads=posix --enable-clocale=generic --enable-tls " -export CARGS+="--enable-libstdcxx-time --enable-fully-dynamic-string " -export CARGS+="--enable-linker-build-id --enable-checking=release " - -# Turn off features not needed -export COFF="--disable-libstdcxx-pch --disable-nls --disable-multilib " -# Need bootstrap to due to unsupported GCC flags & 'poisoned headers' -#export COFF+="--disable-bootstrap --disable-symvers --disable-libsanitizer " -export COFF+="--disable-symvers --disable-libsanitizer " -export COFF+="--disable-libssp --disable-libmpx --disable-libmudflap " -export COFF+="--disable-fixed-point --disable-sjlj-exceptions --disable-werror " - -# Configure source -CC=clang CXX=clang++ \ -LDFLAGS="-Wl,--rpath=/opt/gnu/lib" \ -CFLAGS="-Wl,--rpath=/opt/gnu/lib" \ -CXXFLAGS="-Wl,--rpath=/opt/gnu/lib" \ -SED=sed libat_cv_have_ifunc=no \ -../configure --prefix=/opt/gnu \ - --build=x86_64-pc-linux-musl \ - --enable-languages=c,c++,lto \ - --enable-lto \ - --with-pkgversion='CMLFS 4.0.0' \ - --enable-default-pie \ - --enable-default-ssp \ - --enable-plugins \ - --with-system-zlib $CARGS $COFF $EXTRA_CONFIG - -# Compile -LD_LIBRARY_PATH=/opt/gnu/lib make - -# Install! -make install - -# Bootstrapping does not use the LDFLAGS (invoked with configure script) to set run-path -# Fix with patchelf -for b in cc1 cc1plus lto1 -do - patchelf --set-rpath /opt/gnu/lib /opt/gnu/libexec/gcc/x86_64-pc-linux-musl/13.2.0/$b -done -patchelf --set-rpath /opt/gnu/lib /opt/gnu/bin/lto-dump - -# Create a symlink required by the FHS for 'historical' reasons -ln -sv ../bin/cpp /opt/gnu/lib/cpp - -# Many packages use the name cc to call the C compiler. Satisfy -# those pacakges with a symlink: -ln -sv gcc /opt/gnu/bin/cc - -# Create a compatibility symlink to enable building programs with -# LTO (Link Time Optimization) -install -v -dm755 /opt/gnu/lib/bfd-plugins -ln -sv ../../libexec/gcc/${TUPLE}/13.2.0/liblto_plugin.so \ - /opt/gnu/lib/bfd-plugins/ -mkdir -pv /opt/gnu/share/gdb/auto-load/usr/lib -mv -v /opt/gnu/lib/*gdb.py /opt/gnu/share/gdb/auto-load/usr/lib - -# Clean up variables used in this build -unset PKG_CONFIG_PATH LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH -unset CARGS COFF EXTRA_CONFIG -export PATH=/bin:/usr/bin:/sbin:/usr/sbin diff --git a/4-Final_System/083-S6-Portable-Utils b/4-Final_System/087-S6-Portable-Utils similarity index 95% rename from 4-Final_System/083-S6-Portable-Utils rename to 4-Final_System/087-S6-Portable-Utils index 3ec791d..fcb2d0c 100644 --- a/4-Final_System/083-S6-Portable-Utils +++ b/4-Final_System/087-S6-Portable-Utils @@ -2,7 +2,7 @@ # This section is done in Chroot environment # Configure with clang -CC=clang CXx=clang++ \ +CC=clang CXX=clang++ \ ./configure --enable-shared \ --enable-static \ --enable-allstatic \ diff --git a/4-Final_System/084-S6-Linux-Init b/4-Final_System/088-S6-Linux-Init similarity index 100% rename from 4-Final_System/084-S6-Linux-Init rename to 4-Final_System/088-S6-Linux-Init diff --git a/4-Final_System/086.a-GMP b/4-Final_System/089.a-GMP similarity index 100% rename from 4-Final_System/086.a-GMP rename to 4-Final_System/089.a-GMP diff --git a/4-Final_System/086.b-MPFR b/4-Final_System/089.b-MPFR similarity index 100% rename from 4-Final_System/086.b-MPFR rename to 4-Final_System/089.b-MPFR diff --git a/4-Final_System/086.c-MPC b/4-Final_System/089.c-MPC similarity index 100% rename from 4-Final_System/086.c-MPC rename to 4-Final_System/089.c-MPC diff --git a/4-Final_System/086.d-Binutils b/4-Final_System/089.d-Binutils similarity index 100% rename from 4-Final_System/086.d-Binutils rename to 4-Final_System/089.d-Binutils diff --git a/4-Final_System/089.e-GCC b/4-Final_System/089.e-GCC new file mode 100644 index 0000000..c31ec1e --- /dev/null +++ b/4-Final_System/089.e-GCC @@ -0,0 +1,165 @@ +# Final System: GCC (optional) +# This section is done in Chroot environment + +# NOTE: Installing GCC is optional as most packages can be built with clang. +# NOTE: GCC requires as (assembler) from binutils as LLVM's llvm-as isn't a +# 100% drop-in replacement for binutils' (unsupported arguments) +# NOTE: GCC source is a git snapshot from from gcc.gnu.org/pub/gcc/snapshots. +# However, since they are periodically deleted from the GCC mirrors, +# the utilized snapshots are mirrored on dev.alpinelinux.org. + +# Set CPU flags related to target system +case $(uname -m) in + x86_64) export EXTRA_CONFIG=" --with-arch=x86-64" + ;; + i686) export EXTRA_CONFIG=" --with-arch=pentium3 --with-tune=pentium-m" + ;; + armv7l) export EXTRA_CONFIG=" --with-arch=armv7-a --with-tune=generic-armv7-a " + export EXTRA_CONFIG+="--with-fpu=vfpv3-d16 --with-float=hard " + export EXTRA_CONFIG+="--with-abi=aapcs-linux --with-mode=thumb" + ;; + armv6l) export EXTRA_CONFIG=" --with-arch=armv6zk --with-tune=arm1176jzf-s " + export EXTRA_CONFIG+="--with-fpu=vfp --with-float=hard --with-abi=aapcs-linux" + ;; + aarch64) export EXTRA_CONFIG=" --with-arch=armv8-a --with-abi=lp64 " + export EXTRA_CONFIG+="--enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419" + sed -i '/m64=/s/lib64/lib/' gcc/config/aarch64/t-aarch64-linux + ;; +esac + +# For ARM, disable libitm because of texrels +case $(uname -m) in + arm*) export LIBITM=false ;; +esac + +# Apply patches from Alpine Linux, so gcc can be built against musl libc +patch -Np1 -i ../patches/gcc-alpine/0001-posix_memalign.patch +patch -Np1 -i ../patches/gcc-alpine/0002-gcc-poison-system-directories.patch +patch -Np1 -i ../patches/gcc-alpine/0003-specs-turn-on-Wl-z-now-by-default.patch +patch -Np1 -i ../patches/gcc-alpine/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch +patch -Np1 -i ../patches/gcc-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch +patch -Np1 -i ../patches/gcc-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch +patch -Np1 -i ../patches/gcc-alpine/0007-Enable-Wtrampolines-by-default.patch +patch -Np1 -i ../patches/gcc-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch +patch -Np1 -i ../patches/gcc-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch +patch -Np1 -i ../patches/gcc-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch +patch -Np1 -i ../patches/gcc-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch +patch -Np1 -i ../patches/gcc-alpine/0012-libgcc_s.patch +patch -Np1 -i ../patches/gcc-alpine/0013-nopie.patch +patch -Np1 -i ../patches/gcc-alpine/0014-ada-fix-shared-linking.patch +patch -Np1 -i ../patches/gcc-alpine/0015-build-fix-CXXFLAGS_FOR_BUILD-passing.patch +patch -Np1 -i ../patches/gcc-alpine/0016-add-fortify-headers-paths.patch +patch -Np1 -i ../patches/gcc-alpine/0017-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch +patch -Np1 -i ../patches/gcc-alpine/0018-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch +patch -Np1 -i ../patches/gcc-alpine/0019-aarch64-disable-multilib-support.patch +patch -Np1 -i ../patches/gcc-alpine/0020-s390x-disable-multilib-support.patch +patch -Np1 -i ../patches/gcc-alpine/0021-ppc64-le-disable-multilib-support.patch +patch -Np1 -i ../patches/gcc-alpine/0022-x86_64-disable-multilib-support.patch +patch -Np1 -i ../patches/gcc-alpine/0023-riscv-disable-multilib-support.patch +patch -Np1 -i ../patches/gcc-alpine/0024-always-build-libgcc_eh.a.patch +patch -Np1 -i ../patches/gcc-alpine/0025-ada-libgnarl-compatibility-for-musl.patch +patch -Np1 -i ../patches/gcc-alpine/0026-ada-musl-support-fixes.patch +patch -Np1 -i ../patches/gcc-alpine/0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch +patch -Np1 -i ../patches/gcc-alpine/0028-configure-fix-detection-of-atomic-builtins-in-libato.patch +patch -Np1 -i ../patches/gcc-alpine/0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch +patch -Np1 -i ../patches/gcc-alpine/0030-gdc-unconditionally-link-libgphobos-against-libucont.patch +patch -Np1 -i ../patches/gcc-alpine/0031-druntime-link-against-libucontext-on-all-platforms.patch +patch -Np1 -i ../patches/gcc-alpine/0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch +patch -Np1 -i ../patches/gcc-alpine/0033-libphobos-do-not-use-LFS64-symbols.patch +patch -Np1 -i ../patches/gcc-alpine/0034-libgo-fix-lfs64-use.patch +patch -Np1 -i ../patches/gcc-alpine/0036-PR110792-Early-clobber-issues-with-rot32di2-on-i386.patch +patch -Np1 -i ../patches/gcc-alpine/0037-loongarch-disable-multilib-support.patch + +# Apply patches from Chimera Linux since gcc will be built with libc++ not stdlbc++ +patch -Np1 -i ../patches/gcc-chimera/clang-tree-vect.patch +patch -Np1 -i ../patches/gcc-chimera/clang17.patch + +# Apply fixes from FreeBSD to fix issue with headers +patch -Np1 -i ../patches/gcc-freebsd/fix-system.h-and_explicit_includes.patch + +# Set paths for GNU libraries and headers for GCC: +export PKG_CONFIG_PATH=/opt/gnu/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig +export LIBRARY_PATH=/usr/lib:/opt/gnu/lib +export LD_LIBRARY_PATH=/opt/gnu/lib:/usr/lib +export C_INCLUDE_PATH=/opt/gnu/include +export CPLUS_INCLUDE_PATH=/opt/gnu/include +export PATH=/opt/gnu/bin:/bin:/usr/bin:/sbin:/usr/sbin + +# Build in a dedicated directory +mkdir build && cd build + +# Enable useful features +export CARGS="--enable-__cxa_atexit --with-linker-hash-style=gnu " +export CARGS+="--with-ppl=yes --with-cloog=yes --enable-cloog-backend " +export CARGS+="--enable-threads=posix --enable-clocale=generic --enable-tls " +export CARGS+="--enable-libstdcxx-time --enable-fully-dynamic-string " +export CARGS+="--enable-linker-build-id --enable-checking=release " + +# Turn off features not needed +export COFF="--disable-libstdcxx-pch --disable-nls --disable-multilib " +export COFF+="--disable-symvers --disable-libsanitizer " +export COFF+="--disable-libssp --disable-libmpx --disable-libmudflap " +export COFF+="--disable-fixed-point --disable-sjlj-exceptions --disable-werror " + +# Configure source +CC=clang CXX=clang++ \ +LDFLAGS="-Wl,--rpath=/opt/gnu/lib" \ +CFLAGS=$LDFLAGS CXXFLAGS=$LDFLAGS \ +SED=sed libat_cv_have_ifunc=no \ +../configure --prefix=/opt/gnu \ + --build=$TUPLE \ + --enable-languages=c,c++,lto \ + --enable-lto \ + --with-pkgversion='CMLFS 4.0.1' \ + --enable-default-pie \ + --enable-default-ssp \ + --enable-plugins \ + --with-system-zlib $CARGS $COFF $EXTRA_CONFIG + +# Built xgcc fails to find libraries in /usr/lib +# Create a temporary links +for L in pthread.a c.so ssp_nonshared.a m.a +do + ln -sv /usr/lib/lib$L /opt/gnu/lib/ +done +ln -sv /usr/lib/libgmp.so.10.5.0 /opt/gnu/lib/libgmp.so +ln -sv /usr/lib/libz.so.1.3.0.zlib-ng /opt/gnu/lib/libz.so + +# Compile +LD_LIBRARY_PATH=/opt/gnu/lib make + +# Install! +make install + +# Bootstrapping does not use the LDFLAGS (invoked with configure +# script) to set run-path. Fix with patchelf: +for b in cc1 cc1plus lto1 +do + /llvmtools/bin/patchelf --set-rpath /opt/gnu/lib /opt/gnu/libexec/gcc/${TUPLE}/13.2.1/$b +done +/llvmtools/bin/patchelf --set-rpath /opt/gnu/lib /opt/gnu/bin/lto-dump + +# Create a symlink required by the FHS for 'historical' reasons +ln -sv ../bin/cpp /opt/gnu/lib/cpp + +# Many packages use the name cc to call the C compiler. Satisfy +# those pacakges with a symlink: +ln -sv gcc /opt/gnu/bin/cc + +# Create a compatibility symlink to enable building programs with +# LTO (Link Time Optimization) +install -v -dm755 /opt/gnu/lib/bfd-plugins +ln -sv ../../libexec/gcc/${TUPLE}/13.2.1/liblto_plugin.so \ + /opt/gnu/lib/bfd-plugins/ + +# Remove links for xgcc +for L in pthread.a c.so ssp_nonshared.a \ + m.a gmp.so z.so +do + rm -v /opt/gnu/lib/lib$L +done + +# Clean up variables used in this build +unset PKG_CONFIG_PATH LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH +unset CARGS COFF EXTRA_CONFIG +export PATH=/bin:/usr/bin:/sbin:/usr/sbin diff --git a/4-Final_System/086.f-Dash b/4-Final_System/089.f-Dash similarity index 100% rename from 4-Final_System/086.f-Dash rename to 4-Final_System/089.f-Dash diff --git a/4-Final_System/094-Stripping b/4-Final_System/090-Stripping similarity index 100% rename from 4-Final_System/094-Stripping rename to 4-Final_System/090-Stripping diff --git a/4-Final_System/095-clean-up b/4-Final_System/091-clean-up similarity index 100% rename from 4-Final_System/095-clean-up rename to 4-Final_System/091-clean-up diff --git a/4-Final_System/096-Bootscripts b/4-Final_System/092-Bootscripts similarity index 100% rename from 4-Final_System/096-Bootscripts rename to 4-Final_System/092-Bootscripts diff --git a/4-Final_System/097-network-config b/4-Final_System/093-network-config similarity index 100% rename from 4-Final_System/097-network-config rename to 4-Final_System/093-network-config diff --git a/4-Final_System/098-bash-startup-scripts b/4-Final_System/094-bash-startup-scripts similarity index 100% rename from 4-Final_System/098-bash-startup-scripts rename to 4-Final_System/094-bash-startup-scripts diff --git a/4-Final_System/099-fstab b/4-Final_System/095-fstab similarity index 100% rename from 4-Final_System/099-fstab rename to 4-Final_System/095-fstab diff --git a/4-Final_System/100-kernel b/4-Final_System/096-kernel similarity index 100% rename from 4-Final_System/100-kernel rename to 4-Final_System/096-kernel diff --git a/4-Final_System/101-initramfs b/4-Final_System/097-initramfs similarity index 100% rename from 4-Final_System/101-initramfs rename to 4-Final_System/097-initramfs diff --git a/4-Final_System/102-boot-loader b/4-Final_System/098-boot-loader similarity index 100% rename from 4-Final_System/102-boot-loader rename to 4-Final_System/098-boot-loader diff --git a/4-Final_System/103-The-End b/4-Final_System/099-The-End similarity index 91% rename from 4-Final_System/103-The-End rename to 4-Final_System/099-The-End index f86ac9d..febbb0b 100644 --- a/4-Final_System/103-The-End +++ b/4-Final_System/099-The-End @@ -4,13 +4,13 @@ # file, it is very easy for you (and for us if you need to ask for help at # some point) to find out which LFS version is installed on the system. # Create this file by running: -echo 4.0.0 > /etc/cmlfs-release +echo 4.0.1 > /etc/cmlfs-release # It is also a good idea to create a file to show the status of your new # system with respect to the Linux Standards Base (LSB). To create this file, run: cat > /etc/lsb-release << "EOF" DISTRIB_ID="Clang Musl Linux From Scratch" -DISTRIB_RELEASE="4.0.0" +DISTRIB_RELEASE="4.0.1" DISTRIB_CODENAME="" DISTRIB_DESCRIPTION="Clang Musl Linux From Scratch" EOF @@ -18,10 +18,10 @@ EOF # If desired, an os-release file cat > /usr/lib/os-release << "EOF" NAME="CMLFS" -VERSION="4.0.0" +VERSION="4.0.1" ID=cmlfs ID_LIKE="mlfs lfs" -PRETTY_NAME="Clang-built Musl Linux From Scratch 4.0.0" +PRETTY_NAME="Clang-built Musl Linux From Scratch 4.0.1" VERSION_ID="4.0.0" HOME_URL="https://github.com/dslm4515/CMLFS" SUPPORT_URL="https://github.com/dslm4515/CMLFS/issues" diff --git a/README.md b/README.md index 64aa2a2..4e24480 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ CMLFS can either mean "Clang-built Musl Linux from Scratch" or "Clang MLFS". It Use at you own risk. This builds a Unix-like system that may not be stable enough as a 'daily driver' for most users. Security-hardening of the built system is beyound the scope of this project. This repo started as means to backup and archive my work. +On March 28, 2024, malicious code was discovered in the upstream tarballs of xz. All branches of CMLFS did not update to xz-5.6.x. For now, all branches will stay on 5.4.6 until there is a need to update to a newer version. More info on the malicious code found in xz can be read at [Redhat's CVE-2024-3094](https://access.redhat.com/security/cve/CVE-2024-3094). + ## Getting Started The master branch may be unstable when I am working on upgrading CMLFS. @@ -41,8 +43,8 @@ When I have time later, I will write a more thorough introduction for users new ## Supported Architectures
    -
  • AMD64/x86_64: Toolchains and final system build sucessfully (musl & glibc hosts) .
  • -
  • i686: Pending
  • +
  • AMD64/x86_64: PASS --Toolchains and final system build sucessfully (musl & glibc hosts) .
  • +
  • i686: PASS -- Toolchains and final system build sucessfully (musl host, glibc host not tested yet).
  • AARCH64/ARM64: Pending
  • ARMV7L: Pending
@@ -110,23 +112,40 @@ Build 'cross-tools' with [Mussel](https://github.com/firasuke/mussel) to cross-c
  1. Bootstrap build of cgnutools with mussel
  2. -
  3. Use mussel-built toolchain (cgnutools) to build stage0 LLVM+clang
  4. -
  5. Use cgnutools to build stage1 LLVM+clang with sysroot at llvmtools with stage0 LLVM+clang
  6. -
  7. Build enough of llvmtools to enter a chroot with stage1 LLVM+clang
  8. -
  9. Build the rest of llvmtools under chroot
  10. +
  11. Use mussel-built toolchain (cgnutools) to build stage0 LLVM+clang+LLD & install in cgnutools
  12. +
  13. Use stage0 LLVM+clang+LLD to build stage 1 runtimes to llvmtools in this order: +
      +
    1. libc++ headers
    2. +
    3. compiler-rt
    4. +
    5. libc++abi, libc++, libunwind
    6. +
    +
  14. +
  15. Build stage 1 LLVM+clang+compiler-rt+lld and install in llvmtools
  16. +
  17. Build enough of llvmtools with stage 1 LLVM+clang+compiler-rt+lld to enter chroot
  18. +
  19. Enter chroot and use stage 1 LLVM to build dependencies for building LLVM
  20. +
  21. Use stage 1 LLVM to build stage 2 LLVM+clang+lld. Do not build runtimes (libc++{,abi}, libunwind, compiler-rt) yet.
  22. +
  23. Use stage 2 LLVM to build & install the stage2 runtimes in this order +
      +
    1. libc++-headers (required to build compiler-rt)
    2. +
    3. compiler-rt
    4. +
    5. libc++abi, libc++, libunwind +
    +
  24. +
  25. Use stage 2 LLVM to rebuild stage 2 LLVM+clang+lld against installed stage 2 runtimes & set sysroot to /
  26. Build final system with llvmtools
## Issues
    -
  • Test for C++11/14 fails when testing stage0 & stage1 LLVM's. Not sure what issue this will cause or if test needs to be revised..
  • -
  • Coreutils will not build for llvmtools under 32-bit x86 (i386/i586/i686)
  • -
  • Ninja for llvmtools fails to compile with python3. For now use cmake instead of python3
  • +
  • Test for C++11/14 fails without error when testing stage0 & stage1 LLVM's. Likely test needs updating
  • +
  • Cannot build LLVM all at once. Have to build just LLVM-base, clang, and lld first... then use it to build the runtimes and then rebuild LLVM-base, clang, and lld to compile against just built runtimes.
  • +
  • mussel cannot be reliably built by a system's clang. For now, use GCC. Not sure if just an isolated issue with my system or not. Will need to verify on a MLFS system with LLVM as secondary system compiler.
## Change log
    +
  • 4.0.1: Upgraded to LLVM 17.0.6. Updated build method for cross-compiling. Stage 2 LLVM no longer needs a rebuild.
  • 4.0.0: Upgraded to LLVM 17.0.5
  • 3.0.0: Upgraded to LLVM-15.0.6. cgnutools is now bootstrapped with mussel. Replaced binutils with elftoolchain. Most of llvmtools will be build under chroot to avoid contamination from host.
  • 2.0.0: Upgraded to LLVM-12.0.0. Upgraded GCC to 10.3.1-x Replace ninja with samurai. Replace zlib with zlib-ng. Patched elfutils to build libelf under clang. No longer using /llvmtools/gnu and /opt/gnu.
  • diff --git a/patches/attr-chimeara/basename.patch b/patches/attr-chimeara/basename.patch new file mode 100644 index 0000000..f49ccdd --- /dev/null +++ b/patches/attr-chimeara/basename.patch @@ -0,0 +1,11 @@ +--- a/tools/attr.c ++++ b/tools/attr.c +@@ -31,6 +31,8 @@ + + #include + ++#define basename(src) (strrchr((src),'/') ? strrchr((src),'/')+1 : (src)) ++ + #include "misc.h" + + #define SETOP 1 /* do a SET operation */ diff --git a/patches/gcc-alpine/0001-posix_memalign.patch b/patches/gcc-alpine/0001-posix_memalign.patch new file mode 100644 index 0000000..04240c2 --- /dev/null +++ b/patches/gcc-alpine/0001-posix_memalign.patch @@ -0,0 +1,42 @@ +From 47b4bd4deb2c356bb07d2a96f22127aefafec3a4 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Fri, 26 Jan 2018 20:32:50 +0000 +Subject: [PATCH 01/35] posix_memalign + +--- + gcc/config/i386/pmm_malloc.h | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h +index 3527283693b..c4071b64b53 100644 +--- a/gcc/config/i386/pmm_malloc.h ++++ b/gcc/config/i386/pmm_malloc.h +@@ -27,12 +27,13 @@ + #include + + /* We can't depend on since the prototype of posix_memalign +- may not be visible. */ ++ may not be visible and we can't pollute the namespace either. */ + #ifndef __cplusplus +-extern int posix_memalign (void **, size_t, size_t); ++extern int _mm_posix_memalign (void **, size_t, size_t) + #else +-extern "C" int posix_memalign (void **, size_t, size_t) throw (); ++extern "C" int _mm_posix_memalign (void **, size_t, size_t) throw () + #endif ++__asm__("posix_memalign"); + + static __inline void * + _mm_malloc (size_t __size, size_t __alignment) +@@ -42,7 +43,7 @@ _mm_malloc (size_t __size, size_t __alignment) + return malloc (__size); + if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4)) + __alignment = sizeof (void *); +- if (posix_memalign (&__ptr, __alignment, __size) == 0) ++ if (_mm_posix_memalign (&__ptr, __alignment, __size) == 0) + return __ptr; + else + return NULL; +-- +2.41.0 + diff --git a/patches/gcc-alpine/0002-gcc-poison-system-directories.patch b/patches/gcc-alpine/0002-gcc-poison-system-directories.patch new file mode 100644 index 0000000..b14c921 --- /dev/null +++ b/patches/gcc-alpine/0002-gcc-poison-system-directories.patch @@ -0,0 +1,203 @@ +From 4fa620d8c3e6730211bfb071eb4c817320491bd0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 29 Mar 2013 08:59:00 +0400 +Subject: [PATCH 02/35] gcc: poison-system-directories + +Add /sw/include and /opt/include based on the original +zecke-no-host-includes.patch patch. The original patch checked for +/usr/include, /sw/include and /opt/include and then triggered a failure and +aborted. + +Instead, we add the two missing items to the current scan. If the user +wants this to be a failure, they can add "-Werror=poison-system-directories". + +Signed-off-by: Mark Hatle +Signed-off-by: Khem Raj + +Upstream-Status: Pending +--- + gcc/common.opt | 4 ++++ + gcc/config.in | 6 ++++++ + gcc/configure | 16 ++++++++++++++++ + gcc/configure.ac | 10 ++++++++++ + gcc/doc/invoke.texi | 9 +++++++++ + gcc/gcc.cc | 2 ++ + gcc/incpath.cc | 21 +++++++++++++++++++++ + 7 files changed, 68 insertions(+) + +diff --git a/gcc/common.opt b/gcc/common.opt +index 862c474d3c8..64c4277c991 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -711,6 +711,10 @@ Wreturn-local-addr + Common Var(warn_return_local_addr) Init(1) Warning + Warn about returning a pointer/reference to a local or temporary variable. + ++Wpoison-system-directories ++Common Var(flag_poison_system_directories) Init(1) Warning ++Warn for -I and -L options using system directories if cross compiling ++ + Wshadow + Common Var(warn_shadow) Warning + Warn when one variable shadows another. Same as -Wshadow=global. +diff --git a/gcc/config.in b/gcc/config.in +index 4cad077bfbe..0679fbbf4c6 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -236,6 +236,12 @@ + #endif + + ++/* Define to warn for use of native system header directories */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_POISON_SYSTEM_DIRECTORIES ++#endif ++ ++ + /* Define if you want all operations on RTL (the basic data structure of the + optimizer and back end) to be checked for dynamic type safety at runtime. + This is quite expensive. */ +diff --git a/gcc/configure b/gcc/configure +index c7b26d1927d..8c46369f73f 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -1026,6 +1026,7 @@ enable_maintainer_mode + enable_link_mutex + enable_link_serialization + enable_version_specific_runtime_libs ++enable_poison_system_directories + enable_plugin + enable_host_shared + enable_libquadmath_support +@@ -1788,6 +1789,8 @@ Optional Features: + --enable-version-specific-runtime-libs + specify that runtime libraries should be installed + in a compiler-specific directory ++ --enable-poison-system-directories ++ warn for use of native system header directories + --enable-plugin enable plugin support + --enable-host-shared build host code as shared libraries + --disable-libquadmath-support +@@ -31753,6 +31756,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : + fi + + ++# Check whether --enable-poison-system-directories was given. ++if test "${enable_poison_system_directories+set}" = set; then : ++ enableval=$enable_poison_system_directories; ++else ++ enable_poison_system_directories=no ++fi ++ ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ ++$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h ++ ++fi ++ + # Substitute configuration variables + + +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 09082e8ccae..5504bf6eb01 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -7292,6 +7292,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, + [specify that runtime libraries should be + installed in a compiler-specific directory])]) + ++AC_ARG_ENABLE([poison-system-directories], ++ AS_HELP_STRING([--enable-poison-system-directories], ++ [warn for use of native system header directories]),, ++ [enable_poison_system_directories=no]) ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], ++ [1], ++ [Define to warn for use of native system header directories]) ++fi ++ + # Substitute configuration variables + AC_SUBST(subdirs) + AC_SUBST(srcdir) +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index af0e5933fdb..b6731a4673c 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -384,6 +384,7 @@ Objective-C and Objective-C++ Dialects}. + -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded + -Wparentheses -Wno-pedantic-ms-format + -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast ++-Wno-poison-system-directories + -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls + -Wrestrict -Wno-return-local-addr -Wreturn-type + -Wno-scalar-storage-order -Wsequence-point +@@ -8426,6 +8427,14 @@ made up of data only and thus requires no special treatment. But, for + most targets, it is made up of code and thus requires the stack to be + made executable in order for the program to work properly. + ++@opindex Wno-poison-system-directories ++@item -Wno-poison-system-directories ++Do not warn for @option{-I} or @option{-L} options using system ++directories such as @file{/usr/include} when cross compiling. This ++option is intended for use in chroot environments when such ++directories contain the correct headers and libraries for the target ++system rather than the host. ++ + @opindex Wfloat-equal + @opindex Wno-float-equal + @item -Wfloat-equal +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index 16bb07f2cdc..33b56e721d2 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -1146,6 +1146,8 @@ proper position among the other output files. */ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ ++ %{Wno-poison-system-directories:--no-poison-system-directories} \ ++ %{Werror=poison-system-directories:--error-poison-system-directories} \ + %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ + %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ +diff --git a/gcc/incpath.cc b/gcc/incpath.cc +index 4d44321183f..0f3f071b44c 100644 +--- a/gcc/incpath.cc ++++ b/gcc/incpath.cc +@@ -26,6 +26,7 @@ + #include "intl.h" + #include "incpath.h" + #include "cppdefault.h" ++#include "diagnostic-core.h" + + /* Microsoft Windows does not natively support inodes. + VMS has non-numeric inodes. */ +@@ -399,6 +400,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) + } + fprintf (stderr, _("End of search list.\n")); + } ++ ++#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES ++ if (flag_poison_system_directories) ++ { ++ struct cpp_dir *p; ++ ++ for (p = heads[INC_QUOTE]; p; p = p->next) ++ { ++ if ((!strncmp (p->name, "/usr/include", 12)) ++ || (!strncmp (p->name, "/usr/local/include", 18)) ++ || (!strncmp (p->name, "/usr/X11R6/include", 18)) ++ || (!strncmp (p->name, "/sw/include", 11)) ++ || (!strncmp (p->name, "/opt/include", 12))) ++ warning (OPT_Wpoison_system_directories, ++ "include location \"%s\" is unsafe for " ++ "cross-compilation", ++ p->name); ++ } ++ } ++#endif + } + + /* Use given -I paths for #include "..." but not #include <...>, and +-- +2.41.0 + diff --git a/patches/gcc-alpine/0003-specs-turn-on-Wl-z-now-by-default.patch b/patches/gcc-alpine/0003-specs-turn-on-Wl-z-now-by-default.patch new file mode 100644 index 0000000..bfb0a6e --- /dev/null +++ b/patches/gcc-alpine/0003-specs-turn-on-Wl-z-now-by-default.patch @@ -0,0 +1,44 @@ +From ff4dd4ce33133e675b7bedc86b73357c04631cb9 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:45:49 +0000 +Subject: [PATCH 03/35] specs: turn on -Wl,-z,now by default + +Previously, we also used to turn on -z relro here, but we now build +binutils with --enable-relro, which is functionally equivalent. + +Binutils does not appear to have a similar option for enabling -z +now by default. +--- + gcc/doc/invoke.texi | 3 +++ + gcc/gcc.cc | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index b6731a4673c..f393c7846c6 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -17961,6 +17961,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the + linker. When using the GNU linker, you can also get the same effect with + @option{-Wl,-Map=output.map}. + ++NOTE: In Alpine Linux, for LDFLAGS, the option ++@option{-Wl,-z,now} is used. To disable, use @option{-Wl,-z,nonow}. ++ + @opindex u + @item -u @var{symbol} + Pretend the symbol @var{symbol} is undefined, to force linking of +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index 33b56e721d2..f82fae23c22 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -1144,6 +1144,7 @@ proper position among the other output files. */ + "%{flto|flto=*:% +Date: Fri, 21 Aug 2020 06:46:22 +0000 +Subject: [PATCH 04/35] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, + ObjC, ObjC++, if the optimization level is > 0 + +--- + gcc/c-family/c-cppbuiltin.cc | 4 ++++ + gcc/doc/invoke.texi | 6 ++++++ + 2 files changed, 10 insertions(+) + +diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc +index 5d64625fcd7..868d69506e4 100644 +--- a/gcc/c-family/c-cppbuiltin.cc ++++ b/gcc/c-family/c-cppbuiltin.cc +@@ -1546,6 +1546,10 @@ c_cpp_builtins (cpp_reader *pfile) + builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); + builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); + ++ /* Fortify Source enabled by default for optimization levels > 0 */ ++ if (optimize) ++ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2); ++ + /* Misc. */ + if (flag_gnu89_inline) + cpp_define (pfile, "__GNUC_GNU_INLINE__"); +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index f393c7846c6..ef3c14a189e 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -11868,6 +11868,12 @@ also turns on the following optimization flags: + Please note the warning under @option{-fgcse} about + invoking @option{-O2} on programs that use computed gotos. + ++NOTE: In Alpine Linux, @option{-D_FORTIFY_SOURCE=2} is ++set by default, and is activated when @option{-O} is set to 2 or higher. ++This enables additional compile-time and run-time checks for several libc ++functions. To disable, specify either @option{-U_FORTIFY_SOURCE} or ++@option{-D_FORTIFY_SOURCE=0}. ++ + @opindex O3 + @item -O3 + Optimize yet more. @option{-O3} turns on all optimizations specified +-- +2.41.0 + diff --git a/patches/gcc-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch b/patches/gcc-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch new file mode 100644 index 0000000..d229bcf --- /dev/null +++ b/patches/gcc-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch @@ -0,0 +1,272 @@ +From 67c0f5789630b27149f60ff831999ef7c1dba5d5 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:46:56 +0000 +Subject: [PATCH 05/35] On linux targets pass --as-needed by default to the + linker, but always link the sanitizer libraries with --no-as-needed. + +--- + gcc/config/aarch64/aarch64-linux.h | 1 + + gcc/config/alpha/linux-elf.h | 2 +- + gcc/config/arm/linux-elf.h | 1 + + gcc/config/gnu-user.h | 6 +++--- + gcc/config/i386/gnu-user.h | 2 +- + gcc/config/i386/gnu-user64.h | 1 + + gcc/config/ia64/linux.h | 2 +- + gcc/config/mips/gnu-user.h | 1 + + gcc/config/riscv/linux.h | 1 + + gcc/config/rs6000/linux64.h | 4 ++-- + gcc/config/rs6000/sysv4.h | 2 +- + gcc/config/s390/linux.h | 2 +- + gcc/config/sparc/linux.h | 2 +- + gcc/gcc.cc | 28 ++++++++++++++++++++-------- + 14 files changed, 36 insertions(+), 19 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h +index 4277f03da2a..b131983a546 100644 +--- a/gcc/config/aarch64/aarch64-linux.h ++++ b/gcc/config/aarch64/aarch64-linux.h +@@ -35,6 +35,7 @@ + #define CPP_SPEC "%{pthread:-D_REENTRANT}" + + #define LINUX_TARGET_LINK_SPEC "%{h*} \ ++ --as-needed \ + %{static:-Bstatic} \ + %{shared:-shared} \ + %{symbolic:-Bsymbolic} \ +diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h +index 03f783f2ad1..d946e700dda 100644 +--- a/gcc/config/alpha/linux-elf.h ++++ b/gcc/config/alpha/linux-elf.h +@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. If not see + + #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER + +-#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \ ++#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \ + %{O*:-O3} %{!O*:-O1} \ + %{shared:-shared} \ + %{!shared: \ +diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h +index 7b7b7cbbe14..49c050c6f2c 100644 +--- a/gcc/config/arm/linux-elf.h ++++ b/gcc/config/arm/linux-elf.h +@@ -70,6 +70,7 @@ + %{rdynamic:-export-dynamic} \ + %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ + -X \ ++ --as-needed \ + %{mbig-endian:-EB} %{mlittle-endian:-EL}" \ + SUBTARGET_EXTRA_LINK_SPEC + +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index eda8010b133..b26b17f2f2a 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \ + "%{static-libasan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ +- LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" ++ LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}" + #undef LIBHWASAN_EARLY_SPEC + #define LIBHWASAN_EARLY_SPEC "%{!shared:libhwasan_preinit%O%s} " \ + "%{static-libhwasan:%{!shared:" \ +@@ -146,12 +146,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \ + "%{static-libtsan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ +- LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}" ++ LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}" + #undef LIBLSAN_EARLY_SPEC + #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \ + "%{static-liblsan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \ +- LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}" ++ LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}" + #endif + + #undef TARGET_F951_OPTIONS +diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h +index a79b739089d..e0752673dff 100644 +--- a/gcc/config/i386/gnu-user.h ++++ b/gcc/config/i386/gnu-user.h +@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3. If not see + { "link_emulation", GNU_USER_LINK_EMULATION },\ + { "dynamic_linker", GNU_USER_DYNAMIC_LINKER } + +-#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ ++#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \ + %{!shared: \ + %{!static: \ + %{!static-pie: \ +diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h +index 3b63b99acf6..759bf0db86f 100644 +--- a/gcc/config/i386/gnu-user64.h ++++ b/gcc/config/i386/gnu-user64.h +@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \ + %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \ + %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \ ++ --as-needed \ + %{shared:-shared} \ + %{!shared: \ + %{!static: \ +diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h +index 5dfd428aa17..02656dad7fc 100644 +--- a/gcc/config/ia64/linux.h ++++ b/gcc/config/ia64/linux.h +@@ -58,7 +58,7 @@ do { \ + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2" + + #undef LINK_SPEC +-#define LINK_SPEC "\ ++#define LINK_SPEC " --as-needed \ + %{shared:-shared} \ + %{!shared: \ + %{!static: \ +diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h +index a4e5380b589..3cc61bce69f 100644 +--- a/gcc/config/mips/gnu-user.h ++++ b/gcc/config/mips/gnu-user.h +@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see + #undef GNU_USER_TARGET_LINK_SPEC + #define GNU_USER_TARGET_LINK_SPEC "\ + %{G*} %{EB} %{EL} %{mips*} %{shared} \ ++ -as-needed \ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h +index 3e625e0f867..f8c2c351e5a 100644 +--- a/gcc/config/riscv/linux.h ++++ b/gcc/config/riscv/linux.h +@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see + "%{mabi=ilp32:_ilp32}" + + #define LINK_SPEC "\ ++-as-needed \ + -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \ + %{mno-relax:--no-relax} \ + %{mbig-endian:-EB} \ +diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h +index 9e457033d11..08016bf224d 100644 +--- a/gcc/config/rs6000/linux64.h ++++ b/gcc/config/rs6000/linux64.h +@@ -377,13 +377,13 @@ extern int dot_symbols; + " -m elf64ppc") + #endif + +-#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ ++#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --as-needed %{!shared: %{!static: \ + %{!static-pie: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \ + %(link_os_extra_spec32)" + +-#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \ ++#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --as-needed %{!shared: %{!static: \ + %{!static-pie: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \ +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index ae932fc22f0..c8ff0c6dc8e 100644 +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -780,7 +780,7 @@ GNU_USER_TARGET_CC1_SPEC + #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER + #endif + +-#define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ ++#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --as-needed %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" + +diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h +index 02aa1edaff8..64df5801134 100644 +--- a/gcc/config/s390/linux.h ++++ b/gcc/config/s390/linux.h +@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3. If not see + + #undef LINK_SPEC + #define LINK_SPEC \ +- "%{m31:-m elf_s390}%{m64:-m elf64_s390} \ ++ "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \ + %{shared:-shared} \ + %{!shared: \ + %{static:-static} \ +diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h +index 0e33b3cac2c..c2f44546e62 100644 +--- a/gcc/config/sparc/linux.h ++++ b/gcc/config/sparc/linux.h +@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" + + #undef LINK_SPEC +-#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ ++#define LINK_SPEC "-m elf32_sparc --as-needed %{shared:-shared} \ + %{!mno-relax:%{!r:-relax}} \ + %{!shared: \ + %{!static: \ +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index f82fae23c22..da6417dd0d1 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -754,8 +754,11 @@ proper position among the other output files. */ + #ifdef LIBASAN_EARLY_SPEC + #define LIBASAN_SPEC STATIC_LIBASAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \ +- "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -lasan " \ ++ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBASAN_LIBS + #else + #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS +@@ -790,8 +793,11 @@ proper position among the other output files. */ + #ifdef LIBTSAN_EARLY_SPEC + #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \ +- "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -ltsan " \ ++ " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBTSAN_LIBS + #else + #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS +@@ -808,8 +814,11 @@ proper position among the other output files. */ + #ifdef LIBLSAN_EARLY_SPEC + #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \ +- "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -llsan " \ ++ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBLSAN_LIBS + #else + #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS +@@ -824,8 +833,11 @@ proper position among the other output files. */ + #define STATIC_LIBUBSAN_LIBS \ + " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" + #ifdef HAVE_LD_STATIC_DYNAMIC +-#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \ +- "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -lubsan " \ ++ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBUBSAN_LIBS + #else + #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS +-- +2.41.0 + diff --git a/patches/gcc-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch b/patches/gcc-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch new file mode 100644 index 0000000..55dff36 --- /dev/null +++ b/patches/gcc-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch @@ -0,0 +1,34 @@ +From bb25e8489384504cd59e4a2538720863da1fb29c Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:47:43 +0000 +Subject: [PATCH 06/35] Enable -Wformat and -Wformat-security by default. + +--- + gcc/c-family/c.opt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt +index a75038930ae..b98726f33ed 100644 +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -704,7 +704,7 @@ Warn about function calls with format strings that write past the end + of the destination region. Same as -Wformat-overflow=1. + + Wformat-security +-C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) ++C ObjC C++ ObjC++ Var(warn_format_security) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) + Warn about possible security problems with format functions. + + Wformat-signedness +@@ -725,7 +725,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ + Warn about zero-length formats. + + Wformat= +-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) ++C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) + Warn about printf/scanf/strftime/strfmon format string anomalies. + + Wformat-overflow= +-- +2.41.0 + diff --git a/patches/gcc-alpine/0007-Enable-Wtrampolines-by-default.patch b/patches/gcc-alpine/0007-Enable-Wtrampolines-by-default.patch new file mode 100644 index 0000000..eb7aae8 --- /dev/null +++ b/patches/gcc-alpine/0007-Enable-Wtrampolines-by-default.patch @@ -0,0 +1,25 @@ +From 4a728ad48a7b437cc6f2697e26603bf648149f86 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:48:24 +0000 +Subject: [PATCH 07/35] Enable -Wtrampolines by default. + +--- + gcc/common.opt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index 64c4277c991..c24839d32bc 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -803,7 +803,7 @@ Common Var(warn_system_headers) Warning + Do not suppress warnings from system headers. + + Wtrampolines +-Common Var(warn_trampolines) Warning ++Common Var(warn_trampolines) Init(1) Warning + Warn whenever a trampoline is generated. + + Wtrivial-auto-var-init +-- +2.41.0 + diff --git a/patches/gcc-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch b/patches/gcc-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch new file mode 100644 index 0000000..69c1bf7 --- /dev/null +++ b/patches/gcc-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch @@ -0,0 +1,53 @@ +From 32f24560d0602f7735d5e9efd92fe3151bd72cea Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:49:40 +0000 +Subject: [PATCH 08/35] Disable ssp on -nostdlib, -nodefaultlibs and + -ffreestanding Change the buffer size. + +--- + gcc/gcc.cc | 8 +++++++- + gcc/params.opt | 2 +- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index da6417dd0d1..b5a6f200635 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -983,6 +983,12 @@ proper position among the other output files. */ + #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" + #endif + ++#ifdef ENABLE_DEFAULT_SSP ++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} " ++#else ++#define NO_SSP_SPEC "" ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +@@ -1282,7 +1288,7 @@ static const char *cc1_options = + %{-version:--version}\ + %{-help=*:--help=%*}\ + %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\ +- %{fsyntax-only:-o %j} %{-param*}\ ++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\ + %{coverage:-fprofile-arcs -ftest-coverage}\ + %{fprofile-arcs|fprofile-generate*|coverage:\ + %{!fprofile-update=single:\ +diff --git a/gcc/params.opt b/gcc/params.opt +index 823cdb2ff85..5b096899b40 100644 +--- a/gcc/params.opt ++++ b/gcc/params.opt +@@ -1006,7 +1006,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim + The maximum number of SSA_NAME assignments to follow in determining a value. + + -param=ssp-buffer-size= +-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization ++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization + The lower bound for a buffer to be considered for stack smashing protection. + + -param=stack-clash-protection-guard-size= +-- +2.41.0 + diff --git a/patches/gcc-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch b/patches/gcc-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch new file mode 100644 index 0000000..f4dd52f --- /dev/null +++ b/patches/gcc-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch @@ -0,0 +1,54 @@ +From c7ec8da7280d7f97f5543eb9ddeca7600aafc43c Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:50:33 +0000 +Subject: [PATCH 09/35] Ensure that msgfmt doesn't encounter problems during + gcc bootstrapping. + +Solves error messages like the following: + +msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6) + +The libgcc_s.so used during build doesn't satisfy the needs of the +libstdc++.so that msgfmt is linked against. On the other hand, msgfmt +is used as a stand-alone application here, and what library it uses +behind the scenes is of no concern to the gcc build process. +Therefore, simply invoking it "as usual", i.e. without any special +library path, will make it work as expected here. + +2011-09-19 Martin von Gagern + +References: +https://bugs.gentoo.org/372377 +https://bugs.gentoo.org/295480 +--- + libstdc++-v3/po/Makefile.am | 1 + + libstdc++-v3/po/Makefile.in | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/libstdc++-v3/po/Makefile.am b/libstdc++-v3/po/Makefile.am +index 12d34910830..61b13762b71 100644 +--- a/libstdc++-v3/po/Makefile.am ++++ b/libstdc++-v3/po/Makefile.am +@@ -38,6 +38,7 @@ MSGFMT = msgfmt + EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN) + + .po.mo: ++ env --unset=LD_LIBRARY_PATH \ + $(MSGFMT) -o $@ $< + + all-local: all-local-$(USE_NLS) +diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in +index 8e93445acd2..d6ff06e5ddb 100644 +--- a/libstdc++-v3/po/Makefile.in ++++ b/libstdc++-v3/po/Makefile.in +@@ -561,6 +561,7 @@ uninstall-am: + + + .po.mo: ++ env --unset=LD_LIBRARY_PATH \ + $(MSGFMT) -o $@ $< + + all-local: all-local-$(USE_NLS) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch b/patches/gcc-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch new file mode 100644 index 0000000..f56d41a --- /dev/null +++ b/patches/gcc-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch @@ -0,0 +1,28 @@ +From aaa029bcee68298695b7c4278c90b6bc320d098c Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:52:07 +0000 +Subject: [PATCH 10/35] Don't declare asprintf if defined as a macro. + +--- + include/libiberty.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/include/libiberty.h b/include/libiberty.h +index 1d5c779fcff..19e3cb1e31c 100644 +--- a/include/libiberty.h ++++ b/include/libiberty.h +@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *, + /* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. */ + ++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */ ++#ifndef asprintf + extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2; + #endif ++#endif + + /* Like asprintf but allocates memory without fail. This works like + xmalloc. */ +-- +2.41.0 + diff --git a/patches/gcc-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch b/patches/gcc-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch new file mode 100644 index 0000000..b12d4f9 --- /dev/null +++ b/patches/gcc-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch @@ -0,0 +1,24 @@ +From 65e01e749205c9af218b01233cebd0077538d0ee Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:53:00 +0000 +Subject: [PATCH 11/35] libiberty: copy PIC objects during build process + +--- + libiberty/Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in +index 72608f3e4a7..58356884728 100644 +--- a/libiberty/Makefile.in ++++ b/libiberty/Makefile.in +@@ -265,6 +265,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) + $(AR) $(AR_FLAGS) $(TARGETLIB) \ + $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \ + $(RANLIB) $(TARGETLIB); \ ++ cp $(TARGETLIB) ../ ; \ + cd ..; \ + else true; fi + +-- +2.41.0 + diff --git a/patches/gcc-alpine/0012-libgcc_s.patch b/patches/gcc-alpine/0012-libgcc_s.patch new file mode 100644 index 0000000..d8bbc60 --- /dev/null +++ b/patches/gcc-alpine/0012-libgcc_s.patch @@ -0,0 +1,57 @@ +From 453a815bf2844971a91eaef800af188d9e86b784 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sat, 24 Oct 2015 20:09:53 +0000 +Subject: [PATCH 12/35] libgcc_s + +--- + gcc/config/i386/i386-expand.cc | 4 ++-- + libgcc/config/i386/cpuinfo.c | 6 +++--- + libgcc/config/i386/t-linux | 2 +- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc +index 0d817fc3f3b..2e99db00db9 100644 +--- a/gcc/config/i386/i386-expand.cc ++++ b/gcc/config/i386/i386-expand.cc +@@ -12691,10 +12691,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, + { + case IX86_BUILTIN_CPU_INIT: + { +- /* Make it call __cpu_indicator_init in libgcc. */ ++ /* Make it call __cpu_indicator_init in libgcc.a. */ + tree call_expr, fndecl, type; + type = build_function_type_list (integer_type_node, NULL_TREE); +- fndecl = build_fn_decl ("__cpu_indicator_init", type); ++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type); + call_expr = build_call_expr (fndecl, 0); + return expand_expr (call_expr, target, mode, EXPAND_NORMAL); + } +diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c +index 50b6d8248a2..724ced402a1 100644 +--- a/libgcc/config/i386/cpuinfo.c ++++ b/libgcc/config/i386/cpuinfo.c +@@ -63,7 +63,7 @@ __cpu_indicator_init (void) + __cpu_features2); + } + +-#if defined SHARED && defined USE_ELF_SYMVER +-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); +-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); ++#ifndef SHARED ++int __cpu_indicator_init_local (void) ++ __attribute__ ((weak, alias ("__cpu_indicator_init"))); + #endif +diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux +index 8506a635790..564296f788e 100644 +--- a/libgcc/config/i386/t-linux ++++ b/libgcc/config/i386/t-linux +@@ -3,5 +3,5 @@ + # t-slibgcc-elf-ver and t-linux + SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver + +-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS) ++HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) + CRTSTUFF_T_CFLAGS += $(CET_FLAGS) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0013-nopie.patch b/patches/gcc-alpine/0013-nopie.patch new file mode 100644 index 0000000..28a765e --- /dev/null +++ b/patches/gcc-alpine/0013-nopie.patch @@ -0,0 +1,75 @@ +From 7d7d12137c666761a8dd61179c9651b85dae9b41 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sat, 7 Nov 2015 02:08:05 +0000 +Subject: [PATCH 13/35] nopie + +--- + gcc/configure | 27 +++++++++++++++++++++++++++ + gcc/configure.ac | 13 +++++++++++++ + 2 files changed, 40 insertions(+) + +diff --git a/gcc/configure b/gcc/configure +index 8c46369f73f..e59cbee1767 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -32268,6 +32268,33 @@ fi + $as_echo "$gcc_cv_no_pie" >&6; } + if test "$gcc_cv_no_pie" = "yes"; then + NO_PIE_FLAG="-no-pie" ++else ++ # Check if -nopie works. ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5 ++$as_echo_n "checking for -nopie option... " >&6; } ++if test "${gcc_cv_nopie+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ saved_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS -nopie" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++int main(void) {return 0;} ++_ACEOF ++if ac_fn_cxx_try_link "$LINENO"; then : ++ gcc_cv_nopie=yes ++else ++ gcc_cv_nopie=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ LDFLAGS="$saved_LDFLAGS" ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5 ++$as_echo "$gcc_cv_nopie" >&6; } ++ if test "$gcc_cv_nopie" = "yes"; then ++ NO_PIE_FLAG="-nopie" ++ fi + fi + + +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 5504bf6eb01..57268319de1 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -7552,6 +7552,19 @@ AC_CACHE_CHECK([for -no-pie option], + LDFLAGS="$saved_LDFLAGS"]) + if test "$gcc_cv_no_pie" = "yes"; then + NO_PIE_FLAG="-no-pie" ++else ++ # Check if -nopie works. ++ AC_CACHE_CHECK([for -nopie option], ++ [gcc_cv_nopie], ++ [saved_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS -nopie" ++ AC_LINK_IFELSE([int main(void) {return 0;}], ++ [gcc_cv_nopie=yes], ++ [gcc_cv_nopie=no]) ++ LDFLAGS="$saved_LDFLAGS"]) ++ if test "$gcc_cv_nopie" = "yes"; then ++ NO_PIE_FLAG="-nopie" ++ fi + fi + AC_SUBST([NO_PIE_FLAG]) + +-- +2.41.0 + diff --git a/patches/gcc-alpine/0014-ada-fix-shared-linking.patch b/patches/gcc-alpine/0014-ada-fix-shared-linking.patch new file mode 100644 index 0000000..ff6e429 --- /dev/null +++ b/patches/gcc-alpine/0014-ada-fix-shared-linking.patch @@ -0,0 +1,42 @@ +From dd5bb97c31a9f57034c70a7a18ba6e2e133084c7 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:59:16 +0000 +Subject: [PATCH 14/35] ada: fix shared linking + +--- + gcc/ada/link.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/gcc/ada/link.c b/gcc/ada/link.c +index f2126441208..22cfa9c641f 100644 +--- a/gcc/ada/link.c ++++ b/gcc/ada/link.c +@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir = "lib"; + || defined (__NetBSD__) || defined (__OpenBSD__) \ + || defined (__QNX__) + const char *__gnat_object_file_option = "-Wl,@"; +-const char *__gnat_run_path_option = "-Wl,-rpath,"; +-char __gnat_shared_libgnat_default = STATIC; +-char __gnat_shared_libgcc_default = STATIC; ++const char *__gnat_run_path_option = ""; ++char __gnat_shared_libgnat_default = SHARED; ++char __gnat_shared_libgcc_default = SHARED; + int __gnat_link_max = 8192; + unsigned char __gnat_objlist_file_supported = 1; + const char *__gnat_object_library_extension = ".a"; +@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir = "lib"; + + #elif defined (__linux__) || defined (__GLIBC__) + const char *__gnat_object_file_option = "-Wl,@"; +-const char *__gnat_run_path_option = "-Wl,-rpath,"; +-char __gnat_shared_libgnat_default = STATIC; +-char __gnat_shared_libgcc_default = STATIC; ++const char *__gnat_run_path_option = ""; ++char __gnat_shared_libgnat_default = SHARED; ++char __gnat_shared_libgcc_default = SHARED; + int __gnat_link_max = 8192; + unsigned char __gnat_objlist_file_supported = 1; + const char *__gnat_object_library_extension = ".a"; +-- +2.41.0 + diff --git a/patches/gcc-alpine/0015-build-fix-CXXFLAGS_FOR_BUILD-passing.patch b/patches/gcc-alpine/0015-build-fix-CXXFLAGS_FOR_BUILD-passing.patch new file mode 100644 index 0000000..937cad8 --- /dev/null +++ b/patches/gcc-alpine/0015-build-fix-CXXFLAGS_FOR_BUILD-passing.patch @@ -0,0 +1,24 @@ +From 6bb5b7d9161d05f31b001d8211a9c63caf63fd2f Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:59:43 +0000 +Subject: [PATCH 15/35] build: fix CXXFLAGS_FOR_BUILD passing + +--- + Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makefile.in b/Makefile.in +index 06a9398e172..6ff2b3f9925 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -178,6 +178,7 @@ BUILD_EXPORTS = \ + # built for the build system to override those in BASE_FLAGS_TO_PASS. + EXTRA_BUILD_FLAGS = \ + CFLAGS="$(CFLAGS_FOR_BUILD)" \ ++ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ + LDFLAGS="$(LDFLAGS_FOR_BUILD)" + + # This is the list of directories to built for the host system. +-- +2.41.0 + diff --git a/patches/gcc-alpine/0016-add-fortify-headers-paths.patch b/patches/gcc-alpine/0016-add-fortify-headers-paths.patch new file mode 100644 index 0000000..b554e02 --- /dev/null +++ b/patches/gcc-alpine/0016-add-fortify-headers-paths.patch @@ -0,0 +1,25 @@ +From f0d9e00cac06689f64b214de7aee80d7116ef084 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:01:06 +0000 +Subject: [PATCH 16/35] add fortify-headers paths + +--- + gcc/config/linux.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gcc/config/linux.h b/gcc/config/linux.h +index e3aca79cccc..b3537b8fbeb 100644 +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -159,6 +159,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + #ifdef NATIVE_SYSTEM_HEADER_DIR + #define INCLUDE_DEFAULTS_MUSL_NATIVE \ ++ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 2 }, \ ++ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 0 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, + #else +-- +2.41.0 + diff --git a/patches/gcc-alpine/0017-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch b/patches/gcc-alpine/0017-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch new file mode 100644 index 0000000..9697248 --- /dev/null +++ b/patches/gcc-alpine/0017-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch @@ -0,0 +1,31 @@ +From 857db04f4f1a06e866551b4172fe8f27363f4a92 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Fri, 21 Aug 2020 07:03:00 +0000 +Subject: [PATCH 17/35] Alpine musl package provides libssp_nonshared.a. We + link to it unconditionally, as otherwise we get link failures if some objects + are -fstack-protector built and final link happens with -fno-stack-protector. + This seems to be the common case when bootstrapping gcc, the piepatches do + not seem to fully fix the crosstoolchain and bootstrap sequence wrt. + stack-protector flag usage. + +--- + gcc/gcc.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index b5a6f200635..6cbb726599b 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -991,8 +991,7 @@ proper position among the other output files. */ + + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP +-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +- "|fstack-protector-strong|fstack-protector-explicit:}" ++#define LINK_SSP_SPEC "-lssp_nonshared" + #else + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ +-- +2.41.0 + diff --git a/patches/gcc-alpine/0018-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch b/patches/gcc-alpine/0018-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch new file mode 100644 index 0000000..a961291 --- /dev/null +++ b/patches/gcc-alpine/0018-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch @@ -0,0 +1,69 @@ +From 5a8347e23ab13912b6edec2c6c6e3a101b017c79 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:03:42 +0000 +Subject: [PATCH 18/35] DP: Use --push-state/--pop-state for gold as well when + linking libtsan. + +--- + gcc/gcc.cc | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index 6cbb726599b..59390fd39d6 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -755,10 +755,10 @@ proper position among the other output files. */ + #define LIBASAN_SPEC STATIC_LIBASAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) + #define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ +- " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-libasan:--push-state --no-as-needed}" \ + " -lasan " \ + " %{static-libasan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-libasan:--pop-state}" \ + STATIC_LIBASAN_LIBS + #else + #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS +@@ -794,10 +794,10 @@ proper position among the other output files. */ + #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) + #define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \ +- " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-libtsan:--push-state --no-as-needed}" \ + " -ltsan " \ + " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-libtsan:--pop-state}" \ + STATIC_LIBTSAN_LIBS + #else + #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS +@@ -815,10 +815,10 @@ proper position among the other output files. */ + #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) + #define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ +- " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-liblsan:--push-state --no-as-needed}" \ + " -llsan " \ + " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-liblsan:--pop-state}" \ + STATIC_LIBLSAN_LIBS + #else + #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS +@@ -834,10 +834,10 @@ proper position among the other output files. */ + " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" + #ifdef HAVE_LD_STATIC_DYNAMIC + #define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ +- " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " %{!static-libubsan:--push-state --no-as-needed}" \ + " -lubsan " \ + " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ +- " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ ++ " %{!static-libubsan:--pop-state}" \ + STATIC_LIBUBSAN_LIBS + #else + #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS +-- +2.41.0 + diff --git a/patches/gcc-alpine/0019-aarch64-disable-multilib-support.patch b/patches/gcc-alpine/0019-aarch64-disable-multilib-support.patch new file mode 100644 index 0000000..5a8148f --- /dev/null +++ b/patches/gcc-alpine/0019-aarch64-disable-multilib-support.patch @@ -0,0 +1,26 @@ +From 41d00a2eb0754acf71958808bd17dbebeb517b84 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:12:55 +0000 +Subject: [PATCH 19/35] aarch64: disable multilib support + +multilib is unsupported on Alpine GCC +--- + gcc/config/aarch64/t-aarch64-linux | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux +index 57bf4100fcd..172894b57ef 100644 +--- a/gcc/config/aarch64/t-aarch64-linux ++++ b/gcc/config/aarch64/t-aarch64-linux +@@ -22,7 +22,7 @@ LIB1ASMSRC = aarch64/lib1funcs.asm + LIB1ASMFUNCS = _aarch64_sync_cache_range + + AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) +-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) ++MULTILIB_OSDIRNAMES = mabi.lp64=../lib + MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) + + MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0020-s390x-disable-multilib-support.patch b/patches/gcc-alpine/0020-s390x-disable-multilib-support.patch new file mode 100644 index 0000000..ef2f449 --- /dev/null +++ b/patches/gcc-alpine/0020-s390x-disable-multilib-support.patch @@ -0,0 +1,25 @@ +From 85b42bfbba71616831d14360b16998acb28790fd Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:13:59 +0000 +Subject: [PATCH 20/35] s390x: disable multilib support + +multilib is not supported on Alpine GCC at present +--- + gcc/config/s390/t-linux64 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/config/s390/t-linux64 b/gcc/config/s390/t-linux64 +index cc6ab367072..7f498ee1cdc 100644 +--- a/gcc/config/s390/t-linux64 ++++ b/gcc/config/s390/t-linux64 +@@ -7,5 +7,5 @@ + + MULTILIB_OPTIONS = m64/m31 + MULTILIB_DIRNAMES = 64 32 +-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu) +-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 +-- +2.41.0 + diff --git a/patches/gcc-alpine/0021-ppc64-le-disable-multilib-support.patch b/patches/gcc-alpine/0021-ppc64-le-disable-multilib-support.patch new file mode 100644 index 0000000..dbdc788 --- /dev/null +++ b/patches/gcc-alpine/0021-ppc64-le-disable-multilib-support.patch @@ -0,0 +1,81 @@ +From 7b53df284242638e940c0155b6c21e88cea1f55b Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:14:33 +0000 +Subject: [PATCH 21/35] ppc64[le]: disable multilib support + +multilib is not presently supported on Alpine GCC +--- + gcc/config/rs6000/t-linux | 6 ++++-- + gcc/config/rs6000/t-linux64 | 4 ++-- + gcc/config/rs6000/t-linux64bele | 4 ++-- + gcc/config/rs6000/t-linux64lebe | 4 ++-- + 4 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/gcc/config/rs6000/t-linux b/gcc/config/rs6000/t-linux +index 4e371255533..128c75c7d39 100644 +--- a/gcc/config/rs6000/t-linux ++++ b/gcc/config/rs6000/t-linux +@@ -2,7 +2,8 @@ + # or soft-float. + ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float))) + ifneq (,$(findstring powerpc64,$(target))) +-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + else + MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu) + endif +@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target))) + MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME)) + endif + ifneq (,$(findstring powerpc64le,$(target))) +-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES)) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + endif + endif + +diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 +index 01a94242308..b3a76379c03 100644 +--- a/gcc/config/rs6000/t-linux64 ++++ b/gcc/config/rs6000/t-linux64 +@@ -28,8 +28,8 @@ + MULTILIB_OPTIONS := m64/m32 + MULTILIB_DIRNAMES := 64 32 + MULTILIB_EXTRA_OPTS := +-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu) +-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + + rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc + $(COMPILE) $< +diff --git a/gcc/config/rs6000/t-linux64bele b/gcc/config/rs6000/t-linux64bele +index 97c1ee6fb4d..08d72639cb6 100644 +--- a/gcc/config/rs6000/t-linux64bele ++++ b/gcc/config/rs6000/t-linux64bele +@@ -2,6 +2,6 @@ + + MULTILIB_OPTIONS += mlittle + MULTILIB_DIRNAMES += le +-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES)))))) +-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES))) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 + MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} +diff --git a/gcc/config/rs6000/t-linux64lebe b/gcc/config/rs6000/t-linux64lebe +index 2e63bdb9fc9..c6e1c5db65d 100644 +--- a/gcc/config/rs6000/t-linux64lebe ++++ b/gcc/config/rs6000/t-linux64lebe +@@ -2,6 +2,6 @@ + + MULTILIB_OPTIONS += mbig + MULTILIB_DIRNAMES += be +-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES)))))) +-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES))) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} +-- +2.41.0 + diff --git a/patches/gcc-alpine/0022-x86_64-disable-multilib-support.patch b/patches/gcc-alpine/0022-x86_64-disable-multilib-support.patch new file mode 100644 index 0000000..2b2f3e7 --- /dev/null +++ b/patches/gcc-alpine/0022-x86_64-disable-multilib-support.patch @@ -0,0 +1,26 @@ +From 96e7e1e9a899d9bb5fcbdf788bd529d0390c626f Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:14:54 +0000 +Subject: [PATCH 22/35] x86_64: disable multilib support + +multilib is not presently supported on Alpine GCC +--- + gcc/config/i386/t-linux64 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 +index 138956b0962..bc03dab874f 100644 +--- a/gcc/config/i386/t-linux64 ++++ b/gcc/config/i386/t-linux64 +@@ -33,6 +33,6 @@ + comma=, + MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) + MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu) +-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 + MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0023-riscv-disable-multilib-support.patch b/patches/gcc-alpine/0023-riscv-disable-multilib-support.patch new file mode 100644 index 0000000..b919def --- /dev/null +++ b/patches/gcc-alpine/0023-riscv-disable-multilib-support.patch @@ -0,0 +1,76 @@ +From b26224acf342eacb33491f6ea0da1faf73d35715 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Mon, 3 Jan 2022 07:14:48 +0100 +Subject: [PATCH 23/35] riscv: disable multilib support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From the musl wiki [1]: + + musl does not support sharing an include directory between archs + […], and thus is not compatible with GCC-style multilib. It is + recommended that distributions build GCC with multilib disabled, + and use library directories named lib, not lib64 or lib32. + +For this reason, we patch existing GCC configuration files (gcc/config) +to pin MULTILIB_OSDIRNAMES to lib, there is also a corresponding GCC +upstream bug about this issue [2]. Avoiding the use of lib64 and lib32 +directories is a bit more difficult on the RISC-V architecture. This is +due to the fact that the default RISC-V configuration does not only use +the lib64 and lib32 directories but also subdirectories within these +directories for different RISC-V ABIs (e.g. lp64d, lp64, …) [3]. + +This patch aligns the RISC-V configuration with other architectures by +pinning MULTILIB_OSDIRNAMES to lib for rv64gc (our default RISC-V +-march). Furthermore, this patch removes the ABI-specific startfile +prefix spec. Since both of these impact the default LIBRARY_PATH [4] +this patch thereby aligns the default RISC-V LIBRARY_PATH with that from +other Alpine architectures and thereby fixes #13369 [5]. + +Incidentally, this also fixes gccgo on riscv64, as without this patch +gccgo is otherwise not able to find the *.gox files for the Go standard +library. + +[1]: https://wiki.musl-libc.org/guidelines-for-distributions.html#Multilib/multi_arch +[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077 +[3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889#c14 +[4]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.c;h=d4c8746b0aa322286decf92aa72a12f0a393b655;hb=HEAD#l9122 +[5]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13369 +--- + gcc/config/riscv/linux.h | 8 -------- + gcc/config/riscv/t-linux | 7 +++++-- + 2 files changed, 5 insertions(+), 10 deletions(-) + +diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h +index f8c2c351e5a..8d9881eadeb 100644 +--- a/gcc/config/riscv/linux.h ++++ b/gcc/config/riscv/linux.h +@@ -61,11 +61,3 @@ along with GCC; see the file COPYING3. If not see + %{static:-static}}" + + #define TARGET_ASM_FILE_END file_end_indicate_exec_stack +- +-#define STARTFILE_PREFIX_SPEC \ +- "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ +- "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ +- "/lib/ " \ +- "/usr/lib/ " +- +-#define RISCV_USE_CUSTOMISED_MULTI_LIB select_by_abi +diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux +index 216d2776a18..1a8a863853e 100644 +--- a/gcc/config/riscv/t-linux ++++ b/gcc/config/riscv/t-linux +@@ -1,3 +1,6 @@ +-# Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ +-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) ++MULTILIB_OPTIONS := march=rv64gc ++MULTILIB_DIRNAMES := rv64gc ++ ++MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib,$(MULTILIB_DIRNAMES))) + MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) ++MULTILIB_MATCHES := march?rv64gc=march?rv64imafdc +-- +2.41.0 + diff --git a/patches/gcc-alpine/0024-always-build-libgcc_eh.a.patch b/patches/gcc-alpine/0024-always-build-libgcc_eh.a.patch new file mode 100644 index 0000000..6b0514e --- /dev/null +++ b/patches/gcc-alpine/0024-always-build-libgcc_eh.a.patch @@ -0,0 +1,51 @@ +From a72e0613f79f6b6867819317accb7a714031a08c Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:05:41 +0000 +Subject: [PATCH 24/35] always build libgcc_eh.a + +highly inspired by: + http://landley.net/hg/aboriginal/file/7e0747a665ab/sources/patches/gcc-core-libgcceh.patch +--- + libgcc/Makefile.in | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in +index 6c4dc79ab71..023cede18a7 100644 +--- a/libgcc/Makefile.in ++++ b/libgcc/Makefile.in +@@ -960,8 +960,9 @@ ifneq ($(LIBUNWIND),) + all: libunwind.a + endif + ++all: libgcc_eh.a + ifeq ($(enable_shared),yes) +-all: libgcc_eh.a libgcc_s$(SHLIB_EXT) ++all: libgcc_s$(SHLIB_EXT) + ifneq ($(LIBUNWIND),) + all: libunwind$(SHLIB_EXT) + libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +@@ -1163,10 +1164,6 @@ install-libunwind: + install-shared: + $(mkinstalldirs) $(DESTDIR)$(inst_libdir) + +- $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ +- chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a +- $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a +- + $(subst @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_base_name@,libgcc_s,$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL)))) +@@ -1183,6 +1180,10 @@ ifeq ($(enable_gcov),yes) + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a + endif + ++ $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ ++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a ++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a ++ + parts="$(INSTALL_PARTS)"; \ + for file in $$parts; do \ + rm -f $(DESTDIR)$(inst_libdir)/$$file; \ +-- +2.41.0 + diff --git a/patches/gcc-alpine/0025-ada-libgnarl-compatibility-for-musl.patch b/patches/gcc-alpine/0025-ada-libgnarl-compatibility-for-musl.patch new file mode 100644 index 0000000..b7c1c5f --- /dev/null +++ b/patches/gcc-alpine/0025-ada-libgnarl-compatibility-for-musl.patch @@ -0,0 +1,135 @@ +From 3ee8cbc1cad261b30d4a7a66d31496d5f243ce2f Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:06:30 +0000 +Subject: [PATCH 25/35] ada: libgnarl compatibility for musl + +--- + gcc/ada/libgnarl/s-osinte__linux.ads | 11 ------ + gcc/ada/libgnarl/s-taprop__linux.adb | 53 ++-------------------------- + 2 files changed, 3 insertions(+), 61 deletions(-) + +diff --git a/gcc/ada/libgnarl/s-osinte__linux.ads b/gcc/ada/libgnarl/s-osinte__linux.ads +index a5e645d334d..32165347071 100644 +--- a/gcc/ada/libgnarl/s-osinte__linux.ads ++++ b/gcc/ada/libgnarl/s-osinte__linux.ads +@@ -403,12 +403,6 @@ package System.OS_Interface is + PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1; + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2; + +- function pthread_rwlockattr_setkind_np +- (attr : access pthread_rwlockattr_t; +- pref : int) return int; +- pragma Import +- (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np"); +- + function pthread_rwlock_init + (mutex : access pthread_rwlock_t; + attr : access pthread_rwlockattr_t) return int; +@@ -470,11 +464,6 @@ package System.OS_Interface is + protocol : int) return int; + pragma Import (C, pthread_mutexattr_setprotocol); + +- function pthread_mutexattr_setprioceiling +- (attr : access pthread_mutexattr_t; +- prioceiling : int) return int; +- pragma Import (C, pthread_mutexattr_setprioceiling); +- + type struct_sched_param is record + sched_priority : int; -- scheduling priority + end record; +diff --git a/gcc/ada/libgnarl/s-taprop__linux.adb b/gcc/ada/libgnarl/s-taprop__linux.adb +index 821ceef30e4..ae95b58e01e 100644 +--- a/gcc/ada/libgnarl/s-taprop__linux.adb ++++ b/gcc/ada/libgnarl/s-taprop__linux.adb +@@ -198,9 +198,6 @@ package body System.Task_Primitives.Operations is + pragma Import + (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); + +- function GNAT_has_cap_sys_nice return C.int; +- pragma Import +- (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice"); + -- We do not have pragma Linker_Options ("-lcap"); here, because this + -- library is not present on many Linux systems. 'libcap' is the Linux + -- "capabilities" library, called by __gnat_has_cap_sys_nice. +@@ -210,38 +207,6 @@ package body System.Task_Primitives.Operations is + -- Convert Ada priority to Linux priority. Priorities are 1 .. 99 on + -- GNU/Linux, so we map 0 .. 98 to 1 .. 99. + +- function Get_Ceiling_Support return Boolean; +- -- Get the value of the Ceiling_Support constant (see below). +- -- Note well: If this function or related code is modified, it should be +- -- tested by hand, because automated testing doesn't exercise it. +- +- ------------------------- +- -- Get_Ceiling_Support -- +- ------------------------- +- +- function Get_Ceiling_Support return Boolean is +- Ceiling_Support : Boolean := False; +- begin +- if Locking_Policy /= 'C' then +- return False; +- end if; +- +- declare +- function geteuid return Integer; +- pragma Import (C, geteuid, "geteuid"); +- Superuser : constant Boolean := geteuid = 0; +- Has_Cap : constant C.int := GNAT_has_cap_sys_nice; +- pragma Assert (Has_Cap in 0 | 1); +- begin +- Ceiling_Support := Superuser or else Has_Cap = 1; +- end; +- +- return Ceiling_Support; +- end Get_Ceiling_Support; +- +- pragma Warnings (Off, "non-preelaborable call not allowed*"); +- Ceiling_Support : constant Boolean := Get_Ceiling_Support; +- pragma Warnings (On, "non-preelaborable call not allowed*"); + -- True if the locking policy is Ceiling_Locking, and the current process + -- has permission to use this policy. The process has permission if it is + -- running as 'root', or if the capability was set by the setcap command, +@@ -344,7 +309,9 @@ package body System.Task_Primitives.Operations is + -- Init_Mutex -- + ---------------- + ++ pragma Warnings (Off, "formal parameter * is not referenced"); + function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is ++ pragma Warnings (On, "formal parameter * is not referenced"); + Mutex_Attr : aliased pthread_mutexattr_t; + Result, Result_2 : C.int; + +@@ -356,16 +323,7 @@ package body System.Task_Primitives.Operations is + return Result; + end if; + +- if Ceiling_Support then +- Result := pthread_mutexattr_setprotocol +- (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT); +- pragma Assert (Result = 0); +- +- Result := pthread_mutexattr_setprioceiling +- (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio)); +- pragma Assert (Result = 0); +- +- elsif Locking_Policy = 'I' then ++ if Locking_Policy = 'I' then + Result := pthread_mutexattr_setprotocol + (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT); + pragma Assert (Result = 0); +@@ -405,11 +363,6 @@ package body System.Task_Primitives.Operations is + Result := pthread_rwlockattr_init (RWlock_Attr'Access); + pragma Assert (Result = 0); + +- Result := pthread_rwlockattr_setkind_np +- (RWlock_Attr'Access, +- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); +- pragma Assert (Result = 0); +- + Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access); + + pragma Assert (Result in 0 | ENOMEM); +-- +2.41.0 + diff --git a/patches/gcc-alpine/0026-ada-musl-support-fixes.patch b/patches/gcc-alpine/0026-ada-musl-support-fixes.patch new file mode 100644 index 0000000..ada9293 --- /dev/null +++ b/patches/gcc-alpine/0026-ada-musl-support-fixes.patch @@ -0,0 +1,223 @@ +From 3df4788c79c7429b196c7b284af2b4cf9a4b4f8d Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:07:48 +0000 +Subject: [PATCH 26/35] ada: musl support fixes + +--- + gcc/ada/Makefile.rtl | 10 +++++----- + gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- + gcc/ada/adaint.h | 10 ++++------ + gcc/ada/terminals.c | 8 ++++---- + 4 files changed, 32 insertions(+), 30 deletions(-) + +diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl +index 96306f8cc9a..090b6770ae5 100644 +--- a/gcc/ada/Makefile.rtl ++++ b/gcc/ada/Makefile.rtl +@@ -1549,7 +1549,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) + s-intman.adb + #include + #endif ++ ++#if defined (linux) || defined(__linux__) ++#define _GNU_SOURCE 1 ++#include ++#endif + + #ifdef __PikeOS__ + #define __BSD_VISIBLE 1 +@@ -3438,7 +3443,6 @@ __gnat_lwp_self (void) + #endif + + #if defined (__linux__) +-#include + + /* glibc versions earlier than 2.7 do not define the routines to handle + dynamically allocated CPU sets. For these targets, we use the static +@@ -3448,7 +3452,7 @@ __gnat_lwp_self (void) + + /* Dynamic cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count) + { + return CPU_ALLOC (count); +@@ -3461,33 +3465,33 @@ __gnat_cpu_alloc_size (size_t count) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { +- CPU_FREE (set); ++ CPU_FREE ((cpu_set_t *) set); + } + + void +-__gnat_cpu_zero (size_t count, cpu_set_t *set) ++__gnat_cpu_zero (size_t count, void *set) + { +- CPU_ZERO_S (count, set); ++ CPU_ZERO_S (count, (cpu_set_t *) set); + } + + void +-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET_S (cpu - 1, count, set); ++ CPU_SET_S (cpu - 1, count, (cpu_set_t *) set); + } + + #else /* !CPU_ALLOC */ + + /* Static cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) + { +- return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); ++ return xmalloc (sizeof (cpu_set_t)); + } + + size_t +@@ -3497,23 +3501,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { + free (set); + } + + void +-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) + { +- CPU_ZERO (set); ++ CPU_ZERO ((cpu_set_t *) set); + } + + void +-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET (cpu - 1, set); ++ CPU_SET (cpu - 1, (cpu_set_t *) set); + } + #endif /* !CPU_ALLOC */ + #endif /* __linux__ */ +diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h +index 987432c9307..4d782f07de9 100644 +--- a/gcc/ada/adaint.h ++++ b/gcc/ada/adaint.h +@@ -319,13 +319,11 @@ extern void *__gnat_lwp_self (void); + + /* Routines for interface to required CPU set primitives */ + +-#include +- +-extern cpu_set_t *__gnat_cpu_alloc (size_t); ++extern void * __gnat_cpu_alloc (size_t); + extern size_t __gnat_cpu_alloc_size (size_t); +-extern void __gnat_cpu_free (cpu_set_t *); +-extern void __gnat_cpu_zero (size_t, cpu_set_t *); +-extern void __gnat_cpu_set (int, size_t, cpu_set_t *); ++extern void __gnat_cpu_free (void *); ++extern void __gnat_cpu_zero (size_t, void *); ++extern void __gnat_cpu_set (int, size_t, void *); + #endif + + #if defined (_WIN32) +diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c +index c0ee4a16bb1..ed796a48c1b 100644 +--- a/gcc/ada/terminals.c ++++ b/gcc/ada/terminals.c +@@ -1127,7 +1127,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, + /* POSIX does not specify how to open the master side of a terminal.Several + methods are available (system specific): + 1- using a cloning device (USE_CLONE_DEVICE) +- 2- getpt (USE_GETPT) ++ 2- posix_openpt (USE_POSIX_OPENPT) + 3- openpty (USE_OPENPTY) + + When using the cloning device method, the macro USE_CLONE_DEVICE should +@@ -1141,7 +1141,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, + #if defined (__APPLE__) || defined (BSD) + #define USE_OPENPTY + #elif defined (__linux__) +-#define USE_GETPT ++#define USE_POSIX_OPENPT + #elif defined (__sun__) + #define USE_CLONE_DEVICE "/dev/ptmx" + #elif defined (_AIX) +@@ -1190,8 +1190,8 @@ allocate_pty_desc (pty_desc **desc) { + int master_fd = -1; + char *slave_name = NULL; + +-#ifdef USE_GETPT +- master_fd = getpt (); ++#if defined(USE_POSIX_OPENPT) ++ master_fd = posix_openpt(O_RDWR | O_NOCTTY); + #elif defined (USE_OPENPTY) + status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); + #elif defined (USE_CLONE_DEVICE) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch b/patches/gcc-alpine/0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch new file mode 100644 index 0000000..fcf74ee --- /dev/null +++ b/patches/gcc-alpine/0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch @@ -0,0 +1,256 @@ +From 7b50823d8a4131e5a55d2499a0f5a52b3d91eed2 Mon Sep 17 00:00:00 2001 +From: Drew DeVault +Date: Wed, 9 Dec 2020 07:42:06 +0000 +Subject: [PATCH 27/35] configure: Add --enable-autolink-libatomic, use in + LINK_GCC_C_SEQUENCE_SPEC [PR81358] + +This fixes issues with RISC-V. +--- + Makefile.in | 1 + + gcc/config.in | 6 ++++++ + gcc/config/gnu-user.h | 12 +++++++++++- + gcc/configure | 31 ++++++++++++++++++++++++++++++- + gcc/configure.ac | 21 +++++++++++++++++++++ + gcc/doc/install.texi | 8 ++++++++ + gcc/doc/tm.texi | 8 +++++++- + gcc/doc/tm.texi.in | 8 +++++++- + gcc/gcc.cc | 12 +++++++++++- + 9 files changed, 102 insertions(+), 5 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +index 6ff2b3f9925..394b105b271 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -235,6 +235,7 @@ HOST_EXPORTS = \ + RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \ + READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \ + TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ ++ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \ + HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \ + GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \ + GMPINC="$(HOST_GMPINC)"; export GMPINC; \ +diff --git a/gcc/config.in b/gcc/config.in +index 0679fbbf4c6..ee81139b385 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -118,6 +118,12 @@ + #endif + + ++/* Define if libatomic should always be linked. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_AUTOLINK_LIBATOMIC ++#endif ++ ++ + /* Define to 1 to specify that we are using the BID decimal floating point + format instead of DPD */ + #ifndef USED_FOR_TARGET +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index b26b17f2f2a..3f64ea46180 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " + #endif + ++#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC) ++# ifdef LD_AS_NEEDED_OPTION ++# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION ++# else ++# define LINK_LIBATOMIC_SPEC "-latomic" ++# endif ++#elif !defined(LINK_LIBATOMIC_SPEC) ++# define LINK_LIBATOMIC_SPEC "" ++#endif ++ + #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \ +- "%{static|static-pie:--start-group} %G %{!nolibc:%L} \ ++ "%{static|static-pie:--start-group} %G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L} \ + %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" + + #undef LINK_GCC_C_SEQUENCE_SPEC +diff --git a/gcc/configure b/gcc/configure +index e59cbee1767..787c35d4e25 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -984,6 +984,7 @@ with_changes_root_url + enable_languages + with_multilib_list + with_multilib_generator ++enable_autolink_libatomic + with_zstd + with_zstd_include + with_zstd_lib +@@ -1713,6 +1714,9 @@ Optional Features: + --disable-shared don't provide a shared libgcc + --disable-gcov don't provide libgcov and related host tools + --enable-languages=LIST specify which front-ends to build ++ --enable-autolink-libatomic ++ enable automatic linking of libatomic (ignored if ++ not built) + --disable-rpath do not hardcode runtime library paths + --enable-sjlj-exceptions + arrange to use setjmp/longjmp exception handling +@@ -8329,7 +8333,6 @@ else + fi + + +- + # Check whether --with-multilib-generator was given. + if test "${with_multilib_generator+set}" = set; then : + withval=$with_multilib_generator; : +@@ -8337,6 +8340,32 @@ else + with_multilib_generator=default + fi + ++# If libatomic is available, whether it should be linked automatically ++# Check whether --enable-autolink-libatomic was given. ++if test "${enable_autolink_libatomic+set}" = set; then : ++ enableval=$enable_autolink_libatomic; ++ case $enable_autolink_libatomic in ++ yes | no) ;; ++ *) as_fn_error $? "'$enable_autolink_libatomic' is an invalid value for ++--enable-autolink-libatomic. Valid choices are 'yes' and 'no'." "$LINENO" 5 ;; ++ esac ++ ++else ++ enable_autolink_libatomic='' ++fi ++ ++ ++if test x$enable_autolink_libatomic = xyes; then ++ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then ++ ++$as_echo "#define ENABLE_AUTOLINK_LIBATOMIC 1" >>confdefs.h ++ ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&5 ++$as_echo "$as_me: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&2;} ++ fi ++fi ++ + + # ------------------------- + # Checks for other programs +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 57268319de1..56bcaa87620 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -1199,6 +1199,27 @@ AC_ARG_WITH(multilib-generator, + :, + with_multilib_generator=default) + ++# If libatomic is available, whether it should be linked automatically ++AC_ARG_ENABLE(autolink-libatomic, ++[AS_HELP_STRING([--enable-autolink-libatomic], ++ [enable automatic linking of libatomic (ignored if not built)])], ++[ ++ case $enable_autolink_libatomic in ++ yes | no) ;; ++ *) AC_MSG_ERROR(['$enable_autolink_libatomic' is an invalid value for ++--enable-autolink-libatomic. Valid choices are 'yes' and 'no'.]) ;; ++ esac ++], [enable_autolink_libatomic='']) ++ ++if test x$enable_autolink_libatomic = xyes; then ++ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then ++ AC_DEFINE(ENABLE_AUTOLINK_LIBATOMIC, 1, ++ [Define if libatomic should always be linked.]) ++ else ++ AC_MSG_WARN([libatomic is not build for this target, --enable-autolink-libatomic ignored]) ++ fi ++fi ++ + # ------------------------- + # Checks for other programs + # ------------------------- +diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi +index b30d3691fe6..ccc8e5dbb00 100644 +--- a/gcc/doc/install.texi ++++ b/gcc/doc/install.texi +@@ -2377,6 +2377,14 @@ files, but these changed header paths may conflict with some compilation + environments. Enabled by default, and may be disabled using + @option{--disable-canonical-system-headers}. + ++@item --enable-autolink-libatomic ++@itemx --disable-autolink-libatomic ++Tell GCC that it should automatically link libatomic; if supported by ++the linker, the file is only linked as needed. This flag is ignored ++when libatomic is not built. Note that this conigure flag is in particular ++useful when building an offloading-target compiler; as for those, a ++user had to specify @code{-foffload=target=-latomic} otherwise. ++ + @item --with-glibc-version=@var{major}.@var{minor} + Tell GCC that when the GNU C Library (glibc) is used on the target it + will be version @var{major}.@var{minor} or later. Normally this can +diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi +index a660e33739b..6183c407a2b 100644 +--- a/gcc/doc/tm.texi ++++ b/gcc/doc/tm.texi +@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search. + + @defmac LINK_GCC_C_SEQUENCE_SPEC + The sequence in which libgcc and libc are specified to the linker. +-By default this is @code{%G %L %G}. ++By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}. ++@end defmac ++ ++@defmac LINK_LIBATOMIC_SPEC ++This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link ++libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC} ++is set. + @end defmac + + @defmac POST_LINK_SPEC +diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in +index f7ab5d48a63..281540aba68 100644 +--- a/gcc/doc/tm.texi.in ++++ b/gcc/doc/tm.texi.in +@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search. + + @defmac LINK_GCC_C_SEQUENCE_SPEC + The sequence in which libgcc and libc are specified to the linker. +-By default this is @code{%G %L %G}. ++By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}. ++@end defmac ++ ++@defmac LINK_LIBATOMIC_SPEC ++This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link ++libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC} ++is set. + @end defmac + + @defmac POST_LINK_SPEC +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index 59390fd39d6..dae1dd4cf79 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -974,13 +974,23 @@ proper position among the other output files. */ + # define ASM_DEBUG_OPTION_SPEC "" + #endif + ++#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC) ++# ifdef LD_AS_NEEDED_OPTION ++# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION ++# else ++# define LINK_LIBATOMIC_SPEC "-latomic" ++# endif ++#elif !defined(LINK_LIBATOMIC_SPEC) ++# define LINK_LIBATOMIC_SPEC "" ++#endif ++ + /* Here is the spec for running the linker, after compiling all files. */ + + /* This is overridable by the target in case they need to specify the + -lgcc and -lc order specially, yet not require them to override all + of LINK_COMMAND_SPEC. */ + #ifndef LINK_GCC_C_SEQUENCE_SPEC +-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" ++#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}" + #endif + + #ifdef ENABLE_DEFAULT_SSP +-- +2.41.0 + diff --git a/patches/gcc-alpine/0028-configure-fix-detection-of-atomic-builtins-in-libato.patch b/patches/gcc-alpine/0028-configure-fix-detection-of-atomic-builtins-in-libato.patch new file mode 100644 index 0000000..f92fc7b --- /dev/null +++ b/patches/gcc-alpine/0028-configure-fix-detection-of-atomic-builtins-in-libato.patch @@ -0,0 +1,57 @@ +From 5bbbd320e54ab5341cfba83e8af98685131caba1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 29 Aug 2021 12:23:34 +0200 +Subject: [PATCH 28/35] configure: fix detection of atomic builtins in + libatomic configure script + +Alpine's --enable-autolink-libatomic (which is enabled for riscv64 by +default) causes the libatomic configure script to incorrectly detect +which builtins are available on riscv64. This then causes incorrect code +generation for libatomic since it assumes compiler builtins to be +available which are not actually available on riscv64. + +This commit fixes this issue by disabling linking of libatomic configure +test code entirely, thereby preventing linking against libatomic. + +See: + +* https://gitlab.alpinelinux.org/alpine/aports/-/issues/12948 +* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c6 +--- + libatomic/configure.tgt | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt +index a92ae9e8309..90b579ca4d8 100644 +--- a/libatomic/configure.tgt ++++ b/libatomic/configure.tgt +@@ -30,6 +30,26 @@ + # on ${target_cpu}. For example to allow proper use of multilibs. + configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}" + ++# The libatomic configure script performs several checks to determine ++# whether builtins for atomic operations are available. When compiling ++# with --enable-autolink-libatomic the test code compiled by the ++# configure script is also linked against libatomic. This causes it ++# to think that builtins are available, even if there are not, since ++# the tested symbols are provided by libatomic. ++# ++# This is a hack to ensure that we don't link against libatomic by not ++# linking any configure test code at all when --enable-autolink-libatomic ++# is given. ++# ++# See: ++# ++# * https://gitlab.alpinelinux.org/alpine/aports/-/issues/12817 ++# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c4 ++# ++if test x$enable_autolink_libatomic = xyes; then ++ gcc_no_link=yes ++fi ++ + case "${target_cpu}" in + alpha*) + # fenv.c needs this option to generate inexact exceptions. +-- +2.41.0 + diff --git a/patches/gcc-alpine/0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch b/patches/gcc-alpine/0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch new file mode 100644 index 0000000..4418cd5 --- /dev/null +++ b/patches/gcc-alpine/0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch @@ -0,0 +1,27 @@ +From 430c701a3cefbe09a9c7c8a2f5bbe957f9b2ecb2 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Thu, 30 Jun 2022 16:44:51 +0000 +Subject: [PATCH 29/35] libstdc++: do not throw exceptions for non-C locales on + musl targets + +--- + libstdc++-v3/config/locale/generic/c_locale.cc | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc +index 8849d78fdfa..aff467f98fe 100644 +--- a/libstdc++-v3/config/locale/generic/c_locale.cc ++++ b/libstdc++-v3/config/locale/generic/c_locale.cc +@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + // Currently, the generic model only supports the "C" locale. + // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html + __cloc = 0; +- if (strcmp(__s, "C")) +- __throw_runtime_error(__N("locale::facet::_S_create_c_locale " +- "name not valid")); + } + + void +-- +2.41.0 + diff --git a/patches/gcc-alpine/0030-gdc-unconditionally-link-libgphobos-against-libucont.patch b/patches/gcc-alpine/0030-gdc-unconditionally-link-libgphobos-against-libucont.patch new file mode 100644 index 0000000..6c5bf83 --- /dev/null +++ b/patches/gcc-alpine/0030-gdc-unconditionally-link-libgphobos-against-libucont.patch @@ -0,0 +1,27 @@ +From 05f0043755f341a2ff4f845379327076b3e0203d Mon Sep 17 00:00:00 2001 +From: Mathias LANG +Date: Mon, 17 Jan 2022 03:49:21 +0000 +Subject: [PATCH 30/35] gdc: unconditionally link libgphobos against + libucontext + +ref: alpine/aports#13422 +--- + Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 394b105b271..bc4a77fc300 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -52809,7 +52809,7 @@ configure-target-libphobos: + esac; \ + module_srcdir=libphobos; \ + rm -f no-such-file || : ; \ +- CONFIG_SITE=no-such-file $(SHELL) \ ++ CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \ + $$s/$$module_srcdir/configure \ + --srcdir=$${topdir}/$$module_srcdir \ + $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +-- +2.41.0 + diff --git a/patches/gcc-alpine/0031-druntime-link-against-libucontext-on-all-platforms.patch b/patches/gcc-alpine/0031-druntime-link-against-libucontext-on-all-platforms.patch new file mode 100644 index 0000000..eb7aa6d --- /dev/null +++ b/patches/gcc-alpine/0031-druntime-link-against-libucontext-on-all-platforms.patch @@ -0,0 +1,54 @@ +From 0b89a74fbf77ae6917f043c79cd03db0d6ef0212 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sat, 16 Jul 2022 09:21:11 +0200 +Subject: [PATCH 31/35] druntime: link against libucontext on all platforms + +On musl-based Linux distributions, swapcontext etc. are not provided by +musl but instead by libucontext. Hence, we _always_ need to link against +an external library for these functions. +--- + libphobos/configure | 8 -------- + libphobos/m4/druntime/libraries.m4 | 8 -------- + 2 files changed, 16 deletions(-) + +diff --git a/libphobos/configure b/libphobos/configure +index 925c53c5f5e..60c2a0c11c6 100755 +--- a/libphobos/configure ++++ b/libphobos/configure +@@ -15216,14 +15216,6 @@ fi + # Keep this in sync with core/thread.d, set druntime_fiber_asm_external to + # "yes" for targets that have 'version = AsmExternal'. + druntime_fiber_asm_external=no +- case "$target_cpu" in +- aarch64* | \ +- arm* | \ +- i[34567]86|x86_64 | \ +- powerpc) +- druntime_fiber_asm_external=yes +- ;; +- esac + if test "$druntime_fiber_asm_external" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5 + $as_echo_n "checking for library containing swapcontext... " >&6; } +diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 +index 45a56f6f76a..fef6e890b1e 100644 +--- a/libphobos/m4/druntime/libraries.m4 ++++ b/libphobos/m4/druntime/libraries.m4 +@@ -220,14 +220,6 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT], + # Keep this in sync with core/thread.d, set druntime_fiber_asm_external to + # "yes" for targets that have 'version = AsmExternal'. + druntime_fiber_asm_external=no +- case "$target_cpu" in +- aarch64* | \ +- arm* | \ +- i[[34567]]86|x86_64 | \ +- powerpc) +- druntime_fiber_asm_external=yes +- ;; +- esac + if test "$druntime_fiber_asm_external" = no; then + AC_SEARCH_LIBS([swapcontext], [c ucontext], [], + AC_MSG_ERROR([swapcontext required but not found])) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch b/patches/gcc-alpine/0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch new file mode 100644 index 0000000..e1679a8 --- /dev/null +++ b/patches/gcc-alpine/0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch @@ -0,0 +1,25 @@ +From eeec799f43fbd0bfffc13594585b39d708972511 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Tue, 19 Jul 2022 14:54:07 +0200 +Subject: [PATCH 32/35] libgnat: time_t is always 64-bit on musl libc + +--- + gcc/ada/libgnat/s-parame.ads | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/ada/libgnat/s-parame.ads b/gcc/ada/libgnat/s-parame.ads +index 3d6e345a1ba..cfe0b4d3ca6 100644 +--- a/gcc/ada/libgnat/s-parame.ads ++++ b/gcc/ada/libgnat/s-parame.ads +@@ -102,7 +102,7 @@ package System.Parameters is + -- Characteristics of time_t type -- + ------------------------------------ + +- time_t_bits : constant := Long_Integer'Size; ++ time_t_bits : constant := Long_Long_Integer'Size; + -- Number of bits in type time_t + + ---------------------------------------------- +-- +2.41.0 + diff --git a/patches/gcc-alpine/0033-libphobos-do-not-use-LFS64-symbols.patch b/patches/gcc-alpine/0033-libphobos-do-not-use-LFS64-symbols.patch new file mode 100644 index 0000000..138bd64 --- /dev/null +++ b/patches/gcc-alpine/0033-libphobos-do-not-use-LFS64-symbols.patch @@ -0,0 +1,44 @@ +From b71d21b87e6946c763edad5e420bf22d8a453077 Mon Sep 17 00:00:00 2001 +From: psykose +Date: Mon, 29 May 2023 15:33:11 +0000 +Subject: [PATCH 33/35] libphobos: do not use LFS64 symbols + +musl does not have these since 1.2.4, we can't use the compat interfaces. +--- + libphobos/libdruntime/core/sys/posix/config.d | 2 +- + libphobos/libdruntime/core/sys/posix/sys/mman.d | 6 +----- + 2 files changed, 2 insertions(+), 6 deletions(-) + +diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d +index ae6752f220e..6b80d1ff0e6 100644 +--- a/libphobos/libdruntime/core/sys/posix/config.d ++++ b/libphobos/libdruntime/core/sys/posix/config.d +@@ -88,7 +88,7 @@ else version (CRuntime_Musl) + enum __REDIRECT = false; + + // Those three are irrelevant for Musl as it always uses 64 bits off_t +- enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; ++ enum __USE_FILE_OFFSET64 = false; + enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; + enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; + +diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d +index 0d3d517d69a..323aa0af72d 100644 +--- a/libphobos/libdruntime/core/sys/posix/sys/mman.d ++++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d +@@ -293,11 +293,7 @@ else version (CRuntime_Bionic) + } + else version (CRuntime_Musl) + { +- static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t); +- static if (__USE_FILE_OFFSET64) +- alias mmap = mmap64; +- else +- void* mmap(void*, size_t, int, int, int, off_t); ++ void* mmap(void*, size_t, int, int, int, off_t); + int munmap(void*, size_t); + } + else version (CRuntime_UClibc) +-- +2.41.0 + diff --git a/patches/gcc-alpine/0034-libgo-fix-lfs64-use.patch b/patches/gcc-alpine/0034-libgo-fix-lfs64-use.patch new file mode 100644 index 0000000..cf47858 --- /dev/null +++ b/patches/gcc-alpine/0034-libgo-fix-lfs64-use.patch @@ -0,0 +1,195 @@ +From 4bfcb35bc43d3e3b7510620362d7c28d9e4c17ca Mon Sep 17 00:00:00 2001 +From: psykose +Date: Mon, 10 Jul 2023 23:23:29 +0000 +Subject: [PATCH 34/35] libgo: fix lfs64 use + +--- + .../go/internal/syscall/unix/at_largefile.go | 2 +- + libgo/go/os/dir_largefile.go | 2 +- + libgo/go/syscall/libcall_glibc.go | 2 +- + libgo/go/syscall/libcall_linux.go | 4 +-- + libgo/go/syscall/libcall_posix_largefile.go | 26 +++++++++---------- + libgo/runtime/go-varargs.c | 2 +- + libgo/sysinfo.c | 9 +++---- + 7 files changed, 22 insertions(+), 25 deletions(-) + +diff --git a/libgo/go/internal/syscall/unix/at_largefile.go b/libgo/go/internal/syscall/unix/at_largefile.go +index 82e0dcfd074..16151ecad1b 100644 +--- a/libgo/go/internal/syscall/unix/at_largefile.go ++++ b/libgo/go/internal/syscall/unix/at_largefile.go +@@ -10,5 +10,5 @@ import ( + "syscall" + ) + +-//extern fstatat64 ++//extern fstatat + func fstatat(int32, *byte, *syscall.Stat_t, int32) int32 +diff --git a/libgo/go/os/dir_largefile.go b/libgo/go/os/dir_largefile.go +index 1fc5ee0771f..0c6dffe1a75 100644 +--- a/libgo/go/os/dir_largefile.go ++++ b/libgo/go/os/dir_largefile.go +@@ -11,5 +11,5 @@ package os + + import "syscall" + +-//extern readdir64 ++//extern readdir + func libc_readdir(*syscall.DIR) *syscall.Dirent +diff --git a/libgo/go/syscall/libcall_glibc.go b/libgo/go/syscall/libcall_glibc.go +index 5c1ec483c75..5a1245ed44b 100644 +--- a/libgo/go/syscall/libcall_glibc.go ++++ b/libgo/go/syscall/libcall_glibc.go +@@ -114,7 +114,7 @@ func Pipe2(p []int, flags int) (err error) { + } + + //sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) +-//sendfile64(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t ++//sendfile(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t + + func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + if race.Enabled { +diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go +index 03ca7261b59..ad21fd0b3ac 100644 +--- a/libgo/go/syscall/libcall_linux.go ++++ b/libgo/go/syscall/libcall_linux.go +@@ -158,7 +158,7 @@ func Reboot(cmd int) (err error) { + //adjtimex(buf *Timex) _C_int + + //sys Fstatfs(fd int, buf *Statfs_t) (err error) +-//fstatfs64(fd _C_int, buf *Statfs_t) _C_int ++//fstatfs(fd _C_int, buf *Statfs_t) _C_int + + func Gettid() (tid int) { + r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0) +@@ -245,7 +245,7 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i + } + + //sys Statfs(path string, buf *Statfs_t) (err error) +-//statfs64(path *byte, buf *Statfs_t) _C_int ++//statfs(path *byte, buf *Statfs_t) _C_int + + //sysnb Sysinfo(info *Sysinfo_t) (err error) + //sysinfo(info *Sysinfo_t) _C_int +diff --git a/libgo/go/syscall/libcall_posix_largefile.go b/libgo/go/syscall/libcall_posix_largefile.go +index f90055bb29a..334212f0af1 100644 +--- a/libgo/go/syscall/libcall_posix_largefile.go ++++ b/libgo/go/syscall/libcall_posix_largefile.go +@@ -10,40 +10,40 @@ + package syscall + + //sys Creat(path string, mode uint32) (fd int, err error) +-//creat64(path *byte, mode Mode_t) _C_int ++//creat(path *byte, mode Mode_t) _C_int + + //sys Fstat(fd int, stat *Stat_t) (err error) +-//fstat64(fd _C_int, stat *Stat_t) _C_int ++//fstat(fd _C_int, stat *Stat_t) _C_int + + //sys Ftruncate(fd int, length int64) (err error) +-//ftruncate64(fd _C_int, length Offset_t) _C_int ++//ftruncate(fd _C_int, length Offset_t) _C_int + + //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +-//getrlimit64(resource _C_int, rlim *Rlimit) _C_int ++//getrlimit(resource _C_int, rlim *Rlimit) _C_int + + //sys Lstat(path string, stat *Stat_t) (err error) +-//lstat64(path *byte, stat *Stat_t) _C_int ++//lstat(path *byte, stat *Stat_t) _C_int + + //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) +-//mmap64(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte ++//mmap(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte + + //sys Open(path string, mode int, perm uint32) (fd int, err error) +-//__go_open64(path *byte, mode _C_int, perm Mode_t) _C_int ++//__go_open(path *byte, mode _C_int, perm Mode_t) _C_int + + //sys Pread(fd int, p []byte, offset int64) (n int, err error) +-//pread64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t ++//pread(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t + + //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +-//pwrite64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t ++//pwrite(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t + + //sys Seek(fd int, offset int64, whence int) (off int64, err error) +-//lseek64(fd _C_int, offset Offset_t, whence _C_int) Offset_t ++//lseek(fd _C_int, offset Offset_t, whence _C_int) Offset_t + + //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +-//setrlimit64(resource int, rlim *Rlimit) _C_int ++//setrlimit(resource int, rlim *Rlimit) _C_int + + //sys Stat(path string, stat *Stat_t) (err error) +-//stat64(path *byte, stat *Stat_t) _C_int ++//stat(path *byte, stat *Stat_t) _C_int + + //sys Truncate(path string, length int64) (err error) +-//truncate64(path *byte, length Offset_t) _C_int ++//truncate(path *byte, length Offset_t) _C_int +diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c +index f84860891e6..7efc9615985 100644 +--- a/libgo/runtime/go-varargs.c ++++ b/libgo/runtime/go-varargs.c +@@ -84,7 +84,7 @@ __go_ioctl_ptr (int d, int request, void *arg) + int + __go_open64 (char *path, int mode, mode_t perm) + { +- return open64 (path, mode, perm); ++ return open (path, mode, perm); + } + + #endif +diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c +index 180f5c31d74..1d717d55c0e 100644 +--- a/libgo/sysinfo.c ++++ b/libgo/sysinfo.c +@@ -366,7 +366,7 @@ typedef loff_t libgo_loff_t_type; + #endif + + #if defined(HAVE_OFF64_T) +-typedef off64_t libgo_off_t_type; ++typedef off_t libgo_off_t_type; + #else + typedef off_t libgo_off_t_type; + #endif +@@ -398,13 +398,11 @@ typedef off_t libgo_off_t_type; + + // From dirent.h + SREF(dirent); +-SREF(dirent64); + OTREF(DIR); + EREF(DT_UNKNOWN); + + // From fcntl.h + SREF(flock); +-SREF(flock64); + + // From ffi headers + SREF(_ffi_type); +@@ -485,11 +483,10 @@ EREF(SS_ONSTACK); + EREF(SEGV_MAPERR); + + // From stat.h +-SREF(stat64); ++SREF(stat); + + // From statfs.h + SREF(statfs); +-SREF(statfs64); + + // From sysinfo.h + SREF(sysinfo); +@@ -519,7 +516,7 @@ EREF(PTRACE_PEEKTEXT); + + // From sys/resource.h + SREF(rusage); +-SREF(rlimit64); ++SREF(rlimit); + EREF(RLIMIT_NOFILE); + EREF(PRIO_USER); + EREF(RUSAGE_SELF); +-- +2.41.0 + diff --git a/patches/gcc-alpine/0036-PR110792-Early-clobber-issues-with-rot32di2-on-i386.patch b/patches/gcc-alpine/0036-PR110792-Early-clobber-issues-with-rot32di2-on-i386.patch new file mode 100644 index 0000000..e3c09cc --- /dev/null +++ b/patches/gcc-alpine/0036-PR110792-Early-clobber-issues-with-rot32di2-on-i386.patch @@ -0,0 +1,186 @@ +https://gcc.gnu.org/PR110792 +https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=790c1f60a5662b16eb19eb4b81922995863c7571 +https://github.com/randombit/botan/issues/3637 + +From 85628c5653ff40963158a24c60eeec6a3b5a8e56 Mon Sep 17 00:00:00 2001 +From: Roger Sayle +Date: Thu, 3 Aug 2023 07:12:04 +0100 +Subject: [PATCH] PR target/110792: Early clobber issues with + rot32di2_doubleword on i386. + +This patch is a conservative fix for PR target/110792, a wrong-code +regression affecting doubleword rotations by BITS_PER_WORD, which +effectively swaps the highpart and lowpart words, when the source to be +rotated resides in memory. The issue is that if the register used to +hold the lowpart of the destination is mentioned in the address of +the memory operand, the current define_insn_and_split unintentionally +clobbers it before reading the highpart. + +Hence, for the testcase, the incorrectly generated code looks like: + + salq $4, %rdi // calculate address + movq WHIRL_S+8(%rdi), %rdi // accidentally clobber addr + movq WHIRL_S(%rdi), %rbp // load (wrong) lowpart + +Traditionally, the textbook way to fix this would be to add an +explicit early clobber to the instruction's constraints. + + (define_insn_and_split "32di2_doubleword" +- [(set (match_operand:DI 0 "register_operand" "=r,r,r") ++ [(set (match_operand:DI 0 "register_operand" "=r,r,&r") + (any_rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,r,o") + (const_int 32)))] + +but unfortunately this currently generates significantly worse code, +due to a strange choice of reloads (effectively memcpy), which ends up +looking like: + + salq $4, %rdi // calculate address + movdqa WHIRL_S(%rdi), %xmm0 // load the double word in SSE reg. + movaps %xmm0, -16(%rsp) // store the SSE reg back to the stack + movq -8(%rsp), %rdi // load highpart + movq -16(%rsp), %rbp // load lowpart + +Note that reload's "&" doesn't distinguish between the memory being +early clobbered, vs the registers used in an addressing mode being +early clobbered. + +The fix proposed in this patch is to remove the third alternative, that +allowed offsetable memory as an operand, forcing reload to place the +operand into a register before the rotation. This results in: + + salq $4, %rdi + movq WHIRL_S(%rdi), %rax + movq WHIRL_S+8(%rdi), %rdi + movq %rax, %rbp + +I believe there's a more advanced solution, by swapping the order of +the loads (if first destination register is mentioned in the address), +or inserting a lea insn (if both destination registers are mentioned +in the address), but this fix is a minimal "safe" solution, that +should hopefully be suitable for backporting. + +2023-08-03 Roger Sayle + +gcc/ChangeLog + PR target/110792 + * config/i386/i386.md (ti3): For rotations by 64 bits + place operand in a register before gen_64ti2_doubleword. + (di3): Likewise, for rotations by 32 bits, place + operand in a register before gen_32di2_doubleword. + (32di2_doubleword): Constrain operand to be in register. + (64ti2_doubleword): Likewise. + +gcc/testsuite/ChangeLog + PR target/110792 + * g++.target/i386/pr110792.C: New 32-bit C++ test case. + * gcc.target/i386/pr110792.c: New 64-bit C test case. + +(cherry picked from commit 790c1f60a5662b16eb19eb4b81922995863c7571) +--- + gcc/config/i386/i386.md | 18 ++++++++++++------ + gcc/testsuite/g++.target/i386/pr110792.C | 16 ++++++++++++++++ + gcc/testsuite/gcc.target/i386/pr110792.c | 18 ++++++++++++++++++ + 3 files changed, 46 insertions(+), 6 deletions(-) + create mode 100644 gcc/testsuite/g++.target/i386/pr110792.C + create mode 100644 gcc/testsuite/gcc.target/i386/pr110792.c + +diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md +index f3a3305..a71e837 100644 +--- a/gcc/config/i386/i386.md ++++ b/gcc/config/i386/i386.md +@@ -14359,7 +14359,10 @@ + emit_insn (gen_ix86_ti3_doubleword + (operands[0], operands[1], operands[2])); + else if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 64) +- emit_insn (gen_64ti2_doubleword (operands[0], operands[1])); ++ { ++ operands[1] = force_reg (TImode, operands[1]); ++ emit_insn (gen_64ti2_doubleword (operands[0], operands[1])); ++ } + else + { + rtx amount = force_reg (QImode, operands[2]); +@@ -14394,7 +14397,10 @@ + emit_insn (gen_ix86_di3_doubleword + (operands[0], operands[1], operands[2])); + else if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 32) +- emit_insn (gen_32di2_doubleword (operands[0], operands[1])); ++ { ++ operands[1] = force_reg (DImode, operands[1]); ++ emit_insn (gen_32di2_doubleword (operands[0], operands[1])); ++ } + else + FAIL; + +@@ -14562,8 +14568,8 @@ + }) + + (define_insn_and_split "32di2_doubleword" +- [(set (match_operand:DI 0 "register_operand" "=r,r,r") +- (any_rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,r,o") ++ [(set (match_operand:DI 0 "register_operand" "=r,r") ++ (any_rotate:DI (match_operand:DI 1 "register_operand" "0,r") + (const_int 32)))] + "!TARGET_64BIT" + "#" +@@ -14580,8 +14586,8 @@ + }) + + (define_insn_and_split "64ti2_doubleword" +- [(set (match_operand:TI 0 "register_operand" "=r,r,r") +- (any_rotate:TI (match_operand:TI 1 "nonimmediate_operand" "0,r,o") ++ [(set (match_operand:TI 0 "register_operand" "=r,r") ++ (any_rotate:TI (match_operand:TI 1 "register_operand" "0,r") + (const_int 64)))] + "TARGET_64BIT" + "#" +diff --git a/gcc/testsuite/g++.target/i386/pr110792.C b/gcc/testsuite/g++.target/i386/pr110792.C +new file mode 100644 +index 0000000..ce21a7a +--- /dev/null ++++ b/gcc/testsuite/g++.target/i386/pr110792.C +@@ -0,0 +1,16 @@ ++/* { dg-do compile { target ia32 } } */ ++/* { dg-options "-O2" } */ ++ ++template ++inline T rotr(T input) ++{ ++ return static_cast((input >> ROT) | (input << (8 * sizeof(T) - ROT))); ++} ++ ++unsigned long long WHIRL_S[256] = {0x18186018C07830D8}; ++unsigned long long whirl(unsigned char x0) ++{ ++ const unsigned long long s4 = WHIRL_S[x0&0xFF]; ++ return rotr<32>(s4); ++} ++/* { dg-final { scan-assembler-not "movl\tWHIRL_S\\+4\\(,%eax,8\\), %eax" } } */ +diff --git a/gcc/testsuite/gcc.target/i386/pr110792.c b/gcc/testsuite/gcc.target/i386/pr110792.c +new file mode 100644 +index 0000000..b65125c +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/pr110792.c +@@ -0,0 +1,18 @@ ++/* { dg-do compile { target int128 } } */ ++/* { dg-options "-O2" } */ ++ ++static inline unsigned __int128 rotr(unsigned __int128 input) ++{ ++ return ((input >> 64) | (input << (64))); ++} ++ ++unsigned __int128 WHIRL_S[256] = {((__int128)0x18186018C07830D8) << 64 |0x18186018C07830D8}; ++unsigned __int128 whirl(unsigned char x0) ++{ ++ register int t __asm("rdi") = x0&0xFF; ++ const unsigned __int128 s4 = WHIRL_S[t]; ++ register unsigned __int128 tt __asm("rdi") = rotr(s4); ++ asm("":::"memory"); ++ return tt; ++} ++/* { dg-final { scan-assembler-not "movq\tWHIRL_S\\+8\\(%rdi\\), %rdi" } } */ +-- +2.41.0 + diff --git a/patches/gcc-alpine/0037-loongarch-disable-multilib-support.patch b/patches/gcc-alpine/0037-loongarch-disable-multilib-support.patch new file mode 100644 index 0000000..37de3c7 --- /dev/null +++ b/patches/gcc-alpine/0037-loongarch-disable-multilib-support.patch @@ -0,0 +1,61 @@ +From c4f484f465a32e796ae384aa3f90e79fa218b4e9 Mon Sep 17 00:00:00 2001 +From: Jingyun Hua +Date: Mon, 7 Aug 2023 15:25:58 +0800 +Subject: [PATCH] loongarch disable multilib support + +Signed-off-by: Jingyun Hua +--- + gcc/config/loongarch/linux.h | 10 +--------- + gcc/config/loongarch/t-linux | 18 +++--------------- + 3 files changed, 5 insertions(+), 25 deletions(-) + +diff --git a/gcc/config/loongarch/linux.h b/gcc/config/loongarch/linux.h +index 9059d2441..23eaff0cc 100644 +--- a/gcc/config/loongarch/linux.h ++++ b/gcc/config/loongarch/linux.h +@@ -22,15 +22,7 @@ along with GCC; see the file COPYING3. If not see + * can work in a multilib environment. */ + + #if defined(LA_DISABLE_MULTILIB) && defined(LA_DISABLE_MULTIARCH) +- +- #if DEFAULT_ABI_BASE == ABI_BASE_LP64D +- #define ABI_LIBDIR "lib64" +- #elif DEFAULT_ABI_BASE == ABI_BASE_LP64F +- #define ABI_LIBDIR "lib64/f32" +- #elif DEFAULT_ABI_BASE == ABI_BASE_LP64S +- #define ABI_LIBDIR "lib64/sf" +- #endif +- ++ #define ABI_LIBDIR "lib" + #endif + + #ifndef ABI_LIBDIR +diff --git a/gcc/config/loongarch/t-linux b/gcc/config/loongarch/t-linux +index e40da1792..f72c6e878 100644 +--- a/gcc/config/loongarch/t-linux ++++ b/gcc/config/loongarch/t-linux +@@ -36,18 +36,6 @@ else + endif + + # Don't define MULTILIB_OSDIRNAMES if multilib is disabled. +-ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),) +- +- MULTILIB_OSDIRNAMES = \ +- mabi.lp64d=../lib64$\ +- $(call if_multiarch,:loongarch64-linux-gnu) +- +- MULTILIB_OSDIRNAMES += \ +- mabi.lp64f=../lib64/f32$\ +- $(call if_multiarch,:loongarch64-linux-gnuf32) +- +- MULTILIB_OSDIRNAMES += \ +- mabi.lp64s=../lib64/sf$\ +- $(call if_multiarch,:loongarch64-linux-gnusf) +- +-endif ++ MULTILIB_OSDIRNAMES = mabi.lp64d=../lib ++ MULTILIB_OSDIRNAMES += mabi.lp64f=../lib ++ MULTILIB_OSDIRNAMES += mabi.lp64s=../lib +-- +2.41.0 + diff --git a/patches/gcc-chimera/clang-tree-vect.patch b/patches/gcc-chimera/clang-tree-vect.patch new file mode 100755 index 0000000..0767145 --- /dev/null +++ b/patches/gcc-chimera/clang-tree-vect.patch @@ -0,0 +1,21 @@ +https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239266 reports how +clang unfortunately poisons user namespace by default (without any +special options). + +Until that changes (or GCC changes) we need to avoid using vec_step +as a variable. + +--- UTC +Index: gcc/tree-vect-loop.cc +=================================================================== +--- a/gcc/tree-vect-loop.cc (revision 273856) ++++ b/gcc/tree-vect-loop.cc (working copy) +@@ -55,6 +55,8 @@ along with GCC; see the file COPYING3. If not see + #include "vec-perm-indices.h" + #include "tree-eh.h" + ++#define vec_step vec_step_ ++ + /* Loop Vectorization Pass. + + This pass tries to vectorize loops. diff --git a/patches/gcc-chimera/clang17.patch b/patches/gcc-chimera/clang17.patch new file mode 100755 index 0000000..af6c286 --- /dev/null +++ b/patches/gcc-chimera/clang17.patch @@ -0,0 +1,134 @@ +https://bugs.gentoo.org/912035 +https://inbox.sourceware.org/gcc-patches/0623E896-6B99-49EC-9144-B41BC51089F0@andric.com +https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274038 +https://gcc.gnu.org/PR111632 + +commit 8992952bfa95e769a554bd97581cf332987383d8 +Author: Dimitry Andric +Date: 2023-09-28T17:40:29+02:00 + + Include safe-ctype.h after C++ standard headers, to avoid over-poisoning + + When building gcc's C++ sources against recent libc++, the poisoning of + the ctype macros due to including safe-ctype.h before including C++ + standard headers such as , , etc, causes many compilation + errors, similar to: + + In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23: + In file included from /home/dim/src/gcc/master/gcc/system.h:233: + In file included from /usr/include/c++/v1/vector:321: + In file included from + /usr/include/c++/v1/__format/formatter_bool.h:20: + In file included from + /usr/include/c++/v1/__format/formatter_integral.h:32: + In file included from /usr/include/c++/v1/locale:202: + /usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute + only applies to structs, variables, functions, and namespaces + 546 | _LIBCPP_INLINE_VISIBILITY + | ^ + /usr/include/c++/v1/__config:813:37: note: expanded from macro + '_LIBCPP_INLINE_VISIBILITY' + 813 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI + | ^ + /usr/include/c++/v1/__config:792:26: note: expanded from macro + '_LIBCPP_HIDE_FROM_ABI' + 792 | + __attribute__((__abi_tag__(_LIBCPP_TOSTRING( + _LIBCPP_VERSIONED_IDENTIFIER)))) + | ^ + In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23: + In file included from /home/dim/src/gcc/master/gcc/system.h:233: + In file included from /usr/include/c++/v1/vector:321: + In file included from + /usr/include/c++/v1/__format/formatter_bool.h:20: + In file included from + /usr/include/c++/v1/__format/formatter_integral.h:32: + In file included from /usr/include/c++/v1/locale:202: + /usr/include/c++/v1/__locale:547:37: error: expected ';' at end of + declaration list + 547 | char_type toupper(char_type __c) const + | ^ + /usr/include/c++/v1/__locale:553:48: error: too many arguments + provided to function-like macro invocation + 553 | const char_type* toupper(char_type* __low, const + char_type* __high) const + | ^ + /home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note: + macro 'toupper' defined here + 146 | #define toupper(c) do_not_use_toupper_with_safe_ctype + | ^ + + This is because libc++ uses different transitive includes than + libstdc++, and some of those transitive includes pull in various ctype + declarations (typically via ). + + There was already a special case for including before + safe-ctype.h, so move the rest of the C++ standard header includes to + the same location, to fix the problem. + + Signed-off-by: Dimitry Andric + +diff --git a/gcc/system.h b/gcc/system.h +index e924152ad4c..7a516b11438 100644 +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -194,27 +194,8 @@ extern int fprintf_unlocked (FILE *, const char *, ...); + #undef fread_unlocked + #undef fwrite_unlocked + +-/* Include before "safe-ctype.h" to avoid GCC poisoning +- the ctype macros through safe-ctype.h */ +- +-#ifdef __cplusplus +-#ifdef INCLUDE_STRING +-# include +-#endif +-#endif +- +-/* There are an extraordinary number of issues with . +- The last straw is that it varies with the locale. Use libiberty's +- replacement instead. */ +-#include "safe-ctype.h" +- +-#include +- +-#include +- +-#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO +-extern int errno; +-#endif ++/* Include C++ standard headers before "safe-ctype.h" to avoid GCC ++ poisoning the ctype macros through safe-ctype.h */ + + #ifdef __cplusplus + #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY) +@@ -229,6 +210,9 @@ extern int errno; + #ifdef INCLUDE_SET + # include + #endif ++#ifdef INCLUDE_STRING ++# include ++#endif + #ifdef INCLUDE_VECTOR + # include + #endif +@@ -245,6 +229,19 @@ extern int errno; + # include + #endif + ++/* There are an extraordinary number of issues with . ++ The last straw is that it varies with the locale. Use libiberty's ++ replacement instead. */ ++#include "safe-ctype.h" ++ ++#include ++ ++#include ++ ++#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO ++extern int errno; ++#endif ++ + /* Some of glibc's string inlines cause warnings. Plus we'd rather + rely on (and therefore test) GCC's string builtins. */ + #define __NO_STRING_INLINES diff --git a/patches/kmod-chimera/musl-basename.patch b/patches/kmod-chimera/musl-basename.patch new file mode 100644 index 0000000..d979b27 --- /dev/null +++ b/patches/kmod-chimera/musl-basename.patch @@ -0,0 +1,65 @@ +diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c +index e83621b..353543c 100644 +--- a/libkmod/libkmod-config.c ++++ b/libkmod/libkmod-config.c +@@ -35,6 +35,8 @@ + #include "libkmod.h" + #include "libkmod-internal.h" + ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++ + struct kmod_alias { + char *name; + char modname[]; +diff --git a/shared/util.c b/shared/util.c +index e2bab83..4293d18 100644 +--- a/shared/util.c ++++ b/shared/util.c +@@ -35,6 +35,8 @@ + #define USEC_PER_SEC 1000000ULL + #define NSEC_PER_USEC 1000ULL + ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++ + static const struct kmod_ext { + const char *ext; + size_t len; +diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c +index 318343a..f2586e1 100644 +--- a/testsuite/testsuite.c ++++ b/testsuite/testsuite.c +@@ -36,6 +36,8 @@ + + #include "testsuite.h" + ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++ + static const char *ANSI_HIGHLIGHT_GREEN_ON = "\x1B[1;32m"; + static const char *ANSI_HIGHLIGHT_YELLOW_ON = "\x1B[1;33m"; + static const char *ANSI_HIGHLIGHT_RED_ON = "\x1B[1;31m"; +diff --git a/tools/depmod.c b/tools/depmod.c +index 43fc354..8d955ec 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -45,6 +45,8 @@ + + #include "kmod.h" + ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++ + #define DEFAULT_VERBOSE LOG_WARNING + static int verbose = DEFAULT_VERBOSE; + +diff --git a/tools/kmod.c b/tools/kmod.c +index 1015575..a50d628 100644 +--- a/tools/kmod.c ++++ b/tools/kmod.c +@@ -29,6 +29,8 @@ + + #include "kmod.h" + ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++ + static const char options_s[] = "+hV"; + static const struct option options[] = { + { "help", no_argument, NULL, 'h' }, diff --git a/patches/kmod-chimera/no-gtkdoc.patch b/patches/kmod-chimera/no-gtkdoc.patch new file mode 100644 index 0000000..9e008e7 --- /dev/null +++ b/patches/kmod-chimera/no-gtkdoc.patch @@ -0,0 +1,28 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -226,10 +226,7 @@ AS_IF([test "x$enable_coverage" = "xyes"], [ + ]) + AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"]) + +-m4_ifdef([GTK_DOC_CHECK], [ +-GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat]) +-], [ +-AM_CONDITIONAL([ENABLE_GTK_DOC], false)]) ++AM_CONDITIONAL([ENABLE_GTK_DOC], false) + + ##################################################################### + # Default CFLAGS and LDFLAGS +--- a/libkmod/docs/Makefile.am ++++ b/libkmod/docs/Makefile.am +@@ -25,10 +25,4 @@ IGNORE_HFILES = libkmod-internal.h \ + + content_files = version.xml + +-EXTRA_DIST = +- +-if ENABLE_GTK_DOC +-include $(top_srcdir)/libkmod/docs/gtk-doc.make +-else +-EXTRA_DIST += libkmod-docs.xml libkmod-sections.txt +-endif ++EXTRA_DIST = libkmod-docs.xml libkmod-sections.txt diff --git a/patches/llvm-17.0.6-chimera/libcpp-pointer-traits-sfinae.patch b/patches/llvm-17.0.6-chimera/libcpp-pointer-traits-sfinae.patch new file mode 100644 index 0000000..4c33395 --- /dev/null +++ b/patches/llvm-17.0.6-chimera/libcpp-pointer-traits-sfinae.patch @@ -0,0 +1,74 @@ +Patch-Source: https://github.com/llvm/llvm-project/commit/078651b6de4b767b91e3e6a51e5df11a06d7bc4f +chromium 121 needs this +-- +From 078651b6de4b767b91e3e6a51e5df11a06d7bc4f Mon Sep 17 00:00:00 2001 +From: Daniel Cheng +Date: Mon, 18 Sep 2023 05:46:59 -0700 +Subject: [PATCH] [libc++] Implement LWG3545: std::pointer_traits should be + SFINAE-friendly. (#65177) + +See https://wg21.link/LWG3545 for background and details. + +Differential Revision: https://reviews.llvm.org/D158922 +--- + libcxx/docs/Status/Cxx23Issues.csv | 2 +- + libcxx/include/__memory/pointer_traits.h | 17 +- + .../contiguous_iterator.verify.cpp | 54 ---- + ...to_address_without_pointer_traits.pass.cpp | 66 ++++ + .../pointer.traits/difference_type.pass.cpp | 28 -- + .../pointer.traits/element_type.pass.cpp | 28 -- + .../memory/pointer.traits/pointer.pass.cpp | 35 --- + .../memory/pointer.traits/rebind.pass.cpp | 32 -- + .../pointer.traits/types.compile.pass.cpp | 289 ++++++++++++++++++ + 9 files changed, 367 insertions(+), 184 deletions(-) + delete mode 100644 libcxx/test/libcxx/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.verify.cpp + create mode 100644 libcxx/test/std/utilities/memory/pointer.conversion/to_address_without_pointer_traits.pass.cpp + delete mode 100644 libcxx/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp + delete mode 100644 libcxx/test/std/utilities/memory/pointer.traits/element_type.pass.cpp + delete mode 100644 libcxx/test/std/utilities/memory/pointer.traits/pointer.pass.cpp + delete mode 100644 libcxx/test/std/utilities/memory/pointer.traits/rebind.pass.cpp + create mode 100644 libcxx/test/std/utilities/memory/pointer.traits/types.compile.pass.cpp + +diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h +index c33e7bd43f29f7d..7617948ed76bd66 100644 +--- a/libcxx/include/__memory/pointer_traits.h ++++ b/libcxx/include/__memory/pointer_traits.h +@@ -35,7 +35,7 @@ template + struct __has_element_type<_Tp, __void_t > : true_type {}; + + template ::value> +-struct __pointer_traits_element_type; ++struct __pointer_traits_element_type {}; + + template + struct __pointer_traits_element_type<_Ptr, true> +@@ -111,12 +111,14 @@ struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> + typedef _Sp<_Up, _Args...> type; + }; + ++template ++struct __pointer_traits_impl {}; ++ + template +-struct _LIBCPP_TEMPLATE_VIS pointer_traits +-{ +- typedef _Ptr pointer; +- typedef typename __pointer_traits_element_type::type element_type; +- typedef typename __pointer_traits_difference_type::type difference_type; ++struct __pointer_traits_impl<_Ptr, __void_t::type> > { ++ typedef _Ptr pointer; ++ typedef typename __pointer_traits_element_type::type element_type; ++ typedef typename __pointer_traits_difference_type::type difference_type; + + #ifndef _LIBCPP_CXX03_LANG + template using rebind = typename __pointer_traits_rebind::type; +@@ -133,6 +135,9 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits + {return pointer::pointer_to(__r);} + }; + ++template ++struct _LIBCPP_TEMPLATE_VIS pointer_traits : __pointer_traits_impl<_Ptr> {}; ++ + template + struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> + { diff --git a/patches/llvm-17.0.6-chimera/stdc-predef-preinclude.patch b/patches/llvm-17.0.6-chimera/stdc-predef-preinclude.patch new file mode 100644 index 0000000..8d773ac --- /dev/null +++ b/patches/llvm-17.0.6-chimera/stdc-predef-preinclude.patch @@ -0,0 +1,32 @@ +commit e0a2ae9501aaea74a5d631bdd98e9643d15e7528 +Author: q66 +Date: Sun Jan 14 18:31:07 2024 +0100 + + clang: implicitly include stdc-predef.h + + This behavior is required to match gcc and get default access + to some macros to get rid of certain hacks (especially on musl, + which does not explicitly include this - glibc includes it from + features.h) + + Inspired by https://reviews.llvm.org/D137043 but this should not + be tied to libc choice, as gcc unconditionally does the preinclude + for both. + +diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp +index 1ba222b..3381fff 100644 +--- a/clang/lib/Driver/ToolChains/Linux.cpp ++++ b/clang/lib/Driver/ToolChains/Linux.cpp +@@ -668,6 +668,12 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, + + if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl()) + addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude); ++ ++ // Follow gcc in pre-including stdc-predef.h in non-freestanding mode ++ if (!DriverArgs.hasArg(options::OPT_ffreestanding)) { ++ CC1Args.push_back("-include"); ++ CC1Args.push_back("stdc-predef.h"); ++ } + } + + void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, diff --git a/patches/llvm-17.0.6-chimera/string-sso-constant.patch b/patches/llvm-17.0.6-chimera/string-sso-constant.patch new file mode 100644 index 0000000..f32f780 --- /dev/null +++ b/patches/llvm-17.0.6-chimera/string-sso-constant.patch @@ -0,0 +1,592 @@ +Patch-Source: https://github.com/llvm/llvm-project/pull/66576 +-- +From 209a8f9c06a7633737e9f022bc4e61d580ad95e7 Mon Sep 17 00:00:00 2001 +From: James Y Knight +Date: Sat, 16 Sep 2023 12:32:21 +0000 +Subject: [PATCH 1/6] [libcxx] Allow string to use SSO in constant evaluation. + +Previously, libcxx forced all strings created during constant +evaluation to point to allocated memory. That was apparently done due +to implementation difficultites, but it turns out not to be necessary: +this patch shows that it is feasible to use SSO strings during +constant evaluation. It also simplifies the implementation. + +However, I'm not convinced that this is a good idea. + +It is currently an error in C++ for a pointer created during +constant-evaluation-time to attempt to escape into the binary and +become runtime-allocated memory. Thus, the existing string +implementation has the property that NO constant-evaluation-created +string object can escape to runtime. It is always an error. On the +other hand, once we permit SSO strings at constant-evaluation-time, +then "short enough" strings will be permitted to escape to runtime, +while longer strings will produce an error. + +Thus, whether code will successfully compile now depends on whether +the text is smaller than the SSO capacity. Given that the maximum SSO +string length is an unspecified internal implementation detail which +differs between implementations or platforms, having it become an +important part of the API seems unfortunate. + +It is a new way to inadvertently write non-portable code, and to write +difficult-to-modify code. If you depend on constexpr string +initialization for a string that initially fits, it may be tricky to +later modify your code to no longer depend on constexpr string +initialization when it turns out you need a slightly longer string, or +to port the code to a different implementation. + +That said, the other implementations already permit this, and don't +seem to have any inclination to change. So, perhaps it's best to just +follow suit. Currently, libstdc++ and MSVC allow constant-initialized +strings to escape to runtime if they're 15 bytes or less (excluding +the trailing NUL) -- except that libstdc++ does allow it for +function-locals, only globals. With this patch, libc++ will permit +such strings up to 22 bytes on 64-bit platforms, and up to 10 bytes on +32-bit platforms. +--- + libcxx/include/string | 54 ++++++++++++------------------------------- + 1 file changed, 15 insertions(+), 39 deletions(-) + +diff --git a/libcxx/include/string b/libcxx/include/string +index 4b96273698166d..349c892b9243dd 100644 +--- a/libcxx/include/string ++++ b/libcxx/include/string +@@ -830,8 +830,8 @@ private: + { + union + { +- __long __l; + __short __s; ++ __long __l; + __raw __r; + }; + }; +@@ -1729,8 +1729,10 @@ private: + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 + bool __is_long() const _NOEXCEPT { +- if (__libcpp_is_constant_evaluated()) +- return true; ++ if (__libcpp_is_constant_evaluated()) { ++ if (__builtin_constant_p(__r_.first().__l.__is_long_)) ++ return __r_.first().__l.__is_long_; ++ } + return __r_.first().__s.__is_long_; + } + +@@ -1748,24 +1750,11 @@ private: + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() { + __r_.first() = __rep(); +- if (__libcpp_is_constant_evaluated()) { +- size_type __sz = __recommend(0) + 1; +- pointer __ptr = __alloc_traits::allocate(__alloc(), __sz); +- __begin_lifetime(__ptr, __sz); +- __set_long_pointer(__ptr); +- __set_long_cap(__sz); +- __set_long_size(0); +- } +- } +- +- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __deallocate_constexpr() { +- if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr) +- __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap()); + } + + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { + // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly +- return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); ++ return (__sz < __min_cap); + } + + template +@@ -1877,10 +1866,7 @@ private: + size_type __recommend(size_type __s) _NOEXCEPT + { + if (__s < __min_cap) { +- if (__libcpp_is_constant_evaluated()) +- return static_cast(__min_cap); +- else +- return static_cast(__min_cap) - 1; ++ return static_cast(__min_cap) - 1; + } + size_type __guess = __align_it (__s+1) - 1; +@@ -1969,7 +1955,8 @@ private: + allocator_type __a = __str.__alloc(); + auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); + __begin_lifetime(__allocation.ptr, __allocation.count); +- __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); ++ if (__is_long()) ++ __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); + __alloc() = std::move(__a); + __set_long_pointer(__allocation.ptr); + __set_long_cap(__allocation.count); +@@ -2020,7 +2007,7 @@ private: + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s, size_type __n); + + // Assigns the value in __s, guaranteed to be __n < __min_cap in length. +- inline basic_string& __assign_short(const value_type* __s, size_type __n) { ++ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_short(const value_type* __s, size_type __n) { + pointer __p = __is_long() + ? (__set_long_size(__n), __get_long_pointer()) + : (__set_short_size(__n), __get_short_pointer()); +@@ -2334,7 +2321,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace + if (__sec_cp_sz != 0) + traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, + std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); +- if (__old_cap+1 != __min_cap || __libcpp_is_constant_evaluated()) ++ if (__old_cap+1 != __min_cap) + __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); +@@ -2374,7 +2361,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t + traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, + std::__to_address(__old_p) + __n_copy + __n_del, + __sec_cp_sz); +- if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap) ++ if (__old_cap + 1 != __min_cap) + __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); +@@ -2537,12 +2524,8 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr + } + __move_assign_alloc(__str); + __r_.first() = __str.__r_.first(); +- if (__libcpp_is_constant_evaluated()) { +- __str.__default_init(); +- } else { +- __str.__set_short_size(0); +- traits_type::assign(__str.__get_short_pointer()[0], value_type()); +- } ++ __str.__set_short_size(0); ++ traits_type::assign(__str.__get_short_pointer()[0], value_type()); + } + + #endif +@@ -2828,13 +2811,6 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t + if (__pos > __sz) + __throw_out_of_range(); + size_type __cap = capacity(); +- if (__libcpp_is_constant_evaluated()) { +- if (__cap - __sz >= __n) +- __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s); +- else +- __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); +- return *this; +- } + if (__cap - __sz >= __n) + { + if (__n) +@@ -2843,7 +2819,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t + size_type __n_move = __sz - __pos; + if (__n_move != 0) + { +- if (__p + __pos <= __s && __s < __p + __sz) ++ if (std::__is_pointer_in_range(__p + __pos, __p + __sz, __s)) + __s += __n; + traits_type::move(__p + __pos + __n, __p + __pos, __n_move); + } + +From e198d3699334aa0534b71a949a1c8e56f3c65caa Mon Sep 17 00:00:00 2001 +From: James Y Knight +Date: Mon, 18 Sep 2023 13:22:24 +0000 +Subject: [PATCH 2/6] Address review comments. + +--- + libcxx/include/string | 24 +++++++++--------------- + 1 file changed, 9 insertions(+), 15 deletions(-) + +diff --git a/libcxx/include/string b/libcxx/include/string +index 349c892b9243dd..fb943ecc1fc3aa 100644 +--- a/libcxx/include/string ++++ b/libcxx/include/string +@@ -880,7 +880,7 @@ public: + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() + _NOEXCEPT_(is_nothrow_default_constructible::value) + : __r_(__default_init_tag(), __default_init_tag()) { +- __default_init(); ++ __r_.first() = __rep(); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a) +@@ -890,7 +890,7 @@ public: + _NOEXCEPT + #endif + : __r_(__default_init_tag(), __a) { +- __default_init(); ++ __r_.first() = __rep(); + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str) +@@ -917,7 +917,7 @@ public: + _NOEXCEPT + # endif + : __r_(std::move(__str.__r_)) { +- __str.__default_init(); ++ __str.__r_.first() = __rep(); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a) +@@ -928,7 +928,7 @@ public: + if (__libcpp_is_constant_evaluated()) + __r_.first() = __rep(); + __r_.first() = __str.__r_.first(); +- __str.__default_init(); ++ __str.__r_.first() = __rep(); + } + } + #endif // _LIBCPP_CXX03_LANG +@@ -984,7 +984,7 @@ public: + auto __len = std::min(__n, __str.size() - __pos); + if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) { + __r_.first() = __str.__r_.first(); +- __str.__default_init(); ++ __str.__r_.first() = __rep(); + + _Traits::move(data(), data() + __pos, __len); + __set_size(__len); +@@ -1729,9 +1729,8 @@ private: + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 + bool __is_long() const _NOEXCEPT { +- if (__libcpp_is_constant_evaluated()) { +- if (__builtin_constant_p(__r_.first().__l.__is_long_)) +- return __r_.first().__l.__is_long_; ++ if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__r_.first().__l.__is_long_)) { ++ return __r_.first().__l.__is_long_; + } + return __r_.first().__s.__is_long_; + } +@@ -1748,12 +1747,7 @@ private: + #endif // _LIBCPP_STD_VER >= 20 + } + +- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() { +- __r_.first() = __rep(); +- } +- + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { +- // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly + return (__sz < __min_cap); + } + +@@ -2221,7 +2215,7 @@ template + template + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 + void basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) { +- __default_init(); ++ __r_.first() = __rep(); + + #ifndef _LIBCPP_HAS_NO_EXCEPTIONS + try +@@ -3842,7 +3836,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT + if(__is_long()) + { + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); +- __default_init(); ++ __r_.first() = __rep(); + } + } + + +From 829978bbb01c2dbb2334a14795f17f1655e41e03 Mon Sep 17 00:00:00 2001 +From: James Y Knight +Date: Mon, 25 Sep 2023 16:36:26 +0000 +Subject: [PATCH 3/6] Add test, address comment, add doc note. + +--- + libcxx/docs/UsingLibcxx.rst | 24 +++++++++++++++++++ + libcxx/include/string | 2 +- + .../constinit_sso_string.compile.pass.cpp | 22 +++++++++++++++++ + 3 files changed, 47 insertions(+), 1 deletion(-) + create mode 100644 libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp + +diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst +index 0b517c0f8f7860..cd3dc9bfff5c93 100644 +--- a/libcxx/docs/UsingLibcxx.rst ++++ b/libcxx/docs/UsingLibcxx.rst +@@ -545,6 +545,30 @@ Extensions to the C++23 modules ``std`` and ``std.compat`` + Like other major implementations, libc++ provides C++23 modules ``std`` and + ``std.compat`` in C++20 as an extension" + ++Constant-initialized std::string ++-------------------------------- ++ ++As an implementation-specific optimization, ``std::basic_string`` (``std::string``, ++``std::wstring``, etc.) may either store the string data directly in the object, or else store a ++pointer to heap-allocated memory, depending on the length of the string. ++ ++As of C++20, the constructors are now declared ``constexpr``, which permits strings to be used ++during constant-evaluation time. In libc++, as in other common implementations, it is also possible ++to constant-initialize a string object (e.g. via declaring a variable with ``constinit`` or ++``constexpr``), but, only if the string is short enough to not require a heap allocation. Reliance ++upon this should be discouraged in portable code, as the allowed length differs based on the ++standard-library implementation and also based on whether the platform uses 32-bit or 64-bit ++pointers. ++ ++.. code-block:: cpp ++ ++ // Non-portable: 11-char string works on 64-bit libc++, but not on 32-bit. ++ constinit std::string x = "hello world"; ++ ++ // Prefer to use string_view, or remove constinit/constexpr from the variable definition: ++ constinit std::string_view x = "hello world"; ++ std::string_view y = "hello world"; ++ + .. _turning-off-asan: + + Turning off ASan annotation in containers +diff --git a/libcxx/include/string b/libcxx/include/string +index fb943ecc1fc3aa..5a922f281f1f24 100644 +--- a/libcxx/include/string ++++ b/libcxx/include/string +@@ -1748,7 +1748,7 @@ private: + } + + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { +- return (__sz < __min_cap); ++ return __sz < __min_cap; + } + + template +diff --git a/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp +new file mode 100644 +index 00000000000000..9caf298c05177b +--- /dev/null ++++ b/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp +@@ -0,0 +1,22 @@ ++//===----------------------------------------------------------------------===// ++// ++// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ++// See https://llvm.org/LICENSE.txt for license information. ++// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ++// ++//===----------------------------------------------------------------------===// ++ ++// UNSUPPORTED: c++03, c++11, c++14, c++17 ++ ++// Ensure that strings which fit within the SSO size can be constant-initialized ++// globals. (this is permitted but not required to work by the standard). ++ ++#include ++ ++#if __SIZE_WIDTH__ == 64 ++constinit std::string my_str = "0123456789012345678901"; ++#elif __SIZE_WIDTH__ == 32 ++constinit std::string my_str = "0123456789"; ++#else ++# error "std::size_t has an unexpected size" ++#endif + +From 9d179b43ad62c2d66d7bd0f9588147c6141a54c1 Mon Sep 17 00:00:00 2001 +From: James Y Knight +Date: Tue, 26 Sep 2023 17:06:39 +0000 +Subject: [PATCH 4/6] Address value_init_tag comment + +--- + libcxx/include/string | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/libcxx/include/string b/libcxx/include/string +index 5a922f281f1f24..33e87406a1156a 100644 +--- a/libcxx/include/string ++++ b/libcxx/include/string +@@ -879,9 +879,7 @@ public: + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() + _NOEXCEPT_(is_nothrow_default_constructible::value) +- : __r_(__default_init_tag(), __default_init_tag()) { +- __r_.first() = __rep(); +- } ++ : __r_(__value_init_tag(), __default_init_tag()) {} + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a) + #if _LIBCPP_STD_VER <= 14 +@@ -889,9 +887,7 @@ public: + #else + _NOEXCEPT + #endif +- : __r_(__default_init_tag(), __a) { +- __r_.first() = __rep(); +- } ++ : __r_(__value_init_tag(), __a) {} + + _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str) + : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { + +From db9f3b84e91a948ff0c5d9a7b7a058b61cdbe9e9 Mon Sep 17 00:00:00 2001 +From: James Y Knight +Date: Fri, 6 Oct 2023 22:26:09 +0000 +Subject: [PATCH 5/6] Tweak test per review comments. + +--- + .../string.cons/constinit_sso_string.compile.pass.cpp | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp +index 9caf298c05177b..5c0114c02970e6 100644 +--- a/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp ++++ b/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp +@@ -9,14 +9,19 @@ + // UNSUPPORTED: c++03, c++11, c++14, c++17 + + // Ensure that strings which fit within the SSO size can be constant-initialized +-// globals. (this is permitted but not required to work by the standard). ++// as both a global and local. + + #include + + #if __SIZE_WIDTH__ == 64 +-constinit std::string my_str = "0123456789012345678901"; ++#define LONGEST_STR "0123456789012345678901" + #elif __SIZE_WIDTH__ == 32 +-constinit std::string my_str = "0123456789"; ++#define LONGEST_STR "0123456789" + #else + # error "std::size_t has an unexpected size" + #endif ++ ++constinit std::string g_str = LONGEST_STR; ++void fn() { ++ constexpr std::string l_str = LONGEST_STR; ++} + +From 98ca35e17520376b367f283a696868b986405a05 Mon Sep 17 00:00:00 2001 +From: James Y Knight +Date: Sun, 8 Oct 2023 23:29:42 +0000 +Subject: [PATCH 6/6] Split off wchar bitset::to_string tests to avoid + constexpr evaluation limit. + +--- + .../bitset.members/to_string.pass.cpp | 78 ++++++++++++------- + 1 file changed, 51 insertions(+), 27 deletions(-) + +diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp +index 78c58f678e7960..809de12d45dbac 100644 +--- a/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp ++++ b/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp +@@ -47,16 +47,6 @@ TEST_CONSTEXPR_CXX23 bool test_to_string() { + std::vector > const cases = get_test_cases(); + for (std::size_t c = 0; c != cases.size(); ++c) { + std::bitset const v = cases[c]; +-#ifndef TEST_HAS_NO_WIDE_CHARACTERS +- { +- std::wstring s = v.template to_string, std::allocator >(); +- check_equal(s, v, L'0', L'1'); +- } +- { +- std::wstring s = v.template to_string >(); +- check_equal(s, v, L'0', L'1'); +- } +-#endif + { + std::string s = v.template to_string(); + check_equal(s, v, '0', '1'); +@@ -65,49 +55,64 @@ TEST_CONSTEXPR_CXX23 bool test_to_string() { + std::string s = v.to_string(); + check_equal(s, v, '0', '1'); + } +-#ifndef TEST_HAS_NO_WIDE_CHARACTERS + { +- std::wstring s = v.template to_string, std::allocator >('0'); +- check_equal(s, v, L'0', L'1'); ++ std::string s = v.template to_string('0'); ++ check_equal(s, v, '0', '1'); + } + { +- std::wstring s = v.template to_string >('0'); +- check_equal(s, v, L'0', L'1'); ++ std::string s = v.to_string('0'); ++ check_equal(s, v, '0', '1'); + } +-#endif + { +- std::string s = v.template to_string('0'); ++ std::string s = v.template to_string('0', '1'); + check_equal(s, v, '0', '1'); + } + { +- std::string s = v.to_string('0'); ++ std::string s = v.to_string('0', '1'); + check_equal(s, v, '0', '1'); + } ++ { ++ std::string s = v.to_string('x', 'y'); ++ check_equal(s, v, 'x', 'y'); ++ } ++ } ++ return true; ++} ++ + #ifndef TEST_HAS_NO_WIDE_CHARACTERS ++template ++TEST_CONSTEXPR_CXX23 bool test_to_string_wchar() { ++ std::vector > const cases = get_test_cases(); ++ for (std::size_t c = 0; c != cases.size(); ++c) { ++ std::bitset const v = cases[c]; + { +- std::wstring s = v.template to_string, std::allocator >('0', '1'); ++ std::wstring s = v.template to_string, std::allocator >(); + check_equal(s, v, L'0', L'1'); + } + { +- std::wstring s = v.template to_string >('0', '1'); ++ std::wstring s = v.template to_string >(); + check_equal(s, v, L'0', L'1'); + } +-#endif + { +- std::string s = v.template to_string('0', '1'); +- check_equal(s, v, '0', '1'); ++ std::wstring s = v.template to_string, std::allocator >('0'); ++ check_equal(s, v, L'0', L'1'); + } + { +- std::string s = v.to_string('0', '1'); +- check_equal(s, v, '0', '1'); ++ std::wstring s = v.template to_string >('0'); ++ check_equal(s, v, L'0', L'1'); + } + { +- std::string s = v.to_string('x', 'y'); +- check_equal(s, v, 'x', 'y'); ++ std::wstring s = v.template to_string, std::allocator >('0', '1'); ++ check_equal(s, v, L'0', L'1'); ++ } ++ { ++ std::wstring s = v.template to_string >('0', '1'); ++ check_equal(s, v, L'0', L'1'); + } + } + return true; + } ++#endif + + int main(int, char**) { + test_to_string<0>(); +@@ -130,5 +135,24 @@ int main(int, char**) { + static_assert(test_to_string<65>()); + #endif + ++#ifndef TEST_HAS_NO_WIDE_CHARACTERS ++ test_to_string_wchar<0>(); ++ test_to_string_wchar<1>(); ++ test_to_string_wchar<31>(); ++ test_to_string_wchar<32>(); ++ test_to_string_wchar<33>(); ++ test_to_string_wchar<63>(); ++ test_to_string_wchar<64>(); ++ test_to_string_wchar<65>(); ++ test_to_string_wchar<1000>(); // not in constexpr because of constexpr evaluation step limits ++#if TEST_STD_VER > 20 ++ static_assert(test_to_string_wchar<0>()); ++ static_assert(test_to_string_wchar<1>()); ++ static_assert(test_to_string_wchar<31>()); ++ static_assert(test_to_string_wchar<32>()); ++ static_assert(test_to_string_wchar<33>()); ++ static_assert(test_to_string_wchar<63>()); ++#endif ++#endif + return 0; + } diff --git a/patches/llvm-cmlfs/modify-clang-config-header.patch b/patches/llvm-cmlfs/modify-clang-config-header.patch new file mode 100644 index 0000000..97abf49 --- /dev/null +++ b/patches/llvm-cmlfs/modify-clang-config-header.patch @@ -0,0 +1,11 @@ +--- /llvmtools/include/clang/Config/config.h.orig 2024-04-25 19:29:34.469253648 +0000 ++++ /llvmtools/include/clang/Config/config.h 2024-04-25 19:29:46.908252957 +0000 +@@ -46,7 +46,7 @@ + /* #undef CLANG_CONFIG_FILE_USER_DIR */ + + /* Default to all compiler invocations for --sysroot=. */ +-#define DEFAULT_SYSROOT "/llvmtools" ++#define DEFAULT_SYSROOT "/" + + /* Directory where gcc is installed. */ + #define GCC_INSTALL_PREFIX "" diff --git a/patches/python3-Chimera/expat-2.6.patch b/patches/python3-Chimera/expat-2.6.patch new file mode 100644 index 0000000..0567fa5 --- /dev/null +++ b/patches/python3-Chimera/expat-2.6.patch @@ -0,0 +1,48 @@ +Patch-Source: https://github.com/python/cpython/pull/115138 +-- +From a147a3e2b9252e8452a37628e07ddcd4e0709880 Mon Sep 17 00:00:00 2001 +From: Sebastian Pipping +Date: Wed, 7 Feb 2024 15:32:45 +0100 +Subject: [PATCH] test_xml_etree.py: Fix for Expat >=2.6.0 with reparse + deferral + +--- + Lib/test/test_xml_etree.py | 10 ++++++---- + .../2024-02-07-15-49-37.gh-issue-115133.WBajNr.rst | 1 + + 2 files changed, 7 insertions(+), 4 deletions(-) + create mode 100644 Misc/NEWS.d/next/Tests/2024-02-07-15-49-37.gh-issue-115133.WBajNr.rst + +diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py +index a435ec7822ea0c..1eac7dd08b9676 100644 +--- a/Lib/test/test_xml_etree.py ++++ b/Lib/test/test_xml_etree.py +@@ -1483,6 +1483,7 @@ def assert_event_tags(self, parser, expected, max_events=None): + def test_simple_xml(self): + for chunk_size in (None, 1, 5): + with self.subTest(chunk_size=chunk_size): ++ expected_events = [] + parser = ET.XMLPullParser() + self.assert_event_tags(parser, []) + self._feed(parser, "\n", chunk_size) +@@ -1492,16 +1493,17 @@ def test_simple_xml(self): + chunk_size) + self.assert_event_tags(parser, []) + self._feed(parser, ">\n", chunk_size) +- self.assert_event_tags(parser, [('end', 'element')]) ++ expected_events += [('end', 'element')] + self._feed(parser, "texttail\n", chunk_size) + self._feed(parser, "\n", chunk_size) +- self.assert_event_tags(parser, [ ++ expected_events += [ + ('end', 'element'), + ('end', 'empty-element'), +- ]) ++ ] + self._feed(parser, "\n", chunk_size) +- self.assert_event_tags(parser, [('end', 'root')]) ++ expected_events += [('end', 'root')] + self.assertIsNone(parser.close()) ++ self.assert_event_tags(parser, expected_events) + + def test_feed_while_iterating(self): + parser = ET.XMLPullParser() diff --git a/patches/python-alpine/musl-find_library.patch b/patches/python3-Chimera/musl-find_library.patch similarity index 87% rename from patches/python-alpine/musl-find_library.patch rename to patches/python3-Chimera/musl-find_library.patch index 7899abb..d6c4b37 100644 --- a/patches/python-alpine/musl-find_library.patch +++ b/patches/python3-Chimera/musl-find_library.patch @@ -1,6 +1,5 @@ -diff -ru Python-2.7.12.orig/Lib/ctypes/util.py Python-2.7.12/Lib/ctypes/util.py ---- Python-2.7.12.orig/Lib/ctypes/util.py 2016-06-26 00:49:30.000000000 +0300 -+++ Python-2.7.12/Lib/ctypes/util.py 2016-11-03 16:05:46.954665040 +0200 +--- a/Lib/ctypes/util.py.orig ++++ b/Lib/ctypes/util.py @@ -204,6 +204,41 @@ def find_library(name, is64 = False): return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name)) diff --git a/patches/python3-Chimera/strictoverfl0w.patch b/patches/python3-Chimera/strictoverfl0w.patch new file mode 100644 index 0000000..7b468df --- /dev/null +++ b/patches/python3-Chimera/strictoverfl0w.patch @@ -0,0 +1,14 @@ +clang has 'fstrict-overflow' but ignores no-strict-overflow and generates a warning +this breaks test_cppext which passes this and has -Werror +-- +--- a/configure ++++ b/configure.ac +@@ -9232,7 +9232,7 @@ + if test "x$ac_cv_cc_supports_fstrict_overflow" = xyes + then : + STRICT_OVERFLOW_CFLAGS="-fstrict-overflow" +- NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow" ++ NO_STRICT_OVERFLOW_CFLAGS="" + else $as_nop + STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS="" diff --git a/patches/systemd-chimera/0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch b/patches/systemd-chimera/0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch index 3228f17..87fa8d7 100644 --- a/patches/systemd-chimera/0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch +++ b/patches/systemd-chimera/0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch @@ -1,3 +1,5 @@ +Added in more places by q66. + From d0bdce977b7acc5e45e82cf84256c4bedc0e74c4 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sun, 27 May 2018 08:36:44 -0700 @@ -28,3 +30,163 @@ Signed-off-by: Khem Raj #include "alloc-util.h" #include "bus-common-errors.h" #include "bus-get-properties.h" +diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c +index 132a846..5683e5c 100644 +--- a/src/analyze/analyze-verify-util.c ++++ b/src/analyze/analyze-verify-util.c +@@ -16,6 +16,11 @@ + #include "unit-name.h" + #include "unit-serialize.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static void log_syntax_callback(const char *unit, int level, void *userdata) { + Set **s = ASSERT_PTR(userdata); + int r; +diff --git a/src/basic/unit-file.c b/src/basic/unit-file.c +index 54f2137..33a593e 100644 +--- a/src/basic/unit-file.c ++++ b/src/basic/unit-file.c +@@ -16,6 +16,11 @@ + #include "strv.h" + #include "unit-file.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + bool unit_type_may_alias(UnitType type) { + return IN_SET(type, + UNIT_SERVICE, +diff --git a/src/core/execute.c b/src/core/execute.c +index c4788a4..0e0d167 100644 +--- a/src/core/execute.c ++++ b/src/core/execute.c +@@ -121,6 +121,11 @@ + + #define SNDBUF_SIZE (8*1024*1024) + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static int shift_fds(int fds[], size_t n_fds) { + if (n_fds <= 0) + return 0; +diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c +index fd45744..c8e6a51 100644 +--- a/src/core/load-dropin.c ++++ b/src/core/load-dropin.c +@@ -11,6 +11,11 @@ + #include "unit-name.h" + #include "unit.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static int process_deps(Unit *u, UnitDependency dependency, const char *dir_suffix) { + _cleanup_strv_free_ char **paths = NULL; + int r; +diff --git a/src/delta/delta.c b/src/delta/delta.c +index eee2111..2462bbd 100644 +--- a/src/delta/delta.c ++++ b/src/delta/delta.c +@@ -28,6 +28,11 @@ + #include "strv.h" + #include "terminal-util.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static const char prefixes[] = + "/etc\0" + "/run\0" +diff --git a/src/shared/install.c b/src/shared/install.c +index a34e7bf..c3a38fa 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -38,6 +38,11 @@ + #include "strv.h" + #include "unit-file.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + #define UNIT_FILE_FOLLOW_SYMLINK_MAX 64 + + typedef enum SearchFlags { +diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c +index 940f546..a388ac6 100644 +--- a/src/systemctl/systemctl-enable.c ++++ b/src/systemctl/systemctl-enable.c +@@ -11,6 +11,11 @@ + #include "systemctl-util.h" + #include "systemctl.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static int normalize_filenames(char **names) { + int r; + +diff --git a/src/systemctl/systemctl-list-unit-files.c b/src/systemctl/systemctl-list-unit-files.c +index fc1ad98..29ca24a 100644 +--- a/src/systemctl/systemctl-list-unit-files.c ++++ b/src/systemctl/systemctl-list-unit-files.c +@@ -8,6 +8,11 @@ + #include "systemctl.h" + #include "terminal-util.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static int compare_unit_file_list(const UnitFileList *a, const UnitFileList *b) { + const char *d1, *d2; + +diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c +index 6422550..ed860dc 100644 +--- a/src/systemctl/systemctl-show.c ++++ b/src/systemctl/systemctl-show.c +@@ -42,6 +42,11 @@ + #include "terminal-util.h" + #include "utf8.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + static OutputFlags get_output_flags(void) { + return + FLAGS_SET(arg_print_flags, BUS_PRINT_PROPERTY_SHOW_EMPTY) * OUTPUT_SHOW_ALL | +diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c +index b554a68..ef90e34 100644 +--- a/src/udev/net/link-config.c ++++ b/src/udev/net/link-config.c +@@ -36,6 +36,11 @@ + #include "strv.h" + #include "utf8.h" + ++#if !defined(__GLIBC__) ++#include ++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src) ++#endif ++ + struct LinkConfigContext { + LIST_HEAD(LinkConfig, configs); + int ethtool_fd; diff --git a/sources.list b/sources.list index 294ae51..1f004b1 100644 --- a/sources.list +++ b/sources.list @@ -1,11 +1,11 @@ https://www.kernel.org/pub/linux/docs/man-pages/man-pages-6.05.01.tar.xz -https://musl.libc.org/releases/musl-1.2.4.tar.gz +https://musl.libc.org/releases/musl-1.2.5.tar.gz https://skarnet.org/software/skalibs/skalibs-2.14.0.1.tar.gz https://skarnet.org/software/utmps/utmps-0.1.2.2.tar.gz -https://data.iana.org/time-zones/releases/tzdata2023c.tar.gz -https://data.iana.org/time-zones/releases/tzcode2023c.tar.gz +https://data.iana.org/time-zones/releases/tzdata2024a.tar.gz +https://data.iana.org/time-zones/releases/tzcode2024a.tar.gz https://dev.alpinelinux.org/archive/posixtz/posixtz-0.5.tar.xz -https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.1.4.tar.gz +https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.1.6.tar.gz https://astron.com/pub/file/file-5.45.tar.gz https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz @@ -13,14 +13,14 @@ https://github.com/gavinhoward/bc/releases/download/6.7.2/bc-6.7.2.tar.xz https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz -https://github.com/shadow-maint/shadow/releases/download/4.14.2/shadow-4.14.2.tar.xz -https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz +https://github.com/shadow-maint/shadow/releases/download/4.14.6/shadow-4.14.6.tar.xz +https://dev.alpinelinux.org/archive/gcc/13-20240309/gcc-13-20240309.tar.xz http://isl.gforge.inria.fr/isl-0.23.tar.bz2 https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz -https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.5.tar.xz +https://distfiles.dereferenced.org/pkgconf/pkgconf-2.2.0.tar.xz http://ftp.barfooze.de/pub/sabotage/tarballs/netbsd-curses-0.3.2.tar.xz -https://download.savannah.gnu.org/releases/attr/attr-2.5.1.tar.gz -https://download.savannah.gnu.org/releases/acl/acl-2.3.1.tar.xz +https://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.gz +https://download.savannah.gnu.org/releases/acl/acl-2.3.2.tar.xz https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.69.tar.xz http://ftp.gnu.org/gnu/sed/sed-4.9.tar.xz https://sourceforge.net/projects/psmisc/files/psmisc/psmisc-23.6.tar.xz @@ -32,21 +32,21 @@ https://ftp.gnu.org/gnu/bash/bash-5.2.21.tar.gz https://ftp.gnu.org/gnu/libtool/libtool-2.4.7.tar.xz https://ftp.gnu.org/gnu/gdbm/gdbm-1.23.tar.gz http://ftp.gnu.org/gnu/gperf/gperf-3.1.tar.gz -https://prdownloads.sourceforge.net/expat/expat-2.5.0.tar.xz +https://prdownloads.sourceforge.net/expat/expat-2.6.2.tar.xz https://ftp.gnu.org/gnu/inetutils/inetutils-2.4.tar.xz -https://www.cpan.org/src/5.0/perl-5.38.0.tar.xz +https://www.cpan.org/src/5.0/perl-5.38.2.tar.xz https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.46.tar.gz https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz http://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.xz https://github.com/chimera-linux/musl-fts/archive/refs/tags/v1.2.7-mk2.tar.gz -https://tukaani.org/xz/xz-5.4.5.tar.xz -https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-31.tar.xz +https://tukaani.org/xz/xz-5.4.6.tar.xz +https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-32.tar.xz http://ftp.barfooze.de/pub/sabotage/tarballs/gettext-tiny-0.3.2.tar.xz https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz https://github.com/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.8.2.tar.gz -https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz +https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz https://github.com/ninja-build/ninja/archive/v1.11.1/ninja-1.11.1.tar.gz https://github.com/mesonbuild/meson/releases/download/1.3.0/meson-1.3.0.tar.gz https://sourceforge.net/projects/procps-ng/files/Production/procps-ng-4.0.4.tar.xz @@ -67,8 +67,8 @@ http://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz https://download.savannah.gnu.org/releases/man-db/man-db-2.12.0.tar.xz https://ftp.gnu.org/gnu/tar/tar-1.35.tar.xz https://ftp.gnu.org/gnu/texinfo/texinfo-7.1.tar.xz -https://anduin.linuxfromscratch.org/LFS/vim-9.0.2103.tar.xz -https://www.kernel.org/pub/linux/utils/util-linux/v2.39/util-linux-2.39.2.tar.xz +https://github.com/vim/vim/archive/v9.1.0330/vim-9.1.0330.tar.gz +https://www.kernel.org/pub/linux/utils/util-linux/v2.39/util-linux-2.39.4.tar.xz https://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.47.0/e2fsprogs-1.47.0.tar.gz https://skarnet.org/software/execline/execline-2.9.4.0.tar.gz https://skarnet.org/software/s6/s6-2.12.0.2.tar.gz @@ -83,14 +83,14 @@ https://prdownloads.sourceforge.net/expect/expect5.45.4.tar.gz https://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.3.tar.gz https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.2.tar.xz http://distcache.freebsd.org/local-distfiles/itetcu/libexecinfo-1.1.tar.bz2 -https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/llvm-project-17.0.6.src.tar.xz https://cmake.org/files/v3.27/cmake-3.27.8.tar.gz https://dist.libuv.org/dist/v1.41.0/libuv-v1.41.0.tar.gz https://github.com/chimera-linux/libatomic-chimera/archive/refs/tags/v0.90.0.tar.gz https://github.com/libarchive/libarchive/releases/download/v3.7.2/libarchive-3.7.2.tar.xz https://www.crufty.net/ftp/pub/sjg/bmake-20230909.tar.gz https://www.nano-editor.org/dist/v7/nano-7.2.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/compiler-rt-17.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/compiler-rt-17.0.6.src.tar.xz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://github.com/Projeto-Pindorama/musl-compat/archive/refs/tags/20230601.tar.gz https://github.com/chimera-linux/elftoolchain/archive/fea115ec80ece0a0c2271ed2bc25a30a85da990e.tar.gz diff --git a/sources.md5 b/sources.md5 index 282a41f..dccfe57 100644 --- a/sources.md5 +++ b/sources.md5 @@ -2,11 +2,11 @@ f07552114d9913cc8bfa368496b733a3 217059f21e2d1f016f7ba044b36d12de95788cf3.tar.gz d31148abd89c1df1cdb077a55db27d02 Jinja2-3.1.2.tar.gz ca33f119bd0551ce15837f58bb180214 MarkupSafe-2.1.3.tar.gz -f6f4616584b23254d165f4db90c247d6 Python-3.12.0.tar.xz +e7c178b97bf8f7ccd677b94d614f7b3c Python-3.12.2.tar.xz 80bb18a8e6240fcf7ec2f7b57601c170 XML-Parser-2.46.tar.gz -95ce715fe09acca7c12d3306d0f076b2 acl-2.3.1.tar.xz +590765dee95907dbc3c856f7255bd669 acl-2.3.2.tar.xz 720704bac078d067111b32444e24ba69 argp-standalone-1.3.tar.gz -ac1c5a7a084f0f83b8cace34211f64d8 attr-2.5.1.tar.gz +227043ec2f6ca03c0948df5517f9c927 attr-2.5.2.tar.gz 12cfa1687ffa2606337efe1a64416106 autoconf-2.71.tar.xz 4017e96f89fca45ca946f1c5db6be714 automake-1.16.5.tar.xz ad5b38410e3bf0e9bcc20e2765f5e3f9 bash-5.2.21.tar.gz @@ -19,7 +19,7 @@ fc9e8c37c6636ede45bf6834c2d6716f byacc-20230521.tgz 50fcafcecde5a380415b12e9c574e0b2 check-0.15.2.tar.gz 877200cc072ece1a52c27677ab26e3ee clang-12.0.0.src.tar.xz df0e65607c9280a8df68b2c93eac4437 cmake-3.27.8.tar.gz -c706f8b37eda3900a6d902d584b93a6d compiler-rt-17.0.5.src.tar.xz +85d25f04cbc4c1a20e3a1ab2a2c522cd compiler-rt-17.0.6.src.tar.xz 459e9546074db2834eefe5421f250025 coreutils-9.4.tar.xz 6800b5dbfbfdd43ac3df2ba9d31d0706 dash-0.5.12.tar.gz 68c5208c58236eba447d7d6d1326b821 dejagnu-1.6.3.tar.gz @@ -27,7 +27,7 @@ c706f8b37eda3900a6d902d584b93a6d compiler-rt-17.0.5.src.tar.xz e8ef5fa3b72557be5e9fe564a25da6eb e2fsprogs-1.46.2.tar.gz 2b6e94c2eebc1f2194173e31bca9396e elfutils-0.185.tar.bz2 ab98d90c068f99c854277c6c8c696072 execline-2.9.4.0.tar.gz -a4fb91a9441bcaec576d4c4a56fa3aa6 expat-2.4.1.tar.xz +0cb75c8feb842c0794ba89666b762a2d expat-2.6.2.tar.xz 00fce8de158422f5ccd2666512329bd2 expect5.45.4.tar.gz dc8ad5a95487136ccf002fe6afeb76ef fea115ec80ece0a0c2271ed2bc25a30a85da990e.tar.gz 26b2a96d4e3a8938827a1e572afd527a file-5.45.tar.gz @@ -35,7 +35,7 @@ eeefe2e6380931a77dfa6d9350b43186 findutils-4.8.0.tar.xz 2882e3179748cc9f9c23ec593d6adc8d flex-2.6.4.tar.gz 3bc52f1952b9a78361114147da63c35b flit_core-3.9.0.tar.gz 97c5a7d83f91a7e1b2035ebbe6ac7abd gawk-5.3.0.tar.xz -e0e48554cc6e4f261d55ddee9ab69075 gcc-13.2.0.tar.xz +65fb71238ff76078a136fa393415716b gcc-13-20240309.tar.xz 8551961e36bf8c70b7500d255d3658ec gdbm-1.23.tar.gz 9ddf4d35636fa3beacd3627cc02723ff gettext-tiny-0.3.2.tar.xz 956dc04e864001a9c22429f761f2c283 gmp-6.3.0.tar.xz @@ -50,7 +50,7 @@ f26b37a03a211ddd4e9c7189191e2772 iana-etc-20231117.tar.gz 6716fc3188dbea226997fa2478a190d7 iproute2-6.6.0.tar.xz a43a8da08df0744a6453956718e2b76b isl-0.23.tar.bz2 4764775cac0415f1d35a0cd311249941 kbd-2.6.3.tar.xz -6165867e1836d51795a11ea4762ff66a kmod-31.tar.xz +1046fda48766fae905f83150d12eec78 kmod-32.tar.xz cf05e2546a3729492b944b4874dd43dd less-643.tar.gz 4f4ef6a17c7b0b484aa2c95aa6deefac libarchive-3.7.2.tar.xz 4667bacb837f9ac4adb4a1a0266f4b65 libcap-2.69.tar.xz @@ -81,8 +81,8 @@ e812da327b1c2214ac1aed440ea3ae8d ncurses-6.2.tar.gz 7903549a14abebc5c323ce4e85f2cbb2 openssl-3.2.0.tar.gz 78ad9937e4caadcba1526ef1853730d5 patch-2.7.6.tar.xz 9b091a689583fdc7c3206679586322d5 patchelf-0.18.0.tar.bz2 -e1c8aaec897dd386c741f97eef9f2e87 perl-5.38.0.tar.xz -be4e3987047a95c2b75fbbf1884353ad pkgconf-1.7.4.tar.xz +d3957d75042918a23ec0abac4a2b7e0a perl-5.38.2.tar.xz +00e309a3bf0909030a4fc701389db2b9 pkgconf-2.2.0.tar.xz 80f8ae1df19dd28e1c8b192c6ea7b836 posixtz-0.5.tar.xz 2f747fc7df8ccf402d03e375c565cf96 procps-ng-4.0.4.tar.xzz ed3206da1184ce9e82d607dc56c52633 psmisc-23.6.tar.xz @@ -94,7 +94,7 @@ bc82735506f2bd4316d4e6ac1f149e02 s6-portable-utils-2.3.0.3.tar.gz c3c36ab55d340e4146d459b9abcc766a s6-rc-0.5.4.2.tar.gz 6d906edfdb3202304059233f51f9a71d sed-4.8.tar.xz 32bcc14eb830a13fbf33e053286f1081 setuptools-69.0.2.tar.gz -effc1aa17590305647413125b966f1dd shadow-4.14.2.tar.xz +293e93f78f2d3217b253d289271a40fa shadow-4.14.6.tar.xz 50e0eeeea99514cc00f212f2f46c3ec2 skalibs-2.14.0.1.tar.gz d0462c4f60c1783311a77583f60a68bb sources.list 0d266e5361dc72097b6c18cfde1c0001 systemd-254.tar.gz @@ -102,17 +102,17 @@ a2d8042658cfd8ea939e6d911eaf4152 tar-1.35.tar.xz 0e4358aade2f5db8a8b6f2f6d9481ec2 tcl8.6.13-src.tar.gz edd9928b4a3f82674bcc3551616eef3b texinfo-7.1.tar.xz 715191c7f369be377fc7cc8ce0ccd835 tree-1.8.0.tgz -532bcd571bff983447f0596112bbc065 tzcode2023c.tar.gz -5aa672bf129b44dd915f8232de38e49a tzdata2023c.tar.gz -2feb3e7c306f336a3d22a182dfffc942 util-linux-2.39.2.tar.xz +1a9d670f0b418130503401b8b8f41769 tzcode2024a.tar.gz +2349edd8335245525cc082f2755d5bf4 tzdata2024a.tar.gz +178032a1fe2b3812e55fc08df9962f65 util-linux-2.39.4.tar.xz 319baec6f795d3920cd34c2384322eb0 utmps-0.1.2.2.tar.gz 20f5fe6c1f5fd9fba650c5495e5f9fb5 v0.90.0.tar.gz 8f5a5022fa66d94b7b0934618dfa6350 v1.0.tar.gz 185975cc117dba8e6158cce847ba44d5 v1.1.tar.gz 64cbd6b7224ec81a1c2d1ca73877b232 v1.2.7-mk2.tar.gz -1af1d018026234d085a82348703461ce vim-9.0.2103.tar.xz +88d5656c21668ae98a0cd1a13abb3d12 vim-9.1.0330.tar.gz 802ad6e5f9336fcb1c76b7593f0cd22d wheel-0.42.0.tar.gz 097ff1a324ae02e0a3b0369f07a7544a which-2.21.tar.gz -1d33e0be05c53e7a5641acf5c8b35fdd xz-5.4.5.tar.xz +7ade7bd1181a731328f875bec62a9377 xz-5.4.6.tar.xz d2ac0866850e3f80d5e4e509aab62438 2.1.4.tar.gz 63251602329a106220e0a5ad26ba656f zstd-1.5.5.tar.gz