Hi @zhuowei. I have been (somewhat verbosely) documenting my progress getting 
your SwiftAndroid build working on the reddit thread here 
https://www.reddit.com/r/swift/comments/3w0xrd/im_patching_the_opensource_swift_compiler_to/
 
<https://www.reddit.com/r/swift/comments/3w0xrd/im_patching_the_opensource_swift_compiler_to/>
 (as ephemer9). Given that I’ve now worked through a lot of issues, I think 
together we can make this build repeatable for everyone (that is if you need my 
help at all - you seem to be doing a mighty fine job yourself so far). What I’d 
like to do is work on the JNI integration part of this. Before I can though, I 
have to get through a few problems here still:

After dealing with the dependency issues (see reddit), the SwiftAndroid build 
finally completed. It had plenty of warnings along the way, but in the end I 
was left with binaries that seemed to do something. I was then able to use 
swiftc to compile for linux x86_64 as usual. I couldn't figure out how to 
cross-compile to armv7 though. This is what I tried:

    swiftc -target armv7-none-linux-androideabi -target-cpu armv7 test.swift

This unfortunately produces a segfault on my machine: "<unknown>:0: error: the 
clang compiler does not support '-mcpu=armv7'"

Removing -target-cpu from the `swiftc` call leads to an error about missing 
`swift.ld` for architecture x86_64. It is looking under android/x86_64 - I 
symlinked the linker file from android/armv7 into that path and got this 
instead:

    me@linuxbox:~# swiftc -target armv7-none-linux-androideabi test.swift 
-vSwift version 2.2-dev (LLVM 7bae82deaa, Clang 53d04af5ce, Swift 65921fc110)
    Target: armv7-none-linux-android
    /me/swift/build/Ninja-Release/swift-linux-x86_64/bin/swift -frontend -c 
-primary-file test.swift -target armv7-none-linux-android -disable-objc-interop 
-color-diagnostics -module-name test -o /tmp/test-706f67.o
    /me/swift/build/Ninja-Release/swift-linux-x86_64/bin/swift-autolink-extract 
/tmp/test-706f67.o -o /tmp/test-58bef6.autolink
    /usr/bin/clang++ /tmp/test-706f67.o -L 
/me/swift/build/Ninja-Release/swift-linux-x86_64/lib/swift/android -Xlinker 
-rpath -Xlinker 
/me/swift/build/Ninja-Release/swift-linux-x86_64/lib/swift/android -lswiftCore 
@/tmp/test-58bef6.autolink -Xlinker -T 
/me/swift/build/Ninja-Release/swift-linux-x86_64/lib/swift/android/x86_64/swift.ld
 -o test
    /usr/bin/ld: /tmp/test-706f67.o: Relocations in generic ELF (EM: 40)
    /usr/bin/ld: /tmp/test-706f67.o: Relocations in generic ELF (EM: 40)
    /tmp/test-706f67.o: error adding symbols: File in wrong format
    clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
    <unknown>:0: error: link command failed with exit code 1 (use -v to see 
invocation)

I’m assuming this is because it’s trying to link the armv7 binary with the 
x86_64 standard library or something illogical like that. In any case I’m a 
little stuck now as to how to proceed. Given that clang is telling me it 
doesn’t support armv7, I imagine I’m just entering the wrong arguments for 
swiftc. Or do I have to make LLVM-IR first and link using the android toolchain 
for now? Can you or anyone else give me an idea as to how to cross-compile 
using swiftc?

Many thanks,
Geordie

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

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

Reply via email to