Skip to content

SwiftPM on macOS produces "error: manifest parse error(s)" #1365

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

Closed
MaxDesiatov opened this issue Jul 3, 2020 · 0 comments · Fixed by #1387
Closed

SwiftPM on macOS produces "error: manifest parse error(s)" #1365

MaxDesiatov opened this issue Jul 3, 2020 · 0 comments · Fixed by #1387
Labels
bug Something isn't working

Comments

@MaxDesiatov
Copy link

I think this exact issue will be fixed in tonight's snapshot, at least not able to reproduce it locally anymore thanks to c7557be. Nevertheless, there's a different issue with SwiftPM on macOS, which prevents it from working properly. I think it has something to be with how libPackageDescription.dylibthat belongs to SwiftPM is compiled. If you completely clean your .build directory (for any package, not just Tokamak) you get this error:

 error: manifest parse error(s):
<unknown>

The breakage happens when the Package.swift manifest path is compiled, you can infer by passing the -v flag to swift build and checking where exactly the error occurs:

/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/bin/swiftc -L /Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2 -lPackageDescription -Xlinker -rpath -Xlinker /Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.15 -swift-version 5 -I /Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2 -sdk /Applications/Xcode-11.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -package-description-version 5.2.0 /Users/maxd/Documents/Tokamak/Package.swift -o /var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/TemporaryDirectory.MvuBHz/tokamak-manifest
/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/TemporaryDirectory.MvuBHz/tokamak-manifest -fileno 7 sandbox-exec -p '(version 1)
(deny default)
(import "system.sb")
(allow file-read*)
(allow process*)
(allow sysctl*)
(allow file-write*
    (regex #"^/private/var/tmp/org\.llvm\.clang.*")
    (regex #"^/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/org\.llvm\.clang.*")
    (regex #"^/private/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/T/org\.llvm\.clang.*")
    (regex #"^/private/var/folders/r4/5d00qxmn0rz1v00hb9lv3fdr0000gn/C/org\.llvm\.clang.*")
    (subpath "/Users/maxd/Documents/Tokamak/.build")
)
'
/Users/maxd/Documents/Tokamak: error: manifest parse error(s):
<unknown>

Note that I'm using 2020-06-13-a snapshot in the above output, that's the oldest snapshot where the issue is reproduced. 2020-06-12-a snapshot is working fine. I've also tried to compile the manifest file separately by 2020-06-13-a and 2020-06-12-a versions of the compiler, but using the same version of the libPackageDescription.dylib module from either 2020-06-13-a or 2020-06-12-a. Testing these different combinations, I think that the issues is caused by libPackageDescription.dylib that became broken in 2020-06-13-a and is still broken in the latest snapshots for both swiftwasm-release/5.3 and swiftwasm branches. Looking at file sizes, we can also see that something happened to the library that significantly changed its binary size starting with the 2020-06-13-a snapshot:

892K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-11-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
892K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-12-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
752K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-13-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
756K	/Users/maxd/.swiftenv/versions/swift-wasm-5.3-SNAPSHOT-2020-07-03-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib
752K	/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-06-22-a/usr/lib/swift/pm/4_2/libPackageDescription.dylib

There don't seem to be any changes between 2020-06-12-a and 2020-06-13-a in the SwiftPM itself, I think something changed in the compiler that made it miscompile the library.

I'm going to research this further, need to investigate what exactly is different between those two compiler versions and how to fix it.

Originally posted by @MaxDesiatov in #1362 (comment)

@MaxDesiatov MaxDesiatov added the bug Something isn't working label Jul 3, 2020
MaxDesiatov added a commit that referenced this issue Jul 6, 2020
MaxDesiatov added a commit that referenced this issue Jul 7, 2020
Build both host and target toolchains on CI

Both `libPackageDescription.dylib` and `swiftc` used to compile package manifests should come from the same toolchain for SwiftPM to work on macOS. This is resolved here by re-reverting the previous change #1024 to build both host and target toolchain in one go on CI. I'm wary of the disk space/time limit constraints, but I think those should be resolved separately when they appear, otherwise SwiftPM is completely broken on macOS currently. Resolves #1365.
MaxDesiatov added a commit that referenced this issue Jul 7, 2020
Resolves #1365.

# Conflicts:
#	utils/build-presets.ini
#	utils/webassembly/build-toolchain.sh
#	utils/webassembly/install-nightly-toolchain.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant