Skip to content

Commit adcbc09

Browse files
committed
Fix linkage of hello world executable on FreeBSD
Closes #899
1 parent f728ff1 commit adcbc09

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Sources/SWBCore/Settings/Settings.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4242,9 +4242,17 @@ private class SettingsBuilder {
42424242

42434243
// 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.
42444244
if scope.evaluate(BuiltinMacros.ENABLE_TESTABILITY) {
4245+
let exportGlobalSymbols: Bool
4246+
if let standardTarget = target as? StandardTarget, ["com.apple.product-type.objfile", "org.swift.product-type.common.object"].contains(standardTarget.productTypeIdentifier) {
4247+
// 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
4248+
exportGlobalSymbols = false
4249+
} else {
4250+
exportGlobalSymbols = true
4251+
}
4252+
42454253
table.push(BuiltinMacros.GCC_SYMBOLS_PRIVATE_EXTERN, literal: false)
42464254
table.push(BuiltinMacros.SWIFT_ENABLE_TESTABILITY, literal: true)
4247-
table.push(BuiltinMacros.LD_EXPORT_GLOBAL_SYMBOLS, literal: true) // So symbols are available for testing even when LTO is enabled
4255+
table.push(BuiltinMacros.LD_EXPORT_GLOBAL_SYMBOLS, literal: exportGlobalSymbols) // So symbols are available for testing even when LTO is enabled
42484256
table.push(BuiltinMacros.STRIP_INSTALLED_PRODUCT, literal: false)
42494257
}
42504258

Sources/SWBGenericUnixPlatform/Plugin.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ struct GenericUnixSDKRegistryExtension: SDKRegistryExtension {
200200
try ("__SYSROOT_\(LLVMTriple(targetTriple.key).arch)", .plString(swiftSDK.path.join(targetTriple.value.sdkRootPath).str))
201201
}).merging([
202202
"SYSROOT": "$(__SYSROOT_$(CURRENT_ARCH))",
203-
204-
// ld.lld: error: -r and --export-dynamic (-rdynamic) may not be used together
205-
"LD_EXPORT_GLOBAL_SYMBOLS": "YES",
206203
], uniquingKeysWith: { _, new in new })
207204
} catch {
208205
// FIXME: Handle errors?

0 commit comments

Comments
 (0)