If llvm isn't already installed and is being built with gold useflags, lvm fails to build. Simply removing $(SharedLibDir) sed line fixes the problem. The exact failure is: llvm[2]: Linking Release Loadable Module LLVMgold.so i686-pc-linux-gnu-g++ -I/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm -3.0.src/include -I/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0. src/tools/gold -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-exceptions -fPIC -Woverloaded-virtual -Wcast-qual -O2 -march=athlon -mtune=athlon -pipe -I/usr/include/ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 /usr/lib/llvm/libLTO.so -Wl,-R -Wl,'$ORIGIN' -L/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib -L/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -shared -o /mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib/LLVMgold.so /mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/tools/gold/Release/gold-plugin.o \ -lLLVM-3.0 -Wl,--version-script,/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/tools/gold/Release/gold.exports.map -lpthread -lffi -ldl -lm i686-pc-linux-gnu-g++: /usr/lib/llvm/libLTO.so: No such file or directory. Obviously, on a rebuild, the failure is irreproducible, as the needed file is already installed.
I suspect SharedLibDir is empty in this case, so we force it to be something. We'd have to patch the "source" of SharedLibDir.
Well, after removing that block, the command line looks like this: i686-pc-linux-gnu-g++ -I/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/include -I/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/tools/gold -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-exceptions -fPIC -Woverloaded-virtual -Wcast-qual -O2 -march=athlon -mtune=athlon -pipe -I/usr/include/ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 /mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib/libLTO.so -Wl,-R -Wl,'$ORIGIN' -L/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib -L/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -shared -o /mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/Release/lib/LLVMgold.so /mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/tools/gold/Release/gold-plugin.o \ -lLLVM-3.0 -Wl,--version-script,/mnt/workbox/builds/portage/sys-devel/llvm-3.0/work/llvm-3.0.src/tools/gold/Release/gold.exports.map -lpthread -lffi -ldl -lm so the difference is exactly the path to the just built lib, instead of the one in the live system.
Well, on the other hand, it seems that removing $(SharedLibDir) sed line instead prepends ${WORKDIR} to LLVMgold.so rpath. So it comes down to adding proper ${DESTDIR} support to llvm build system. Might be quite tricky.
(In reply to comment #3) > Well, on the other hand, it seems that removing $(SharedLibDir) sed line > instead prepends ${WORKDIR} to LLVMgold.so rpath. > So it comes down to adding proper ${DESTDIR} support to llvm build system. > > Might be quite tricky. I absolutely concur with that. Hence the hacking with install_names, iso a proper fix.
Luckily for us, the patch is simple and it is in upstream SVN: http://llvm.org/viewvc/llvm-project?view=rev&revision=145095 This is now in 3.0-1 (9999 is OK), thanks for the report!