On Sat, Jul 13, 2013 at 11:47:29PM +0200, Jakub Jelinek wrote: > On Wed, Jun 19, 2013 at 10:17:15AM +0200, Jakub Jelinek wrote: > > While it would be possible to define say %:sanitize(thread LIBTSAN_EARLY) > > that would work roughly like %{fsanitize=thread:LIBTSAN_EARLY} worked > > until now (variable number of arguments that would be concatenated together > > if flag_sanitize & ..., otherwise return empty), we use e.g. %e inside > > of the %{fsanitize=thread:...} etc. > > So, I wonder if we couldn't extend the handle_braces, I think right now > > empty atoms are disallowed for the first choice, so perhaps > > %{%:function(args):...} > > where %:function(args) would be expanded to either non-empty or empty string > > and depending on that the condition would be then true resp. false. > > As % is not considered part of the atom name, and we require after atom name > > optional * and then only one of |, }, &, :, I think this wouldn't be > > ambiguous in the grammar. > > We could then have: > > %{!%:function1():-lfoo;%:function2(bar baz):-lbar -lbaz;-lxxx} > > and for the sanitizer purposes: > > %{%:sanitize(address):LIBTSAN_EARLY} > > %{!nostdlib:%{!nodefaultlibs:%{%:sanitize(address):" LIBASAN_SPEC "\ > > %{static:%ecannot specify -static with -fsanitize=address}\ > > %{%:sanitize(thread):%e-fsanitize=address is incompatible with > > -fsanitize=thread}}\ > > %{%:sanitize(thread):" LIBTSAN_SPEC "\ > > %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or > > %-shared}}}}}" > > Here is a patch that implements that (of course on top of Marek's patch from > June). > > 2013-07-13 Jakub Jelinek <ja...@redhat.com> > > * gcc.c: Document %{%:function(args):X}. > (SANITIZER_EARLY_SPEC, SANITIZER_SPEC): Use %:sanitize(address) > instead of fsanitize=address and %:sanitize(thread) instead of > fsanitize=thread. > (static_spec_functions): Add sanitize. > (handle_spec_function): Add retval_nonnull argument and if non-NULL, > store funcval != NULL there. > (do_spec_1): Adjust handle_spec_function caller. > (handle_braces): Allow %:function(args) as condition. > (sanitize_spec_function): New function. > * common.opt (fsanitize=): Add Driver. > * config/darwin.h (LINK_COMMAND_SPEC_A): Use %:sanitize(address) > instead of fsanitize=address. > * config/arm/linux-eabi.h (ASAN_CC1_SPEC): Use %:sanitize(address) > instead of fsanitize=address*.
Thanks, commited to the ubsan branch. Marek