Skip to content

Commit 19ce521

Browse files
committed
Revert "Add toolchain swift stdlib to env when swift run. (#8364)"
This reverts commit 6dbb879.
1 parent ad9aa30 commit 19ce521

File tree

2 files changed

+6
-36
lines changed

2 files changed

+6
-36
lines changed

Sources/Commands/SwiftRunCommand.swift

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import ArgumentParser
14-
@_spi(SwiftPMInternal) import Basics
14+
import Basics
1515
import CoreCommands
1616
import Foundation
1717
import PackageGraph
@@ -233,9 +233,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
233233
let runnerPath: AbsolutePath
234234
let arguments: [String]
235235

236-
let toolchain = try swiftCommandState.getTargetToolchain()
237-
238-
if let debugger = toolchain.swiftSDK.toolset.knownTools[.debugger],
236+
if let debugger = try swiftCommandState.getTargetToolchain().swiftSDK.toolset.knownTools[.debugger],
239237
let debuggerPath = debugger.path {
240238
runnerPath = debuggerPath
241239
arguments = debugger.extraCLIOptions + [productAbsolutePath.pathString] + options.arguments
@@ -244,23 +242,11 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
244242
arguments = options.arguments
245243
}
246244

247-
// For Linux, need to point LD_LIBRARY_PATH at the swift runtime
248-
let environment: [String: String]?
249-
if toolchain.targetTriple.isLinux() {
250-
var current = Environment.current
251-
let pathVar: EnvironmentKey = "LD_LIBRARY_PATH"
252-
current.prependPath(key: pathVar, value: try toolchain.linuxSwiftStdlib.pathString)
253-
environment = .init(current)
254-
} else {
255-
environment = nil
256-
}
257-
258245
try self.run(
259246
fileSystem: swiftCommandState.fileSystem,
260247
executablePath: runnerPath,
261248
originalWorkingDirectory: swiftCommandState.originalWorkingDirectory,
262-
arguments: arguments,
263-
environment: environment
249+
arguments: arguments
264250
)
265251
} catch Diagnostics.fatalError {
266252
throw ExitCode.failure
@@ -308,8 +294,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
308294
fileSystem: FileSystem,
309295
executablePath: AbsolutePath,
310296
originalWorkingDirectory: AbsolutePath,
311-
arguments: [String],
312-
environment: [String: String]? = nil
297+
arguments: [String]
313298
) throws {
314299
// Make sure we are running from the original working directory.
315300
let cwd: AbsolutePath? = fileSystem.currentWorkingDirectory
@@ -318,7 +303,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
318303
}
319304

320305
let pathRelativeToWorkingDirectory = executablePath.relative(to: originalWorkingDirectory)
321-
try execute(path: executablePath.pathString, args: [pathRelativeToWorkingDirectory.pathString] + arguments, env: environment)
306+
try execute(path: executablePath.pathString, args: [pathRelativeToWorkingDirectory.pathString] + arguments)
322307
}
323308

324309
/// Determines if a path points to a valid swift file.
@@ -342,7 +327,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
342327
}
343328

344329
/// A safe wrapper of TSCBasic.exec.
345-
private func execute(path: String, args: [String], env: [String: String]?) throws -> Never {
330+
private func execute(path: String, args: [String]) throws -> Never {
346331
#if !os(Windows)
347332
// Dispatch will disable almost all asynchronous signals on its worker threads, and this is called from `async`
348333
// context. To correctly `exec` a freshly built binary, we will need to:
@@ -373,13 +358,6 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
373358
#endif /* os(FreeBSD) || os(OpenBSD) */
374359
#endif
375360

376-
if let env {
377-
// set the env before we exec.
378-
// TODO: we should really use execve here.
379-
// Though, Windows doesn't really exec anyway.
380-
try env.forEach { try ProcessEnv.setVar($0, value: $1) }
381-
}
382-
383361
try TSCBasic.exec(path: path, args: args)
384362
}
385363

Sources/PackageModel/Toolchain.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ extension Toolchain {
8888
}
8989
}
9090

91-
public var linuxSwiftStdlib: AbsolutePath {
92-
get throws {
93-
try Self.toolchainLibDir(swiftCompilerPath: self.swiftCompilerPath).appending(
94-
components: ["swift", "linux"]
95-
)
96-
}
97-
}
98-
9991
public var toolchainLibDir: AbsolutePath {
10092
get throws {
10193
// FIXME: Not sure if it's better to base this off of Swift compiler or our own binary.

0 commit comments

Comments
 (0)