SwiftAndroid / swift

Port of Apple's reference Swift toolchain to Android; doesn't quite work yet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lib Bionic doesn't compile

ephemer opened this issue · comments

I'm using your pre-built toolchain and I can't get swiftc-android to compile anything. It first tries to build Bionic, which doesn't work because the module map contains absolute paths:

// C standard library
  module C {
    //module complex {
    //  header "/home/zhuowei/ndk/platforms/android-16/arch-arm/usr/include/complex.h"
    //  export *
    //}
    module ctype {
      header "/home/zhuowei/ndk/platforms/android-16/arch-arm/usr/include/ctype.h"
      export *
    }

etc

After replacing these absolute paths with my own, Bionic still fails to build. It seems to be missing a lot of internal dependencies. I've tried setting C_INCLUDE_PATH=$ANDROID_NDK_HOME/platforms/android-16/arch-arm/usr/include, which gets me slightly further, as does reorganising the module map to import the C standard library first etc., but I think I'm missing a step here that will make it "just work". Any ideas?

I ended up giving on on this and just compiling the toolchain from your sources using the second-latest commit. Using your swiftc-android script, this allows me to build android binaries that run as expected, other than the segfaults detailed in #5

Not sure how we can get around the bionic issue for people who can't compile the source themselves though

I managed to compile a Hello World on a machine with the NDK at a different path, so I guess only the Bionic library is broken; I'll see what I can do with the hardcoded paths.

For the hardcoded path issue, I would probably just have swiftc-android replace the hardcoded paths with the current NDK home when you run it.

Thanks!

Yes it seems (strangely enough) that Glibc and Bionic get recompiled every
time, even if the .so binaries are in the correct /lib subfolder

Try with the latest version: run
swift androidfix
to fix the include paths.

I included the Clang headers (so the "stddef.h missing" error should go away).

The modulemap no longer uses absolute paths. Instead, it references "SYSROOT", which is sed-ed in stdlib/public/Bionic/CMakeLists.txt. So this issue should be fixed! Thanks for the fix @zhuowei!