Skip to content

Commit 39c0c8e

Browse files
mati865jeremyd2019
authored andcommitted
[LLVM][Cygwin] Enable dynamic linking of libLLVM (llvm#146440)
These changes allow to link everything to shared LLVM library with MSYS2 "Cygwin" toolchain.
1 parent 9a23be7 commit 39c0c8e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function(add_llvm_symbol_exports target_name export_file)
137137
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
138138
LINK_FLAGS " -Wl,--version-script,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
139139
endif()
140-
elseif(WIN32)
140+
elseif(WIN32 OR CYGWIN)
141141
set(native_export_file "${target_name}.def")
142142

143143
add_custom_command(OUTPUT ${native_export_file}
@@ -153,7 +153,7 @@ function(add_llvm_symbol_exports target_name export_file)
153153
elseif(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
154154
# clang in msvc mode, calling a link.exe/lld-link style linker
155155
set(export_file_linker_flag "-Wl,/DEF:${export_file_linker_flag}")
156-
elseif(MINGW)
156+
elseif(MINGW OR CYGWIN)
157157
# ${export_file_linker_flag}, which is the plain file name, works as is
158158
# when passed to the compiler driver, which then passes it on to the
159159
# linker as an input file.
@@ -666,7 +666,7 @@ function(llvm_add_library name)
666666
# When building shared objects for each target there are some internal APIs
667667
# that are used across shared objects which we can't hide.
668668
if (LLVM_BUILD_LLVM_DYLIB_VIS AND NOT BUILD_SHARED_LIBS AND NOT APPLE AND
669-
(NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
669+
(NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
670670
NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
671671
NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
672672

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ if( LLVM_ENABLE_PIC )
455455
endif()
456456

457457
if((NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) AND
458-
(NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
458+
(NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
459459
# GCC for MinGW does nothing about -fvisibility-inlines-hidden, but warns
460460
# about use of the attributes. As long as we don't use the attributes (to
461461
# override the default) we shouldn't set the command line options either.

llvm/include/llvm/Support/Compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
#endif
130130

131131
#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \
132-
(defined(__MINGW32__) && defined(__clang__)))
132+
((defined(__MINGW32__) || defined(__CYGWIN__)) && defined(__clang__)))
133133
#define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN
134134
// Clang compilers older then 15 do not support gnu style attributes on
135135
// namespaces.

llvm/lib/Target/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ add_llvm_component_library(LLVMTarget
2323
# When building shared objects for each target there are some internal APIs
2424
# that are used across shared objects which we can't hide.
2525
if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND
26-
(NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
26+
(NOT (WIN32 OR CYGWIN) OR ((MINGW OR CYGWIN) AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
2727
NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
2828
NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
2929
# Set default visibility to hidden, so we don't export all the Target classes

0 commit comments

Comments
 (0)