-
Notifications
You must be signed in to change notification settings - Fork 25
swift package build fail #126
Comments
I made a small tunings to Package to be able to build it successfully on macOS first. // swift-tools-version:5.4.0
import PackageDescription
let package = Package(
name: "App",
platforms: [
.macOS(.v10_15), .iOS(.v13)
],
products: [
.library(name: "App", type: .dynamic, targets: ["App"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.14.0"),
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", from: "4.0.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.0.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.2.2"),
.package(url: "https://github.com/swift-server/swift-backtrace.git", from: "1.2.1"),
.package(url: "https://github.com/vapor/multipart-kit.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/console-kit.git", from: "4.0.0"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "1.0.0"),
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.0.0"),
],
targets: [
.target( name: "App", dependencies: [
.product(name: "NIO", package: "swift-nio"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "Backtrace", package: "swift-backtrace"),
.product(name: "NIOSSL", package: "swift-nio-ssl"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "NIOWebSocket", package: "swift-nio"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
.product(name: "NIOExtras", package: "swift-nio-extras"),
.product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver"),
.product(name: "MultipartKit", package: "multipart-kit"),
.product(name: "ConsoleKit", package: "console-kit"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "WebSocketKit", package: "websocket-kit"),
]
)
]
) // File: Sources/App/Dummy.swift
function noop() {
} Then I'm launched android build as shown below. Note, that you have to use Android API 24 to have /.../swift-android-toolchain/usr/bin/swift-build-aarch64-linux-android -v -Xcc -D__ANDROID_API__=24 After that I am corrected few files (e.g. // Before
import Dispatch
#if os(Linux)
import Glibc
#else
import Darwin.C
#endif
// After
import Dispatch
#if os(Linux) || os(Android)
import Glibc
#else
import Darwin.C
#endif
// Or even better
import Dispatch
#if canImport(Glibc)
import Glibc
#else
import Darwin.C
#endif Particularly in file // Before
internal struct StdioOutputStream: TextOutputStream {
#if canImport(WASILibc)
internal let file: OpaquePointer
#else
internal let file: UnsafeMutablePointer<FILE>
#endif
internal let flushMode: FlushMode
// After
internal struct StdioOutputStream: TextOutputStream {
#if canImport(WASILibc) || canImport(Glibc)
internal let file: OpaquePointer
#else
internal let file: UnsafeMutablePointer<FILE>
#endif
internal let flushMode: FlushMode Now build fails due missed sqlite header |
As far as I understand the sqlite for Android needs to be build separately and included into APK manually by developer. I can't find For issues about See also: |
I was doing some investigation about problem with |
while building https://github.com/apple/swift-nio-ssl same error
|
I think this is a bug in the Swift ClangImporter that it can't handle opaque structs, been meaning to look into it and file a bug. I hit that nio-ssl issue too which is why I disabled building it on my daily Android CI. A workaround for Android is to pass in |
Never mind, I guess Swift chooses not to handle this, as Vlad says above, so you will have to change it to |
Interesting. I didn't know about that Clang/Swift behaviour with |
I've submitted patches for this in apple/swift-nio-ssl#306 and swiftlang/swift-tools-support-core#243. You may want to do the same for |
|
hello @vgorloff , @buttaface . error while building for swift-build-arm-linux-androideabi |
It says duplicate symbols in the same file, for C and ARMv7 assembly: maybe you're missing some C define that normally picks one or the other? I regularly build those files for ARMv7 on my daily Android CI without a problem and occasionally run that Swift package's ARMv7 tests without a problem. If you run in verbose mode and paste the compilation command for one of those broken C/asm files, I can compare with my working clang command and let you know. |
Hmm, there is only a single definition in those files, so C defines are not the issue. You may need to examine those object files and see what's going on: what does |
try build this https://github.com/apple/swift-crypto.git package for swift-build-arm-linux-androideabi. this problem in this package |
I do, that package is built separately for armv7 on my Android CI that runs on Ubuntu every day without a problem. If you can reproduce when building that package alone with the Swift package manager, try adding the verbose flag I will compare it to my working build and let you know of any differences. |
Oh wait, I see it now, the paths are different. You are linking the same file from You may need to look into keeping those build artifacts separate or excising one of those packages. Also, there's nothing specific to Android here: make sure this project builds on Linux, which will be easier to debug for these SPM packaging issues, then you can try Android. |
The text was updated successfully, but these errors were encountered: