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
[SR-11405] Can't build Swift PM due to non-unwrapped arguments to C function calls #4668
Comments
Possibly a difference between Ubuntu and Fedora C stdlibs? |
Comment by Ryan (JIRA) ubuntu 18.04 seems to be using glibc 2.27, and Fedora 31 currently has 2.30, but the functions don't appear to have changed between those two versions. |
Comment by Jonas Schwartz (JIRA) I am seeing the same error on Arch Linux, also glibc 2.30 I am trying to compile the latest Swift 5.1.1-RELEASE, anyone have an idea for a solution for this? |
Comment by Ryan (JIRA) I'm not proud, but diff --git a/Sources/TSCBasic/Process.swift b/Sources/TSCBasic/Process.swift
index 9d53054d..8a817f0d 100644
--- a/Sources/TSCBasic/Process.swift
+++ b/Sources/TSCBasic/Process.swift
@@ -366,7 +366,9 @@ public final class Process: ObjectIdentifierProtocol {
defer { posix_spawn_file_actions_destroy(&fileActions) }
// Workaround for https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=89e435f3559c53084498e9baad22172b64429362
- let devNull = strdup("/dev/null")
+ guard let devNull = strdup("/dev/null") else {
+ throw SystemError.posix_spawn(0, arguments)
+ }
defer { free(devNull) }
// Open /dev/null as stdin.
posix_spawn_file_actions_addopen(&fileActions, 0, devNull, O_RDONLY, 0)
@@ -392,7 +394,7 @@ public final class Process: ObjectIdentifierProtocol {
let argv = CStringArray(arguments)
let env = CStringArray(environment.map({ "\($0.0)=\($0.1)" }))
- let rv = posix_spawnp(&processID, argv.cArray[0], &fileActions, &attributes, argv.cArray, env.cArray)
+ let rv = posix_spawnp(&processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray)
guard rv == 0 else {
throw SystemError.posix_spawn(rv, arguments) |
Comment by Jonas Schwartz (JIRA) ryanw (JIRA User) thanks, was thinking the same, something in the back of my head just screamed no, but then again it's just my local dev machine 🙂 |
You're welcome to make it both-ways compatible and put up a PR. Just leave comments as to why it's necessary!
|
Comment by Ryan (JIRA) Fixed on Fedora 31 by swift-pm@35e66e5. Thanks jonas (JIRA User)& @aciidb0mb3r! |
Environment
Fedora 31 Branched x86_64
Swift master @Head (a951a4) with @tachoknight's Python 3 patch cherry-picked.
Additional Detail from JIRA
md5: 004490f8efd8e192ac0f2157161c738e
Issue Description:
I'm trying to build a Swift toolchain from master on Linux (Fedora 31) but the SwiftPM build fails with the following message:
The text was updated successfully, but these errors were encountered: