Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 642040 - clang-5.0.1_rc2: build fails with 'error while loading shared libraries: libLLVMSupport.so.5 : cannot open shared object file: No such file or directory'
Summary: clang-5.0.1_rc2: build fails with 'error while loading shared libraries: libL...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-22 13:44 UTC by Benjamin Block
Modified: 2018-01-31 09:58 UTC (History)
0 users

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


Attachments
Output from: emerge --info (emerge-info.txt,5.45 KB, text/plain)
2017-12-22 13:45 UTC, Benjamin Block
Details
Output from: emerge -pqv (emerge-pqv.txt,458 bytes, text/plain)
2017-12-22 13:46 UTC, Benjamin Block
Details
Copy of: build.log (emerge-build.log.txt,26.37 KB, text/plain)
2017-12-22 13:46 UTC, Benjamin Block
Details
Copy of: environment (emerge-environment.txt,198.28 KB, text/plain)
2017-12-22 13:47 UTC, Benjamin Block
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Block 2017-12-22 13:44:06 UTC
In the past I could build this just fine but now it fails with the error: error while loading shared libraries: libLLVMSupport.so.5 : cannot open shared object file: No such file or directory

The command it fails on is this (re-formated for readability):
SRC=/home/bblock/local/portage-tree/var/tmp/portage/sys-devel/clang-5.0.1_rc2/work/x/y/cfe-5.0.1rc2.src
cd ${SRC}-abi_x86_64.amd64 && 										\
  ${SRC}-abi_x86_64.amd64/bin/clang-tblgen								\
    -gen-clang-comment-command-list									\
    -I ${SRC}/include/clang/AST -I /home/bblock/local/portage-tree/usr/lib/llvm/5/include		\
    ${SRC}/work/x/y/cfe-5.0.1rc2.src/include/clang/AST/CommentCommands.td				\
    -o include/clang/AST/CommentCommandList.inc.tmp -d include/clang/AST/CommentCommandList.inc.d

So it executes bin/clang-tblgen and that can not find libLLVMSupport.so.5.

The file is definitely on the system:
~ $ q qfile ~/local/portage-tree/usr/lib/llvm/5/lib/libLLVMSupport.so.5
sys-devel/llvm (/home/bblock/local/portage-tree/usr/lib/llvm/5/lib/libLLVMSupport.so.5)

The dynamic section of bin/clang-tblgen read like this:
~  $ readelf --wide -d bin/clang-tblgen
Dynamic section at offset 0x81d28 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libLLVMSupport.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libLLVMTableGen.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/bblock/local/portage-tree/usr/x86_64-pc-linux-gnu/lib/gcc:/home/bblock/local/portage-tree/usr/x86_64-pc-linux-gnu/lib:/home/bblock/local/portage-tree/usr/lib:/home/bblock/local/portage-tree/lib]
 0x000000000000000c (INIT)               0x405178
 0x000000000000000d (FINI)               0x46c004
 0x0000000000000019 (INIT_ARRAY)         0x680c60
 0x000000000000001b (INIT_ARRAYSZ)       16 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x680c70
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x400278
 0x0000000000000005 (STRTAB)             0x4015d0
 0x0000000000000006 (SYMTAB)             0x4003b8
 0x000000000000000a (STRSZ)              9535 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x682000
 0x0000000000000002 (PLTRELSZ)           3096 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x404560
 0x0000000000000007 (RELA)               0x403d68
 0x0000000000000008 (RELASZ)             2040 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x403c98
 0x000000006fffffff (VERNEEDNUM)         3
 0x000000006ffffff0 (VERSYM)             0x403b10
 0x0000000000000000 (NULL)               0x0

So eh, I figured that the first entry in the Library runpath is the problem here. After that I did take an other look at the build output (after turning off parallel build) and sure enough I spotted this (I reformatted this a bit for readability reasons):

[11/1171] : && /home/bblock/local/portage-tree/usr/bin/x86_64-pc-linux-gnu-g++	\
    -O2 -pipe -march=native -mtune=native -O2 -ggdb -pipe -fstack-check -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter	\
    -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -fno-common	\
    -Woverloaded-virtual -fno-strict-aliasing -pedantic -Wno-long-long  -Wl,-O1 -Wl,--hash-style=gnu -Wl,-z,relro	\
    -Wl,-rpath-link,/home/bblock/local/portage-tree/var/tmp/portage/sys-devel/clang-5.0.1_rc2/work/x/y/cfe-5.0.1rc2.src-abi_x86_64.amd64/./lib	\
    -Wl,-O3 -Wl,--gc-sections	\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o				\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o					\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o			\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o	\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o			\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o				\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOptionDocEmitter.cpp.o				\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o				\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o					\
    utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o						\
    -o bin/clang-tblgen											\
    -L/home/bblock/local/portage-tree/usr/lib/llvm/5/lib						\
    -Wl,-rpath,"\$ORIGIN/../lib:/home/bblock/local/portage-tree/usr/x86_64-pc-linux-gnu/lib/gcc:/home/bblock/local/portage-tree/usr/x86_64-pc-linux-gnu/lib:/home/bblock/local/portage-tree/usr/lib:/home/bblock/local/portage-tree/lib"	\
    /home/bblock/local/portage-tree/usr/lib/llvm/5/lib/libLLVMSupport.so.5.0.1				\
    /home/bblock/local/portage-tree/usr/lib/llvm/5/lib/libLLVMTableGen.so.5.0.1 -lpthread && :

No idea where that ${ORIGIN} is coming from. I guess it should not be quoted in the commandline? But even then, I didn't see any such variable in the environment file of the build. I also didn't fine anything in the build-files that would specify it. I could only find some of it in one of the files from ninja.

~ $ vim ./work/x/y/cfe-5.0.1rc2.src-abi_x86_64.amd64/build.ninja
....
#############################################
# Link the executable bin/clang-tblgen

build bin/clang-tblgen: CXX_EXECUTABLE_LINKER__clang-tblgen utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.
cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o utils/
TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/
ClangOptionDocEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o utils/TableGen/CMakeFiles/
clang-tblgen.dir/TableGen.cpp.o | /home/bblock/local/portage-tree/usr/lib/llvm/5/lib/libLLVMSupport.so.5.0.1 /home/bblock/local/portage-tree/usr/lib/llvm/5/lib/libLLVMTableGen.so.5.0.1
  FLAGS = -O2 -pipe -march=native -mtune=native -O2 -ggdb -pipe -fstack-check -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -
Wcast-qual -Wno-missing-field-initializers -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pedantic -Wno-long-
long
  LINK_FLAGS = -Wl,-O1 -Wl,--hash-style=gnu -Wl,-z,relro     -Wl,-rpath-link,/home/bblock/local/portage-tree/var/tmp/portage/sys-devel/clang-5.0.1_rc2/work/x/y/cfe-5.0.1rc2.src-abi_x86_64.
amd64/./lib  -Wl,-O3 -Wl,--gc-sections
  LINK_LIBRARIES = -Wl,-rpath,"\$$ORIGIN/../lib:/home/bblock/local/portage-tree/usr/x86_64-pc-linux-gnu/lib/gcc:/home/bblock/local/portage-tree/usr/x86_64-pc-linux-gnu/lib:/home/bblock/local/
portage-tree/usr/lib:/home/bblock/local/portage-tree/lib" /home/bblock/local/portage-tree/usr/lib/llvm/5/lib/libLLVMSupport.so.5.0.1 /home/bblock/local/portage-tree/usr/lib/llvm/5/lib/
libLLVMTableGen.so.5.0.1 -lpthread
  LINK_PATH = -L/home/bblock/local/portage-tree/usr/lib/llvm/5/lib
  OBJECT_DIR = utils/TableGen/CMakeFiles/clang-tblgen.dir
  POST_BUILD = :
  PRE_LINK = :
  TARGET_COMPILE_PDB = utils/TableGen/CMakeFiles/clang-tblgen.dir/
  TARGET_FILE = bin/clang-tblgen
  TARGET_PDB = bin/clang-tblgen.pdb
....

Any ideas? I will see if I find anything else.

This prefix is running on a Ubuntu14.04.

Reproducible: Always
Comment 1 Benjamin Block 2017-12-22 13:45:43 UTC
Created attachment 511468 [details]
Output from: emerge --info
Comment 2 Benjamin Block 2017-12-22 13:46:23 UTC
Created attachment 511470 [details]
Output from: emerge -pqv
Comment 3 Benjamin Block 2017-12-22 13:46:52 UTC
Created attachment 511472 [details]
Copy of: build.log
Comment 4 Benjamin Block 2017-12-22 13:47:16 UTC
Created attachment 511474 [details]
Copy of: environment
Comment 5 Benjamin Block 2017-12-22 14:17:26 UTC
Ok scratch my comment about $ORIGIN being the problem. Incomplete knowledge on my side.

Anyway, then it looks like ~/local/portage-tree/usr/lib/llvm/5/lib/ is missing from the runtime paths?
Comment 6 Benjamin Block 2017-12-22 16:59:20 UTC
The same thing does _not_ happen with sys-devel/clang-3.9.1-r100
Comment 7 Fabian Groffen gentoo-dev 2018-01-30 12:21:28 UTC
I think this is because clang's libs are now stashed in a non-standard location.
Comment 8 Fabian Groffen gentoo-dev 2018-01-30 12:30:56 UTC
Yes, the llvm lib-dir needs to be in RPATH.  Question is why it isn't, as the ld-wrapper should do this for all -L args found.

I see the same problem.
Comment 9 Fabian Groffen gentoo-dev 2018-01-30 12:54:34 UTC
for some reason the ld wrapper isn't used by gcc, which is why it doesn't have the runpath
Comment 10 Fabian Groffen gentoo-dev 2018-01-31 09:46:59 UTC
This appears to be a logic error in the binutils-config wrapper.
Comment 11 Larry the Git Cow gentoo-dev 2018-01-31 09:50:13 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=edc0d44f70c27daebcc080ac5d08e8e191bccd95

commit edc0d44f70c27daebcc080ac5d08e8e191bccd95
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-01-31 09:49:10 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-01-31 09:50:06 +0000

    sys-devel/binutils-config: fix inversed logic
    
    Obviously we should skip turning -L into -R if the path points inside
    PORTAGE_BUILDDIR, not the other way around.
    
    Thanks to this, bugs like #642040 surfaced.
    
    Bug: https://bugs.gentoo.org/642040

 sys-devel/binutils-config/files/ldwrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)}
Comment 12 Larry the Git Cow gentoo-dev 2018-01-31 09:58:34 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=72d338d62675e24de16b010444ed2b493a5db4af

commit 72d338d62675e24de16b010444ed2b493a5db4af
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-01-31 09:58:24 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-01-31 09:58:24 +0000

    sys-devel/binutils-config: interrevbump to fix rpath injection issue
    
    Thanks to inversed logic we no longer included rpaths for -L arguments
    given on the command line.
    
    Closes: https://bugs.gentoo.org/642040
    Package-Manager: Portage-2.3.18-prefix, Repoman-2.3.6

 sys-devel/binutils-config/Manifest                                  | 2 +-
 ...inutils-config-5-r03.3.ebuild => binutils-config-5-r03.4.ebuild} | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)