Skip to content

Driver: allow static executables when using Musl #1383

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

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ public struct Driver {

self.lto = Self.ltoKind(&parsedOptions, diagnosticsEngine: diagnosticsEngine)
// Figure out the primary outputs from the driver.
(self.compilerOutputType, self.linkerOutputType) = Self.determinePrimaryOutputs(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
(self.compilerOutputType, self.linkerOutputType) =
Self.determinePrimaryOutputs(&parsedOptions, targetTriple: self.frontendTargetInfo.target.triple,
driverKind: driverKind, diagnosticsEngine: diagnosticEngine)

// Multithreading.
self.numThreads = Self.determineNumThreads(&parsedOptions, compilerMode: compilerMode, diagnosticsEngine: diagnosticEngine)
Expand Down Expand Up @@ -1994,6 +1996,7 @@ extension Driver {
/// Determine the primary compiler and linker output kinds.
private static func determinePrimaryOutputs(
_ parsedOptions: inout ParsedOptions,
targetTriple: Triple,
driverKind: DriverKind,
diagnosticsEngine: DiagnosticsEngine
) -> (FileType?, LinkOutputType?) {
Expand All @@ -2005,7 +2008,7 @@ extension Driver {
if let outputOption = parsedOptions.getLast(in: .modes) {
switch outputOption.option {
case .emitExecutable:
if parsedOptions.contains(.static) {
if parsedOptions.contains(.static) && targetTriple.environment != .musl {
diagnosticsEngine.emit(.error_static_emit_executable_disallowed)
}
linkerOutputType = .executable
Expand Down