newbie llc build problem: BreakCriticalEdges.cpp:44: undefined reference to `llvm::LoopSimplifyID'

Hi,

Looking into LLVM for a database query engine project...

After downloading the latest source from CVS, it's my first time trying
to build LLVM. Following the "Getting Started" instructions, all went well
until gmake reported this error while trying to link llc:

In function `(anonymous namespace)::BreakCriticalEdges::getAnalysisUsage(llvm::AnalysisUsage&) const':
/home/kh/llvm.cvs/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:44: undefined reference to `llvm::LoopSimplifyID'
collect2: ld returned 1 exit status
gmake[2]: *** [/home/kh/llvm/obj/Debug/bin/llc] Error 1

AFAICT, 'LoopSimplifyID' does in fact appear to be present in libLLVMScalarOpts.a, and
that library does appear to be specified in the linker command line displayed by gmake.

What should I do to solve the link error?

Thank you for your help,
... kurt

++++++++++++++ Configuration: Red Hat Enterprise Linux 4 - x86 - GCC 3.4.3

$ export LLVM_SRC_ROOT=~/llvm.cvs/llvm
$ export LLVM_OBJ_ROOT=~/llvm/obj
$ export LLVM_GCC_DIR=~/llvm/cfrontend/x86/llvm-gcc
$ export LLVM_LIB_SEARCH_PATH=~/llvm/obj/lib
$ PATH=${PATH}:${LLVM_GCC_DIR}/bin
# (using the prebuilt 1.5 llvm-gcc)
$ cd $LLVM_OBJ_ROOT

$ $LLVM_SRC_ROOT/configure --enable-targets=host-only

++++++++++++++ gmake stderr...
$ gmake TOOL_VERBOSE=1 >../make2.log
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
  /usr/libexec/gcc/i386-redhat-linux/3.4.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /home/kh/llvm/obj/Debug/bin/llc /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crti.o /usr/lib/gcc/i386-redhat-linux/3.4.3/crtbegin.o -L/home/kh/llvm/obj/Debug/lib -L/usr/lib/gcc/i386-redhat-linux/3.4.3 -L/usr/lib/gcc/i386-redhat-linux/3.4.3 -L/usr/lib/gcc/i386-redhat-linux/3.4.3/../../.. /home/kh/llvm/obj/tools/llc/Debug/llc.o /home/kh/llvm/obj/Debug/lib/LLVMCBackend.o /home/kh/llvm/obj/Debug/lib/LLVMX86.o /home/kh/llvm/obj/Debug/lib/LLVMSelectionDAG.o /home/kh/llvm/obj/Debug/lib/LLVMCodeGen.o /home/kh/llvm/obj/Debug/lib/LLVMBCReader.o /home/kh/llvm/obj/Debug/lib/LLVMBCWriter.o /home/kh/llvm/obj/Debug/lib/LLVMCore.o /home/kh/llvm/obj/Debug/lib/LLVMbzip2.o --export-dynamic -lLLVMTarget -lLLVMipa -lLLVMTransforms -lLLVMScalarOpts -lLLVMAnalysis -lLLVMTransformUtils -lLLVMSupport -lLLVMSystem -lpthread /usr/lib/libltdl.so -ldl --rpath /home/kh/llvm/obj/Debug/bin -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i386-redhat-linux/3.4.3/crtend.o /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crtn.o
/home/kh/llvm/obj/Debug/lib/libLLVMTransformUtils.a(BreakCriticalEdges.o)(.gnu.linkonce.t._ZNK95_GLOBAL__N__home_kh_llvm.cvs_llvm_lib_Transforms_Utils_BreakCriticalEdges.cpp_DD76033A_46A04D1D18BreakCriticalEdges16getAnalysisUsageERN4llvm13AnalysisUsageE+0x51): In function `(anonymous namespace)::BreakCriticalEdges::getAnalysisUsage(llvm::AnalysisUsage&) const':
/home/kh/llvm.cvs/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:44: undefined reference to `llvm::LoopSimplifyID'
collect2: ld returned 1 exit status
gmake[2]: *** [/home/kh/llvm/obj/Debug/bin/llc] Error 1
gmake[1]: *** [llc/.makeall] Error 2

++++++++++++++ gmake stdout tail...
gmake[2]: Entering directory `/home/kh/llvm/obj/tools/llc'
llvm[2]: Linking Debug executable llc
/home/kh/llvm/obj/mklib --tag=CXX --tag=disable-shared --mode=link g++ -I/home/kh/llvm/obj/tools/llc -I/home/kh/llvm.cvs/llvm/tools/llc -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -Wall -W -Wwrite-strings -Wno-unused -g -D_DEBUG -v -rpath /home/kh/llvm/obj/Debug/bin -export-dynamic -L/home/kh/llvm/obj/Debug/lib -L/home/kh/llvm/obj/Debug/lib -o /home/kh/llvm/obj/Debug/bin/llc /home/kh/llvm/obj/tools/llc/Debug/llc.o /home/kh/llvm/obj/Debug/lib/LLVMCBackend.o /home/kh/llvm/obj/Debug/lib/LLVMX86.o /home/kh/llvm/obj/Debug/lib/LLVMSelectionDAG.o /home/kh/llvm/obj/Debug/lib/LLVMCodeGen.o -lLLVMTarget -lLLVMipa -lLLVMTransforms -lLLVMScalarOpts -lLLVMAnalysis -lLLVMTransformUtils /home/kh/llvm/obj/Debug/lib/LLVMBCReader.o /home/kh/llvm/obj/Debug/lib/LLVMBCWriter.o /home/kh/llvm/obj/Debug/lib/LLVMCore.o -lLLVMSupport /home/kh/llvm/obj/Debug/lib/LLVMbzip2.o -lLLVMSystem \
              -lpthread -lltdl
g++ -I/home/kh/llvm/obj/tools/llc -I/home/kh/llvm.cvs/llvm/tools/llc -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -Wall -W -Wwrite-strings -Wno-unused -g -D_DEBUG -v -o /home/kh/llvm/obj/Debug/bin/llc /home/kh/llvm/obj/tools/llc/Debug/llc.o /home/kh/llvm/obj/Debug/lib/LLVMCBackend.o /home/kh/llvm/obj/Debug/lib/LLVMX86.o /home/kh/llvm/obj/Debug/lib/LLVMSelectionDAG.o /home/kh/llvm/obj/Debug/lib/LLVMCodeGen.o /home/kh/llvm/obj/Debug/lib/LLVMBCReader.o /home/kh/llvm/obj/Debug/lib/LLVMBCWriter.o /home/kh/llvm/obj/Debug/lib/LLVMCore.o /home/kh/llvm/obj/Debug/lib/LLVMbzip2.o -Wl,--export-dynamic -L/home/kh/llvm/obj/Debug/lib -lLLVMTarget -lLLVMipa -lLLVMTransforms -lLLVMScalarOpts -lLLVMAnalysis -lLLVMTransformUtils -lLLVMSupport -lLLVMSystem -lpthread /usr/lib/libltdl.so -ldl -Wl,--rpath -Wl,/home/kh/llvm/obj/Debug/bin
gmake[2]: Leaving directory `/home/kh/llvm/obj/tools/llc'
gmake[1]: Leaving directory `/home/kh/llvm/obj/tools'

++++++++++++++ checking whether the library exists and contains the symbol...
$ nm --print-armap /home/kh/llvm/obj/Debug/lib/libLLVMScalarOpts.a | grep LoopSimplifyID
_ZN4llvm14LoopSimplifyIDE in LoopSimplify.o
          U _ZN4llvm14LoopSimplifyIDE
00000024 B _ZN4llvm14LoopSimplifyIDE
          U _ZN4llvm14LoopSimplifyIDE

Looking into LLVM for a database query engine project...

After downloading the latest source from CVS, it's my first time trying
to build LLVM. Following the "Getting Started" instructions, all went well
until gmake reported this error while trying to link llc:

AFAICT, 'LoopSimplifyID' does in fact appear to be present in libLLVMScalarOpts.a, and
that library does appear to be specified in the linker command line displayed by gmake.

What should I do to solve the link error?

This appears to be a problem exposed by some recent reorg of the libraries (to build one version of each library instead of two). To fix this, I moved the loopsimplify pass from the Scalar library to the utils library. Please do the following:

1. cd lib/Transforms
2. cvs up -P -d
3. cd Utils; make clean
4. cd Scalar; make clean

Then rebuild. Hopefully LLC will build now. If not, please send in the error message. Thanks for reporting the problem!

People who haven't hit this problem shouldn't need to do the steps above: normal update and builds should be fine.

-Chris

++++++++++++++ Configuration: Red Hat Enterprise Linux 4 - x86 - GCC 3.4.3

$ export LLVM_SRC_ROOT=~/llvm.cvs/llvm
$ export LLVM_OBJ_ROOT=~/llvm/obj
$ export LLVM_GCC_DIR=~/llvm/cfrontend/x86/llvm-gcc
$ export LLVM_LIB_SEARCH_PATH=~/llvm/obj/lib
$ PATH=${PATH}:${LLVM_GCC_DIR}/bin
# (using the prebuilt 1.5 llvm-gcc)
$ cd $LLVM_OBJ_ROOT

$ $LLVM_SRC_ROOT/configure --enable-targets=host-only

++++++++++++++ gmake stderr...
$ gmake TOOL_VERBOSE=1 >../make2.log
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
/usr/libexec/gcc/i386-redhat-linux/3.4.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /home/kh/llvm/obj/Debug/bin/llc /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crti.o /usr/lib/gcc/i386-redhat-linux/3.4.3/crtbegin.o -L/home/kh/llvm/obj/Debug/lib -L/usr/lib/gcc/i386-redhat-linux/3.4.3 -L/usr/lib/gcc/i386-redhat-linux/3.4.3 -L/usr/lib/gcc/i386-redhat-linux/3.4.3/../../.. /home/kh/llvm/obj/tools/llc/Debug/llc.o /home/kh/llvm/obj/Debug/lib/LLVMCBackend.o /home/kh/llvm/obj/Debug/lib/LLVMX86.o /home/kh/llvm/obj/Debug/lib/LLVMSelectionDAG.o /home/kh/llvm/obj/Debug/lib/LLVMCodeGen.o /home/kh/llvm/obj/Debug/lib/LLVMBCReader.o /home/kh/llvm/obj/Debug/lib/LLVMBCWriter.o /home/kh/llvm/obj/Debug/lib/LLVMCore.o /home/kh/llvm/obj/Debug/lib/LLVMbzip2.o --export-dynamic -lLLVMTarget -lLLVMipa -lLLVMTransforms -lLLVMScalarOpts -lLLVMAnalysis -lLLVMTransformUtils -lLLVMSupport -lLLVMSystem -lpthread /usr/lib/libltdl.so -ldl --rpath /home/kh/llvm/obj/Debug/bin -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i386-redhat-linux/3.4.3/crtend.o /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../crtn.o
/home/kh/llvm/obj/Debug/lib/libLLVMTransformUtils.a(BreakCriticalEdges.o)(.gnu.linkonce.t._ZNK95_GLOBAL__N__home_kh_llvm.cvs_llvm_lib_Transforms_Utils_BreakCriticalEdges.cpp_DD76033A_46A04D1D18BreakCriticalEdges16getAnalysisUsageERN4llvm13AnalysisUsageE+0x51): In function `(anonymous namespace)::BreakCriticalEdges::getAnalysisUsage(llvm::AnalysisUsage&) const':
/home/kh/llvm.cvs/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:44: undefined reference to `llvm::LoopSimplifyID'
collect2: ld returned 1 exit status
gmake[2]: *** [/home/kh/llvm/obj/Debug/bin/llc] Error 1
gmake[1]: *** [llc/.makeall] Error 2

++++++++++++++ gmake stdout tail...
gmake[2]: Entering directory `/home/kh/llvm/obj/tools/llc'
llvm[2]: Linking Debug executable llc
/home/kh/llvm/obj/mklib --tag=CXX --tag=disable-shared --mode=link g++ -I/home/kh/llvm/obj/tools/llc -I/home/kh/llvm.cvs/llvm/tools/llc -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -Wall -W -Wwrite-strings -Wno-unused -g -D_DEBUG -v -rpath /home/kh/llvm/obj/Debug/bin -export-dynamic -L/home/kh/llvm/obj/Debug/lib -L/home/kh/llvm/obj/Debug/lib -o /home/kh/llvm/obj/Debug/bin/llc /home/kh/llvm/obj/tools/llc/Debug/llc.o /home/kh/llvm/obj/Debug/lib/LLVMCBackend.o /home/kh/llvm/obj/Debug/lib/LLVMX86.o /home/kh/llvm/obj/Debug/lib/LLVMSelectionDAG.o /home/kh/llvm/obj/Debug/lib/LLVMCodeGen.o -lLLVMTarget -lLLVMipa -lLLVMTransforms -lLLVMScalarOpts -lLLVMAnalysis -lLLVMTransformUtils /home/kh/llvm/obj/Debug/lib/LLVMBCReader.o /home/kh/llvm/obj/Debug/lib/LLVMBCWriter.o /home/kh/llvm/obj/Debug/lib/LLVMCore.o -lLLVMSupport /home/kh/llvm/obj/Debug/lib/LLVMbzip2.o -lLLVMSystem \
            -lpthread -lltdl
g++ -I/home/kh/llvm/obj/tools/llc -I/home/kh/llvm.cvs/llvm/tools/llc -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -I/home/kh/llvm/obj/include -I/home/kh/llvm.cvs/llvm/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -Wall -W -Wwrite-strings -Wno-unused -g -D_DEBUG -v -o /home/kh/llvm/obj/Debug/bin/llc /home/kh/llvm/obj/tools/llc/Debug/llc.o /home/kh/llvm/obj/Debug/lib/LLVMCBackend.o /home/kh/llvm/obj/Debug/lib/LLVMX86.o /home/kh/llvm/obj/Debug/lib/LLVMSelectionDAG.o /home/kh/llvm/obj/Debug/lib/LLVMCodeGen.o /home/kh/llvm/obj/Debug/lib/LLVMBCReader.o /home/kh/llvm/obj/Debug/lib/LLVMBCWriter.o /home/kh/llvm/obj/Debug/lib/LLVMCore.o /home/kh/llvm/obj/Debug/lib/LLVMbzip2.o -Wl,--export-dynamic -L/home/kh/llvm/obj/Debug/lib -lLLVMTarget -lLLVMipa -lLLVMTransforms -lLLVMScalarOpts -lLLVMAnalysis -lLLVMTransformUtils -lLLVMSupport -lLLVMSystem -lpthread /usr/lib/libltdl.so -ldl -Wl,--rpath -Wl,/home/kh/llvm/obj/Debug/bin
gmake[2]: Leaving directory `/home/kh/llvm/obj/tools/llc'
gmake[1]: Leaving directory `/home/kh/llvm/obj/tools'

++++++++++++++ checking whether the library exists and contains the symbol...
$ nm --print-armap /home/kh/llvm/obj/Debug/lib/libLLVMScalarOpts.a | grep LoopSimplifyID
_ZN4llvm14LoopSimplifyIDE in LoopSimplify.o
        U _ZN4llvm14LoopSimplifyIDE
00000024 B _ZN4llvm14LoopSimplifyIDE
        U _ZN4llvm14LoopSimplifyIDE

_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-Chris

Chris Lattner wrote:

This appears to be a problem exposed by some recent reorg of the libraries (to build one version of each library instead of two). To fix this, I moved the loopsimplify pass from the Scalar library to the utils library. Please do the following:

1. cd lib/Transforms
2. cvs up -P -d
3. cd Utils; make clean
4. cd Scalar; make clean

Then rebuild. Hopefully LLC will build now. If not, please send in the error message. Thanks for reporting the problem!

People who haven't hit this problem shouldn't need to do the steps above: normal update and builds should be fine.

-Chris

Problem solved! Thanks very much!

Regards,
... kurt