Trying to install swiftpm on Pop!_OS 19.04

I have been able to install swift, lldb, llbuild, foundation, and libdispatch. Using the following command:

python2 swift/utils/build-script -R --llvm-max-parallel-lto-link-jobs 2 --swift-tools-max-parallel-lto-link-jobs 2 -j 16 --extra-cmake-options="-DPYTHON_EXECUTABLE=/usr/bin/python2" --lldb --llbuild --foundation --libdispatch

However, adding --swiftpm to this causes a lot of failures. Basically, I needed to install all of the packages such that I have the following directory /usr/lib/swift/linux. Then I place sym-links so everything is available in build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/linux. After a lot of tinkering I finally got to the common denominator:

strace -f -o strace.txt /home/bmooreii/src/swift/swiftpm/Utilities/bootstrap --release --swiftc=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc --sbt=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/llbuild-linux-x86_64/bin/swift-build-tool --build=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64 --link-llbuild --llbuild-source-dir=/home/bmooreii/src/swift/llbuild --llbuild-build-dir=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/llbuild-linux-x86_64 --foundation=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/foundation-linux-x86_64 --libdispatch-source-dir=/home/bmooreii/src/swift/swift-corelibs-libdispatch --libdispatch-build-dir=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64

Error:

--- bootstrap: note: building runtime v4 target: PackageDescription4: 
--- bootstrap: note: building runtime v4_2 target: PackageDescription4: 
--- bootstrap: note: building stage1
--- bootstrap: note: building self-hosted 'swift-build': env SWIFT_EXEC=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64/x86_64-unknown-linux/release/swiftc SWIFTPM_BUILD_DIR=/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64 SWIFTPM_BOOTSTRAP=1 /home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64/x86_64-unknown-linux/release/swift-build-stage1 --disable-sandbox -Xlinker -rpath -Xlinker $ORIGIN/../lib/swift/linux -Xswiftc -Xcc -Xswiftc -DSPM_BUILD_IDENT=9c5a13ae -Xswiftc -I/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/llbuild-linux-x86_64/products/llbuildSwift -Xswiftc -I/home/bmooreii/src/swift/llbuild/products/libllbuild/include -Xlinker -rpath -Xlinker $ORIGIN/../lib/swift/pm/llbuild -Xlinker -L/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/llbuild-linux-x86_64/lib -Xlinker -rpath -Xlinker /home/bmooreii/src/swift/build/Ninja-ReleaseAssert/llbuild-linux-x86_64/lib -Xswiftc -enable-testing --configuration release --build-tests
/home/bmooreii/src/swift/swiftpm: error: manifest parse error(s):
<unknown>:0: error: cannot load underlying module for 'Dispatch'
--- bootstrap: error: build failed with exit status 1

Which yields the following strace output:

22493 unlink("/tmp/TemporaryFile.FaKCGo") = 0
22493 futex(0x7fa83a42c740, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22493 futex(0x7fa83a42c708, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22493 close(7)                          = 0
22493 pwrite64(6, "\0\0\0\2", 4, 8720)  = 4
22493 pwrite64(6, "\r\0\0\0\1\17\366\0\17\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 8724) = 4096
22493 pwrite64(6, "\236<\247\261", 4, 12820) = 4
22493 pwrite64(6, "\0\0\0\1", 4, 12824) = 4
22493 pwrite64(6, "SQLite format 3\0\20\0\1\1\0@  \0\0\0\f\0\0\0\6"..., 4096, 12828) = 4096
22493 pwrite64(6, "\236<\250\277", 4, 16924) = 4
22493 pread64(6, "", 8, 17408)          = 0
22493 fdatasync(6)                      = 0
22493 openat(AT_FDCWD, "/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64", O_RDONLY|O_CLOEXEC) = 7
22493 fdatasync(7)                      = 0
22493 close(7)                          = 0
22493 pwrite64(6, "\331\325\5\371 \241c\327\0\0\0\4", 12, 0) = 12
22493 fdatasync(6)                      = 0
22493 pwrite64(5, "SQLite format 3\0\20\0\1\1\0@  \0\0\0\r\0\0\0\6"..., 4096, 0) = 4096
22493 pwrite64(5, "\r\0\0\0\1\17\366\0\17\366\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 4096) = 4096
22493 pwrite64(5, "\r\1s\0\4\1D\2\17W\1D\3\364\1\371\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 16384) = 4096
22493 pwrite64(5, "\n\0\0\0\4\17\352\0\17\374\17\366\17\360\17\352\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 20480) = 4096
22493 fdatasync(5)                      = 0
22493 close(6)                          = 0
22313 unlink("/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64/manifest.db-journal") = 0
22313 fcntl(5, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
22313 fcntl(5, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=2}) = 0
22313 fcntl(5, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
22313 stat("/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64/manifest.db", {st_mode=S_IFREG|0644, st_size=24576, ...}) = 0
22313 fstat(5, {st_mode=S_IFREG|0644, st_size=24576, ...}) = 0
22313 stat("/home/bmooreii/src/swift/build/Ninja-ReleaseAssert/swiftpm-linux-x86_64/manifest.db", {st_mode=S_IFREG|0644, st_size=24576, ...}) = 0
22313 close(5)                          = 0
22313 futex(0x564a3cfa17c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfad5d8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfad658, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cf97808, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cf97888, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfb2120, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
22313 futex(0x7fec04fef7f8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fef8f8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fef878, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 ioctl(1, TIOCGWINSZ, {ws_row=45, ws_col=158, ws_xpixel=0, ws_ypixel=0}) = 0
22313 futex(0x564a3cf94eb0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 write(2, "/home/bmooreii/src/swift/swiftpm", 32) = 32
22313 write(2, ": ", 2)                 = 2
22313 write(2, "\33[31m\33[1merror: \33[0m", 20) = 20
22313 write(2, "manifest parse error(s):\n<unknow"..., 89) = 89
22313 write(2, "\n", 1)                 = 1
22313 futex(0x7fec04ff2530, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe07e8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe0768, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fed078, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fecff8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfa8948, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfa88c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe1ae8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe9df8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe1c68, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe9f78, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfa5ce8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfa5d68, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x7fec04fe9e78, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cf9eb20, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaaa48, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaaac8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaa848, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaa8c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaac48, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaacc8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaa648, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfaa6c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 futex(0x564a3cfad8d8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
22313 exit_group(1)                     = ?
22314 <... read resumed> <unfinished ...>) = ?
22314 +++ exited with 1 +++
22313 +++ exited with 1 +++
22239 <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 22313
22239 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=22313, si_uid=1000, si_status=1, si_utime=5, si_stime=1} ---
22239 write(1, "--- bootstrap: error: build fail"..., 54) = 54
22239 rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f61d0b00f60}, {sa_handler=0x5f0ee0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f61d0b00f60}, 8) = 0
22239 sigaltstack(NULL, {ss_sp=0x1fe4270, ss_flags=0, ss_size=8192}) = 0
22239 sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}, NULL) = 0
22239 exit_group(1)                     = ?
22239 +++ exited with 1 +++

I have worked through many of my errors simply by looking at straces, but I am lost on this one. I am wondering if it has something to do with SQLite because of this manifest.db output, but I really don't have a clue. Any thoughts are appreciated.

Heh, you should have asked on here before you spent so much time on it. I believe it's because you left out XCTest from your build-script invocation, ie --xctest should be there too if you want to build SwiftPM. This is because the SwiftPM bootstrap script looks for the XCTest path before setting up an internal directory with a bunch of symlinks to all the required shared libraries, such as libdispatch and Foundation, and will simply fall down if you don't add --xctest -b anytime you want to build SwiftPM. I discovered this while trying to build SwiftPM on Arch linux earlier this year, works ever since.

1 Like

I'll try this when I get home! :crossed_fingers:

Yup, @Buttaface is correct. Adding that worked. Seems like --swiftpm should imply the things it needs...

Terms of Service

Privacy Policy

Cookie Policy