Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 874024 - sys-devel/clang-15.0.1 - ld: /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/libatomic.so.1: error adding symbols: DSO missing from command line
Summary: sys-devel/clang-15.0.1 - ld: /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/li...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: PPC Linux
: Normal normal
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-02 12:19 UTC by ernsteiswuerfel
Modified: 2022-11-18 08:01 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (ppc, 15.0.1) (clang-15.0.1:20221002-103400.log.xz,59.80 KB, application/x-xz)
2022-10-02 12:19 UTC, ernsteiswuerfel
Details
emerge --info (file_874024.txt,6.33 KB, text/plain)
2022-10-02 12:20 UTC, ernsteiswuerfel
Details
clang-15.0.1-libclangBasic_linking.patch (clang-15.0.1-libclangBasic_linking.patch,503 bytes, patch)
2022-10-03 01:59 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
clang-15.0.1-clangBasic_linking.patch (clang-15.0.1-libclangBasic_linking.patch,503 bytes, patch)
2022-10-04 07:07 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
clang-15.0.1-libclangBasic_linking.patch (clang-15.0.1-libclangBasic_linking.patch,925 bytes, patch)
2022-10-04 07:10 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
clang-15.0.1-libclangBasic_linking.patch (clang-15.0.1-libclangBasic_linking.patch,1.13 KB, patch)
2022-10-05 00:59 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
llvm-15.0.2-cmake_mold_linker_detection.patch (llvm-15.0.2-cmake_mold_linker_detection.patch,399 bytes, patch)
2022-10-05 01:29 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
clang-15.0.1-libclangBasic_linking.patch (clang-15.0.1-libclangBasic_linking.patch,833 bytes, patch)
2022-10-05 01:30 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
llvm-15.0.2-cmake_libatomic_variable.patch (llvm-15.0.2-cmake_libatomic_variable.patch,874 bytes, patch)
2022-10-05 16:16 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
clang-15.0.2-libclangBasic_linking.patch (clang-15.0.2-libclangBasic_linking.patch,420 bytes, patch)
2022-10-05 16:20 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
build.log (ppc, 15.0.2 + patches w. clang) (clang-15.0.2:20221005-132622.log.xz,25.55 KB, application/x-xz)
2022-10-05 16:53 UTC, ernsteiswuerfel
Details
build.log (ppc, 15.0.2 + llvm patches applied to llvm + clang patches, clang-build) (clang-15.0.2:20221005-180706.log,133.93 KB, text/plain)
2022-10-05 18:14 UTC, ernsteiswuerfel
Details
build.log (ppc, 15.0.2 + patched llvm + clang patches, clang-build) (clang-15.0.2:20221006-102542.log.xz,75.91 KB, application/x-xz)
2022-10-06 11:47 UTC, ernsteiswuerfel
Details
llvm-15.0.2-cmake_mold_linker_detection.patch (llvm-15.0.2-cmake_mold_linker_detection.patch,608 bytes, patch)
2022-10-09 16:53 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
llvm-15.0.2-cmake_libatomic.patch (llvm-15.0.2-cmake_libatomic.patch,1.94 KB, patch)
2022-10-09 16:55 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff
clang-15.0.2-libclangBasic_linking.patch (clang-15.0.2-libclangBasic_linking.patch,555 bytes, patch)
2022-10-09 17:01 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ernsteiswuerfel archtester 2022-10-02 12:19:41 UTC
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
Comment 1 ernsteiswuerfel archtester 2022-10-02 12:20:10 UTC
Created attachment 815398 [details]
emerge --info
Comment 3 Arfrever Frehtes Taifersar Arahesis 2022-10-03 01:58:47 UTC
(In reply to comment #2)

Actually these commits are for situations when using Clang itself as compiler, not compiling Clang with GCC.
Comment 4 Arfrever Frehtes Taifersar Arahesis 2022-10-03 01:59:11 UTC
Created attachment 816109 [details, diff]
clang-15.0.1-libclangBasic_linking.patch

Please test this patch.
Comment 5 ernsteiswuerfel archtester 2022-10-03 18:36:09 UTC
(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. ;)
Comment 6 Arfrever Frehtes Taifersar Arahesis 2022-10-04 07:07:43 UTC
Created attachment 818470 [details, diff]
clang-15.0.1-clangBasic_linking.patch

(Adding Mold linker.)
Comment 7 Arfrever Frehtes Taifersar Arahesis 2022-10-04 07:10:44 UTC
Created attachment 818473 [details, diff]
clang-15.0.1-libclangBasic_linking.patch
Comment 8 ernsteiswuerfel archtester 2022-10-04 18:07:39 UTC
(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.
Comment 9 Arfrever Frehtes Taifersar Arahesis 2022-10-05 00:59:02 UTC
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)
Comment 10 Arfrever Frehtes Taifersar Arahesis 2022-10-05 01:18:35 UTC
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.
Comment 11 Arfrever Frehtes Taifersar Arahesis 2022-10-05 01:29:28 UTC
Created attachment 820363 [details, diff]
llvm-15.0.2-cmake_mold_linker_detection.patch
Comment 12 Arfrever Frehtes Taifersar Arahesis 2022-10-05 01:30:16 UTC
Created attachment 820366 [details, diff]
clang-15.0.1-libclangBasic_linking.patch
Comment 13 Arfrever Frehtes Taifersar Arahesis 2022-10-05 16:16:26 UTC
Created attachment 820816 [details, diff]
llvm-15.0.2-cmake_libatomic_variable.patch
Comment 14 Arfrever Frehtes Taifersar Arahesis 2022-10-05 16:20:47 UTC
Created attachment 820819 [details, diff]
clang-15.0.2-libclangBasic_linking.patch
Comment 15 ernsteiswuerfel archtester 2022-10-05 16:53:55 UTC
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.
Comment 16 ernsteiswuerfel archtester 2022-10-05 18:14:27 UTC
Created attachment 821389 [details]
build.log (ppc, 15.0.2 + llvm patches applied to llvm + clang patches, clang-build)
Comment 17 ernsteiswuerfel archtester 2022-10-06 11:47:03 UTC
Created attachment 821752 [details]
build.log (ppc, 15.0.2 + patched llvm + clang patches, clang-build)
Comment 18 ernsteiswuerfel archtester 2022-10-06 11:49:21 UTC
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.
Comment 19 Arfrever Frehtes Taifersar Arahesis 2022-10-09 16:53:34 UTC
Created attachment 822931 [details, diff]
llvm-15.0.2-cmake_mold_linker_detection.patch
Comment 20 Arfrever Frehtes Taifersar Arahesis 2022-10-09 16:55:41 UTC
Created attachment 822937 [details, diff]
llvm-15.0.2-cmake_libatomic.patch
Comment 21 Arfrever Frehtes Taifersar Arahesis 2022-10-09 17:01:32 UTC
Created attachment 822943 [details, diff]
clang-15.0.2-libclangBasic_linking.patch
Comment 22 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-18 08:01:44 UTC
Fixed in 15.0.5.