Skip to content

Commit f7b42ad

Browse files
committed
Address PR feedback
1 parent ca34514 commit f7b42ad

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

Sources/Build/BuildDescription/ProductBuildDescription.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
148148
}
149149

150150
/// The arguments to link and create this product.
151-
public func linkArguments(outputPathSuffix: String = "") throws -> [String] {
151+
public func linkArguments() throws -> [String] {
152152
var args = [buildParameters.toolchain.swiftCompilerPath.pathString]
153153
args += self.buildParameters.sanitizers.linkSwiftFlags()
154154
args += self.additionalFlags
@@ -164,7 +164,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
164164
}
165165

166166
args += ["-L", self.buildParameters.buildPath.pathString]
167-
args += try ["-o", binaryPath.pathString + outputPathSuffix]
167+
args += try ["-o", binaryPath.pathString]
168168
args += ["-module-name", self.product.name.spm_mangledToC99ExtendedIdentifier()]
169169
args += self.dylibs.map { "-l" + $0.product.name }
170170

Sources/Build/BuildManifest/LLBuildManifestBuilder+Product.swift

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ extension LLBuildManifestBuilder {
3737
let targetName = try buildProduct.product.getLLBuildTargetName(config: self.buildConfig)
3838
let output: Node = .virtual(targetName)
3939

40+
let finalProductNode: Node
4041
switch buildProduct.product.type {
4142
case .library(.static):
43+
finalProductNode = try .file(buildProduct.binaryPath)
4244
try self.manifest.addShellCmd(
4345
name: cmdName,
4446
description: "Archiving \(buildProduct.binaryPath.prettyPath())",
4547
inputs: (buildProduct.objects + [buildProduct.linkFileListPath]).map(Node.file),
46-
outputs: [.file(buildProduct.binaryPath)],
48+
outputs: [finalProductNode],
4749
arguments: try buildProduct.archiveArguments()
4850
)
4951

@@ -54,22 +56,24 @@ extension LLBuildManifestBuilder {
5456
+ testInputs
5557

5658
let shouldCodeSign: Bool
59+
let linkedBinaryNode: Node
60+
let linkedBinaryPath = try buildProduct.binaryPath
5761
if case .executable = buildProduct.product.type,
62+
buildParameters.targetTriple.isMacOSX,
5863
buildParameters.debuggingParameters.shouldEnableDebuggingEntitlement {
5964
shouldCodeSign = true
65+
linkedBinaryNode = try .file(buildProduct.binaryPath, isMutated: true)
6066
} else {
6167
shouldCodeSign = false
68+
linkedBinaryNode = try .file(buildProduct.binaryPath)
6269
}
6370

64-
let linkedBinarySuffix = shouldCodeSign ? "-unsigned" : ""
65-
let linkedBinaryPath = try AbsolutePath(validating: buildProduct.binaryPath.pathString + linkedBinarySuffix)
66-
6771
try self.manifest.addShellCmd(
6872
name: cmdName,
6973
description: "Linking \(buildProduct.binaryPath.prettyPath())",
7074
inputs: inputs.map(Node.file),
71-
outputs: [.file(linkedBinaryPath)],
72-
arguments: try buildProduct.linkArguments(outputPathSuffix: linkedBinarySuffix)
75+
outputs: [linkedBinaryNode],
76+
arguments: try buildProduct.linkArguments()
7377
)
7478

7579
if shouldCodeSign {
@@ -86,25 +90,20 @@ extension LLBuildManifestBuilder {
8690
try self.manifest.addShellCmd(
8791
name: "\(cmdName)-entitlements",
8892
description: "Applying debug entitlements to \(buildProduct.binaryPath.prettyPath())",
89-
inputs: [linkedBinaryPath, plistPath].map(Node.file),
93+
inputs: [linkedBinaryNode, .file(plistPath)],
9094
outputs: [codeSigningOutput],
9195
arguments: buildProduct.codeSigningArguments(plistPath: plistPath, binaryPath: linkedBinaryPath)
9296
)
93-
94-
try self.manifest.addShellCmd(
95-
name: "\(cmdName)-codesigning",
96-
description: "Applying debug entitlements to \(buildProduct.binaryPath.prettyPath())",
97-
inputs: [codeSigningOutput],
98-
outputs: [.file(buildProduct.binaryPath)],
99-
arguments: ["mv", linkedBinaryPath.pathString, buildProduct.binaryPath.pathString]
100-
)
97+
finalProductNode = codeSigningOutput
98+
} else {
99+
finalProductNode = linkedBinaryNode
101100
}
102101
}
103102

104103
self.manifest.addNode(output, toTarget: targetName)
105-
try self.manifest.addPhonyCmd(
104+
self.manifest.addPhonyCmd(
106105
name: output.name,
107-
inputs: [.file(buildProduct.binaryPath)],
106+
inputs: [finalProductNode],
108107
outputs: [output]
109108
)
110109

Sources/CoreCommands/Options.swift

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,11 @@ public struct BuildOptions: ParsableArguments {
477477
)
478478
public var linkTimeOptimizationMode: LinkTimeOptimizationMode?
479479

480-
/// Whether to enable debugging capabilities for code built by SwiftPM.
481-
@Flag(
482-
help: """
483-
Whether to enable unsafe debugging and backtraces for code built by SwiftPM. \
484-
Currently has an effect only on macOS.
485-
"""
486-
)
487-
public var enableUnsafeDebugging: Bool = false
480+
@Flag(help: .hidden)
481+
public var enableGetTaskAllowEntitlement: Bool = false
488482

489-
/// Whether to disable debugging capabilities for code built by SwiftPM.
490-
@Flag(help: """
491-
Whether to disable unsafe debugging and backtraces for code built by SwiftPM. \
492-
Currently has an effect only on macOS.
493-
"""
494-
)
495-
public var disableUnsafeDebugging: Bool = false
483+
@Flag(help: .hidden)
484+
public var disableGetTaskAllowEntitlement: Bool = false
496485

497486
// @Flag works best when there is a default value present
498487
// if true, false aren't enough and a third state is needed

Sources/CoreCommands/SwiftTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ public final class SwiftTool {
689689
debugInfoFormat: options.build.debugInfoFormat.buildParameter,
690690
targetTriple: targetTriple,
691691
shouldEnableDebuggingEntitlement:
692-
(options.build.configuration == .debug && !options.build.disableUnsafeDebugging) ||
693-
(options.build.enableUnsafeDebugging && !options.build.disableUnsafeDebugging)
692+
(options.build.configuration == .debug && !options.build.disableGetTaskAllowEntitlement) ||
693+
(options.build.enableGetTaskAllowEntitlement && !options.build.disableGetTaskAllowEntitlement)
694694
),
695695
driverParameters: .init(
696696
canRenameEntrypointFunctionName: driverSupport.checkSupportedFrontendFlags(

0 commit comments

Comments
 (0)