简体   繁体   English

Arch Linux 上来自 git (3.9.0svn) 的最新 LLVM 的“未定义引用”链接器错误

[英]'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.在 Macbook Pro 主板出现故障之前,我正在使用 Flex、Bison 和 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.老实说,我不记得我当时链接的 LLVM 版本(我会在从驱动器中抢救数据后尝试找出这一点),但我知道我现在使用的最新版本来自 git (clang 版本 3.9.0( http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8)( http://llvm.org/git/llvm.git 4edb79d2d975816fee50382816fee5038816fee5038816fee5038814 对 API4 进行了一些小改动)补偿了一些 API5038872) .

I actually ended up replacing my Macbook with an MSI GS40 and chose Arch Linux as my new main OS.实际上,我最终用 MSI GS40 替换了我的 Macbook,并选择了 Arch Linux 作为我的新主操作系统。 So my two primary variables here are Linux vs OS X and the different versions of LLVM/Clang/GCC involved.所以我这里的两个主要变量是 Linux 与 OS X 以及涉及的不同版本的 LLVM/Clang/GCC。

I built LLVM the same way I did on OS X:我以与在 OS X 上相同的方式构建 LLVM:

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= ).直到这次我才意识到它创建了一个“prefix=”文件夹,因为 LLVM 的文档使它看起来好像这是命令(实际上你会省略prefix= )。 So I just manually moved the output llvm folder to a new location and exported the include directory in my .bash_profile.所以我只是手动将输出llvm文件夹移动到一个新位置,并在我的 .bash_profile 中导出include目录。

I have the project compiling now, but I am unable to link with LLVM and receive the following errors:我现在有项目正在编译,但我无法与 LLVM 链接并收到以下错误:

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.奇怪的是,那些应该在包含的 LLVMSupport 库中。

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.您会注意到我在详细输出中包含了-v ,因此我可以看到所有库以及 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 .请注意,我目前通过简单地将--libs参数用于llvm-config来包含所有 LLVM 组件。 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'; warning: unknown warning option '-Wno-maybe-uninitialized'; is also new in this version of LLVM apparently as I wasn't getting that warn before.显然在这个版本的 LLVM 中也是新的,因为我之前没有收到警告。

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 .我确定这在 Arch 上是可能的,因为我在Arch Wiki上发现了类似错误的搜索之一,但您可以看到我已经在遵循在此stackoverflow 帖子中回答的建议。

Any help with this would be greatly appreciated.对此的任何帮助将不胜感激。

For those that are interested some relevant information can be found in the following links:有兴趣的人可以在以下链接中找到一些相关信息:

Great...伟大的...

So this appears to be a bug with ABI incompatability between GCC 5.0 and Clang.所以这似乎是 GCC 5.0 和 Clang 之间 ABI 不兼容的错误。 :( :(

More information here and the open bug .更多信息在这里和开放的错误

I can fix easily for now by switching from clang++ to g++ in my Makefile.我现在可以通过在我的 Makefile 中从 clang++ 切换到 g++ 来轻松修复。

Funny thing is g++ seems to build WAY faster then clang ever was.有趣的是 g++ 似乎比 clang 构建得更快。 I'm talking orders of magnitude faster.我说的速度要快几个数量级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM