@@ -2947,7 +2947,7 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
29472947 return ( isEnabled, isExplicitlyEnabled)
29482948 }
29492949
2950- private func staticallyLinkSwiftStdlib( _ producer: any CommandProducer , scope: MacroEvaluationScope ) -> Bool {
2950+ private func staticallyLinkSwiftStdlib( _ producer: any CommandProducer , scope: MacroEvaluationScope , lookup : @escaping ( ( MacroDeclaration ) -> MacroStringExpression ? ) ) -> Bool {
29512951 // Determine whether we should statically link the Swift stdlib, and determined
29522952 // by the following logic in the following order:
29532953 //
@@ -2960,17 +2960,17 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
29602960 //
29612961 // NOTE: With Swift in the OS, static libs aren't being supplied by the toolchains
29622962 // so users of this flag will need to provide their own.
2963- if scope. evaluate ( BuiltinMacros . SWIFT_FORCE_STATIC_LINK_STDLIB) {
2963+ if scope. evaluate ( BuiltinMacros . SWIFT_FORCE_STATIC_LINK_STDLIB, lookup : lookup ) {
29642964 return true
29652965 }
29662966 return false
29672967 }
29682968
2969- public override func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2970- return await computeAdditionalLinkerArgs ( producer, scope: scope, inputFileTypes: inputFileTypes, optionContext: optionContext, forTAPI: false , delegate: delegate)
2969+ public override func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , lookup : @escaping ( ( MacroDeclaration ) -> MacroStringExpression ? ) , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2970+ return await computeAdditionalLinkerArgs ( producer, scope: scope, lookup : lookup , inputFileTypes: inputFileTypes, optionContext: optionContext, forTAPI: false , delegate: delegate)
29712971 }
29722972
2973- func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , forTAPI: Bool = false , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2973+ func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , lookup : @escaping ( ( MacroDeclaration ) -> MacroStringExpression ? ) , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , forTAPI: Bool = false , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
29742974 guard let swiftToolSpec = optionContext as? DiscoveredSwiftCompilerToolSpecInfo else {
29752975 // An error message would have already been emitted by this point
29762976 return ( args: [ [ ] ] , inputPaths: [ ] )
@@ -2983,21 +2983,21 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
29832983 var inputPaths : [ Path ] = [ ]
29842984 if !forTAPI {
29852985 // TAPI can't use all of the additional linker options, and its spec has all of the build setting/option arguments that it can use.
2986- args = producer. effectiveFlattenedOrderedBuildOptions ( self ) . map { $0. getAdditionalLinkerArgs ( producer, scope: scope, inputFileTypes: inputFileTypes) } . filter { !$0. isEmpty }
2986+ args = producer. effectiveFlattenedOrderedBuildOptions ( self ) . map { $0. getAdditionalLinkerArgs ( producer, scope: scope, lookup : lookup , inputFileTypes: inputFileTypes) } . filter { !$0. isEmpty }
29872987 }
29882988
29892989 // Determine if we are forced to use the standard system location; this is currently only for OS adopters of Swift, not any client.
2990- let useSystemSwift = scope. evaluate ( BuiltinMacros . SWIFT_FORCE_SYSTEM_LINK_STDLIB)
2990+ let useSystemSwift = scope. evaluate ( BuiltinMacros . SWIFT_FORCE_SYSTEM_LINK_STDLIB, lookup : lookup )
29912991
29922992 // Determine whether we should statically link the Swift stdlib.
2993- let shouldStaticLinkStdlib = staticallyLinkSwiftStdlib ( producer, scope: scope)
2993+ let shouldStaticLinkStdlib = staticallyLinkSwiftStdlib ( producer, scope: scope, lookup : lookup )
29942994
2995- let swiftStdlibName = scope. evaluate ( BuiltinMacros . SWIFT_STDLIB)
2996- var swiftLibraryPath = scope. evaluate ( BuiltinMacros . SWIFT_LIBRARY_PATH)
2997- let dynamicLibraryExtension = scope. evaluate ( BuiltinMacros . DYNAMIC_LIBRARY_EXTENSION)
2995+ let swiftStdlibName = scope. evaluate ( BuiltinMacros . SWIFT_STDLIB, lookup : lookup )
2996+ var swiftLibraryPath = scope. evaluate ( BuiltinMacros . SWIFT_LIBRARY_PATH, lookup : lookup )
2997+ let dynamicLibraryExtension = scope. evaluate ( BuiltinMacros . DYNAMIC_LIBRARY_EXTENSION, lookup : lookup )
29982998
29992999 // If we weren't given an explicit library path, compute one
3000- let platformName = scope. evaluate ( BuiltinMacros . PLATFORM_NAME)
3000+ let platformName = scope. evaluate ( BuiltinMacros . PLATFORM_NAME, lookup : lookup )
30013001 if swiftLibraryPath. isEmpty {
30023002 // Look next to the compiler and in the toolchains for one.
30033003 if shouldStaticLinkStdlib {
@@ -3015,13 +3015,13 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
30153015 }
30163016 }
30173017
3018- let isMacCatalystUnzippered = producer. sdkVariant? . isMacCatalyst == true && !scope. evaluate ( BuiltinMacros . IS_ZIPPERED)
3018+ let isMacCatalystUnzippered = producer. sdkVariant? . isMacCatalyst == true && !scope. evaluate ( BuiltinMacros . IS_ZIPPERED, lookup : lookup )
30193019
30203020 var sdkPathArgument : [ String ] = [ ]
30213021 var unzipperedSDKPathArgument : [ String ] = [ ]
30223022 if forTAPI {
30233023 // TAPI requires absolute paths.
3024- let sdkroot = scope. evaluate ( BuiltinMacros . SDKROOT)
3024+ let sdkroot = scope. evaluate ( BuiltinMacros . SDKROOT, lookup : lookup )
30253025 if !sdkroot. isEmpty {
30263026 sdkPathArgument = [ " -L " + sdkroot. join ( " usr/lib/swift " ) . str]
30273027 unzipperedSDKPathArgument = [ " -L " + sdkroot. join ( " System/iOSSupport/usr/lib/swift " ) . str]
@@ -3072,24 +3072,24 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
30723072 // be a source-less target which just contains object files in it's framework phase.
30733073 let currentPlatformFilter = PlatformFilter ( scope)
30743074 let containsSources = ( producer. configuredTarget? . target as? StandardTarget ) ? . sourcesBuildPhase? . buildFiles. filter { currentPlatformFilter. matches ( $0. platformFilters) } . isEmpty == false
3075- if containsSources && inputFileTypes. contains ( where: { $0. conformsTo ( identifier: " sourcecode.swift " ) } ) && scope. evaluate ( BuiltinMacros . GCC_GENERATE_DEBUGGING_SYMBOLS) && !scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_MODULEWRAP) {
3076- let moduleName = scope. evaluate ( BuiltinMacros . SWIFT_MODULE_NAME)
3077- let moduleFileDir = scope. evaluate ( BuiltinMacros . PER_ARCH_MODULE_FILE_DIR)
3075+ if containsSources && inputFileTypes. contains ( where: { $0. conformsTo ( identifier: " sourcecode.swift " ) } ) && scope. evaluate ( BuiltinMacros . GCC_GENERATE_DEBUGGING_SYMBOLS, lookup : lookup ) && !scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_MODULEWRAP, lookup : lookup ) {
3076+ let moduleName = scope. evaluate ( BuiltinMacros . SWIFT_MODULE_NAME, lookup : lookup )
3077+ let moduleFileDir = scope. evaluate ( BuiltinMacros . PER_ARCH_MODULE_FILE_DIR, lookup : lookup )
30783078 let moduleFilePath = moduleFileDir. join ( moduleName + " .swiftmodule " )
30793079 args += [ [ " -Xlinker " , " -add_ast_path " , " -Xlinker " , moduleFilePath. str] ]
3080- if scope. evaluate ( BuiltinMacros . SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS) {
3080+ if scope. evaluate ( BuiltinMacros . SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS, lookup : lookup ) {
30813081 args += [ [ " @ \( Path ( moduleFilePath. appendingFileNameSuffix ( " -linker-args " ) . withoutSuffix + " .resp " ) . str) " ] ]
30823082 }
30833083 }
30843084 }
30853085
3086- if scope. evaluate ( BuiltinMacros . SWIFT_ADD_TOOLCHAIN_SWIFTSYNTAX_SEARCH_PATHS) {
3086+ if scope. evaluate ( BuiltinMacros . SWIFT_ADD_TOOLCHAIN_SWIFTSYNTAX_SEARCH_PATHS, lookup : lookup ) {
30873087 args += [ [ " -L \( swiftToolSpec. hostLibraryDirectory. str) " ] ]
30883088 }
30893089
30903090 let containsSwiftSources = ( producer. configuredTarget? . target as? StandardTarget ) ? . sourcesBuildPhase? . containsSwiftSources ( producer, producer, scope, producer. filePathResolver) == true
3091- if scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_AUTOLINK_EXTRACT) && containsSwiftSources {
3092- let inputPath = scope. evaluate ( BuiltinMacros . SWIFT_AUTOLINK_EXTRACT_OUTPUT_PATH)
3091+ if scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_AUTOLINK_EXTRACT, lookup : lookup ) && containsSwiftSources {
3092+ let inputPath = scope. evaluate ( BuiltinMacros . SWIFT_AUTOLINK_EXTRACT_OUTPUT_PATH, lookup : lookup )
30933093 args += [ [ " @ \( inputPath. str) " ] ]
30943094 inputPaths. append ( inputPath)
30953095 }
0 commit comments