Skip to content

Cherry-pick Disable check for unsafe flags. (#8896) #8914

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
Jul 17, 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
3 changes: 2 additions & 1 deletion Sources/PackageLoading/PackageBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,8 @@ extension Sequence {

extension TargetDescription {
fileprivate var usesUnsafeFlags: Bool {
settings.filter(\.kind.isUnsafeFlags).isEmpty == false
// We no longer restrict unsafe flags
false
}

fileprivate func isMacroTest(in manifest: Manifest) -> Bool {
Expand Down
22 changes: 2 additions & 20 deletions Tests/PackageGraphTests/ModulesGraphTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2127,26 +2127,8 @@ final class ModulesGraphTests: XCTestCase {
observabilityScope: observability.topScope
)

XCTAssertEqual(observability.diagnostics.count, 3)
testDiagnostics(observability.diagnostics) { result in
var expectedMetadata = ObservabilityMetadata()
expectedMetadata.moduleName = "Foo2"
let diagnostic1 = result.checkUnordered(
diagnostic: .contains("the target 'Bar2' in product 'TransitiveBar' contains unsafe build flags"),
severity: .error
)
XCTAssertEqual(diagnostic1?.metadata?.moduleName, "Foo2")
let diagnostic2 = result.checkUnordered(
diagnostic: .contains("the target 'Bar' in product 'Bar' contains unsafe build flags"),
severity: .error
)
XCTAssertEqual(diagnostic2?.metadata?.moduleName, "Foo")
let diagnostic3 = result.checkUnordered(
diagnostic: .contains("the target 'Bar2' in product 'Bar' contains unsafe build flags"),
severity: .error
)
XCTAssertEqual(diagnostic3?.metadata?.moduleName, "Foo")
}
// We have turned off the unsafe flags check
XCTAssertEqual(observability.diagnostics.count, 0)
}

func testConditionalTargetDependency() throws {
Expand Down
16 changes: 2 additions & 14 deletions Tests/WorkspaceTests/WorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5793,20 +5793,8 @@ final class WorkspaceTests: XCTestCase {

// We should only see errors about use of unsafe flag in the version-based dependency.
try await workspace.checkPackageGraph(roots: ["Foo", "Bar"]) { _, diagnostics in
testDiagnostics(diagnostics) { result in
let diagnostic1 = result.checkUnordered(
diagnostic: .equal("the target 'Baz' in product 'Baz' contains unsafe build flags"),
severity: .error
)
XCTAssertEqual(diagnostic1?.metadata?.packageIdentity, .plain("foo"))
XCTAssertEqual(diagnostic1?.metadata?.moduleName, "Foo")
let diagnostic2 = result.checkUnordered(
diagnostic: .equal("the target 'Bar' in product 'Baz' contains unsafe build flags"),
severity: .error
)
XCTAssertEqual(diagnostic2?.metadata?.packageIdentity, .plain("foo"))
XCTAssertEqual(diagnostic2?.metadata?.moduleName, "Foo")
}
// We have disabled the check so there shouldn't be any errors.
XCTAssert(diagnostics.filter({ $0.severity == .error }).isEmpty)
}
}

Expand Down