Skip to content

Commit 8b5a55d

Browse files
authored
Merge pull request #34180 from spevans/pr_static_executable_fix_1lib
2 parents 7df8b70 + 960d0e3 commit 8b5a55d

File tree

5 files changed

+14
-64
lines changed

5 files changed

+14
-64
lines changed

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL FREEBSD)
274274
${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${SWIFT_PRIMARY_VARIANT_ARCH}.a)
275275
elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL LINUX)
276276
if(SWIFT_BUILD_STATIC_STDLIB)
277-
list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
277+
list(APPEND swift_core_private_link_libraries)
278278
endif()
279279
elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL WINDOWS)
280280
list(APPEND swift_core_private_link_libraries shell32;DbgHelp)

stdlib/public/runtime/CMakeLists.txt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -82,48 +82,9 @@ list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/stdlib/inc
8282

8383
set(sdk "${SWIFT_HOST_VARIANT_SDK}")
8484
if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
85-
list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp)
8685
set(static_binary_lnk_file_list)
8786
string(TOLOWER "${sdk}" lowercase_sdk)
8887

89-
# These two libraries are only used with the static swiftcore
90-
add_swift_target_library(swiftImageInspectionShared STATIC
91-
ImageInspectionELF.cpp
92-
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
93-
LINK_FLAGS ${swift_runtime_linker_flags}
94-
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
95-
INSTALL_IN_COMPONENT stdlib)
96-
97-
foreach(arch IN LISTS SWIFT_SDK_${sdk}_ARCHITECTURES)
98-
set(FragileSupportLibrary swiftImageInspectionShared-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch})
99-
set(LibraryLocation ${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${arch})
100-
add_custom_command_target(swift_image_inspection_${arch}_static
101-
COMMAND
102-
"${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${FragileSupportLibrary}> ${LibraryLocation}
103-
OUTPUT
104-
"${LibraryLocation}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}"
105-
DEPENDS
106-
${FragileSupportLibrary})
107-
add_dependencies(stdlib ${FragileSupportLibrary})
108-
swift_install_in_component(FILES $<TARGET_FILE:${FragileSupportLibrary}>
109-
DESTINATION "lib/swift_static/${lowercase_sdk}/${arch}"
110-
COMPONENT stdlib)
111-
endforeach()
112-
113-
set(FragileSupportLibraryPrimary swiftImageInspectionShared-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${SWIFT_PRIMARY_VARIANT_ARCH})
114-
set(LibraryLocationPrimary ${SWIFTSTATICLIB_DIR}/${lowercase_sdk})
115-
add_custom_command_target(swift_image_inspection_static_primary_arch
116-
COMMAND
117-
"${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${FragileSupportLibraryPrimary}> ${LibraryLocationPrimary}
118-
OUTPUT
119-
"${LibraryLocationPrimary}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}"
120-
DEPENDS
121-
${FragileSupportLibraryPrimary})
122-
add_dependencies(stdlib ${FragileSupportLibraryPrimary})
123-
swift_install_in_component(FILES $<TARGET_FILE:${FragileSupportLibraryPrimary}>
124-
DESTINATION "lib/swift_static/${lowercase_sdk}"
125-
COMPONENT stdlib)
126-
12788
# Generate the static-executable-args.lnk file used for ELF systems (eg linux)
12889
set(linkfile "${lowercase_sdk}/static-executable-args.lnk")
12990
add_custom_command_target(swift_static_binary_${sdk}_args
@@ -141,18 +102,6 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
141102
DESTINATION "lib/swift_static/${lowercase_sdk}"
142103
COMPONENT stdlib)
143104
add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list})
144-
foreach(arch IN LISTS SWIFT_SDK_LINUX_ARCHITECTURES)
145-
add_dependencies(static_binary_magic ${swift_image_inspection_${arch}_static})
146-
endforeach()
147-
add_dependencies(static_binary_magic ${swift_image_inspection_static_primary_arch})
148-
add_dependencies(stdlib static_binary_magic)
149-
150-
add_swift_target_library(swiftImageInspectionSharedObject OBJECT_LIBRARY
151-
ImageInspectionELF.cpp
152-
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
153-
LINK_FLAGS ${swift_runtime_linker_flags}
154-
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
155-
INSTALL_IN_COMPONENT never_install)
156105
endif()
157106

158107
add_swift_target_library(swiftRuntime OBJECT_LIBRARY
@@ -281,7 +230,6 @@ foreach(sdk ${SWIFT_CONFIGURED_SDKS})
281230
-ldl
282231
-lpthread
283232
-lswiftCore
284-
-lswiftImageInspectionShared
285233
${libicu_i18n_a}
286234
${libicu_uc_a}
287235
${libicu_data_a}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Build a static executable "hello world" program
2+
// REQUIRES: OS=linux-gnu
3+
// REQUIRES: static_stdlib
4+
print("hello world!")
5+
// RUN: %empty-directory(%t)
6+
// RUN: %target-swiftc_driver -static-executable -o %t/static-executable %s
7+
// RUN: %t/static-executable | %FileCheck %s
8+
// RUN: file %t/static-executable | %FileCheck %s --check-prefix=FILE
9+
// CHECK: hello world!
10+
// FILE: , statically linked,

unittests/runtime/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
2828
endif()
2929
endif()
3030

31-
set(swift_runtime_test_extra_libraries)
32-
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
33-
list(APPEND swift_runtime_test_extra_libraries
34-
$<TARGET_FILE:swiftImageInspectionShared-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}>)
35-
endif()
36-
3731
add_subdirectory(LongTests)
3832

3933
set(PLATFORM_SOURCES)
@@ -94,7 +88,6 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
9488
PRIVATE
9589
swiftCore${SWIFT_PRIMARY_VARIANT_SUFFIX}
9690
${PLATFORM_TARGET_LINK_LIBRARIES}
97-
${swift_runtime_test_extra_libraries}
9891
)
9992
endif()
10093

utils/static-executable-args.lnk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
-static
22
-lswiftCore
3-
-lswiftImageInspectionShared
43
-Xlinker
5-
--defsym=__import_pthread_self=pthread_self
4+
-undefined=pthread_self
65
-Xlinker
7-
--defsym=__import_pthread_once=pthread_once
6+
-undefined=pthread_once
87
-Xlinker
9-
--defsym=__import_pthread_key_create=pthread_key_create
8+
-undefined=pthread_key_create
109
-lpthread
1110
-licui18nswift
1211
-licuucswift

0 commit comments

Comments
 (0)