Skip to content

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Nov 3, 2023

This is deprecated on macOS:

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, because it's version check is broken:

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

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 3, 2023

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.

@fanquake
Copy link
Member Author

fanquake commented Nov 3, 2023

@theuni @TheCharlatan you might have some libtool ideas? Couldn't see too anything obvious to prune this out.

@theuni
Copy link
Member

theuni commented Nov 3, 2023

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

@theuni
Copy link
Member

theuni commented Nov 3, 2023

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

See theuni@c61c9c5 which is ugly but seems to work as intended.

@fanquake fanquake force-pushed the remove_bind_at_load branch from 46d4667 to 144deff Compare November 8, 2023 10:24
@fanquake
Copy link
Member Author

fanquake commented Nov 8, 2023

See theuni@c61c9c5 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.

@fanquake
Copy link
Member Author

fanquake commented Nov 8, 2023

Guix Build (arm64):

cf3250e32cf25ee1a75372bed2fb105fc893abd40662ed60b6376cd1f77586a1  guix-build-144deffe35b7/output/arm64-apple-darwin/SHA256SUMS.part
11a505365063b6234a8e205e3b30a5a7a9bb1b1cc6bf266b5038b18474edbd1f  guix-build-144deffe35b7/output/arm64-apple-darwin/bitcoin-144deffe35b7-arm64-apple-darwin-unsigned.tar.gz
674f71f6c59e064e8f42a2f11c2406fea08873b6369b472f9662e8ee0c5567e4  guix-build-144deffe35b7/output/arm64-apple-darwin/bitcoin-144deffe35b7-arm64-apple-darwin-unsigned.zip
c6fe023ee5e7fdcec8b42a4ac77c6303daf0b2fa61022009fb87e440f8e43a6a  guix-build-144deffe35b7/output/arm64-apple-darwin/bitcoin-144deffe35b7-arm64-apple-darwin.tar.gz
f7658c6b212e04b6ced4afb471abca6eece9763ec9b912004ecf0b2f9c2bb7d8  guix-build-144deffe35b7/output/dist-archive/bitcoin-144deffe35b7.tar.gz
d0e86a3eedbe3e944df7282936994d755580e69a4d7c7bd7fb4350e3bf670f81  guix-build-144deffe35b7/output/x86_64-apple-darwin/SHA256SUMS.part
7839a306c6fe7113b0fb390b11799903857594ac5b22ce92c77baca7f28adbdc  guix-build-144deffe35b7/output/x86_64-apple-darwin/bitcoin-144deffe35b7-x86_64-apple-darwin-unsigned.tar.gz
94edf9895f2d176810ed8025c779d11106a2176fe2dd7b331a34c99c30fb0a4a  guix-build-144deffe35b7/output/x86_64-apple-darwin/bitcoin-144deffe35b7-x86_64-apple-darwin-unsigned.zip
49441bbef48c0abc1ce7eba15cba9dc3562f8ab6e4cd402984f7c10849361dbf  guix-build-144deffe35b7/output/x86_64-apple-darwin/bitcoin-144deffe35b7-x86_64-apple-darwin.tar.gz

@theuni
Copy link
Member

theuni commented Nov 9, 2023

utACK.

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

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`.
@fanquake
Copy link
Member Author

fanquake commented Nov 9, 2023

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

Pretty sure it is there? "Similar to a98356f."

@theuni
Copy link
Member

theuni commented Nov 9, 2023

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

@Sjors
Copy link
Member

Sjors commented Nov 13, 2023

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

./configure --with-gui --enable-wallet --disable-fuzz-binary --disable-bench --disable-tests
...
checking whether the linker accepts -Wl,-bind_at_load... no
...
make
...
  CXXLD    bitcoin-wallet
ld: warning: -single_module is obsolete
  CXXLD    bitcoin-util
ld: warning: -bind_at_load is deprecated on macOS
ld: warning: -bind_at_load is deprecated on macOS
ld: warning: -bind_at_load is deprecated on macOS
ld: warning: -bind_at_load is deprecated on macOS
ld: warning: -bind_at_load is deprecated on macOS
ld: warning: ignoring duplicate libraries: '-levent'
  AR       qt/libbitcoinqt.a
  CXXLD    qt/bitcoin-qt
ld: warning: -bind_at_load is deprecated on macOS
ld: warning: ignoring duplicate libraries: '-levent', 'libbitcoin_util.a'
...

With 3c61c60 it's gone:

./configure ...
...
  CFLAGS                  = -g -O2
  LDFLAGS                 = 
Removing -Wl,bind_at_load from libtool.
...
make
...
  CXXLD    bitcoin-wallet
  CXXLD    bitcoin-util
  CXXLD    bitcoind
ld: warning: -single_module is obsolete
qt/macnotificationhandler.mm:27:9: warning: 'NSUserNotification' is deprecated:
...
  AR       qt/libbitcoinqt.a
ld: warning: ignoring duplicate libraries: '-levent'
  CXXLD    qt/bitcoin-qt
ld: warning: ignoring duplicate libraries: '-levent', 'libbitcoin_util.a'

Quickly tested the QT binary still works.

@theuni
Copy link
Member

theuni commented Nov 13, 2023

utACK 3c61c60.

@hebasto
Copy link
Member

hebasto commented Nov 13, 2023

My Guix builds:

x86_64
99a81851f831f102e8f52e3e75b72b9228b3317d79670c7093b40550a28681e9  guix-build-3c61c60b90db/output/arm64-apple-darwin/SHA256SUMS.part
3a6d8c63489481d3c58ed6a54b2b1264a2489932a0f1c528c453e620ec3f1c69  guix-build-3c61c60b90db/output/arm64-apple-darwin/bitcoin-3c61c60b90db-arm64-apple-darwin-unsigned.tar.gz
816808b6c7df70c171bace2b95d66d34fb042b15f0d690c6f519479e5f3a57fd  guix-build-3c61c60b90db/output/arm64-apple-darwin/bitcoin-3c61c60b90db-arm64-apple-darwin-unsigned.zip
dcac324ff8fa0081d55fc45d820fb78f797e4d73906c077d4edcd6d1c8815be9  guix-build-3c61c60b90db/output/arm64-apple-darwin/bitcoin-3c61c60b90db-arm64-apple-darwin.tar.gz
9cabe2608e8ced9ee3ab7cbae4b1db86ae1d5194673dcf1b30823556c8805694  guix-build-3c61c60b90db/output/dist-archive/bitcoin-3c61c60b90db.tar.gz
15c26a2865dfb2d7f45afdfc3da435ab578ece1a8726ac8d898485bdae713aca  guix-build-3c61c60b90db/output/x86_64-apple-darwin/SHA256SUMS.part
ca7a13d89bcf73246603ea9afff0ce597b21529a7f786f13d4c2462ae707a942  guix-build-3c61c60b90db/output/x86_64-apple-darwin/bitcoin-3c61c60b90db-x86_64-apple-darwin-unsigned.tar.gz
9930a5a808d86f36cf82238ec691aae31ae9197984234dfe4572b80632ae4a6d  guix-build-3c61c60b90db/output/x86_64-apple-darwin/bitcoin-3c61c60b90db-x86_64-apple-darwin-unsigned.zip
61a0e53167268548daf0de9548fc9891598c4c938270e76be7361dd584edc5ec  guix-build-3c61c60b90db/output/x86_64-apple-darwin/bitcoin-3c61c60b90db-x86_64-apple-darwin.tar.gz

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3c61c60, 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.

@fanquake fanquake merged commit fb85bb2 into bitcoin:master Nov 14, 2023
@fanquake fanquake deleted the remove_bind_at_load branch November 14, 2023 09:48
@DrahtBot
Copy link
Contributor

Guix builds (on x86_64)

File commit 5800c55
(master)
commit 2e23316
(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...

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on ARM64 M1 Max with macOS Ventura 13.6 and the bind_at_load warnings are now gone. Thank you for fixing this.

hebasto added a commit to hebasto/bitcoin that referenced this pull request May 23, 2024
The `-bind_at_load` has been removed since bitcoin#28783.
hebasto added a commit to hebasto/bitcoin that referenced this pull request May 23, 2024
3b612a0 fixup! cmake: Add `HARDENING` option (Hennadii Stepanov)

Pull request description:

  The `-bind_at_load` has been removed since bitcoin#28783.

Top commit has no ACKs.

Tree-SHA512: a7ccd561edc1fb260d3fbb5dad3ecc516488d9c6ca9b1f926e709f62b415d969f7ad620260ed86b5f80a44fc1791d8e11e3b61f375f1f6993a2e60d304e0b919
kwvg added a commit to kwvg/dash that referenced this pull request Nov 7, 2024
kwvg added a commit to kwvg/dash that referenced this pull request Nov 13, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants