Created attachment 815395 [details] build.log (ppc, 15.0.1) [...] [844/1806] : && /usr/bin/powerpc-unknown-linux-gnu-g++ -O2 -mcpu=7450 -mtune=7450 -pipe -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pedantic -Wno-long-long -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-rpath-link,/var/tmp/portage/sys-devel/clang-15.0.1/work/x/y/clang-.ppc/./lib -Wl,--gc-sections lib/Tooling/DumpTool/CMakeFiles/clang-ast-dump.dir/ASTSrcLocProcessor.cpp.o lib/Tooling/DumpTool/CMakeFiles/clang-ast-dump.dir/ClangSrcLocDump.cpp.o -o bin/clang-ast-dump -L/usr/lib/llvm/15/lib -Wl,-rpath,"\$ORIGIN/../lib" lib/libclangAST.a lib/libclangASTMatchers.a lib/libclangBasic.a lib/libclangDriver.a lib/libclangFrontend.a lib/libclangSerialization.a lib/libclangToolingCore.a lib/libclangDriver.a lib/libclangParse.a lib/libclangSema.a lib/libclangEdit.a lib/libclangAnalysis.a lib/libclangASTMatchers.a lib/libclangAST.a lib/libclangSupport.a lib/libclangRewrite.a lib/libclangLex.a lib/libclangBasic.a /usr/lib/llvm/15/lib/libLLVM-15.so && : FAILED: bin/clang-ast-dump : && /usr/bin/powerpc-unknown-linux-gnu-g++ -O2 -mcpu=7450 -mtune=7450 -pipe -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pedantic -Wno-long-long -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-rpath-link,/var/tmp/portage/sys-devel/clang-15.0.1/work/x/y/clang-.ppc/./lib -Wl,--gc-sections lib/Tooling/DumpTool/CMakeFiles/clang-ast-dump.dir/ASTSrcLocProcessor.cpp.o lib/Tooling/DumpTool/CMakeFiles/clang-ast-dump.dir/ClangSrcLocDump.cpp.o -o bin/clang-ast-dump -L/usr/lib/llvm/15/lib -Wl,-rpath,"\$ORIGIN/../lib" lib/libclangAST.a lib/libclangASTMatchers.a lib/libclangBasic.a lib/libclangDriver.a lib/libclangFrontend.a lib/libclangSerialization.a lib/libclangToolingCore.a lib/libclangDriver.a lib/libclangParse.a lib/libclangSema.a lib/libclangEdit.a lib/libclangAnalysis.a lib/libclangASTMatchers.a lib/libclangAST.a lib/libclangSupport.a lib/libclangRewrite.a lib/libclangLex.a lib/libclangBasic.a /usr/lib/llvm/15/lib/libLLVM-15.so && : /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/../../../../powerpc-unknown-linux-gnu/bin/ld: lib/libclangBasic.a(FileManager.cpp.o): undefined reference to symbol '__atomic_load_8@@LIBATOMIC_1.0' /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/../../../../powerpc-unknown-linux-gnu/bin/ld: /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/libatomic.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. * ERROR: sys-devel/clang-15.0.1::gentoo failed (compile phase): * ninja -v -j1 -l0 distribution failed
Created attachment 815398 [details] emerge --info
It seems that this problem on SPARC 32-bit was fixed in: https://reviews.llvm.org/D118021 https://github.com/llvm/llvm-project/commit/a6afa9e6b0d9a08ecc878e62343a2af80ff30435 https://reviews.llvm.org/D130569 https://github.com/llvm/llvm-project/commit/9b1897bbd0e3a6e9ef099e74c3d3ed35428c0460
(In reply to comment #2) Actually these commits are for situations when using Clang itself as compiler, not compiling Clang with GCC.
Created attachment 816109 [details, diff] clang-15.0.1-libclangBasic_linking.patch Please test this patch.
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #4) > Created attachment 816109 [details, diff] [details, diff] > clang-15.0.1-libclangBasic_linking.patch > > Please test this patch. Your patch fixes the build failure. Thanks! Now the build fails again with bug #829602. ;)
Created attachment 818470 [details, diff] clang-15.0.1-clangBasic_linking.patch (Adding Mold linker.)
Created attachment 818473 [details, diff] clang-15.0.1-libclangBasic_linking.patch
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #7) > Created attachment 818473 [details, diff] [details, diff] > clang-15.0.1-libclangBasic_linking.patch This patch fails to apply as there is no /llvm/cmake/modules/AddLLVM.cmake in build directory (there is only /clang/cmake/modules/AddClang.cmake). AddClang.cmake also does not look like you could define a linker here, Your 1st uploaded patch just works fine.
Created attachment 820360 [details, diff] clang-15.0.1-libclangBasic_linking.patch When backporting of patch to Gentoo, llvm/cmake/modules/AddLLVM.cmake part should be moved to sys-devel/llvm. Code in https://github.com/llvm/llvm-project/blob/e28b15b572b58e5db4375da35745a4131858fc4c/llvm/cmake/modules/AddLLVM.cmake#L209-L248 also detects Apple OS X ld64 linker and Solaris ld linker. However neither of them seems to support options --push-state, --pop-state, --as-needed. https://opensource.apple.com/source/ld64/ https://opensource.apple.com/source/ld64/ld64-609/ https://opensource.apple.com/source/ld64/ld64-609/doc/man/man1/ld.1.auto.html https://www.unix.com/man-page/sunos/1/ld/ (/usr/ccs/bin/ld) https://www.unix.com/man-page/sunos/1b/ld/ (/usr/ucb/ld)
Attachment 820285 [details] shows that in 1 case, for bin/clangd, options have been incorrectly re-ordered: /usr/bin/powerpc-unknown-linux-gnu-g++ ... -o bin/clangd ... lib/libclangBasic.a -Wl,--push-state -Wl,--as-needed -Wl,--pop-state ... lib/libclang-cpp.so.15 /usr/lib/llvm/15/lib/libLLVM-15.so -latomic Maybe if we merge them to one -Wl option, then CMake will not re-order them.
Created attachment 820363 [details, diff] llvm-15.0.2-cmake_mold_linker_detection.patch
Created attachment 820366 [details, diff] clang-15.0.1-libclangBasic_linking.patch
Created attachment 820816 [details, diff] llvm-15.0.2-cmake_libatomic_variable.patch
Created attachment 820819 [details, diff] clang-15.0.2-libclangBasic_linking.patch
Created attachment 820822 [details] build.log (ppc, 15.0.2 + patches w. clang) Building llvm with clang went fine, building clang with clang did not work out. I got an error like building clang with gcc without the patch. [...] /usr/bin/powerpc-unknown-linux-gnu-ld: /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/libatomic.so.1: error adding symbols: DSO missing from command line clang-15: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
Created attachment 821389 [details] build.log (ppc, 15.0.2 + llvm patches applied to llvm + clang patches, clang-build)
Created attachment 821752 [details] build.log (ppc, 15.0.2 + patched llvm + clang patches, clang-build)
Successful (!) clang-15.0.2 build with clang, with the 2 llvm patches applied to llvm and clang patches used for clang. Toolchain used was gcc-11.3.1, glibc-2.35-r8, binutils-2.39-r2.
Created attachment 822931 [details, diff] llvm-15.0.2-cmake_mold_linker_detection.patch
Created attachment 822937 [details, diff] llvm-15.0.2-cmake_libatomic.patch
Created attachment 822943 [details, diff] clang-15.0.2-libclangBasic_linking.patch
Fixed in 15.0.5.