Hot to test for _FORTIFY_SOURCE with Autoconf

Jim Wilson jimw@sifive.com
Wed Mar 18 22:21:00 GMT 2020


On Tue, Mar 17, 2020 at 6:49 PM Martin Sebor via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> > On Tue, Mar 17, 2020 at 8:11 PM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> > I think it is related to object size checking.
>
> In GCC 10 you can test __has_builtin (__builtin_object_size).  In GCC
> versions that don't support __has_builtin using __builtin_object_size
> will either compile or not, depending on whether it's supported.  It
> doesn't depend on any macros.

That is a good way to test if the compiler has object size checking
support, but it is no guarantee that the C library has FORTIFY_SOURCE
support.  If it is fortify source support that you need, then you need
to explicitly check for that.  If it is just the object size checking
support you need, then you can do the check this way.

Jim



More information about the Gcc-help mailing list