-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: fix libnatpmp macos cross compile #21320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently, our cross-compile of libnatpmp for macOS doesn't work at all. The wrong archiver is used, which produces an archive the linker doesn't like. This becomes clear when configuring: ```bash configure:25722: checking for initnatpmp in -lnatpmp configure:25747: env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH /home/ubuntu/bitcoin/depends/x86_64-apple-darwin18/native/bin/clang++ --target=x86_64-apple-darwin18 <trim> -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-dead_strip_dylibs conftest.cpp -lnatpmp >&5 ld: archive has no table of contents for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` Fix this by using the right `ar` (we do the same for upnp). While we're at it, we fixe the build so that we are using our c/ppflags. This means building with `-O2` rather than `-Os`. Note that this fixes an issue that is also fixed by bitcoin#21209. However, given there are reservations about updating to use a newer libnatpmp source, we should just fix this for now.
Concept ACK. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK bd49ac4, tested:
- cross-compiling -- on Linux Mint 20.1 (x86_64)
- binaries -- on macOS Big Sur 11.2.1 (20D74)
Cross-compiling:
- master (ad89812):
$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin16/share/config.site ./configure
...
Options used to compile and link:
...
with natpmp = no
- this PR (bd49ac4):
$ CONFIG_SITE=$PWD/depends/x86_64-apple-darwin16/share/config.site ./configure
...
Options used to compile and link:
...
with natpmp = yes
Replacement compiler flags s /Os
/O2
/ could increase code size by using more optimization options. I'm ok with it.
Also added the -pipe
flag which has no effect on the generated code at all, only on compiling speed.
|
Why? libnatpmp isn't in the 0.21 branch. |
Indeed. I messed my memory. Sorry for noise. |
bd49ac4 build: fix libnatpmp macos cross compile (fanquake) Pull request description: Currently, our cross-compile of libnatpmp for macOS doesn't work at all. The wrong archiver is used, which produces an archive the linker doesn't like. This becomes clear when configuring: ```bash configure:25722: checking for initnatpmp in -lnatpmp configure:25747: env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH /home/ubuntu/bitcoin/depends/x86_64-apple-darwin18/native/bin/clang++ --target=x86_64-apple-darwin18 <trim> -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-dead_strip_dylibs conftest.cpp -lnatpmp >&5 ld: archive has no table of contents for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` Fix this by using the right `ar` (we do the same for upnp). While we're at it, fix the build so that we are using our c/ppflags. In practice this basically means building with `-O2` rather than `-Os`. Note that this fixes an issue that is also fixed by bitcoin#21209. However, given there are reservations about updating to use a newer libnatpmp source, we should just fix this for now. ACKs for top commit: hebasto: ACK bd49ac4, tested: Tree-SHA512: 2efc2c788ef3ebebfbf564ef07b6cf63a72d8a0bccc22b0ba36537216aa575436b7e87088477e85f6d9191ad34f0b13f1c22cf88c90e1cb81641bfee5dc3058a
Currently, our cross-compile of libnatpmp for macOS doesn't work at all.
The wrong archiver is used, which produces an archive the linker doesn't like.
This becomes clear when configuring:
Fix this by using the right
ar
(we do the same for upnp).While we're at it, fix the build so that we are using our c/ppflags.
In practice this basically means building with
-O2
rather than-Os
.Note that this fixes an issue that is also fixed by #21209. However, given there are reservations about updating to use a newer libnatpmp source, we should just fix this for now.