Building Swift Package Manager on ARM

Howdy,

I'm looking to getting the Swift Package Manager building on ARM systems
such as the BeagleBoard, and its now in the bootstrap stage, and bombs out
which what appears to be a linking error. I know that
_TMaC18PackageDescription7Package
is defined in libPackageDescription.so but its not being picked up when
Package.swift is compiled.

That issue aside, what is the meaning of the "driver-mode" option to
swiftc, and why would one invoke swiftc with --driver-mode=swift?

swiftpm: using standard linker
+ /mnt/usbms/package-swift/swiftpm/Utilities/bootstrap
--swiftc=/mnt/usbms/package-swift/build/buildbot_linux/swift-linux-armv7/bin/swiftc
--sbt=/mnt/usbms/package-swift/build/buildbot_linux/llbuild-linux-armv7/bin/swift-build-tool
--build=/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7
--xctest=/mnt/usbms/package-swift/build/buildbot_linux/xctest-linux-armv7
bootstrap: note: building stage1:
/mnt/usbms/package-swift/build/buildbot_linux/llbuild-linux-armv7/bin/swift-build-tool
-f
/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/build.swift-build
bootstrap: note: building self-hosted 'swift-build': env
SWIFTC=/mnt/usbms/package-swift/build/buildbot_linux/swift-linux-armv7/bin/swiftc
SWIFT_BUILD_TOOL=/mnt/usbms/package-swift/build/buildbot_linux/llbuild-linux-armv7/bin/swift-build-tool
SWIFT_BUILD_PATH=/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7
SWIFTPM_EMBED_RPATH=$ORIGIN/../lib/swift/linux
/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/bin/swift-build
bootstrap: note: cwd will be set to /mnt/usbms/package-swift/swiftpm
LLVM ERROR: Program used external function
'_TMaC18PackageDescription7Package' which could not be resolved!
error: ExitStatus(1,
["/mnt/usbms/package-swift/build/buildbot_linux/swift-linux-armv7/bin/swiftc",
"--driver-mode=swift", "-I",
"/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/lib/swift/pm",
"-L",
"/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/lib/swift/pm",
"-lPackageDescription", "/mnt/usbms/package-swift/swiftpm/Package.swift"])
bootstrap: error: build failed with exit status 1
./swift/utils/build-script: command terminated with a non-zero exit status
1, aborting
./swift/utils/build-script: command terminated with a non-zero exit status
1, aborting

Hi Joseph,

The driver mode option tells swiftc to "behave" like "swift" (in this case, to act as an interpreter). The reason we use that option there is so that the bootstrap script can be passed just the path to `swiftc` and not need to be passed (or derive) the path to `swift`.

The failure you are seeing is most likely because `swift` is unable to load the dynamic library associated with the PackageDescription module (which is used to load the manifest files). The way that this is *supposed* to work is:
- The manifest files have `import PackageDescription`.
- swift finds that library via the -L arguments.
- swift will try and load the dynamic library associated with the module (but currently I don't believe it is an error if the `import` succeeds but the loading of the .so fails).
- swift JITs the code for the module, which then can dynamically link with the loaded library. This is what is failing in your case.

Unfortunately the way the LLVM JIT works the exact nature of the failure isn't obvious. What you can try to do is write a simple C program which dlopen()s the PackageDescription .so and see why it is failing (or if that is in fact the issue). It is also possible that some part of this pipeline isn't working properly for Swift on Linux/ARM.

HTH,
- Daniel

ยทยทยท

On Dec 28, 2015, at 7:00 AM, Joseph Bell via swift-build-dev <swift-build-dev@swift.org> wrote:

Howdy,

I'm looking to getting the Swift Package Manager building on ARM systems such as the BeagleBoard, and its now in the bootstrap stage, and bombs out which what appears to be a linking error. I know that _TMaC18PackageDescription7Package is defined in libPackageDescription.so but its not being picked up when Package.swift is compiled.

That issue aside, what is the meaning of the "driver-mode" option to swiftc, and why would one invoke swiftc with --driver-mode=swift?

swiftpm: using standard linker
+ /mnt/usbms/package-swift/swiftpm/Utilities/bootstrap --swiftc=/mnt/usbms/package-swift/build/buildbot_linux/swift-linux-armv7/bin/swiftc --sbt=/mnt/usbms/package-swift/build/buildbot_linux/llbuild-linux-armv7/bin/swift-build-tool --build=/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7 --xctest=/mnt/usbms/package-swift/build/buildbot_linux/xctest-linux-armv7
bootstrap: note: building stage1: /mnt/usbms/package-swift/build/buildbot_linux/llbuild-linux-armv7/bin/swift-build-tool -f /mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/build.swift-build
bootstrap: note: building self-hosted 'swift-build': env SWIFTC=/mnt/usbms/package-swift/build/buildbot_linux/swift-linux-armv7/bin/swiftc SWIFT_BUILD_TOOL=/mnt/usbms/package-swift/build/buildbot_linux/llbuild-linux-armv7/bin/swift-build-tool SWIFT_BUILD_PATH=/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7 SWIFTPM_EMBED_RPATH=$ORIGIN/../lib/swift/linux /mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/bin/swift-build
bootstrap: note: cwd will be set to /mnt/usbms/package-swift/swiftpm
LLVM ERROR: Program used external function '_TMaC18PackageDescription7Package' which could not be resolved!
error: ExitStatus(1, ["/mnt/usbms/package-swift/build/buildbot_linux/swift-linux-armv7/bin/swiftc", "--driver-mode=swift", "-I", "/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/lib/swift/pm", "-L", "/mnt/usbms/package-swift/build/buildbot_linux/swiftpm-linux-armv7/.bootstrap/lib/swift/pm", "-lPackageDescription", "/mnt/usbms/package-swift/swiftpm/Package.swift"])
bootstrap: error: build failed with exit status 1
./swift/utils/build-script: command terminated with a non-zero exit status 1, aborting
./swift/utils/build-script: command terminated with a non-zero exit status 1, aborting

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev