-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
[POC] guix: produce a fully -static-pie
bitcoind
#25573
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. 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. |
da9f731
to
26c437e
Compare
Rebased, and made small changes to fixup the linter and improve the security/symbol checks. |
This is amazing!
Hard agree. Static musl builds would be very cool but tricky to audit for parity and thus pretty unlikely to ever become official/supported imo. This is a MUCH more palatable change. |
26c437e
to
8cccf45
Compare
Added an additional patch to disable building various features/libs in GCC that we don't need. i.e libquadmath, libsanitizer, gcov, libada and native language support. This should speed up compiling GCC, and slightly reduces the size of the pthread patch. I'm not currently disabling these features via the available configure flags, because they get passed through to GMP, which cannot handle them. I've also updated lto-wrapper: warning: using serial compilation of 84 LTRANS jobs
lto-wrapper: note: see the '-flto' option documentation for more information I've also split the ELF PIE check into it's own func, so we can special-case x86_64, and re-added the list of allowed ELF libs, but special-cased x86_64 to only pass if the list is empty. |
How does this handle resolvers? eg, static glibc 2.33 applications break on systems with glibc 2.34... |
8cccf45
to
caa0664
Compare
Which OS did you build on? On Ubuntu 20.04 after build: Trying to run it, it crashes after seconds: Any ideas? |
The base OS shouldn't matter, because the build is performed with Guix. However I've been performing these builds on Ubuntu 22.04.
How did you actually build bitcoind? Something like |
caa0664
to
ef0edd5
Compare
Rebased on master. Added a commit to use LIEF master, which reduces the number of changes in our scripts, as support for |
Yes, that's what I used to build it. |
I have just re-tested building the changes here (ef0edd5), and this produces a guix-build-ef0edd55f3bc/distsrc-ef0edd55f3bc-x86_64-linux-gnu/src/bitcoind: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), static-pie linked, for GNU/Linux 3.2.0, with debug_info, not stripped It's not clear to me that you are actually running a Guix build. |
the build I was testing: just building again, fresh cloned with commit ef0edd5 $ file guix-build-ef0edd55f3bc/distsrc-ef0edd55f3bc-x86_64-linux-gnu/src/bitcoind $ ldd ./guix-build-ef0edd55f3bc/distsrc-ef0edd55f3bc-x86_64-linux-gnu/src/bitcoind $ ./bitcoind build and run on Ubuntu 20.04 |
building the same on Ubuntu 22.04: ldd guix-build-ef0edd55f3bc/distsrc-ef0edd55f3bc-x86_64-linux-gnu/src/bitcoind Running it on Ubuntu22 it works. Taking this bitcoind to Ubuntu 20 it shows: and crashes with the above mentioned message: Checksums are the same for both builds (on Ubuntu 20 and 22) Same bitcoind on Debian 10: |
0cf3c2b
to
054894f
Compare
Rebased. Simplified somewhat. Switched to GCC 13.2.0 and glibc 2.39. |
054894f
to
a4c5193
Compare
a4c5193
to
d73587b
Compare
So we have atleast: https://git.savannah.gnu.org/cgit/guix.git/commit/?id=ffd1d0c2d486b9de35706ca73a4e89177114e4de and https://git.savannah.gnu.org/cgit/guix.git/commit/?id=97bad5e1947a07d96f40205bec1e91463e7bf014 which are needed for Windows.
Don't bother with anything static with Qt.
Not currently compatible with static builds.
-static-pie Produce a static position independent executable on targets that support it. A static position independent executable is similar to a static executable, but can be loaded at any address without a dynamic linker. See https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html GCC 12 is needed to avoid issues with std::thread and static linking. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852
d73587b
to
c9541a6
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
🐙 This pull request conflicts with the target branch and needs rebase. |
Use Guix to produce a fully
-static-pie
x86_64-linux-gnu
bitcoind using GCC 13.2.0 and glibc 2.39. The binary is ~15mb stripped, includes wallet/upnp/natpmp/zmq etc.-static-pie
Using glibc for static builds, would be less of a leap compared to switching to musl libc (POC in #23203).