Skip to content

Commit dbeff97

Browse files
authored
Merge pull request #63562 from xymus/disable-deserialization-safety
[Serialization] Move deserialization safety behind an env var or flag
2 parents 5033a73 + 62a6469 commit dbeff97

File tree

6 files changed

+29
-6
lines changed

6 files changed

+29
-6
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ namespace swift {
366366

367367
/// Enable early skipping deserialization of decls that are marked as
368368
/// unsafe to read.
369-
bool EnableDeserializationSafety = true;
369+
bool EnableDeserializationSafety =
370+
::getenv("SWIFT_ENABLE_DESERIALIZATION_SAFETY");
370371

371372
/// Whether to enable the new operator decl and precedencegroup lookup
372373
/// behavior. This is a staging flag, and will be removed in the future.

test/Serialization/Safety/override-internal-func.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
// RUN: -emit-module-interface-path %t/Lib.swiftinterface
1111

1212
/// Build against the swiftmodule.
13-
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t
13+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
14+
// RUN: -enable-deserialization-safety
1415

1516
/// Build against the swiftinterface.
1617
// RUN: rm %t/Lib.swiftmodule
17-
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t
18+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
19+
// RUN: -enable-deserialization-safety
1820

1921
//--- Lib.swift
2022

test/Serialization/Safety/skip-reading-internal-anyobject.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
/// Build client.
1313
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
14-
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \
14+
// RUN: -verify -Xllvm -debug-only=Serialization \
15+
// RUN: -enable-deserialization-safety 2>&1 \
1516
// RUN: | %FileCheck --check-prefixes=SAFE %s
1617

1718
/// Decls skips by the deserialization safety logic.

test/Serialization/Safety/skip-reading-internal-details.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@
1919
// RUN: | %FileCheck --check-prefixes=NEEDED,UNSAFE %s
2020

2121
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
22+
// RUN: -verify -Xllvm -debug-only=Serialization \
23+
// RUN: -enable-deserialization-safety 2>&1 \
24+
// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN,SAFE %s
25+
26+
/// Disabled by default.
27+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
28+
// RUN: -verify -Xllvm -debug-only=Serialization \
29+
// RUN: -disable-deserialization-safety 2>&1 \
30+
// RUN: | %FileCheck --check-prefixes=NEEDED,UNSAFE %s
31+
32+
/// Enable with env var.
33+
// RUN: env SWIFT_ENABLE_DESERIALIZATION_SAFETY=true \
34+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
2235
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \
2336
// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN,SAFE %s
2437

test/Serialization/Safety/unsafe-decls.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@
44

55
// RUN: %target-swift-frontend -emit-module %s \
66
// RUN: -enable-library-evolution -swift-version 5 \
7+
// RUN: -enable-deserialization-safety \
78
// RUN: -Xllvm -debug-only=Serialization 2>&1 | %swift-demangle --simplified \
89
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,SAFETY-INTERNAL %s
910

1011
// RUN: %target-swift-frontend -emit-module %s \
1112
// RUN: -enable-library-evolution -swift-version 5 \
13+
// RUN: -enable-deserialization-safety \
1214
// RUN: -Xllvm -debug-only=Serialization \
1315
// RUN: -enable-testing 2>&1 \
1416
// RUN: | %FileCheck --check-prefixes=DISABLED %s
1517

1618
/// Don't mark decls as unsafe when private import is enabled.
1719
// RUN: %target-swift-frontend -emit-module %s \
1820
// RUN: -enable-library-evolution -swift-version 5 \
21+
// RUN: -enable-deserialization-safety \
1922
// RUN: -Xllvm -debug-only=Serialization \
2023
// RUN: -enable-private-imports 2>&1 \
2124
// RUN: | %FileCheck --check-prefixes=DISABLED %s
2225

2326
/// Don't mark decls as unsafe without library evolution.
2427
// RUN: %target-swift-frontend -emit-module %s \
25-
// RUN: -swift-version 5 \
28+
// RUN: -enable-deserialization-safety -swift-version 5 \
2629
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
2730
// RUN: | %FileCheck --check-prefixes=DISABLED %s
2831

test/Serialization/Safety/unsafe-extensions.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@
44

55
// RUN: %target-swift-frontend -emit-module %s \
66
// RUN: -enable-library-evolution -swift-version 5 \
7+
// RUN: -enable-deserialization-safety \
78
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
89
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,SAFETY-INTERNAL %s
910

1011
// RUN: %target-swift-frontend -emit-module %s \
1112
// RUN: -enable-library-evolution -swift-version 5 \
13+
// RUN: -enable-deserialization-safety \
1214
// RUN: -Xllvm -debug-only=Serialization \
1315
// RUN: -enable-testing 2>&1 \
1416
// RUN: | %FileCheck --check-prefixes=DISABLED %s
1517

1618
/// Don't mark decls as unsafe when private import is enabled.
1719
// RUN: %target-swift-frontend -emit-module %s \
1820
// RUN: -enable-library-evolution -swift-version 5 \
21+
// RUN: -enable-deserialization-safety \
1922
// RUN: -Xllvm -debug-only=Serialization \
2023
// RUN: -enable-private-imports 2>&1 \
2124
// RUN: | %FileCheck --check-prefixes=DISABLED %s
2225

2326
/// Don't mark decls as unsafe without library evolution.
2427
// RUN: %target-swift-frontend -emit-module %s \
25-
// RUN: -swift-version 5 \
28+
// RUN: -enable-deserialization-safety -swift-version 5 \
2629
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
2730
// RUN: | %FileCheck --check-prefixes=DISABLED %s
2831

0 commit comments

Comments
 (0)