Repository navigation
Add build hardening and fix build-system inconsistencies - #16
Merged
Merged
Conversation
mattsva
force-pushed
the
build/hardening-consistency
branch
3 times, most recently
from
October 11, 2026 13:45
33bb62f to
ff5607f
Compare
Hardening, consistently in Make, CMake and Meson:
- -fstack-protector-strong for GCC/Clang
- -D_FORTIFY_SOURCE=2 only where the build is optimized (at -O0 glibc
emits a #warning that -Werror would escalate); the Makefile sets no
-O by default, so FORTIFY is documented for optimized builds there
- -Wl,-z,relro,-z,now on Linux only (ELF-only; macOS links fine
without it)
- MSVC: no new flags - /GS, /DYNAMICBASE and /NXCOMPAT are on by
default, documented in both CMake and Meson. /sdl was deliberately
not added because it cannot be verified without a Windows build.
Consistency fixes found while verifying:
- Meson was missing test_client and test_welcome: it built 9 test
binaries where Make and CMake build 11. Added.
- CMake's Release config defines NDEBUG, which compiled every assert()
out of the test binaries: the suite would have passed vacuously and
the newly-unused variables failed the build with
-Werror=unused-but-set-variable. Test targets now compile with
-UNDEBUG so assertions stay active in every build type.
- test_mnet.c had set-but-unused variables that only trip at -O2.
Verified: make test (pass), ctest default and Release (11/11, asserts
confirmed active via __assert_fail), meson debug and release (11/11),
full RELRO (BIND_NOW) and stack canaries present in the Make-built
libmnet.so.
test_starvation, test_reentrancy and test_http_edge were built by make test but never added to .gitignore, so every git add -A swept the freshly built binaries into the following commit; the build-rel directory (a CMake build dir) matched nothing because only the exact name build/ was listed. Added the three missing test binaries and test_welcome to the test binary list and build-*/ to the build directory list. The binaries and build-rel were removed from the unpushed commits with git filter-branch, so no build artifact is committed on this branch.
mattsva
force-pushed
the
build/hardening-consistency
branch
from
October 11, 2026 13:50
ff5607f to
d3b9b1b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9. Two commits: build hardening +
.gitignorehygiene.-fstack-protector-strong;-D_FORTIFY_SOURCE=2only in optimized build types (it requires optimization — glibc warns otherwise and-Werrorwould escalate);-Wl,-z,relro,-z,nowon Linux only. MSVC needs none:/GS,/DYNAMICBASEand/NXCOMPATare on by default./sdldeliberately not added — unverifiable against the/WXWindows build without a Windows machine.test_clientandtest_welcometargets (9 → 11 tests, matching Make/CMake).-UNDEBUGso assertions stay live in Release (previously the suite passed vacuously withNDEBUG).test_mnet.cunused-variable warnings fixed (only triggered at-O2with-Werror).test_reentrancymoved to port 18780 — it collided withtest_security's 18779 and meson runs tests in parallel (intermittent bind failure)..gitignore: added the three missing test binaries,test_welcomeand abuild-*/pattern.Verified: full RELRO (BIND_NOW) + stack canaries on the built library; ctest Debug + Release 11/11; meson debug + release 11/11. Windows and macOS builds not verified locally — see #1.
Stacked on the previous PR in the series; merge in order.