Skip to content

Commit 581a41c

Browse files
committed
cmake: Don’t add -lobjc in linux builds
Fixes a linux build error. It doesn’t make sense to let add HAS_LIBSWIFT to add_swift_host_library(). This was added to work around a linker bug (d22b348). Instead do the workaround in libSwiftScan/CMakeLists.txt.
1 parent 8651e6a commit 581a41c

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ function(add_swift_host_library name)
466466
SHARED
467467
STATIC
468468
OBJECT
469-
PURE_SWIFT
470-
HAS_LIBSWIFT)
469+
PURE_SWIFT)
471470
set(single_parameter_options)
472471
set(multiple_parameter_options
473472
LLVM_LINK_COMPONENTS)
@@ -520,12 +519,6 @@ function(add_swift_host_library name)
520519
521520
add_library(${name} ${libkind} ${ASHL_SOURCES})
522521
523-
if (ASHL_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE)
524-
# Workaround for a linker crash related to autolinking: rdar://77839981
525-
set_property(TARGET ${name} APPEND_STRING PROPERTY
526-
LINK_FLAGS " -lobjc ")
527-
endif()
528-
529522
# Respect LLVM_COMMON_DEPENDS if it is set.
530523
#
531524
# LLVM_COMMON_DEPENDS if a global variable set in ./lib that provides targets

tools/libSwiftScan/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ set(LLVM_EXPORTED_SYMBOL_FILE
66

77
add_swift_host_library(libSwiftScan SHARED
88
libSwiftScan.cpp
9-
c-include-check.c
10-
HAS_LIBSWIFT)
9+
c-include-check.c)
10+
11+
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
12+
# Workaround for a linker crash related to autolinking: rdar://77839981
13+
set_property(TARGET libSwiftScan APPEND_STRING PROPERTY
14+
LINK_FLAGS " -lobjc ")
15+
endif()
1116

1217
add_dependencies(libSwiftScan
1318
clang

0 commit comments

Comments
 (0)