{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/162","repository_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch","labels_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/162/comments","events_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/162/events","html_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/162","id":172962630,"number":162,"title":"Android support","user":{"login":"gonzalolarralde","id":132825,"avatar_url":"https://avatars.githubusercontent.com/u/132825?v=3","gravatar_id":"","url":"https://api.github.com/users/gonzalolarralde","html_url":"https://github.com/gonzalolarralde","followers_url":"https://api.github.com/users/gonzalolarralde/followers","following_url":"https://api.github.com/users/gonzalolarralde/following{/other_user}","gists_url":"https://api.github.com/users/gonzalolarralde/gists{/gist_id}","starred_url":"https://api.github.com/users/gonzalolarralde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonzalolarralde/subscriptions","organizations_url":"https://api.github.com/users/gonzalolarralde/orgs","repos_url":"https://api.github.com/users/gonzalolarralde/repos","events_url":"https://api.github.com/users/gonzalolarralde/events{/privacy}","received_events_url":"https://api.github.com/users/gonzalolarralde/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/labels/changes%20requested","name":"changes requested","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-24T14:11:09Z","updated_at":"2016-08-26T03:17:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/162","html_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/162","diff_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/162.diff","patch_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/162.patch"},"body":"This changeset adds support for Android cross-compilation with the same restrictions applied to `swift` project.\r\n\r\n## Options\r\n\r\n- `--disable-build-tests`: tests are failing to be built due to the lack of `spawn`. Until this is fixed, the flag will be useful to complete compilation\r\n- `--with-android-ndk`: Android NDK path to be used as a base for cross toolchain, SDK and support files.\r\n- `--with-android-ndk-gcc-version`: NDK GCC version to be used (defaults to `4.9`)\r\n- `--with-android-api-level`: API version to be used for compilation\r\n- `--enable-android`: Enabled Android cross-compilation. In this implementation, as it is being done right now in `swift`, this is enforcing `arm-linux-androideabi` `armeabi-v7a`. \r\n\r\n## Issues\r\n\r\nThere are a few things in this changeset that I'd like to iterate, assuming there are better or more generic solution that can be applied:\r\n\r\n- [x] `src/shims/android` includes: In this directory I created [`sys/sysctl.h`](https://github.com/gonzalolarralde/swift-corelibs-libdispatch/blob/android-support/src/shims/android/sys/sysctl.h) + [`syscall.h`](https://github.com/gonzalolarralde/swift-corelibs-libdispatch/blob/android-support/src/shims/android/syscall.h) to redirect headers to their locations in Android. -- *update: moved to compiler conditionals instead of include overlay. [commit](https://github.com/apple/swift-corelibs-libdispatch/pull/162/commits/e67e77f9eda8b87eca90795364e4bc4cd0839582)*\r\n- [ ] `src/shims/android` libraries: `libpthread.a` + `librt.a` are dummy libraries because of the [difference described here](https://gist.github.com/leto/663362#file-gistfile1-txt-L85). To avoid this both `libkqueue` and `libpwq` should be modified to avoid asking libtool to link against them.\r\n- [ ] [`configure.ac` and `src/Makefile.am`](https://github.com/gonzalolarralde/swift-corelibs-libdispatch/commit/2b2cb83a1810fe2f8dd37f5c64d0ce00fdcafeda): This the first time I deal with `autotools`, so I think there should be a better way to implement this. `(C|CXX|LD)FLAGS` params I think will be needed explicitly declared somewhere to enable cross compilation, but maybe in `AM_$0_FLAGS`? I think there are some overwrites in the `am` files that were causing troubles, but they can be fixed if this is the right direction. Removing flags from `ac_configure_args` like that with `sed` seems like a terrible idea, maybe both `libkqueue` and `libpwq` need to be extended somehow to support this in a better way?\r\n- [ ] and more…\r\n\r\n## Build\r\n\r\nThis is an example call to compile `libdispatch` for Android. This is similarly formatted to the call that build script in `swift` does to compile `libdispatch`.\r\n\r\n```\r\n$ sh autogen.sh\r\n$ export SWIFT_ANDROID=<...>\r\n$ export NDK_PATH=<...>\r\n$ env \\\r\nCC=\"$SWIFT_ANDROID/build/Ninja-ReleaseAssert/llvm-linux-x86_64/bin/clang\" \\\r\nCXX=\"$SWIFT_ANDROID/build/Ninja-ReleaseAssert/llvm-linux-x86_64/bin/clang++\" \\\r\nSWIFTC=\"$SWIFT_ANDROID/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc\" \\\r\n$SWIFT_ANDROID/swift-corelibs-libdispatch/configure \\\r\n--with-swift-toolchain=\"$SWIFT_ANDROID/build/Ninja-ReleaseAssert/swift-linux-x86_64/\" \\\r\n--with-build-variant=release \\\r\n--enable-android \\\r\n--host=arm-linux-androideabi \\\r\n--with-android-ndk=$NDK_PATH \\\r\n--with-android-api-level=21 \\\r\n--disable-build-tests\r\n$ make\r\n```\r\n\r\n_Side note: `va_list` issue mentioned in #155 is affecting the build process. There's no patch for that issues here, to avoid mixing problems that may be addressed in different ways._\r\n\r\n## Outcome\r\n\r\nThis compilation process creates the shared library with the following ELF header:\r\n```\r\nELF Header:\r\n  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 \r\n  Class:                             ELF32\r\n  Data:                              2's complement, little endian\r\n  Version:                           1 (current)\r\n  OS/ABI:                            UNIX - System V\r\n  ABI Version:                       0\r\n  Type:                              DYN (Shared object file)\r\n  Machine:                           ARM\r\n  Version:                           0x1\r\n  Entry point address:               0x0\r\n  Start of program headers:          52 (bytes into file)\r\n  Start of section headers:          1060700 (bytes into file)\r\n  Flags:                             0x5000200, Version5 EABI, soft-float ABI\r\n  Size of this header:               52 (bytes)\r\n  Size of program headers:           32 (bytes)\r\n  Number of program headers:         9\r\n  Size of section headers:           40 (bytes)\r\n  Number of section headers:         50\r\n  Section header string table index: 49\r\n```\r\n\r\nand dependencies\r\n```\r\n 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]\r\n 0x00000001 (NEEDED)                     Shared library: [libm.so]\r\n 0x00000001 (NEEDED)                     Shared library: [libc.so]\r\n 0x00000001 (NEEDED)                     Shared library: [libdl.so]\r\n```"},"comment":{"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/comments/242617837","html_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/162#issuecomment-242617837","issue_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/162","id":242617837,"user":{"login":"MadCoder","id":44708,"avatar_url":"https://avatars.githubusercontent.com/u/44708?v=3","gravatar_id":"","url":"https://api.github.com/users/MadCoder","html_url":"https://github.com/MadCoder","followers_url":"https://api.github.com/users/MadCoder/followers","following_url":"https://api.github.com/users/MadCoder/following{/other_user}","gists_url":"https://api.github.com/users/MadCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/MadCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MadCoder/subscriptions","organizations_url":"https://api.github.com/users/MadCoder/orgs","repos_url":"https://api.github.com/users/MadCoder/repos","events_url":"https://api.github.com/users/MadCoder/events{/privacy}","received_events_url":"https://api.github.com/users/MadCoder/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T03:17:11Z","updated_at":"2016-08-26T03:17:11Z","body":"I think the .a issue should be resolved with other upstreams.\r\n@dgrove-oss or @seabaylea or other linux porters should look at the sanity of the autoconf part, I didn't even read it that carefully."}}
{"actor":{"display_login":"MadCoder"}}