Skip to content

Commit 0b96083

Browse files
authored
Merge pull request #1379 from nkcsgexi/5.9-flag-blocklist
[5.9] cherry-pick block list configuration changes
2 parents 28b1bf8 + 6e2bd8e commit 0b96083

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

+18
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,24 @@ public struct Driver {
426426
return supportedFrontendFeatures.contains(feature.rawValue)
427427
}
428428

429+
@_spi(Testing)
430+
public static func findBlocklists(RelativeTo execDir: AbsolutePath) throws -> [AbsolutePath] {
431+
// Expect to find all blocklists in such dir:
432+
// .../XcodeDefault.xctoolchain/usr/local/lib/swift/blocklists
433+
var results: [AbsolutePath] = []
434+
let blockListDir = execDir.parentDirectory
435+
.appending(components: "local", "lib", "swift", "blocklists")
436+
if (localFileSystem.exists(blockListDir)) {
437+
try localFileSystem.getDirectoryContents(blockListDir).forEach {
438+
let currentFile = AbsolutePath(blockListDir, try VirtualPath(path: $0).relativePath!)
439+
if currentFile.extension == "yml" || currentFile.extension == "yaml" {
440+
results.append(currentFile)
441+
}
442+
}
443+
}
444+
return results
445+
}
446+
429447
/// Handler for emitting diagnostics to stderr.
430448
public static let stderrDiagnosticsHandler: DiagnosticsEngine.DiagnosticsHandler = { diagnostic in
431449
stdErrQueue.sync {

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

+7
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ extension Driver {
262262
try commandLine.appendAll(.pluginPath, .loadPluginLibrary, from: &parsedOptions)
263263
}
264264

265+
if isFrontendArgSupported(.blockListFile) {
266+
try Driver.findBlocklists(RelativeTo: try toolchain.executableDir).forEach {
267+
commandLine.appendFlag(.blockListFile)
268+
commandLine.appendPath($0)
269+
}
270+
}
271+
265272
// Pass down -user-module-version if we are working with a compiler that
266273
// supports it.
267274
if let ver = parsedOptions.getLastArgument(.userModuleVersion)?.asSingle,

Sources/SwiftOptions/Options.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extension Option {
4444
public static let BF: Option = Option("-BF", .joinedOrSeparate, attributes: [.noDriver, .argumentIsPath], helpText: "add a directory to the baseline framework search path")
4545
public static let BIEQ: Option = Option("-BI=", .joined, alias: Option.BI, attributes: [.noDriver])
4646
public static let BI: Option = Option("-BI", .joinedOrSeparate, attributes: [.noDriver, .argumentIsPath], helpText: "add a module for baseline input")
47+
public static let blockListFile: Option = Option("-blocklist-file", .separate, attributes: [.frontend, .noDriver], metaVar: "<path>", helpText: "The path to a blocklist configuration file")
4748
public static let breakageAllowlistPath: Option = Option("-breakage-allowlist-path", .joinedOrSeparate, attributes: [.noDriver, .argumentIsPath], helpText: "An allowlist of breakages to not complain about")
4849
public static let bridgingHeaderDirectoryForPrint: Option = Option("-bridging-header-directory-for-print", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<path>", helpText: "Directory for bridging header to be printed in compatibility header")
4950
public static let bsdk: Option = Option("-bsdk", .joinedOrSeparate, attributes: [.noDriver, .argumentIsPath], helpText: "path to the baseline SDK to import frameworks")
@@ -72,7 +73,7 @@ extension Option {
7273
public static let CrossModuleOptimization: Option = Option("-cross-module-optimization", .flag, attributes: [.helpHidden, .frontend], helpText: "Perform cross-module optimization")
7374
public static let crosscheckUnqualifiedLookup: Option = Option("-crosscheck-unqualified-lookup", .flag, attributes: [.frontend, .noDriver], helpText: "Compare legacy DeclContext- to ASTScope-based unqualified name lookup (for debugging)")
7475
public static let cxxInteropGettersSettersAsProperties: Option = Option("-cxx-interop-getters-setters-as-properties", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Import getters and setters as computed properties in Swift")
75-
public static let cxxInteroperabilityMode: Option = Option("-cxx-interoperability-mode=", .joined, attributes: [.frontend, .moduleInterface], helpText: "Enables C++ interoperability; requires compatbility version to be specified.")
76+
public static let cxxInteroperabilityMode: Option = Option("-cxx-interoperability-mode=", .joined, attributes: [.frontend, .moduleInterface], helpText: "Enables C++ interoperability; pass 'default' to enable or 'off' to disable")
7677
public static let c: Option = Option("-c", .flag, alias: Option.emitObject, attributes: [.frontend, .noInteractive], group: .modes)
7778
public static let debugAssertAfterParse: Option = Option("-debug-assert-after-parse", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Force an assertion failure after parsing", group: .debugCrash)
7879
public static let debugAssertImmediately: Option = Option("-debug-assert-immediately", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Force an assertion failure immediately", group: .debugCrash)
@@ -136,6 +137,7 @@ extension Option {
136137
public static let disableConformanceAvailabilityErrors: Option = Option("-disable-conformance-availability-errors", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnose conformance availability violations as warnings")
137138
public static let disableConstraintSolverPerformanceHacks: Option = Option("-disable-constraint-solver-performance-hacks", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable all the hacks in the constraint solver")
138139
public static let disableCrossImportOverlays: Option = Option("-disable-cross-import-overlays", .flag, attributes: [.frontend, .noDriver], helpText: "Do not automatically import declared cross-import overlays.")
140+
public static let cxxInteropDisableRequirementAtImport: Option = Option("-disable-cxx-interop-requirement-at-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Do not require C++ interoperability to be enabled when importing a Swift module that enables C++ interoperability")
139141
public static let disableDebuggerShadowCopies: Option = Option("-disable-debugger-shadow-copies", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable debugger shadow copies of local variables.This option is only useful for testing the compiler.")
140142
public static let disableDeserializationRecovery: Option = Option("-disable-deserialization-recovery", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't attempt to recover from missing xrefs (etc) in swiftmodules")
141143
public static let disableDeserializationSafety: Option = Option("-disable-deserialization-safety", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Don't avoid reading potentially unsafe decls in swiftmodules")
@@ -384,6 +386,8 @@ extension Option {
384386
public static let enableOperatorDesignatedTypes: Option = Option("-enable-operator-designated-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable operator designated types")
385387
public static let enableOssaCompleteLifetimes: Option = Option("-enable-ossa-complete-lifetimes", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Require linear OSSA lifetimes after SILGen")
386388
public static let enableOssaModules: Option = Option("-enable-ossa-modules", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Always serialize SIL in ossa form. If this flag is not passed in, when optimizing ownership will be lowered before serializing SIL")
389+
public static let enablePackMetadataStackPromotion: Option = Option("-enable-pack-metadata-stack-promotion=", .joined, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "true|false", helpText: "Whether to skip heapifying stack metadata packs when possible.")
390+
public static let enablePackMetadataStackPromotionNoArg: Option = Option("-enable-pack-metadata-stack-promotion", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Skip heapifying stack metadata packs when possible.")
387391
public static let enablePrivateImports: Option = Option("-enable-private-imports", .flag, attributes: [.helpHidden, .frontend, .noInteractive], helpText: "Allows this module's internal and private API to be accessed")
388392
public static let enableRelativeProtocolWitnessTables: Option = Option("-enable-relative-protocol-witness-tables", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable relative protocol witness tables")
389393
public static let enableRemoveDeprecatedCheck: Option = Option("-enable-remove-deprecated-check", .flag, attributes: [.noDriver], helpText: "Diagnosing removal of deprecated symbols")
@@ -812,6 +816,7 @@ extension Option {
812816
Option.BF,
813817
Option.BIEQ,
814818
Option.BI,
819+
Option.blockListFile,
815820
Option.breakageAllowlistPath,
816821
Option.bridgingHeaderDirectoryForPrint,
817822
Option.bsdk,
@@ -904,6 +909,7 @@ extension Option {
904909
Option.disableConformanceAvailabilityErrors,
905910
Option.disableConstraintSolverPerformanceHacks,
906911
Option.disableCrossImportOverlays,
912+
Option.cxxInteropDisableRequirementAtImport,
907913
Option.disableDebuggerShadowCopies,
908914
Option.disableDeserializationRecovery,
909915
Option.disableDeserializationSafety,
@@ -1152,6 +1158,8 @@ extension Option {
11521158
Option.enableOperatorDesignatedTypes,
11531159
Option.enableOssaCompleteLifetimes,
11541160
Option.enableOssaModules,
1161+
Option.enablePackMetadataStackPromotion,
1162+
Option.enablePackMetadataStackPromotionNoArg,
11551163
Option.enablePrivateImports,
11561164
Option.enableRelativeProtocolWitnessTables,
11571165
Option.enableRemoveDeprecatedCheck,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

Tests/SwiftDriverTests/SwiftDriverTests.swift

+7
Original file line numberDiff line numberDiff line change
@@ -6940,6 +6940,13 @@ final class SwiftDriverTests: XCTestCase {
69406940
#endif
69416941
}
69426942

6943+
func testFindingBlockLists() throws {
6944+
let execDir = testInputsPath.appending(components: "Dummy.xctoolchain", "usr", "bin")
6945+
let list = try Driver.findBlocklists(RelativeTo: execDir)
6946+
XCTAssertEqual(list.count, 2)
6947+
XCTAssertTrue(list.allSatisfy { $0.extension! == "yml" || $0.extension! == "yaml"})
6948+
}
6949+
69436950
func testToolSearching() throws {
69446951
#if os(Windows)
69456952
let PATH = "Path"

0 commit comments

Comments
 (0)