Skip to content

Commit 1f363be

Browse files
authored
Merge pull request #69403 from kubamracek/embedded-require-swiftsources
[embedded] Require SwiftCompilerSources to use embedded Swift
2 parents 5561f1a + f1aba67 commit 1f363be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+70
-5
lines changed

include/swift/SIL/SILBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class SwiftPassInvocation;
6060
class GenericSpecializationInformation;
6161
}
6262

63+
bool swiftModulesInitialized();
6364
void registerBridgedClass(BridgedStringRef className, SwiftMetatype metatype);
6465

6566
struct BridgedType {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/Option/Options.h"
2121
#include "swift/Option/SanitizerOptions.h"
2222
#include "swift/Parse/ParseVersion.h"
23+
#include "swift/SIL/SILBridging.h"
2324
#include "swift/Strings.h"
2425
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
2526
#include "llvm/ADT/STLExtras.h"
@@ -521,12 +522,12 @@ static void diagnoseCxxInteropCompatMode(Arg *verArg, ArgList &Args,
521522
diags.diagnose(SourceLoc(), diag::valid_cxx_interop_modes, versStr);
522523
}
523524

524-
static llvm::Optional<StrictConcurrency>
525+
static llvm::Optional<swift::StrictConcurrency>
525526
parseStrictConcurrency(StringRef value) {
526-
return llvm::StringSwitch<llvm::Optional<StrictConcurrency>>(value)
527-
.Case("minimal", StrictConcurrency::Minimal)
528-
.Case("targeted", StrictConcurrency::Targeted)
529-
.Case("complete", StrictConcurrency::Complete)
527+
return llvm::StringSwitch<llvm::Optional<swift::StrictConcurrency>>(value)
528+
.Case("minimal", swift::StrictConcurrency::Minimal)
529+
.Case("targeted", swift::StrictConcurrency::Targeted)
530+
.Case("complete", swift::StrictConcurrency::Complete)
530531
.Default(llvm::None);
531532
}
532533

@@ -1334,6 +1335,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13341335
Opts.BypassResilienceChecks |= Args.hasArg(OPT_bypass_resilience);
13351336

13361337
if (Opts.hasFeature(Feature::Embedded)) {
1338+
assert(swiftModulesInitialized() && "no SwiftCompilerSources");
1339+
13371340
Opts.UnavailableDeclOptimizationMode = UnavailableDeclOptimization::Complete;
13381341
Opts.DisableImplicitStringProcessingModuleImport = true;
13391342
Opts.DisableImplicitConcurrencyModuleImport = true;

lib/SIL/Utils/SILBridging.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ SwiftMetatype nodeMetatypes[(unsigned)SILNodeKind::Last_SILNode + 1];
4040

4141
}
4242

43+
bool swiftModulesInitialized() {
44+
return nodeMetatypesInitialized;
45+
}
46+
4347
// Does return null if initializeSwiftModules() is never called.
4448
SwiftMetatype SILNode::getSILNodeMetatype(SILNodeKind kind) {
4549
SwiftMetatype metatype = nodeMetatypes[(unsigned)kind];

test/embedded/anyobject-error-no-stdlib.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %target-swift-emit-ir -parse-stdlib %s -enable-experimental-feature Embedded -verify -wmo
22

3+
// REQUIRES: swift_in_compiler
4+
35
public enum Never {}
46

57
@_silgen_name("abort")

test/embedded/array-builtins-exec.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: %target-clang %t/main.o -o %t/a.out -dead_strip
44
// RUN: %target-run %t/a.out | %FileCheck %s
55

6+
// REQUIRES: swift_in_compiler
67
// REQUIRES: executable_test
78
// REQUIRES: optimized_stdlib
89
// REQUIRES: VENDOR=apple

test/embedded/array-to-pointer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-clang %t/main.o %t/print.o -o %t/a.out -dead_strip
55
// RUN: %target-run %t/a.out | %FileCheck %s
66

7+
// REQUIRES: swift_in_compiler
78
// REQUIRES: executable_test
89
// REQUIRES: optimized_stdlib
910
// REQUIRES: VENDOR=apple

test/embedded/array-zero-size-struct.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
22

3+
// REQUIRES: swift_in_compiler
34
// REQUIRES: optimized_stdlib
45
// REQUIRES: VENDOR=apple
56
// REQUIRES: OS=macosx

test/embedded/arrays.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-clang %t/main.o %t/print.o -o %t/a.out -dead_strip
55
// RUN: %target-run %t/a.out | %FileCheck %s
66

7+
// REQUIRES: swift_in_compiler
78
// REQUIRES: executable_test
89
// REQUIRES: optimized_stdlib
910
// REQUIRES: VENDOR=apple

test/embedded/availability-code-removal.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// RUN: %target-swift-frontend -emit-ir %s -parse-stdlib -wmo | %FileCheck %s --check-prefix CHECK-A
1111
// RUN: %target-swift-frontend -emit-ir %s -parse-stdlib -enable-experimental-feature Embedded -wmo | %FileCheck %s --check-prefix CHECK-B
1212

13+
// REQUIRES: swift_in_compiler
14+
1315
public protocol Player {}
1416
struct Concrete: Player {}
1517

test/embedded/availability.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// Building with embedded Swift should produce unavailability errors
55
// RUN: %target-typecheck-verify-swift -parse-stdlib -enable-experimental-feature Embedded -wmo
66

7+
// REQUIRES: swift_in_compiler
8+
79
@_unavailableInEmbedded
810
public func embedded() { }
911
public func regular() {

0 commit comments

Comments
 (0)