I can't include the llvm/Support/Host.h
header in C++ even after specifying:
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")
target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})
include_directories(/opt/homebrew/opt/llvm/include)
Every other header file works just fine, it's just Host.h
that is not budging.
Due to that, or maybe something else, trying to do
llvm::sys::getDefaultTargetTriple())
Gives an error, with it complaining that it cannot resolve the symbol getDefaultTargetTriple
To avoid that I also tried:
llvm::Triple triple(Module->getTargetTriple());
llvm::outs() << "Target triple: " << triple.str() << "\n";
Which, gave nothing, it just prints:
Target triple:
Is there something I'm missing?
The full CMakeLists.txt:
cmake_minimum_required(VERSION 3.29)
project(Vast)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#find_package(LLVM REQUIRED CONFIG)
#include_directories(${LLVM_INCLUDE_DIRS})
#add_definitions(${LLVM_DEFINITIONS})
add_executable(Vast
cvast/main.cpp
)
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")
target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})
#target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})
include_directories(/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13)
include_directories(/opt/homebrew/opt/llvm/include)
target_link_libraries(${PROJECT_NAME}
/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/lib/libpython3.13.dylib
)
target_include_directories(Vast PRIVATE /opt/homebrew/include)
Error from C++:
[1/2] Building CXX object CMakeFiles/Vast.dir/cvast/main.cpp.o
FAILED: CMakeFiles/Vast.dir/cvast/main.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++ -I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13 -isystem /opt/homebrew/include -g -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -fcolor-diagnostics -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/Vast.dir/cvast/main.cpp.o -MF CMakeFiles/Vast.dir/cvast/main.cpp.o.d -o CMakeFiles/Vast.dir/cvast/main.cpp.o -c /Users/silicon/PycharmProjects/Vast/cvast/main.cpp
In file included from /Users/silicon/PycharmProjects/Vast/cvast/main.cpp:19:
In file included from /Users/silicon/PycharmProjects/Vast/cvast/headers/runner.h:14:
/Users/silicon/PycharmProjects/Vast/cvast/headers/irgen.h:27:10: fatal error: 'llvm/Support/Host.h' file not found
27 | #include "llvm/Support/Host.h"
| ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
I can't include the llvm/Support/Host.h
header in C++ even after specifying:
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")
target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})
include_directories(/opt/homebrew/opt/llvm/include)
Every other header file works just fine, it's just Host.h
that is not budging.
Due to that, or maybe something else, trying to do
llvm::sys::getDefaultTargetTriple())
Gives an error, with it complaining that it cannot resolve the symbol getDefaultTargetTriple
To avoid that I also tried:
llvm::Triple triple(Module->getTargetTriple());
llvm::outs() << "Target triple: " << triple.str() << "\n";
Which, gave nothing, it just prints:
Target triple:
Is there something I'm missing?
The full CMakeLists.txt:
cmake_minimum_required(VERSION 3.29)
project(Vast)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#find_package(LLVM REQUIRED CONFIG)
#include_directories(${LLVM_INCLUDE_DIRS})
#add_definitions(${LLVM_DEFINITIONS})
add_executable(Vast
cvast/main.cpp
)
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -lLLVM")
target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})
#target_link_libraries(Vast PRIVATE ${LLVM_LIBRARIES})
include_directories(/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13)
include_directories(/opt/homebrew/opt/llvm/include)
target_link_libraries(${PROJECT_NAME}
/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/lib/libpython3.13.dylib
)
target_include_directories(Vast PRIVATE /opt/homebrew/include)
Error from C++:
[1/2] Building CXX object CMakeFiles/Vast.dir/cvast/main.cpp.o
FAILED: CMakeFiles/Vast.dir/cvast/main.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++ -I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.13/include/python3.13 -isystem /opt/homebrew/include -g -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -fcolor-diagnostics -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/Vast.dir/cvast/main.cpp.o -MF CMakeFiles/Vast.dir/cvast/main.cpp.o.d -o CMakeFiles/Vast.dir/cvast/main.cpp.o -c /Users/silicon/PycharmProjects/Vast/cvast/main.cpp
In file included from /Users/silicon/PycharmProjects/Vast/cvast/main.cpp:19:
In file included from /Users/silicon/PycharmProjects/Vast/cvast/headers/runner.h:14:
/Users/silicon/PycharmProjects/Vast/cvast/headers/irgen.h:27:10: fatal error: 'llvm/Support/Host.h' file not found
27 | #include "llvm/Support/Host.h"
| ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
Share
Improve this question
edited Feb 6 at 16:13
Silicon
asked Feb 6 at 14:29
SiliconSilicon
296 bronze badges
4
|
1 Answer
Reset to default 0Back, 5 hours later that is. Turns out the answer is that Host.h
is not located within llvm/Support
, but instead llvm/TargetParser/Host.h
, and with that, you can use the llvm::sys::getDefaultTargetTriple()
.
#include <llvm/Support/Host.h>
– GandhiGandhi Commented Feb 6 at 15:49LLVM_LIBRARIES
contains; I don't see it set. – GandhiGandhi Commented Feb 6 at 15:59#include
is just that,#include "llvm/Support/Host.h"
and the error has been added to the question – Silicon Commented Feb 6 at 16:11"
has slightly different file lookup rules than including with angle bracket<>
– GandhiGandhi Commented Feb 7 at 16:21