Skip to content

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

@Stanlyhalo

Description

@Stanlyhalo

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

No one assigned

    Labels

    build-problemcmakeBuild system in general and CMake in particular

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions