-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[POC] guix: produce a fully -static-pie
bitcoind
#25573
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
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 Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/25573. 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: |
0d34d13
to
80a9ee0
Compare
80a9ee0
to
41720e2
Compare
41720e2
to
550bb0d
Compare
550bb0d
to
d657be0
Compare
d657be0
to
e881c8c
Compare
e881c8c
to
9c7154a
Compare
74e927f
to
5959093
Compare
5959093
to
e7bdb2b
Compare
Package updates: file 5.44 -> 5.45 (base) glibc 2.35 -> 2.39 grep 3.8 -> 3.11 diffutils 3.8 -> 3.10 gawk 5.2.1 -> 5.3.0 gzip 1.12 -> 1.13 xz 5.2.8 -> 5.4.5 make 4.3 -> 4.4.1 git-minimal 2.45.2 -> 2.48.1 binutils 2.38 -> 2.41 linux-headers 6.1.106 -> 6.1.128 CMake-3.30 becomes available. Clang/LLVM 19 & 20 become available.
-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
e7bdb2b
to
fa0d534
Compare
Use Guix to produce a fully
-static-pie
bitcoind using GCC 13.3.0 and glibc 2.35. The binary is ~18mb stripped, includes wallet/upnp/natpmp/zmq etc. This is currently done forx86_64-linux-gnu
,aarch64-linux-gnu
.-static-pie
Using glibc for static builds, would be less of a leap compared to switching to musl libc (POC in #23203).