www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Problems building on Ubuntu 13.10 with LLVM 3.3

reply "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
Hi all,

I've just made a new install of Ubuntu 13.10 and have tried to 
carry out a fresh build of from-git LDC.  I've installed 
llvm-3.3-dev, but the compilation process falls over with the 
following error:

---------------------------------------------
[ 11%] Building CXX object 
CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o
Linking CXX executable bin/gen_gccbuiltins
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Threading.o): In function 
`llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned 
int)':
(.text+0x13c): undefined reference to `pthread_create'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Threading.o): In function 
`llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned 
int)':
(.text+0x14c): undefined reference to `pthread_join'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Threading.o): In function 
`llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned 
int)':
(.text+0x176): undefined reference to `pthread_attr_setstacksize'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function 
`llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x38): undefined reference to `pthread_mutexattr_init'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function 
`llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x44): undefined reference to `pthread_mutexattr_settype'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function 
`llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x4e): undefined reference to 
`pthread_mutexattr_setpshared'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function 
`llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x61): undefined reference to `pthread_mutexattr_destroy'
/usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function 
`llvm::sys::MutexImpl::tryacquire()':
(.text+0xf8): undefined reference to `pthread_mutex_trylock'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/gen_gccbuiltins] Error 1
make[1]: *** [CMakeFiles/gen_gccbuiltins.dir/all] Error 2
---------------------------------------------

Is this a known bug/issue when building against LLVM 3.3 or is 
something else the problem?

Thanks & best wishes,

     -- Joe
Aug 19 2013
parent reply "David Nadlinger" <code klickverbot.at> writes:
Hi Joseph,

On 20 Aug 2013, at 0:04, Joseph Rushton Wakeling wrote:
 […]
 /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function 
 `llvm::sys::MutexImpl::tryacquire()':
 (.text+0xf8): undefined reference to `pthread_mutex_trylock'
 collect2: error: ld returned 1 exit status
 make[2]: *** [bin/gen_gccbuiltins] Error 1
 make[1]: *** [CMakeFiles/gen_gccbuiltins.dir/all] Error 2
 ---------------------------------------------

 Is this a known bug/issue when building against LLVM 3.3 or is 
 something else the problem?
LLVM depends on pthreads, but it should be pulled in automatically as part of the linker flags specified by llvm-config. To find out what is going on here, could you please post: 1) the output of "llvm-config --ldflags", and 2) the command line used for linking (make VERBOSE=1)? David
Aug 19 2013
next sibling parent reply "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
On Monday, 19 August 2013 at 22:13:22 UTC, David Nadlinger wrote:
 To find out what is going on here, could you please post:
  1) the output of "llvm-config --ldflags", and
$ llvm-config-3.3 --ldflags -L/usr/lib/llvm-3.3/lib -lpthread -lffi -ldl -lm Could the problem be that (for reasons best known unto themselves...) the packagers of llvm-3.3 have determined that the executable name will be llvm-config-3.3 rather than llvm-config?
  2) the command line used for linking (make VERBOSE=1)?
------------------------------------------------------------- Linking CXX executable bin/gen_gccbuiltins /usr/bin/cmake -E cmake_link_script CMakeFiles/gen_gccbuiltins.dir/link.txt --verbose=1 /usr/bin/c++ CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o -o bin/gen_gccbuiltins -rdynamic -L/usr/lib/llvm-3.3/lib -lpthread -lffi -ldl -lm /usr/lib/llvm-3.3/lib/libLLVMAsmParser.a /usr/lib/llvm-3.3/lib/libLLVMTableGen.a /usr/lib/llvm-3.3/lib/libLLVMInstrumentation.a /usr/lib/llvm-3.3/lib/libLLVMipo.a /usr/lib/llvm-3.3/lib/libLLVMVectorize.a /usr/lib/llvm-3.3/lib/libLLVMLinker.a /usr/lib/llvm-3.3/lib/libLLVMBitWriter.a /usr/lib/llvm-3.3/lib/libLLVMSystemZCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMSystemZAsmParser.a /usr/lib/llvm-3.3/lib/libLLVMSystemZDesc.a /usr/lib/llvm-3.3/lib/libLLVMSystemZInfo.a /usr/lib/llvm-3.3/lib/libLLVMSystemZAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMHexagonCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMHexagonAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMHexagonDesc.a /usr/lib/llvm-3.3/lib/libLLVMHexagonInfo.a /usr/lib/llvm-3.3/lib/libLLVMNVPTXCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMNVPTXDesc.a /usr/lib/llvm-3.3/lib/libLLVMNVPTXInfo.a /usr/lib/llvm-3.3/lib/libLLVMNVPTXAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMMBlazeDisassembler.a /usr/lib/llvm-3.3/lib/libLLVMMBlazeCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMMBlazeDesc.a /usr/lib/llvm-3.3/lib/libLLVMMBlazeAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMMBlazeAsmParser.a /usr/lib/llvm-3.3/lib/libLLVMMBlazeInfo.a /usr/lib/llvm-3.3/lib/libLLVMCppBackendCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMCppBackendInfo.a /usr/lib/llvm-3.3/lib/libLLVMMSP430CodeGen.a /usr/lib/llvm-3.3/lib/libLLVMMSP430Desc.a /usr/lib/llvm-3.3/lib/libLLVMMSP430Info.a /usr/lib/llvm-3.3/lib/libLLVMMSP430AsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMXCoreDisassembler.a /usr/lib/llvm-3.3/lib/libLLVMXCoreCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMXCoreDesc.a /usr/lib/llvm-3.3/lib/libLLVMXCoreInfo.a /usr/lib/llvm-3.3/lib/libLLVMXCoreAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMMipsDisassembler.a /usr/lib/llvm-3.3/lib/libLLVMMipsCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMMipsAsmParser.a /usr/lib/llvm-3.3/lib/libLLVMMipsDesc.a /usr/lib/llvm-3.3/lib/libLLVMMipsInfo.a /usr/lib/llvm-3.3/lib/libLLVMMipsAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMARMDisassembler.a /usr/lib/llvm-3.3/lib/libLLVMARMCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMARMAsmParser.a /usr/lib/llvm-3.3/lib/libLLVMARMDesc.a /usr/lib/llvm-3.3/lib/libLLVMARMInfo.a /usr/lib/llvm-3.3/lib/libLLVMARMAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMAArch64Disassembler.a /usr/lib/llvm-3.3/lib/libLLVMAArch64CodeGen.a /usr/lib/llvm-3.3/lib/libLLVMAArch64AsmParser.a /usr/lib/llvm-3.3/lib/libLLVMAArch64Desc.a /usr/lib/llvm-3.3/lib/libLLVMAArch64Info.a /usr/lib/llvm-3.3/lib/libLLVMAArch64AsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMAArch64Utils.a /usr/lib/llvm-3.3/lib/libLLVMPowerPCCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMPowerPCDesc.a /usr/lib/llvm-3.3/lib/libLLVMPowerPCAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMPowerPCAsmParser.a /usr/lib/llvm-3.3/lib/libLLVMPowerPCInfo.a /usr/lib/llvm-3.3/lib/libLLVMSparcCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMSparcDesc.a /usr/lib/llvm-3.3/lib/libLLVMSparcInfo.a /usr/lib/llvm-3.3/lib/libLLVMX86Disassembler.a /usr/lib/llvm-3.3/lib/libLLVMX86AsmParser.a /usr/lib/llvm-3.3/lib/libLLVMX86CodeGen.a /usr/lib/llvm-3.3/lib/libLLVMX86Desc.a /usr/lib/llvm-3.3/lib/libLLVMX86Info.a /usr/lib/llvm-3.3/lib/libLLVMX86AsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMX86Utils.a /usr/lib/llvm-3.3/lib/libLLVMR600CodeGen.a /usr/lib/llvm-3.3/lib/libLLVMSelectionDAG.a /usr/lib/llvm-3.3/lib/libLLVMAsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMMCParser.a /usr/lib/llvm-3.3/lib/libLLVMCodeGen.a /usr/lib/llvm-3.3/lib/libLLVMObjCARCOpts.a /usr/lib/llvm-3.3/lib/libLLVMScalarOpts.a /usr/lib/llvm-3.3/lib/libLLVMInstCombine.a /usr/lib/llvm-3.3/lib/libLLVMTransformUtils.a /usr/lib/llvm-3.3/lib/libLLVMipa.a /usr/lib/llvm-3.3/lib/libLLVMAnalysis.a /usr/lib/llvm-3.3/lib/libLLVMTarget.a /usr/lib/llvm-3.3/lib/libLLVMCore.a /usr/lib/llvm-3.3/lib/libLLVMR600Desc.a /usr/lib/llvm-3.3/lib/libLLVMR600Info.a /usr/lib/llvm-3.3/lib/libLLVMR600AsmPrinter.a /usr/lib/llvm-3.3/lib/libLLVMMC.a /usr/lib/llvm-3.3/lib/libLLVMObject.a /usr/lib/llvm-3.3/lib/libLLVMSupport.a -ldl /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)': (.text+0x13c): undefined reference to `pthread_create' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)': (.text+0x14c): undefined reference to `pthread_join' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)': (.text+0x176): undefined reference to `pthread_attr_setstacksize' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)': (.text+0x38): undefined reference to `pthread_mutexattr_init' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)': (.text+0x44): undefined reference to `pthread_mutexattr_settype' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)': (.text+0x4e): undefined reference to `pthread_mutexattr_setpshared' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)': (.text+0x61): undefined reference to `pthread_mutexattr_destroy' /usr/lib/llvm-3.3/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()': (.text+0xf8): undefined reference to `pthread_mutex_trylock' collect2: error: ld returned 1 exit status -------------------------------------------------------------
Aug 19 2013
parent reply "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
On Monday, 19 August 2013 at 22:19:00 UTC, Joseph Rushton 
Wakeling wrote:
 On Monday, 19 August 2013 at 22:13:22 UTC, David Nadlinger 
 wrote:
 2) the command line used for linking (make VERBOSE=1)?
At a guess, I'd suggest that -lpthread is being placed in the wrong order on the command line -- surely it should occur _after_ all the /usr/lib/llvm-3.3/* libraries, in the same place as -ldl ... ?
Aug 20 2013
parent reply "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
On Tuesday, 20 August 2013 at 09:44:11 UTC, Joseph Rushton 
Wakeling wrote:
 At a guess, I'd suggest that -lpthread is being placed in the 
 wrong order on the command line -- surely it should occur 
 _after_ all the /usr/lib/llvm-3.3/* libraries, in the same 
 place as -ldl ... ?
I've checked the CMakeLists.txt file and indeed this seems to be the case. Pull request with fix here: https://github.com/ldc-developers/ldc/pull/452
Aug 20 2013
parent reply "David Nadlinger" <code klickverbot.at> writes:
On 20 Aug 2013, at 17:47, Joseph Rushton Wakeling wrote:
 On Tuesday, 20 August 2013 at 09:44:11 UTC, Joseph Rushton Wakeling 
 wrote:
 At a guess, I'd suggest that -lpthread is being placed in the wrong 
 order on the command line -- surely it should occur _after_ all the 
 /usr/lib/llvm-3.3/* libraries, in the same place as -ldl ... ?
I've checked the CMakeLists.txt file and indeed this seems to be the case. Pull request with fix here: https://github.com/ldc-developers/ldc/pull/452
Yep, thanks; see my comment there. The way the linker flags from llvm-config are handled in the build system is really one big hack, but I couldn't manage to find a clean solution yet. It has been a while since I last tried, though, maybe more recent versions of CMake include more adequate facilities to solve this problem. David
Aug 20 2013
parent "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
On Tuesday, 20 August 2013 at 18:48:20 UTC, David Nadlinger wrote:
 The way the linker flags from llvm-config are handled in the 
 build system is really one big hack, but I couldn't manage to 
 find a clean solution yet. It has been a while since I last 
 tried, though, maybe more recent versions of CMake include more 
 adequate facilities to solve this problem.
Might be worth extending the test system with builds made with different C++ compilers/versions, just to check for issues like this?
Aug 22 2013
prev sibling parent "Joseph Rushton Wakeling" <joseph.wakeling webdrake.net> writes:
On Monday, 19 August 2013 at 22:13:22 UTC, David Nadlinger wrote:
 To find out what is going on here, could you please post:
  1) the output of "llvm-config --ldflags", and
  2) the command line used for linking (make VERBOSE=1)?
Further to what I've already posted, you should be able to get a copy of the complete (verbose) build log here: http://ubuntuone.com/05Fm94QnMebYcStgn4XvTr The compiler is GCC 4.8.1.
Aug 20 2013