Skip to content

Commit 6217a62

Browse files
authored
Ensure we do not expect additional linker args to be produced in targets with Swift-produced object files (#378)
If Swift produced an object in the linked libraries of a target, we allow it to generate additional linker options, even if it did not run to compile any source files. However, we should not attempt to inject top-level AST paths for debugging since no actual compile took place, and the paths won't exist at execution time. Use the object file type when injecting Swift tool usage in these targets so that we don't take the unintended code path. rdar://144729550
1 parent 008bd85 commit 6217a62

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, FilesBase
896896

897897
// If there is at least one object file that was built using Swift, ensure the Swift tool is present in the used tools to allow linker spec to add swift specific linker arguments.
898898
if objectsInFrameworkPhase.contains(where: { !$0.swiftModulePaths.isEmpty }), !usedTools.keys.contains(context.swiftCompilerSpec) {
899-
usedTools[context.swiftCompilerSpec] = [context.lookupFileType(identifier: "sourcecode.swift")!]
899+
usedTools[context.swiftCompilerSpec] = [context.lookupFileType(identifier: "compiled.mach-o.objfile")!]
900900
}
901901

902902
// If this is an API build, or there are no tasks and object files, don't link, so we don't produce a binary if we're not compiling any code.

0 commit comments

Comments
 (0)