Page MenuHomeFreeBSD

build: provide a FORTIFY_SOURCE.<src file> override
ClosedPublic

Authored by kevans on May 30 2026, 2:09 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jul 2, 12:46 AM
Unknown Object (File)
Thu, Jul 2, 12:04 AM
Unknown Object (File)
Thu, Jun 25, 9:01 AM
Unknown Object (File)
Wed, Jun 24, 9:50 PM
Unknown Object (File)
Wed, Jun 24, 6:37 PM
Unknown Object (File)
Wed, Jun 24, 7:45 AM
Unknown Object (File)
Tue, Jun 23, 10:25 AM
Unknown Object (File)
Tue, Jun 23, 1:08 AM

Details

Summary

For native files we can do more minimal fixes to avoid this large of a
hammer, but for third party files it may not be worth the effort to try
and patch them. NetBSD has the original _FORTIFY_SOURCE implementation
that ours is based on, for instance, but tests sourced from there can't
do an __ssp_real(foo) without being certain that foo actually has a
fortified definition.

This change does always define _FORTIFY_SOURCE as a result, so gate it
on CFLAGS not already containing _FORTIFY_SOURCE definitions.

This re-applies c46a0b59071614, but without re-defining _FORTIFY_SOURCE
needlessly.

PR: 294881

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This will re-fix the getgroups test with FORTIFY_SOURCE > 0; the use of FORTIFY_SOURCE.<foo> there wasn't reverted when the implementation was.

It's hard for me to judge whether this is the best way to handle it, but it seems to work.

share/mk/bsd.sys.mk
309–310

Should this be grouped with the block you modified?

323
This revision is now accepted and ready to land.Jun 5 2026, 2:10 PM
sjg added inline comments.
share/mk/bsd.sys.mk
329

Since this probably looks like line-noise to some, you might want to mention in the comment that, the flag is dropped if FORTIFY_SOURCE=0

This revision was automatically updated to reflect the committed changes.
kevans marked an inline comment as done.