v2: The GNU C Library 2.16 release plan

Mike Frysinger vapier@gentoo.org
Thu Jun 14 05:08:00 GMT 2012


On Tuesday 12 June 2012 13:13:19 Roland McGrath wrote:
> > * We change glibc to use _FORTIFY_SOURCE_IF_OPT?
> 
> As it's not something we'd encourage users to use directly themselves,
> I think we should give it a more obscure name.
> 
> But it now occurs to me that distributions might just be able to use:
> 
> '-D_FORTIFY_SOURCE=((defined __OPTIMIZE__ && __OPTIMIZE__ > 1) ? 2 : 0)'

mmm, i don't think that can work, can it ?  it'll expand _FORTIFY_SOURCE into 
literally "((defined __OPTIMIZE__ && __OPTIMIZE__ > 1) ? 2 : 0)" since the 
preprocessor isn't recursive.

> So let's have Mike or someone similarly interested try that out.  If it
> works, then we can just advise package-builders to use that (e.g. on the
> wiki somewhere) and we won't need to do anything at all in libc.  Not that
> we'd advise people to break their gcc this way, but if they are going to
> predefine _FORTIFY_SOURCE, that's the thing to predefine it to.  This has
> the advantage that it works with all libc versions, not just a forthcoming
> one.

doesn't seem to work as a builtin at least:
	builtin_define_with_value ("_FORTIFY_SOURCE",
		"((defined __OPTIMIZE__ && __OPTIMIZE__ > 1) ? 2 : 0)",
		0);

$ echo _FORTIFY_SOURCE | gcc -E -
((defined __OPTIMIZE__ && __OPTIMIZE__ > 1) ? 2 : 0)

$ printf '#if _FORTIFY_SOURCE\n#else\n#error\n#endif\n' > test.c
$ gcc -c test.c 
test.c:3:2: error: #error 
$ gcc -c test.c -O1
test.c:3:2: error: #error 
$ gcc -c test.c -O2
test.c:3:2: error: #error 
$ gcc -c test.c -O3
test.c:3:2: error: #error 
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120614/f2c3aad3/attachment.sig>


More information about the Libc-alpha mailing list