Skip to content

Pass critical CFLAGS/CXXFLAGS to more build steps#237

Open
kwsantiago wants to merge 7 commits into
bitcoinknots:29.x-knotsfrom
privkeyio:159-build-checks
Open

Pass critical CFLAGS/CXXFLAGS to more build steps#237
kwsantiago wants to merge 7 commits into
bitcoinknots:29.x-knotsfrom
privkeyio:159-build-checks

Conversation

@kwsantiago

@kwsantiago kwsantiago commented Nov 18, 2025

Copy link
Copy Markdown

@kwsantiago kwsantiago marked this pull request as draft November 19, 2025 00:38
@kwsantiago kwsantiago force-pushed the 159-build-checks branch 2 times, most recently from 3d6400e to eb8d6f7 Compare January 8, 2026 20:24
@kwsantiago kwsantiago marked this pull request as ready for review January 8, 2026 20:25

@luke-jr luke-jr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What do you think about taking the hardening logic out of /CMakeLists.txt and putting it into a CMake module that we can just use here too? (Maybe make that a separate PR in case it doesn't work out)

Comment thread contrib/guix/libexec/build.sh Outdated
Comment thread contrib/guix/libexec/build.sh Outdated
Comment thread depends/hosts/default.mk Outdated
@kwsantiago

Copy link
Copy Markdown
Author

What do you think about taking the hardening logic out of /CMakeLists.txt and putting it into a CMake module that we can just use here too? (Maybe make that a separate PR in case it doesn't work out)

@luke-jr I moved this logic to #254

@kwsantiago kwsantiago requested a review from luke-jr February 17, 2026 17:55
@kwsantiago kwsantiago force-pushed the 159-build-checks branch 2 times, most recently from 56926e1 to c0488d3 Compare February 20, 2026 22:30
Comment thread src/CMakeLists.txt Outdated
Comment thread depends/hosts/default.mk Outdated
Comment thread contrib/guix/libexec/build.sh Outdated
@luke-jr

luke-jr commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

With the current PR, guix/depends don't get the hardening options. The point of #159 is to build everything included in the official binaries with full hardening (and source builds by default). The difficulty is using the same hardening decision logic for both the main source as well as dependencies.

@kwsantiago

Copy link
Copy Markdown
Author

Added hardening flag propagation to all depends host configs (linux, darwin, mingw, freebsd, openbsd, netbsd), gated by NO_HARDEN, matching what Hardening.cmake applies to the main build: bb87830

@luke-jr

luke-jr commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

The goal isn't to match Hardening.cmake, but to call and use it. Which would also test the usability of compiler-specific flags.

@kwsantiago

Copy link
Copy Markdown
Author

Reworked: depends now probes Hardening.cmake directly instead of duplicating flags per-host.

Comment thread CMakeLists.txt Outdated
Comment thread cmake/module/Hardening.cmake Outdated
@kwsantiago

Copy link
Copy Markdown
Author

Moved -fstack-reuse=none into Hardening.cmake and pulled target_link_libraries out of the module so the probe skips the dummy library.

Comment thread ci/test/00_setup_env_native_fuzz_with_msan.sh
Comment thread cmake/module/Hardening.cmake Outdated
@luke-jr luke-jr added this to the 29.3 (2nd) milestone Apr 3, 2026
@kwsantiago kwsantiago requested a review from luke-jr April 11, 2026 14:35
Comment thread CMakeLists.txt
@luke-jr

luke-jr commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Don't we need to update build_id to include the flags?

Also, this doesn't seem to actually work. strace'ing the guix build shows many dependencies being built without the hardening flags.

@kwsantiago kwsantiago requested a review from luke-jr April 15, 2026 15:57
@kwsantiago

Copy link
Copy Markdown
Author

Fixed build_id to hash host_CFLAGS/CXXFLAGS/LDFLAGS (full flags incl. probe output). Verified under guix: 470/470 compile commands have all hardening flags; prior missing-flags symptom was stale cache not invalidating.

@kwsantiago

Copy link
Copy Markdown
Author

Also added build-toolchain probe so native depends packages get hardening. Verified end-to-end under guix: 506/506 compile commands hardened, all 7 output binaries have BIND_NOW/PIE/stack_chk.

@kwsantiago kwsantiago force-pushed the 159-build-checks branch 2 times, most recently from 770e500 to c185ff8 Compare April 15, 2026 20:12
@kwsantiago

kwsantiago commented Apr 15, 2026

Copy link
Copy Markdown
Author

Added host_build: QMAKE_* lines in qt.mk so Qt's native tools (moc, rcc, uic) also get hardening. Verified under guix: 495/495 real compiles hardened (remaining 36 are cmake/autoconf internal probes, which your grep already filters).

grep 'execve("[^"]*\(cc\|++\|ld\)[^/"]*"' log-tmp | grep -v 'execve("[^"]*-ar"\|/bin/ldd"\|/bin/rcc"\|"--help"\|"-[-q]\?version"\|"-\?-print\|-ranlib"\|"-E"\|CompilerId\b\|conftest\|CMakeFiles/\|"-[Vv]"' |perl -nle 'if(m["(-o)", "([^"]{2,})"] and $2 ne "/dev/null"){print "$1 $2 $_"}elsif(m["([^"]+\.([ch](xx|pp)?|cc))"]){print "$1 $_"} else{print}'|grep -v '^-o /tmp/\|^cmTC_' | grep -v 'fstack-clash-protection\|-z.separate-code' |wc -l

@kwsantiago

Copy link
Copy Markdown
Author

Patched qmake's Makefile.unix template so configure's bootstrap also gets hardening. Strace-verified under guix: 0 real build commands missing flags.

@kwsantiago kwsantiago force-pushed the 159-build-checks branch 5 times, most recently from 06f1fbe to 7b83d9c Compare April 23, 2026 18:19
@luke-jr luke-jr removed this from the 29.3 (2nd) milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass certain CFLAGS/CXXFLAGS to more build steps

2 participants