88 lines
4.4 KiB
Diff
88 lines
4.4 KiB
Diff
From 39c0c8eb59bb76eb2ad07183a06ebdadbc4290df Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <oss@mateuszmikula.dev>
|
|
Date: Wed, 2 Jul 2025 07:30:12 +0200
|
|
Subject: [PATCH] [LLVM][Cygwin] Enable dynamic linking of libLLVM (#146440)
|
|
|
|
These changes allow to link everything to shared LLVM library with
|
|
MSYS2 "Cygwin" toolchain.
|
|
---
|
|
llvm/cmake/modules/AddLLVM.cmake | 6 +++---
|
|
llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +-
|
|
llvm/include/llvm/Support/Compiler.h | 2 +-
|
|
llvm/lib/Target/CMakeLists.txt | 2 +-
|
|
4 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
|
|
index 2fd9e12365..52139eb143 100644
|
|
--- a/llvm/cmake/modules/AddLLVM.cmake
|
|
+++ b/llvm/cmake/modules/AddLLVM.cmake
|
|
@@ -137,7 +137,7 @@ function(add_llvm_symbol_exports target_name export_file)
|
|
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -Wl,--version-script,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
|
|
endif()
|
|
- elseif(WIN32)
|
|
+ elseif(WIN32 OR CYGWIN)
|
|
set(native_export_file "${target_name}.def")
|
|
|
|
add_custom_command(OUTPUT ${native_export_file}
|
|
@@ -153,7 +153,7 @@ function(add_llvm_symbol_exports target_name export_file)
|
|
elseif(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
|
# clang in msvc mode, calling a link.exe/lld-link style linker
|
|
set(export_file_linker_flag "-Wl,/DEF:${export_file_linker_flag}")
|
|
- elseif(MINGW)
|
|
+ elseif(MINGW OR CYGWIN)
|
|
# ${export_file_linker_flag}, which is the plain file name, works as is
|
|
# when passed to the compiler driver, which then passes it on to the
|
|
# linker as an input file.
|
|
@@ -666,7 +666,7 @@ function(llvm_add_library name)
|
|
# When building shared objects for each target there are some internal APIs
|
|
# that are used across shared objects which we can't hide.
|
|
if (LLVM_BUILD_LLVM_DYLIB_VIS AND NOT BUILD_SHARED_LIBS AND NOT APPLE AND
|
|
- (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
|
|
+ (NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
|
|
NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
|
|
NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
|
|
|
|
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
|
index f09fce24e5..7dac6edf9a 100644
|
|
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
|
|
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
|
@@ -455,7 +455,7 @@ if( LLVM_ENABLE_PIC )
|
|
endif()
|
|
|
|
if((NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) AND
|
|
- (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
|
|
+ (NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
|
|
# GCC for MinGW does nothing about -fvisibility-inlines-hidden, but warns
|
|
# about use of the attributes. As long as we don't use the attributes (to
|
|
# override the default) we shouldn't set the command line options either.
|
|
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
|
|
index 0d26c81308..6c1a9b7e70 100644
|
|
--- a/llvm/include/llvm/Support/Compiler.h
|
|
+++ b/llvm/include/llvm/Support/Compiler.h
|
|
@@ -129,7 +129,7 @@
|
|
#endif
|
|
|
|
#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \
|
|
- (defined(__MINGW32__) && defined(__clang__)))
|
|
+ ((defined(__MINGW32__) || defined(__CYGWIN__)) && defined(__clang__)))
|
|
#define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
|
|
// Clang compilers older then 15 do not support gnu style attributes on
|
|
// namespaces.
|
|
diff --git a/llvm/lib/Target/CMakeLists.txt b/llvm/lib/Target/CMakeLists.txt
|
|
index 2739233f9c..e2c86baffb 100644
|
|
--- a/llvm/lib/Target/CMakeLists.txt
|
|
+++ b/llvm/lib/Target/CMakeLists.txt
|
|
@@ -23,7 +23,7 @@ add_llvm_component_library(LLVMTarget
|
|
# When building shared objects for each target there are some internal APIs
|
|
# that are used across shared objects which we can't hide.
|
|
if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND
|
|
- (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
|
|
+ (NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
|
|
NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
|
|
NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
|
|
# Set default visibility to hidden, so we don't export all the Target classes
|
|
--
|
|
2.50.1.windows.1
|
|
|