building LLVM-trunk with LLVM-trunk breaks with undefined symbol _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE

Hi,

I tried to build a current version of llvm-trunk with clang-trunk
from yesterday. Unfortunately, I get an error.

loki build 128 clang -v
clang version 7.0.0 (trunk 336111)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/llvm-trunk/bin
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Selected GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 9.0
loki build 129

loki build 129 cd ../llvm/
loki llvm 130 svn info --revision HEAD
Path: trunk
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Relative URL: ^/llvm/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 336173
Node Kind: directory
Last Changed Author: mkazantsev
Last Changed Rev: 336172
Last Changed Date: 2018-07-03 08:23:57 +0200 (Tue, 03 Jul 2018)

I've downloaded the following packages.

svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
svn co http://llvm.org/svn/llvm-project/polly/trunk polly
svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb
svn co http://llvm.org/svn/llvm-project/lld/trunk lld
cd clang/tools
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk/ extra
cd ../../../projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
svn co http://llvm.org/svn/llvm-project/openmp/trunk openmp

I use the following configure command.

set LLVM_VERSION=llvm-trunk-new
set LLVM_COMPILER=llvm-trunk
rm -r build
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/${LLVM_VERSION} \
   -DCMAKE_BUILD_TYPE:STRING="Release" \
   -DCMAKE_C_COMPILER:STRING="${DIRPREFIX_PROG}/${LLVM_COMPILER}/bin/clang" \
   -DCMAKE_C_FLAGS:STRING="-m64 -I/usr/local/valgrind/include -I/usr/include/ncurses" \
   -DCMAKE_C_STANDARD_LIBRARIES="-lpthread" \
   -DCMAKE_CXX_COMPILER:STRING="${DIRPREFIX_PROG}/${LLVM_COMPILER}/bin/clang++" \
   -DCMAKE_CXX_FLAGS:STRING="-m64 -I/usr/local/valgrind/include -I/usr/include/ncurses" \
   -DCMAKE_CXX_STANDARD_LIBRARIES="-lpthread" \
   -DCMAKE_EXE_LINKER_FLAGS:STRING="-m64" \
   -DCUDA_INCLUDE_DIRS:STRING="/usr/local/cuda/include" \
   -DCUDA_LIBRARIES:STRING="/usr/local/cuda/lib64/libcudart.so" \
   -DLLVM_PARALLEL_COMPILE_JOBS:STRING="8" \
   -DLLVM_PARALLEL_LINK_JOBS:STRING="8" \
   -DLLVM_LIBDIR_SUFFIX:STRING="64" \
   -DBUILD_SHARED_LIBS:BOOL=ON \
   -DLLVM_POLLY_LINK_INTO_TOOLS:BOOL=ON \
   -DLLVM_TARGETS_TO_BUILD:STRING="NVPTX;X86" \
   -DOPENMP_ENABLE_LIBOMPTARGET:BOOL=ON \
   -DLIBOMP_ENABLE_SHARED:BOOL=ON \
   -DLIBOMP_USE_HWLOC:BOOL=ON \
   -DLIBOMP_HWLOC_INSTALL_DIR:STRING="/usr/local/hwloc-2.0.1" \
   -DLIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR:STRING="/usr/local/elfutils-0.169/include" \
   -DLIBOMPTARGET_DEP_LIBELF_LIBRARIES:STRING="/usr/local/elfutils-0.169/lib64/libelf.so" \
   -DLIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR:STRING="/usr/include" \
   -DLIBOMPTARGET_DEP_LIBFFI_LIBRARIES:STRING="/usr/lib64/libffi.so" \
   -DLIBOMPTARGET_NVPTX_ENABLE_BCLIB:BOOL=ON \
   -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES:STRING="50,60,70" \
   -DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_50 \
   -DLIBOMPTARGET_DEBUG:BOOL=ON \
   -GNinja \
   ../llvm \
   >& tee log.cmake

Building the packages breaks with the following error.

loki build 145 grep FAILED log.ninja-build
FAILED: include/llvm/IR/IntrinsicImpl.inc.tmp
FAILED: lib/ToolDrivers/llvm-lib/Options.inc.tmp
FAILED: tools/clang/include/clang/Driver/Options.inc.tmp
FAILED: tools/lld/lib/Driver/DarwinLdOptions.inc.tmp
FAILED: lib/Transforms/InstCombine/InstCombineTables.inc.tmp
FAILED: include/llvm/IR/IntrinsicEnums.inc.tmp
FAILED: include/llvm/IR/Attributes.inc.tmp
FAILED: tools/lld/ELF/Options.inc.tmp
FAILED: tools/lld/COFF/Options.inc.tmp
FAILED: lib/IR/AttributesCompatFunc.inc.tmp
FAILED: lib/ToolDrivers/llvm-dlltool/Options.inc.tmp
FAILED: tools/llvm-rc/Opts.inc.tmp
FAILED: tools/llvm-cvtres/Opts.inc.tmp
FAILED: tools/lld/wasm/Options.inc.tmp
FAILED: tools/lld/MinGW/Options.inc.tmp
FAILED: tools/llvm-objcopy/ObjcopyOpts.inc.tmp
FAILED: tools/llvm-mt/Opts.inc.tmp
loki build 146 grep error: log.ninja-build
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
/export2/src/llvm-trunk/build/bin/llvm-tblgen: symbol lookup error: /export2/src/llvm-trunk/build/bin/llvm-tblgen: undefined symbol: _ZTVN4llvm2cl3optISsLb0ENS0_6parserISsEEEE
loki build 147

Hopefully somebody can fix the problem. Do you need anything
else to locate the error? Thank you very much for any help
in advance.

Kind regards

Siegmar

"symbol lookup error" is an dynamic linker error; it looks like llvm-tblgen is finding shared libraries from a different version of LLVM. You should be able to use ldd to figure out which library it's finding instead.

-Eli