From f8a70e6151948a2a0bb6adc286f81d88f9141740 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:06:22 -0600 Subject: [PATCH 001/484] Updated build method of clang+LLVM to use bootstrapping options. --- 1-cgnutools/7-LLVM | 300 +++++++++++++++++++++++---------------------- 1 file changed, 151 insertions(+), 149 deletions(-) diff --git a/1-cgnutools/7-LLVM b/1-cgnutools/7-LLVM index 8674e4d..643b627 100644 --- a/1-cgnutools/7-LLVM +++ b/1-cgnutools/7-LLVM @@ -1,11 +1,14 @@ -# cgnutools: Stage0 LLVM Runtime Libraries ( with clang,compiler-rt,libcxx,libcxxabi,libunwind,lld) +# cgnutools: Stage0 Clang ( with compiler-rt,libcxx,libcxxabi,libunwind,lld) +# # Build as cmlfs # -# NOTE: Unpack llvm-project-x.x.x.src.tar.xz not llvm-x.x.x.src.tar.xz - +# NOTES: Stage 0 Clang seems to work (can compile musl libc, ncurses, etc), yet when +# building stage 1 clang (in llvmools) CMake complains about Stage 0 clang lacking +# atomics OR cannot find kernel headers already installed in llvmtools. +# # Rename for shorter paths: -mv llvm-project-15.0.5.src llvm-rl -export LLVMSRC=${CMLFS}/sources/llvm-rl +mv llvm-project-15.0.5.src llvm +export LLVMSRC=${CMLFS}/sources/llvm cd $LLVMSRC @@ -35,36 +38,23 @@ rm -v test/tools/llvm-readobj/ELF/dependent-libraries.test test/Object/macho-inv test/CodeGen/RISCV/rv64zbp.ll sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt -# If building Hexagon target, there is a known broken codegen -# for Hexagon target, reported upstream. -# https://github.com/llvm/llvm-project/issues/48936 -#rm -v \ -# test/CodeGen/Hexagon/csr-stubs-spill-threshold.ll \ -# test/CodeGen/Hexagon/long-calls.ll \ -# test/CodeGen/Hexagon/mlong-calls.ll \ -# test/CodeGen/Hexagon/pic-regusage.ll \ -# test/CodeGen/Hexagon/runtime-stkchk.ll \ -# test/CodeGen/Hexagon/swp-memrefs-epilog.ll \ -# test/CodeGen/Hexagon/vararg-formal.ll \ -# test/tools/llvm-objcopy/MachO/universal-object.test \ -# test/DebugInfo/X86/vla-multi.ll - # Return to top-level cd .. # Apply patches for clang cd clang patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch +patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch # Apply patches for compiler-rt -cd ../compiler-rt -patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch -patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch +cd ../compiler-rt +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch # Apply patches for libcxx cd ../libcxx -patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch -patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch cd .. @@ -73,131 +63,143 @@ CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' CXXFLAGS=$CFLAGS export CFLAGS CXXFLAGS -# Set the build options .. -export CONFIG_OPTIONS="-DCMAKE_BUILD_TYPE=Release " -export CONFIG_OPTIONS+="-DBUILD_SHARED_LIBS=ON " -export CONFIG_OPTIONS+="-DLLVM_ENABLE_LIBCXX=ON " -export CONFIG_OPTIONS+="-DLLVM_TARGET_ARCH=X86 " -export CONFIG_OPTIONS+="-DLLVM_TARGETS_TO_BUILD=X86 " -export CONFIG_OPTIONS+="-DLIBCXX_HAS_MUSL_LIBC=ON " -export CONFIG_OPTIONS+="-DLLVM_ENABLE_EH=ON " -export CONFIG_OPTIONS+="-DLLVM_ENABLE_RTTI=ON " -export CONFIG_OPTIONS+="-DLLVM_BUILD_LLVM_DYLIB=ON " - # Set the compiler and linker flags... export LINKERFLAGS="-Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1" -export CONFIG_TOOLS="-DCMAKE_C_COMPILER=${CMLFS_TARGET}-gcc " -export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${CMLFS_TARGET}-g++ " -export CONFIG_TOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " - -# Set the tuples... -export CONFIG_TUPLES="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " -export CONFIG_TUPLES+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " -export CONFIG_TUPLES+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " - -# Set the flags for Compiler-rt... -export CONFIG_CRT="-DCOMPILER_RT_BUILD_SANITIZERS=OFF" -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_ORC=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_HWASAN_WITH_INTERCEPTORS=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_USE_LLVM_UNWINDER=ON " - -# Set the flags for clang: -export CONFIG_CLANG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " -export CONFIG_CLANG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " -export CONFIG_CLANG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " -export CONFIG_CLANG+="-DCLANG_ENABLE_STATIC_ANALYZER=OFF " -export CONFIG_CLANG+="-DCLANG_ENABLE_ARCMT=OFF " -export CONFIG_CLANG+="-DCLANG_TOOL_CLANG_IMPORT_TEST_BUILD=OFF " -export CONFIG_CLANG+="-DCLANG_TOOL_C_ARCMT_TEST_BUILD=OFF " -export CONFIG_CLANG+="-DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF " -export CONFIG_CLANG+="-DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " -export CONFIG_CLANG+="-DCLANG_TOOL_APINOTES_TEST_BUILD=OFF " -export CONFIG_CLANG+="-DCLANG_TOOL_ARCMT_TEST_BUILD=OFF " - -# Set the flags to prevent build static libraries for -# libunwind, libcxxabi, and libcxx: -export CONFIG_LIBUNWIND="-DLIBUNWIND_ENABLE_STATIC=OFF " -export CONFIG_LIBCXXABI="-DLIBCXXABI_ENABLE_STATIC=OFF " -export CONFIG_LIBCXX="-DLIBCXX_ENABLE_STATIC=OFF " - -# Set the options for libc++ -export CONFIG_LIBCXX+="-DLIBCXX_USE_COMPILER_RT=ON " -export CONFIG_LIBCXX+="-DLIBCXX_EXTRA_SITE_DEFINES=ON " -export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_ASSERTIONS=ON " -export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_LOCALIZATION=OFF " -export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS=ON " -export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF " - -# Set the options for libc++abi -export CONFIG_LIBCXXABI+="-DLIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST=ON " -export CONFIG_LIBCXXABI+="-DLIBCXXABI_USE_COMPILER_RT=ON " -export CONFIG_LIBCXXABI+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " - -# Set the options for libunwind -export CONFIG_LIBUNWIND+="-DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON " - -# Set paths... -export CONFIG_PATHS="-DCMAKE_INSTALL_PREFIX=/cgnutools " -export CONFIG_PATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/cgnutools/include " -export CONFIG_PATHS+="-DDEFAULT_SYSROOT=/cgnutools " -export CONFIG_PATHS+="-DBacktrace_LIBRARY=/cgnutools/lib/libexecinfo.so " -#export CONFIG_PATHS+="-DICONV_LIBRARY_PATH=/cgnutools/lib/libc.so" - -# Turn off unwanted features, docs and tests -export BUILD_OFF="-DLLVM_BUILD_TESTS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_GO_TESTS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_TESTS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_DOCS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_LIBEDIT=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_LIBXML2=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_LIBPFM=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_TERMINFO=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_ZLIB=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_Z3_SOLVER=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_CRASH_OVERRIDES=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_ZSTD=OFF " -export BUILD_OFF+="-DLLVM_APPEND_VC_REV=OFF " -export BUILD_OFF+="-DLIBCXX_INCLUDE_BENCHMARKS=OFF " -export BUILD_OFF+="-DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF " -export BUILD_OFF+="-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF " -export BUILD_OFF+="-DLLVM_TOOL_LLVM_MICROSOFT_DEMANGLE_FUZZER_BUILD=OFF " -export BUILD_OFF+="-DLLVM_TOOL_LLVM_ITANIUM_DEMANGLE_FUZZER_BUILD=OFF " -export BUILD_OFF+="-DLLVM_TOOL_LLVM_GO_BUILD=OFF " -export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_PASSES_BUILD=OFF " -export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_BUILD=OFF " - -# Configure source +export CTOOLS="-DCMAKE_C_COMPILER=${CMLFS_TARGET}-gcc " +export CTOOLS+="-DCMAKE_CXX_COMPILER=${CMLFS_TARGET}-g++ " +export CTOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " + +# Set the tuples & build target ... +export CTARG="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=X86 " +export CTARG+="-DLLVM_TARGET_ARCH=X86 " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=Native " + +# Set the paths ... +export CPATHS="-DCMAKE_INSTALL_PREFIX=/cgnutools " +export CPATHS+="-DDEFAULT_SYSROOT=/cgnutools " +export CPATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/cgnutools/lib " +export CPATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/cgnutools/include " + +# Set bootstrap options.. +# https://discourse.llvm.org/t/bootstrapping-standalone-llvm-clang-libc-lld-toolchain/3069 +export CBSTRAP="-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release " +export CBSTRAP+="-DCLANG_ENABLE_BOOTSTRAP=ON " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt " +export CBSTRAP+="-DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=ON " +export CBSTRAP+="-DBOOTSTRAP_LLVM_USE_LINKER=lld " +export CBSTRAP+="-DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=ON " +# make sure bootstrap has atomics +#export CBSTRAP+="-DBOOTSTRAP_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC=ON " +#export CBSTRAP+="-DBOOTSTRAP_COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " + +# Set the standard C++ library that clang will use to LLVM's libc++: +export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " + +# Set the runtime library that clang will use to compiler-rt: +export COPTS+="-DCLANG_DEFAULT_RTLIB=compiler-rt " + +# Set libc++abi & libc++ to use compiler-rt instead of gcc's runtime: +export COPTS+="-DLIBCXX_USE_COMPILER_RT=ON " +export COPTS+="-DLIBCXXABI_USE_COMPILER_RT=ON " + +# Set libc++abi to use libunwind to avoid dependace on GCC: +export COPTS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " + +# Enable Exception Handling: +export COPTS+="-DLLVM_ENABLE_EH=ON " + +# Exception handling requires Runtime Type Info +export COPTS+="-DLLVM_ENABLE_RTTI=ON " + +# Stage 1 clang's compiler-rt will require new delete definitions in libc++ +export COPTS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " + +# Enable atomics to avoid using atomics from GCC: +export COPTS+="-DCOMPILER_RT_BUILD_STANDALONE_LIBATOMIC=OFF " +export COPTS+="-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " + +# Turn off features ... +export BOFF="-DLLVM_ENABLE_LIBXML2=OFF -DLIBCXX_ENABLE_LOCALIZATION=OFF " +export BOFF+="-DLLVM_ENABLE_ZLIB=OFF -DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " +export BOFF+="-DLLVM_ENABLE_ZSTD=OFF -DLIBUNWIND_INCLUDE_TESTS=OFF " +export BOFF+="-DLLVM_ENABLE_LIBEDIT=OFF -DLIBUNWIND_INCLUDE_DOCS=OFF " + +export BOFF+="-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF " + +# Turn off features that cause compiler-rt to NOT reference backtrace symbols from libexecinfo +export BOFF+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_ORC=OFF " + cmake -B build -G Ninja -Wno-dev -S llvm \ - -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ - -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS}" \ - ${CONFIG_TOOLS} ${CONFIG_TUPLES} \ - ${CONFIG_CRT} ${CONFIG_CLANG} ${CONFIG_OPTIONS} \ - ${CONFIG_LIBUNWIND} ${CONFIG_LIBCXXABI} \ - ${CONFIG_LIBCXX} ${CONFIG_PATHS} ${BUILD_OFF} \ - -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;libcxx;libcxxabi;lld;libunwind" \ - -DCLANG_VENDOR="cgnutools 3.0.0" -DLLD_VENDOR="cgnutools 3.0.0" - -# Compile -ninja -C build cxx -ninja -C build - -# Install to /cgnutools -ninja -C build install - -# Clean up -unset CFLAGS CXXFLAGS CONFIG_TOOLS CONFIG_TUPLES -unset CONFIG_CRT CONFIG_CLANG CONFIG_OPTIONS -unset CONFIG_LIBUNWIND CONFIG_LIBCXXABI CONFIG_LIBCXX -unset CONFIG_PATHS BUILD_OFF LLVMSRC -rm -rf build - -# Source tree will be used later. Save time by not removing + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="compiler-rt;libunwind;libcxx;libcxxabi;lld;clang" \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} ${CBSTRAP} ${COPTS} ${BOFF} -DLIBUNWIND_INSTALL_HEADERS=ON + +# Compile only what we need for a stage 0 clang +#ninja -C build builtins #164 targets +#ninja -C build unwind #19 +#ninja -C build cxxabi #829 +#ninja -C build cxx #79 +#ninja -C build compiler-rt # 598 +#ninja -C build lld #1652 +#ninja -C build libclang #798 +#ninja -C build clang #288 + +for t in builtins unwind cxxabi cxx compiler-rt lld libclang clang ; +do + ninja -C build $t +done + +# Compile LLVM binutils(binary utilities) +for b in addr2line ar as config cxxdump diff link lipo \ + lto lto2 nm objcopy objdump ranlib rc readelf \ + size split strings strip tblgen ; +do + ninja -C build llvm-$b +done + +# Install only what we built to /cgnutools +#ninja -C build install-builtins #............... libclang_rt.builtins.a +#ninja -C build install-crt #.................... clang_rt.crtbegin.o;clang_rt.crtbend.o +#ninja -C build install-unwind #................. /cgnutools/lib/libunwind.so.1.0 & /cgnutools/include/libunwind.h +#ninja -C build install-cxxabi #................. /cgnutools/lib/x86_64-pc-linux-musl/libc++abi.so.1.0 +#ninja -C build install-cxxabi-headers #......... /cgnutools/include/c++/v1/__cxxabi_config.h;/cgnutools/include/c++/v1/cxxabi_config.h +#ninja -C build install-cxx #.................... /cgnutools/lib/x86_64-pc-linux-musl/libc++.so.1.0 +#ninja -C build install-cxx-headers # ........... /cgnutools/include/c++/v1;/cgnutools/include/x86_64-pc-linux-musl/c++/v1 +#ninja -C build install-compiler-rt # ........... /cgnutools/lib/clang/15.0.5/lib/x86_64-pc-linux-musl/* +#ninja -C build install-lld # ................... lld-link;ld.lld;ld64.lld;wasm-ld +#ninja -C build install-libclang # .............. /cgnutools/lib/libclang.so.15.0.5 +#ninja -C build install-libclang-headers #....... /cgnutools/include/clang-c +#ninja -C build install-clang # ................. /cgnutools/bin/{clang,clang-15,clang++,clang-cl,clang-cpp} +#ninja -C build install-x86-resource-headers #..... /cgnutools/lib/clang/15.0.5/include/* +#ninja -C build install-utility-resource-headers #../cgnutools/lib/clang/15.0.5/include/mm_malloc.h +#ninja -C build install-ve-resource-headers #......./cgnutools/lib/clang/15.0.5/include/velintrin* +#ninja -C build install-compiler-rt-headers #......./cgnutools/lib/clang/15.0.5/include/sanitizer/* +#ninja -C build install-clang-resource-headers #..../cgnutools/lib/clang/15.0.5/include/builtins.h +#ninja -C build install-clang-headers #............./cgnutools/include/clang/AST + +for t in butiltins crt unwind cxxabi cxx compiler-rt lld libclang libclang-headers clang \ + x86-resource-headers utility-resource-headers ve-resource-headers \ + compiler-rt-headers clang-resource-headers clang-headers ; +do + ninja -C build install-$t +done + +# Install LLVM binutils: +for b in addr2line ar as config cxxdump diff link lipo \ + lto lto2 nm objcopy objdump ranlib rc readelf \ + size split strings strip tblgen ; +do + ninja -C build install-llvm-$b +done + +unset CC CXX CFLAGS CXXFLAGS CTOOLS CTARG CPATHS CBSTRAP COPTS BOFF LINKERFLAGS From 48c1d289a440f8aeced7e24543db6a7b285bba9b Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:08:14 -0600 Subject: [PATCH 002/484] Updated stage 0 clang configuration to default to *-pc-linux-musl instead of *-cmlfs-linux-musl --- 1-cgnutools/8-Configuration | 60 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/1-cgnutools/8-Configuration b/1-cgnutools/8-Configuration index 8f72f79..a1fd00d 100644 --- a/1-cgnutools/8-Configuration +++ b/1-cgnutools/8-Configuration @@ -3,23 +3,16 @@ # Configure clang to build binaries with /llvmtools/lib/ld-musl-x86_64.so.1 instead # of /lib/ld-musl-x86_64.so.1. This is similar in Musl-LFS/LFS when gcc specs -# file is modified to set the dynamic linker in /tools instead of host's /lib -ln -sv clang-15 /cgnutools/bin/${CMLFS_TARGET}-clang -ln -sv clang-15 /cgnutools/bin/${CMLFS_TARGET}-clang++ -cat > /cgnutools/bin/${CMLFS_TARGET}.cfg << "EOF" +# file is modified to set the dynamic linker in /tools instead of host's /lib. +# Also configure clang to use compiler-rt instead of GCC's runtime +ln -sv clang-15 /cgnutools/bin/${TARGET_TUPLE}-clang +ln -sv clang-15 /cgnutools/bin/${TARGET_TUPLE}-clang++ + +#cat > /cgnutools/bin/${CMLFS_TARGET}.cfg << "EOF" +cat > /cgnutools/bin/${TARGET_TUPLE}.cfg << "EOF" -Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1 --L/cgnutools/lib/x86_64-pc-linux-musl EOF -# Clang will require libunwind -# Link libunwind to /cgnutools/lib -ln -sv x86_64-pc-linux-musl/libunwind.so.1.0 /cgnutools/lib/libunwind.so -ln -sv x86_64-pc-linux-musl/libunwind.so.1.0 /cgnutools/lib/libunwind.so.1 - -# Fix a path with a link, so clang can find it -ln -sv x86_64-pc-linux-musl /cgnutools/lib/clang/15.0.5/lib/linux -ln -sv libclang_rt.builtins.a /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/linux/libclang_rt.builtins-x86_64.a - # Set LLD as default toolchain linker ln -sv lld /cgnutools/bin/ld @@ -84,7 +77,7 @@ grep succeeded dummy.log rm -rf a.out dummy.log # Test Clang of cgnutools toolchain: -${CMLFS_TARGET}-clang dummy.c -v -Wl,--verbose &> dummy.log +${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] @@ -92,7 +85,7 @@ readelf -l a.out | grep ': /llvmtools' # Check if the correct start files are used grep 'crt[1in]' dummy.log | grep ld.lld: # Should output: -# /cgnutools/lib/crt1.o succeeded +# /cgnutools/lib/Scrt1.o succeeded # /cgnutools/lib/crti.o succeeded # /cgnutools/lib/crtn.o succeeded @@ -102,15 +95,34 @@ grep ld.lld: dummy.log # Should output: # ld.lld: /cgnutools/lib/Scrt1.o # ld.lld: /cgnutools/lib/crti.o -# ld.lld: /cgnutools/lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/crtbeginS.o -# ld.lld: /tmp/dummy-56dafa.o -# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/linux/libclang_rt.builtins-x86_64.a -# ld.lld: /cgnutools/lib/libunwind.so +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/x86_64-cmlfs-linux-musl/clang_rt.crtbegin.o +# ld.lld: /tmp/dummy-0ef0e1.o +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/x86_64-cmlfs-linux-musl/libclang_rt.builtins.a # ld.lld: /cgnutools/lib/libc.so -# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/linux/libclang_rt.builtins-x86_64.a -# ld.lld: /cgnutools/lib/libunwind.so -# ld.lld: /cgnutools/lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/crtendS.o +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/x86_64-cmlfs-linux-musl/libclang_rt.builtins.a +# ld.lld: /mnt/cmlfs/cgnutools/lib/clang/15.0.5/lib/x86_64-cmlfs-linux-musl/clang_rt.crtend.o # ld.lld: /cgnutools/lib/crtn.o +# Check if clang++ has atomics. Usually atomics are provided by gcc. +# Building LLVM for llvmtools requires clang++ to support std::atomic +cat > atomics-test.cpp << "EOF" +#include +std::atomic x; +std::atomic y; +std::atomic z; +int main() { + ++z; + ++y; + return ++x; + } +EOF + +${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. + # If all is good, clean up: -rm -v dummy.log dummy.c a.out +rm -v dummy.log dummy.c a.out atomics-test.cpp atomics-test.log From b0a1877c9a06b1486363c6ac54e64604555e7197 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:16:15 -0600 Subject: [PATCH 003/484] libexecinfo and ncurses should be built before stage 1 clang. --- 2-llvmtools/{05-libexecinfo => 02-libexecinfo} | 0 2-llvmtools/{06-ncurses => 03-ncurses} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename 2-llvmtools/{05-libexecinfo => 02-libexecinfo} (100%) rename 2-llvmtools/{06-ncurses => 03-ncurses} (100%) diff --git a/2-llvmtools/05-libexecinfo b/2-llvmtools/02-libexecinfo similarity index 100% rename from 2-llvmtools/05-libexecinfo rename to 2-llvmtools/02-libexecinfo diff --git a/2-llvmtools/06-ncurses b/2-llvmtools/03-ncurses similarity index 100% rename from 2-llvmtools/06-ncurses rename to 2-llvmtools/03-ncurses From ae1e966889238d4a21980dcf258878f0e0a6a291 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:19:42 -0600 Subject: [PATCH 004/484] libunwind, libc++abi, and libc++ now need to be built together. --- 2-llvmtools/02-libunwind | 78 ------------------- 2-llvmtools/03-libcxxabi | 43 ----------- 2-llvmtools/04-LLVM.Runtimes | 140 +++++++++++++++++++++++++++++++++++ 2-llvmtools/04-libcxx | 48 ------------ 4 files changed, 140 insertions(+), 169 deletions(-) delete mode 100644 2-llvmtools/02-libunwind delete mode 100644 2-llvmtools/03-libcxxabi create mode 100644 2-llvmtools/04-LLVM.Runtimes delete mode 100644 2-llvmtools/04-libcxx diff --git a/2-llvmtools/02-libunwind b/2-llvmtools/02-libunwind deleted file mode 100644 index 4a176e5..0000000 --- a/2-llvmtools/02-libunwind +++ /dev/null @@ -1,78 +0,0 @@ -# llvmtools: libunwind - -# Set CC and CXX compiler with stage0 clang -export CXX=${CMLFS_TARGET}-clang++ -export CC=${CMLFS_TARGET}-clang - - -# Unpack llvm then unpack libunwind -# No need to remove llvm source tree as it will -# be used to build LLVM+clang later -tar xf pkgs/llvm-12.0.0.src.tar.xz && \ -mv llvm-12.0.0.src llvm && \ -export LLVMSRC=$PWD/llvm && \ -cd ${LLVMSRC}/projects && \ -tar xf ../../pkgs/libunwind-12.0.0.src.tar.xz - -# Truncate directory name -mv libunwind-12.0.0.src libunwind - -# libunwind now expects libcxx in llvm source tree -tar -xf ../../pkgs/libcxx-12.0.0.src.tar.xz && \ -mv libcxx-12.0.0.src libcxx - -cd ${LLVMSRC}/projects/libunwind - -# Set configure flags -export CARGS="-DCMAKE_INSTALL_PREFIX=/llvmtools " -export CARGS+="-DLIBUNWIND_ENABLE_SHARED=ON " -export CARGS+="-DLIBUNWIND_USE_COMPILER_RT=ON " -export CARGS+="-DCMAKE_C_FLAGS=-fPIC " -export CARGS+="-DCMAKE_CXX_FLAGS=-fPIC " -export CARGS+="-DCMAKE_AR=/cgnutools/bin/llvm-ar " -export CARGS+="-DCMAKE_LINKER=/cgnutools/bin/ld.lld " -export CARGS+="-DCMAKE_NM=/cgnutools/bin/llvm-nm " -export CARGS+="-DCMAKE_OBJCOPY=/cgnutools/bin/llvm-objcopy " -export CARGS+="-DCMAKE_OBJDUMP=/cgnutools/bin/llvm-objdump " -export CARGS+="-DCMAKE_RANLIB=/cgnutools/bin/llvm-ranlib " -export CARGS+="-DCMAKE_READELF=/cgnutools/bin/llvm-readelf " -export CARGS+="-DCMAKE_STRIP=/cgnutools/bin/llvm-strip " -export CARGS+="-DLLVM_PATH=${LLVMSRC} " - -# Configure -cmake -B build ${CARGS} - -# Build -make -C build - -# Check that built library is 'GCC free' -readelf -d build/lib/libunwind.so.1.0 - -# Output should not have any GCC libraries: -#Dynamic section at offset 0xe780 contains 18 entries: -# Tag Type Name/Value -# 0x0000000000000001 (NEEDED) Shared library: [libc.so] -# 0x000000000000000e (SONAME) Library soname: [libunwind.so.1] -# 0x0000000000000007 (RELA) 0xdf8 -# 0x0000000000000008 (RELASZ) 936 (bytes) -# 0x0000000000000009 (RELAENT) 24 (bytes) -# 0x000000006ffffff9 (RELACOUNT) 35 -# 0x0000000000000017 (JMPREL) 0x11a0 -# 0x0000000000000002 (PLTRELSZ) 552 (bytes) -# 0x0000000000000003 (PLTGOT) 0x118e8 -# 0x0000000000000014 (PLTREL) RELA -# 0x0000000000000006 (SYMTAB) 0x238 -# 0x000000000000000b (SYMENT) 24 (bytes) -# 0x0000000000000005 (STRTAB) 0x9ac -# 0x000000000000000a (STRSZ) 1095 (bytes) -# 0x000000006ffffef5 (GNU_HASH) 0x838 -# 0x000000000000000c (INIT) 0xf4ba -# 0x000000000000000d (FINI) 0xf4c2 -# 0x0000000000000000 (NULL) 0x0 - -# Then install -make -C build install - -# Remove source as it wiil not be needed for clang -cd ${LLVMSRC} && \ -rm -rf ${LLVMSRC}/projects/libunwind diff --git a/2-llvmtools/03-libcxxabi b/2-llvmtools/03-libcxxabi deleted file mode 100644 index f4abbf5..0000000 --- a/2-llvmtools/03-libcxxabi +++ /dev/null @@ -1,43 +0,0 @@ -# llvmtools: libcxx-abi - -# Set CC and CXX compiler with recently built stage0 clang (cgnutools) -export CXX=${CMLFS_TARGET}-clang++ -export CC=${CMLFS_TARGET}-clang - -# Extract and truncate directory name -cd ${LLVMSRC}/projects -tar xf ../../pkgs/libcxxabi-12.0.0.src.tar.xz -mv libcxxabi-12.0.0.src libcxxabi - -cd ${LLVMSRC}/projects/libcxxabi - -# Configure -cmake -B build \ - -DCMAKE_INSTALL_PREFIX=/llvmtools \ - -DLIBCXXABI_ENABLE_STATIC=ON \ - -DLIBCXXABI_USE_COMPILER_RT=ON \ - -DLIBCXXABI_USE_LLVM_UNWINDER=ON \ - -DLIBCXXABI_LIBUNWIND_PATH="/llvmtools/lib" \ - -DLIBCXXABI_LIBCXX_INCLUDES="${LLVMSRC}/projects/libcxx/include" \ - -DLLVM_PATH="${LLVMSRC}" - -# Build -make -C build - -# Make sure built library has no GCC dependancies -readelf -d build/lib/libc++abi.so.1.0 -#Dynamic section at offset 0x586c0 contains 19 entries: -# Tag Type Name/Value -# 0x0000000000000001 (NEEDED) Shared library: [libunwind.so.1] -# 0x0000000000000001 (NEEDED) Shared library: [libc.so] -# 0x000000000000000e (SONAME) Library soname: [libc++abi.so.1] - -# If good, install to llvmtools -make -C build install - -# Install headers too -cp -v include/*.h /llvmtools/include/ - -# Remove build. Will need libcxxabi source for libcxx -cd ${LLVMSRC} && \ -rm -rf ${LLVMSRC}/projects/libcxxabi/build diff --git a/2-llvmtools/04-LLVM.Runtimes b/2-llvmtools/04-LLVM.Runtimes new file mode 100644 index 0000000..11b992f --- /dev/null +++ b/2-llvmtools/04-LLVM.Runtimes @@ -0,0 +1,140 @@ +# llvmtools: LLVM Runtime libraries (libunwind, libcxxabi, libcxx) +# +# Build as cmlfs +# +# libunwind, libcxxabi, and libcxx now need to be built together. + +# Reused unpacked LLVM source from building cgnutools + +# Set CC and CXX compiler with stage0 clang +export CXX=${TARGET_TUPLE}-clang++ +export CC=${TARGET_TUPLE}-clang + +# Set flags to greatly reduce debugging symbols +CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' +CXXFLAGS=$CFLAGS +export CFLAGS CXXFLAGS + +# Set the build options .. +export CONFIG_OPTIONS="-DCMAKE_BUILD_TYPE=Release " +export CONFIG_OPTIONS+="-DBUILD_SHARED_LIBS=ON " + +# Build libc++abi with compiler-rt [from cgnutools] and +# libunwind from cgnutools: +export CONFIG_OPTIONS+="-DLIBCXXABI_USE_COMPILER_RT=ON " +export CONFIG_OPTIONS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " + +export CONFIG_OPTIONS+="-DLIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST=ON " + +# Stage 1 compiler-rt will require new DELETE definitions +export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " + +# Libc++ will not build with localization as musl does not +# have built in support. To enable, libc++ will need patching. +export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_LOCALIZATION=OFF " + +# Build libc++ with musl support +export CONFIG_OPTIONS+="-DLIBCXX_HAS_MUSL_LIBC=ON " + +# Build libc++ & libunwind with compiler-rt [from cgnutools]: +export CONFIG_OPTIONS+="-DLIBCXX_USE_COMPILER_RT=ON " +export CONFIG_OPTIONS+="-DLIBUNWIND_USE_COMPILER_RT=ON " + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1" +export CONFIG_TOOLS="-DCMAKE_C_COMPILER=${CC} " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${CXX} " +export CONFIG_TOOLS+="-DCMAKE_ADDR2LINE=/cgnutools/bin/llvm-addr2line " +export CONFIG_TOOLS+="-DCMAKE_AR=/cgnutools/bin/llvm-ar " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${CXX} " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER_AR=/cgnutools/bin/llvm-ar " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER_RANLIB=/cgnutools/bin/llvm-ranlib " +export CONFIG_TOOLS+="-DCMAKE_C_COMPILER=${CC} " +export CONFIG_TOOLS+="-DCMAKE_C_COMPILER_AR=/cgnutools/bin/llvm-ar " +export CONFIG_TOOLS+="-DCMAKE_C_COMPILER_RANLIB=/cgnutools/bin/llvm-ranlib " +export CONFIG_TOOLS+="-DCMAKE_LINKER=/cgnutools/bin/lld " +export CONFIG_TOOLS+="-DCMAKE_NM=/cgnutools/bin/llvm-nm " +export CONFIG_TOOLS+="-DCMAKE_OBJCOPY=/cgnutools/bin/llvm-objcopy " +export CONFIG_TOOLS+="-DCMAKE_OBJDUMP=/cgnutools/bin/llvm-objdump " +export CONFIG_TOOLS+="-DCMAKE_RANLIB=/cgnutools/bin/llvm-ranlib " +export CONFIG_TOOLS+="-DCMAKE_READELF=/cgnutools/bin/llvm-readelf " +export CONFIG_TOOLS+="-DCMAKE_STRIP=/cgnutools/bin/llvm-strip " + +# Set paths... +export CONFIG_PATHS="-DCMAKE_INSTALL_PREFIX=/llvmtools " +export CONFIG_PATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/llvmtools/include " +export CONFIG_PATHS+="-DCMAKE_INSTALL_BINDIR=/llvmtools/bin " +export CONFIG_PATHS+="-DCMAKE_INSTALL_DATAROOTDIR=/llvmtools/share " +export CONFIG_PATHS+="-DCMAKE_INSTALL_INCLUDEDIR=/llvmtools/include " +export CONFIG_PATHS+="-DCMAKE_INSTALL_LIBDIR=/llvmtools/lib " +export CONFIG_PATHS+="-DCMAKE_INSTALL_LIBEXECDIR=/llvmtools/libexec " +export CONFIG_PATHS+="-DCMAKE_INSTALL_SBINDIR=/llvmtools/sbin " +export CONFIG_PATHS+="-DBacktrace_LIBRARY=/lvmtools/lib/libexecinfo.so.1 " +export CONFIG_PATHS+="-DBacktrace_INCLUDE_DIR=/llvmtools/include " +#export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +#export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_LIBRARY_DIR=/llvmtools/lib/x86_64-pc-linux-musl " #default: lib/x86_64-pc-linux-musl +#export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +#export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +#export CONFIG_PATHS+="-DLIBCXX_INSTALL_LIBRARY_DIR=/llvmtools/lib/x86_64-pc-linux-musl " #default: lib/x86_64-pc-linux-musl +export CONFIG_PATHS+="-DLIBCXX_INSTALL_RUNTIME_DIR=/llvmtools/bin " #default: bin +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/llvmtools/lib " +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_INCLUDE_DIR=/llvmtools/include " +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_RUNTIME_DIR=/llvmtools/lib" + +# Turn off unwanted features, docs and tests +export BUILD_OFF="-DLLVM_BUILD_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_GO_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_DOCS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBEDIT=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBXML2=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBPFM=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_TERMINFO=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_ZLIB=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_Z3_SOLVER=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_CRASH_OVERRIDES=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_ZSTD=OFF " +export BUILD_OFF+="-DLLVM_APPEND_VC_REV=OFF " +export BUILD_OFF+="-DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_MICROSOFT_DEMANGLE_FUZZER_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_ITANIUM_DEMANGLE_FUZZER_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_GO_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_PASSES_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_BUILD=OFF " +export BUILD_OFF+="-DLIBCXX_INCLUDE_BENCHMARKS=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_AS_FUZZER_BUILD=OFF -DLLVM_TOOL_LLVM_BCANALYZER_BUILD=OFF -DLLVM_TOOL_LLVM_DLANG_DEMANGLE_FUZZER_BUILD=OFF " + +# Configure source: +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS}" \ + ${CONFIG_TOOLS} ${CONFIG_OPTIONS} ${CONFIG_PATHS} ${BUILD_OFF} \ + -DLLVM_ENABLE_PROJECTS="libcxxabi;libcxx;libunwind" \ + -DLLVM_TABLEGEN=/cgnutools/bin/llvm-tblgen \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_TARGET_ARCH=host \ + -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl \ + -DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl -DLIBUNWIND_INSTALL_HEADERS=ON + +# Compile +ninja -C build unwind #19 targets +ninja -C build cxxabi #829 +ninja -C build cxx #77 + +# Install to llvmtools +ninja -C build install-unwind +ninja -C build install-cxxabi +ninja -C build install-cxxabi-headers +ninja -C build install-cxx +ninja -C build install-cxx-headers + +# Remove build directory for next build. +# Same source tree will be used next +rm -rf build + +unset CONFIG_TOOLS CONFIG_OPTIONS CONFIG_PATHS LINKERFLAGS LINKERFLAGS BUILD_OFF diff --git a/2-llvmtools/04-libcxx b/2-llvmtools/04-libcxx deleted file mode 100644 index b9702d0..0000000 --- a/2-llvmtools/04-libcxx +++ /dev/null @@ -1,48 +0,0 @@ -# llvmtools: libcxx - - -# Set CC and CXX compiler with recently built stage0 clang (cgnutools) -export CXX=${CMLFS_TARGET}-clang++ -export CC=${CMLFS_TARGET}-clang - -cd ${LLVMSRC}/projects/libcxx - -# Configure -cmake -B build \ - -DCMAKE_INSTALL_PREFIX=/llvmtools \ - -DCMAKE_BUILD_TYPE="Release" \ - -DCMAKE_CXX_FLAGS="-isystem /llvmtools/include" \ - -DLLVM_PATH="${LLVMSRC}" \ - -DLIBCXXABI_USE_LLVM_UNWINDER=ON \ - -DLIBCXX_ENABLE_SHARED=ON \ - -DLIBCXX_ENABLE_STATIC=ON \ - -DLIBCXX_HAS_MUSL_LIBC=ON \ - -DLIBCXX_USE_COMPILER_RT=ON \ - -DLIBCXX_HAS_ATOMIC_LIB=OFF \ - -DLIBCXX_CXX_ABI=libcxxabi \ - -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/llvmtools/include" \ - -DLIBCXX_CXX_ABI_LIBRARY_PATH="/llvmtools/lib" \ - -DLIBCXX_INSTALL_HEADERS=ON \ - -DLIBCXX_INCLUDE_BENCHMARKS=OFF \ - -DLIBCXX_INCLUDE_DOCS=OFF \ - -DLIBCXX_INCLUDE_TESTS=OFF - -# Compile -make -C build - -# Check to make sure no GCC dependancies like libatomic -readelf -d build/lib/libc++.so.1 -#Dynamic section at offset 0xc6e10 contains 22 entries: -# Tag Type Name/Value -# 0x0000000000000001 (NEEDED) Shared library: [libc.so] -# 0x0000000000000001 (NEEDED) Shared library: [libunwind.so.1] -# 0x0000000000000001 (NEEDED) Shared library: [libc++abi.so.1] -# 0x000000000000000e (SONAME) Library soname: [libc++.so.1] - - -# If good, install to llvmtools -make -C build install - -# Remove libcxx & libcxxabi sources, but keep llvm source tree for later -cd ${LLVMSRC} && \ -rm -rf ${LLVMSRC}/projects/{libcxx,libcxxabi} From c829df34366d0ad206d9be91a1fdd5aca4be3d68 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:26:48 -0600 Subject: [PATCH 005/484] Attempted to build stage 1 clang with installed runtimes in llvmtools... --- 2-llvmtools/07-clang-llvm | 363 ++++++++++++++++++-------------------- 1 file changed, 173 insertions(+), 190 deletions(-) diff --git a/2-llvmtools/07-clang-llvm b/2-llvmtools/07-clang-llvm index d59b470..59614fc 100644 --- a/2-llvmtools/07-clang-llvm +++ b/2-llvmtools/07-clang-llvm @@ -1,192 +1,175 @@ -# llvmtools: LLVM+clang -# Build and install as cmlfs - -cd ${LLVMSRC} -# make sure compiler-rt are unpacked in ${{LLVMSRC}/projects -# and clang & lld in ${LLVMSRC}/tools. No need to unpack libunwind, -# libcxxabi and libcxxabi as all 3 are installed in /llvmtools -rm -rf projects/{libunwind,libcxx,libcxxabi} -tar xf ../pkgs/compiler-rt-12.0.0.src.tar.xz -mv compiler-rt-12.0.0.src projects/compiler-rt -tar xf ../pkgs/clang-12.0.0.src.tar.xz -tar xf ../pkgs/lld-12.0.0.src.tar.xz -mv clang-12.0.0.src tools/clang -mv lld-12.0.0.src tools/lld - -# Apply patches from void linux -cd ${LLVMSRC}/projects/compiler-rt -patch -Np1 -i ../../../patches/llvm12-compiler-rt-void/compiler-rt-aarch64-ucontext.patch -patch -Np1 -i ../../../patches/llvm12-compiler-rt-void/compiler-rt-sanitizer-ppc64-musl.patch -patch -Np1 -i ../../../patches/llvm12-compiler-rt-void/compiler-rt-size_t.patch -patch -Np1 -i ../../../patches/llvm12-compiler-rt-void/compiler-rt-xray-ppc64-musl.patch -cd ${LLVMSRC}/tools/clang -patch -Np1 -i ../../../patches/llvm12-clang-void/clang-001-fix-unwind-chain-inclusion.patch -patch -Np1 -i ../../../patches/llvm12-clang-void/clang-002-add-musl-triples.patch -patch -Np1 -i ../../../patches/llvm12-clang-void/clang-003-ppc64-dynamic-linker-path.patch -patch -Np1 -i ../../../patches/llvm12-clang-void/clang-004-ppc64-musl-elfv2.patch -cd ${LLVMSRC} -patch -Np1 -i ../patches/llvm12-void/llvm-001-musl.patch -patch -Np1 -i ../patches/llvm12-void/llvm-002-musl-ppc64-elfv2.patch -patch -Np1 -i ../patches/llvm12-void/llvm-003-ppc-secureplt.patch -patch -Np1 -i ../patches/llvm12-void/llvm-004-override-opt.patch -patch -Np1 -i ../patches/llvm12-void/llvm-005-ppc-bigpic.patch -patch -Np1 -i ../patches/llvm12-void/llvm-006-aarch64-mf_exec.patch - -# Disable sanitizers for musl systems, per Void Linux... fixes early build failure -sed -i 's/set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)/set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)/' projects/compiler-rt/cmake/config-ix.cmake - -# Fix missing header for lld, https://bugs.llvm.org/show_bug.cgi?id=49228 -tar xf ../pkgs/libunwind-12.0.0.src.tar.xz libunwind-12.0.0.src/include/mach-o/compact_unwind_encoding.h -mv libunwind-12.0.0.src/include/mach-o tools/lld/include/ -rm -rf libunwind-12.0.0.src/ +# cgnutools: Stage1 Clang ( with compiler-rt, lld) +# +# Build as cmlfs +# + +# Rename for shorter paths: +mv llvm-project-15.0.5.src llvm +export LLVMSRC=${CMLFS}/sources/llvm + +cd $LLVMSRC + +# Apply patches for main LLVM source ... from alpine linux: +patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch +patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch +patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch +patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch + +# Known broken test on musl +cd llvm +rm -v test/CodeGen/AArch64/wineh4.mir +# https://github.com/llvm/llvm-project/issues/47657 +rm -v test/ExecutionEngine/Interpreter/intrinsics.ll + +# If builing on x86, remove tests: +rm -v test/Object/macho-invalid.test test/tools/llvm-size/radix.test unittests/Support/JSONTest.cpp +sed -i "/JSONTest.cpp/d" unittests/Support/CMakeLists.txt + +# If building on arm*, remove tests: +rm -v test/tools/llvm-readobj/ELF/dependent-libraries.test test/Object/macho-invalid.test \ + test/tools/llvm-size/radix.test test/tools/gold/X86/split-dwarf.ll \ + test/ExecutionEngine/frem.ll test/tools/llvm-dwarfdump/X86/prettyprint_types.s \ + test/tools/llvm-dwarfdump/X86/simplified-template-names.s \ + unittests/ExecutionEngine/Orc/OrcCAPITest.cpp \ + test/CodeGen/RISCV/rv32zbp.ll \ + test/CodeGen/RISCV/rv64zbp.ll +sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt + +# Return to top-level +cd .. + +# Apply patches for clang +cd clang +patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch +patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch + +# Apply patches for compiler-rt +cd ../compiler-rt +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch + +# Apply patches for libcxx +cd ../libcxx +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch + +cd .. # Set flags to greatly reduce debugging symbols -export CFLAGS=" -g -g1" -export CXXFLAGS=" -g -g1" - -# Update host/target triple detection -cp -v ../files/config.guess-musl cmake/config.guess - -# Remember to use the configured stage0 clang. -# Make sure to use LLVM's binary tools from cgnutools. -export CONFIG_TOOLS="-DCMAKE_CXX_COMPILER_AR=/cgnutools/bin/llvm-ar " -export CONFIG_TOOLS+="-DCMAKE_C_COMPILER_AR=/cgnutools/bin/llvm-ar " -export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER_RANLIB=/cgnutools/bin/llvm-ranlib " -export CONFIG_TOOLS+="-DCMAKE_C_COMPILER_RANLIB=/cgnutools/bin/llvm-ranlib " -export CONFIG_TOOLS+="-DCMAKE_LINKER=/cgnutools/bin/ld.lld " -export CONFIG_TOOLS+="-DCMAKE_NM=/cgnutools/bin/llvm-nm " -export CONFIG_TOOLS+="-DCMAKE_OBJCOPY=/cgnutools/bin/llvm-objcopy " -export CONFIG_TOOLS+="-DCMAKE_READELF=/cgnutools/bin/llvm-readelf " -export CONFIG_TOOLS+="-DCMAKE_STRIP=/cgnutools/bin/llvm-strip " - -# Set the truples... -export CONFIG_TUPLES="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " -export CONFIG_TUPLES+="-DLLVM_HOST_TRIPLE=x86_64-cmlfs-linux-musl " -export CONFIG_TUPLES+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " - -# Set the flags for Compiler-rt... -export CONFIG_CRT="-DCOMPILER_RT_BUILD_SANITIZERS=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " -export CONFIG_CRT+="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON " - -# Set the flags for clang: -export CONFIG_CLANG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " -export CONFIG_CLANG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " -export CONFIG_CLANG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " -export CONFIG_CLANG+="-DCLANG_DEFAULT_LINKER=/llvmtools/bin/ld.lld " - -# Turn off unwanted features, docs and tests -export BUILD_OFF="-DLLVM_BUILD_TESTS=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_LIBEDIT=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_LIBXML2=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_GO_TESTS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_TESTS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_DOCS=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " -export BUILD_OFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " -export BUILD_OFF+="-DLLVM_ENABLE_ZLIB=OFF " - -# Turn on features for LLVM... -export CONFIG_LLVM="-DLLVM_LINK_LLVM_DYLIB=ON " -export CONFIG_LLVM+="-DLLVM_BUILD_LLVM_DYLIB=ON " -export CONFIG_LLVM+="-DLLVM_ENABLE_LIBCXX=ON " -export CONFIG_LLVM+="-DLLVM_ENABLE_LLD=ON " -export CONFIG_LLVM+="-DLLVM_ENABLE_RTTI=ON " - -# Set paths... -export CONFIG_PATHS="-DCMAKE_INSTALL_OLDINCLUDEDIR=/llvmtools/include" -export CONFIG_PATHS+="-DBacktrace_INCLUDE_DIR=/llvmtools/include " -export CONFIG_PATHS+="-DBacktrace_LIBRARY=/llvmtools/lib/libexecinfo.so " -export CONFIG_PATHS+="-DICONV_LIBRARY_PATH=/llvmtools/lib/libc.so " -export CONFIG_PATHS+="-DBacktrace_INCLUDE_DIR=/llvmtools/include " -export CONFIG_PATHS+="-DCOMPILER_RT_TERMINFO_LIB=/llvmtools/lib/libncursesw.so.6.2 " -export CONFIG_PATHS+="-DTERMINFO_LIB=/llvmtools/lib/libncursesw.so.6.2 " - -# Now configure the source -CC=x86_64-cmlfs-linux-musl-clang \ -CXX=x86_64-cmlfs-linux-musl-clang++ \ -cmake -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="/llvmtools" \ - -DLLVM_TARGET_ARCH="X86" \ - -DLLVM_TARGETS_TO_BUILD="X86" \ - -DDEFAULT_SYSROOT="/llvmtools" \ - ${CONFIG_TOOLS} ${CONFIG_TUPLES} \ - ${CONFIG_CLANG} ${CONFIG_CRT} \ - ${CONFIG_LLVM} ${CONFIG_PATHS} \ - ${BUILD_OFF} - -# Compile -make -C build - -# Install -cd build && \ -cmake -DCMAKE_INSTALL_PREFIX="/llvmtools" -P cmake_install.cmake - -# Some binaries were not installed -#for b in as readobj tblgen -#do -# cp -v build/llvm-$b /llvmtools/bin/ -#done -#ln -sv llvm-readobj /llvmtools/bin/llvm-readelf -cp -v build/bin/clang-tblgen /llvmtools/bin/ - -# Remove the LLVM source as it will not be needed until chroot -cd $CMLFS/sources && \ -rm -rf llvm - -# Configure stage1 clang to build binaries with /llvmtools/lib/ld-musl-x86_64.so.1 instead -# of /lib/ld-musl-x86_64.so.1. This is similar in Musl-LFS/LFS when gcc specs -# file is modified to use the dynamic linker in /tools instead of host's /lib -ln -sv clang-12 /llvmtools/bin/x86_64-pc-linux-musl-clang -ln -sv clang-12 /llvmtools/bin/x86_64-pc-linux-musl-clang++ -cat > /llvmtools/bin/x86_64-pc-linux-musl.cfg << "EOF" --Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1 -EOF - -# Unset these flags -unset CFLAGS CXXFLAGS - -# Create script to switch system between LLVM and binutils -# since some packages are hard coded. -cat > /llvmtools/bin/set-llvm-bin-mode << "EOF" -#! /bin/bash -echo "[ 1 / 2 ] Clearing links..." && \ -for b in ar as nm objcopy objdump size strings addr2line ranlib readelf strip -do - rm -v /llvmtools/bin/$b -done && \ -echo "[ 2 / 2 ] Setting LLVM as system binary tools..." && \ -for b in ar as nm objcopy objdump size strings -do - ln -sv llvm-$b /llvmtools/bin/$b -done && \ -ln -sv llvm-symbolizer /llvmtools/bin/addr2line && \ -ln -sv llvm-ar /llvmtools/bin/ranlib && \ -ln -sv llvm-readobj /llvmtools/bin/readelf && \ -ln -sv llvm-objcopy /llvmtools/bin/strip && \ -echo "[ info ] LLVM Binary tools set as system default" -EOF - -# Some packages are hard coded to use GCC . Create script -# to set clang/LLVM as system compiler -cat > /llvmtools/bin/set-llvm-mode << "EOF" -#! /bin/bash -echo "[ 1 / 1 ] Setting LLVM as system compiler..." && \ -for b in c++ cpp g++ gcc cc -do - rm -v /llvmtools/bin/$b - ln -sv clang-12 /llvmtools/bin/$b -done -rm -v /llvmtools/lib/cpp -ln -sv ../llvmtools/bin/clang-12 /llvmtools/lib/cpp -EOF - -# Make the scripts executable -for s in llvm-bin llvm -do - chmod -v +x /llvmtools/bin/set-$s-mode -done - +#CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' +CFLAGS="-g -g1 " +CXXFLAGS=$CFLAGS +export CFLAGS CXXFLAGS + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1" +export CTOOLS="-DCMAKE_C_COMPILER=${TARGET_TUPLE}-clang " +export CTOOLS+="-DCMAKE_CXX_COMPILER=${TARGET_TUPLE}-clang++ " +export CTOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " + +# Set the tuples & build target ... +export CTARG="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=X86 " +export CTARG+="-DLLVM_TARGET_ARCH=X86 " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=Native " + +# Set the paths ... +export CPATHS="-DCMAKE_INSTALL_PREFIX=/llvmtools " +export CPATHS+="-DDEFAULT_SYSROOT=/llvmtools " +export CPATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/llvmtools/lib " +export CPATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/llvmtools/include " + +# Set bootstrap options.. +export CBSTRAP="-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release " +export CBSTRAP+="-DCLANG_ENABLE_BOOTSTRAP=ON " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt " +export CBSTRAP+="-DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=ON " +export CBSTRAP+="-DBOOTSTRAP_LLVM_USE_LINKER=lld " +export CBSTRAP+="-DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=ON " + +# Set the standard C++ library that clang will use to LLVM's libc++: +export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " + +# Set the runtime library that clang will use to compiler-rt: +export COPTS+="-DCLANG_DEFAULT_RTLIB=compiler-rt " + +# Set libc++abi & libc++ to use compiler-rt instead of gcc's runtime: +export COPTS+="-DLIBCXX_USE_COMPILER_RT=ON " # YES--OFF? +export COPTS+="-DLIBCXXABI_USE_COMPILER_RT=ON " + +# Set libc++abi to use libunwind to avoid dependence on GCC: +export COPTS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " # YES--OFF? + +# Enable Exception Handling: +export COPTS+="-DLLVM_ENABLE_EH=ON " + +# Exception handling requires Runtime Type Info +export COPTS+="-DLLVM_ENABLE_RTTI=ON " + +# Stage 1 clang's compiler-rt will require new delete definitions in libc++ +export COPTS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON" + +# Turn off features ... +export BOFF="-DLLVM_ENABLE_LIBXML2=OFF -DLIBCXX_ENABLE_LOCALIZATION=OFF " +export BOFF+="-DLLVM_ENABLE_ZLIB=OFF -DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " +export BOFF+="-DLLVM_ENABLE_ZSTD=OFF -DLIBUNWIND_INCLUDE_TESTS=OFF " +export BOFF+="-DLLVM_ENABLE_LIBEDIT=OFF -DLIBUNWIND_INCLUDE_DOCS=OFF " + +export BOFF+="-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF " + +# Turn off features that cause compiler-rt to NOT reference backtrace symbols from libexecinfo +export BOFF+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_ORC=OFF " #-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " + +# Compile source ... with installed runtimes in llvmtools? +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="lld;clang" \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} ${BOFF} ${COPTS} -DCLANG_DEFAULT_UNWINDLIB=libunwind -DCOMPILER_RT_USE_LLVM_UNWINDER=ON \ + -DLIBUNWIND_INSTALL_HEADERS=ON -DLIBUNWIND_USE_COMPILER_RT=ON -DCOMPILER_RT_CXX_LIBRARY=libcxx -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON + +# Manually-specified variables were not used by the project: +# LIBCXXABI_USE_COMPILER_RT +# LIBCXXABI_USE_LLVM_UNWINDER +# LIBCXX_ENABLE_LOCALIZATION +# LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS +# LIBCXX_USE_COMPILER_RT + +# Compile only what we need for a stage 1 clang +ninja -C build builtins #165 targets +ninja -C build unwind #19 +ninja -C build cxxabi #829 +ninja -C build cxx #77 +ninja -C build compiler-rt # 598 ........fails. Can't find unwind.h ...and missing headers in /cgnutools/lib/clang/15.0.5/include +ninja -C build lld #1652 +ninja -C build libclang #798 +ninja -C build clang #288 + +# Configure source ... +# The llvm-project source tree seems to not use the installed LLVM runtimes +# (libc++abi,libc++, libunwind) in llvmtools. +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="compiler-rt;libunwind;libcxx;libcxxabi;lld;clang" \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} ${CBSTRAP} ${BOFF} ${COPTS} -DCLANG_DEFAULT_UNWINDLIB=libunwind -DCOMPILER_RT_USE_LLVM_UNWINDER=ON \ + -DLIBUNWIND_INSTALL_HEADERS=ON -DLIBUNWIND_USE_COMPILER_RT=ON -DCOMPILER_RT_CXX_LIBRARY=libcxx -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \ + -DCOMPILER_RT_TERMINFO_LIB=/llvmtools/lib/libcurses.so -DC_INCLUDE_DIRS=/llvmtools/include -DLLVM_ENABLE_TERMINFO=OFF \ + -DBacktrace_INCLUDE_DIR=/llvmtools/include -DLIBCXX_HAS_MUSL_LIBC=ON #-DCOMPILER_RT_BUILD_STANDALONE_LIBATOMIC=OFF + +# Compile +ninja -C build builtins +ninja -C build unwind +ninja -C build cxxabi +ninja -C build cxx # .............. Stage 0 clang still lacks atomics... need lib/clang/14.0.5/lib/linux/libclang_rt.tsan-x86_64.so ? +ninja -C build compiler-rt From f0efc5055fafc3c3394b2935d02b5cd36edabd17 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:28:29 -0600 Subject: [PATCH 006/484] Removed old patches for llvm-12.x.x --- ...clang-001-fix-unwind-chain-inclusion.patch | 44 ------- .../clang-002-add-musl-triples.patch | 110 ------------------ .../clang-003-ppc64-dynamic-linker-path.patch | 13 --- .../clang-004-ppc64-musl-elfv2.patch | 48 -------- .../compiler-rt-aarch64-ucontext.patch | 11 -- .../compiler-rt-sanitizer-ppc64-musl.patch | 35 ------ .../compiler-rt-size_t.patch | 10 -- .../compiler-rt-xray-ppc64-musl.patch | 62 ---------- patches/llvm12-libcxx-void/libcxx-musl.patch | 26 ----- patches/llvm12-libcxx-void/libcxx-ppc.patch | 22 ---- .../libcxx-ssp-nonshared.patch | 11 -- .../libunwind-ppc32.patch | 63 ---------- patches/llvm12-void/llvm-001-musl.patch | 57 --------- .../llvm-002-musl-ppc64-elfv2.patch | 30 ----- .../llvm12-void/llvm-003-ppc-secureplt.patch | 11 -- .../llvm12-void/llvm-004-override-opt.patch | 18 --- patches/llvm12-void/llvm-005-ppc-bigpic.patch | 36 ------ .../llvm-006-aarch64-mf_exec.patch | 25 ---- 18 files changed, 632 deletions(-) delete mode 100644 patches/llvm12-clang-void/clang-001-fix-unwind-chain-inclusion.patch delete mode 100644 patches/llvm12-clang-void/clang-002-add-musl-triples.patch delete mode 100644 patches/llvm12-clang-void/clang-003-ppc64-dynamic-linker-path.patch delete mode 100644 patches/llvm12-clang-void/clang-004-ppc64-musl-elfv2.patch delete mode 100644 patches/llvm12-compiler-rt-void/compiler-rt-aarch64-ucontext.patch delete mode 100644 patches/llvm12-compiler-rt-void/compiler-rt-sanitizer-ppc64-musl.patch delete mode 100644 patches/llvm12-compiler-rt-void/compiler-rt-size_t.patch delete mode 100644 patches/llvm12-compiler-rt-void/compiler-rt-xray-ppc64-musl.patch delete mode 100644 patches/llvm12-libcxx-void/libcxx-musl.patch delete mode 100644 patches/llvm12-libcxx-void/libcxx-ppc.patch delete mode 100644 patches/llvm12-libcxx-void/libcxx-ssp-nonshared.patch delete mode 100644 patches/llvm12-libunwind-void/libunwind-ppc32.patch delete mode 100644 patches/llvm12-void/llvm-001-musl.patch delete mode 100644 patches/llvm12-void/llvm-002-musl-ppc64-elfv2.patch delete mode 100644 patches/llvm12-void/llvm-003-ppc-secureplt.patch delete mode 100644 patches/llvm12-void/llvm-004-override-opt.patch delete mode 100644 patches/llvm12-void/llvm-005-ppc-bigpic.patch delete mode 100644 patches/llvm12-void/llvm-006-aarch64-mf_exec.patch diff --git a/patches/llvm12-clang-void/clang-001-fix-unwind-chain-inclusion.patch b/patches/llvm12-clang-void/clang-001-fix-unwind-chain-inclusion.patch deleted file mode 100644 index 04244bc..0000000 --- a/patches/llvm12-clang-void/clang-001-fix-unwind-chain-inclusion.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 352974169f0d2b5da3d5321f588f5e3b5941330e Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:14:57 +0200 -Subject: [PATCH 2/7] fix unwind chain inclusion - ---- - lib/Headers/unwind.h | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/lib/Headers/unwind.h b/lib/Headers/unwind.h -index 303d792..44e10cc 100644 ---- a/lib/Headers/unwind.h -+++ b/lib/Headers/unwind.h -@@ -9,9 +9,6 @@ - - /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/ - --#ifndef __CLANG_UNWIND_H --#define __CLANG_UNWIND_H -- - #if defined(__APPLE__) && __has_include_next() - /* Darwin (from 11.x on) provide an unwind.h. If that's available, - * use it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE, -@@ -39,6 +36,9 @@ - # endif - #else - -+#ifndef __CLANG_UNWIND_H -+#define __CLANG_UNWIND_H -+ - #include - - #ifdef __cplusplus -@@ -322,6 +322,7 @@ _Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *); - } - #endif - -+#endif /* __CLANG_UNWIND_H */ -+ - #endif - --#endif /* __CLANG_UNWIND_H */ --- -2.5.1 diff --git a/patches/llvm12-clang-void/clang-002-add-musl-triples.patch b/patches/llvm12-clang-void/clang-002-add-musl-triples.patch deleted file mode 100644 index 6945e7f..0000000 --- a/patches/llvm12-clang-void/clang-002-add-musl-triples.patch +++ /dev/null @@ -1,110 +0,0 @@ ---- a/lib/Driver/ToolChains/Gnu.cpp -+++ b/lib/Driver/ToolChains/Gnu.cpp -@@ -2086,7 +2086,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( - static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", - "armv7hl-redhat-linux-gnueabi", - "armv6hl-suse-linux-gnueabi", -- "armv7hl-suse-linux-gnueabi"}; -+ "armv7hl-suse-linux-gnueabi", -+ "armv7l-linux-gnueabihf"}; - static const char *const ARMebLibDirs[] = {"/lib"}; - static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", - "armeb-linux-androideabi"}; -@@ -2153,8 +2154,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( - "powerpc64-suse-linux", "powerpc-montavista-linuxspe"}; - static const char *const PPCLELibDirs[] = {"/lib32", "/lib"}; - static const char *const PPCLETriples[] = {"powerpcle-linux-gnu", -- "powerpcle-unknown-linux-gnu", -- "powerpcle-linux-musl"}; -+ "powerpcle-unknown-linux-gnu"}; - - static const char *const PPC64LibDirs[] = {"/lib64", "/lib"}; - static const char *const PPC64Triples[] = { -@@ -2235,6 +2235,87 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( - return; - } - -+ if (TargetTriple.isMusl()) { -+ static const char *const AArch64MuslTriples[] = {"aarch64-linux-musl"}; -+ static const char *const ARMHFMuslTriples[] = { -+ "arm-linux-musleabihf", "armv7l-linux-musleabihf" -+ }; -+ static const char *const ARMMuslTriples[] = {"arm-linux-musleabi"}; -+ static const char *const X86_64MuslTriples[] = {"x86_64-linux-musl"}; -+ static const char *const X86MuslTriples[] = {"i686-linux-musl"}; -+ static const char *const MIPSMuslTriples[] = { -+ "mips-linux-musl", "mipsel-linux-musl", -+ "mipsel-linux-muslhf", "mips-linux-muslhf" -+ }; -+ static const char *const PPCMuslTriples[] = {"powerpc-linux-musl"}; -+ static const char *const PPCLEMuslTriples[] = {"powerpcle-linux-musl"}; -+ static const char *const PPC64MuslTriples[] = {"powerpc64-linux-musl"}; -+ static const char *const PPC64LEMuslTriples[] = {"powerpc64le-linux-musl"}; -+ -+ switch (TargetTriple.getArch()) { -+ case llvm::Triple::aarch64: -+ LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs)); -+ TripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples)); -+ BiarchLibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs)); -+ BiarchTripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples)); -+ break; -+ case llvm::Triple::arm: -+ LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); -+ if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { -+ TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples)); -+ } else { -+ TripleAliases.append(begin(ARMMuslTriples), end(ARMMuslTriples)); -+ } -+ break; -+ case llvm::Triple::x86_64: -+ LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); -+ TripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples)); -+ BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs)); -+ BiarchTripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples)); -+ break; -+ case llvm::Triple::x86: -+ LibDirs.append(begin(X86LibDirs), end(X86LibDirs)); -+ TripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples)); -+ BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); -+ BiarchTripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples)); -+ break; -+ case llvm::Triple::mips: -+ LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs)); -+ TripleAliases.append(begin(MIPSMuslTriples), end(MIPSMuslTriples)); -+ break; -+ case llvm::Triple::ppc: -+ LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs)); -+ TripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples)); -+ BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs)); -+ BiarchTripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples)); -+ break; -+ case llvm::Triple::ppcle: -+ LibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs)); -+ TripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples)); -+ BiarchLibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs)); -+ BiarchTripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples)); -+ break; -+ case llvm::Triple::ppc64: -+ LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs)); -+ TripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples)); -+ BiarchLibDirs.append(begin(PPCLibDirs), end(PPCLibDirs)); -+ BiarchTripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples)); -+ break; -+ case llvm::Triple::ppc64le: -+ LibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs)); -+ TripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples)); -+ BiarchLibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs)); -+ BiarchTripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples)); -+ break; -+ default: -+ break; -+ } -+ TripleAliases.push_back(TargetTriple.str()); -+ if (TargetTriple.str() != BiarchTriple.str()) -+ BiarchTripleAliases.push_back(BiarchTriple.str()); -+ return; -+ } -+ - // Android targets should not use GNU/Linux tools or libraries. - if (TargetTriple.isAndroid()) { - static const char *const AArch64AndroidTriples[] = { diff --git a/patches/llvm12-clang-void/clang-003-ppc64-dynamic-linker-path.patch b/patches/llvm12-clang-void/clang-003-ppc64-dynamic-linker-path.patch deleted file mode 100644 index afc0810..0000000 --- a/patches/llvm12-clang-void/clang-003-ppc64-dynamic-linker-path.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/lib/Driver/ToolChains/Linux.cpp -+++ b/lib/Driver/ToolChains/Linux.cpp -@@ -504,10 +504,6 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const { - Loader = "ld.so.1"; - break; - case llvm::Triple::ppc64: -- LibDir = "lib64"; -- Loader = -- (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1"; -- break; - case llvm::Triple::ppc64le: - LibDir = "lib64"; - Loader = diff --git a/patches/llvm12-clang-void/clang-004-ppc64-musl-elfv2.patch b/patches/llvm12-clang-void/clang-004-ppc64-musl-elfv2.patch deleted file mode 100644 index 912094e..0000000 --- a/patches/llvm12-clang-void/clang-004-ppc64-musl-elfv2.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/lib/Basic/Targets/PPC.h -+++ b/lib/Basic/Targets/PPC.h -@@ -415,11 +415,10 @@ public: - LongDoubleFormat = &llvm::APFloat::IEEEdouble(); - } else if ((Triple.getArch() == llvm::Triple::ppc64le)) { - DataLayout = "e-m:e-i64:64-n32:64"; -- ABI = "elfv2"; - } else { - DataLayout = "E-m:e-i64:64-n32:64"; -- ABI = "elfv1"; - } -+ ABI = "elfv2"; - - if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) { - LongDoubleWidth = LongDoubleAlign = 64; ---- a/lib/CodeGen/TargetInfo.cpp -+++ b/lib/CodeGen/TargetInfo.cpp -@@ -10927,9 +10927,9 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() { - return SetCGInfo(new AIXTargetCodeGenInfo(Types, /*Is64Bit*/ true)); - - if (Triple.isOSBinFormatELF()) { -- PPC64_SVR4_ABIInfo::ABIKind Kind = PPC64_SVR4_ABIInfo::ELFv1; -- if (getTarget().getABI() == "elfv2") -- Kind = PPC64_SVR4_ABIInfo::ELFv2; -+ PPC64_SVR4_ABIInfo::ABIKind Kind = PPC64_SVR4_ABIInfo::ELFv2; -+ if (getTarget().getABI() == "elfv1") -+ Kind = PPC64_SVR4_ABIInfo::ELFv1; - bool IsSoftFloat = CodeGenOpts.FloatABI == "soft"; - - return SetCGInfo( ---- a/lib/Driver/ToolChains/Clang.cpp -+++ b/lib/Driver/ToolChains/Clang.cpp -@@ -1920,14 +1920,7 @@ void Clang::AddPPCTargetArgs(const ArgList &Args, - const llvm::Triple &T = getToolChain().getTriple(); - if (T.isOSBinFormatELF()) { - switch (getToolChain().getArch()) { -- case llvm::Triple::ppc64: { -- if ((T.isOSFreeBSD() && T.getOSMajorVersion() >= 13) || -- T.isOSOpenBSD() || T.isMusl()) -- ABIName = "elfv2"; -- else -- ABIName = "elfv1"; -- break; -- } -+ case llvm::Triple::ppc64: - case llvm::Triple::ppc64le: - ABIName = "elfv2"; - break; diff --git a/patches/llvm12-compiler-rt-void/compiler-rt-aarch64-ucontext.patch b/patches/llvm12-compiler-rt-void/compiler-rt-aarch64-ucontext.patch deleted file mode 100644 index 49689ca..0000000 --- a/patches/llvm12-compiler-rt-void/compiler-rt-aarch64-ucontext.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp.orig -+++ compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp -@@ -1799,7 +1799,7 @@ - - static bool Aarch64GetESR(ucontext_t *ucontext, u64 *esr) { - static const u32 kEsrMagic = 0x45535201; -- u8 *aux = ucontext->uc_mcontext.__reserved; -+ u8 *aux = reinterpret_cast(ucontext->uc_mcontext.__reserved); - while (true) { - _aarch64_ctx *ctx = (_aarch64_ctx *)aux; - if (ctx->size == 0) break; diff --git a/patches/llvm12-compiler-rt-void/compiler-rt-sanitizer-ppc64-musl.patch b/patches/llvm12-compiler-rt-void/compiler-rt-sanitizer-ppc64-musl.patch deleted file mode 100644 index a776e82..0000000 --- a/patches/llvm12-compiler-rt-void/compiler-rt-sanitizer-ppc64-musl.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/lib/sanitizer_common/sanitizer_linux.cpp -+++ b/lib/sanitizer_common/sanitizer_linux.cpp -@@ -74,6 +74,10 @@ - #include - #endif - -+#if SANITIZER_LINUX && defined(__powerpc__) -+#include -+#endif -+ - #if SANITIZER_LINUX && !SANITIZER_ANDROID - #include - #endif ---- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp -@@ -92,7 +92,7 @@ - # include - # include - #if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \ -- SANITIZER_RISCV64 -+ defined(__powerpc__) || SANITIZER_RISCV64 - # include - # ifdef __arm__ - typedef struct user_fpregs elf_fpregset_t; ---- a/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp -+++ b/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp -@@ -31,7 +31,7 @@ - #include // for pid_t - #include // for iovec - #include // for NT_PRSTATUS --#if (defined(__aarch64__) || SANITIZER_RISCV64) && !SANITIZER_ANDROID -+#if (defined(__aarch64__) || defined(__powerpc__) || SANITIZER_RISCV64) && !SANITIZER_ANDROID - // GLIBC 2.20+ sys/user does not include asm/ptrace.h - # include - #endif diff --git a/patches/llvm12-compiler-rt-void/compiler-rt-size_t.patch b/patches/llvm12-compiler-rt-void/compiler-rt-size_t.patch deleted file mode 100644 index 2c943d9..0000000 --- a/patches/llvm12-compiler-rt-void/compiler-rt-size_t.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp.orig -+++ compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp -@@ -25,6 +25,7 @@ - } - - #include -+#include - #include - #include // for dlsym() - diff --git a/patches/llvm12-compiler-rt-void/compiler-rt-xray-ppc64-musl.patch b/patches/llvm12-compiler-rt-void/compiler-rt-xray-ppc64-musl.patch deleted file mode 100644 index 6db37ce..0000000 --- a/patches/llvm12-compiler-rt-void/compiler-rt-xray-ppc64-musl.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- a/lib/xray/xray_powerpc64.inc -+++ b/lib/xray/xray_powerpc64.inc -@@ -12,7 +12,13 @@ - - #include - #include -+#ifdef __GLIBC__ - #include -+#else -+#include -+#include -+#include -+#endif - - #include "xray_defs.h" - -@@ -20,13 +26,45 @@ namespace __xray { - - ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT { - CPU = 0; -+#ifdef __GLIBC__ - return __ppc_get_timebase(); -+#else -+ return __builtin_ppc_get_timebase(); -+#endif - } - - inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT { - static std::mutex M; - std::lock_guard Guard(M); -+#ifdef __GLIBC__ - return __ppc_get_timebase_freq(); -+#else -+ /* FIXME: a less dirty implementation? */ -+ static uint64_t base; -+ if (!base) { -+ FILE *f = fopen("/proc/cpuinfo", "rb"); -+ if (f) { -+ ssize_t nr; -+ /* virtually always big enough to hold the line */ -+ char buf[512]; -+ while (fgets(buf, sizeof(buf), f)) { -+ char *ret = strstr(buf, "timebase"); -+ if (!ret) { -+ continue; -+ } -+ ret += sizeof("timebase") - 1; -+ ret = strchr(ret, ':'); -+ if (!ret) { -+ continue; -+ } -+ base = strtoul(ret + 1, nullptr, 10); -+ break; -+ } -+ fclose(f); -+ } -+ } -+ return base; -+#endif - } - - inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT { diff --git a/patches/llvm12-libcxx-void/libcxx-musl.patch b/patches/llvm12-libcxx-void/libcxx-musl.patch deleted file mode 100644 index f6068f7..0000000 --- a/patches/llvm12-libcxx-void/libcxx-musl.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/include/locale -+++ b/include/locale -@@ -742,7 +742,11 @@ __num_get_signed_integral(const char* __a, const char* __a_end, - typename remove_reference::type __save_errno = errno; - errno = 0; - char *__p2; -+#if defined(__linux__) && !defined(__GLIBC__) -+ long long __ll = strtoll(__a, &__p2, __base); -+#else - long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); -+#endif - typename remove_reference::type __current_errno = errno; - if (__current_errno == 0) - errno = __save_errno; -@@ -782,7 +786,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, - typename remove_reference::type __save_errno = errno; - errno = 0; - char *__p2; -+#if defined(__linux__) && !defined(__GLIBC__) -+ unsigned long long __ll = strtoull(__a, &__p2, __base); -+#else - unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); -+#endif - typename remove_reference::type __current_errno = errno; - if (__current_errno == 0) - errno = __save_errno; diff --git a/patches/llvm12-libcxx-void/libcxx-ppc.patch b/patches/llvm12-libcxx-void/libcxx-ppc.patch deleted file mode 100644 index b1a7bab..0000000 --- a/patches/llvm12-libcxx-void/libcxx-ppc.patch +++ /dev/null @@ -1,22 +0,0 @@ -This ensures `is_iec559` is defined correctly under all long double ABIs, -including musl and its 64-bit long double. Also, `__ppc__` or `__ppc64__` -is not defined on gcc. - ---- a/include/limits -+++ b/include/limits -@@ -426,8 +426,14 @@ protected: - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");} - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;} - --#if (defined(__ppc__) || defined(__ppc64__)) -+#if defined(__powerpc__) || defined(__powerpc64__) -+#if (__LDBL_MAX_EXP__ > __DBL_MAX_EXP__) || (__LDBL_MANT_DIG__ == __DBL_MANT_DIG__) -+ /* IEEE 754 quadruple or double precision */ -+ static _LIBCPP_CONSTEXPR const bool is_iec559 = true; -+#else -+ /* 128-bit IBM double-double */ - static _LIBCPP_CONSTEXPR const bool is_iec559 = false; -+#endif - #else - static _LIBCPP_CONSTEXPR const bool is_iec559 = true; - #endif diff --git a/patches/llvm12-libcxx-void/libcxx-ssp-nonshared.patch b/patches/llvm12-libcxx-void/libcxx-ssp-nonshared.patch deleted file mode 100644 index 86ce396..0000000 --- a/patches/llvm12-libcxx-void/libcxx-ssp-nonshared.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -769,6 +769,8 @@ function(cxx_link_system_libraries target) - target_link_libraries(${target} PRIVATE atomic) - endif() - -+#ssp target_link_libraries(${target} PRIVATE ssp_nonshared) -+ - if (MINGW) - target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}") - endif() diff --git a/patches/llvm12-libunwind-void/libunwind-ppc32.patch b/patches/llvm12-libunwind-void/libunwind-ppc32.patch deleted file mode 100644 index 08fdb99..0000000 --- a/patches/llvm12-libunwind-void/libunwind-ppc32.patch +++ /dev/null @@ -1,63 +0,0 @@ -This fixes build at least with gcc9 which does not define `__ppc__`. - ---- a/include/__libunwind_config.h -+++ b/include/__libunwind_config.h -@@ -49,7 +49,7 @@ - # define _LIBUNWIND_CONTEXT_SIZE 167 - # define _LIBUNWIND_CURSOR_SIZE 179 - # define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 --# elif defined(__ppc__) -+# elif defined(__powerpc__) - # define _LIBUNWIND_TARGET_PPC 1 - # define _LIBUNWIND_CONTEXT_SIZE 117 - # define _LIBUNWIND_CURSOR_SIZE 124 ---- a/src/UnwindRegistersRestore.S -+++ b/src/UnwindRegistersRestore.S -@@ -392,7 +392,7 @@ Lnovec: - PPC64_LR(3) - bctr - --#elif defined(__ppc__) -+#elif defined(__powerpc__) - - DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv) - // ---- a/src/UnwindRegistersSave.S -+++ b/src/UnwindRegistersSave.S -@@ -554,7 +554,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) - blr - - --#elif defined(__ppc__) -+#elif defined(__powerpc__) - - // - // extern int unw_getcontext(unw_context_t* thread_state) ---- a/src/config.h -+++ b/src/config.h -@@ -95,12 +95,12 @@ - #define _LIBUNWIND_BUILD_SJLJ_APIS - #endif - --#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) -+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__powerpc64__) - #define _LIBUNWIND_SUPPORT_FRAME_APIS - #endif - - #if defined(__i386__) || defined(__x86_64__) || \ -- defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) || \ -+ defined(__powerpc__) || defined(__powerpc64__) || \ - (!defined(__APPLE__) && defined(__arm__)) || \ - (defined(__arm64__) || defined(__aarch64__)) || \ - defined(__mips__) ---- a/src/libunwind.cpp -+++ b/src/libunwind.cpp -@@ -42,7 +42,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor, - # define REGISTER_KIND Registers_x86_64 - #elif defined(__powerpc64__) - # define REGISTER_KIND Registers_ppc64 --#elif defined(__ppc__) -+#elif defined(__powerpc__) - # define REGISTER_KIND Registers_ppc - #elif defined(__aarch64__) - # define REGISTER_KIND Registers_arm64 diff --git a/patches/llvm12-void/llvm-001-musl.patch b/patches/llvm12-void/llvm-001-musl.patch deleted file mode 100644 index 0204a89..0000000 --- a/patches/llvm12-void/llvm-001-musl.patch +++ /dev/null @@ -1,57 +0,0 @@ -From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001 -From: Andrea Brancaleoni -Date: Tue, 8 Sep 2015 22:03:02 +0200 -Subject: [PATCH 3/3] musl - ---- - include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++ - lib/Support/DynamicLibrary.cpp | 2 +- - lib/Support/Unix/Signals.inc | 6 +++--- - utils/unittest/googletest/src/gtest.cc | 1 + - 5 files changed, 17 insertions(+), 6 deletions(-) - -diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h -index 34a8a1e3..1214ece5 100644 ---- a/include/llvm/Analysis/TargetLibraryInfo.h -+++ b/include/llvm/Analysis/TargetLibraryInfo.h -@@ -18,6 +18,15 @@ - #include "llvm/IR/PassManager.h" - #include "llvm/Pass.h" - -+#undef fopen64 -+#undef fseeko64 -+#undef fstat64 -+#undef fstatvfs64 -+#undef ftello64 -+#undef lstat64 -+#undef stat64 -+#undef tmpfile64 -+ - namespace llvm { - template class ArrayRef; - class Triple; -diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc -index a2a37996..2f86c470 100644 ---- a/lib/Support/Unix/DynamicLibrary.inc -+++ b/lib/Support/Unix/DynamicLibrary.inc -@@ -102,7 +102,7 @@ static void *DoSearch(const char* SymbolName) { - - // This macro returns the address of a well-known, explicit symbol - #define EXPLICIT_SYMBOL(SYM) \ -- if (!strcmp(SymbolName, #SYM)) return &SYM -+ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM - - // Under glibc we have a weird situation. The stderr/out/in symbols are both - // macros and global variables because of standards requirements. So, we -diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc -index d882ab2e..f1fb12d0 100644 ---- a/utils/unittest/googletest/src/gtest.cc -+++ b/utils/unittest/googletest/src/gtest.cc -@@ -128,6 +128,7 @@ - - #if GTEST_CAN_STREAM_RESULTS_ - # include // NOLINT -+# include // NOLINT - # include // NOLINT - # include // NOLINT - # include // NOLINT diff --git a/patches/llvm12-void/llvm-002-musl-ppc64-elfv2.patch b/patches/llvm12-void/llvm-002-musl-ppc64-elfv2.patch deleted file mode 100644 index fb842cf..0000000 --- a/patches/llvm12-void/llvm-002-musl-ppc64-elfv2.patch +++ /dev/null @@ -1,30 +0,0 @@ -This patches LLVM to use ELFv2 on ppc64 unconditionally unless overridden. We -need this because unlike most distros we use ELFv2 for both glibc and musl -on big endian ppc64. - -diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp -index 0634833e..b7cbc2e7 100644 ---- a/lib/Target/PowerPC/PPCTargetMachine.cpp -+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp -@@ -222,9 +222,8 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT, - - switch (TT.getArch()) { - case Triple::ppc64le: -- return PPCTargetMachine::PPC_ABI_ELFv2; - case Triple::ppc64: -- return PPCTargetMachine::PPC_ABI_ELFv1; -+ return PPCTargetMachine::PPC_ABI_ELFv2; - default: - return PPCTargetMachine::PPC_ABI_UNKNOWN; - } -diff --git a/test/CodeGen/PowerPC/ppc64-elf-abi.ll b/test/CodeGen/PowerPC/ppc64-elf-abi.ll -index 8b1cf6b5..296a2afa 100644 ---- a/test/CodeGen/PowerPC/ppc64-elf-abi.ll -+++ b/test/CodeGen/PowerPC/ppc64-elf-abi.ll -@@ -1,4 +1,5 @@ --; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv1 -+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2 -+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-musl < %s | FileCheck %s -check-prefix=CHECK-ELFv2 - ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1 - ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2 - ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2 diff --git a/patches/llvm12-void/llvm-003-ppc-secureplt.patch b/patches/llvm12-void/llvm-003-ppc-secureplt.patch deleted file mode 100644 index b9e60d5..0000000 --- a/patches/llvm12-void/llvm-003-ppc-secureplt.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- llvm/lib/Target/PowerPC/PPCSubtarget.cpp -+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp -@@ -165,7 +165,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { - - if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) || - TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() || -- TargetTriple.isMusl()) -+ isTargetLinux()) - SecurePlt = true; - - if (HasSPE && IsPPC64) diff --git a/patches/llvm12-void/llvm-004-override-opt.patch b/patches/llvm12-void/llvm-004-override-opt.patch deleted file mode 100644 index 3f5276c..0000000 --- a/patches/llvm12-void/llvm-004-override-opt.patch +++ /dev/null @@ -1,18 +0,0 @@ -This allows us to override the optimization level as not all platforms can -deal with -O3. - ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -918,6 +918,12 @@ if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) - llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2") - endif() - -+set(VOID_CXX_OPT_FLAGS "" CACHE STRING "Optimization level to use") -+ -+if (NOT VOID_CXX_OPT_FLAGS STREQUAL "") -+ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "${VOID_CXX_OPT_FLAGS}") -+endif() -+ - # Put this before tblgen. Else we have a circular dependence. - add_subdirectory(lib/Demangle) - add_subdirectory(lib/Support) diff --git a/patches/llvm12-void/llvm-005-ppc-bigpic.patch b/patches/llvm12-void/llvm-005-ppc-bigpic.patch deleted file mode 100644 index d0c0cdb..0000000 --- a/patches/llvm12-void/llvm-005-ppc-bigpic.patch +++ /dev/null @@ -1,36 +0,0 @@ -From f3dbdd49c06bfafc1d6138094cf42889c14d38b6 Mon Sep 17 00:00:00 2001 -From: Samuel Holland -Date: Sun, 3 Nov 2019 10:57:27 -0600 -Subject: [PATCH] [LLVM][PowerPC] Assume BigPIC if no PIC level is specified - ---- - llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +- - llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp -index cce21f32..87ca5f9b 100644 ---- a/lib/Target/PowerPC/PPCAsmPrinter.cpp -+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp -@@ -520,7 +520,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI, - - // Add 32768 offset to the symbol so we follow up the latest GOT/PLT ABI. - if (Kind == MCSymbolRefExpr::VK_PLT && Subtarget->isSecurePlt() && -- M->getPICLevel() == PICLevel::BigPIC) -+ M->getPICLevel() != PICLevel::SmallPIC) - TlsRef = MCBinaryExpr::createAdd( - TlsRef, MCConstantExpr::create(32768, OutContext), OutContext); - const MachineOperand &MO = MI->getOperand(2); -diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp -index 5cc180d7..a5b02565 100644 ---- a/lib/Target/PowerPC/PPCMCInstLower.cpp -+++ b/lib/Target/PowerPC/PPCMCInstLower.cpp -@@ -117,7 +117,7 @@ static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, - const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, RefKind, Ctx); - // If -msecure-plt -fPIC, add 32768 to symbol. - if (Subtarget->isSecurePlt() && TM.isPositionIndependent() && -- M->getPICLevel() == PICLevel::BigPIC && -+ M->getPICLevel() != PICLevel::SmallPIC && - MO.getTargetFlags() == PPCII::MO_PLT) - Expr = - MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(32768, Ctx), Ctx); diff --git a/patches/llvm12-void/llvm-006-aarch64-mf_exec.patch b/patches/llvm12-void/llvm-006-aarch64-mf_exec.patch deleted file mode 100644 index 098d748..0000000 --- a/patches/llvm12-void/llvm-006-aarch64-mf_exec.patch +++ /dev/null @@ -1,25 +0,0 @@ -Fix failures in AllocationTests/MappedMemoryTest.* on aarch64: - - Failing Tests (8): - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3 - LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3 - -Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10 - ---- a/lib/Support/Unix/Memory.inc -+++ b/lib/Support/Unix/Memory.inc -@@ -58,7 +58,7 @@ static int getPosixProtectionFlags(unsigned Flags) { - return PROT_READ | PROT_WRITE | PROT_EXEC; - case llvm::sys::Memory::MF_EXEC: - #if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \ -- defined(_POWER) || defined(_ARCH_PPC)) -+ defined(_POWER) || defined(_ARCH_PPC) || (defined(__linux__) && defined(__aarch64__))) - // On PowerPC, having an executable page that has no read permission - // can have unintended consequences. The function InvalidateInstruction- - // Cache uses instructions dcbf and icbi, both of which are treated by From 8805fe5b23b9d97878ecf86752fef7e7a68cec1d Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:30:36 -0600 Subject: [PATCH 007/484] Removed old patches for gcc-11.2.0 --- .../0001-posix_memalign.patch | 42 -- .../0002-gcc-poison-system-directories.patch | 203 --------- ...-Turn-on-Wl-z-relro-z-now-by-default.patch | 39 -- ...Y_SOURCE-2-by-default-for-C-C-ObjC-O.patch | 46 -- ...-pass-as-needed-by-default-to-the-li.patch | 242 ---------- ...rmat-and-Wformat-security-by-default.patch | 34 -- .../0007-Enable-Wtrampolines-by-default.patch | 25 -- ...ostdlib-nodefaultlibs-and-ffreestand.patch | 45 -- ...mt-doesn-t-encounter-problems-during.patch | 54 --- ...clare-asprintf-if-defined-as-a-macro.patch | 28 -- ...opy-PIC-objects-during-build-process.patch | 24 - .../0012-libitm-disable-FORTIFY.patch | 33 -- patches/gcc-11.2.0-alpine/0013-libgcc_s.patch | 57 --- patches/gcc-11.2.0-alpine/0014-nopie.patch | 75 ---- ...ux__-instead-of-__gnu_linux__-for-mu.patch | 25 -- .../0016-dlang-update-zlib-binding.patch | 425 ------------------ ...ix-fcntl-on-mips-add-libucontext-dep.patch | 51 --- .../0018-ada-fix-shared-linking.patch | 42 -- ...build-fix-CXXFLAGS_FOR_BUILD-passing.patch | 24 - .../0020-add-fortify-headers-paths.patch | 25 -- ...age-provides-libssp_nonshared.a.-We-.patch | 31 -- ...e-pop-state-for-gold-as-well-when-li.patch | 69 --- .../0023-Pure-64-bit-MIPS.patch | 47 -- ...-bit-configuration-where-appropriate.patch | 121 ----- .../0025-always-build-libgcc_eh.a.patch | 51 --- ...-ada-libgnarl-compatibility-for-musl.patch | 133 ------ .../0027-ada-musl-support-fixes.patch | 223 --------- ...o-Use-_off_t-type-instead-of-_loff_t.patch | 48 -- ...0029-gcc-go-Don-t-include-sys-user.h.patch | 30 -- .../0030-gcc-go-Fix-ucontext_t-on-PPC64.patch | 29 -- ...go-Fix-handling-of-signal-34-on-musl.patch | 43 -- ...t64-type-as-offset-argument-for-mmap.patch | 38 -- ...-m-c-tim-fields-in-generated-sysinfo.patch | 24 - ...go-signal-34-is-special-on-musl-libc.patch | 29 -- ...5-gcc-go-Prefer-_off_t-over-_off64_t.patch | 30 -- ...ef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch | 27 -- .../0037-gcc-go-link-to-libucontext.patch | 25 -- ...rinting-of-unaccessible-ppc64-struct.patch | 26 -- ...able-autolink-libatomic-use-in-LINK_.patch | 264 ----------- ...ric-errstr.go-implementation-on-musl.patch | 48 -- ...ostdlib-nodefaultlibs-and-ffreestand.patch | 21 - ...able-autolink-libatomic-use-in-LINK_.patch | 21 - patches/gcc-11.2.0-alpine/apply_patches_ct.sh | 40 -- 43 files changed, 2957 deletions(-) delete mode 100644 patches/gcc-11.2.0-alpine/0001-posix_memalign.patch delete mode 100644 patches/gcc-11.2.0-alpine/0002-gcc-poison-system-directories.patch delete mode 100644 patches/gcc-11.2.0-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch delete mode 100644 patches/gcc-11.2.0-alpine/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch delete mode 100644 patches/gcc-11.2.0-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch delete mode 100644 patches/gcc-11.2.0-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch delete mode 100644 patches/gcc-11.2.0-alpine/0007-Enable-Wtrampolines-by-default.patch delete mode 100644 patches/gcc-11.2.0-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch delete mode 100644 patches/gcc-11.2.0-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch delete mode 100644 patches/gcc-11.2.0-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch delete mode 100644 patches/gcc-11.2.0-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch delete mode 100644 patches/gcc-11.2.0-alpine/0012-libitm-disable-FORTIFY.patch delete mode 100644 patches/gcc-11.2.0-alpine/0013-libgcc_s.patch delete mode 100644 patches/gcc-11.2.0-alpine/0014-nopie.patch delete mode 100644 patches/gcc-11.2.0-alpine/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch delete mode 100644 patches/gcc-11.2.0-alpine/0016-dlang-update-zlib-binding.patch delete mode 100644 patches/gcc-11.2.0-alpine/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch delete mode 100644 patches/gcc-11.2.0-alpine/0018-ada-fix-shared-linking.patch delete mode 100644 patches/gcc-11.2.0-alpine/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch delete mode 100644 patches/gcc-11.2.0-alpine/0020-add-fortify-headers-paths.patch delete mode 100644 patches/gcc-11.2.0-alpine/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch delete mode 100644 patches/gcc-11.2.0-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch delete mode 100644 patches/gcc-11.2.0-alpine/0023-Pure-64-bit-MIPS.patch delete mode 100644 patches/gcc-11.2.0-alpine/0024-use-pure-64-bit-configuration-where-appropriate.patch delete mode 100644 patches/gcc-11.2.0-alpine/0025-always-build-libgcc_eh.a.patch delete mode 100644 patches/gcc-11.2.0-alpine/0026-ada-libgnarl-compatibility-for-musl.patch delete mode 100644 patches/gcc-11.2.0-alpine/0027-ada-musl-support-fixes.patch delete mode 100644 patches/gcc-11.2.0-alpine/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch delete mode 100644 patches/gcc-11.2.0-alpine/0029-gcc-go-Don-t-include-sys-user.h.patch delete mode 100644 patches/gcc-11.2.0-alpine/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch delete mode 100644 patches/gcc-11.2.0-alpine/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch delete mode 100644 patches/gcc-11.2.0-alpine/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch delete mode 100644 patches/gcc-11.2.0-alpine/0033-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch delete mode 100644 patches/gcc-11.2.0-alpine/0034-gcc-go-signal-34-is-special-on-musl-libc.patch delete mode 100644 patches/gcc-11.2.0-alpine/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch delete mode 100644 patches/gcc-11.2.0-alpine/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch delete mode 100644 patches/gcc-11.2.0-alpine/0037-gcc-go-link-to-libucontext.patch delete mode 100644 patches/gcc-11.2.0-alpine/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch delete mode 100644 patches/gcc-11.2.0-alpine/0040-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch delete mode 100644 patches/gcc-11.2.0-alpine/0041-Use-generic-errstr.go-implementation-on-musl.patch delete mode 100644 patches/gcc-11.2.0-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch delete mode 100644 patches/gcc-11.2.0-alpine/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch delete mode 100755 patches/gcc-11.2.0-alpine/apply_patches_ct.sh diff --git a/patches/gcc-11.2.0-alpine/0001-posix_memalign.patch b/patches/gcc-11.2.0-alpine/0001-posix_memalign.patch deleted file mode 100644 index 50d489d..0000000 --- a/patches/gcc-11.2.0-alpine/0001-posix_memalign.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0f6c64b962bb3bf75f15aec350a9d6f8997fa814 Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Fri, 26 Jan 2018 20:32:50 +0000 -Subject: [PATCH] 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 87344d9383f..ece428df487 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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0002-gcc-poison-system-directories.patch b/patches/gcc-11.2.0-alpine/0002-gcc-poison-system-directories.patch deleted file mode 100644 index 44a79d2..0000000 --- a/patches/gcc-11.2.0-alpine/0002-gcc-poison-system-directories.patch +++ /dev/null @@ -1,203 +0,0 @@ -From 2f5ca6e3850401c628c5cc18cd606134e8b29113 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Fri, 29 Mar 2013 08:59:00 +0400 -Subject: [PATCH] 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.c | 2 ++ - gcc/incpath.c | 21 +++++++++++++++++++++ - 7 files changed, 68 insertions(+) - -diff --git a/gcc/common.opt b/gcc/common.opt -index ec5235c3a41..ca942863064 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -682,6 +682,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 364eba47737..9551c0dfdf9 100644 ---- a/gcc/config.in -+++ b/gcc/config.in -@@ -224,6 +224,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 8fe9c91fd7c..17b878e4b4e 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -1010,6 +1010,7 @@ with_system_zlib - enable_maintainer_mode - enable_link_mutex - enable_version_specific_runtime_libs -+enable_poison_system_directories - enable_plugin - enable_host_shared - enable_libquadmath_support -@@ -1766,6 +1767,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 -@@ -30276,6 +30279,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 84dceb8074a..bf64ffbe46f 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -6608,6 +6608,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 eabeec944e7..cd31b522e42 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -348,6 +348,7 @@ Objective-C and Objective-C++ Dialects}. - -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol - -Wparentheses -Wno-pedantic-ms-format @gol - -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol -+-Wno-poison-system-directories @gol - -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol - -Wrestrict -Wno-return-local-addr -Wreturn-type @gol - -Wno-scalar-storage-order -Wsequence-point @gol -@@ -6926,6 +6927,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. - -+@item -Wno-poison-system-directories -+@opindex 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. -+ - @item -Wfloat-equal - @opindex Wfloat-equal - @opindex Wno-float-equal -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 9f790db0daf..b2200c5185a 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1041,6 +1041,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.c b/gcc/incpath.c -index 8a2bda00f80..9098ab044ab 100644 ---- a/gcc/incpath.c -+++ b/gcc/incpath.c -@@ -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. */ -@@ -393,6 +394,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch b/patches/gcc-11.2.0-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch deleted file mode 100644 index 334d17e..0000000 --- a/patches/gcc-11.2.0-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch +++ /dev/null @@ -1,39 +0,0 @@ -From ef512b8fcf9c7628267ff2dbb127aa094f6754f3 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:45:49 +0000 -Subject: [PATCH] Turn on -Wl,-z,relro,-z,now by default. - ---- - gcc/doc/invoke.texi | 3 +++ - gcc/gcc.c | 1 + - 2 files changed, 4 insertions(+) - -diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index cd31b522e42..17d371ef432 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -14663,6 +14663,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,relro,now} is used. To disable, use @option{-Wl,-z,norelro}. -+ - @item -u @var{symbol} - @opindex u - Pretend the symbol @var{symbol} is undefined, to force linking of -diff --git a/gcc/gcc.c b/gcc/gcc.c -index b2200c5185a..625c9ab7902 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1039,6 +1039,7 @@ proper position among the other output files. */ - "%{flto|flto=*:% -Date: Fri, 21 Aug 2020 06:46:22 +0000 -Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC, - ObjC++, if the optimization level is > 0 - ---- - gcc/c-family/c-cppbuiltin.c | 4 ++++ - gcc/doc/invoke.texi | 6 ++++++ - 2 files changed, 10 insertions(+) - -diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c -index db91a36794a..ed976c71404 100644 ---- a/gcc/c-family/c-cppbuiltin.c -+++ b/gcc/c-family/c-cppbuiltin.c -@@ -1385,6 +1385,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 17d371ef432..fe793ac08db 100644 ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -9230,6 +9230,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}. -+ - @item -O3 - @opindex O3 - Optimize yet more. @option{-O3} turns on all optimizations specified --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch b/patches/gcc-11.2.0-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch deleted file mode 100644 index a9522aa..0000000 --- a/patches/gcc-11.2.0-alpine/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch +++ /dev/null @@ -1,242 +0,0 @@ -From: Ariadne Conill -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 -Subject: [PATCH] On linux targets pass --as-needed by default to the linker, - but always link the sanitizer libraries with --no-as-needed. - -diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h -index 7f2529a2a..b097e1688 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 c1dae8ca2..a87dc7401 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 0c1c4e70b..8b581afac 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 5ebbf42a1..e1a04e9fd 100644 ---- a/gcc/config/gnu-user.h -+++ b/gcc/config/gnu-user.h -@@ -136,21 +136,21 @@ 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 "%{static-libhwasan:%{!shared:" \ - LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \ -- LD_DYNAMIC_OPTION "}}%{!static-libhwasan:-lhwasan}" -+ LD_DYNAMIC_OPTION "}}%{!static-libhwasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lhwasan %{fuse-ld=gold:--as-needed;:--pop-state}}" - #undef LIBTSAN_EARLY_SPEC - #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 a23e7ab3e..12ac8cb93 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 f3e25b141..712b0f1c3 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 ac40c3dfd..6e19e25c3 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 a390bcece..be0ee2893 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/rs6000/linux64.h b/gcc/config/rs6000/linux64.h -index e3f2cd254..43499ed29 100644 ---- a/gcc/config/rs6000/linux64.h -+++ b/gcc/config/rs6000/linux64.h -@@ -374,13 +374,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 510abe169..3c1f3a8ec 100644 ---- a/gcc/config/rs6000/sysv4.h -+++ b/gcc/config/rs6000/sysv4.h -@@ -789,7 +789,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 daa48fdfc..2fcfc5d77 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 2550d7ee8..7596d0b27 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.c b/gcc/gcc.c -index 4d790f9dd..5b2fa8c93 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -737,8 +737,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 -@@ -773,8 +776,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 -@@ -791,8 +797,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 -@@ -807,8 +816,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 diff --git a/patches/gcc-11.2.0-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch b/patches/gcc-11.2.0-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch deleted file mode 100644 index aca0075..0000000 --- a/patches/gcc-11.2.0-alpine/0006-Enable-Wformat-and-Wformat-security-by-default.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 44b1a01cbe3932122112f38e06a21b1c9efad568 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:47:43 +0000 -Subject: [PATCH] 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 c49da99d395..93f25319005 100644 ---- a/gcc/c-family/c.opt -+++ b/gcc/c-family/c.opt -@@ -599,7 +599,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 -@@ -620,7 +620,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0007-Enable-Wtrampolines-by-default.patch b/patches/gcc-11.2.0-alpine/0007-Enable-Wtrampolines-by-default.patch deleted file mode 100644 index 515d5e0..0000000 --- a/patches/gcc-11.2.0-alpine/0007-Enable-Wtrampolines-by-default.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5679adc04a200e3a1a8dd77466eb79d03da8bf8a Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:48:24 +0000 -Subject: [PATCH] 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 ca942863064..0a0ab6195ee 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -774,7 +774,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. - - Wtype-limits --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch b/patches/gcc-11.2.0-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch deleted file mode 100644 index 996abdf..0000000 --- a/patches/gcc-11.2.0-alpine/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch +++ /dev/null @@ -1,45 +0,0 @@ -From: Ariadne Conill -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 -Subject: [PATCH] Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding - Change the buffer size. - -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 5b2fa8c93..d7f3ee55c 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -989,6 +989,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" \ -@@ -1285,7 +1291,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 8ba281b4c..bab39cdf8 100644 ---- a/gcc/params.opt -+++ b/gcc/params.opt -@@ -946,7 +946,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= diff --git a/patches/gcc-11.2.0-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch b/patches/gcc-11.2.0-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch deleted file mode 100644 index c4cd1fe..0000000 --- a/patches/gcc-11.2.0-alpine/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 27863679bde671cdd354cba398ef71a956873e6a Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:50:33 +0000 -Subject: [PATCH] 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 a9391d8d167..f7eee24dc8c 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 a0f84b0cfa0..ab24a47a2fd 100644 ---- a/libstdc++-v3/po/Makefile.in -+++ b/libstdc++-v3/po/Makefile.in -@@ -548,6 +548,7 @@ uninstall-am: - - - .po.mo: -+ env --unset=LD_LIBRARY_PATH \ - $(MSGFMT) -o $@ $< - - all-local: all-local-$(USE_NLS) --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch b/patches/gcc-11.2.0-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch deleted file mode 100644 index 4fbd367..0000000 --- a/patches/gcc-11.2.0-alpine/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 953779008f2caa78c55f80c2d6096bf627080016 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:52:07 +0000 -Subject: [PATCH] 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 141cb886a85..fa0e78eb62f 100644 ---- a/include/libiberty.h -+++ b/include/libiberty.h -@@ -645,8 +645,11 @@ extern int pwait (int, int *, int); - /* 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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch b/patches/gcc-11.2.0-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch deleted file mode 100644 index 0e8f83f..0000000 --- a/patches/gcc-11.2.0-alpine/0011-libiberty-copy-PIC-objects-during-build-process.patch +++ /dev/null @@ -1,24 +0,0 @@ -From b43185f44ed438267db101fbe41361001c4e8a94 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:53:00 +0000 -Subject: [PATCH] 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 d6b302e02fd..fd39928546f 100644 ---- a/libiberty/Makefile.in -+++ b/libiberty/Makefile.in -@@ -263,6 +263,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0012-libitm-disable-FORTIFY.patch b/patches/gcc-11.2.0-alpine/0012-libitm-disable-FORTIFY.patch deleted file mode 100644 index 0f262f2..0000000 --- a/patches/gcc-11.2.0-alpine/0012-libitm-disable-FORTIFY.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 10f38bef9af2e3d6a32253ca18d5ae0123e25e1b Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:53:36 +0000 -Subject: [PATCH] libitm: disable FORTIFY - ---- - libitm/configure.tgt | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/libitm/configure.tgt b/libitm/configure.tgt -index d1beb5c9ec8..c2b50b95c01 100644 ---- a/libitm/configure.tgt -+++ b/libitm/configure.tgt -@@ -47,6 +47,16 @@ if test "$gcc_cv_have_tls" = yes ; then - esac - fi - -+# FIXME: error: inlining failed in call to always_inline -+# ‘int vfprintf(FILE*, const char*, __va_list_tag*)’ -+# : function body can be overwritten at link time -+# Disable Fortify in libitm for now. #508852 -+case "${target}" in -+ *-*-linux*) -+ XCFLAGS="${XCFLAGS} -U_FORTIFY_SOURCE" -+ ;; -+esac -+ - # Map the target cpu to an ARCH sub-directory. At the same time, - # work out any special compilation flags as necessary. - case "${target_cpu}" in --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0013-libgcc_s.patch b/patches/gcc-11.2.0-alpine/0013-libgcc_s.patch deleted file mode 100644 index 5569221..0000000 --- a/patches/gcc-11.2.0-alpine/0013-libgcc_s.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 3614b3586d4a0f75e454943895977a9df1b734d5 Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Sat, 24 Oct 2015 20:09:53 +0000 -Subject: [PATCH] libgcc_s - ---- - gcc/config/i386/i386-expand.c | 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.c b/gcc/config/i386/i386-expand.c -index 47d52550e5e..9cb8cc7950e 100644 ---- a/gcc/config/i386/i386-expand.c -+++ b/gcc/config/i386/i386-expand.c -@@ -10976,10 +10976,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_local 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 83301a1445f..89fdc7eb587 100644 ---- a/libgcc/config/i386/cpuinfo.c -+++ b/libgcc/config/i386/cpuinfo.c -@@ -516,7 +516,7 @@ __cpu_indicator_init (void) - return 0; - } - --#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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0014-nopie.patch b/patches/gcc-11.2.0-alpine/0014-nopie.patch deleted file mode 100644 index 1ca5745..0000000 --- a/patches/gcc-11.2.0-alpine/0014-nopie.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 8e58f9aa5b86dc92e5a1fa71e40e499739473894 Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Sat, 7 Nov 2015 02:08:05 +0000 -Subject: [PATCH] nopie - ---- - gcc/configure | 27 +++++++++++++++++++++++++++ - gcc/configure.ac | 13 +++++++++++++ - 2 files changed, 40 insertions(+) - -diff --git a/gcc/configure b/gcc/configure -index 17b878e4b4e..808570b6c99 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -30784,6 +30784,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 bf64ffbe46f..9c2571de709 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -6866,6 +6866,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch b/patches/gcc-11.2.0-alpine/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch deleted file mode 100644 index b36fa1e..0000000 --- a/patches/gcc-11.2.0-alpine/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch +++ /dev/null @@ -1,25 +0,0 @@ -From c5ee6bb497f640877be668428292487eb026d79e Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:57:09 +0000 -Subject: [PATCH] libffi: use __linux__ instead of __gnu_linux__ for musl - ---- - libffi/src/closures.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libffi/src/closures.c b/libffi/src/closures.c -index 721ff00ea43..22a699c6340 100644 ---- a/libffi/src/closures.c -+++ b/libffi/src/closures.c -@@ -34,7 +34,7 @@ - #include - - #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE --# if __gnu_linux__ && !defined(__ANDROID__) -+# if __linux__ && !defined(__ANDROID__) - /* This macro indicates it may be forbidden to map anonymous memory - with both write and execute permission. Code compiled when this - option is defined will attempt to map such pages once, but if it --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0016-dlang-update-zlib-binding.patch b/patches/gcc-11.2.0-alpine/0016-dlang-update-zlib-binding.patch deleted file mode 100644 index 8a99d5c..0000000 --- a/patches/gcc-11.2.0-alpine/0016-dlang-update-zlib-binding.patch +++ /dev/null @@ -1,425 +0,0 @@ -From b2e1bf216169f470ced86f1f3e95c89debf606cd Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:57:51 +0000 -Subject: [PATCH] dlang: update zlib binding - ---- - libphobos/src/std/zlib.d | 266 ++++++++++++++++++++++++++++----------- - 1 file changed, 196 insertions(+), 70 deletions(-) - -diff --git a/libphobos/src/std/zlib.d b/libphobos/src/std/zlib.d -index e6cce240fd5..bd2fe37ebec 100644 ---- a/libphobos/src/std/zlib.d -+++ b/libphobos/src/std/zlib.d -@@ -1,7 +1,7 @@ - // Written in the D programming language. - - /** -- * Compress/decompress data using the $(HTTP www._zlib.net, _zlib library). -+ * Compress/decompress data using the $(HTTP www.zlib.net, zlib library). - * - * Examples: - * -@@ -43,12 +43,12 @@ - * References: - * $(HTTP en.wikipedia.org/wiki/Zlib, Wikipedia) - * -- * Copyright: Copyright Digital Mars 2000 - 2011. -+ * Copyright: Copyright The D Language Foundation 2000 - 2011. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: $(HTTP digitalmars.com, Walter Bright) -- * Source: $(PHOBOSSRC std/_zlib.d) -+ * Source: $(PHOBOSSRC std/zlib.d) - */ --/* Copyright Digital Mars 2000 - 2011. -+/* Copyright The D Language Foundation 2000 - 2011. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) -@@ -75,9 +75,9 @@ enum - - class ZlibException : Exception - { -- this(int errnum) -- { string msg; -- -+ private static string getmsg(int errnum) nothrow @nogc pure @safe -+ { -+ string msg; - switch (errnum) - { - case Z_STREAM_END: msg = "stream end"; break; -@@ -90,7 +90,12 @@ class ZlibException : Exception - case Z_VERSION_ERROR: msg = "version error"; break; - default: msg = "unknown error"; break; - } -- super(msg); -+ return msg; -+ } -+ -+ this(int errnum) -+ { -+ super(getmsg(errnum)); - } - } - -@@ -104,7 +109,7 @@ class ZlibException : Exception - * buf = buffer containing input data - * - * Returns: -- * A $(D uint) checksum for the provided input data and starting checksum -+ * A `uint` checksum for the provided input data and starting checksum - * - * See_Also: - * $(LINK http://en.wikipedia.org/wiki/Adler-32) -@@ -147,7 +152,7 @@ uint adler32(uint adler, const(void)[] buf) - * buf = buffer containing input data - * - * Returns: -- * A $(D uint) checksum for the provided input data and starting checksum -+ * A `uint` checksum for the provided input data and starting checksum - * - * See_Also: - * $(LINK http://en.wikipedia.org/wiki/Cyclic_redundancy_check) -@@ -191,13 +196,14 @@ uint crc32(uint crc, const(void)[] buf) - ubyte[] compress(const(void)[] srcbuf, int level) - in - { -- assert(-1 <= level && level <= 9); -+ assert(-1 <= level && level <= 9, "Compression level needs to be within [-1, 9]."); - } --body -+do - { - import core.memory : GC; -+ import std.array : uninitializedArray; - auto destlen = srcbuf.length + ((srcbuf.length + 1023) / 1024) + 12; -- auto destbuf = new ubyte[destlen]; -+ auto destbuf = uninitializedArray!(ubyte[])(destlen); - auto err = etc.c.zlib.compress2(destbuf.ptr, &destlen, cast(ubyte *) srcbuf.ptr, srcbuf.length, level); - if (err) - { -@@ -276,7 +282,7 @@ void[] uncompress(const(void)[] srcbuf, size_t destlen = 0u, int winbits = 15) - throw new ZlibException(err); - } - } -- assert(0); -+ assert(0, "Unreachable code"); - } - - @system unittest -@@ -370,9 +376,9 @@ class Compress - this(int level, HeaderFormat header = HeaderFormat.deflate) - in - { -- assert(1 <= level && level <= 9); -+ assert(1 <= level && level <= 9, "Legal compression level are in [1, 9]."); - } -- body -+ do - { - this.level = level; - this.gzip = header == HeaderFormat.gzip; -@@ -406,6 +412,7 @@ class Compress - const(void)[] compress(const(void)[] buf) - { - import core.memory : GC; -+ import std.array : uninitializedArray; - int err; - ubyte[] destbuf; - -@@ -420,7 +427,7 @@ class Compress - inited = 1; - } - -- destbuf = new ubyte[zs.avail_in + buf.length]; -+ destbuf = uninitializedArray!(ubyte[])(zs.avail_in + buf.length); - zs.next_out = destbuf.ptr; - zs.avail_out = to!uint(destbuf.length); - -@@ -461,9 +468,10 @@ class Compress - void[] flush(int mode = Z_FINISH) - in - { -- assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH); -+ assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH, -+ "Mode must be either Z_FINISH, Z_SYNC_FLUSH or Z_FULL_FLUSH."); - } -- body -+ do - { - import core.memory : GC; - ubyte[] destbuf; -@@ -523,6 +531,7 @@ class UnCompress - z_stream zs; - int inited; - int done; -+ bool inputEnded; - size_t destbufsize; - - HeaderFormat format; -@@ -571,16 +580,16 @@ class UnCompress - const(void)[] uncompress(const(void)[] buf) - in - { -- assert(!done); -+ assert(!done, "Buffer has been flushed."); - } -- body -+ do - { -+ if (inputEnded || !buf.length) -+ return null; -+ - import core.memory : GC; -+ import std.array : uninitializedArray; - int err; -- ubyte[] destbuf; -- -- if (buf.length == 0) -- return null; - - if (!inited) - { -@@ -598,26 +607,152 @@ class UnCompress - - if (!destbufsize) - destbufsize = to!uint(buf.length) * 2; -- destbuf = new ubyte[zs.avail_in * 2 + destbufsize]; -- zs.next_out = destbuf.ptr; -- zs.avail_out = to!uint(destbuf.length); -- -- if (zs.avail_in) -- buf = zs.next_in[0 .. zs.avail_in] ~ cast(ubyte[]) buf; -+ auto destbuf = uninitializedArray!(ubyte[])(destbufsize); -+ size_t destFill; - - zs.next_in = cast(ubyte*) buf.ptr; - zs.avail_in = to!uint(buf.length); - -- err = inflate(&zs, Z_NO_FLUSH); -- if (err != Z_STREAM_END && err != Z_OK) -+ while (true) - { -- GC.free(destbuf.ptr); -- error(err); -+ auto oldAvailIn = zs.avail_in; -+ -+ zs.next_out = destbuf[destFill .. $].ptr; -+ zs.avail_out = to!uint(destbuf.length - destFill); -+ -+ err = inflate(&zs, Z_NO_FLUSH); -+ if (err == Z_STREAM_END) -+ { -+ inputEnded = true; -+ break; -+ } -+ else if (err != Z_OK) -+ { -+ GC.free(destbuf.ptr); -+ error(err); -+ } -+ else if (!zs.avail_in) -+ break; -+ -+ /* -+ According to the zlib manual inflate() stops when either there's -+ no more data to uncompress or the output buffer is full -+ So at this point, the output buffer is too full -+ */ -+ -+ destFill = destbuf.length; -+ -+ if (destbuf.capacity) -+ { -+ if (destbuf.length < destbuf.capacity) -+ destbuf.length = destbuf.capacity; -+ else -+ { -+ auto newLength = GC.extend(destbuf.ptr, destbufsize, destbufsize); -+ -+ if (newLength && destbuf.length < destbuf.capacity) -+ destbuf.length = destbuf.capacity; -+ else -+ destbuf.length += destbufsize; -+ } -+ } -+ else -+ destbuf.length += destbufsize; - } -+ - destbuf.length = destbuf.length - zs.avail_out; - return destbuf; - } - -+ // Test for issues 3191 and 9505 -+ @system unittest -+ { -+ import std.algorithm.comparison; -+ import std.array; -+ import std.file; -+ import std.zlib; -+ -+ // Data that can be easily compressed -+ ubyte[1024] originalData; -+ -+ // This should yield a compression ratio of at least 1/2 -+ auto compressedData = compress(originalData, 9); -+ assert(compressedData.length < originalData.length / 2, -+ "The compression ratio is too low to accurately test this situation"); -+ -+ auto chunkSize = compressedData.length / 4; -+ assert(chunkSize < compressedData.length, -+ "The length of the compressed data is too small to accurately test this situation"); -+ -+ auto decompressor = new UnCompress(); -+ ubyte[originalData.length] uncompressedData; -+ ubyte[] reusedBuf; -+ int progress; -+ -+ reusedBuf.length = chunkSize; -+ -+ for (int i = 0; i < compressedData.length; i += chunkSize) -+ { -+ auto len = min(chunkSize, compressedData.length - i); -+ // simulate reading from a stream in small chunks -+ reusedBuf[0 .. len] = compressedData[i .. i + len]; -+ -+ // decompress using same input buffer -+ auto chunk = decompressor.uncompress(reusedBuf); -+ assert(progress + chunk.length <= originalData.length, -+ "The uncompressed result is bigger than the original data"); -+ -+ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[]; -+ progress += chunk.length; -+ } -+ -+ auto chunk = decompressor.flush(); -+ assert(progress + chunk.length <= originalData.length, -+ "The uncompressed result is bigger than the original data"); -+ -+ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[]; -+ progress += chunk.length; -+ -+ assert(progress == originalData.length, -+ "The uncompressed and the original data sizes differ"); -+ assert(originalData[] == uncompressedData[], -+ "The uncompressed and the original data differ"); -+ } -+ -+ @system unittest -+ { -+ ubyte[1024] invalidData; -+ auto decompressor = new UnCompress(); -+ -+ try -+ { -+ auto uncompressedData = decompressor.uncompress(invalidData); -+ } -+ catch (ZlibException e) -+ { -+ assert(e.msg == "data error"); -+ return; -+ } -+ -+ assert(false, "Corrupted data didn't result in an error"); -+ } -+ -+ @system unittest -+ { -+ ubyte[2014] originalData = void; -+ auto compressedData = compress(originalData, 9); -+ -+ auto decompressor = new UnCompress(); -+ auto uncompressedData = decompressor.uncompress(compressedData ~ cast(ubyte[]) "whatever"); -+ -+ assert(originalData.length == uncompressedData.length, -+ "The uncompressed and the original data sizes differ"); -+ assert(originalData[] == uncompressedData[], -+ "The uncompressed and the original data differ"); -+ assert(!decompressor.uncompress("whatever").length, -+ "Compression continued after the end"); -+ } -+ - /** - * Decompress and return any remaining data. - * The returned data should be appended to that returned by uncompress(). -@@ -626,49 +761,40 @@ class UnCompress - void[] flush() - in - { -- assert(!done); -+ assert(!done, "Buffer has been flushed before."); - } - out - { -- assert(done); -+ assert(done, "Flushing failed."); - } -- body -+ do - { -- import core.memory : GC; -- ubyte[] extra; -- ubyte[] destbuf; -- int err; -- - done = 1; -- if (!inited) -- return null; -+ return null; -+ } - -- L1: -- destbuf = new ubyte[zs.avail_in * 2 + 100]; -- zs.next_out = destbuf.ptr; -- zs.avail_out = to!uint(destbuf.length); -+ /// Returns true if all input data has been decompressed and no further data -+ /// can be decompressed (inflate() returned Z_STREAM_END) -+ @property bool empty() const -+ { -+ return inputEnded; -+ } - -- err = etc.c.zlib.inflate(&zs, Z_NO_FLUSH); -- if (err == Z_OK && zs.avail_out == 0) -- { -- extra ~= destbuf; -- goto L1; -- } -- if (err != Z_STREAM_END) -- { -- GC.free(destbuf.ptr); -- if (err == Z_OK) -- err = Z_BUF_ERROR; -- error(err); -- } -- destbuf = destbuf.ptr[0 .. zs.next_out - destbuf.ptr]; -- err = etc.c.zlib.inflateEnd(&zs); -- inited = 0; -- if (err) -- error(err); -- if (extra.length) -- destbuf = extra ~ destbuf; -- return destbuf; -+ /// -+ @system unittest -+ { -+ // some random data -+ ubyte[1024] originalData = void; -+ -+ // append garbage data (or don't, this works in both cases) -+ auto compressedData = cast(ubyte[]) compress(originalData) ~ cast(ubyte[]) "whatever"; -+ -+ auto decompressor = new UnCompress(); -+ auto uncompressedData = decompressor.uncompress(compressedData); -+ -+ assert(uncompressedData[] == originalData[], -+ "The uncompressed and the original data differ"); -+ assert(decompressor.empty, "The UnCompressor reports not being done"); - } - } - --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch b/patches/gcc-11.2.0-alpine/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch deleted file mode 100644 index b10008f..0000000 --- a/patches/gcc-11.2.0-alpine/0017-dlang-fix-fcntl-on-mips-add-libucontext-dep.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 76c7eb27b9dfe96f2f1db4fa6f29ce28715ad2a4 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:58:22 +0000 -Subject: [PATCH] dlang: fix fcntl on mips, add libucontext dep - ---- - libphobos/configure.tgt | 1 + - libphobos/libdruntime/core/sys/posix/fcntl.d | 15 +++++++++++++++ - 2 files changed, 16 insertions(+) - -diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt -index 94e42bf5509..73f2e4b7f01 100644 ---- a/libphobos/configure.tgt -+++ b/libphobos/configure.tgt -@@ -35,6 +35,7 @@ case "${target}" in - ;; - mips*-*-linux*) - LIBPHOBOS_SUPPORTED=yes -+ LIBDRUNTIME_NEEDS_UCONTEXT=yes - ;; - power*-*-linux*) - LIBPHOBOS_SUPPORTED=yes -diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d -index 9febcff849b..cb34e2108bd 100644 ---- a/libphobos/libdruntime/core/sys/posix/fcntl.d -+++ b/libphobos/libdruntime/core/sys/posix/fcntl.d -@@ -870,6 +870,21 @@ else version (CRuntime_Musl) - F_SETLKW = 7, - } - } -+ else version (MIPS_Any) -+ { -+ enum -+ { -+ O_DIRECTORY = 0x010000, // octal 0200000 -+ O_NOFOLLOW = 0x020000, // octal 0400000 -+ O_DIRECT = 0x008000, // octal 0100000 -+ O_LARGEFILE = 0x002000, // octal 0020000 -+ O_TMPFILE = 0x410000, // octal 020200000 -+ -+ F_GETLK = 33, -+ F_SETLK = 34, -+ F_SETLKW = 35, -+ } -+ } - else - static assert(0, "Platform not supported"); - --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0018-ada-fix-shared-linking.patch b/patches/gcc-11.2.0-alpine/0018-ada-fix-shared-linking.patch deleted file mode 100644 index 83cd1d5..0000000 --- a/patches/gcc-11.2.0-alpine/0018-ada-fix-shared-linking.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 95fee2cfb1a6a32b7e671861b58ee93978ba16b8 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:59:16 +0000 -Subject: [PATCH] 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 02c413a412f..f0e52a87d6e 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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch b/patches/gcc-11.2.0-alpine/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch deleted file mode 100644 index 34c2da1..0000000 --- a/patches/gcc-11.2.0-alpine/0019-build-fix-CXXFLAGS_FOR_BUILD-passing.patch +++ /dev/null @@ -1,24 +0,0 @@ -From aa0311c59892d7fbc4ffa9e2f0520391521cc4dd Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 06:59:43 +0000 -Subject: [PATCH] build: fix CXXFLAGS_FOR_BUILD passing - ---- - Makefile.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Makefile.in b/Makefile.in -index 36e369df6e7..63627db68cf 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -170,6 +170,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0020-add-fortify-headers-paths.patch b/patches/gcc-11.2.0-alpine/0020-add-fortify-headers-paths.patch deleted file mode 100644 index f445401..0000000 --- a/patches/gcc-11.2.0-alpine/0020-add-fortify-headers-paths.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 39e86416709d3d34f46da7cd7b8a3e5a8f0ff7cd Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 07:01:06 +0000 -Subject: [PATCH] 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 95654bcdb5a..d88df8f154a 100644 ---- a/gcc/config/linux.h -+++ b/gcc/config/linux.h -@@ -167,6 +167,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch b/patches/gcc-11.2.0-alpine/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch deleted file mode 100644 index 073d56f..0000000 --- a/patches/gcc-11.2.0-alpine/0021-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch +++ /dev/null @@ -1,31 +0,0 @@ -From c6b54651688cf062ae48ca3402d6d2e08b70ceed 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] 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.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/gcc/gcc.c b/gcc/gcc.c -index daeb4d0c8ea..6920bec0fa0 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -894,8 +894,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch b/patches/gcc-11.2.0-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch deleted file mode 100644 index 684041c..0000000 --- a/patches/gcc-11.2.0-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 4841bee243517cd52504f97ea934f44bc0c1fd5c Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 07:03:42 +0000 -Subject: [PATCH] DP: Use --push-state/--pop-state for gold as well when - linking libtsan. - ---- - gcc/gcc.c | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -diff --git a/gcc/gcc.c b/gcc/gcc.c -index 6920bec0fa0..40e07354b3d 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -696,10 +696,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 -@@ -717,10 +717,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 -@@ -738,10 +738,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 -@@ -757,10 +757,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0023-Pure-64-bit-MIPS.patch b/patches/gcc-11.2.0-alpine/0023-Pure-64-bit-MIPS.patch deleted file mode 100644 index c8f9c98..0000000 --- a/patches/gcc-11.2.0-alpine/0023-Pure-64-bit-MIPS.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 720c0d7094d27b6cbfe9669c4f65e2021debcb07 Mon Sep 17 00:00:00 2001 -From: Nils Andreas Svee -Date: Thu, 21 Dec 2017 03:14:33 +0100 -Subject: [PATCH] Pure 64-bit MIPS - ---- - gcc/config/mips/mips.h | 8 ++++---- - gcc/config/mips/t-linux64 | 6 +++--- - 2 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h -index 3ce0c19a29a..b9920b49167 100644 ---- a/gcc/config/mips/mips.h -+++ b/gcc/config/mips/mips.h -@@ -3424,11 +3424,11 @@ struct GTY(()) machine_function { - /* If we are *not* using multilibs and the default ABI is not ABI_32 we - need to change these from /lib and /usr/lib. */ - #if MIPS_ABI_DEFAULT == ABI_N32 --#define STANDARD_STARTFILE_PREFIX_1 "/lib32/" --#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib32/" -+#define STANDARD_STARTFILE_PREFIX_1 "/lib/" -+#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" - #elif MIPS_ABI_DEFAULT == ABI_64 --#define STANDARD_STARTFILE_PREFIX_1 "/lib64/" --#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib64/" -+#define STANDARD_STARTFILE_PREFIX_1 "/lib/" -+#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" - #endif - - /* Load store bonding is not supported by micromips and fix_24k. The -diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 -index ceb58d3b5f3..8116e23ebba 100644 ---- a/gcc/config/mips/t-linux64 -+++ b/gcc/config/mips/t-linux64 -@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64 - MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el) - MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft) - MULTILIB_OSDIRNAMES = \ -- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \ -- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \ -- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT)) -+ ../lib \ -+ ../lib32 \ -+ ../lib --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0024-use-pure-64-bit-configuration-where-appropriate.patch b/patches/gcc-11.2.0-alpine/0024-use-pure-64-bit-configuration-where-appropriate.patch deleted file mode 100644 index eb592dc..0000000 --- a/patches/gcc-11.2.0-alpine/0024-use-pure-64-bit-configuration-where-appropriate.patch +++ /dev/null @@ -1,121 +0,0 @@ -From c60bb23972769f687dcac689ddf00f88e46b8bb7 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 07:04:40 +0000 -Subject: [PATCH] use pure 64-bit configuration where appropriate - ---- - gcc/config/aarch64/t-aarch64-linux | 2 +- - gcc/config/i386/t-linux64 | 4 ++-- - gcc/config/rs6000/t-linux | 6 ++++-- - gcc/config/rs6000/t-linux64 | 4 ++-- - gcc/config/rs6000/t-linux64bele | 4 ++-- - gcc/config/rs6000/t-linux64lebe | 4 ++-- - gcc/config/s390/t-linux64 | 4 ++-- - 7 files changed, 15 insertions(+), 13 deletions(-) - -diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux -index 83e59e33b85..6ec56fdf6a8 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) -diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 -index 1171e218578..256f8c079ba 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) -diff --git a/gcc/config/rs6000/t-linux b/gcc/config/rs6000/t-linux -index aeb7440c492..ab14c455d8d 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 264a7e27524..d1e460811cc 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.c - $(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} -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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0025-always-build-libgcc_eh.a.patch b/patches/gcc-11.2.0-alpine/0025-always-build-libgcc_eh.a.patch deleted file mode 100644 index 65324ab..0000000 --- a/patches/gcc-11.2.0-alpine/0025-always-build-libgcc_eh.a.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 00917df4274ea2fb33b08c963a97cf1b28f59dd3 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 07:05:41 +0000 -Subject: [PATCH] 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 851e7657d07..99ec513a1a6 100644 ---- a/libgcc/Makefile.in -+++ b/libgcc/Makefile.in -@@ -956,8 +956,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) -@@ -1159,10 +1160,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)))) -@@ -1179,6 +1176,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0026-ada-libgnarl-compatibility-for-musl.patch b/patches/gcc-11.2.0-alpine/0026-ada-libgnarl-compatibility-for-musl.patch deleted file mode 100644 index 0faf41a..0000000 --- a/patches/gcc-11.2.0-alpine/0026-ada-libgnarl-compatibility-for-musl.patch +++ /dev/null @@ -1,133 +0,0 @@ -From: Ariadne Conill -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 -Subject: [PATCH] ada: libgnarl compatibility for musl - -diff --git a/gcc/ada/libgnarl/s-osinte__linux.ads b/gcc/ada/libgnarl/s-osinte__linux.ads -index 2272f83d6..1d7845654 100644 ---- a/gcc/ada/libgnarl/s-osinte__linux.ads -+++ b/gcc/ada/libgnarl/s-osinte__linux.ads -@@ -401,12 +401,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; -@@ -468,11 +462,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 757a6cdfd..18e60e8d1 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,44 +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, -- -- as in "sudo /sbin/setcap cap_sys_nice=ep exe_file". If it doesn't have -- -- permission, then a request for Ceiling_Locking is ignored. -- - type RTS_Lock_Ptr is not null access all RTS_Lock; - - function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int; -@@ -344,7 +303,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 +317,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 +357,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); diff --git a/patches/gcc-11.2.0-alpine/0027-ada-musl-support-fixes.patch b/patches/gcc-11.2.0-alpine/0027-ada-musl-support-fixes.patch deleted file mode 100644 index 0f4ef64..0000000 --- a/patches/gcc-11.2.0-alpine/0027-ada-musl-support-fixes.patch +++ /dev/null @@ -1,223 +0,0 @@ -From 21692d89e7876dcaecea3e3c961c6504be4a83e9 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Fri, 21 Aug 2020 07:07:48 +0000 -Subject: [PATCH] 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 55ff9b0f3d5..0fadf4e4b79 100644 ---- a/gcc/ada/Makefile.rtl -+++ b/gcc/ada/Makefile.rtl -@@ -1533,7 +1533,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) - s-intman.adb - #include - #endif -+ -+#if defined (linux) -+#define _GNU_SOURCE 1 -+#include -+#endif - - #ifdef __PikeOS__ - #define __BSD_VISIBLE 1 -@@ -3308,7 +3313,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 -@@ -3318,7 +3322,7 @@ __gnat_lwp_self (void) - - /* Dynamic cpu sets */ - --cpu_set_t * -+void * - __gnat_cpu_alloc (size_t count) - { - return CPU_ALLOC (count); -@@ -3331,33 +3335,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 -@@ -3367,23 +3371,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 311e240dfcc..1c4d0050103 100644 ---- a/gcc/ada/adaint.h -+++ b/gcc/ada/adaint.h -@@ -316,13 +316,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 af4417fab90..bab6bf3ca87 100644 ---- a/gcc/ada/terminals.c -+++ b/gcc/ada/terminals.c -@@ -1145,7 +1145,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns) - /* 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 -@@ -1159,7 +1159,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns) - #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) -@@ -1208,8 +1208,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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch b/patches/gcc-11.2.0-alpine/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch deleted file mode 100644 index 2932ce7..0000000 --- a/patches/gcc-11.2.0-alpine/0028-gcc-go-Use-_off_t-type-instead-of-_loff_t.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 1852ae06e733180f090b58c267bde8fb9501a41e Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:58:08 +0200 -Subject: [PATCH] gcc-go: Use _off_t type instead of _loff_t -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/go/syscall/libcall_linux.go | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go -index 88286c07b6e..f8f5cfb5011 100644 ---- a/libgo/go/syscall/libcall_linux.go -+++ b/libgo/go/syscall/libcall_linux.go -@@ -206,19 +206,19 @@ func Gettid() (tid int) { - //sys Setxattr(path string, attr string, data []byte, flags int) (err error) - //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int - --//sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error) --//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t -+//sys splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error) -+//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t - func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { -- var lroff _loff_t -- var plroff *_loff_t -+ var lroff _off_t -+ var plroff *_off_t - if roff != nil { -- lroff = _loff_t(*roff) -+ lroff = _off_t(*roff) - plroff = &lroff - } -- var lwoff _loff_t -- var plwoff *_loff_t -+ var lwoff _off_t -+ var plwoff *_off_t - if woff != nil { -- lwoff = _loff_t(*woff) -+ lwoff = _off_t(*woff) - plwoff = &lwoff - } - n, err = splice(rfd, plroff, wfd, plwoff, len, flags) --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0029-gcc-go-Don-t-include-sys-user.h.patch b/patches/gcc-11.2.0-alpine/0029-gcc-go-Don-t-include-sys-user.h.patch deleted file mode 100644 index 5f2cb2d..0000000 --- a/patches/gcc-11.2.0-alpine/0029-gcc-go-Don-t-include-sys-user.h.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 40322de36043aaa3cbb98d7f01037f53fc1b5a98 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:58:21 +0200 -Subject: [PATCH] gcc-go: Don't include sys/user.h -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/sysinfo.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index 0692fd41eb7..c8d987358d9 100644 ---- a/libgo/sysinfo.c -+++ b/libgo/sysinfo.c -@@ -73,9 +73,6 @@ - #include - #include - #include --#if defined(HAVE_SYS_USER_H) --#include --#endif - #if defined(HAVE_SYS_UTSNAME_H) - #include - #endif --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch b/patches/gcc-11.2.0-alpine/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch deleted file mode 100644 index 37fa522..0000000 --- a/patches/gcc-11.2.0-alpine/0030-gcc-go-Fix-ucontext_t-on-PPC64.patch +++ /dev/null @@ -1,29 +0,0 @@ -From f1503cf97b5a5c6f9466145f5eb1ed3b5f200119 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:59:22 +0200 -Subject: [PATCH] gcc-go: Fix ucontext_t on PPC64 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/runtime/go-signal.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c -index b429fdb2403..fd1c885f043 100644 ---- a/libgo/runtime/go-signal.c -+++ b/libgo/runtime/go-signal.c -@@ -224,7 +224,7 @@ getSiginfo(siginfo_t *info, void *context __attribute__((unused))) - #elif defined(__alpha__) && defined(__linux__) - ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.sc_pc; - #elif defined(__PPC__) && defined(__linux__) -- ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip; -+ ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gp_regs[32]; - #elif defined(__PPC__) && defined(_AIX) - ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.jmp_context.iar; - #elif defined(__aarch64__) && defined(__linux__) --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch b/patches/gcc-11.2.0-alpine/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch deleted file mode 100644 index dca7043..0000000 --- a/patches/gcc-11.2.0-alpine/0031-gcc-go-Fix-handling-of-signal-34-on-musl.patch +++ /dev/null @@ -1,43 +0,0 @@ -From fc950e32b9ebc2bae09604ebe630df6df454151d Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:59:45 +0200 -Subject: [PATCH] gcc-go: Fix handling of signal 34 on musl -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/mksigtab.sh | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/libgo/mksigtab.sh b/libgo/mksigtab.sh -index 11e4ec436bd..fe866eacb27 100644 ---- a/libgo/mksigtab.sh -+++ b/libgo/mksigtab.sh -@@ -82,7 +82,7 @@ checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}' - checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}' - checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}' - checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}' --checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' -+#checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' - checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}' - checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}' - checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}' -@@ -95,10 +95,12 @@ checksig _SIGLOST ' {_SigNotify, "SIGLOST: resource lost (Sun); server died (G - - # Special handling of signals 32 and 33 on GNU/Linux systems, - # because they are special to glibc. -+# Signal 34 is additionally special to Linux systems with musl. - if test "${GOOS}" = "linux"; then -- SIGLIST=$SIGLIST"_32__33_" -+ SIGLIST=$SIGLIST"_32__33__34_" - echo ' 32: {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */' - echo ' 33: {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */' -+ echo ' 34: {_SigSetStack + _SigUnblock, "signal 34"}, /* see issue 30062 */' - fi - - if test "${GOOS}" = "aix"; then --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch b/patches/gcc-11.2.0-alpine/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch deleted file mode 100644 index 918d6b0..0000000 --- a/patches/gcc-11.2.0-alpine/0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 3be2284d92c560204e9eddb20db56d57fe584360 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 18:01:03 +0200 -Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/go/runtime/mem_gccgo.go | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go -index ba38ebaa9ab..3c9e5ce9461 100644 ---- a/libgo/go/runtime/mem_gccgo.go -+++ b/libgo/go/runtime/mem_gccgo.go -@@ -15,7 +15,7 @@ import ( - //go:linkname sysFree - - //extern mmap --func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer -+func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer - - //extern munmap - func munmap(addr unsafe.Pointer, length uintptr) int32 -@@ -37,7 +37,7 @@ func init() { - } - } - --func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { -+func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) { - p := sysMmap(addr, n, prot, flags, fd, off) - if uintptr(p) == _MAP_FAILED { - return nil, errno() --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0033-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch b/patches/gcc-11.2.0-alpine/0033-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch deleted file mode 100644 index 44ba58b..0000000 --- a/patches/gcc-11.2.0-alpine/0033-gcc-go-Fix-st_-a-m-c-tim-fields-in-generated-sysinfo.patch +++ /dev/null @@ -1,24 +0,0 @@ -From: "A. Wilcox" -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 -Subject: [PATCH] gcc-go: Fix st_{a,m,c}tim fields in generated sysinfo.go - -There are more than one st_{a,m,c}tim fields in struct stat on time64 machines. - -Run the Go-isation on all of them. - -Taken from Adélie Linux. - -diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 0c52ea5d7..6fef104cc 100755 ---- a/libgo/mksysinfo.sh -+++ b/libgo/mksysinfo.sh -@@ -510,7 +510,7 @@ fi - - # For historical reasons Go uses the suffix "timespec" instead of "tim" for - # stat_t's time fields on NetBSD. --st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' -+st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' - if test "${GOOS}" = "netbsd"; then - st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' - fi diff --git a/patches/gcc-11.2.0-alpine/0034-gcc-go-signal-34-is-special-on-musl-libc.patch b/patches/gcc-11.2.0-alpine/0034-gcc-go-signal-34-is-special-on-musl-libc.patch deleted file mode 100644 index 921bf3f..0000000 --- a/patches/gcc-11.2.0-alpine/0034-gcc-go-signal-34-is-special-on-musl-libc.patch +++ /dev/null @@ -1,29 +0,0 @@ -From dd1465b56f76ada5c7383ebd98ef02311a3b907c Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 18:03:03 +0200 -Subject: [PATCH] gcc-go: signal 34 is special on musl libc -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/go/runtime/signal_gccgo.go | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/go/runtime/signal_gccgo.go b/libgo/go/runtime/signal_gccgo.go -index c555712a03c..9e228580d37 100644 ---- a/libgo/go/runtime/signal_gccgo.go -+++ b/libgo/go/runtime/signal_gccgo.go -@@ -106,7 +106,7 @@ func getsig(i uint32) uintptr { - if sigaction(i, nil, &sa) < 0 { - // On GNU/Linux glibc rejects attempts to call - // sigaction with signal 32 (SIGCANCEL) or 33 (SIGSETXID). -- if GOOS == "linux" && (i == 32 || i == 33) { -+ if GOOS == "linux" && (i == 32 || i == 33 || i == 34) { - return _SIG_DFL - } - throw("sigaction read failure") --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch b/patches/gcc-11.2.0-alpine/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch deleted file mode 100644 index abb3f3f..0000000 --- a/patches/gcc-11.2.0-alpine/0035-gcc-go-Prefer-_off_t-over-_off64_t.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 382d4516db8a7c183e9d7b5ec16a9bc175523ac9 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 30 Aug 2020 19:26:53 +0200 -Subject: [PATCH] gcc-go: Prefer _off_t over _off64_t - -musl does not seem to have _off64_t. ---- - libgo/mksysinfo.sh | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 972e2c379bc..8d6da15f983 100755 ---- a/libgo/mksysinfo.sh -+++ b/libgo/mksysinfo.sh -@@ -379,11 +379,7 @@ fi - # Some basic types. - echo 'type Size_t _size_t' >> ${OUT} - echo "type Ssize_t _ssize_t" >> ${OUT} --if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then -- echo "type Offset_t _off64_t" >> ${OUT} --else -- echo "type Offset_t _off_t" >> ${OUT} --fi -+echo "type Offset_t _off_t" >> ${OUT} - echo "type Mode_t _mode_t" >> ${OUT} - echo "type Pid_t _pid_t" >> ${OUT} - echo "type Uid_t _uid_t" >> ${OUT} --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch b/patches/gcc-11.2.0-alpine/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch deleted file mode 100644 index 0e17708..0000000 --- a/patches/gcc-11.2.0-alpine/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 79d8ab42aefb1d3c5f794f51df643ab040c30e30 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 30 Aug 2020 19:27:51 +0200 -Subject: [PATCH] gcc-go: undef SETCONTEXT_CLOBBERS_TLS in proc.c - ---- - libgo/runtime/proc.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c -index 6f7d2e27996..5afd7902497 100644 ---- a/libgo/runtime/proc.c -+++ b/libgo/runtime/proc.c -@@ -66,6 +66,10 @@ static void gscanstack(G*); - - __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); - -+/* libucontext does not seem to support tlsbase, undef the macro -+ * here to make sure we define initcontext and fixcontext as dummies. */ -+#undef SETCONTEXT_CLOBBERS_TLS -+ - #ifndef SETCONTEXT_CLOBBERS_TLS - - static inline void --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0037-gcc-go-link-to-libucontext.patch b/patches/gcc-11.2.0-alpine/0037-gcc-go-link-to-libucontext.patch deleted file mode 100644 index b81d8bf..0000000 --- a/patches/gcc-11.2.0-alpine/0037-gcc-go-link-to-libucontext.patch +++ /dev/null @@ -1,25 +0,0 @@ -From d42de24395e4f07cf6412896d4cd8c7f83a9b875 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Mon, 31 Aug 2020 08:59:40 +0200 -Subject: [PATCH] gcc-go: link to libucontext - ---- - Makefile.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile.in b/Makefile.in -index 63627db68cf..c7f1f84d683 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -48823,7 +48823,7 @@ configure-target-libgo: - esac; \ - module_srcdir=libgo; \ - 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.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch b/patches/gcc-11.2.0-alpine/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch deleted file mode 100644 index 15acfdb..0000000 --- a/patches/gcc-11.2.0-alpine/0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 570cd2b596daf12e8dfe1a444fe405a7c26fc2bc Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Mon, 31 Aug 2020 20:26:56 +0200 -Subject: [PATCH] gcc-go: Disable printing of unaccessible ppc64 struct members - -These struct members do not seem to exist on musl. ---- - libgo/runtime/go-signal.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c -index fd1c885f043..e845e453332 100644 ---- a/libgo/runtime/go-signal.c -+++ b/libgo/runtime/go-signal.c -@@ -333,7 +333,7 @@ dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((u - runtime_printf("sp %X\n", m->sc_regs[30]); - runtime_printf("pc %X\n", m->sc_pc); - } --#elif defined(__PPC__) && defined(__LITTLE_ENDIAN__) && defined(__linux__) -+#elif defined(__PPC__) && defined(__LITTLE_ENDIAN__) && defined(__GLIBC__) - { - mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext; - int i; --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0040-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch b/patches/gcc-11.2.0-alpine/0040-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch deleted file mode 100644 index b118eae..0000000 --- a/patches/gcc-11.2.0-alpine/0040-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch +++ /dev/null @@ -1,264 +0,0 @@ -From: Drew DeVault -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 -Subject: [PATCH] configure: Add --enable-autolink-libatomic, use in - LINK_GCC_C_SEQUENCE_SPEC [PR81358] - -This fixes issues with RISC-V. - -diff --git a/Makefile.in b/Makefile.in -index 047be0255..765f6b89b 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -221,6 +221,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 313c13c8e..d0287d4cc 100644 ---- a/gcc/config.in -+++ b/gcc/config.in -@@ -106,6 +106,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 e1a04e9fd..ef1ffa6d2 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 9b28369e3..8afa1c84f 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -978,6 +978,7 @@ with_changes_root_url - enable_languages - with_multilib_list - with_multilib_generator -+enable_autolink_libatomic - with_zstd - with_zstd_include - with_zstd_lib -@@ -1706,6 +1707,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 -@@ -8076,6 +8080,33 @@ else - 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 - # ------------------------- -@@ -19392,7 +19423,7 @@ else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 19395 "configure" -+#line 19426 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -@@ -19498,7 +19529,7 @@ else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 19501 "configure" -+#line 19532 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -@@ -33588,4 +33619,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} - fi - -- -diff --git a/gcc/configure.ac b/gcc/configure.ac -index 162e08cbc..115ba8ac6 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -1149,6 +1149,28 @@ 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 - # ------------------------- -@@ -7553,4 +7575,3 @@ done - ], - [subdirs='$subdirs']) - AC_OUTPUT -- -diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi -index 4c38244ae..4a544e6a4 100644 ---- a/gcc/doc/install.texi -+++ b/gcc/doc/install.texi -@@ -2213,6 +2213,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 b370bc76b..acc782739 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 2974dae27..80e003a38 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.c b/gcc/gcc.c -index d7f3ee55c..bc1bd1686 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -980,13 +980,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 diff --git a/patches/gcc-11.2.0-alpine/0041-Use-generic-errstr.go-implementation-on-musl.patch b/patches/gcc-11.2.0-alpine/0041-Use-generic-errstr.go-implementation-on-musl.patch deleted file mode 100644 index 222513d..0000000 --- a/patches/gcc-11.2.0-alpine/0041-Use-generic-errstr.go-implementation-on-musl.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 70d70a1106b31ab840dbf5361312af221a2d5f04 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Mon, 19 Apr 2021 07:21:41 +0200 -Subject: [PATCH] Use generic errstr.go implementation on musl - -glibc provides two version of strerror_r() depending on a feature test -macro. The first is the XSI-compliant version which returns an int, the -second is GNU-specific and returns a char pointer. - -Similarity, gcc's libgo provides two implementations of Errstr() both of -which use strerror_r(). On Linux, it is assumed that the GNU-specific -strerror_r version is used. However, musl only provides the -XSI-compliant version of strerror_r. This patch enables the generic -Errstr() implementation which also uses the XSI-compliant version of -strerror_r. ---- - libgo/go/syscall/errstr.go | 1 - - libgo/go/syscall/errstr_glibc.go | 2 +- - 2 files changed, 1 insertion(+), 2 deletions(-) - -diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go -index 6c2441d364d..8f7c5538163 100644 ---- a/libgo/go/syscall/errstr.go -+++ b/libgo/go/syscall/errstr.go -@@ -5,7 +5,6 @@ - // license that can be found in the LICENSE file. - - // +build !hurd --// +build !linux - - package syscall - -diff --git a/libgo/go/syscall/errstr_glibc.go b/libgo/go/syscall/errstr_glibc.go -index 5b19e6f202d..8dc60172186 100644 ---- a/libgo/go/syscall/errstr_glibc.go -+++ b/libgo/go/syscall/errstr_glibc.go -@@ -7,7 +7,7 @@ - // We use this rather than errstr.go because on GNU/Linux sterror_r - // returns a pointer to the error message, and may not use buf at all. - --// +build hurd linux -+// +build hurd !linux - - package syscall - --- -2.31.1 - diff --git a/patches/gcc-11.2.0-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch b/patches/gcc-11.2.0-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch deleted file mode 100644 index 96deb51..0000000 --- a/patches/gcc-11.2.0-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Alpine Linux community -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 - -diff --git a/gcc/gcc.c b/gcc/gcc.c -index bc1bd1686..b5c83977f 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -1005,6 +1005,12 @@ proper position among the other output files. */ - #define NO_SSP_SPEC "" - #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" \ diff --git a/patches/gcc-11.2.0-alpine/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch b/patches/gcc-11.2.0-alpine/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch deleted file mode 100644 index 762c6ef..0000000 --- a/patches/gcc-11.2.0-alpine/0043-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Alpine Linux community -From: Olsken (updated patches) -Date: Sat, 21 Aug 2021 08:51:52 +0000 - -diff --git a/gcc/config.in b/gcc/config.in -index d0287d4cc..8c10816c4 100644 ---- a/gcc/config.in -+++ b/gcc/config.in -@@ -112,6 +112,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/patches/gcc-11.2.0-alpine/apply_patches_ct.sh b/patches/gcc-11.2.0-alpine/apply_patches_ct.sh deleted file mode 100755 index d939664..0000000 --- a/patches/gcc-11.2.0-alpine/apply_patches_ct.sh +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/bash - -for p in 0001-posix_memalign 0002-gcc-poison-system-directories \ - 0003-Turn-on-Wl-z-relro-z-now-by-default \ - 0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O \ - 0006-Enable-Wformat-and-Wformat-security-by-default \ - 0007-Enable-Wtrampolines-by-default \ - 0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during \ - 0010-Don-t-declare-asprintf-if-defined-as-a-macro \ - 0011-libiberty-copy-PIC-objects-during-build-process \ - 0012-libitm-disable-FORTIFY \ - 0013-libgcc_s \ - 0014-nopie \ - 0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu \ - 0016-dlang-update-zlib-binding \ - 0017-dlang-fix-fcntl-on-mips-add-libucontext-dep \ - 0018-ada-fix-shared-linking \ - 0019-build-fix-CXXFLAGS_FOR_BUILD-passing \ - 0020-add-fortify-headers-paths \ - 0023-Pure-64-bit-MIPS \ - 0024-use-pure-64-bit-configuration-where-appropriate \ - 0025-always-build-libgcc_eh.a \ - 0027-ada-musl-support-fixes \ - 0028-gcc-go-Use-_off_t-type-instead-of-_loff_t \ - 0029-gcc-go-Don-t-include-sys-user.h \ - 0030-gcc-go-Fix-ucontext_t-on-PPC64 \ - 0031-gcc-go-Fix-handling-of-signal-34-on-musl \ - 0032-gcc-go-Use-int64-type-as-offset-argument-for-mmap \ - 0034-gcc-go-signal-34-is-special-on-musl-libc \ - 0035-gcc-go-Prefer-_off_t-over-_off64_t \ - 0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c \ - 0037-gcc-go-link-to-libucontext \ - 0038-gcc-go-Disable-printing-of-unaccessible-ppc64-struct \ - 0041-Use-generic-errstr.go-implementation-on-musl \ - 0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand \ - 0043-configure-Add-enable-autolink-libatomic-use-in-LINK_ \ - 0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li -do - patch -Np1 -i ../patches/gcc-11.2.0-alpine/$p.patch -done From 924ef136c596ad86deaba0b1f076977378a587f8 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:38:34 -0600 Subject: [PATCH 008/484] Updated source URL's and md5sums --- sources.list | 30 ++++++++++++++++-------------- sources.md5 | 15 ++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/sources.list b/sources.list index a8c2b3f..770e93e 100644 --- a/sources.list +++ b/sources.list @@ -1,5 +1,5 @@ https://www.kernel.org/pub/linux/docs/man-pages/man-pages-5.11.tar.xz -https://www.musl-libc.org/releases/musl-1.2.2.tar.gz +https://www.musl-libc.org/releases/musl-1.2.3.tar.gz http://skarnet.org/software/skalibs/skalibs-2.10.0.3.tar.gz https://skarnet.org/software/utmps/utmps-0.1.0.2.tar.gz https://www.iana.org/time-zones/repository/releases/tzdata2021a.tar.gz @@ -7,20 +7,20 @@ https://www.iana.org/time-zones/repository/releases/tzcode2021a.tar.gz https://dev.alpinelinux.org/archive/posixtz/posixtz-0.5.tar.xz http://www.lysator.liu.se/~nisse/misc/argp-standalone-1.3.tar.gz https://zlib.net/zlib-1.2.11.tar.xz -ftp://ftp.astron.com/pub/file/file-5.40.tar.gz +https://astron.com/pub/file/file-5.43.tar.gz http://ftp.gnu.org/gnu/readline/readline-8.1.tar.gz http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.xz https://github.com/gavinhoward/bc/releases/download/4.0.2/bc-4.0.2.tar.xz -http://ftp.gnu.org/gnu/binutils/binutils-2.36.1.tar.xz +https://ftp.gnu.org/gnu/binutils/binutils-2.39.tar.xz http://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz -http://www.mpfr.org/mpfr-4.1.0/mpfr-4.1.0.tar.xz +https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.1.tar.xz https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz https://github.com/shadow-maint/shadow/releases/download/4.8.1/shadow-4.8.1.tar.xz -https://dev.alpinelinux.org/~nenolod/gcc-10.3.1_git20210424.tar.xz +https://ftp.gnu.org/gnu/gcc/gcc-12.2.0/gcc-12.2.0.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.7.4.tar.xz -http://ftp.gnu.org/gnu/ncurses/ncurses-6.2.tar.gz +http://ftp.gnu.org/gnu/ncurses/ncurses-6.3.tar.gz 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://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.50.tar.xz @@ -89,13 +89,15 @@ https://downloads.sourceforge.net/tcl/tcl8.6.10-src.tar.gz https://sourceforge.net/projects/expect/files/Expect/5.45.3/expect5.45.3.tar.gz http://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.2.tar.gz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.12.10.tar.xz -http://distcache.freebsd.org/local-distfiles/itetcu/libexecinfo-1.1.tar.bz2 -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/llvm-12.0.0.src.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang-12.0.0.src.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/compiler-rt-12.0.0.src.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/libcxx-12.0.0.src.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/libcxxabi-12.0.0.src.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/libunwind-12.0.0.src.tar.xz -https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/lld-12.0.0.src.tar.xz +http://distcache.freebsd.org/local-distfiles/itetcu/libexecinfo-1.1.tar.bz2 +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/llvm-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/llvm-project-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/clang-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/compiler-rt-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/libcxx-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/libcxxabi-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/libunwind-15.0.5.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.5/lld-15.0.5.src.tar.xz +https://anduin.linuxfromscratch.org/BLFS/llvm/llvm-cmake-15.0.5.src.tar.xz https://cmake.org/files/v3.20/cmake-3.20.4.tar.gz https://dist.libuv.org/dist/v1.41.0/libuv-v1.41.0.tar.gz diff --git a/sources.md5 b/sources.md5 index dd0dc0c..1d80710 100644 --- a/sources.md5 +++ b/sources.md5 @@ -10,9 +10,7 @@ bb91a17fd6c9032c26d0b2b78b50aff5 bash-5.1.tar.gz 628d490d976d8957279bbbff06cf29d4 binutils-2.36.1.tar.xz d61aa92e3562cb7292b004ce96173cf7 bison-3.7.6.tar.xz 50fcafcecde5a380415b12e9c574e0b2 check-0.15.2.tar.gz -877200cc072ece1a52c27677ab26e3ee clang-12.0.0.src.tar.xz 99e849c6910f1df027cc0365027fa19b cmake-3.20.4.tar.gz -313e9b1caf33195cbece3ba3174115a1 compiler-rt-12.0.0.src.tar.xz 022042695b7d5bcf1a93559a9735e668 coreutils-8.32.tar.xz f3438e672e3fa273a7dc26339dd1eed6 cpio-2.13.tar.bz2 e1b07516533f351b3aba3423fafeffd6 dejagnu-1.6.2.tar.gz @@ -27,7 +25,7 @@ a8855cd41c1ef004b9794db9e2a57a9d expect5.45.3.tar.gz eeefe2e6380931a77dfa6d9350b43186 findutils-4.8.0.tar.xz 2882e3179748cc9f9c23ec593d6adc8d flex-2.6.4.tar.gz 8470c34eeecc41c1aa0c5d89e630df50 gawk-5.1.0.tar.xz -6b2dfc39ee0f301f09edfebd163c2cc8 gcc-10.3.1_git20210424.tar.xz +73bafd0af874439dcdb9fc063b6fb069 gcc-12.2.0.tar.xz aeb29c6a90350a4c959cd1df38cd0a7e gdbm-1.19.tar.gz 9ddf4d35636fa3beacd3627cc02723ff gettext-tiny-0.3.2.tar.xz 0b82665c4a92fd2ade7440c13fcaa42b gmp-6.2.1.tar.xz @@ -45,18 +43,13 @@ a43a8da08df0744a6453956718e2b76b isl-0.23.tar.bz2 e81e63acd80697d001c8d85c1acb38a0 kmod-29.tar.xz 6201df5b9dae2af9767fc220471471b3 less-581.tar.gz 66a561afa81666236ff973544ff4e864 libcap-2.50.tar.xz -588d440bfa1420c696b900d5d9c012ae libcxx-12.0.0.src.tar.xz -fb0f38c1a57d67d0c56f617fb1f71b88 libcxxabi-12.0.0.src.tar.xz 8e9e81c554c1c5d735bc877448e92b91 libexecinfo-1.1.tar.bz2 6313289e32f1d38a9df4770b014a2ca7 libffi-3.3.tar.gz dad443d0911cf9f0f1bd90a334bc9004 libpipeline-1.5.3.tar.gz c4a3a25c89cacf19fa36470ab69624e4 libressl-3.3.3.tar.gz 1bfb9b923f2c1339b4d2ce1807064aa5 libtool-2.4.6.tar.xz -a41e903c1989df7de8c39b65fc43467b libunwind-12.0.0.src.tar.xz d990b0770dd2b15f7a8399580d55d32c libuv-v1.41.0.tar.gz 7a3d78b97103f2b64c8c8592c1dfbe8d linux-5.12.10.tar.xz -7368ec545a26d67dbc487706970827c1 lld-12.0.0.src.tar.xz -ceab21c9081e122a88d82216a80d0dc0 llvm-12.0.0.src.tar.xz 730bb15d96fffe47e148d1e09235af82 m4-1.4.18.tar.xz fc7a67ea86ace13195b0bce683fd4469 make-4.3.tar.gz 6e233a555f7b9ae91ce7cd0faa322bce man-db-2.9.4.tar.xz @@ -64,8 +57,8 @@ fc7a67ea86ace13195b0bce683fd4469 make-4.3.tar.gz 18ac55e3d6a5acb17b5737eb2a15bb5b meson-0.58.0.tar.gz 9f16c976c25bb0f76b50be749cd7a3a8 mpc-1.2.1.tar.gz bdd3d5efba9c17da8d83a35ec552baef mpfr-4.1.0.tar.xz -aed8ae9e2b0898151b36a204088292dd musl-1.2.2.tar.gz -e812da327b1c2214ac1aed440ea3ae8d ncurses-6.2.tar.gz +a507ae4f7f20bcfe566d8eb65c1af73e musl-1.2.3.tar.gz +a2736befde5fee7d2b7eb45eb281cdbe ncurses-6.3.tar.gz 639f75bc2e3b19ab893eaf2c810d4eb4 ninja-1.10.2.tar.gz 78ad9937e4caadcba1526ef1853730d5 patch-2.7.6.tar.xz df7ecb0653440b26dc951ad9dbfab517 perl-5.34.0.tar.xz @@ -82,7 +75,6 @@ d245f2d3c0399f32b5e834adb30c0531 s6-linux-init-1.0.6.3.tar.gz 6d906edfdb3202304059233f51f9a71d sed-4.8.tar.xz 4b05eff8a427cf50e615bda324b5bc45 shadow-4.8.1.tar.xz 85ad305218d10fe65b38c4c351faa395 skalibs-2.10.0.3.tar.gz -d0462c4f60c1783311a77583f60a68bb sources.list 9a08d29a9ac4727130b5708347c0f5cf tar-1.34.tar.xz 97c55573f8520bcab74e21bfd8d0aadc tcl8.6.10-src.tar.gz d4c5d8cc84438c5993ec5163a59522a6 texinfo-6.7.tar.xz @@ -99,3 +91,4 @@ ec8a8ec5f67b0ad0edba82cad2354d33 vim-8.2.2890.tar.gz aa1621ec7013a19abab52a8aff04fe5b xz-5.2.5.tar.xz 85adef240c5f370b308da8c938951a68 zlib-1.2.11.tar.xz a6eb7fb1f2c21fa80030a47993853e92 zstd-1.5.0.tar.gz +a2915a201a1eb1d32833818fd27f77b9 llvm-project-15.0.5.src.tar.xz From bc8daad8ddd3ed9f1014d26746715d961d6bcf75 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:41:45 -0600 Subject: [PATCH 009/484] Added project status --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b6a674..488ef81 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ CMLFS can either mean "Clang-built Musl Linux from Scratch" or "Clang MLFS". It started as a hobby to see if a Linux system can be built with clang as primary toolchain and GCC as secondary (for packages that cannot be built with clang). This is based on Linux From Scratch (www.linuxfromscratch.org) and my previous work MLFS (https://github.com/dslm4515/Musl-LFS). +# Project Status +Attempted to upgrade CMLFS to LLVM-15.0.5... required new build methods. Currently, cgnutools can be built with a stage 0 clang but cannot build stage 1 clang for llvmtools. + ## Specification
  • C Runtime Library (system libc): Musl
  • @@ -46,7 +49,7 @@ CMLFS can either mean "Clang-built Musl Linux from Scratch" or "Clang MLFS". It
  • [x] Build toolchain (llvmtools) with GCC as secondary compiler
  • [x] Merge cross-tools build with cgnutools
  • [x] Build successfully on a Glibc host
  • -
  • [ ] Reduce LLVM size & build time for cgnutools and llvmtools +
  • [x] Reduce LLVM size & build time for cgnutools and llvmtools
  • [ ] Build on aarch64
From 88f0d7f786c069f16f3640e44503659deb32f386 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Wed, 21 Dec 2022 08:59:13 -0600 Subject: [PATCH 010/484] stage 1 clang fails to compile. --- 2-llvmtools/07-clang-llvm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/2-llvmtools/07-clang-llvm b/2-llvmtools/07-clang-llvm index 59614fc..11e742c 100644 --- a/2-llvmtools/07-clang-llvm +++ b/2-llvmtools/07-clang-llvm @@ -172,4 +172,36 @@ ninja -C build builtins ninja -C build unwind ninja -C build cxxabi ninja -C build cxx # .............. Stage 0 clang still lacks atomics... need lib/clang/14.0.5/lib/linux/libclang_rt.tsan-x86_64.so ? -ninja -C build compiler-rt +ninja -C build compiler-rt + +# Compile just clang with runtimes? +CC=${TARGET_TUPLE}-clang \ +CXX=${TARGET_TUPLE}-clang++ \ +cmake -B build -G Ninja -Wno-dev -S llvm -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ + -DLLVM_RUNTIME_TARGETS=x86_64-pc-linux-musl \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} ${BOFF} ${COPTS} -DBacktrace_INCLUDE_DIR=/llvmtools/include -DCLANG_DEFAULT_UNWINDLIB=libunwind \ + -DCLANG_ENABLE_ARCMT=OFF -DCLANG_ENABLE_PROTO_FUZZER=OFF -DCLANG_TOOL_ARCMT_TEST_BUILD=OFF -DCLANG_TOOL_CLANG_FUZZER_BUILD=OFF \ + -DCLANG_TOOL_C_ARCMT_TEST_BUILD=OFF -DC_INCLUDE_DIRS=/llvmtools/include -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_TOOL_GOLD_BUILD=OFF \ + -DBUILD_SHARED_LIBS=ON -DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON -DLLVM_ENABLE_LIBCXX=ON \ + -DLLVM_TOOL_COMPILER_RT_BUILD=ON -DLLVM_TOOL_LIBCXXABI_BUILD=ON -DLLVM_TOOL_LIBCXX_BUILD=ON -DLLVM_TOOL_LIBUNWIND_BUILD=ON \ + -DLLVM_TOOL_LLD_BUILD=ON -DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF -DLLVM_ENABLE_LLD=ON + +# Manually-specified variables were not used by the project: + + COMPILER_RT_BUILD_GWP_ASAN + COMPILER_RT_BUILD_LIBFUZZER + COMPILER_RT_BUILD_ORC + COMPILER_RT_DEFAULT_TARGET_TRIPLE + LIBCXXABI_USE_COMPILER_RT + LIBCXXABI_USE_LLVM_UNWINDER + LIBCXX_ENABLE_LOCALIZATION + LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS + LIBCXX_USE_COMPILER_RT + LIBUNWIND_INCLUDE_DOCS + LIBUNWIND_INCLUDE_TESTS + LIBUNWIND_INSTALL_LIBRARY_DIR + +# Compile +ninja -C build runtimes # ..... Fails: " is not supported since libc++ has been configured without support for localization." From 7365bae01e71cc84d1e35c78c6d5402b171cf66c Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Wed, 21 Dec 2022 09:00:02 -0600 Subject: [PATCH 011/484] Failed attempt to build LLVM runtimes with just-build clang --- 1-cgnutools/FAILED-llvm.runtime.clang | 105 ++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 1-cgnutools/FAILED-llvm.runtime.clang diff --git a/1-cgnutools/FAILED-llvm.runtime.clang b/1-cgnutools/FAILED-llvm.runtime.clang new file mode 100644 index 0000000..69f0543 --- /dev/null +++ b/1-cgnutools/FAILED-llvm.runtime.clang @@ -0,0 +1,105 @@ +# cgnutools: Stage 0 Clang ( with compiler-rt,libcxx,libcxxabi,libunwind,lld) +# +# Build as cmlfs +# +# NOTES: Build a stage 0 clang with compiler-rt support AND gcc dependancy. Later, +# Stage 1 clang will be built with only compiler-rt support + +# Rename for shorter paths: +mv llvm-project-15.0.5.src llvm +export LLVMSRC=${CMLFS}/sources/llvm + +cd $LLVMSRC + +# Apply patches for main LLVM source ... from alpine linux: +patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch +patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch +patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch +patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch + +# Known broken test on musl +cd llvm +rm -v test/CodeGen/AArch64/wineh4.mir +# https://github.com/llvm/llvm-project/issues/47657 +rm -v test/ExecutionEngine/Interpreter/intrinsics.ll + +# If builing on x86, remove tests: +rm -v test/Object/macho-invalid.test test/tools/llvm-size/radix.test unittests/Support/JSONTest.cpp +sed -i "/JSONTest.cpp/d" unittests/Support/CMakeLists.txt + +# If building on arm*, remove tests: +rm -v test/tools/llvm-readobj/ELF/dependent-libraries.test test/Object/macho-invalid.test \ + test/tools/llvm-size/radix.test test/tools/gold/X86/split-dwarf.ll \ + test/ExecutionEngine/frem.ll test/tools/llvm-dwarfdump/X86/prettyprint_types.s \ + test/tools/llvm-dwarfdump/X86/simplified-template-names.s \ + unittests/ExecutionEngine/Orc/OrcCAPITest.cpp \ + test/CodeGen/RISCV/rv32zbp.ll \ + test/CodeGen/RISCV/rv64zbp.ll +sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt + +# Return to top-level +cd .. + +# Apply patches for clang +cd clang +patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch +patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch + +# Apply patches for compiler-rt +cd ../compiler-rt +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch + +# Apply patches for libcxx +cd ../libcxx +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch + +cd .. + +# Set flags to greatly reduce debugging symbols +CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' +CXXFLAGS=$CFLAGS +export CFLAGS CXXFLAGS + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1" +export CTOOLS="-DCMAKE_C_COMPILER=${CMLFS_TARGET}-gcc " +export CTOOLS+="-DCMAKE_CXX_COMPILER=${CMLFS_TARGET}-g++ " +export CTOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " + +# Set the tuples & build target ... +export CTARG="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=X86 " +export CTARG+="-DLLVM_TARGET_ARCH=X86 " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=Native " + +# Set the paths ... +export CPATHS="-DCMAKE_INSTALL_PREFIX=/cgnutools " +export CPATHS+="-DDEFAULT_SYSROOT=/cgnutools " +export CPATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/cgnutools/lib " +export CPATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/cgnutools/include " + +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="clang" \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} -DCLANG_VENDOR="cgnutools 3.0.0" \ + -DBENCHMARK_INSTALL_DOCS=OFF -DBENCHMARK_USE_BUNDLED_GTEST=OFF -DCLANG_INCLUDE_DOCS=OFF -DCLANG_INCLUDE_TESTS=OFF \ + -DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF -DCLANG_TOOL_C_ARCMT_TEST_BUILD=OFF -DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF \ + -DCUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE=OFF -DCUDA_HOST_COMPILATION_CPP=OFF \ + -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_OCAMLDOC=OFF \ + -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_ZSTD=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_DOCS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DCLANG_TOOL_ARCMT_TEST_BUILD=OFF \ + -DCLANG_TOOL_CLANG_FUZZER_BUILD=OFF -DCLANG_TOOL_CLANG_NVLINK_WRAPPER_BUILD=OFF -DCUDA_PROPAGATE_HOST_FLAGS=OFF \ + -DLLVM_ENABLE_LIBPFM=OFF -DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF -DLLVM_ENABLE_UNWIND_TABLES=OFF + +# Compile +ninja -C build runtimes # 2642 targets .... fails. "Compiler doesn't support generation of unwind tables + # if exception support is disabled. Building libunwind DSO with runtime dependency + # on C++ ABI library is not supported. + +unset CC CXX CFLAGS CXXFLAGS CTOOLS CTARG CPATHS From 2f407d9aca429eca8145b8f83f6648273caa4f19 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Wed, 21 Dec 2022 09:02:10 -0600 Subject: [PATCH 012/484] Failed attempt to skip stage0 clang and built stage1 clang: clang 1 depends on libgcc_s and libstdc++ --- 1-cgnutools/FAILED.llvmtools.LLVM-P1 | 99 +++++++++++++ 1-cgnutools/FAILED.llvmtools.LLVM-P2 | 207 +++++++++++++++++++++++++++ 2 files changed, 306 insertions(+) create mode 100644 1-cgnutools/FAILED.llvmtools.LLVM-P1 create mode 100644 1-cgnutools/FAILED.llvmtools.LLVM-P2 diff --git a/1-cgnutools/FAILED.llvmtools.LLVM-P1 b/1-cgnutools/FAILED.llvmtools.LLVM-P1 new file mode 100644 index 0000000..32fe365 --- /dev/null +++ b/1-cgnutools/FAILED.llvmtools.LLVM-P1 @@ -0,0 +1,99 @@ +# Build musl libc for llvmtools with gcc of cgnutools +# build as cmlfs + +export CC=${CMLFS_TARGET}-gcc +export CXX=${CMLFS_TARGET}-g++ + +CC=$CC CXX=$CXX ./configure --prefix=/ + +# Build and install to llvmtools +make && make DESTDIR=/llvmtools install + +# fix a symlink +rm -v /llvmtools/lib/ld-musl-x86_64.so.1 +ln -sv libc.so /llvmtools/lib/ld-musl-x86_64.so.1 + +# Create a symlink to make a tool that can print the +# shared objects (shared libraries) required by each +# program or shared object (i.e. library) +mkdir /llvmtools/{bin,etc} +ln -sv ../lib/libc.so /llvmtools/bin/ldd + +# Configure dynamic linker +cat > /llvmtools/etc/ld-musl-x86_64.path << "EOF" +/llvmtools/lib +EOF + +# Install the kernel headers +# as cmlfs + +# Clean +make mrproper + +# Generate headers +make ARCH=${CMLFS_ARCH} CC=$CC CXX=$CXX headers + +# Install to llvmtools +find usr/include \( -name .install -o -name ..install.cmd \) -delete +cp -rv usr/include/* /llvmtools/include/ + +# Remove unecessary Makefile +rm -v /llvmtools/include/Makefile + +# Build libexecinfo +# as cmlfs + +# Patch source to fix broken build system +patch -Np1 -i ../patches/libexecinfo-alpine/10-execinfo.patch +patch -Np1 -i ../patches/libexecinfo-alpine/20-define-gnu-source.patch +patch -Np1 -i ../patches/libexecinfo-alpine/30-linux-makefile.patch + +# build +CC=$CC CXX=$CXX CFLAGS=" -fno-omit-frame-pointer" make + +# Install to llvmtools +install -D -m755 -v execinfo.h /llvmtools/include/execinfo.h && \ +install -D -m755 -v stacktraverse.h /llvmtools/include/stacktraverse.h && \ +install -D -m755 -v libexecinfo.a /llvmtools/lib/libexecinfo.a && \ +install -D -m755 -v libexecinfo.so.1 /llvmtools/lib/libexecinfo.so.1 && \ +ln -sv libexecinfo.so.1 /llvmtools/lib/libexecinfo.so + +# Build ncurses +# as cmlfs + +# Then, run the following commands to build the “tic” program on the build host: +unset CC CXX +mkdir build +pushd build + ../configure + make -C include + make -C progs tic +popd + +# Ensure that gawk is found first during configuration: +sed -i s/mawk// configure + +# Configure +export CC=${CMLFS_TARGET}-gcc +export CXX=${CMLFS_TARGET}-g++ + +CC=$CC CXX=$CXX \ +./configure --prefix=/llvmtools \ + --host=${TARGET_TUPLE} \ + --with-shared \ + --without-debug \ + --without-ada \ + --enable-widec \ + --enable-overwrite + +# Build and install +make && make TIC_PATH=$(pwd)/build/progs/tic install + +# Bash build expects to find libcurses.so: +ln -sv libncursesw.so.6.2 /llvmtools/lib/libcurses.so + +# Create symlinks for building stage 1 clang. +# Required by llvm-tblgen when building stage 1 LLD +ln -sv /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6.0.30 /llvmtools/lib/libstdc++.so.6 +ln -sv /cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1 /llvmtools/lib/libgcc_s.so.1 + diff --git a/1-cgnutools/FAILED.llvmtools.LLVM-P2 b/1-cgnutools/FAILED.llvmtools.LLVM-P2 new file mode 100644 index 0000000..0279c07 --- /dev/null +++ b/1-cgnutools/FAILED.llvmtools.LLVM-P2 @@ -0,0 +1,207 @@ +# cgnutools: Stage0 Clang ( with compiler-rt,libcxx,libcxxabi,libunwind,lld) +# +# Build as cmlfs +# +# NOTES: Skip stage 0 clang. Build stage 1 clang with GCC in cgnutools. +# o Configure cgnutools to build for llvmtools. +# o Build musl, kheaders, libexecinfo, ncurses to install in llvmtools +# +# Rename for shorter paths: +mv llvm-project-15.0.5.src llvm +export LLVMSRC=${CMLFS}/sources/llvm + +cd $LLVMSRC + +# Apply patches for main LLVM source ... from alpine linux: +patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch +patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch +patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch +patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch + +# Known broken test on musl +cd llvm +rm -v test/CodeGen/AArch64/wineh4.mir +# https://github.com/llvm/llvm-project/issues/47657 +rm -v test/ExecutionEngine/Interpreter/intrinsics.ll + +# If builing on x86, remove tests: +rm -v test/Object/macho-invalid.test test/tools/llvm-size/radix.test unittests/Support/JSONTest.cpp +sed -i "/JSONTest.cpp/d" unittests/Support/CMakeLists.txt + +# If building on arm*, remove tests: +rm -v test/tools/llvm-readobj/ELF/dependent-libraries.test test/Object/macho-invalid.test \ + test/tools/llvm-size/radix.test test/tools/gold/X86/split-dwarf.ll \ + test/ExecutionEngine/frem.ll test/tools/llvm-dwarfdump/X86/prettyprint_types.s \ + test/tools/llvm-dwarfdump/X86/simplified-template-names.s \ + unittests/ExecutionEngine/Orc/OrcCAPITest.cpp \ + test/CodeGen/RISCV/rv32zbp.ll \ + test/CodeGen/RISCV/rv64zbp.ll +sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt + +# Return to top-level +cd .. + +# Apply patches for clang +cd clang +patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch +patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch + +# Apply patches for compiler-rt +cd ../compiler-rt +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch + +# Apply patches for libcxx +cd ../libcxx +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch + +cd .. + +# Set flags to greatly reduce debugging symbols +CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' +CXXFLAGS=$CFLAGS +export CFLAGS CXXFLAGS + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1" +export CTOOLS="-DCMAKE_C_COMPILER=${CMLFS_TARGET}-gcc " +export CTOOLS+="-DCMAKE_CXX_COMPILER=${CMLFS_TARGET}-g++ " +export CTOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " + +# Set the tuples & build target ... +export CTARG="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=X86 " +export CTARG+="-DLLVM_TARGET_ARCH=X86 " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=Native " + +# Set the paths ... +export CPATHS="-DCMAKE_INSTALL_PREFIX=/llvmtools " +export CPATHS+="-DDEFAULT_SYSROOT=/llvmtools " +export CPATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/llvmtools/lib " +export CPATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/llvmtools/include " + +# Set bootstrap options.. +# https://discourse.llvm.org/t/bootstrapping-standalone-llvm-clang-libc-lld-toolchain/3069 +export CBSTRAP="-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release " +export CBSTRAP+="-DCLANG_ENABLE_BOOTSTRAP=ON " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt " +export CBSTRAP+="-DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=ON " +export CBSTRAP+="-DBOOTSTRAP_LLVM_USE_LINKER=lld " +export CBSTRAP+="-DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=ON " +# make sure bootstrap has atomics +#export CBSTRAP+="-DBOOTSTRAP_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC=ON " +#export CBSTRAP+="-DBOOTSTRAP_COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " + +# Set the standard C++ library that clang will use to LLVM's libc++: +export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " + +# Set the runtime library that clang will use to compiler-rt: +export COPTS+="-DCLANG_DEFAULT_RTLIB=compiler-rt " + +# Set libc++abi & libc++ to use compiler-rt instead of gcc's runtime: +export COPTS+="-DLIBCXX_USE_COMPILER_RT=ON " +export COPTS+="-DLIBCXXABI_USE_COMPILER_RT=ON " + +# Set libc++abi to use libunwind to avoid dependace on GCC: +export COPTS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " + +# Enable Exception Handling: +export COPTS+="-DLLVM_ENABLE_EH=ON " + +# Exception handling requires Runtime Type Info +export COPTS+="-DLLVM_ENABLE_RTTI=ON " + +# Stage 1 clang's compiler-rt will require new delete definitions in libc++ +export COPTS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " + +# Enable atomics to avoid using atomics from GCC: +export COPTS+="-DCOMPILER_RT_BUILD_STANDALONE_LIBATOMIC=OFF " +export COPTS+="-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " + +# Turn off features ... +export BOFF="-DLLVM_ENABLE_LIBXML2=OFF -DLIBCXX_ENABLE_LOCALIZATION=OFF " +export BOFF+="-DLLVM_ENABLE_ZLIB=OFF -DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " +export BOFF+="-DLLVM_ENABLE_ZSTD=OFF -DLIBUNWIND_INCLUDE_TESTS=OFF " +export BOFF+="-DLLVM_ENABLE_LIBEDIT=OFF -DLIBUNWIND_INCLUDE_DOCS=OFF " + +export BOFF+="-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF " + +# Turn off features that cause compiler-rt to NOT reference backtrace symbols from libexecinfo +export BOFF+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_ORC=OFF " + +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="compiler-rt;libunwind;libcxx;libcxxabi;lld;clang" \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} ${CBSTRAP} ${COPTS} ${BOFF} -DLIBUNWIND_INSTALL_HEADERS=ON + +# Compile only what we need for a stage 0 clang +#ninja -C build builtins #164 targets +#ninja -C build unwind #19 +#ninja -C build cxxabi #829 +#ninja -C build cxx #79 +#ninja -C build compiler-rt # 598 +#ninja -C build lld #1652 +#ninja -C build libclang #798 +#ninja -C build clang #288 + +for t in builtins unwind cxxabi cxx compiler-rt lld libclang clang ; +do + ninja -C build $t +done + +# Compile LLVM binutils(binary utilities) +for b in addr2line ar as config cxxdump diff link lipo \ + lto lto2 nm objcopy objdump ranlib rc readelf \ + size split strings strip tblgen ; +do + ninja -C build llvm-$b +done + +# STOP! Built llibraries and binaries depend on libgcc_s & libstdc++ that were linked earlier + +# Install only what we built to /cgnutools +#ninja -C build install-builtins #............... libclang_rt.builtins.a +#ninja -C build install-crt #.................... clang_rt.crtbegin.o;clang_rt.crtbend.o +#ninja -C build install-unwind #................. /cgnutools/lib/libunwind.so.1.0 & /cgnutools/include/libunwind.h +#ninja -C build install-cxxabi #................. /cgnutools/lib/x86_64-pc-linux-musl/libc++abi.so.1.0 +#ninja -C build install-cxxabi-headers #......... /cgnutools/include/c++/v1/__cxxabi_config.h;/cgnutools/include/c++/v1/cxxabi_config.h +#ninja -C build install-cxx #.................... /cgnutools/lib/x86_64-pc-linux-musl/libc++.so.1.0 +#ninja -C build install-cxx-headers # ........... /cgnutools/include/c++/v1;/cgnutools/include/x86_64-pc-linux-musl/c++/v1 +#ninja -C build install-compiler-rt # ........... /cgnutools/lib/clang/15.0.5/lib/x86_64-pc-linux-musl/* +#ninja -C build install-lld # ................... lld-link;ld.lld;ld64.lld;wasm-ld +#ninja -C build install-libclang # .............. /cgnutools/lib/libclang.so.15.0.5 +#ninja -C build install-libclang-headers #....... /cgnutools/include/clang-c +#ninja -C build install-clang # ................. /cgnutools/bin/{clang,clang-15,clang++,clang-cl,clang-cpp} +#ninja -C build install-x86-resource-headers #..... /cgnutools/lib/clang/15.0.5/include/* +#ninja -C build install-utility-resource-headers #../cgnutools/lib/clang/15.0.5/include/mm_malloc.h +#ninja -C build install-ve-resource-headers #......./cgnutools/lib/clang/15.0.5/include/velintrin* +#ninja -C build install-compiler-rt-headers #......./cgnutools/lib/clang/15.0.5/include/sanitizer/* +#ninja -C build install-clang-resource-headers #..../cgnutools/lib/clang/15.0.5/include/builtins.h +#ninja -C build install-clang-headers #............./cgnutools/include/clang/AST + +for t in butiltins crt unwind cxxabi cxx compiler-rt lld libclang libclang-headers clang \ + x86-resource-headers utility-resource-headers ve-resource-headers \ + compiler-rt-headers clang-resource-headers clang-headers ; +do + ninja -C build install-$t +done + +# Install LLVM binutils: +for b in addr2line ar as config cxxdump diff link lipo \ + lto lto2 nm objcopy objdump ranlib rc readelf \ + size split strings strip tblgen ; +do + ninja -C build install-llvm-$b +done + +unset CC CXX CFLAGS CXXFLAGS CTOOLS CTARG CPATHS CBSTRAP COPTS BOFF LINKERFLAGS From 5288c960785e94d597383142bda435cfc16ae654 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Thu, 22 Dec 2022 10:03:14 -0600 Subject: [PATCH 013/484] Attempted to build LLVM runtimes seperate from clang for cgnutools --- 1-cgnutools/LLVM.Runtimes | 198 ++++++++++++++++++++++++++++++++++++++ 1-cgnutools/LLVM.clang | 133 +++++++++++++++++++++++++ 2 files changed, 331 insertions(+) create mode 100644 1-cgnutools/LLVM.Runtimes create mode 100644 1-cgnutools/LLVM.clang diff --git a/1-cgnutools/LLVM.Runtimes b/1-cgnutools/LLVM.Runtimes new file mode 100644 index 0000000..439d931 --- /dev/null +++ b/1-cgnutools/LLVM.Runtimes @@ -0,0 +1,198 @@ +# cgnutools: LLVM Runtime libraries (libunwind, libcxxabi, libcxx) +# +# Build as cmlfs. +# +# Build LLVM Runtime libraries fo stage 0 clang to use. +# + +# Rename for shorter paths: +mv llvm-project-15.0.5.src llvm +export LLVMSRC=${CMLFS}/sources/llvm + +cd $LLVMSRC + +# Apply patches for main LLVM source ... from alpine linux: +patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch +patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch +patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch +patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch + +# Known broken test on musl +cd llvm +rm -v test/CodeGen/AArch64/wineh4.mir +# https://github.com/llvm/llvm-project/issues/47657 +rm -v test/ExecutionEngine/Interpreter/intrinsics.ll + +# If builing on x86, remove tests: +rm -v test/Object/macho-invalid.test test/tools/llvm-size/radix.test unittests/Support/JSONTest.cpp +sed -i "/JSONTest.cpp/d" unittests/Support/CMakeLists.txt + +# If building on arm*, remove tests: +rm -v test/tools/llvm-readobj/ELF/dependent-libraries.test test/Object/macho-invalid.test \ + test/tools/llvm-size/radix.test test/tools/gold/X86/split-dwarf.ll \ + test/ExecutionEngine/frem.ll test/tools/llvm-dwarfdump/X86/prettyprint_types.s \ + test/tools/llvm-dwarfdump/X86/simplified-template-names.s \ + unittests/ExecutionEngine/Orc/OrcCAPITest.cpp \ + test/CodeGen/RISCV/rv32zbp.ll \ + test/CodeGen/RISCV/rv64zbp.ll +sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt + +# Return to top-level +cd .. + +# Apply patches for clang +cd clang +patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch +patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch + +# Apply patches for compiler-rt +cd ../compiler-rt +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch +patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch + +# Apply patches for libcxx +cd ../libcxx +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch +patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch + +cd .. + +# Fix libcxx localization: +# Musl doesn't support strtoll_l(), so replace it with a simple strtoll() call. +# edit libcxx/include/locale + +# Set CC and CXX compiler with cross-gcc +export CXX=${CMLFS_TARGET}-g++ +export CC=${CMLFS_TARGET}-gcc + +# Set flags to greatly reduce debugging symbols +CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' +CXXFLAGS=$CFLAGS +export CFLAGS CXXFLAGS + +# Set the build options .. +export CONFIG_OPTIONS="-DCMAKE_BUILD_TYPE=Release " +export CONFIG_OPTIONS+="-DBUILD_SHARED_LIBS=ON " + +# Build libc++abi with compiler-rt [from cgnutools] and +# libunwind from cgnutools: +#export CONFIG_OPTIONS+="-DLIBCXXABI_USE_COMPILER_RT=ON " +#export CONFIG_OPTIONS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " + +export CONFIG_OPTIONS+="-DLIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST=ON " + +# Stage 1 compiler-rt will require new DELETE definitions +export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " + +# Libc++ will not build with localization as musl does not +# have built in support. To enable, libc++ will need patching. +export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_LOCALIZATION=ON " #<<<<<<<<<<<< + +# Build libc++ with musl support +export CONFIG_OPTIONS+="-DLIBCXX_HAS_MUSL_LIBC=ON " + +# Build libc++ & libunwind with compiler-rt [from cgnutools]: +#export CONFIG_OPTIONS+="-DLIBCXX_USE_COMPILER_RT=ON " +#export CONFIG_OPTIONS+="-DLIBUNWIND_USE_COMPILER_RT=ON " + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1" +export CONFIG_TOOLS="-DCMAKE_C_COMPILER=${CC} " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${CXX} " +#export CONFIG_TOOLS+="-DCMAKE_ADDR2LINE=/cgnutools/bin/llvm-addr2line " +#export CONFIG_TOOLS+="-DCMAKE_AR=/cgnutools/bin/llvm-ar " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${CXX} " +#export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER_AR=/cgnutools/bin/llvm-ar " +#export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER_RANLIB=/cgnutools/bin/llvm-ranlib " +export CONFIG_TOOLS+="-DCMAKE_C_COMPILER=${CC} " +#export CONFIG_TOOLS+="-DCMAKE_C_COMPILER_AR=/cgnutools/bin/llvm-ar " +#export CONFIG_TOOLS+="-DCMAKE_C_COMPILER_RANLIB=/cgnutools/bin/llvm-ranlib " +#export CONFIG_TOOLS+="-DCMAKE_LINKER=/cgnutools/bin/lld " +#export CONFIG_TOOLS+="-DCMAKE_NM=/cgnutools/bin/llvm-nm " +#export CONFIG_TOOLS+="-DCMAKE_OBJCOPY=/cgnutools/bin/llvm-objcopy " +#export CONFIG_TOOLS+="-DCMAKE_OBJDUMP=/cgnutools/bin/llvm-objdump " +#export CONFIG_TOOLS+="-DCMAKE_RANLIB=/cgnutools/bin/llvm-ranlib " +#export CONFIG_TOOLS+="-DCMAKE_READELF=/cgnutools/bin/llvm-readelf " +#export CONFIG_TOOLS+="-DCMAKE_STRIP=/cgnutools/bin/llvm-strip " + +# Set paths... +export CONFIG_PATHS="-DCMAKE_INSTALL_PREFIX=/cgnutools " +export CONFIG_PATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/cgnutools/include " +export CONFIG_PATHS+="-DCMAKE_INSTALL_BINDIR=/cgnutools/bin " +export CONFIG_PATHS+="-DCMAKE_INSTALL_DATAROOTDIR=/cgnutools/share " +export CONFIG_PATHS+="-DCMAKE_INSTALL_INCLUDEDIR=/cgnutools/include " +export CONFIG_PATHS+="-DCMAKE_INSTALL_LIBDIR=/cgnutools/lib " +export CONFIG_PATHS+="-DCMAKE_INSTALL_LIBEXECDIR=/cgnutools/libexec " +export CONFIG_PATHS+="-DCMAKE_INSTALL_SBINDIR=/cgnutools/sbin " +export CONFIG_PATHS+="-DBacktrace_LIBRARY=/cgnutools/lib/libexecinfo.so.1 " +export CONFIG_PATHS+="-DBacktrace_INCLUDE_DIR=/cgnutools/include " +#export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +#export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_LIBRARY_DIR=/llvmtools/lib/x86_64-pc-linux-musl " #default: lib/x86_64-pc-linux-musl +#export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +#export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +#export CONFIG_PATHS+="-DLIBCXX_INSTALL_LIBRARY_DIR=/llvmtools/lib/x86_64-pc-linux-musl " #default: lib/x86_64-pc-linux-musl +export CONFIG_PATHS+="-DLIBCXX_INSTALL_RUNTIME_DIR=/cgnutools/bin " #default: bin +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/cgnutools/lib " +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_INCLUDE_DIR=/cgnutools/include " +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_RUNTIME_DIR=/cgnutools/lib" + +# Turn off unwanted features, docs and tests +export BUILD_OFF="-DLLVM_BUILD_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_GO_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_DOCS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBEDIT=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBXML2=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBPFM=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_TERMINFO=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_ZLIB=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_Z3_SOLVER=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_CRASH_OVERRIDES=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_ZSTD=OFF " +export BUILD_OFF+="-DLLVM_APPEND_VC_REV=OFF " +export BUILD_OFF+="-DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_MICROSOFT_DEMANGLE_FUZZER_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_ITANIUM_DEMANGLE_FUZZER_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_GO_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_PASSES_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_BUILD=OFF " +export BUILD_OFF+="-DLIBCXX_INCLUDE_BENCHMARKS=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_AS_FUZZER_BUILD=OFF -DLLVM_TOOL_LLVM_BCANALYZER_BUILD=OFF -DLLVM_TOOL_LLVM_DLANG_DEMANGLE_FUZZER_BUILD=OFF " + +# Configure source: +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS}" \ + ${CONFIG_TOOLS} ${CONFIG_OPTIONS} ${CONFIG_PATHS} ${BUILD_OFF} \ + -DLLVM_ENABLE_PROJECTS="libcxxabi;libcxx;libunwind" \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_TARGET_ARCH=host \ + -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl \ + -DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl -DLIBUNWIND_INSTALL_HEADERS=ON + +# Compile +ninja -C build unwind #19 targets +ninja -C build cxxabi #829 +ninja -C build cxx #77 + +# Install to cgnutools +ninja -C build install-unwind +ninja -C build install-cxxabi +ninja -C build install-cxxabi-headers +ninja -C build install-cxx +ninja -C build install-cxx-headers + +# Move misplaced headers: +mv -v /cgnutools/include/x86_64-pc-linux-musl/c++/v1/* /cgnutools/include/c++/v1/ +rm -rfv /cgnutools/include/x86_64-pc-linux-musl/c++/v1 + +# Remove build directory for next build. +# Same source tree will be used next +rm -rf build + +unset CONFIG_TOOLS CONFIG_OPTIONS CONFIG_PATHS LINKERFLAGS LINKERFLAGS BUILD_OFF diff --git a/1-cgnutools/LLVM.clang b/1-cgnutools/LLVM.clang new file mode 100644 index 0000000..c88a521 --- /dev/null +++ b/1-cgnutools/LLVM.clang @@ -0,0 +1,133 @@ +# cgnutools: LLVM Clang +# +# Build as cmlfs +# +# libunwind, libcxxabi, and libcxx now need to be built together. + +# Reused unpacked LLVM source from building LLVM runtimes + +# Set cxxflags for cross-gcc to build clang with the +# just built LLVM runtimes + +export CXXFLAGS="-nostdinc++ -nodefaultlibs " +export CXXFLAGS+="-isystem /cgnutools/include/c++/v1 " +export CXXFLAGS+="-L/cgnutools/lib/x86_64-pc-linux-musl " +export CXXFLAGS+="-Wl,-rpath,/cgnutools/lib/x86_64-pc-linux-musl " +export CXXFLAGS+="-lc++ -lc++abi -lm -lc -lgcc_s -lgcc " + +# Test that cross-gcc will use the LLVM runtime libraries : +cat > atomics-test.cpp << "EOF" +#include +std::atomic x; +std::atomic y; +std::atomic z; +int main() { + ++z; + ++y; + return ++x; + } +EOF + +${CMLFS_TARGET}-g++ $CXXFLAGS atomics-test.cpp -v -Wl,--verbose &> atomics-test.log + +# Check if runtime lbraries are used: +grep libc++ atomics-test.log | grep succeeded + +# Should output: +# attempt to open /cgnutools/lib/x86_64-pc-linux-musl/libc++.so succeeded +# attempt to open /cgnutools/lib/x86_64-pc-linux-musl/libc++.so.1 succeeded +# attempt to open /cgnutools/lib/x86_64-pc-linux-musl/libc++abi.so succeeded +# attempt to open /cgnutools/lib/x86_64-pc-linux-musl/libc++abi.so succeeded + +# If all is good, clean up: +rm -rf atomics-test.cpp atomics-test.log + +# Set flags to greatly reduce debugging symbols +CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' +CXXFLAGS+=" -g -g1 -Wl,--as-needed -lexecinfo " +export CFLAGS + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1" +export CTOOLS="-DCMAKE_C_COMPILER=${CMLFS_TARGET}-gcc " +export CTOOLS+="-DCMAKE_CXX_COMPILER=${CMLFS_TARGET}-g++ " +export CTOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " + +# Set the tuples & build target . +# Using vendor pc instead of CMLFS since clang is the last +# tool to build for cgnutools +export CTARG="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=X86 " +export CTARG+="-DLLVM_TARGET_ARCH=X86 " +export CTARG+="-DLLVM_TARGETS_TO_BUILD=Native " + +# Set the paths ... +export CPATHS="-DCMAKE_INSTALL_PREFIX=/cgnutools " +export CPATHS+="-DDEFAULT_SYSROOT=/cgnutools " +export CPATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/cgnutools/include " + +# Set bootstrap options.. +# # https://discourse.llvm.org/t/bootstrapping-standalone-llvm-clang-libc-lld-toolchain/3069 +export CBSTRAP="-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release " +export CBSTRAP+="-DCLANG_ENABLE_BOOTSTRAP=ON " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ " +export CBSTRAP+="-DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt " +export CBSTRAP+="-DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=ON " +export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=ON " +export CBSTRAP+="-DBOOTSTRAP_LLVM_USE_LINKER=lld " +#export CBSTRAP+="-DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=ON " + +# Set the standard C++ library that clang will use to LLVM's libc++: +export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " + +# Set the runtime library that clang will use to compiler-rt: +export COPTS+="-DCLANG_DEFAULT_RTLIB=compiler-rt " + +# Set libc++abi & libc++ to use compiler-rt instead of gcc's runtime: +export COPTS+="-DLIBCXX_USE_COMPILER_RT=ON " +export COPTS+="-DLIBCXXABI_USE_COMPILER_RT=ON " + +# Set libc++abi to use libunwind to avoid dependace on GCC: +export COPTS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " + +# Enable Exception Handling: +export COPTS+="-DLLVM_ENABLE_EH=ON " + +# Exception handling requires Runtime Type Info +export COPTS+="-DLLVM_ENABLE_RTTI=ON " + +# Stage 1 clang's compiler-rt will require new delete definitions in libc++ +export COPTS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " + +# Enable atomics to avoid using atomics from GCC: +export COPTS+="-DCOMPILER_RT_BUILD_STANDALONE_LIBATOMIC=OFF " +export COPTS+="-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " + +# Turn off features ... +export BOFF="-DLLVM_ENABLE_LIBXML2=OFF -DLIBCXX_ENABLE_LOCALIZATION=OFF " +export BOFF+="-DLLVM_ENABLE_ZLIB=OFF -DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " +export BOFF+="-DLLVM_ENABLE_ZSTD=OFF -DLIBUNWIND_INCLUDE_TESTS=OFF " +export BOFF+="-DLLVM_ENABLE_LIBEDIT=OFF -DLIBUNWIND_INCLUDE_DOCS=OFF " + +export BOFF+="-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF " + +# Turn off features that cause compiler-rt to NOT reference backtrace symbols from libexecinfo +export BOFF+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " +export BOFF+="-DCOMPILER_RT_BUILD_ORC=OFF " + + +# Configure source: +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld" -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ + ${CTOOLS} ${CTARG} ${CPATHS} ${CBSTRAP} ${COPTS} ${BOFF} -DBOOTSTRAP_LIBCXX_ENABLE_LOCALIZATION=OFF + +# Build +ninja -C build builtins #... 165 targets +ninja -C build compiler-rt # 598 +ninja -C build lld #.........1652 ... Fails: The iostreams library is not supported since libc++ has been configured without support for localization +ninja -C build libclang #....2219 From 3d65bfca71d44cc0f637c2f8245cae678c12433f Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Thu, 22 Dec 2022 10:03:34 -0600 Subject: [PATCH 014/484] Added note that may be useful later --- 1-cgnutools/using.custom_runtime.with.clang | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 1-cgnutools/using.custom_runtime.with.clang diff --git a/1-cgnutools/using.custom_runtime.with.clang b/1-cgnutools/using.custom_runtime.with.clang new file mode 100644 index 0000000..e3d31db --- /dev/null +++ b/1-cgnutools/using.custom_runtime.with.clang @@ -0,0 +1,13 @@ +# Most compilers provide a way to disable the +# default behavior for finding the standard +# library and to override it with custom paths. +# With Clang, this can be done with: + +clang++ -nostdinc++ -nostdlib++ \ + -isystem /include/c++/v1 \ + -L /lib \ + -Wl,-rpath,/lib \ + -lc++ \ + test.cpp + + From c0022b0ed5c32a922e20145326c699652cae97f2 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Fri, 23 Dec 2022 17:13:55 -0600 Subject: [PATCH 015/484] Added patches to enable localization for libc++ --- 1-cgnutools/LLVM.Runtimes | 74 ++++++++++--------- .../libcxx-use-strtoll_strtoul.patch | 27 +++++++ .../remove-locale-inlines.patch | 36 +++++++++ 3 files changed, 102 insertions(+), 35 deletions(-) create mode 100644 patches/llvm1505-cmlfs/libcxx-use-strtoll_strtoul.patch create mode 100644 patches/llvm1505-cmlfs/remove-locale-inlines.patch diff --git a/1-cgnutools/LLVM.Runtimes b/1-cgnutools/LLVM.Runtimes index 439d931..04b76f3 100644 --- a/1-cgnutools/LLVM.Runtimes +++ b/1-cgnutools/LLVM.Runtimes @@ -12,10 +12,18 @@ export LLVMSRC=${CMLFS}/sources/llvm cd $LLVMSRC # Apply patches for main LLVM source ... from alpine linux: -patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch -patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch -patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch -patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch +#patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch +#patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch +#patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch +#patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch + +# Musl doesn't support strtoll_l(), so replace it with a simple strtoll() call. +# Apply patches to allow localization of libc++: Force 'abi' changes (glibc->musl) +# to source and disable xlocale.h (holds abi changes). +patch -Np1 -i ../patches/llvm1505-cmlfs/libcxx-use-strtoll_strtoul.patch + +# Force 'abi' changes (glibc->musl) to source and disable xlocale.h (holds abi changes). +patch -Np1 -i ../patches/llvm1505-cmlfs/remove-locale-inlines.patch # Known broken test on musl cd llvm @@ -41,25 +49,21 @@ sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt cd .. # Apply patches for clang -cd clang -patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch -patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch +#cd clang +#patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch +#patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch # Apply patches for compiler-rt -cd ../compiler-rt -patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch -patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch +#cd ../compiler-rt +#patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch +#patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch # Apply patches for libcxx -cd ../libcxx -patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch -patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch +#cd ../libcxx +#patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch +#patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch -cd .. - -# Fix libcxx localization: -# Musl doesn't support strtoll_l(), so replace it with a simple strtoll() call. -# edit libcxx/include/locale +#cd .. # Set CC and CXX compiler with cross-gcc export CXX=${CMLFS_TARGET}-g++ @@ -77,20 +81,22 @@ export CONFIG_OPTIONS+="-DBUILD_SHARED_LIBS=ON " # Build libc++abi with compiler-rt [from cgnutools] and # libunwind from cgnutools: #export CONFIG_OPTIONS+="-DLIBCXXABI_USE_COMPILER_RT=ON " -#export CONFIG_OPTIONS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " +export CONFIG_OPTIONS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " export CONFIG_OPTIONS+="-DLIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST=ON " # Stage 1 compiler-rt will require new DELETE definitions export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON " -# Libc++ will not build with localization as musl does not -# have built in support. To enable, libc++ will need patching. -export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_LOCALIZATION=ON " #<<<<<<<<<<<< +# Enable localization in Libc++. Required by ncurses +export CONFIG_OPTIONS+="-DLIBCXX_ENABLE_LOCALIZATION=ON " # Build libc++ with musl support export CONFIG_OPTIONS+="-DLIBCXX_HAS_MUSL_LIBC=ON " +# Install libunwind headers +export CONFIG_OPTIONS+="-DLIBUNWIND_INSTALL_HEADERS=ON " + # Build libc++ & libunwind with compiler-rt [from cgnutools]: #export CONFIG_OPTIONS+="-DLIBCXX_USE_COMPILER_RT=ON " #export CONFIG_OPTIONS+="-DLIBUNWIND_USE_COMPILER_RT=ON " @@ -126,11 +132,11 @@ export CONFIG_PATHS+="-DCMAKE_INSTALL_LIBEXECDIR=/cgnutools/libexec " export CONFIG_PATHS+="-DCMAKE_INSTALL_SBINDIR=/cgnutools/sbin " export CONFIG_PATHS+="-DBacktrace_LIBRARY=/cgnutools/lib/libexecinfo.so.1 " export CONFIG_PATHS+="-DBacktrace_INCLUDE_DIR=/cgnutools/include " -#export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 -#export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_LIBRARY_DIR=/llvmtools/lib/x86_64-pc-linux-musl " #default: lib/x86_64-pc-linux-musl -#export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 -#export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 -#export CONFIG_PATHS+="-DLIBCXX_INSTALL_LIBRARY_DIR=/llvmtools/lib/x86_64-pc-linux-musl " #default: lib/x86_64-pc-linux-musl +export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_INCLUDE_DIR=/cgnutools/include/c++/v1 " #default: include/c++/v1 +export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_LIBRARY_DIR=/cgnutools/lib " #default: lib/x86_64-pc-linux-musl +export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_DIR=/cgnutools/include/c++/v1 " #default: include/c++/v1 +export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=/cgnutools/include/c++/v1 " #default: include/c++/v1 +export CONFIG_PATHS+="-DLIBCXX_INSTALL_LIBRARY_DIR=/cgnutools/lib " #default: lib/x86_64-pc-linux-musl export CONFIG_PATHS+="-DLIBCXX_INSTALL_RUNTIME_DIR=/cgnutools/bin " #default: bin export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/cgnutools/lib " export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_INCLUDE_DIR=/cgnutools/include " @@ -173,23 +179,21 @@ cmake -B build -G Ninja -Wno-dev -S llvm \ -DLLVM_TARGETS_TO_BUILD=X86 \ -DLLVM_TARGET_ARCH=host \ -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl \ - -DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl -DLIBUNWIND_INSTALL_HEADERS=ON + -DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl # Compile -ninja -C build unwind #19 targets -ninja -C build cxxabi #829 -ninja -C build cxx #77 +ninja -C build unwind #19 targets ... pass +ninja -C build cxxabi #828 .......... pass +ninja -C build cxx #91 ........... pass # Install to cgnutools ninja -C build install-unwind ninja -C build install-cxxabi -ninja -C build install-cxxabi-headers ninja -C build install-cxx -ninja -C build install-cxx-headers # Move misplaced headers: -mv -v /cgnutools/include/x86_64-pc-linux-musl/c++/v1/* /cgnutools/include/c++/v1/ -rm -rfv /cgnutools/include/x86_64-pc-linux-musl/c++/v1 +#mv -v /cgnutools/include/x86_64-pc-linux-musl/c++/v1/* /cgnutools/include/c++/v1/ +#rm -rfv /cgnutools/include/x86_64-pc-linux-musl/c++/v1 # Remove build directory for next build. # Same source tree will be used next diff --git a/patches/llvm1505-cmlfs/libcxx-use-strtoll_strtoul.patch b/patches/llvm1505-cmlfs/libcxx-use-strtoll_strtoul.patch new file mode 100644 index 0000000..10d842b --- /dev/null +++ b/patches/llvm1505-cmlfs/libcxx-use-strtoll_strtoul.patch @@ -0,0 +1,27 @@ +# PATCH [ 2 of 2 ] : Replace strtoll_l() with a simple strtoll() call. +# +# GCC's name-mangling may not work. Change source since Musl doesn't support strtoll_l(), +# so replace it with a simple strtoll() call. Helps fix "abi tag" errors when compiling libcxx on musl + +--- llvm-project-15.0.5.src.orig/libcxx/include/locale 2022-11-16 00:28:29.000000000 -0600 ++++ llvm-project-15.0.5.src/libcxx/include/locale 2022-12-23 15:23:41.760570897 -0600 +@@ -760,7 +760,8 @@ + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; +- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++//glibc long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++ long long __ll = strtoll(__a, &__p2, __base); + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +@@ -800,7 +801,8 @@ + typename remove_reference::type __save_errno = errno; + errno = 0; + char *__p2; +- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++//glibc unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++ unsigned long long __ll = strtoull(__a, &__p2, __base); + typename remove_reference::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; diff --git a/patches/llvm1505-cmlfs/remove-locale-inlines.patch b/patches/llvm1505-cmlfs/remove-locale-inlines.patch new file mode 100644 index 0000000..29bb8c7 --- /dev/null +++ b/patches/llvm1505-cmlfs/remove-locale-inlines.patch @@ -0,0 +1,36 @@ +# PATCH [ 2 of 2 ] : Remove the need for name mangling for locale.h for musl builds +# +--- llvm-project-15.0.5.src.orig/llvm/utils/gn/secondary/libcxx/include/BUILD.gn 2022-11-16 00:28:29.000000000 -0600 ++++ llvm-project-15.0.5.src/llvm/utils/gn/secondary/libcxx/include/BUILD.gn 2022-12-23 15:40:12.621515898 -0600 +@@ -554,7 +554,6 @@ + "__support/ibm/locale_mgmt_zos.h", + "__support/ibm/nanosleep.h", + "__support/ibm/xlocale.h", +- "__support/musl/xlocale.h", + "__support/newlib/xlocale.h", + "__support/openbsd/xlocale.h", + "__support/solaris/floatingpoint.h", +--- llvm-project-15.0.5.src.orig/libcxx/include/__locale 2022-11-16 00:28:29.000000000 -0600 ++++ llvm-project-15.0.5.src/libcxx/include/__locale 2022-12-23 15:39:35.080517981 -0600 +@@ -37,11 +37,6 @@ + # include + #elif defined(__Fuchsia__) + # include <__support/fuchsia/xlocale.h> +-#elif defined(__wasi__) +-// WASI libc uses musl's locales support. +-# include <__support/musl/xlocale.h> +-#elif defined(_LIBCPP_HAS_MUSL_LIBC) +-# include <__support/musl/xlocale.h> + #endif + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +--- llvm-project-15.0.5.src.orig/libcxx/include/CMakeLists.txt 2022-11-16 00:28:29.000000000 -0600 ++++ llvm-project-15.0.5.src/libcxx/include/CMakeLists.txt 2022-12-23 15:38:28.631521670 -0600 +@@ -492,7 +492,6 @@ + __support/ibm/locale_mgmt_zos.h + __support/ibm/nanosleep.h + __support/ibm/xlocale.h +- __support/musl/xlocale.h + __support/newlib/xlocale.h + __support/openbsd/xlocale.h + __support/solaris/floatingpoint.h From 8c01577f386baf463f6d1c862d20ffb81de046a4 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sat, 24 Dec 2022 23:05:53 -0600 Subject: [PATCH 016/484] Build tic on host for ncurses tools for llvmtools like clear. --- 2-llvmtools/03-ncurses | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/2-llvmtools/03-ncurses b/2-llvmtools/03-ncurses index c754a7b..9f14203 100644 --- a/2-llvmtools/03-ncurses +++ b/2-llvmtools/03-ncurses @@ -5,6 +5,15 @@ # Ensure that gawk is found first during configuration: sed -i s/mawk// configure +# Run the following commands to build the “tic” program +# on the build host: +mkdir build +pushd build + ../configure + make -C include + make -C progs tic +popd + # Configure source with clang CC=$CC CXX=$CXX \ AR=llvm-ar \ @@ -19,10 +28,10 @@ STRIP=llvm-strip \ --without-debug \ --without-ada \ --enable-widec \ - --enable-overwrite + --enable-overwrite --with-cxx-shared --without-normal # Build and install to toolchain -make && make install +make && make TIC_PATH=$(pwd)/build/progs/tic install # Bash build expects to find libcurses.so: ln -sv libncursesw.so.6.2 /llvmtools/lib/libcurses.so From 23c251eba837eaac08e59a95ec5f2300d2205b68 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 05:17:48 -0600 Subject: [PATCH 017/484] Kernel headers need to be in /cgnutools/include for libc++ of stage 1 clang (llvmtools). --- 1-cgnutools/1-kernel-headers | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/1-cgnutools/1-kernel-headers b/1-cgnutools/1-kernel-headers index 32d0569..37519ca 100644 --- a/1-cgnutools/1-kernel-headers +++ b/1-cgnutools/1-kernel-headers @@ -1,17 +1,19 @@ # cgnutools: Kernel Headers # Build as cmlfs user -# Kernel version greater than 5.9.16 will not compile under musl -patch -Np1 -i ../patches/kernel/include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch - # Clean the source make mrproper # Build the headers ARCH=${CMLFS_ARCH} make headers -# Install the headers +# Install the headers for cross-gcc find usr/include \( -name .install -o -name ..install.cmd \) -exec rm -vf {} \; mkdir -pv /cgnutools/${CMLFS_TARGET}/include cp -rv usr/include/* /cgnutools/${CMLFS_TARGET}/include/ rm -v /cgnutools/${CMLFS_TARGET}/include/Makefile + +# And install headers for stage 0 clang +mkdir -pv /cgnutools/include +cp -rv usr/include/* /cgnutools/include/ +rm -v /cgnutools/include/Makefile From 5a13253ae45bafea296314b06d2ca3d88bf441a6 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 05:25:37 -0600 Subject: [PATCH 018/484] LLVM-15 now has to be bootstraped to build it for cgnutools. --- 1-cgnutools/7-LLVM | 101 +++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 55 deletions(-) diff --git a/1-cgnutools/7-LLVM b/1-cgnutools/7-LLVM index 643b627..1738ec2 100644 --- a/1-cgnutools/7-LLVM +++ b/1-cgnutools/7-LLVM @@ -2,21 +2,20 @@ # # Build as cmlfs # -# NOTES: Stage 0 Clang seems to work (can compile musl libc, ncurses, etc), yet when -# building stage 1 clang (in llvmools) CMake complains about Stage 0 clang lacking -# atomics OR cannot find kernel headers already installed in llvmtools. -# + # Rename for shorter paths: -mv llvm-project-15.0.5.src llvm -export LLVMSRC=${CMLFS}/sources/llvm +mv llvm-project-15.0.5.src llvm-prj +export LLVMSRC=${CMLFS}/sources/llvm-prj cd $LLVMSRC -# Apply patches for main LLVM source ... from alpine linux: -patch -Np1 -i ../patches/llvm15-alpine/0001-Disable-dynamic-lib-tests-for-musl-s-dlclose-is-noop.patch -patch -Np1 -i ../patches/llvm15-alpine/fix-memory-mf_exec-on-aarch64.patch -patch -Np1 -i ../patches/llvm15-alpine/install-prefix.patch -patch -Np1 -i ../patches/llvm15-alpine/llvm-stack-size.patch +# Musl doesn't support strtoll_l(), so replace it with a simple strtoll() call. +# Apply patches to allow localization of libc++: Force 'abi' changes (glibc->musl) +# to source and disable xlocale.h (holds abi changes). +patch -Np1 -i ../patches/llvm1505-cmlfs/libcxx-use-strtoll_strtoul.patch + +# Force 'abi' changes (glibc->musl) to source and disable xlocale.h (holds abi changes). +patch -Np1 -i ../patches/llvm1505-cmlfs/remove-locale-inlines.patch # Known broken test on musl cd llvm @@ -41,23 +40,6 @@ sed -i "/OrcCAPITest.cpp/d" unittests/ExecutionEngine/Orc/CMakeLists.txt # Return to top-level cd .. -# Apply patches for clang -cd clang -patch -Np1 -i ../../patches/llvm15-clang-alpine/10-add-musl-triples.patch -patch -Np1 -i ../../patches/llvm15-clang-alpine/clang-003-as-needed.patch - -# Apply patches for compiler-rt -cd ../compiler-rt -patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-ppc64-musl.patch -patch -Np2 -i ../../patches/llvm15-compiler-rt-alpine/compiler-rt-sanitizer-supported-arch.patch - -# Apply patches for libcxx -cd ../libcxx -patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-musl.patch -patch -Np2 -i ../../patches/llvm15-libcxx-alpine/libcxx-ppc.patch - -cd .. - # Set flags to greatly reduce debugging symbols CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo' CXXFLAGS=$CFLAGS @@ -94,9 +76,6 @@ export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=ON " export CBSTRAP+="-DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=ON " export CBSTRAP+="-DBOOTSTRAP_LLVM_USE_LINKER=lld " export CBSTRAP+="-DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=ON " -# make sure bootstrap has atomics -#export CBSTRAP+="-DBOOTSTRAP_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC=ON " -#export CBSTRAP+="-DBOOTSTRAP_COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " # Set the standard C++ library that clang will use to LLVM's libc++: export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " @@ -104,6 +83,12 @@ export COPTS="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " # Set the runtime library that clang will use to compiler-rt: export COPTS+="-DCLANG_DEFAULT_RTLIB=compiler-rt " +# Enable musl support in libc++ +export COPTS+="-DLIBCXX_HAS_MUSL_LIBC=ON " + +# Libc++ has been patched to force localization support: +export COPTS+="-DLIBCXX_ENABLE_LOCALIZATION=ON " + # Set libc++abi & libc++ to use compiler-rt instead of gcc's runtime: export COPTS+="-DLIBCXX_USE_COMPILER_RT=ON " export COPTS+="-DLIBCXXABI_USE_COMPILER_RT=ON " @@ -111,6 +96,9 @@ export COPTS+="-DLIBCXXABI_USE_COMPILER_RT=ON " # Set libc++abi to use libunwind to avoid dependace on GCC: export COPTS+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " +# Make sure to install libunwind headers +export COPTS+="-DLIBUNWIND_INSTALL_HEADERS=ON " + # Enable Exception Handling: export COPTS+="-DLLVM_ENABLE_EH=ON " @@ -125,12 +113,11 @@ export COPTS+="-DCOMPILER_RT_BUILD_STANDALONE_LIBATOMIC=OFF " export COPTS+="-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF " # Turn off features ... -export BOFF="-DLLVM_ENABLE_LIBXML2=OFF -DLIBCXX_ENABLE_LOCALIZATION=OFF " +export BOFF="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_TESTS=OFF " export BOFF+="-DLLVM_ENABLE_ZLIB=OFF -DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " export BOFF+="-DLLVM_ENABLE_ZSTD=OFF -DLIBUNWIND_INCLUDE_TESTS=OFF " export BOFF+="-DLLVM_ENABLE_LIBEDIT=OFF -DLIBUNWIND_INCLUDE_DOCS=OFF " - -export BOFF+="-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF " +export BOFF+="-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF " # Turn off features that cause compiler-rt to NOT reference backtrace symbols from libexecinfo export BOFF+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF " @@ -142,17 +129,19 @@ cmake -B build -G Ninja -Wno-dev -S llvm \ -DLLVM_ENABLE_PROJECTS="compiler-rt;libunwind;libcxx;libcxxabi;lld;clang" \ -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS} -Wl,--as-needed -lexecinfo" \ - ${CTOOLS} ${CTARG} ${CPATHS} ${CBSTRAP} ${COPTS} ${BOFF} -DLIBUNWIND_INSTALL_HEADERS=ON + ${CTOOLS} ${CTARG} ${CPATHS} ${CBSTRAP} ${COPTS} ${BOFF} # Compile only what we need for a stage 0 clang -#ninja -C build builtins #164 targets -#ninja -C build unwind #19 -#ninja -C build cxxabi #829 -#ninja -C build cxx #79 -#ninja -C build compiler-rt # 598 -#ninja -C build lld #1652 -#ninja -C build libclang #798 -#ninja -C build clang #288 + +# When build fails, troubleshoot by building individual targets: +#ninja -C build builtins #165 targets ... pass +#ninja -C build unwind #19 ............ pass +#ninja -C build cxxabi #828 ........... pass +#ninja -C build cxx #89 ............ PASS +#ninja -C build compiler-rt #598 ........... PASS +#ninja -C build lld #1652 .......... PASS +#ninja -C build libclang #798 ........... PASS +#ninja -C build clang #288 ........... PASS for t in builtins unwind cxxabi cxx compiler-rt lld libclang clang ; do @@ -168,18 +157,20 @@ do done # Install only what we built to /cgnutools -#ninja -C build install-builtins #............... libclang_rt.builtins.a -#ninja -C build install-crt #.................... clang_rt.crtbegin.o;clang_rt.crtbend.o -#ninja -C build install-unwind #................. /cgnutools/lib/libunwind.so.1.0 & /cgnutools/include/libunwind.h -#ninja -C build install-cxxabi #................. /cgnutools/lib/x86_64-pc-linux-musl/libc++abi.so.1.0 -#ninja -C build install-cxxabi-headers #......... /cgnutools/include/c++/v1/__cxxabi_config.h;/cgnutools/include/c++/v1/cxxabi_config.h -#ninja -C build install-cxx #.................... /cgnutools/lib/x86_64-pc-linux-musl/libc++.so.1.0 -#ninja -C build install-cxx-headers # ........... /cgnutools/include/c++/v1;/cgnutools/include/x86_64-pc-linux-musl/c++/v1 -#ninja -C build install-compiler-rt # ........... /cgnutools/lib/clang/15.0.5/lib/x86_64-pc-linux-musl/* -#ninja -C build install-lld # ................... lld-link;ld.lld;ld64.lld;wasm-ld -#ninja -C build install-libclang # .............. /cgnutools/lib/libclang.so.15.0.5 -#ninja -C build install-libclang-headers #....... /cgnutools/include/clang-c -#ninja -C build install-clang # ................. /cgnutools/bin/{clang,clang-15,clang++,clang-cl,clang-cpp} + +# When install fails, troubleshoot by installing individual targets: +#ninja -C build install-builtins #................. libclang_rt.builtins.a +#ninja -C build install-crt #...................... clang_rt.crtbegin.o;clang_rt.crtbend.o +#ninja -C build install-unwind #................... /cgnutools/lib/libunwind.so.1.0 & /cgnutools/include/libunwind.h +#ninja -C build install-cxxabi #................... /cgnutools/lib/x86_64-pc-linux-musl/libc++abi.so.1.0 +#ninja -C build install-cxxabi-headers #........... /cgnutools/include/c++/v1/__cxxabi_config.h;/cgnutools/include/c++/v1/cxxabi_config.h +#ninja -C build install-cxx #...................... /cgnutools/lib/x86_64-pc-linux-musl/libc++.so.1.0 +#ninja -C build install-cxx-headers # ............. /cgnutools/include/c++/v1;/cgnutools/include/x86_64-pc-linux-musl/c++/v1 +#ninja -C build install-compiler-rt # ............. /cgnutools/lib/clang/15.0.5/lib/x86_64-pc-linux-musl/* +#ninja -C build install-lld # ..................... lld-link;ld.lld;ld64.lld;wasm-ld +#ninja -C build install-libclang # ................ /cgnutools/lib/libclang.so.15.0.5 +#ninja -C build install-libclang-headers #......... /cgnutools/include/clang-c +#ninja -C build install-clang # ................... /cgnutools/bin/{clang,clang-15,clang++,clang-cl,clang-cpp} #ninja -C build install-x86-resource-headers #..... /cgnutools/lib/clang/15.0.5/include/* #ninja -C build install-utility-resource-headers #../cgnutools/lib/clang/15.0.5/include/mm_malloc.h #ninja -C build install-ve-resource-headers #......./cgnutools/lib/clang/15.0.5/include/velintrin* From cb60b285253c56806442196bf0bbe29df53ff491 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 05:27:27 -0600 Subject: [PATCH 019/484] Updated cgnutools configuration. Use instead of . Also included atomics test. --- 1-cgnutools/8-Configuration | 1 - 1 file changed, 1 deletion(-) diff --git a/1-cgnutools/8-Configuration b/1-cgnutools/8-Configuration index a1fd00d..800cc48 100644 --- a/1-cgnutools/8-Configuration +++ b/1-cgnutools/8-Configuration @@ -4,7 +4,6 @@ # Configure clang to build binaries with /llvmtools/lib/ld-musl-x86_64.so.1 instead # of /lib/ld-musl-x86_64.so.1. This is similar in Musl-LFS/LFS when gcc specs # file is modified to set the dynamic linker in /tools instead of host's /lib. -# Also configure clang to use compiler-rt instead of GCC's runtime ln -sv clang-15 /cgnutools/bin/${TARGET_TUPLE}-clang ln -sv clang-15 /cgnutools/bin/${TARGET_TUPLE}-clang++ From 35c2459e89467eed737fbb19dd64ae88eb7cac12 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 05:29:27 -0600 Subject: [PATCH 020/484] Updated musl libc build in llvmtools to use the new stage0 clang --- 2-llvmtools/00-Musl | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/2-llvmtools/00-Musl b/2-llvmtools/00-Musl index 50c18b6..71ad0f8 100644 --- a/2-llvmtools/00-Musl +++ b/2-llvmtools/00-Musl @@ -5,8 +5,8 @@ export PATH=/cgnutools/bin:/llvmtools/bin:/bin:/usr/bin # and ... set C and C++ compilers with stage0 clang -export CXX=clang++ -export CC=clang +export CXX=${TARGET_TUPLE}-clang++ +export CC=${TARGET_TUPLE}-clang # Configure CC=$CC CXX=$CXX ./configure --prefix=/ @@ -29,19 +29,3 @@ cat > /llvmtools/etc/ld-musl-x86_64.path << "EOF" /llvmtools/lib EOF -# Test clang of cgnutools toolchain: -echo "int main(){}" > dummy.c -${CMLFS_TARGET}-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 'ld.lld:' dummy.log | grep crt[1in] -# Should output: -# ld.lld: /cgnutools/lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../Scrt1.o -# ld.lld: /cgnutools/lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../crti.o -# ld.lld: /cgnutools/lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../crtn.o - -# If all is well, remove output files; -rm -v a.out dummy.log From deab324d2544f3c81d8a017fdd74666f0e916250 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 05:32:08 -0600 Subject: [PATCH 021/484] Updated kernel header install in llvmtools with the new stage0 clang --- 2-llvmtools/01-kernel-headers | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/2-llvmtools/01-kernel-headers b/2-llvmtools/01-kernel-headers index 9ed065a..abfd787 100644 --- a/2-llvmtools/01-kernel-headers +++ b/2-llvmtools/01-kernel-headers @@ -1,14 +1,11 @@ # llvmtools: Kernel headers # Build and install as cmlfs -# Kernel version greater than 5.9.16 will not compile under musl -patch -Np1 -i ../patches/kernel/include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch - # Clean make mrproper # Generate headers -make ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ HOSTCC=${CMLFS_TARGET}-clang headers +make ARCH=${CMLFS_ARCH} LLVM=1 CC=$CC CXX=$CXX HOSTCC=${TARGET_TUPLE}-clang headers # Install to llvmtools find usr/include \( -name .install -o -name ..install.cmd \) -delete From 872ccbaee7fec1c3b0669d4d778511bf5af2f672 Mon Sep 17 00:00:00 2001 From: dslm4515 <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 05:35:42 -0600 Subject: [PATCH 022/484] Libunwind, libc++, libc++abi, compiler-rt, clang and lld all now need to be built together for llvmtools. --- 2-llvmtools/04-LLVM | 284 ++++++++++++++++++ .../{04-LLVM.Runtimes => LLVM.Runtimes} | 0 2-llvmtools/{07-clang-llvm => clang-llvm} | 0 3 files changed, 284 insertions(+) create mode 100644 2-llvmtools/04-LLVM rename 2-llvmtools/{04-LLVM.Runtimes => LLVM.Runtimes} (100%) rename 2-llvmtools/{07-clang-llvm => clang-llvm} (100%) diff --git a/2-llvmtools/04-LLVM b/2-llvmtools/04-LLVM new file mode 100644 index 0000000..e4705c4 --- /dev/null +++ b/2-llvmtools/04-LLVM @@ -0,0 +1,284 @@ +# llvmtools: Stage1 LLVM ( with clang,compiler-rt,libcxx,libcxxabi,libunwind,lld ) +# Build as cmlfs +# +# NOTE Reused unpacked LLVM source from building cgnutools + +# Set CC and CXX compiler with stage0 clang +export CXX=${TARGET_TUPLE}-clang++ +export CC=${TARGET_TUPLE}-clang + +# Set flags to greatly reduce debugging symbols +CFLAGS=' -g -g1 -Wl,--as-needed -lexecinfo -fPIC ' +CXXFLAGS=$CFLAGS +export CFLAGS CXXFLAGS + +# Set the build options .. +export CONFIG_OPTIONS="-DCMAKE_BUILD_TYPE=Release " +export CONFIG_OPTIONS+="-DBUILD_SHARED_LIBS=ON " +export CONFIG_OPTIONS+="-DLLVM_ENABLE_LIBCXX=ON " +export CONFIG_OPTIONS+="-DLLVM_TARGET_ARCH=X86 " +export CONFIG_OPTIONS+="-DLLVM_TARGETS_TO_BUILD=X86 " +export CONFIG_OPTIONS+="-DLIBCXX_HAS_MUSL_LIBC=ON " +export CONFIG_OPTIONS+="-DLLVM_ENABLE_EH=ON " +export CONFIG_OPTIONS+="-DLLVM_ENABLE_RTTI=ON " +export CONFIG_OPTIONS+="-DLLVM_BUILD_LLVM_DYLIB=ON " + +# Set the compiler and linker flags... +export LINKERFLAGS="-Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1" +export CONFIG_TOOLS="-DCMAKE_C_COMPILER=${CC} " +export CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${CXX} " +export CONFIG_TOOLS+="-DCLANG_DEFAULT_LINKER=/llvmtools/bin/ld.lld " + +# Set the tuples... +export CONFIG_TUPLES="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " +export CONFIG_TUPLES+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " +export CONFIG_TUPLES+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " + +# Set the flags for Compiler-rt... +export CONFIG_CRT="-DCOMPILER_RT_BUILD_SANITIZERS=OFF" +export CONFIG_CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_BUILD_ORC=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_HWASAN_WITH_INTERCEPTORS=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=OFF " +export CONFIG_CRT+="-DCOMPILER_RT_USE_LLVM_UNWINDER=ON " + +# Set the flags for clang: +export CONFIG_CLANG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " +export CONFIG_CLANG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " +export CONFIG_CLANG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " +export CONFIG_CLANG+="-DCLANG_ENABLE_STATIC_ANALYZER=OFF " +export CONFIG_CLANG+="-DCLANG_ENABLE_ARCMT=OFF " +export CONFIG_CLANG+="-DCLANG_TOOL_CLANG_IMPORT_TEST_BUILD=OFF " +export CONFIG_CLANG+="-DCLANG_TOOL_C_ARCMT_TEST_BUILD=OFF " +export CONFIG_CLANG+="-DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF " +export CONFIG_CLANG+="-DCLANG_TOOL_AMDGPU_ARCH_BUILD=OFF " +export CONFIG_CLANG+="-DCLANG_TOOL_APINOTES_TEST_BUILD=OFF " +export CONFIG_CLANG+="-DCLANG_TOOL_ARCMT_TEST_BUILD=OFF " + +# Set the flags to prevent build static libraries for +# libunwind, libcxxabi, and libcxx: +export CONFIG_LIBUNWIND="-DLIBUNWIND_ENABLE_STATIC=OFF " +export CONFIG_LIBCXXABI="-DLIBCXXABI_ENABLE_STATIC=OFF " +export CONFIG_LIBCXX="-DLIBCXX_ENABLE_STATIC=OFF " + +# Set the options for libc++ +export CONFIG_LIBCXX+="-DLIBCXX_USE_COMPILER_RT=ON " +export CONFIG_LIBCXX+="-DLIBCXX_EXTRA_SITE_DEFINES=ON " +export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_ASSERTIONS=ON " +export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_LOCALIZATION=ON " +export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS=OFF " +export CONFIG_LIBCXX+="-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF " + +# Set the options for libc++abi +export CONFIG_LIBCXXABI+="-DLIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST=ON " +export CONFIG_LIBCXXABI+="-DLIBCXXABI_USE_COMPILER_RT=ON " +export CONFIG_LIBCXXABI+="-DLIBCXXABI_USE_LLVM_UNWINDER=ON " + +# Set the options for libunwind +export CONFIG_LIBUNWIND+="-DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON " + +# Set paths... +export CONFIG_PATHS="-DCMAKE_INSTALL_PREFIX=/llvmtools " +export CONFIG_PATHS+="-DCMAKE_INSTALL_OLDINCLUDEDIR=/llvmtools/include " +export CONFIG_PATHS+="-DDEFAULT_SYSROOT=/llvmtools " +export CONFIG_PATHS+="-DBacktrace_LIBRARY=/llvmtools/lib/libexecinfo.so.1 " +export CONFIG_PATHS+="-DCOMPILER_RT_INSTALL_BINARY_DIR=/llvmtools/bin " +export CONFIG_PATHS+="-DCOMPILER_RT_INSTALL_DATA_DIR=/llvmtools/share " +export CONFIG_PATHS+="-DCOMPILER_RT_INSTALL_INCLUDE_DIR=/llvmtools/include/clang/15.0.5 " #default: lib/clang/15.0.5/include +export CONFIG_PATHS+="-DCOMPILER_RT_INSTALL_LIBRARY_DIR=/llvmtools/lib/clang/15.0.5 " #default: lib/clang/15.0.5/lib +export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +export CONFIG_PATHS+="-DLIBCXXABI_INSTALL_LIBRARY_DIR=/llvmtools/lib " #default: lib/x86_64-pc-linux-musl +export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +export CONFIG_PATHS+="-DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=/llvmtools/include/c++/v1 " #default: include/c++/v1 +export CONFIG_PATHS+="-DLIBCXX_INSTALL_LIBRARY_DIR=/llvmtools/lib " #default: lib/x86_64-pc-linux-musl +export CONFIG_PATHS+="-DLIBCXX_INSTALL_RUNTIME_DIR=/llvmtools/bin " #default: bin +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_LIBRARY_DIR=/llvmtools/lib " +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_INCLUDE_DIR=/llvmtools/include " +export CONFIG_PATHS+="-DLIBUNWIND_INSTALL_RUNTIME_DIR=/llvmtools/lib" + +# Turn off unwanted features, docs and tests +export BUILD_OFF="-DLLVM_BUILD_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_GO_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_TESTS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_DOCS=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " +export BUILD_OFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBEDIT=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBXML2=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_LIBPFM=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_TERMINFO=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_ZLIB=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_Z3_SOLVER=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_CRASH_OVERRIDES=OFF " +export BUILD_OFF+="-DLLVM_ENABLE_ZSTD=OFF " +export BUILD_OFF+="-DLLVM_APPEND_VC_REV=OFF " +export BUILD_OFF+="-DLLVM_TOOL_XCODE_TOOLCHAIN_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_XRAY_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_MICROSOFT_DEMANGLE_FUZZER_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_ITANIUM_DEMANGLE_FUZZER_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_LLVM_GO_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_PASSES_BUILD=OFF " +export BUILD_OFF+="-DLLVM_TOOL_BUGPOINT_BUILD=OFF " +export BUILD_OFF+="-DLIBCXX_INCLUDE_BENCHMARKS=OFF " +export BUILD_OFF+="-DCOMPILER_RT_BUILD_GWP_ASAN=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF " + +# Configure source +cmake -B build -G Ninja -Wno-dev -S llvm \ + -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS}" \ + ${CONFIG_TOOLS} ${CONFIG_TUPLES} \ + ${CONFIG_CRT} ${CONFIG_CLANG} ${CONFIG_OPTIONS} \ + ${CONFIG_LIBUNWIND} ${CONFIG_LIBCXXABI} \ + ${CONFIG_LIBCXX} ${CONFIG_PATHS} ${BUILD_OFF} \ + -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;libcxx;libcxxabi;lld;libunwind" \ + -DCLANG_VENDOR="llvmtools 3.0.0" -DLLD_VENDOR="llvmtools 3.0.0" + +# Since -fPIC was added to CFLAGS/CXXFLAGS, +# Configure llvmtools dynamic linker to search for shared objects in the build directory +echo "${PWD}/build/lib " >> /llvmtools/etc/ld-musl-x86_64.path +echo "${PWD}/build/lib/${TARGET_TUPLE} " >> /llvmtools/etc/ld-musl-x86_64.path + +# Compile +ninja -C build + +# When build fails, troubleshoot by building individual targets: +#ninja -C build builtins #166 targets .............. PASS +#ninja -C build unwind #10 ....................... PASS +#ninja -C build cxxabi #809 ...................... PASS +#ninja -C build cxx #45 ....................... PASS: cgnutools needs kheaders in /cgnutools/include +#ninja -C build compiler-rt #578 ................... PASS +#ninja -C build lld #1711 ..................... PASS +#ninja -C build libclang #795 ...................... PASS +#ninja -C build clang #104 ...................... PASS +#ninja -C build llvm-lib #8 ........................ PASS +#ninja -C build #1053 ..................... PASS + + +# Install to /cgnutools + +#ninja -C build install-unwind +#ninja -C build install-cxxabi +#ninja -C build install-cxx +#ninja -C build install-compiler-rt +#ninja -C build install-lld +#ninja -C build install-libclang +#ninja -C build install-clang +#ninja -C build install-LLVM + +#for b in ar as config lib link nm objcopy objdump ranlib readelf readobj size strip strings tblgen; +#do +# ninja -C build install-llvm-$b +#done + +#for l in Target X86CodeGen X86AsmParser X86Desc X86Info CodeGen ObjCARCOpts ipo Instrumentation \ +# Vectorize Option ScalarOpts AggressiveInstCombine InstCombine TransformUtils Analysis \ +# MCParser MC Core Support Demangle +#do +# ninja -C build install-LLVM$l +#done + +#for c in FrontendTool CodeGen Driver Serialization Basic ; +#do +# ninja -C build install-clang$c +#done + +# Too many libraries need RPATH set. Just use the build target, install. +ninja -C build install + +# Clean up current environment... +unset CFLAGS CXXFLAGS CONFIG_TOOLS CONFIG_TUPLES +unset CONFIG_CRT CONFIG_CLANG CONFIG_OPTIONS +unset CONFIG_LIBUNWIND CONFIG_LIBCXXABI CONFIG_LIBCXX +unset CONFIG_PATHS BUILD_OFF LLVMSRC LINKERFLAGS CC CXX + +# Create symlinks for runtime built-ins +# ** Will need to fix the paths by revising the CMake invocation from earlier +mkdir -pv /llvmtools/lib/clang/15.0.5/lib +ln -sv ../x86_64-pc-linux-musl /llvmtools/lib/clang/15.0.5/lib/linux +ln -sv libclang_rt.builtins.a /llvmtools/lib/clang/15.0.5/lib/linux/libclang_rt.builtins-x86_64.a +ln -sv clang/15.0.5/x86_64-pc-linux-musl/clang_rt.crtbegin.o /llvmtools/lib/crtbeginS.o +ln -sv clang/15.0.5/x86_64-pc-linux-musl/clang_rt.crtend.o /llvmtools/lib/crtendS.o + +# Configure stage 1 clang to build binaries with /llvmtools/lib/ld-musl-x86_64.so.1 +# instead of /lib/ld-musl-x86_64.so.1. This is similar in Musl-LFS/LFS when gcc specs +# file is modified to set the dynamic linker in /tools instead of host's /lib. +ln -sv clang-15 /llvmtools/bin/${TARGET_TUPLE}-clang +ln -sv clang-15 /llvmtools/bin/${TARGET_TUPLE}-clang++ + +cat > /llvmtools/bin/${TARGET_TUPLE}.cfg << "EOF" +-Wl,-dynamic-linker /llvmtools/lib/ld-musl-x86_64.so.1 +EOF + +# Test stage 1 clang +echo "int main(){}" > dummy.c +/llvmtools/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 or +# from cgnutools +grep ld.lld: dummy.log +# Should output: +# ld.lld: /llvmtools/lib/Scrt1.o +# ld.lld: /llvmtools/lib/crti.o +# ld.lld: /llvmtools/lib/crtbeginS.o +# ld.lld: /tmp/dummy-001093.o +# ld.lld: /mnt/cmlfs/llvmtools/lib/clang/15.0.5/lib/linux/libclang_rt.builtins-x86_64.a +# ld.lld: /llvmtools/lib/libunwind.so +# ld.lld: /llvmtools/lib/libc.so +# ld.lld: /mnt/cmlfs/llvmtools/lib/clang/15.0.5/lib/linux/libclang_rt.builtins-x86_64.a +# ld.lld: /llvmtools/lib/libunwind.so +# ld.lld: /llvmtools/lib/crtendS.o +# ld.lld: /llvmtools/lib/crtn.o + +# Check if 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 + +/llvmtools/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. + +# Make sure stage 1 libc++ & libc++abi do not depend on GCC +readelf -d /llvmtools/lib/libc++.so.1.0 | grep Shared | cut -d ":" -f 2 +# Should output +# [libc.so] +# [libc++abi.so.1] +# [libunwind.so.1] + +readelf -d /llvmtools/lib/libc++abi.so.1.0 | grep Shared | cut -d ":" -f 2 +# Should output +# [libc.so] +# [libc++abi.so.1] +# [libunwind.so.1] + +# Clean up +rm -rf build +# Source tree will be used later. Save time by not removing diff --git a/2-llvmtools/04-LLVM.Runtimes b/2-llvmtools/LLVM.Runtimes similarity index 100% rename from 2-llvmtools/04-LLVM.Runtimes rename to 2-llvmtools/LLVM.Runtimes diff --git a/2-llvmtools/07-clang-llvm b/2-llvmtools/clang-llvm similarity index 100% rename from 2-llvmtools/07-clang-llvm rename to 2-llvmtools/clang-llvm From df1156b45f8c26ce594b352221bb8ec8a122b1e4 Mon Sep 17 00:00:00 2001 From: Derrick <27793627+dslm4515@users.noreply.github.com> Date: Sun, 25 Dec 2022 06:00:20 -0600 Subject: [PATCH 023/484] Updated README.md Updated project status: stage0 clang can now build stage1 clang --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 488ef81..7db5f19 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ CMLFS can either mean "Clang-built Musl Linux from Scratch" or "Clang MLFS". It started as a hobby to see if a Linux system can be built with clang as primary toolchain and GCC as secondary (for packages that cannot be built with clang). This is based on Linux From Scratch (www.linuxfromscratch.org) and my previous work MLFS (https://github.com/dslm4515/Musl-LFS). # Project Status -Attempted to upgrade CMLFS to LLVM-15.0.5... required new build methods. Currently, cgnutools can be built with a stage 0 clang but cannot build stage 1 clang for llvmtools. +Attempted to upgrade CMLFS to LLVM-15.0.5... required new build methods. Currently, cgnutools can be built with a stage 0 clang and now can build stage 1 clang. ## Specification