File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
stdlib/public/SwiftRemoteMirror Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -792,6 +792,7 @@ function(_add_swift_library_single target name)
792
792
swift_windows_generate_sdk_vfs_overlay (SWIFTLIB_SINGLE_VFS_OVERLAY_FLAGS )
793
793
foreach (flag ${SWIFTLIB_SINGLE_VFS_OVERLAY_FLAGS} )
794
794
list (APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xcc;${flag} )
795
+ list (APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS ${flag} )
795
796
endforeach ()
796
797
foreach (directory ${SWIFTLIB_INCLUDE} )
797
798
list (APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xfrontend;-I${directory} )
@@ -1719,6 +1720,19 @@ function(add_swift_library name)
1719
1720
endif ()
1720
1721
endif ()
1721
1722
1723
+ # We unconditionally removed "-z,defs" from CMAKE_SHARED_LINKER_FLAGS in
1724
+ # swift_common_standalone_build_config_llvm within SwiftSharedCMakeConfig.cmake,
1725
+ # where it was added by a call to HandleLLVMOptions.
1726
+ #
1727
+ # Rather than applying it to all targets and libraries, we here add it back to
1728
+ # supported targets and libraries only.
1729
+ # This is needed for ELF targets only; however, RemoteMirror needs to build
1730
+ # with undefined symbols.
1731
+ if ("${SWIFT_SDK_${LFLAGS_SDK} _OBJECT_FORMAT}" STREQUAL "ELF"
1732
+ AND NOT "${name} " STREQUAL "swiftRemoteMirror" )
1733
+ list (APPEND swiftlib_link_flags_all "-Wl,-z,defs" )
1734
+ endif ()
1735
+
1722
1736
# Add this library variant.
1723
1737
_add_swift_library_single (
1724
1738
${VARIANT_NAME}
Original file line number Diff line number Diff line change @@ -78,9 +78,17 @@ macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
78
78
include (AddSwiftTableGen ) # This imports TableGen from LLVM.
79
79
include (HandleLLVMOptions )
80
80
81
- # HACK: this ugly tweaking is to prevent the propagation of the flag from LLVM
82
- # into swift. The use of this flag pollutes all targets, and we are not able
83
- # to remove it on a per-target basis which breaks cross-compilation.
81
+ # HACK: Not all targets support -z,defs as a linker flag.
82
+ #
83
+ # Normally, LLVM would only add it as an option for known ELF targets;
84
+ # however, due to the custom scheme Swift uses for cross-compilation, the
85
+ # CMAKE_SHARED_LINKER_FLAGS are determined based on the host system and
86
+ # then applied to all targets. This causes issues in cross-compiling to
87
+ # Windows from a Linux host.
88
+ #
89
+ # To work around this, we unconditionally remove the flag here and then
90
+ # selectively add it to the per-target link flags; this is currently done
91
+ # in add_swift_library within AddSwift.cmake.
84
92
string (REGEX REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} " )
85
93
86
94
set (PACKAGE_VERSION "${LLVM_PACKAGE_VERSION} " )
Original file line number Diff line number Diff line change 1
- # HACK: Force this library to build with undefined symbols.
2
- string (REGEX REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} " )
3
-
4
1
# libswiftRemoteMirror.dylib should not have runtime dependencies; it's
5
2
# always built as a shared library.
6
3
if (SWIFT_BUILD_DYNAMIC_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR )
You can’t perform that action at this time.
0 commit comments