[llvm] Support: allow building with non-C/C++ language linkers (PR #65634)

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 09:28:29 PDT 2023


https://github.com/compnerd created https://github.com/llvm/llvm-project/pull/65634:

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.

>From a32d38a083db5c2853a882854fbcc62ca257d42d Mon Sep 17 00:00:00 2001
From: Saleem Abdulrasool <compnerd at compnerd.org>
Date: Thu, 7 Sep 2023 09:21:54 -0700
Subject: [PATCH] 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.
---
 llvm/lib/Support/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 87fe7bebf688d4e..3fbe0190ac877e8 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -79,7 +79,7 @@ endif( MSVC OR MINGW )
 # Delay load shell32.dll if possible to speed up process startup.
 set (delayload_flags)
 if (MSVC)
-  set (delayload_flags delayimp -delayload:shell32.dll -delayload:ole32.dll)
+  set (delayload_flags $<$<NOT:$<LINK_LANGUAGE:Swift>>:"SHELL:delayimp -delayload:shell32.dll -delayload:ole32.dll">)
 endif()
 
 # Link Z3 if the user wants to build it.



More information about the llvm-commits mailing list