llvm / llvm/llvm-project

[Build][Visual Studio] Issue while compiling a LLVM project with Visual Studio 17.14.16

Open
#165,827 0 comments 0 reactions 0 assignees View on GitHub
build-problem platform:windows
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I am trying to compile a project that uses LLVM with Visual Studio 17.14.16. I am getting following error with LLVM 21.1.4

> ```
> 6> LLVMAsmPrinter.lib(DwarfDebug.obj) : error LNK2019: unresolved external symbol "public: class std::optional cdecl llvm::DWARFExpression::Operation::getSubCode(void)const " (?getSubCode@Operation@DWARFExpression@llvm@@QEBA?AV?$optional@I@std@@XZ) referenced in function "public: void cdecl llvm::DwarfDebug::emitDebugLocEntry(class llvm::ByteStreamer &,struct llvm::DebugLocStream::Entry const &,class llvm::DwarfCompileUnit const *)" (?emitDebugLocEntry@DwarfDebug@llvm@@QEAAXAEAVByteStreamer@2@AEBUEntry@DebugLocStream@2@PEBVDwarfCompileUnit@2@@Z)
> 6> LLVMDebugInfoDWARF.lib(DWARFExpressionPrinter.obj) : error LNK2001: unresolved external symbol "public: class std::optional __cdecl llvm::DWARFExpression::Operation::getSubCode(void)const " (?getSubCode@Operation@DWARFExpression@llvm@@QEBA?AV?$optional@I@std@@XZ)
> ```

There are many other such errors. All of them are from LLVMDebugInfoDWARF.lib and are mostly in the functions marked with `LLVM_ABI` visibility. I was following the instructions from https://llvm.org/docs/GettingStartedVS.html while building LLVM and my cmake command is:
```
cmake -S ./llvm -B build -A x64 -DLLVM_ENABLE_PROJECTS="clang;llvm" -DLLVM_TARGETS_TO_BUILD=X86 -Thost=x64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" --fresh
```
I compiled the LLVM using Visual Studio after the cmake in Debug X86 mode.
LLVM version 21.1.1 also results in the same error.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported LLVM 21.1.4 build with the provided CMake command and Visual Studio 17.14.16 in Debug X86 mode. Investigate why LLVMDebugInfoDWARF.lib and LLVMAsmPrinter.lib reference unresolved LLVM DWARFExpression::Operation::getSubCode symbols, and compare the generated configuration and linked libraries. Done means the project links without these unresolved external symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.