gpt4 book ai didi

linux - Arch Linux 上来自 git (3.9.0svn) 的最新 LLVM 的“ undefined reference ”链接器错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:45:16 25 4
gpt4 key购买 nike

在我的 Macbook Pro 主板出现故障之前,我正在使用 Flex、Bison 和 LLVM 编写我的编程语言。老实说,我不记得我当时链接的 LLVM 版本(我会在从驱动器中抢救数据后尝试找出它),但我知道我现在使用的最新版本来自 git (clang 版本 3.9.0(http://llvm.org/git/clang.git 7658b570923dcdfaaec04d837b7e8862eff895f8)(http://llvm.org/git/llvm.git 4edb79d2d975816fee53b814703812b2287ed455))有一些我必须补偿的小 API 更改。

实际上,我最终用 MSI GS40 替换了我的 Macbook,并选择了 Arch Linux 作为我的新主操作系统。所以我这里的两个主要变量是 Linux 与 OS X 以及所涉及的不同版本的 LLVM/Clang/GCC。

我像在 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

直到这一次我才意识到它创建了一个“prefix=”文件夹,因为 LLVM 的文档使它看起来就像是命令(实际上你会省略 prefix=).所以我只是手动将输出 llvm 文件夹移动到一个新位置,并将 include 目录导出到我的 .bash_profile 中。

我现在正在编译项目,但我无法与 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

奇怪的是,它们应该在包含的 LLVMSupport 库中。

我的生成文件:

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

您会注意到我包含了用于详细输出的 -v,因此我可以看到所有的库以及 llvm-config 包含的此类库。我实际上已经尝试了几种不同的构建参数,但最终遇到了更多链接器问题。

这是完整构建的详细输出示例:

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

请注意,我目前通过简单地使用 --libs 参数到 llvm-config 来包括所有 LLVM 组件。我也尝试通过选择我需要的各种组件来修改它,结果相同。

warning: unknown warning option '-Wno-maybe-uninitialized'; 显然也是这个版本的 LLVM 中的新内容,因为我之前没有收到该警告。

我确信这在 Arch 上是可能的,因为我发现有类似错误的搜索之一是在 Arch Wiki 上,但是你可以看到我已经在遵循在这个 stackoverflow post 上回答的建议.

如有任何帮助,我们将不胜感激。

对于那些感兴趣的人,可以在以下链接中找到一些相关信息:

最佳答案

很好...

所以这似乎是 GCC 5.0 和 Clang 之间 ABI 不兼容的错误。 :(

更多信息 here和开放bug .

我现在可以通过在我的 Makefile 中从 clang++ 切换到 g++ 轻松修复。

有趣的是,g++ 的构建速度似乎比 clang 快得多。我说的是快几个数量级。

关于linux - Arch Linux 上来自 git (3.9.0svn) 的最新 LLVM 的“ undefined reference ”链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37900835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com