llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.77k stars 11.9k forks source link

Duplicate symbol: public: __cdecl llvm::PredicateInfo::~PredicateInfo(void) #87168

Open Stanlyhalo opened 7 months ago

Stanlyhalo commented 7 months ago

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 1) git clone --depth 1 --config core.autocrlf=false https://github.com/llvm/llvm-project.git 2) cmake -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=Debug 3) cmake --build build (this is the long part) 4) 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")

5) Now that a project is setup, write a simple IR builder (anything will do, it's the next part(s) that matter). 6) Follow the guide at https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.html. 7) 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

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).

Stanlyhalo commented 7 months ago

I'll post this as a comment rather then an edit, but a solution I just encountered is that while the macro for cmake for include the available libs is what I'm using, it seems the solution to fix this is to either comment out or remove from the linker "LLVMTableGenCommon.lib".

I would much appreciate if someone replied explaining what this library is for, and if it's important or not before I close this issue, because I don't know if this will cause an issue later on in my project.