Bitcoin core build on Android NDK #11844

issue laanwj openend this issue on December 7, 2017
  1. laanwj commented at 12:02 pm on December 7, 2017: member

    It would be useful to have support for building against the Android NDK in the repository as well as the depends system.

    Greenaddress is currently doing this and has scripts and patches for doing so in a separate repository.

    Integrating this into the upstream build would likely be more maintainable, and it would make it possible to make the ndk build part of the gitian build set at some point, providing higher reassurance for the Android executables.

    (sister issue for iOS is #11720)

  2. laanwj added the label Build system on Dec 7, 2017
  3. greenaddress commented at 12:16 pm on December 7, 2017: contributor

    Thanks @laanwj

    Some things of note:

    • Android deprecated gcc a while back, will be removed entirely eventually so good to use clang
    • the currently working build hasn’t been investigated/benchmarked/optimized yet
    • It uses android ndk r14b as the latest doesn’t work (r16, can see a branch here, build failures once travis is done building will be here )
    • Targets android 21 (lollipop) +. Below that you need many more hacks to build as some functions are not present
  4. laanwj added the label help wanted on Dec 7, 2017
  5. greenaddress commented at 1:21 pm on December 7, 2017: contributor

    ndk r16 works on:

    aarch_64, x86_64

    fails on: arm, x86

    from https://travis-ci.org/greenaddress/bitcoin_ndk/builds/312924976?utm_source=github_status&utm_medium=notification

    /opt/arm-linux-androideabi-clang/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../include/c++/4.9.x/fstream:826:20: error: use of undeclared identifier ‘ftello’

    from a quick investigation this seems an issue with the ndk and the work around is to not set D_FILE_OFFSET_BITS=64 (but I couldn’t see an easy way to do it yet)

  6. greenaddress commented at 2:26 pm on December 13, 2017: contributor
    not setting FILE_OFFSET_BITS in core is not sufficient, I believe zlib is also enabling it (or maybe boost, not sure)
  7. jonasschnelli commented at 7:04 pm on December 13, 2017: contributor
    +1 for an Android build support
  8. greenaddress commented at 10:45 am on December 14, 2017: contributor
    looks like not building the samples for libevent is already in master (thanks @fanquake) so the set of patches needed is less going forward (hopefully at least!)
  9. greenaddress commented at 2:22 pm on January 31, 2018: contributor

    I’ve updated the bitcoin_ndk repo with a new branch for the 0.16 release candidate.

    Had to modify the patch to take into account the 0.16 changes but so far looking good https://github.com/greenaddress/bitcoin_ndk/tree/core_0.16 and smaller patches (which is great)

  10. laanwj commented at 7:48 am on February 1, 2018: member
    Great! Also good to hear that the required amount of patching is less for 0.16.
  11. tofutim commented at 2:25 pm on April 11, 2018: none
    Just curious if this is working now.
  12. laanwj commented at 2:34 pm on April 11, 2018: member
    Not with this repository, that’s why the issue is still open. If you want to play with this, you need @greenaddress ’s stuff he links above.
  13. tofutim commented at 2:53 pm on April 11, 2018: none
    @greenaddress, do you have a gitian-descriptor for android ndk I can experiment with?
  14. greenaddress commented at 10:38 am on June 17, 2018: contributor
    @tofutim sorry just saw this. No I don’t have gitian-descriptor. Ideally it would have one but really I wanted to make sure we could use the latest NDK (still on r14b because of 32bit archs failing on later versions) and upstream necessary changes where possible. Right now I’m in the process of refreshing to 0.16.1 and at least build the 64 bit arch with r17b
  15. greenaddress commented at 3:46 pm on June 17, 2018: contributor

    @laanwj I updated to 0.16.1 and managed to upgrade to latest ndk compiler (r17b) for both 32/64 bit by passing ac_cv_sys_file_offset_bits accordingly.

    I also had to hack zmq depend because of tautological-constant-compare and new compiler (patch is from zmq upstream)

    See https://github.com/greenaddress/bitcoin_ndk/commit/a925df4caa94abdac8727dfac1df191bc2c89277

  16. fanquake commented at 11:52 pm on June 17, 2018: member
    For reference this is the upstream zmq patch https://github.com/zeromq/libzmq/pull/3140. @greenaddress Did you want to try and incorporate some of your work back into this repository?
  17. greenaddress commented at 9:23 am on June 19, 2018: contributor

    @fanquake eventually yes, with some guidance from you and others :)

    For the ZMQ patch since it is upstream I don’t think we need to do anything other than wait until it trickles down in a stable release we move to? Also, I checked the latest update in the one we use in bitcoin core master and still suffers from the tautological-constant-compare Error (in zmq depends).

    Actually I think the actual issue there is that we are not passing through/overriding depends compile flags when we build depends libraries but we do set tautological-constant-compare as a warning when we build bitcoin core. If we were to pass through/override depends CFLAGS/CPPFLAGS then we wouldn’t even need the ZMQ patch.

  18. fanquake commented at 1:53 pm on June 19, 2018: member

    @greenaddress we are already applying patches for zeromq in depends, so if we need to pull that patch in to fix a build issue, that isn’t a problem.

    Given that zeromq/libzmq#3140 was only merged recently, I’d assume it’ll be part of zmq 4.2.6 if/when that’s released. However, a zeromq bump in the 0.16.x branch is pretty unlikely now, so just pulling that patch into depends is probably the best approach.

  19. greenaddress commented at 1:51 pm on July 18, 2018: contributor

    @theuni In https://github.com/greenaddress/bitcoin_ndk I have patches required for 0.16.1 (and 0.16.2rc2 for that matter) to build bitcoind using NDK latest (r17b) on arm/x86 32/64 bit both.

    It has patches for depends, adds ifaddrs (missing on android) and patches leveldb fread/write/flush_unlocked to fread/write/flush. It also has the ZMQ fix for tautological constant compare directly from upstream (which, as you suggested, in bitcoin master already could be avoided by using –disable-Werror though that’s more impactful)

    What do you think, if anything, that we should try to backport either into core or even upstream as applicable?

    By the way, if you have other ideas (like –disable-Werror) or comments about the patches that would improve them or simplify them I am keen on feedback!

  20. greenaddress commented at 1:54 pm on July 18, 2018: contributor

    @fanquake I raised #13689 for the zmq patches (changed from patching in the disabling of tautological constant compare to patch in disabling of Werror as per @theuni feedback)

    Note: the –disable-Werror can only be used in master/0.17.x because we use 4.2.3 zmq, in 0.16,{1,2} we use 4.2.2 which doesn’t support –disable-Werror.

  21. theuni commented at 5:37 pm on July 19, 2018: member

    @greenaddress I took a look at the ndk patches, a few quick notes:

    • #13689 should be good to go
    • #13659 should have fixed the leveldb build for android, I assume you can drop the fread patches now.
    • The libevent patch is annoying to have to carry, but looks good
    • I’d prefer to just drop the use of ifaddrs if unsupported by android (api level < 24) by adding an autoconf check for getifaddrs
  22. MarcoFalke referenced this in commit 8c36432791 on Jul 19, 2018
  23. theuni commented at 6:22 pm on July 19, 2018: member
  24. greenaddress commented at 6:07 pm on July 20, 2018: contributor

    @theuni

    great, thanks a ton!

    Looks like #13659 leveldb fixes works fine https://travis-ci.org/greenaddress/bitcoin_ndk/builds/406349358 thanks for fixing that (at least for 0.17.x/master, for 0.16.2 that wasn’t back ported)

    https://github.com/theuni/bitcoin/commit/6c32dd097755595025f6a94551d77d76cdff2569 also looks much better to me, and it works too - would that be a candidate for merge in master? want me to raise a PR for it?

    Can’t wait to make the bitcoin_ndk repo unnecessary and looks like we are on the right path :) see branch https://github.com/greenaddress/bitcoin_ndk/tree/v0.17.0_master

  25. greenaddress commented at 6:11 pm on July 20, 2018: contributor
    @theuni also, what about the host depends patches for default and linux i.e. https://github.com/greenaddress/bitcoin_ndk/blob/v0.17.0_master/0001-android-patches.patch ? is there a better way to handle that or anything to do a PR in master for?
  26. greenaddress commented at 9:24 am on August 23, 2018: contributor
  27. MarcoFalke added the label good first issue on Nov 5, 2018
  28. MarcoFalke removed the label help wanted on Nov 5, 2018
  29. BlockMechanic commented at 8:30 am on August 17, 2019: contributor

    @greenaddress I took a look at the ndk patches, a few quick notes:

    • #13689 should be good to go
    • #13659 should have fixed the leveldb build for android, I assume you can drop the fread patches now.
    • The libevent patch is annoying to have to carry, but looks good
    • I’d prefer to just drop the use of ifaddrs if unsupported by android (api level < 24) by adding an autoconf check for getifaddrs

    Hi, while building for both android arm64-v8a and arm-v7a i noted that in the ifaddrs.h provided by the ndk , it states that

    Are only supported by ANDROID_API__ >= 24

  30. laanwj added the label Android on Sep 30, 2019
  31. laanwj referenced this in commit 91fbcf41b3 on Nov 4, 2019
  32. sidhujag referenced this in commit d03d72fdae on Nov 7, 2019
  33. RdeWilde commented at 1:33 pm on January 14, 2020: none
    Is this still in the picture?
  34. hebasto commented at 8:09 am on January 30, 2020: member
    Does the merged #16110 close this issue?
  35. MarcoFalke removed the label good first issue on Jan 30, 2020
  36. MarcoFalke commented at 10:27 pm on May 8, 2020: member
    Closing for now. Not sure if anything is left to do here after #16110. Please reopen if I missed something.
  37. MarcoFalke closed this on May 8, 2020

  38. PastaPastaPasta referenced this in commit bcdd83da7c on Jun 9, 2020
  39. PastaPastaPasta referenced this in commit 274911cbb9 on Jun 9, 2020
  40. PastaPastaPasta referenced this in commit 7b0df1dd89 on Jun 10, 2020
  41. PastaPastaPasta referenced this in commit e9d78ed017 on Jun 10, 2020
  42. PastaPastaPasta referenced this in commit cd96e52b4d on Jun 11, 2020
  43. PastaPastaPasta referenced this in commit 1ee1074e22 on Jun 11, 2020
  44. PastaPastaPasta referenced this in commit b31cb3a365 on Jun 12, 2020
  45. PastaPastaPasta referenced this in commit e84e74cab5 on Jun 14, 2020
  46. sidhujag referenced this in commit f98621b111 on Nov 10, 2020
  47. gades referenced this in commit 25565e3b1e on Jun 24, 2021
  48. CryptoCentric referenced this in commit 7d0e2fe99b on Jul 2, 2021
  49. MarcoFalke locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me