Skip to content

Commit 58b919e

Browse files
committed
Support: allow building with non-C/C++ language linkers
When building with Swift as the linker language, CMake will use the Swift driver to perform the link oepration. The flags here are not marked to be interpreted by the linker as the default behaviour with MSVC is to use `link` directly rather than through a linker driver. For simplicity's sake and as an immediate solution to these flags being passed to the driver, avoid the delay load with Swift. A more comprehensive solution would be to pass these flags via `-Xlinker` when building with Swift.
1 parent e91e3cf commit 58b919e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/Support/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ endif( MSVC OR MINGW )
7979
# Delay load shell32.dll if possible to speed up process startup.
8080
set (delayload_flags)
8181
if (MSVC)
82-
set (delayload_flags delayimp -delayload:shell32.dll -delayload:ole32.dll)
82+
# When linking with Swift, `swiftc.exe` is used as the linker drive rather
83+
# than invoking `link.exe` directly. In such a case, the flags should be
84+
# marked as `-Xlinker` to pass them directly to the linker. As a temporary
85+
# workaround simply elide the delay loading.
86+
set (delayload_flags $<$<NOT:$<LINK_LANGUAGE:Swift>>:delayimp -delayload:shell32.dll -delayload:ole32.dll>)
8387
endif()
8488

8589
# Link Z3 if the user wants to build it.

0 commit comments

Comments
 (0)