我正在尝试将llvm用于我的项目。我使用了llvm中的一些头文件,并将它们的路径包含在Makefile中。我也在使用某些llvm库(.a),它包含在makefile中的路径和名称。当我运行makefile时,它构建源代码时没有任何警告或错误但是当我使用生成的.so来运行插件(对于我的项目)时,我得到了未定义符号的错误:
未定义的符号:_ZTIN4llvm2cl18GenericOptionValueE
其中" _ZTIN4llvm2cl18GenericOptionValueE"是" llvm :: cl :: GenericOptionValue"
我按照https://llvm.org/docs/GettingStarted.html
上的命令构建llvm无论是否链接llvm库,都会发生此错误。 我按照llvm.org上的文件,但没有取得任何成功。具体来说 - http://releases.llvm.org/2.6/docs/Projects.html和http://releases.llvm.org/2.6/docs/MakefileGuide.html#overvars 有关LLVM Makefile指南的文档提到了Makefile.config,但这不存在。 nayone有什么建议吗?
makefile是:
CXXFLAGS=-I$(PVLIB_HOME)/include -I$(PVLIB_HOME)/include/fmruntime -I$(PVLIB_HOME)/include/fmruntime/eslapi \
-I/work/Project1/trunk/work/fastsim/Plugins/include -I/work/llvm/llvm-3.8.0/include -I/work/llvm/build/include/ --std=c++11 -I. -fPIC -c
PLUGIN_SRCDIR=Plugin
PIPELINE_MODEL_SRCDIR=Microarchitecture
BUILD_DIR=build
PLUGIN_UTILS=Utils
LIB_PATH=-L/work/llvm/build/lib
LIBS=-lLLVMSupport -lLLVMAArch64Desc -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -ldl
OBJECTS = $(BUILD_DIR)/CAInterface.o $(BUILD_DIR)/InOrderPipelineModelFactoryPlugin.o $(BUILD_DIR)/InOrderPipelineModelPluginHandler.o \
$(BUILD_DIR)/InOrderPipelineModelPlugin.o $(BUILD_DIR)/InOrder4StagePipeline.o \
$(BUILD_DIR)/AArch64Decoder.o $(BUILD_DIR)/EventHandler.o $(BUILD_DIR)/Decode.o $(BUILD_DIR)/ExecuteALU.o \
$(BUILD_DIR)/ExecutionUnit.o $(BUILD_DIR)/Fetch.o $(BUILD_DIR)/Scoreboard.o \
$(BUILD_DIR)/Scoreboard.o $(BUILD_DIR)/Write.o
#
# Build the final plugin
#
$(BUILD_DIR)/InOrderPipelineModel.so: $(OBJECTS)
$(CXX) -shared -o $@ $^ $(LIB_PATH) $(LIBS)
#
# Build the plugin
#
$(BUILD_DIR)/InOrderPipelineModelFactoryPlugin.o : $(PLUGIN_SRCDIR)/InOrderPipelineModelFactoryPlugin.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/InOrderPipelineModelPlugin.o : $(PLUGIN_SRCDIR)/InOrderPipelineModelPlugin.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/InOrderPipelineModelPluginHandler.o : $(PLUGIN_SRCDIR)/InOrderPipelineModelPluginHandler.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/CAInterface.o : $(PLUGIN_SRCDIR)/CAInterface.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
#
# Build the model
#
$(BUILD_DIR)/InOrder4StagePipeline.o : $(PIPELINE_MODEL_SRCDIR)/InOrder4StagePipeline.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/AArch64Decoder.o : $(PIPELINE_MODEL_SRCDIR)/Utils/AArch64Decoder.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/EventHandler.o : $(PIPELINE_MODEL_SRCDIR)/EventHandler.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/Decode.o : $(PIPELINE_MODEL_SRCDIR)/Components/Decode.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/ExecuteALU.o : $(PIPELINE_MODEL_SRCDIR)/Components/ExecuteALU.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/ExecutionUnit.o : $(PIPELINE_MODEL_SRCDIR)/Components/ExecutionUnit.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/Fetch.o : $(PIPELINE_MODEL_SRCDIR)/Components/Fetch.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/Scoreboard.o : $(PIPELINE_MODEL_SRCDIR)/Components/Scoreboard.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
$(BUILD_DIR)/Write.o : $(PIPELINE_MODEL_SRCDIR)/Components/Write.cpp
$(CXX) $(CXXFLAGS) $^ -o $@
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR)/*.o $(BUILD_DIR)/*.so
答案 0 :(得分:0)
人们说[1]这与传递给编译器(CXX_FLAGS)的标志中缺少的标志-fno-rtti
有关。
在链接问题[2]中,作者使用llvm-config --cxxflags
来获取LLVM推荐的正确CXX标记。在我的机器上,这些标志的列表确实包含-fno-rtti
,我相信这是LLVM默认给出的编译器。
[1] [cmake] klee does not build without -fno-rtti #508
[2] LLVM OS X symbol(s) not found for architecture x86_64 compile error