@@ -591,10 +591,10 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
591591
592592 required init ( ) { }
593593
594- func getStandardFlags( _ spec: ClangCompilerSpec , producer : any CommandProducer , scope : MacroEvaluationScope , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate , inputFileType: FileTypeSpec ) -> ConstantFlags {
594+ func getStandardFlags( _ spec: ClangCompilerSpec , cbc : CommandBuildContext , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate , inputFileType: FileTypeSpec ) -> ConstantFlags {
595595 // This cache is per-producer, so it is guaranteed to be invariant based on that.
596- constantFlagsCache. getOrInsert ( ConstantFlagsKey ( scope: scope, inputFileType: inputFileType) ) {
597- return spec. standardFlags ( producer , scope : scope , optionContext: optionContext, delegate: delegate, inputFileType: inputFileType)
596+ constantFlagsCache. getOrInsert ( ConstantFlagsKey ( scope: cbc . scope, inputFileType: inputFileType) ) {
597+ return spec. standardFlags ( cbc , optionContext: optionContext, delegate: delegate, inputFileType: inputFileType)
598598 }
599599 }
600600 }
@@ -646,8 +646,9 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
646646 super. init ( parser, basedOnSpec, isGeneric: false )
647647 }
648648
649- private func standardFlags( _ producer : any CommandProducer , scope : MacroEvaluationScope , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate , inputFileType: FileTypeSpec ) -> ConstantFlags {
649+ private func standardFlags( _ cbc : CommandBuildContext , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate , inputFileType: FileTypeSpec ) -> ConstantFlags {
650650 var commandLine = Array < String > ( )
651+ let producer = cbc. producer, scope = cbc. scope
651652
652653 // Add the arguments from the specification.
653654 commandLine += self . commandLineFromOptions ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, buildOptionsFilter: . specOnly, lookup: { declaration in
@@ -657,7 +658,7 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
657658 return BuiltinMacros . namespace. parseString ( " NO " )
658659 }
659660 }
660- return nil
661+ return self . lookup ( declaration , cbc , delegate )
661662 } ) . map ( \. asString)
662663
663664 // Add the common header search paths.
@@ -1136,7 +1137,8 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
11361137 //
11371138 // FIXME: Eventually we should just apply this optimization to all generic specs, and then find a way to piggy back on that.
11381139 let dataCache = cbc. producer. getSpecDataCache ( self , cacheType: DataCache . self)
1139- let constantFlags = dataCache. getStandardFlags ( self , producer: cbc. producer, scope: cbc. scope, optionContext: clangInfo, delegate: delegate, inputFileType: resolvedInputFileType)
1140+ let cbcWithOutput = cbc. outputs. isEmpty ? cbc. appendingOutputs ( [ outputNode. path] ) : cbc
1141+ let constantFlags = dataCache. getStandardFlags ( self , cbc: cbcWithOutput, optionContext: clangInfo, delegate: delegate, inputFileType: resolvedInputFileType)
11401142 commandLine += constantFlags. flags
11411143 let responseFileAdditionalOutput = constantFlags. responseFileMapping. keys. sorted ( ) . map ( { " Using response file: \( $0. str) " } )
11421144 additionalOutput. append ( contentsOf: responseFileAdditionalOutput)
@@ -1157,7 +1159,6 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
11571159 inputDeps. append ( contentsOf: constantFlags. headerSearchPaths. inputPaths)
11581160#endif
11591161
1160- let cbcWithOutput = cbc. outputs. isEmpty ? cbc. appendingOutputs ( [ outputNode. path] ) : cbc
11611162 commandLine += self . commandLineFromOptions ( cbc. producer, scope: cbc. scope, inputFileType: resolvedInputFileType, optionContext: clangInfo, buildOptionsFilter: . extendedOnly, lookup: {
11621163 self . lookup ( $0, cbcWithOutput, delegate)
11631164 } ) . map ( \. asString)
@@ -1681,7 +1682,7 @@ public class ClangCompilerSpec : CompilerSpec, SpecIdentifierType, GCCCompatible
16811682
16821683 // Add “standard flags”, which are ones that depend only on the variant, architecture, and language (in addition to the identifier, of course).
16831684 let dataCache = cbc. producer. getSpecDataCache ( self , cacheType: DataCache . self)
1684- let constantFlags = dataCache. getStandardFlags ( self , producer : cbc. producer , scope : cbc. scope , optionContext: clangInfo, delegate: delegate, inputFileType: inputFileType)
1685+ let constantFlags = dataCache. getStandardFlags ( self , cbc: cbc, optionContext: clangInfo, delegate: delegate, inputFileType: inputFileType)
16851686 let responseFileAdditionalOutput = constantFlags. responseFileMapping. keys. sorted ( ) . map ( { " Using response file: \( $0. str) " } )
16861687 commandLine += constantFlags. flags
16871688
0 commit comments