SwiftAndroid / swift

Port of Apple's reference Swift toolchain to Android; doesn't quite work yet
Apache License 2.0
720 stars 32 forks source link

Lib Bionic doesn't compile #4

Closed ephemer closed 8 years ago

ephemer commented 8 years ago

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?

ephemer commented 8 years ago

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

zhuowei commented 8 years ago

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!

ephemer commented 8 years ago

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

zhuowei commented 8 years ago

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).

modocache commented 8 years ago

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!