Skip to content

Commit 1f6a8ff

Browse files
authored
Merge pull request #5394 from spevans/pr_libicu_with_static_executable
[SR-648] Add option to create statically linked binaries (take 2)
2 parents 360ba8a + 707588c commit 1f6a8ff

File tree

15 files changed

+436
-29
lines changed

15 files changed

+436
-29
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ function(_add_swift_library_single target name)
567567
cmake_parse_arguments(SWIFTLIB_SINGLE
568568
"${SWIFTLIB_SINGLE_options}"
569569
"MODULE_TARGET;SDK;ARCHITECTURE;INSTALL_IN_COMPONENT;DEPLOYMENT_VERSION_OSX;DEPLOYMENT_VERSION_IOS;DEPLOYMENT_VERSION_TVOS;DEPLOYMENT_VERSION_WATCHOS"
570-
"DEPENDS;LINK_LIBRARIES;FRAMEWORK_DEPENDS;FRAMEWORK_DEPENDS_WEAK;LLVM_COMPONENT_DEPENDS;C_COMPILE_FLAGS;SWIFT_COMPILE_FLAGS;LINK_FLAGS;PRIVATE_LINK_LIBRARIES;INTERFACE_LINK_LIBRARIES;INCORPORATE_OBJECT_LIBRARIES;FILE_DEPENDS"
570+
"DEPENDS;LINK_LIBRARIES;FRAMEWORK_DEPENDS;FRAMEWORK_DEPENDS_WEAK;LLVM_COMPONENT_DEPENDS;C_COMPILE_FLAGS;SWIFT_COMPILE_FLAGS;LINK_FLAGS;PRIVATE_LINK_LIBRARIES;INTERFACE_LINK_LIBRARIES;INCORPORATE_OBJECT_LIBRARIES;INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY;FILE_DEPENDS"
571571
${ARGN})
572572

573573
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_UNPARSED_ARGUMENTS})
@@ -739,6 +739,12 @@ function(_add_swift_library_single target name)
739739
$<TARGET_OBJECTS:${object_library}${VARIANT_SUFFIX}>)
740740
endforeach()
741741

742+
set(SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS_SHARED_ONLY)
743+
foreach(object_library ${SWIFTLIB_SINGLE_INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY})
744+
list(APPEND SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS_SHARED_ONLY
745+
$<TARGET_OBJECTS:${object_library}${VARIANT_SUFFIX}>)
746+
endforeach()
747+
742748
set(SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES)
743749
if(XCODE AND SWIFTLIB_SINGLE_TARGET_LIBRARY)
744750
set(SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES
@@ -747,11 +753,17 @@ function(_add_swift_library_single target name)
747753
${SWIFT_SOURCE_DIR}/cmake/dummy.cpp)
748754
endif()
749755

756+
set(INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS ${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS})
757+
if(${libkind} STREQUAL "SHARED")
758+
list(APPEND INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS
759+
${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS_SHARED_ONLY})
760+
endif()
761+
750762
add_library("${target}" ${libkind}
751763
${SWIFT_SECTIONS_OBJECT_BEGIN}
752764
${SWIFTLIB_SINGLE_SOURCES}
753765
${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}
754-
${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
766+
${INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
755767
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES}
756768
${SWIFT_SECTIONS_OBJECT_END})
757769
_set_target_prefix_and_suffix("${target}" "${libkind}" "${SWIFTLIB_SINGLE_SDK}")
@@ -1270,7 +1282,7 @@ function(add_swift_library name)
12701282
cmake_parse_arguments(SWIFTLIB
12711283
"${SWIFTLIB_options}"
12721284
"INSTALL_IN_COMPONENT;DEPLOYMENT_VERSION_OSX;DEPLOYMENT_VERSION_IOS;DEPLOYMENT_VERSION_TVOS;DEPLOYMENT_VERSION_WATCHOS"
1273-
"DEPENDS;LINK_LIBRARIES;SWIFT_MODULE_DEPENDS;SWIFT_MODULE_DEPENDS_OSX;SWIFT_MODULE_DEPENDS_IOS;SWIFT_MODULE_DEPENDS_TVOS;SWIFT_MODULE_DEPENDS_WATCHOS;SWIFT_MODULE_DEPENDS_FREEBSD;SWIFT_MODULE_DEPENDS_LINUX;FRAMEWORK_DEPENDS;FRAMEWORK_DEPENDS_WEAK;FRAMEWORK_DEPENDS_OSX;FRAMEWORK_DEPENDS_IOS_TVOS;LLVM_COMPONENT_DEPENDS;FILE_DEPENDS;TARGET_SDKS;C_COMPILE_FLAGS;SWIFT_COMPILE_FLAGS;SWIFT_COMPILE_FLAGS_OSX;SWIFT_COMPILE_FLAGS_IOS;SWIFT_COMPILE_FLAGS_TVOS;SWIFT_COMPILE_FLAGS_WATCHOS;LINK_FLAGS;PRIVATE_LINK_LIBRARIES;INTERFACE_LINK_LIBRARIES;INCORPORATE_OBJECT_LIBRARIES"
1285+
"DEPENDS;LINK_LIBRARIES;SWIFT_MODULE_DEPENDS;SWIFT_MODULE_DEPENDS_OSX;SWIFT_MODULE_DEPENDS_IOS;SWIFT_MODULE_DEPENDS_TVOS;SWIFT_MODULE_DEPENDS_WATCHOS;SWIFT_MODULE_DEPENDS_FREEBSD;SWIFT_MODULE_DEPENDS_LINUX;FRAMEWORK_DEPENDS;FRAMEWORK_DEPENDS_WEAK;FRAMEWORK_DEPENDS_OSX;FRAMEWORK_DEPENDS_IOS_TVOS;LLVM_COMPONENT_DEPENDS;FILE_DEPENDS;TARGET_SDKS;C_COMPILE_FLAGS;SWIFT_COMPILE_FLAGS;SWIFT_COMPILE_FLAGS_OSX;SWIFT_COMPILE_FLAGS_IOS;SWIFT_COMPILE_FLAGS_TVOS;SWIFT_COMPILE_FLAGS_WATCHOS;LINK_FLAGS;PRIVATE_LINK_LIBRARIES;INTERFACE_LINK_LIBRARIES;INCORPORATE_OBJECT_LIBRARIES;INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY"
12741286
${ARGN})
12751287
set(SWIFTLIB_SOURCES ${SWIFTLIB_UNPARSED_ARGUMENTS})
12761288

@@ -1491,6 +1503,7 @@ function(add_swift_library name)
14911503
LINK_FLAGS ${SWIFTLIB_LINK_FLAGS}
14921504
PRIVATE_LINK_LIBRARIES ${swiftlib_private_link_libraries_targets}
14931505
INCORPORATE_OBJECT_LIBRARIES ${SWIFTLIB_INCORPORATE_OBJECT_LIBRARIES}
1506+
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY ${SWIFTLIB_INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY}
14941507
${SWIFTLIB_DONT_EMBED_BITCODE_keyword}
14951508
${SWIFTLIB_API_NOTES_NON_OVERLAY_keyword}
14961509
${SWIFTLIB_IS_STDLIB_keyword}
@@ -1682,6 +1695,7 @@ function(add_swift_library name)
16821695
PRIVATE_LINK_LIBRARIES ${SWIFTLIB_PRIVATE_LINK_LIBRARIES}
16831696
INTERFACE_LINK_LIBRARIES ${SWIFTLIB_INTERFACE_LINK_LIBRARIES}
16841697
INCORPORATE_OBJECT_LIBRARIES ${SWIFTLIB_INCORPORATE_OBJECT_LIBRARIES}
1698+
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY ${SWIFTLIB_INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY}
16851699
${SWIFTLIB_DONT_EMBED_BITCODE_keyword}
16861700
${SWIFTLIB_API_NOTES_NON_OVERLAY_keyword}
16871701
${SWIFTLIB_IS_STDLIB_keyword}

include/swift/Option/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ def no_static_stdlib: Flag<["-"], "no-static-stdlib">,
282282
Flags<[HelpHidden]>,
283283
HelpText<"Don't statically link the Swift standard library">;
284284

285+
def static_executable : Flag<["-"], "static-executable">,
286+
HelpText<"Statically link the executable">;
287+
def no_static_executable : Flag<["-"], "no-static-executable">,
288+
Flags<[HelpHidden]>,
289+
HelpText<"Don't statically link the executable">;
290+
285291
def use_ld : Joined<["-"], "use-ld=">,
286292
Flags<[DoesNotAffectIncrementalBuild]>,
287293
HelpText<"Specifies the linker to be used">;

lib/Driver/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,33 @@ add_swift_library(swiftDriver STATIC
1919
DEPENDS SwiftOptions
2020
LINK_LIBRARIES swiftAST swiftBasic swiftFrontend swiftOption)
2121

22+
# Generate the static-stdlib-args.lnk file used by -static-stdlib option
23+
# for 'GenericUnix' (eg linux)
24+
if(SWIFT_BUILD_STATIC_STDLIB)
25+
set(static_stdlib_lnk_file_list)
26+
foreach(sdk ${SWIFT_CONFIGURED_SDKS})
27+
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
28+
string(TOLOWER "${sdk}" lowercase_sdk)
29+
if(SWIFT_LINUX_ICU_STATICLIB)
30+
set(ICU_STATICLIB "TRUE")
31+
else()
32+
set(ICU_STATICLIB "FALSE")
33+
endif()
34+
set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk")
35+
add_custom_command_target(swift_static_stdlib_${sdk}_args
36+
COMMAND
37+
"${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args"
38+
"${sdk}"
39+
"${SWIFTSTATICLIB_DIR}/${linkfile}"
40+
"${ICU_STATICLIB}"
41+
OUTPUT
42+
"${SWIFTSTATICLIB_DIR}/${linkfile}")
43+
44+
list(APPEND static_stdlib_lnk_file_list ${swift_static_stdlib_${sdk}_args})
45+
swift_install_in_component(stdlib
46+
FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
47+
DESTINATION "lib/swift_static/${lowercase_sdk}")
48+
endif()
49+
endforeach()
50+
add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list})
51+
endif()

lib/Driver/ToolChains.cpp

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,12 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
952952
assert(context.Output.getPrimaryOutputType() == types::TY_Image &&
953953
"Invalid linker output type.");
954954

955+
if (context.Args.hasFlag(options::OPT_static_executable,
956+
options::OPT_no_static_executable,
957+
false)) {
958+
llvm::report_fatal_error("-static-executable is not supported on Darwin");
959+
}
960+
955961
const Driver &D = getDriver();
956962
const llvm::Triple &Triple = getTriple();
957963

@@ -1357,33 +1363,42 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
13571363

13581364
// Link the standard library.
13591365
Arguments.push_back("-L");
1360-
if (context.Args.hasFlag(options::OPT_static_stdlib,
1361-
options::OPT_no_static_stdlib,
1362-
false)) {
1366+
if (context.Args.hasFlag(options::OPT_static_executable,
1367+
options::OPT_no_static_executable,
1368+
false)) {
13631369
SmallString<128> StaticRuntimeLibPath;
13641370
getRuntimeStaticLibraryPath(StaticRuntimeLibPath, context.Args, *this);
13651371
Arguments.push_back(context.Args.MakeArgString(StaticRuntimeLibPath));
1366-
// The following libraries are required to build a satisfactory
1367-
// static program
1368-
Arguments.push_back("-ldl");
1369-
Arguments.push_back("-lpthread");
1370-
Arguments.push_back("-lbsd");
1371-
Arguments.push_back("-licui18n");
1372-
Arguments.push_back("-licuuc");
1373-
// The runtime uses dlopen to look for the protocol conformances.
1374-
// Therefore, we need to ensure they appear in the dynamic table.
1375-
// This happens automatically for dynamically-linked programs, but
1376-
// in this case we have to take additional measures.
1377-
Arguments.push_back("-Xlinker");
1378-
Arguments.push_back("-export-dynamic");
1379-
Arguments.push_back("-Xlinker");
1380-
Arguments.push_back("--exclude-libs");
1381-
Arguments.push_back("-Xlinker");
1382-
Arguments.push_back("ALL");
13831372

1373+
SmallString<128> linkFilePath = StaticRuntimeLibPath;
1374+
llvm::sys::path::append(linkFilePath, "static-executable-args.lnk");
1375+
auto linkFile = linkFilePath.str();
1376+
1377+
if (llvm::sys::fs::is_regular_file(linkFile)) {
1378+
Arguments.push_back(context.Args.MakeArgString(Twine("@") + linkFile));
1379+
} else {
1380+
llvm::report_fatal_error("-static-executable not supported on this platform");
1381+
}
1382+
}
1383+
else if (context.Args.hasFlag(options::OPT_static_stdlib,
1384+
options::OPT_no_static_stdlib,
1385+
false)) {
1386+
SmallString<128> StaticRuntimeLibPath;
1387+
getRuntimeStaticLibraryPath(StaticRuntimeLibPath, context.Args, *this);
1388+
Arguments.push_back(context.Args.MakeArgString(StaticRuntimeLibPath));
1389+
1390+
SmallString<128> linkFilePath = StaticRuntimeLibPath;
1391+
llvm::sys::path::append(linkFilePath, "static-stdlib-args.lnk");
1392+
auto linkFile = linkFilePath.str();
1393+
if (llvm::sys::fs::is_regular_file(linkFile)) {
1394+
Arguments.push_back(context.Args.MakeArgString(Twine("@") + linkFile));
1395+
} else {
1396+
llvm::report_fatal_error(linkFile + " not found");
1397+
}
13841398
}
13851399
else {
13861400
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
1401+
Arguments.push_back("-lswiftCore");
13871402
}
13881403

13891404

@@ -1404,8 +1419,6 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
14041419
Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
14051420
}
14061421

1407-
// Always add the stdlib
1408-
Arguments.push_back("-lswiftCore");
14091422

14101423
// Add any autolinking scripts to the arguments
14111424
for (const Job *Cmd : context.Inputs) {

stdlib/public/core/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ else()
177177
# effort has been completed.
178178
#set(LINK_FLAGS
179179
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
180-
find_package(ICU REQUIRED COMPONENTS uc i18n)
181-
list(APPEND swift_core_private_link_libraries
182-
ICU_UC ICU_I18N)
180+
if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
181+
find_package(ICU REQUIRED COMPONENTS uc i18n)
182+
list(APPEND swift_core_private_link_libraries
183+
ICU_UC ICU_I18N)
184+
else()
185+
list(APPEND swift_core_private_link_libraries -licui18n -licuuc -licudata)
186+
endif()
183187
endif()
184188

185189
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
@@ -209,6 +213,12 @@ if(SWIFT_CHECK_ESSENTIAL_STDLIB)
209213
target_link_libraries(swift_stdlib_essential ${RUNTIME_DEPENDENCY})
210214
endif()
211215

216+
217+
set(shared_only_libs)
218+
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
219+
list(APPEND shared_only_libs swiftImageInspectionShared)
220+
endif()
221+
212222
add_swift_library(swiftCore ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE
213223
${SWIFTLIB_SOURCES}
214224
# The copy_shim_headers target dependency is required to let the
@@ -224,5 +234,6 @@ add_swift_library(swiftCore ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STD
224234
LINK_FLAGS ${swift_core_link_flags}
225235
PRIVATE_LINK_LIBRARIES ${swift_core_private_link_libraries}
226236
INCORPORATE_OBJECT_LIBRARIES swiftRuntime swiftStdlibStubs
237+
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY ${shared_only_libs}
227238
FRAMEWORK_DEPENDS ${swift_core_framework_depends}
228239
INSTALL_IN_COMPONENT stdlib)

stdlib/public/runtime/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,57 @@ set(LLVM_OPTIONAL_SOURCES
6262
MutexPThread.cpp
6363
MutexWin32.cpp
6464
CygwinPort.cpp
65+
ImageInspectionELF.cpp
66+
ImageInspectionStatic.cpp
6567
${swift_runtime_sources}
6668
${swift_runtime_objc_sources}
6769
${swift_runtime_leaks_sources})
6870

6971
set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags})
7072
list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS)
7173

74+
set(sdk "${SWIFT_HOST_VARIANT_SDK}")
75+
if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
76+
list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp)
77+
set(static_binary_lnk_file_list)
78+
string(TOLOWER "${sdk}" lowercase_sdk)
79+
80+
# These two libaries are only used with the static swiftcore
81+
add_library(swiftImageInspectionStatic STATIC ImageInspectionStatic.cpp)
82+
set_target_properties(swiftImageInspectionStatic PROPERTIES
83+
ARCHIVE_OUTPUT_DIRECTORY "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}")
84+
85+
add_library(swiftImageInspectionShared STATIC ImageInspectionELF.cpp)
86+
set_target_properties(swiftImageInspectionShared PROPERTIES
87+
ARCHIVE_OUTPUT_DIRECTORY "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}")
88+
89+
swift_install_in_component(stdlib
90+
TARGETS swiftImageInspectionStatic swiftImageInspectionShared
91+
DESTINATION "lib/swift_static/${lowercase_sdk}")
92+
93+
# Generate the static-executable-args.lnk file used for ELF systems (eg linux)
94+
set(linkfile "${lowercase_sdk}/static-executable-args.lnk")
95+
add_custom_command_target(swift_static_binary_${sdk}_args
96+
COMMAND
97+
"${CMAKE_COMMAND}" -E copy
98+
"${SWIFT_SOURCE_DIR}/utils/${lowercase}/static-executable-args.lnk"
99+
"${SWIFTSTATICLIB_DIR}/${linkfile}"
100+
OUTPUT
101+
"${SWIFTSTATICLIB_DIR}/${linkfile}")
102+
103+
list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args})
104+
swift_install_in_component(stdlib
105+
FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
106+
DESTINATION "lib/swift_static/${lowercase_sdk}")
107+
add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list})
108+
109+
add_swift_library(swiftImageInspectionShared OBJECT_LIBRARY TARGET_LIBRARY
110+
ImageInspectionELF.cpp
111+
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
112+
LINK_FLAGS ${swift_runtime_linker_flags}
113+
INSTALL_IN_COMPONENT never_install)
114+
endif()
115+
72116
add_swift_library(swiftRuntime OBJECT_LIBRARY TARGET_LIBRARY
73117
${swift_runtime_sources}
74118
${swift_runtime_objc_sources}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//===-- ImageInspectionStatic.cpp -------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2016 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Implementation of functions to read data sections from static executable.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#include "ImageInspection.h"
18+
#include <cstring>
19+
20+
// Currently only tested on linux but should work for any ELF platform
21+
#if defined(__ELF__) && defined(__linux__)
22+
23+
// These are defined in swift_sections.S to mark the start of a section with the
24+
// length of the data followed immediately by the section data
25+
struct alignas(uint64_t) Section;
26+
extern const Section protocolConformancesStart asm(".swift2_protocol_conformances_start");
27+
extern const Section typeMetadataStart asm(".swift2_type_metadata_start");
28+
29+
struct SectionInfo {
30+
uint64_t size;
31+
const char *data;
32+
};
33+
34+
static SectionInfo
35+
getSectionInfo(const Section *section) {
36+
SectionInfo info;
37+
memcpy(&info.size, section, sizeof(uint64_t));
38+
info.data = reinterpret_cast<const char *>(section) + sizeof(uint64_t);
39+
return info;
40+
}
41+
42+
void
43+
swift::initializeProtocolConformanceLookup() {
44+
auto protocolConformances = getSectionInfo(&protocolConformancesStart);
45+
addImageProtocolConformanceBlockCallback(protocolConformances.data,
46+
protocolConformances.size);
47+
}
48+
49+
void
50+
swift::initializeTypeMetadataRecordLookup() {
51+
auto typeMetadata = getSectionInfo(&typeMetadataStart);
52+
addImageTypeMetadataRecordBlockCallback(typeMetadata.data,
53+
typeMetadata.size);
54+
}
55+
56+
// This is called from Errors.cpp when dumping a stack trace entry.
57+
// It could be implemented by parsing the ELF information in the
58+
// executable. For now it returns 0 for error (cant lookup address).
59+
int
60+
swift::lookupSymbol(const void *address, SymbolInfo *info) {
61+
return 0;
62+
}
63+
64+
#endif

unittests/runtime/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
22
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}"))
33

4+
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
5+
set(swift_runtime_test_extra_sources
6+
"${CMAKE_CURRENT_SOURCE_DIR}/../../stdlib/public/runtime/ImageInspectionELF.cpp")
7+
endif()
8+
49
add_subdirectory(LongTests)
510

611
set(PLATFORM_SOURCES)
@@ -36,6 +41,7 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
3641
# from the swiftCore dylib, so we need to link to both the runtime archive
3742
# and the stdlib.
3843
$<TARGET_OBJECTS:swiftRuntime${SWIFT_PRIMARY_VARIANT_SUFFIX}>
44+
${swift_runtime_test_extra_sources}
3945
)
4046

4147
# FIXME: cross-compile for all variants.

unittests/runtime/LongTests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
3232
# from the swiftCore dylib, so we need to link to both the runtime archive
3333
# and the stdlib.
3434
$<TARGET_OBJECTS:swiftRuntime${SWIFT_PRIMARY_VARIANT_SUFFIX}>
35+
${swift_runtime_test_extra_sources}
3536
)
3637

3738
# FIXME: cross-compile for all variants.

0 commit comments

Comments
 (0)