Skip to content

Commit

Permalink
Merge bitcoin#18779: doc: Better explain GNU ld's dislike of ld64's o…
Browse files Browse the repository at this point in the history
…ptions

cd24f37 doc: Better explain GNU ld's dislike of ld64's options (fanquake)

Pull request description:

  There's also now more than a single option being special cased for
  darwin. If we didn't special case these options they would still end
  up on the link line and the binaries produced would just segfault.

  I'm going to plug bitcoin#17874 here as well, because adding
  `-fatal-warnings` to our `AX_CHECK_LINK_FLAG` calls would
  mostly prevent this sort of option mangling from happening.

  An example of the warning behaviour:
  ```bash
  echo "int main() {}" | g++ -x c++ -std=c++11 -Wl,-dead_strip -
  /usr/bin/ld: warning: cannot find entry symbol ad_strip; defaulting to 0000000000001040

  nm -C a.out
  0000000000001000 t _init
  0000000000001040 T _start
                   U ad_strip
  ```

ACKs for top commit:
  dongcarl:
    ACK cd24f37

Tree-SHA512: 8c5ff11b647e7d44dbb3f509a07caf8606a6b481c114403f0de72b3ad65395dbe9a3436e731ae1b46a823431ed23c3c6aacab8942d78629d59cd8c258c5dbf02
  • Loading branch information
fanquake authored and PastaPastaPasta committed Jun 27, 2021
1 parent a2c2ca9 commit 67b55ab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,9 @@ if test x$use_hardening != xno; then
esac
fi

dnl this flag screws up non-darwin gcc even when the check fails. special-case it.
dnl These flags are specific to ld64, and may cause issues with other linkers.
dnl For example: GNU ld will intepret -dead_strip as -de and then try and use
dnl "ad_strip" as the symbol for the entry point.
if test x$TARGET_OS = xdarwin; then
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"])
Expand Down

0 comments on commit 67b55ab

Please sign in to comment.