From ab96c02ecbac565b88522c46dce9df01fc7a8946 Mon Sep 17 00:00:00 2001 From: Butta Date: Thu, 23 Feb 2023 20:57:28 +0530 Subject: [PATCH] On ELF platforms, look for the runtime libraries in an architecture-specific directory. This is needed for apple/swift#63782, which changes the Unix toolchain to look for libraries in architecture-specific directories. --- Sources/Commands/Utilities/TestingSupport.swift | 5 +++-- Tests/PackageModelTests/DestinationTests.swift | 2 +- Utilities/bootstrap | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/Commands/Utilities/TestingSupport.swift b/Sources/Commands/Utilities/TestingSupport.swift index 5b1e48fd30a..a1d56538973 100644 --- a/Sources/Commands/Utilities/TestingSupport.swift +++ b/Sources/Commands/Utilities/TestingSupport.swift @@ -134,9 +134,10 @@ enum TestingSupport { env.prependPath("Path", value: location.pathString) } #elseif os(Linux) - var libraryPaths = ["/usr/lib/swift/linux"] + let arch = buildParameters.triple.arch.rawValue + var libraryPaths = ["/usr/lib/swift/linux/\(arch)"] if let path = env["PATH"], let firstPathEntry = path.components(separatedBy: ":").first { - libraryPaths.append("\(firstPathEntry)/../lib/swift/linux") + libraryPaths.append("\(firstPathEntry)/../lib/swift/linux/\(arch)") } if let originalLibraryPaths = env["LD_LIBRARY_PATH"] { libraryPaths.append(originalLibraryPaths) diff --git a/Tests/PackageModelTests/DestinationTests.swift b/Tests/PackageModelTests/DestinationTests.swift index 6797d972ab6..50f83ccacd1 100644 --- a/Tests/PackageModelTests/DestinationTests.swift +++ b/Tests/PackageModelTests/DestinationTests.swift @@ -27,7 +27,7 @@ private let extraFlags = BuildFlags( cCompilerFlags: ["-fintegrated-as"], cxxCompilerFlags: ["-fno-exceptions"], swiftCompilerFlags: ["-enable-experimental-cxx-interop", "-use-ld=lld"], - linkerFlags: ["-R/usr/lib/swift/linux/"] + linkerFlags: ["-R/usr/lib/swift/linux/x86_64"] ) private let destinationV1JSON = diff --git a/Utilities/bootstrap b/Utilities/bootstrap index fd1fc91ac6c..a922a888c8d 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -784,7 +784,7 @@ def get_swiftpm_flags(args): platform_path = None for path in args.target_info["paths"]["runtimeLibraryPaths"]: - platform_path = re.search(r"(lib/swift/([^/]+))$", path) + platform_path = re.search(r"(lib/swift/([\w/]+))$", path) if platform_path: build_flags.extend( [