Skip to content

Commit 2f920c4

Browse files
committed
Add a new frontend option -sil-serialize-witness-tables to force serialization of SIL witness tables
This option is supposed to be used only for compiling overlays. User code should never be compiled with this option.
1 parent 1dea34b commit 2f920c4

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

include/swift/AST/SILOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ class SILOptions {
150150
/// \see ResilienceStrategy::Fragile
151151
bool SILSerializeAll = false;
152152

153+
/// If set, SIL witness tables will be serialized.
154+
///
155+
/// It is supposed to be used only for compiling overlays.
156+
/// User code should never be compiled with this flag set.
157+
bool SILSerializeWitnessTables = false;
158+
153159
SILOptions() : Sanitize(SanitizerKind::None) {}
154160

155161
/// Return a hash code of any components from these options that should

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ def sil_link_all : Flag<["-"], "sil-link-all">,
366366
def sil_serialize_all : Flag<["-"], "sil-serialize-all">,
367367
HelpText<"Serialize all generated SIL">;
368368

369+
def sil_serialize_witness_tables : Flag<["-"], "sil-serialize-witness-tables">,
370+
HelpText<"Serialize eligible SIL witness tables">;
371+
369372
def sil_verify_all : Flag<["-"], "sil-verify-all">,
370373
HelpText<"Verify SIL after each transform">;
371374

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
13291329
Opts.MergePartialModules = true;
13301330

13311331
Opts.SILSerializeAll |= Args.hasArg(OPT_sil_serialize_all);
1332+
Opts.SILSerializeWitnessTables |=
1333+
Args.hasArg(OPT_sil_serialize_witness_tables);
1334+
13321335
// Parse the optimization level.
13331336
if (const Arg *A = Args.getLastArg(OPT_O_Group)) {
13341337
if (A->getOption().matches(OPT_Onone)) {

stdlib/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ add_custom_target(swift-test-stdlib ALL
9393

9494
if(SWIFT_STDLIB_ENABLE_RESILIENCE)
9595
set(STDLIB_SIL_SERIALIZE_ALL)
96+
set(STDLIB_SIL_SERIALIZE_WITNESS_TABLES)
9697
else()
9798
if(SWIFT_STDLIB_SIL_SERIALIZE_ALL)
9899
set(STDLIB_SIL_SERIALIZE_ALL "-Xfrontend" "-sil-serialize-all")
100+
set(STDLIB_SIL_SERIALIZE_WITNESS_TABLES "-Xfrontend" "-sil-serialize-witness-tables")
99101
else()
100102
set(STDLIB_SIL_SERIALIZE_ALL)
103+
set(STDLIB_SIL_SERIALIZE_WITNESS_TABLES)
101104
endif()
102105
endif()
103106

stdlib/public/SDK/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ if(SWIFT_BUILD_STATIC_SDK_OVERLAY)
88
list(APPEND SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES STATIC)
99
endif()
1010

11+
list(APPEND SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS "${STDLIB_SIL_SERIALIZE_WITNESS_TABLES}")
12+
1113
set(all_overlays "Accelerate;AppKit;ARKit;AssetsLibrary;AVFoundation;CallKit;CloudKit;Contacts;CoreAudio;CoreData;CoreFoundation;CoreGraphics;CoreImage;CoreLocation;CoreMedia;CryptoTokenKit;Dispatch;Foundation;GameplayKit;GLKit;HomeKit;IOKit;Intents;MapKit;ObjectiveC;OpenCL;os;Photos;QuartzCore;SafariServices;SceneKit;simd;SpriteKit;UIKit;WatchKit;XCTest;XPC")
1214

1315
if(DEFINED SWIFT_OVERLAY_TARGETS)

0 commit comments

Comments
 (0)