Skip to content

[windows] fix flaky linker error when building LLDB #138249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

charles-zablit
Copy link
Contributor

When building LLDB on Windows with build.ps1, the following linker error happens, especially after rebuilding incrementally. The error sometimes goes away after deleting CMakeCache.txt, but that's not reliable.

[1/4][ 25%][39.728s] Linking CXX shared library bin\liblldb.dll
FAILED: bin/liblldb.dll lib/liblldb.lib
C:\WINDOWS\system32\cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=tools\lldb\source\API\CMakeFiles\liblldb.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\arm64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\arm64\mt.exe --manifests  -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\HOSTAR~1\arm64\link.exe /nologo @CMakeFiles\liblldb.rsp  /out:bin\liblldb.dll /implib:lib\liblldb.lib /pdb:bin\liblldb.pdb /dll /version:19.1 /machine:ARM64 /INCREMENTAL:NO && cd ."
LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\HOSTAR~1\arm64\link.exe /nologo @CMakeFiles\liblldb.rsp /out:bin\liblldb.dll /implib:lib\liblldb.lib /pdb:bin\liblldb.pdb /dll /version:19.1 /machine:ARM64 /INCREMENTAL:NO /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
   Creating library lib\liblldb.lib and object lib\liblldb.exp
swiftrt.obj : error LNK2019: unresolved external symbol __imp_swift_addNewDSOImage referenced in function "void __cdecl swift_image_constructor(void)" (?swift_image_constructor@@YAXXZ)
bin\liblldb.dll : fatal error LNK1120: 1 unresolved externals
ninja: build stopped: subcommand failed.

This PR fixes this build error.

git apple-llvm automerger added 30 commits April 29, 2025 10:51
@llvmbot
Copy link
Member

llvmbot commented May 2, 2025

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

Changes

When building LLDB on Windows with build.ps1, the following linker error happens, especially after rebuilding incrementally. The error sometimes goes away after deleting CMakeCache.txt, but that's not reliable.

[1/4][ 25%][39.728s] Linking CXX shared library bin\liblldb.dll
FAILED: bin/liblldb.dll lib/liblldb.lib
C:\WINDOWS\system32\cmd.exe /C "cd . &amp;&amp; "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=tools\lldb\source\API\CMakeFiles\liblldb.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\arm64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\arm64\mt.exe --manifests  -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\HOSTAR~1\arm64\link.exe /nologo @<!-- -->CMakeFiles\liblldb.rsp  /out:bin\liblldb.dll /implib:lib\liblldb.lib /pdb:bin\liblldb.pdb /dll /version:19.1 /machine:ARM64 /INCREMENTAL:NO &amp;&amp; cd ."
LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\HOSTAR~1\arm64\link.exe /nologo @<!-- -->CMakeFiles\liblldb.rsp /out:bin\liblldb.dll /implib:lib\liblldb.lib /pdb:bin\liblldb.pdb /dll /version:19.1 /machine:ARM64 /INCREMENTAL:NO /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
   Creating library lib\liblldb.lib and object lib\liblldb.exp
swiftrt.obj : error LNK2019: unresolved external symbol __imp_swift_addNewDSOImage referenced in function "void __cdecl swift_image_constructor(void)" (?swift_image_constructor@@<!-- -->YAXXZ)
bin\liblldb.dll : fatal error LNK1120: 1 unresolved externals
ninja: build stopped: subcommand failed.

This PR fixes this build error.


Full diff: https://github.com/llvm/llvm-project/pull/138249.diff

1 Files Affected:

  • (modified) lldb/source/API/CMakeLists.txt (+1)
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 3bc569608e458..715aa4344f37c 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -142,6 +142,7 @@ add_lldb_library(liblldb SHARED ${option_framework}
     lldbValueObject
     lldbVersion
     ${LLDB_ALL_PLUGINS}
+    swiftCore
   LINK_COMPONENTS
     Support
 

@@ -142,6 +142,7 @@ add_lldb_library(liblldb SHARED ${option_framework}
lldbValueObject
lldbVersion
${LLDB_ALL_PLUGINS}
swiftCore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a library named this in llvm/llvm-project, did you mean to submit this to Apple's llvm fork?

Which is https://github.com/swiftlang/llvm-project (I think).

Copy link
Contributor Author

@charles-zablit charles-zablit May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, sorry about that. I opened the PR here: swiftlang#10612

@charles-zablit charles-zablit force-pushed the charles-zablit/windows/fix-flaky-linker-error branch from 4884f91 to 54eac41 Compare May 2, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants