Skip to content

Turn on the inclusive language soundness check #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ jobs:
with:
license_header_check_project_name: "Swift"
api_breakage_check_enabled: false
unacceptable_language_check_enabled: false
format_check_enabled: false
2 changes: 1 addition & 1 deletion Plugins/cmake-smoke-test/cmake-smoke-test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ extension Process {
Diagnostics.progress("Using process spawning workaround")
// Linux workaround for https://github.com/swiftlang/swift-corelibs-foundation/issues/4772
// Foundation.Process on Linux seems to inherit the Process.run()-calling thread's signal mask, creating processes that even have SIGTERM blocked
// This manifests as CMake hanging when invoking 'uname' with incorrectly configured signal handlers.
// This manifests as CMake getting stuck when invoking 'uname' with incorrectly configured signal handlers.
var fileActions = posix_spawn_file_actions_t()
defer { posix_spawn_file_actions_destroy(&fileActions) }
var attrs: posix_spawnattr_t = posix_spawnattr_t()
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBCore/Settings/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5066,7 +5066,7 @@ private class SettingsBuilder {
return []
}

// For performance, we're only going to check the Resources build phase because that's where xcstrings are expected to hang out.
// For performance, we're only going to check the Resources build phase because that's where xcstrings are expected to be.
let buildFiles = standardTarget.resourcesBuildPhase?.buildFiles ?? []

let resolver = FilePathResolver(scope: scope)
Expand Down
45 changes: 22 additions & 23 deletions Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,6 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi

// Compute the inputs and object output dependency paths.
// Note that we compute the object file output paths here even if the compilation mode won't produce any, because these paths are used to compute the paths to other generated files.
// FIXME: If we want to match what Xcode did, then when using non-parallel WMO, we should include $(TARGET_NAME)-master.o as an output file, but not include the per-input-file object files as output files.
let outputObjectExtension: String
switch cbc.scope.evaluate(BuiltinMacros.SWIFT_LTO) {
case .yes, .yesThin:
Expand Down Expand Up @@ -2161,11 +2160,11 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi

// Add const metadata outputs to extra compilation outputs
if await supportConstSupplementaryMetadata(cbc, delegate, compilationMode: compilationMode) {
// If using whole module optimization then we use the -master.swiftconstvalues file from the sole compilation task.
// If using whole module optimization then we use the -primary.swiftconstvalues file from the sole compilation task.
if isUsingWholeModuleOptimization {
if let outputPath = objectOutputPaths.first {
let masterSwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + compilationMode.moduleBaseNameSuffix + "-master"
let supplementaryConstMetadataOutputPath = outputPath.dirname.join(masterSwiftBaseName + ".swiftconstvalues")
let primarySwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + compilationMode.moduleBaseNameSuffix + "-primary"
let supplementaryConstMetadataOutputPath = outputPath.dirname.join(primarySwiftBaseName + ".swiftconstvalues")
extraOutputPaths.append(supplementaryConstMetadataOutputPath)
delegate.declareGeneratedSwiftConstMetadataFile(supplementaryConstMetadataOutputPath, architecture: arch)
}
Expand Down Expand Up @@ -2232,11 +2231,11 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
//
// FIXME: Can we simplify this to not require the full macro scope?
//
// If using whole module optimization then we use the -master.d file as the dependency file.
// If using whole module optimization then we use the -primary.d file as the dependency file.
if let outputPath = objectOutputPaths.first {
if Self.shouldUseWholeModuleOptimization(for: cbc.scope).result {
let masterSwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + compilationMode.moduleBaseNameSuffix + "-master"
let dependenciesFilePath = outputPath.dirname.join(masterSwiftBaseName + ".d")
let primarySwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + compilationMode.moduleBaseNameSuffix + "-primary"
let dependenciesFilePath = outputPath.dirname.join(primarySwiftBaseName + ".d")
return dependenciesFilePath
} else {
// if not using WMO, we use the first .d file as all are the same
Expand Down Expand Up @@ -2348,8 +2347,8 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
let dependencyData: DependencyDataStyle?
if await shouldEmitMakeStyleDependencies(cbc.producer, cbc.scope, delegate: delegate) {
// FIXME: Duplication with `SwiftCompilerSpec.computeOutputFileMapContents`
let masterSwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + compilationMode.moduleBaseNameSuffix + "-master"
let emitModuleDependenciesFilePath = objectFileDir.join(masterSwiftBaseName + "-emit-module.d")
let primarySwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + compilationMode.moduleBaseNameSuffix + "-primary"
let emitModuleDependenciesFilePath = objectFileDir.join(primarySwiftBaseName + "-emit-module.d")
dependencyData = eagerCompilationEnabled ? .makefileIgnoringSubsequentOutputs(emitModuleDependenciesFilePath) : dependencyInfoPath.map(DependencyDataStyle.makefileIgnoringSubsequentOutputs)
} else {
dependencyData = nil
Expand Down Expand Up @@ -2755,7 +2754,7 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
moduleDirPath = scope.evaluate(BuiltinMacros.BUILT_PRODUCTS_DIR).join(moduleName + ".swiftmodule")
}
if isProject {
// Copy this content to the Project subdir so we could master them out when installing.
// Copy this content to the Project subdir so we can exclude them by filename pattern when installing.
return moduleDirPath.join("Project")
}
return moduleDirPath
Expand Down Expand Up @@ -3047,7 +3046,7 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi

// Compute strings that will be used at various points when building the map.
let moduleBaseNameSuffix = compilationMode.moduleBaseNameSuffix
let masterSwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + moduleBaseNameSuffix + "-master"
let primarySwiftBaseName = cbc.scope.evaluate(BuiltinMacros.TARGET_NAME) + moduleBaseNameSuffix + "-primary"
let emitConstSideCarValues = await supportConstSupplementaryMetadata(cbc, delegate, compilationMode: compilationMode)

func createCommonFileEntry(input: FileToBuild) -> (objectFilePath: Path, fileMapEntry: SwiftOutputFileMap.Entry) {
Expand Down Expand Up @@ -3110,25 +3109,25 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
var fileMapEntry = SwiftOutputFileMap.Entry()

// The file used by Swift to manage intermodule dependencies.
let globalSwiftDependenciesFilePath = objectFileDir.join(masterSwiftBaseName + ".swiftdeps")
let globalSwiftDependenciesFilePath = objectFileDir.join(primarySwiftBaseName + ".swiftdeps")
fileMapEntry.swiftDependencies = globalSwiftDependenciesFilePath.str

// The diagnostics file.
let diagnosticsFilePath = objectFileDir.join(masterSwiftBaseName + ".dia")
let diagnosticsFilePath = objectFileDir.join(primarySwiftBaseName + ".dia")
fileMapEntry.diagnostics = diagnosticsFilePath.str

// The diagnostics file for emit-module jobs.
let emitModuleDiagnosticsFilePath = objectFileDir.join(masterSwiftBaseName + "-emit-module.dia")
let emitModuleDiagnosticsFilePath = objectFileDir.join(primarySwiftBaseName + "-emit-module.dia")
fileMapEntry.emitModuleDiagnostics = emitModuleDiagnosticsFilePath.str

if await shouldEmitMakeStyleDependencies(cbc.producer, cbc.scope, delegate: delegate) {
// The dependency file for emit-module jobs.
let emitModuleDependenciesFilePath = objectFileDir.join(masterSwiftBaseName + "-emit-module.d")
let emitModuleDependenciesFilePath = objectFileDir.join(primarySwiftBaseName + "-emit-module.d")
fileMapEntry.emitModuleDependencies = emitModuleDependenciesFilePath.str
}

// The PCH file path for generatePCH job.
let bridgingHeaderPCHPath = objectFileDir.join(masterSwiftBaseName + "-Bridging-header.pch")
let bridgingHeaderPCHPath = objectFileDir.join(primarySwiftBaseName + "-Bridging-header.pch")
fileMapEntry.pch = bridgingHeaderPCHPath.str

// Add the global entry to the map.
Expand All @@ -3146,35 +3145,35 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
var fileMapEntry = SwiftOutputFileMap.Entry()

// The diagnostics file.
let diagnosticsFilePath = objectFileDir.join(masterSwiftBaseName + ".dia")
let diagnosticsFilePath = objectFileDir.join(primarySwiftBaseName + ".dia")
fileMapEntry.diagnostics = diagnosticsFilePath.str

// The diagnostics file for emit-module jobs.
let emitModuleDiagnosticsFilePath = objectFileDir.join(masterSwiftBaseName + "-emit-module.dia")
let emitModuleDiagnosticsFilePath = objectFileDir.join(primarySwiftBaseName + "-emit-module.dia")
fileMapEntry.emitModuleDiagnostics = emitModuleDiagnosticsFilePath.str

if await shouldEmitMakeStyleDependencies(cbc.producer, cbc.scope, delegate: delegate) {
// The dependency file for emit-module jobs.
let emitModuleDependenciesFilePath = objectFileDir.join(masterSwiftBaseName + "-emit-module.d")
let emitModuleDependenciesFilePath = objectFileDir.join(primarySwiftBaseName + "-emit-module.d")
fileMapEntry.emitModuleDependencies = emitModuleDependenciesFilePath.str


// The dependencies file, used to discover implicit dependencies. This file will be in Makefile format.
let dependenciesFilePath = objectFileDir.join(masterSwiftBaseName + ".d")
let dependenciesFilePath = objectFileDir.join(primarySwiftBaseName + ".d")
fileMapEntry.dependencies = dependenciesFilePath.str
}

// The file used by Swift to manage intermodule dependencies.
let swiftDependenciesFilePath = objectFileDir.join(masterSwiftBaseName + ".swiftdeps")
let swiftDependenciesFilePath = objectFileDir.join(primarySwiftBaseName + ".swiftdeps")
fileMapEntry.swiftDependencies = swiftDependenciesFilePath.str

// The requested compile-time values
if emitConstSideCarValues && compilationMode.compileSources {
fileMapEntry.constValues = objectFileDir.join(masterSwiftBaseName + ".swiftconstvalues").str
fileMapEntry.constValues = objectFileDir.join(primarySwiftBaseName + ".swiftconstvalues").str
}

// The PCH file path for generatePCH job.
let bridgingHeaderPCHPath = objectFileDir.join(masterSwiftBaseName + "-Bridging-header.pch")
let bridgingHeaderPCHPath = objectFileDir.join(primarySwiftBaseName + "-Bridging-header.pch")
fileMapEntry.pch = bridgingHeaderPCHPath.str

// Add the global entry to the map.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBUtil/Debugger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public enum Debugger: Sendable {
if isXcodeAutoAttachEnabled {
try await waitForAttachment() {
// Exit if parent process died while waiting for debugger
if kill(getppid(), 0) != 0 {
if kill(getppid(), 0) != 0 { // ignore-unacceptable-language; POSIX API
throw StubError.error("Parent process exited while waiting for debugger")
}
return true
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBUtil/PbxCp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public func pbxcp(_ argv: [String], cwd: Path) async -> (success: Bool, output:
}
}

// Do some sanity-checking.
// Do some correctness-checking.
if srcPath.isRoot {
outStream <<< "error: Invalid source path: '\(srcPath.str)'\n"
return (false, outStream.bytes.asString)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftBuild/SWBBuildServiceConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ fileprivate final class OutOfProcessConnection: ConnectionTransport {
// If IBAutoAttach is enabled, send the message so Xcode will attach to the inferior.
try Debugger.requestXcodeAutoAttachIfEnabled(task.processIdentifier)
} catch {
// Terminate the subprocess if start() is going to throw, so that close() will not hang
// Terminate the subprocess if start() is going to throw, so that close() will not get stuck.
task.terminate()
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftBuild/SWBBuildServiceSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ extension SWBBuildServiceSession {
throw StubError.error("Unexpected message: \(msgOpt.map(String.init(describing:)) ?? "<nil>")")
}

// NOTE: If any GetProvisioningTaskInputsRequest/ExternalToolExecutionRequest messages are received, cancellation may result in them never receiving a reply, which could result in background operations hanging. We should find a way to handle that better.
// NOTE: If any GetProvisioningTaskInputsRequest/ExternalToolExecutionRequest messages are received, cancellation may result in them never receiving a reply, which could result in background operations getting stuck. We should find a way to handle that better.

// nil indicates Task cancellation (we broke out of the loop)
return nil
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWBBuildSystemTests/BuildTaskBehaviorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ fileprivate struct BuildTaskBehaviorTests: CoreBasedTests {
try await withTaskCancellationHandler {
switch await operation.build() {
case .cancelled, .failed:
// If the build already failed, cancel the task that waits for the script so the test doesn't hang forever.
// If the build already failed, cancel the task that waits for the script so the test doesn't get stuck forever.
task.cancel()
case .succeeded:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,21 +627,21 @@ fileprivate struct CodeSignTaskConstructionTests: CoreBasedTests {
}

// Check that flags without a dedicated build setting are passed through as expected.
await tester.checkBuild(BuildParameters(action: .install, configuration: "Release", overrides: ["ENABLE_LIBRARY_VALIDATION": "YES", "ENABLE_HARDENED_RUNTIME": "YES", "CODE_SIGN_RESTRICT": "YES", "OTHER_CODE_SIGN_FLAGS": "--options kill,hard,host,expires,linker-signed"]), runDestination: .macOS) { results in
await tester.checkBuild(BuildParameters(action: .install, configuration: "Release", overrides: ["ENABLE_LIBRARY_VALIDATION": "YES", "ENABLE_HARDENED_RUNTIME": "YES", "CODE_SIGN_RESTRICT": "YES", "OTHER_CODE_SIGN_FLAGS": "--options kill,hard,host,expires,linker-signed"]), runDestination: .macOS) { results in // ignore-unacceptable-language; codesign tool option
results.checkTarget("macOSFramework") { target in
results.checkTask(.matchTarget(target), .matchRuleType("CodeSign")) { task in
task.checkCommandLineMatches(["/usr/bin/codesign", "--force", "--sign", "-", "--options", "expires,hard,host,kill,library,linker-signed,restrict,runtime", "--entitlements", .suffix("macOSFramework.framework.xcent"), "--generate-entitlement-der", "/tmp/aProject.dst/Library/Frameworks/macOSFramework.framework/Versions/A"])
task.checkCommandLineMatches(["/usr/bin/codesign", "--force", "--sign", "-", "--options", "expires,hard,host,kill,library,linker-signed,restrict,runtime", "--entitlements", .suffix("macOSFramework.framework.xcent"), "--generate-entitlement-der", "/tmp/aProject.dst/Library/Frameworks/macOSFramework.framework/Versions/A"]) // ignore-unacceptable-language; codesign tool option
}
}

results.checkNoDiagnostics()
}

// Check that flags without a dedicated build setting are passed through as expected, in conjunction with DISABLE_FREEFORM_CODE_SIGN_OPTION_FLAGS removing disabled, known ones.
await tester.checkBuild(BuildParameters(action: .install, configuration: "Release", overrides: ["ENABLE_LIBRARY_VALIDATION": "NO", "ENABLE_HARDENED_RUNTIME": "NO", "CODE_SIGN_RESTRICT": "YES", "OTHER_CODE_SIGN_FLAGS": "--options kill,hard,host,expires,linker-signed"]), runDestination: .macOS) { results in
await tester.checkBuild(BuildParameters(action: .install, configuration: "Release", overrides: ["ENABLE_LIBRARY_VALIDATION": "NO", "ENABLE_HARDENED_RUNTIME": "NO", "CODE_SIGN_RESTRICT": "YES", "OTHER_CODE_SIGN_FLAGS": "--options kill,hard,host,expires,linker-signed"]), runDestination: .macOS) { results in // ignore-unacceptable-language; codesign tool option
results.checkTarget("macOSFramework") { target in
results.checkTask(.matchTarget(target), .matchRuleType("CodeSign")) { task in
task.checkCommandLineMatches(["/usr/bin/codesign", "--force", "--sign", "-", "--options", "expires,hard,host,kill,linker-signed,restrict", "--entitlements", .suffix("macOSFramework.framework.xcent"), "--generate-entitlement-der", "/tmp/aProject.dst/Library/Frameworks/macOSFramework.framework/Versions/A"])
task.checkCommandLineMatches(["/usr/bin/codesign", "--force", "--sign", "-", "--options", "expires,hard,host,kill,linker-signed,restrict", "--entitlements", .suffix("macOSFramework.framework.xcent"), "--generate-entitlement-der", "/tmp/aProject.dst/Library/Frameworks/macOSFramework.framework/Versions/A"]) // ignore-unacceptable-language; codesign tool option
}
}

Expand Down
Loading
Loading