-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
build-problemcmakeBuild system in general and CMake in particularBuild system in general and CMake in particular
Description
Problem
When attempting to build a project that calls llvm::InitializeAllTargets() using the latest llvm repo changes (as of commit 6aa5388), it throws two compiler errors as denoted in the title.
Steps to reproduce
git clone --depth 1 --config core.autocrlf=false https://github.com/llvm/llvm-project.gitcmake -S llvm -B build -G "Visual Studio 17 2022" -DLLVM_ENABLE_PROJECTS="lld" -DLLVM_BUILD_LLVM_DYLIB=OFF -DLLVM_LINK_LLVM_DYLIB=OFF -DCMAKE_BUILD_TYPE=Debugcmake --build build(this is the long part)- Start a new project and add the includes, links, and add defines for llvm (I use premake, however I'm following the output of the following messages from a cmake test project)
message(WARNING "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(WARNING "${LLVM_INCLUDE_DIRS}\n")
message(WARNING "${LLVM_LIBRARY_DIRS}\n")
message(WARNING "${LLVM_DEFINITIONS}\n")
message(WARNING "${LLVM_AVAILABLE_LIBS}\n")
- Now that a project is setup, write a simple IR builder (anything will do, it's the next part(s) that matter).
- Follow the guide at https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.html.
- Upon attempting to compile (tested in clang vs22) while trying to call
llvm::InitializeAllTargets()in the code, it will throw two errors that state what the error is in the title.
Notes
- Commenting out the function will allow it to compile, however I run into a runtime error since TargetMachine will get returned as a nullptr (which I presume is because I haven't initialized the targets). What this means, is that all the other llvm::InitializeXXX() will work except for the AllTargets option, if that is uncommented, then it'll throw the duplicate symbol error.
Edit*:
After rebuilding & recompiling llvm, error still persists, however it's not reliant on the
llvm::InitializeAllTargets();function (I had a temp solution to exclude that and just call to initialize the x86 target, however now it just doesn't work after a full recompile of llvm).
Metadata
Metadata
Assignees
Labels
build-problemcmakeBuild system in general and CMake in particularBuild system in general and CMake in particular