Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public struct LinuxRecipe: SwiftSDKRecipe {
} else {
swiftCompilerOptions.append("-use-ld=lld")

// 32-bit architectures require libatomic
if targetTriple.archName == "armv7" {
swiftCompilerOptions.append("-latomic")
}

if self.hostSwiftSource != .preinstalled {
toolset.linker = Toolset.ToolProperties(path: "ld.lld")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class LinuxRecipeTests: XCTestCase {
let testCases = [
(
swiftVersion: "5.9.2",
targetTriple: Triple("x86_64-unknown-linux-gnu"),
expectedSwiftCompilerOptions: [
"-Xlinker", "-R/usr/lib/swift/linux/",
"-Xclang-linker", "--ld-path=ld.lld"
Expand All @@ -53,19 +54,30 @@ final class LinuxRecipeTests: XCTestCase {
),
(
swiftVersion: "6.0.2",
targetTriple: Triple("aarch64-unknown-linux-gnu"),
expectedSwiftCompilerOptions: [
"-Xlinker", "-R/usr/lib/swift/linux/",
"-use-ld=lld"
],
expectedLinkerPath: "ld.lld"
),
(
swiftVersion: "6.0.3",
targetTriple: Triple("armv7-unknown-linux-gnueabihf"),
expectedSwiftCompilerOptions: [
"-Xlinker", "-R/usr/lib/swift/linux/",
"-use-ld=lld",
"-latomic"
],
expectedLinkerPath: "ld.lld"
)
]

for testCase in testCases {
let recipe = try self.createRecipe(swiftVersion: testCase.swiftVersion)
var toolset = Toolset(rootPath: nil)
recipe.applyPlatformOptions(
toolset: &toolset, targetTriple: Triple("aarch64-unknown-linux-gnu")
toolset: &toolset, targetTriple: testCase.targetTriple
)
XCTAssertEqual(toolset.swiftCompiler?.extraCLIOptions, testCase.expectedSwiftCompilerOptions)
XCTAssertEqual(toolset.linker?.path, testCase.expectedLinkerPath)
Expand Down