[llvm] [CMake] lld-link.exe do not know --gc-sections option (PR #196393)

Artur Wojcik via llvm-commits llvm-commits at lists.llvm.org
Fri May 8 00:02:03 PDT 2026


https://github.com/apwojcik updated https://github.com/llvm/llvm-project/pull/196393

>From 5c3050e4e6e8a78bd7efc5c73bbd1011edcaa97f Mon Sep 17 00:00:00 2001
From: Artur Wojcik <Artur.Wojcik at amd.com>
Date: Thu, 7 May 2026 20:50:18 +0200
Subject: [PATCH] llvm-ld.exe do not know --gc-sections option

---
 llvm/cmake/modules/AddLLVM.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 28858db434f91..cbef77e4fd8d0 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -382,7 +382,7 @@ function(add_link_opts target_name)
           set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                        LINK_FLAGS " -Wl,-z,discard-unused=sections")
         endif()
-      elseif(NOT MSVC AND NOT CMAKE_SYSTEM_NAME MATCHES "AIX|OS390")
+    elseif(NOT WIN32 AND NOT CMAKE_SYSTEM_NAME MATCHES "AIX|OS390")
         # TODO Revisit this later on z/OS.
         set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                      LINK_FLAGS " -Wl,--gc-sections")



More information about the llvm-commits mailing list