@@ -918,7 +918,7 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
918918 )
919919
920920 // Create the task.
921- delegate. createTask ( type: self , payload: payload, ruleInfo: defaultRuleInfo ( cbc, delegate) , commandLine: commandLine, environment: environmentFromSpec ( cbc, delegate) , workingDirectory: cbc. producer. defaultWorkingDirectory, inputs: inputs, outputs: outputs, action: nil , execDescription: resolveExecutionDescription ( cbc, delegate) , enableSandboxing: enableSandboxing)
921+ delegate. createTask ( type: self , payload: payload, ruleInfo: defaultRuleInfo ( cbc, delegate) , commandLine: commandLine, environment: environmentFromSpec ( cbc, delegate) , workingDirectory: cbc. producer. defaultWorkingDirectory, inputs: inputs, outputs: outputs, action: createTaskAction ( cbc , delegate ) , execDescription: resolveExecutionDescription ( cbc, delegate) , enableSandboxing: enableSandboxing)
922922 }
923923
924924 public func constructPreviewsBlankInjectionDylibTask(
@@ -992,7 +992,7 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
992992 workingDirectory: cbc. producer. defaultWorkingDirectory,
993993 inputs: [ ] ,
994994 outputs: outputs,
995- action: nil ,
995+ action: createTaskAction ( cbc , delegate ) ,
996996 execDescription: resolveExecutionDescription ( cbc, delegate) ,
997997 enableSandboxing: enableSandboxing
998998 )
@@ -1246,6 +1246,9 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
12461246 case . object:
12471247 // Object files are added to linker inputs in the sources task producer.
12481248 return ( [ ] , [ ] )
1249+ case . objectLibrary:
1250+ let pathFlags = specifier. absolutePathFlagsForLd ( )
1251+ return ( pathFlags, [ specifier. path] )
12491252 }
12501253 } . reduce ( ( [ ] , [ ] ) ) { ( lhs, rhs) in ( lhs. args + rhs. args, lhs. inputs + rhs. inputs) }
12511254 }
@@ -1367,6 +1370,11 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
13671370 return LdLinkerOutputParser . self
13681371 }
13691372
1373+ override public func createTaskAction( _ cbc: CommandBuildContext , _ delegate: any TaskGenerationDelegate ) -> ( any PlannedTaskAction ) ? {
1374+ let useResponseFile = cbc. scope. evaluate ( BuiltinMacros . CLANG_USE_RESPONSE_FILE)
1375+ return delegate. taskActionCreationDelegate. createLinkerTaskAction ( expandResponseFiles: !useResponseFile)
1376+ }
1377+
13701378 override public func discoveredCommandLineToolSpecInfo( _ producer: any CommandProducer , _ scope: MacroEvaluationScope , _ delegate: any CoreClientTargetDiagnosticProducingDelegate ) async -> ( any DiscoveredCommandLineToolSpecInfo ) ? {
13711379 // The ALTERNATE_LINKER is the 'name' of the linker not the executable name, clang will find the linker binary based on name passed via -fuse-ld, but we need to discover
13721380 // its properties by executing the actual binary. There is a common filename when the linker is not "ld" across all platforms using "ld.<ALTERNAME_LINKER>(.exe)"
@@ -1482,6 +1490,9 @@ fileprivate extension LinkerSpec.LibrarySpecifier {
14821490 case ( . object, _) :
14831491 // Object files are added to linker inputs in the sources task producer.
14841492 return [ ]
1493+ case ( . objectLibrary, _) :
1494+ // Object libraries can't be found via search paths.
1495+ return [ ]
14851496 }
14861497 }
14871498
@@ -1518,6 +1529,8 @@ fileprivate extension LinkerSpec.LibrarySpecifier {
15181529 case ( . object, _) :
15191530 // Object files are added to linker inputs in the sources task producer.
15201531 return [ ]
1532+ case ( . objectLibrary, _) :
1533+ return [ " @ \( path. join ( " args.resp " ) . str) " ]
15211534 }
15221535 }
15231536}
@@ -1574,6 +1587,11 @@ public final class LibtoolLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @u
15741587 }
15751588 }
15761589
1590+ override public func createTaskAction( _ cbc: CommandBuildContext , _ delegate: any TaskGenerationDelegate ) -> ( any PlannedTaskAction ) ? {
1591+ let useResponseFile = cbc. scope. evaluate ( BuiltinMacros . LIBTOOL_USE_RESPONSE_FILE)
1592+ return delegate. taskActionCreationDelegate. createLinkerTaskAction ( expandResponseFiles: !useResponseFile)
1593+ }
1594+
15771595 override public func constructLinkerTasks( _ cbc: CommandBuildContext , _ delegate: any TaskGenerationDelegate , libraries: [ LibrarySpecifier ] , usedTools: [ CommandLineToolSpec : Set < FileTypeSpec > ] ) async {
15781596 var inputPaths = cbc. inputs. map ( { $0. absolutePath } )
15791597 var specialArgs = [ String] ( )
@@ -1619,6 +1637,10 @@ public final class LibtoolLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @u
16191637 // Object files are added to linker inputs in the sources task producer and so end up in the link-file-list.
16201638 return [ ]
16211639
1640+ case . objectLibrary:
1641+ inputPaths. append ( specifier. path)
1642+ return [ " @ \( specifier. path. join ( " args.resp " ) . str) " ]
1643+
16221644 case . framework:
16231645 // A static library can build against a framework, since the library in the framework could be a static library, which is valid, and we can't tell here whether it is or not. So we leave it to libtool to do the right thing here.
16241646 // Also, we wouldn't want to emit an error here even if we could determine that it contained a dylib, since the target might be only using the framework to find headers.
@@ -1710,7 +1732,7 @@ public final class LibtoolLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @u
17101732 workingDirectory: cbc. producer. defaultWorkingDirectory,
17111733 inputs: inputs,
17121734 outputs: outputs,
1713- action: nil ,
1735+ action: createTaskAction ( cbc , delegate ) ,
17141736 execDescription: resolveExecutionDescription ( cbc, delegate) ,
17151737 enableSandboxing: enableSandboxing
17161738 )
0 commit comments