With 6.4.0-1, swift build on SwiftPM's new default engine (swiftbuild) fails for any package that depends on one using package access (swift-log, swift-crypto, …):
error: the package access level used on 'Lock' requires a package name; set it with the compiler flag -package-name
It's caused by how this package lays out the toolchain, not by Swift itself. swiftbuild assumes the toolchain's root directory is named usr. This PKGBUILD copies the tarball's usr/* into /usr/lib/swift/, so the root is named swift. swiftbuild then looks for its files in a nonexistent place (/usr/lib/usr/lib/swift/... shows up in the failing command lines), silently drops -package-name, and the build fails.
I tested this with the same swift-6.4.0-RELEASE-ubi10.tar.gz and a minimal package that depends only on swift-log:
- Tarball's
usr/left as-is: builds, including whenswiftis called through a symlink. - Tarball's
usr/renamed to anything else (e.g.foo/), nothing else changed: fails. - Tarball's
usr/*flattened into<prefix>/lib/swift/, as this PKGBUILD does: fails. - Tarball's
usr/kept intact at<prefix>/lib/swift/usr/and symlinked into a bin dir: builds.
Could the package keep the usr directory? I built 6.4.0-2 locally with this change, and both the minimal package and a real project (CodexBar) then compile on the default engine:
- cp -Ppr "${srcdir}/swift-$pkgver-RELEASE-ubi10${_archsuffix}"/usr/* "${pkgdir}/usr/lib/swift"
+ cp -Ppr "${srcdir}/swift-$pkgver-RELEASE-ubi10${_archsuffix}"/usr "${pkgdir}/usr/lib/swift/usr"
...
- ln -s "/usr/lib/swift/bin/$bin" "${pkgdir}/usr/bin/$bin"
+ ln -s "/usr/lib/swift/usr/bin/$bin" "${pkgdir}/usr/bin/$bin"
...
- echo '/usr/lib/swift/lib/swift/linux' >> "${pkgdir}/etc/ld.so.conf.d/swift.conf"
+ echo '/usr/lib/swift/usr/lib/swift/linux' >> "${pkgdir}/etc/ld.so.conf.d/swift.conf"
find_elf_only searches /usr/lib/swift recursively, so the patchelf step still finds everything. Anything that hardcodes /usr/lib/swift/bin/ would need updating.
Caveat for anyone moving to the new engine: even with the layout fixed, swift build --static-swift-stdlib on swiftbuild fails at the final link for anything that uses Foundation (undefined reference to 'CFStringCreateWithCString', …). That bug is upstream in Swift 6.4.0, not in this package (swift-build#1764). It has been fixed and backported for 6.4.2. Until then, static builds need --build-system native, or need to link the Swift runtime dynamically instead.
Workaround for both issues until then: swift build --build-system native.
Pinned Comments