build: remove -bind_at_load usage #28783

pull fanquake wants to merge 2 commits into bitcoin:master from fanquake:remove_bind_at_load changing 2 files +15 −5
  1. fanquake commented at 3:13 pm on November 3, 2023: member

    This is deprecated on macOS:

    0ld: warning: -bind_at_load is deprecated on macOS
    

    and likely redundant anyways, given the behaviour of dyld3.

    Unfortunately libtool is still injecting a -bind_at_load, because it’s version check is broken:

    0	# Don't allow lazy linking, it breaks C++ global constructors
    1	# But is supposedly fixed on 10.4 or later (yay!).
    2	if test CXX = "$tagname"; then
    3	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
    4	    10.[0123])
    5	      func_append compile_command " $wl-bind_at_load"
    6	      func_append finalize_command " $wl-bind_at_load"
    7	    ;;
    8	  esac
    9	fi
    

    so this adds another change to strip them out at the end of configure.

    Note that anywhere the ld64 warnings are being emitted, we are already not adding this flag to our hardened ldflags, because of -Wl,-fatal_warnings.

  2. DrahtBot commented at 3:13 pm on November 3, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theuni, hebasto

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Build system on Nov 3, 2023
  4. fanquake commented at 3:13 pm on November 3, 2023: member
    @theuni @TheCharlatan you might have some libtool ideas? Couldn’t see too anything obvious to prune this out.
  5. theuni commented at 4:23 pm on November 3, 2023: member
    Yuck. The only thing I can think of is a sledgehammer hack similar to this ancient one: a98356fee8a44d7d1cb37f22c876fff8f244365e
  6. theuni commented at 4:49 pm on November 3, 2023: member

    Yuck. The only thing I can think of is a sledgehammer hack similar to this ancient one: a98356f

    See https://github.com/theuni/bitcoin/commit/c61c9c5c772780be95ba7a8221ea13a72fe97d99 which is ugly but seems to work as intended.

  7. fanquake force-pushed on Nov 8, 2023
  8. fanquake commented at 10:28 am on November 8, 2023: member

    See https://github.com/theuni/bitcoin/commit/c61c9c5c772780be95ba7a8221ea13a72fe97d99 which is ugly but seems to work as intended.

    I do hate sed. Pulled this is for now, but open to any other approaches if anyone has suggestions.

    One other point is that last time I looked, lld only implemented a placeholder option for -bind_at_load, and I’d assume at this point, they won’t bother actually implementing it, so after #21778 this flag will be even more of a no-op.

  9. fanquake commented at 10:47 am on November 8, 2023: member

    Guix Build (arm64):

    0cf3250e32cf25ee1a75372bed2fb105fc893abd40662ed60b6376cd1f77586a1  guix-build-144deffe35b7/output/arm64-apple-darwin/SHA256SUMS.part
    111a505365063b6234a8e205e3b30a5a7a9bb1b1cc6bf266b5038b18474edbd1f  guix-build-144deffe35b7/output/arm64-apple-darwin/bitcoin-144deffe35b7-arm64-apple-darwin-unsigned.tar.gz
    2674f71f6c59e064e8f42a2f11c2406fea08873b6369b472f9662e8ee0c5567e4  guix-build-144deffe35b7/output/arm64-apple-darwin/bitcoin-144deffe35b7-arm64-apple-darwin-unsigned.zip
    3c6fe023ee5e7fdcec8b42a4ac77c6303daf0b2fa61022009fb87e440f8e43a6a  guix-build-144deffe35b7/output/arm64-apple-darwin/bitcoin-144deffe35b7-arm64-apple-darwin.tar.gz
    4f7658c6b212e04b6ced4afb471abca6eece9763ec9b912004ecf0b2f9c2bb7d8  guix-build-144deffe35b7/output/dist-archive/bitcoin-144deffe35b7.tar.gz
    5d0e86a3eedbe3e944df7282936994d755580e69a4d7c7bd7fb4350e3bf670f81  guix-build-144deffe35b7/output/x86_64-apple-darwin/SHA256SUMS.part
    67839a306c6fe7113b0fb390b11799903857594ac5b22ce92c77baca7f28adbdc  guix-build-144deffe35b7/output/x86_64-apple-darwin/bitcoin-144deffe35b7-x86_64-apple-darwin-unsigned.tar.gz
    794edf9895f2d176810ed8025c779d11106a2176fe2dd7b331a34c99c30fb0a4a  guix-build-144deffe35b7/output/x86_64-apple-darwin/bitcoin-144deffe35b7-x86_64-apple-darwin-unsigned.zip
    849441bbef48c0abc1ce7eba15cba9dc3562f8ab6e4cd402984f7c10849361dbf  guix-build-144deffe35b7/output/x86_64-apple-darwin/bitcoin-144deffe35b7-x86_64-apple-darwin.tar.gz
    
  10. theuni commented at 5:04 pm on November 9, 2023: member

    utACK.

    Whoops, I butchered that commit message. I forgot to paste in the commit hash I was referencing. Mind fixing it up?

  11. build: remove -bind_at_load usage
    This is deprecated on macOS:
    ```bash
    ld: warning: -bind_at_load is deprecated on macOS
    ```
    and likely redundant anyways, given the behaviour of dyld3.
    
    Unfortunately libtool is still injecting a `-bind_at_load`:
    ```bash
    	# Don't allow lazy linking, it breaks C++ global constructors
    	# But is supposedly fixed on 10.4 or later (yay!).
    	if test CXX = "$tagname"; then
    	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
    	    10.[0123])
    	      func_append compile_command " $wl-bind_at_load"
    	      func_append finalize_command " $wl-bind_at_load"
    	    ;;
    	  esac
    	fi
    ```
    so this doesn't remove all the warnings, but removes us as a potential
    source of them.
    
    Note that anywhere the ld64 warnings are being emitted, we are already
    not adding this flag to our hardened ldflags, because of `-Wl,-fatal_warnings`.
    45257601da
  12. fanquake commented at 5:08 pm on November 9, 2023: member

    I forgot to paste in the commit hash I was referencing. Mind fixing it up?

    Pretty sure it is there? “Similar to a98356fee8a44d7d1cb37f22c876fff8f244365e.”

  13. theuni commented at 5:13 pm on November 9, 2023: member

    I forgot to paste in the commit hash I was referencing. Mind fixing it up?

    Pretty sure it is there? “Similar to a98356f.”

    “build: Add an old hack similar to remove bind_at_load from libtool.” -> “build: Add an old hack to remove bind_at_load from libtool.”

    I clearly copied “similar to” from one place to another and forgot to delete the first :)

  14. build: Add an old hack to remove bind_at_load from libtool.
    Similar to a98356fee8a44d7d1cb37f22c876fff8f244365e.
    3c61c60b90
  15. fanquake force-pushed on Nov 9, 2023
  16. maflcko added the label DrahtBot Guix build requested on Nov 13, 2023
  17. Sjors commented at 11:44 am on November 13, 2023: member

    On Intel macOS 13.6 before this PR I get the warning 6 times:

     0./configure --with-gui --enable-wallet --disable-fuzz-binary --disable-bench --disable-tests
     1...
     2checking whether the linker accepts -Wl,-bind_at_load... no
     3...
     4make
     5...
     6  CXXLD    bitcoin-wallet
     7ld: warning: -single_module is obsolete
     8  CXXLD    bitcoin-util
     9ld: warning: -bind_at_load is deprecated on macOS
    10ld: warning: -bind_at_load is deprecated on macOS
    11ld: warning: -bind_at_load is deprecated on macOS
    12ld: warning: -bind_at_load is deprecated on macOS
    13ld: warning: -bind_at_load is deprecated on macOS
    14ld: warning: ignoring duplicate libraries: '-levent'
    15  AR       qt/libbitcoinqt.a
    16  CXXLD    qt/bitcoin-qt
    17ld: warning: -bind_at_load is deprecated on macOS
    18ld: warning: ignoring duplicate libraries: '-levent', 'libbitcoin_util.a'
    19...
    

    With 3c61c60b90db1b6a77b3804784430fcd57b447b6 it’s gone:

     0./configure ...
     1...
     2  CFLAGS                  = -g -O2
     3  LDFLAGS                 = 
     4Removing -Wl,bind_at_load from libtool.
     5...
     6make
     7...
     8  CXXLD    bitcoin-wallet
     9  CXXLD    bitcoin-util
    10  CXXLD    bitcoind
    11ld: warning: -single_module is obsolete
    12qt/macnotificationhandler.mm:27:9: warning: 'NSUserNotification' is deprecated:
    13...
    14  AR       qt/libbitcoinqt.a
    15ld: warning: ignoring duplicate libraries: '-levent'
    16  CXXLD    qt/bitcoin-qt
    17ld: warning: ignoring duplicate libraries: '-levent', 'libbitcoin_util.a'
    

    Quickly tested the QT binary still works.

  18. theuni commented at 3:08 pm on November 13, 2023: member
    utACK 3c61c60b90db1b6a77b3804784430fcd57b447b6.
  19. hebasto commented at 3:41 pm on November 13, 2023: member

    My Guix builds:

    0x86_64
    199a81851f831f102e8f52e3e75b72b9228b3317d79670c7093b40550a28681e9  guix-build-3c61c60b90db/output/arm64-apple-darwin/SHA256SUMS.part
    23a6d8c63489481d3c58ed6a54b2b1264a2489932a0f1c528c453e620ec3f1c69  guix-build-3c61c60b90db/output/arm64-apple-darwin/bitcoin-3c61c60b90db-arm64-apple-darwin-unsigned.tar.gz
    3816808b6c7df70c171bace2b95d66d34fb042b15f0d690c6f519479e5f3a57fd  guix-build-3c61c60b90db/output/arm64-apple-darwin/bitcoin-3c61c60b90db-arm64-apple-darwin-unsigned.zip
    4dcac324ff8fa0081d55fc45d820fb78f797e4d73906c077d4edcd6d1c8815be9  guix-build-3c61c60b90db/output/arm64-apple-darwin/bitcoin-3c61c60b90db-arm64-apple-darwin.tar.gz
    59cabe2608e8ced9ee3ab7cbae4b1db86ae1d5194673dcf1b30823556c8805694  guix-build-3c61c60b90db/output/dist-archive/bitcoin-3c61c60b90db.tar.gz
    615c26a2865dfb2d7f45afdfc3da435ab578ece1a8726ac8d898485bdae713aca  guix-build-3c61c60b90db/output/x86_64-apple-darwin/SHA256SUMS.part
    7ca7a13d89bcf73246603ea9afff0ce597b21529a7f786f13d4c2462ae707a942  guix-build-3c61c60b90db/output/x86_64-apple-darwin/bitcoin-3c61c60b90db-x86_64-apple-darwin-unsigned.tar.gz
    89930a5a808d86f36cf82238ec691aae31ae9197984234dfe4572b80632ae4a6d  guix-build-3c61c60b90db/output/x86_64-apple-darwin/bitcoin-3c61c60b90db-x86_64-apple-darwin-unsigned.zip
    961a0e53167268548daf0de9548fc9891598c4c938270e76be7361dd584edc5ec  guix-build-3c61c60b90db/output/x86_64-apple-darwin/bitcoin-3c61c60b90db-x86_64-apple-darwin.tar.gz
    
  20. hebasto approved
  21. hebasto commented at 4:10 pm on November 13, 2023: member
    ACK 3c61c60b90db1b6a77b3804784430fcd57b447b6, tested on macOS Sonoma 14.1.1 (23B81, Apple M1) and Ubuntu 23.10 (cross-compiling for macOS). Also I’ve verified the actual diff in the libtool script.
  22. fanquake merged this on Nov 14, 2023
  23. fanquake closed this on Nov 14, 2023

  24. fanquake deleted the branch on Nov 14, 2023
  25. DrahtBot commented at 12:47 pm on November 14, 2023: contributor

    Guix builds (on x86_64)

    File commit 5800c558eb5efb4839ed00d6967e43306d68e1c3(master) commit 2e233168130838bfadbd213353d30614999c97ab(master and this pull)
    SHA256SUMS.part 6bd90b9df84e04d8... 31ad2d914c7c1b9c...
    *-aarch64-linux-gnu-debug.tar.gz 4b79da8e08fb0b31... e82cacf1bce22f3d...
    *-aarch64-linux-gnu.tar.gz 8c9e70abfd2879c4... ab2ce87a98f9dd34...
    *-arm-linux-gnueabihf-debug.tar.gz 1f042a3613741406... 8cabccbac1b731d3...
    *-arm-linux-gnueabihf.tar.gz 6571a4b5735ab70e... 979a4e2d1bade124...
    *-arm64-apple-darwin-unsigned.tar.gz 3fa3944ead0b745e... 3037b8517a7fab45...
    *-arm64-apple-darwin-unsigned.zip 0a76c6b9f25dd80d... f8962a47ef9f105e...
    *-arm64-apple-darwin.tar.gz 0b5e2d7a3ba6fc2d... 1849570d8f0b974c...
    *-powerpc64-linux-gnu-debug.tar.gz cca22ba8219ef0d8... 5ccfe11897b0742d...
    *-powerpc64-linux-gnu.tar.gz 2c5fcba31faed9f9... fee95fa897393b40...
    *-powerpc64le-linux-gnu-debug.tar.gz 585016cec10a909d... ed70b83a03a257af...
    *-powerpc64le-linux-gnu.tar.gz 69af5870f662d399... 47a295e3f390ff24...
    *-riscv64-linux-gnu-debug.tar.gz a32ea80cc01ed149... 9923c0c7c8a583d2...
    *-riscv64-linux-gnu.tar.gz 6094abe347cbfea0... 5f713a3dd87c9b78...
    *-x86_64-apple-darwin-unsigned.tar.gz c6bf3593d8834575... 9bfaee3c870b3213...
    *-x86_64-apple-darwin-unsigned.zip 3b48d057ee920021... f93f2cb552fb0170...
    *-x86_64-apple-darwin.tar.gz 0ea8d1c7516647ed... 74aaf02f93d12cee...
    *-x86_64-linux-gnu-debug.tar.gz c9b3c2d1f9f36f41... 61c68baaf289208d...
    *-x86_64-linux-gnu.tar.gz ba597239d06c8e52... 3a17793f41b2d2d0...
    *.tar.gz 2b84f5a633c304e7... e0935b7ac7e5e317...
    guix_build.log 0b55a3e85e4d68f8... 68470dee972765c6...
    guix_build.log.diff 983ce5651443ebfb...
  26. DrahtBot removed the label DrahtBot Guix build requested on Nov 14, 2023
  27. jonatack commented at 6:10 pm on November 14, 2023: member
    Tested on ARM64 M1 Max with macOS Ventura 13.6 and the bind_at_load warnings are now gone. Thank you for fixing this.
  28. hebasto referenced this in commit 3b612a0e47 on May 23, 2024
  29. hebasto referenced this in commit 7bef149019 on May 23, 2024
  30. kwvg referenced this in commit ee0bae3894 on Nov 7, 2024
  31. kwvg referenced this in commit d7cb92aa7a on Nov 13, 2024
  32. bitcoin locked this on Nov 13, 2024

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-11-21 21:12 UTC

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