From 1e0c92ffd9ad5ecf60a9bdee376faf76fec145f4 Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Mon, 6 May 2024 17:42:35 +0530 Subject: [PATCH] Revert "Work around lld 13+ issue with --gc-sections for ELF by adding -z nostart-stop-gc" This reverts c771555e1c9, now that it was properly fixed in apple/swift#72061. --- .../Jobs/GenericUnixToolchain+LinkerSupport.swift | 11 ----------- Tests/SwiftDriverTests/SwiftDriverTests.swift | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift index d315d6d25..6a13575e6 100644 --- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift +++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift @@ -89,17 +89,6 @@ extension GenericUnixToolchain { #else commandLine.appendFlag("-fuse-ld=\(linker)") #endif - // Starting with lld 13, Swift stopped working with the lld - // --gc-sections implementation for ELF, unless -z nostart-stop-gc is - // also passed to lld: - // - // https://reviews.llvm.org/D96914 - if linker == "lld" || linker.hasSuffix("ld.lld") { - commandLine.appendFlag(.Xlinker) - commandLine.appendFlag("-z") - commandLine.appendFlag(.Xlinker) - commandLine.appendFlag("nostart-stop-gc") - } } if let arg = parsedOptions.getLastArgument(.ldPath)?.asSingle { diff --git a/Tests/SwiftDriverTests/SwiftDriverTests.swift b/Tests/SwiftDriverTests/SwiftDriverTests.swift index f3c09affb..79c942fba 100644 --- a/Tests/SwiftDriverTests/SwiftDriverTests.swift +++ b/Tests/SwiftDriverTests/SwiftDriverTests.swift @@ -2372,8 +2372,7 @@ final class SwiftDriverTests: XCTestCase { let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs() let lastJob = plannedJobs.last! XCTAssertTrue(lastJob.tool.name.contains("clang")) - XCTAssertTrue(lastJob.commandLine.contains(subsequence: [.flag("-fuse-ld=lld"), - .flag("-Xlinker"), .flag("-z"), .flag("-Xlinker"), .flag("nostart-stop-gc")])) + XCTAssertTrue(lastJob.commandLine.contains(.flag("-fuse-ld=lld"))) } do {