Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator/linux: Use --ldpath linker flag for 5.9 #151

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
19 changes: 13 additions & 6 deletions Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,20 @@ public struct LinuxRecipe: SwiftSDKRecipe {
}

public func applyPlatformOptions(toolset: inout Toolset, targetTriple: Triple) {
toolset.swiftCompiler = Toolset.ToolProperties(extraCLIOptions: [
"-use-ld=lld",
"-Xlinker",
"-R/usr/lib/swift/linux/",
])
var swiftCompilerOptions = ["-Xlinker", "-R/usr/lib/swift/linux/"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think -Xlinker -R/usr/lib/swift/linux/ may not be necessary any more, but want to do more testing before removing it.


// Swift 5.9 does not handle the `-use-ld` option properly:
// https://github.com/swiftlang/swift-package-manager/issues/7222
if self.versionsConfiguration.swiftVersion.hasPrefix("5.9") {
swiftCompilerOptions += ["-Xclang-linker", "--ld-path=ld.lld"]
} else {
swiftCompilerOptions.append("-use-ld=lld")
toolset.linker = Toolset.ToolProperties(path: "ld.lld")
}

toolset.swiftCompiler = Toolset.ToolProperties(extraCLIOptions: swiftCompilerOptions)

toolset.cxxCompiler = Toolset.ToolProperties(extraCLIOptions: ["-lstdc++"])
toolset.linker = Toolset.ToolProperties(path: "ld.lld")
toolset.librarian = Toolset.ToolProperties(path: "llvm-ar")
}

Expand Down