Closed yanglee110 closed 7 years ago
I believe you are missing the LLVM dev headers? You'll need those too.
However I have built the LLVM 3.4 source code successfully and set the LLVM_HOME variable, Of course LLVM 3.4 includes headers. And then I perform the Configure step correctly, So I think the LLVM 3.4 header files are not configured in the Configure step. Any ideas? Thanks!
What platform are you building this on?
Did you manage to resolve this issue? If so, I will close this issue.
I also had this issue as well when I built LLVM from source and installed to a non-system directory. The LLVM headers are not included from $LLVM_HOME for this file. The required fix is:
--- a/full-trace/CMakeLists.txt
+++ b/full-trace/CMakeLists.txt
@@ -1,5 +1,7 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
+include_directories($ENV{LLVM_HOME}/include)
+
file(GLOB SRC "*.cpp")
add_library(full_trace SHARED ${SRC})
install(TARGETS full_trace LIBRARY DESTINATION lib)
The LLVM headers are supposed being included by cmake-scripts/findAndSetLLVM:24, then cmake
configure each subdirectories.
I tested these cmake scripts with cmake 2.8/3.6 and Linux Mint 17/18, and LLVM 3.4/3.5 installed under home directory. Maybe your cmake
does not pass these header settings to subdirectory?
What is your OS and cmake
version? You can get it by lsb_release -a
and cmake --version
# cmake-scripts/findAndSetLLVM
# This function returns these variable
#
# LLVM_ROOT
# LLVM_LIBS
# LLVM_DEFINITIONS
# LLVM_INCLUDE_DIRS
# LLVM_LIBRARY_DIRS
FIND_LLVM(${LLVM_ROOT} ${LLVM_RECOMMEND_VERSION} NEED_LLVM_LIB ${AUTOINSTALL})
findLLVMTool(LLVM_LINK "llvm-link")
findLLVMTool(LLVM_OPT "opt")
findLLVMTool(LLVM_LLC "llc")
findLLVMTool(LLVM_COMPILER "clang")
set(LLVMC_FLAGS ${LLVM_DEFINITIONS}
-fno-inline-functions -fno-use-cxa-atexit)
set(LLVM_OPT_FLAGS )
# Use settings from LLVM cmake module or llvm-config.
include_directories( ${LLVM_INCLUDE_DIRS} )
link_directories( ${LLVM_LIBRARY_DIRS} )
add_definitions( ${LLVM_DEFINITIONS} )
@rgly lsb and cmake output listed below:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily
$ cmake --version
cmake version 3.2.2
$ mkdir build && cd build && cmake .. # Using TEST_CMAKE
-- The CXX compiler identification is GNU 5.2.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- use LLVM_ROOT : /home/$USER/inst/llvm-3.4/inst
-- find LLVM-Config : /home/$USER/inst/llvm-3.4/inst/bin/llvm-config
-- LLVM version : 3.4svn
-- LLVM_LINK found : /home/$USER/inst/llvm-3.4/inst/bin/llvm-link
-- LLVM_OPT found : /home/$USER/inst/llvm-3.4/inst/bin/opt
-- LLVM_LLC found : /home/$USER/inst/llvm-3.4/inst/bin/llc
-- LLVM_COMPILER found : /home/$USER/inst/llvm-3.4/inst/bin/clang-3.4
debug messages below
LLVM_ROOT is /home/$USER/inst/llvm-3.4/inst
REQ_LLVM_LIBRARIES is LLVMMCJIT;LLVMBitWriter;LLVMInterpreter;LLVMLinker;LLVMIRReader;LLVMX86CodeGen;LLVMX86AsmParser;LLVMX86Disassembler;LLVMJIT;LLVMAsmParser;LLVMBitReader;LLVMAsmPrinter;LLVMSelectionDAG;LLVMX86Desc;LLVMExecutionEngine;LLVMRuntimeDyld;LLVMMCParser;LLVMCodeGen;LLVMX86AsmPrinter;LLVMX86Info;LLVMObjCARCOpts;LLVMScalarOpts;LLVMX86Utils;LLVMInstCombine;LLVMTransformUtils;LLVMipa;LLVMAnalysis;LLVMTarget;LLVMCore;LLVMMC;LLVMObject;LLVMSupport;dl;tinfo;pthread;z
LLVM_COMPILER is /home/$USER/inst/llvm-3.4/inst/bin/clang-3.4
LLVMC_FLAGS is -D__STDC_LIMIT_MACROS;-D__STDC_CONSTANT_MACROS;-fno-inline-functions;-fno-use-cxa-atexit
LLVM_DEFINITIONS is -D__STDC_LIMIT_MACROS;-D__STDC_CONSTANT_MACROS
LLVM_LIBRARY_DIRS is /usr/local/lib
LLVM_INCLUDE_DIRS is /usr/local/include
-- Found Curses: /usr/lib/x86_64-linux-gnu/libcurses.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/$USER/inst/LLVM-Tracer/build
If I then look at full-trace-CMakeFiles/full_trace.dir/flags.make
# compile CXX with /usr/bin/c++
CXX_FLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -std=c++11 -fno-rtti -O3 -fPIC -I/usr/local/include
CXX_DEFINES = -DLLVM_VERSION=34 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -Dfull_trace_EXPORTS
So the includes are definitely not being passed. Is there some major difference in include behaviour between cmake 2.8/3.6 and cmake 3.2?
Note that I also have llvm 3.5 and 3.6 installed under /usr/bin/llvm-config-3.5 and /usr/bin/llvm-config-3.6. My PATH is set up to return the correct llvm-config though.
CMake scripts obtain header directories through find_package(). It seems that find_package() searches system directories first.
Could you please try the following patch? It forces cmake using llvm-config instead of find_package().
diff --git a/cmake-scripts/LLVMFinder/findLLVM.cmake b/cmake-scripts/LLVMFinder/
index c107cc6..5b9c02e 100644
--- a/cmake-scripts/LLVMFinder/findLLVM.cmake
+++ b/cmake-scripts/LLVMFinder/findLLVM.cmake
@@ -92,10 +92,9 @@ FUNCTION(LOAD_LLVM_SETTINGS LLVM_CONFIG_EXE NEED_LLVM_LIB_ARG
get_filename_component(LLVM_ROOT ${LLVM_BIN_DIR} PATH)
# try to load the CMake module of LLVM.
- loadLLVMModule(${LLVM_ROOT} ${NEED_LLVM_LIB_ARG})
# Check whether LLVM package is found.
- if(NOT ${LLVM_FOUND})
+ if(NOT "${LLVM_FOUND}")
# if CMake module of LLVM is not found, we collect infomation
# through llvm-config.
loadLLVMConfig(${LLVM_CONFIG_EXE} ${NEED_LLVM_LIB_ARG})
Hi, I am following the README.rd to build the LLVM-Tracer project and I came across a problem when I use the
make
command, that is "full-trace/full_trace.cpp:4:31: fatal error: llvm/IR/Constants.h: No such file or directory". Thanks for any help!Here is what I tried. (1) I have built the LLVM 3.4 source using
cmake
and 'ninja' and then set "LLVM_HOME=/home/xxx/llvm3.4" (2) I have used thecmake
command to generate the Makefile correctly. such as "-- Build files have been written to: "/home/xxx/LLVM-Tracer-master/build" (3) When I use themake
command in the directory "/home/xxx/LLVM-Tracer-master/build", it emit the above error: Scanning dependencies of target full_trace [ 7%] Building CXX object full-trace/CMakeFiles/full_trace.dir/full_trace.cpp.o /home/xxx/LLVM-Tracer-master/full-trace/full_trace.cpp:4:31: fatal error: llvm/IR/Constants.h: No such file or directoryinclude "llvm/IR/Constants.h"