Skip to content
Advertisement

‘undefined reference to’ Linker errors with latest LLVM from git (3.9.0svn) on Arch Linux

Prior to my Macbook Pro motherboard failure I was working on a programming language of mine with Flex, Bison, and LLVM. I honestly don’t recall the version of LLVM I was linking against at the time (I will try to find this out after I salvage the data from the drive), but I do know that the latest version I’m using now from git (clang version 3.9.0 (http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8) (http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455)) had a few minor API changes I had to compensate for.

I actually ended up replacing my Macbook with an MSI GS40 and chose Arch Linux as my new main OS. So my two primary variables here are Linux vs OS X and the different versions of LLVM/Clang/GCC involved.

I built LLVM the same way I did on OS X:

git clone http://llvm.org/git/llvm.git
git clone http://llvm.org/git/clang.git llvm/tools/clang
git clone http://llvm.org/git/clang-tools-extra.git llvm/tools/clang/tools/extra
git clone http://llvm.org/git/compiler-rt.git llvm/projects/compiler-rt
git clone http://llvm.org/git/libcxx.git llvm/projects/libcxx
git clone http://llvm.org/git/libcxxabi.git llvm/projects/libcxxabi

mkdir build_llvm
cd build_llvm && cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=prefix=/usr/local/llvm ../llvm
make
make install

I didn’t realize until this time around that it makes a “prefix=” folder as the documentation for LLVM makes it appear as though this is the command (In reality you would omit the prefix=). So I just manually moved the output llvm folder to a new location and exported the include directory in my .bash_profile.

I have the project compiling now, but I am unable to link with LLVM and receive the following errors:

mycompiler.codegen.o: In function `CodeGenContext':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:59: undefined reference to `llvm::sys::getProcessTriple()'
mycompiler.codegen.o: In function `CodeGenContext::handleError(int, int, llvm::StringRef, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:87: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `CompilationUnit::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2200: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `NamespaceDeclarationNode::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2220: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `UsingDeclarationNode::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2226: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `Int8Node::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2237: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o:/home/storage/data/mycompiler/mycompiler.codegen.cpp:2242: more undefined references to `llvm::Twine::str() const' follow
clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:27: recipe for target 'mycompiler' failed
make: *** [mycompiler] Error 1

Oddly enough those should be in the LLVMSupport library which is being included.

My Makefile:

all: mycompiler

LLVMCONFIG = llvm-config
CPPFLAGS = `$(LLVMCONFIG) --cxxflags` -v
LDFLAGS = `$(LLVMCONFIG) --ldflags` -v -rdynamic
LIBS = `$(LLVMCONFIG) --libs --system-libs`

LEGACY_FLEX_WARNS = -Wno-deprecated-register

OBJECTS = mycompiler.lexer.o  
          mycompiler.parser.o 
          mycompiler.driver.o 
          mycompiler.codegen.o

mycompiler.parser.hpp: mycompiler.parser.cpp

mycompiler.parser.cpp: mycompiler.y
    bison -d $^ --verbose --report=all --report-file=bison_report

mycompiler.lexer.cpp: mycompiler.l mycompiler.parser.hpp
    flex  mycompiler.l

%.o: %.cpp
    clang++ $(LEGACY_FLEX_WARNS) -c $< $(CPPFLAGS) -o $@

mycompiler: $(OBJECTS)
    clang++ -g $^ $(LDFLAGS) $(LIBS) -o $@

clean:
    rm -f *.o *.bc *~ *.output
    rm -f mycompiler.lexer.cpp mycompiler.lexer.hpp mycompiler.parser.cpp mycompiler.parser.hpp
    rm -f mycompiler bison_report

You will notice that I am including -v for verbose output so I can see all the libs and such being included by llvm-config. I have actually tried several different build parameters already, but just end up with even more linker issues.

Here is an example verbose output from the full build:

bison -d mycompiler.y --verbose --report=all --report-file=bison_report
flex  mycompiler.l
clang++ -Wno-deprecated-register -c mycompiler.lexer.cpp `llvm-config --cxxflags` -v -o mycompiler.lexer.o
clang version 3.9.0 (http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8) (http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/storage/data/build_llvm/build/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/home/storage/data/build_llvm/build/llvm/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name mycompiler.lexer.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-file /home/storage/data/mycompiler/mycompiler.lexer.o -resource-dir /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0 -I /home/storage/data/build_llvm/build/llvm/include -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward -internal-isystem /usr/local/include -internal-isystem /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-register -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/storage/data/mycompiler -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -o mycompiler.lexer.o -x c++ mycompiler.lexer.cpp
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
clang -cc1 version 3.9.0 based upon LLVM 3.9.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/storage/data/build_llvm/build/llvm/include
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
 /usr/local/include
 /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include
 /usr/include
End of search list.
mycompiler.l:393:12: warning: unused function 'isValidChar' [-Wunused-function]
static int isValidChar(const char c)
           ^
2 warnings generated.
clang++ -Wno-deprecated-register -c mycompiler.parser.cpp `llvm-config --cxxflags` -v -o mycompiler.parser.o
clang version 3.9.0 (http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8) (http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/storage/data/build_llvm/build/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/home/storage/data/build_llvm/build/llvm/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name mycompiler.parser.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-file /home/storage/data/mycompiler/mycompiler.parser.o -resource-dir /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0 -I /home/storage/data/build_llvm/build/llvm/include -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward -internal-isystem /usr/local/include -internal-isystem /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-register -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/storage/data/mycompiler -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -o mycompiler.parser.o -x c++ mycompiler.parser.cpp
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
clang -cc1 version 3.9.0 based upon LLVM 3.9.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/storage/data/build_llvm/build/llvm/include
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
 /usr/local/include
 /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include
 /usr/include
End of search list.
1 warning generated.
clang++ -Wno-deprecated-register -c mycompiler.driver.cpp `llvm-config --cxxflags` -v -o mycompiler.driver.o
clang version 3.9.0 (http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8) (http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/storage/data/build_llvm/build/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/home/storage/data/build_llvm/build/llvm/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name mycompiler.driver.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-file /home/storage/data/mycompiler/mycompiler.driver.o -resource-dir /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0 -I /home/storage/data/build_llvm/build/llvm/include -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward -internal-isystem /usr/local/include -internal-isystem /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-register -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/storage/data/mycompiler -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -o mycompiler.driver.o -x c++ mycompiler.driver.cpp
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
clang -cc1 version 3.9.0 based upon LLVM 3.9.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/storage/data/build_llvm/build/llvm/include
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
 /usr/local/include
 /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include
 /usr/include
End of search list.
mycompiler.driver.cpp:99:15: warning: unused variable 'output' [-Wunused-variable]
        FILE *output = yyget_out(myscanner); // TODO: where do we want to redirect this?
              ^
2 warnings generated.
clang++ -Wno-deprecated-register -c mycompiler.codegen.cpp `llvm-config --cxxflags` -v -o mycompiler.codegen.o
clang version 3.9.0 (http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8) (http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/storage/data/build_llvm/build/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/home/storage/data/build_llvm/build/llvm/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name mycompiler.codegen.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-file /home/storage/data/mycompiler/mycompiler.codegen.o -resource-dir /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0 -I /home/storage/data/build_llvm/build/llvm/include -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward -internal-isystem /usr/local/include -internal-isystem /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-register -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/storage/data/mycompiler -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -o mycompiler.codegen.o -x c++ mycompiler.codegen.cpp
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
clang -cc1 version 3.9.0 based upon LLVM 3.9.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/storage/data/build_llvm/build/llvm/include
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/x86_64-pc-linux-gnu
 /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
 /usr/local/include
 /home/storage/data/build_llvm/build/llvm/bin/../lib/clang/3.9.0/include
 /usr/include
End of search list.
1 warning generated.
clang++ -g mycompiler.lexer.o mycompiler.parser.o mycompiler.driver.o mycompiler.codegen.o `llvm-config --ldflags` -v -rdynamic `llvm-config --link-static --libs --system-libs` -o mycompiler
clang version 3.9.0 (http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8) (http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/storage/data/build_llvm/build/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/bin/ld" -export-dynamic --eh-frame-hdr -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o mycompiler /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/crtbegin.o -L/home/storage/data/build_llvm/build/llvm/lib -L/usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../.. -L/home/storage/data/build_llvm/build/llvm/bin/../lib -L/lib -L/usr/lib mycompiler.lexer.o mycompiler.parser.o mycompiler.driver.o mycompiler.codegen.o -lLLVMTableGen -lLLVMLTO -lLLVMObjCARCOpts -lLLVMPasses -lLLVMCoverage -lLLVMOrcJIT -lLLVMObjectYAML -lLLVMMIRParser -lLLVMInterpreter -lLLVMLineEditor -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMLibDriver -lLLVMOption -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMBPFAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMipo -lLLVMVectorize -lLLVMObject -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUUtils -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation -lLLVMProfileData -lLLVMTransformUtils -lLLVMBitWriter -lLLVMBitReader -lLLVMAnalysis -lLLVMCore -lLLVMAArch64AsmParser -lLLVMMCParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport -lrt -ldl -lcurses -lpthread -lz -lm -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/crtend.o /usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64/crtn.o
mycompiler.codegen.o: In function `CodeGenContext':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:59: undefined reference to `llvm::sys::getProcessTriple()'
mycompiler.codegen.o: In function `CodeGenContext::handleError(int, int, llvm::StringRef, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:87: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `CompilationUnit::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2200: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `NamespaceDeclarationNode::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2220: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `UsingDeclarationNode::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2226: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o: In function `Int8Node::debugPrintInternal(std::ostream&, CodeGenContext&, llvm::Twine const&)':
/home/storage/data/mycompiler/mycompiler.codegen.cpp:2237: undefined reference to `llvm::Twine::str() const'
mycompiler.codegen.o:/home/storage/data/mycompiler/mycompiler.codegen.cpp:2242: more undefined references to `llvm::Twine::str() const' follow
clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:27: recipe for target 'mycompiler' failed
make: *** [mycompiler] Error 1

Note that I am currently including all LLVM components by simply using the --libs parameter to llvm-config. I have tried to modify this as well by just selecting the various components I needed with the same results.

The warning: unknown warning option '-Wno-maybe-uninitialized'; is also new in this version of LLVM apparently as I wasn’t getting that warn before.

I’m sure this is possible on Arch as one of the searches I found with similar errors was on the Arch Wiki, but you can see that I am already following that advice that was answered on this stackoverflow post.

Any help with this would be greatly appreciated.

For those that are interested some relevant information can be found in the following links:

Advertisement

Answer

Great…

So this appears to be a bug with ABI incompatability between GCC 5.0 and Clang. 🙁

More information here and the open bug.

I can fix easily for now by switching from clang++ to g++ in my Makefile.

Funny thing is g++ seems to build WAY faster then clang ever was. I’m talking orders of magnitude faster.

Advertisement