MSYS2-packages/llvm/0106-Clang-Cygwin-Disable-shared-libs-on-Cygwin-by-defaul.patch
2025-07-09 17:24:53 -07:00

54 lines
2.0 KiB
Diff

From c92c8923e8e7b3238e1b3208d1c7a4513e038ca9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <oss@mateuszmikula.dev>
Date: Fri, 2 May 2025 10:02:11 +0200
Subject: [PATCH] [Clang][Cygwin] Disable shared libs on Cygwin by default
(#138119)
This change follows MinGW decisions, otherwise build with GCC fail with:
```
FAILED: bin/msys-clang-cpp-21.0git.dll lib/libclang-cpp.dll.a
...
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: error: export ordinal too large: 92250
```
Co-authored-by: jeremyd2019 <github@jdrake.com>
---
clang/tools/CMakeLists.txt | 5 +++--
clang/tools/libclang/CMakeLists.txt | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 98c018e968..0446853901 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -21,9 +21,10 @@ endif()
add_clang_subdirectory(c-index-test)
add_clang_subdirectory(clang-refactor)
-# For MinGW we only enable shared library if LLVM_LINK_LLVM_DYLIB=ON.
+# For MinGW/Cygwin we only enable shared library if LLVM_LINK_LLVM_DYLIB=ON.
# Without that option resulting library is too close to 2^16 DLL exports limit.
-if(UNIX OR (MSVC AND LLVM_BUILD_LLVM_DYLIB_VIS) OR (MINGW AND LLVM_LINK_LLVM_DYLIB))
+if((UNIX AND NOT CYGWIN) OR (MSVC AND LLVM_BUILD_LLVM_DYLIB_VIS) OR
+ ((MINGW OR CYGWIN) AND LLVM_LINK_LLVM_DYLIB))
add_clang_subdirectory(clang-shlib)
endif()
diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 00a1223c08..84ced23f17 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -111,7 +111,8 @@ if (LLVM_EXPORTED_SYMBOL_FILE)
DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE})
endif()
-if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC))
+if((NOT (WIN32 OR CYGWIN) AND LLVM_ENABLE_PIC) OR
+ ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC))
set(ENABLE_SHARED SHARED)
endif()
--
2.50.1.windows.1