Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Sources/SWBCore/Settings/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4192,9 +4192,17 @@ private class SettingsBuilder {

// If testability is enabled, then that overrides certain other settings, and in a way that the user cannot override: They're either using testability, or they're not.
if scope.evaluate(BuiltinMacros.ENABLE_TESTABILITY) {
let exportGlobalSymbols: Bool
if let standardTarget = target as? StandardTarget, ["com.apple.product-type.objfile", "org.swift.product-type.common.object"].contains(standardTarget.productTypeIdentifier) {
// with lld, -r and --export-dynamic may not be used together, but this is assumed to be a generally nonsensical combination even if other linkers like gold don't necessarily error out
exportGlobalSymbols = false
} else {
exportGlobalSymbols = true
}

table.push(BuiltinMacros.GCC_SYMBOLS_PRIVATE_EXTERN, literal: false)
table.push(BuiltinMacros.SWIFT_ENABLE_TESTABILITY, literal: true)
table.push(BuiltinMacros.LD_EXPORT_GLOBAL_SYMBOLS, literal: true) // So symbols are available for testing even when LTO is enabled
table.push(BuiltinMacros.LD_EXPORT_GLOBAL_SYMBOLS, literal: exportGlobalSymbols) // So symbols are available for testing even when LTO is enabled
table.push(BuiltinMacros.STRIP_INSTALLED_PRODUCT, literal: false)
}

Expand Down
3 changes: 0 additions & 3 deletions Sources/SWBGenericUnixPlatform/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ struct GenericUnixSDKRegistryExtension: SDKRegistryExtension {
try ("__SYSROOT_\(LLVMTriple(targetTriple.key).arch)", .plString(swiftSDK.path.join(targetTriple.value.sdkRootPath).str))
}).merging([
"SYSROOT": "$(__SYSROOT_$(CURRENT_ARCH))",

// ld.lld: error: -r and --export-dynamic (-rdynamic) may not be used together
"LD_EXPORT_GLOBAL_SYMBOLS": "YES",
], uniquingKeysWith: { _, new in new })
} catch {
// FIXME: Handle errors?
Expand Down