Re: [PATCH] tools/lib/api/Makefile: Add feature check for _FORTIFY_SOURCE

From: Dirk Gouders
Date: Mon Apr 20 2015 - 14:40:13 EST


Ingo Molnar <mingo@xxxxxxxxxx> writes:

> * Dirk Gouders <dirk@xxxxxxxxxxx> wrote:
>
>> For example on Gentoo systems where _FORTIFY_SOURCE is set by default,
>> `make -C tools/perf' fails, because of the macro being redefined.
>>
>> Fix that by a feature-check analogous to tools/perf/config/Makefile.
>>
>> Signed-off-by: Dirk Gouders <dirk@xxxxxxxxxxx>
>> ---
>> tools/lib/api/Makefile | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
>> index d8fe29f..acf9097 100644
>> --- a/tools/lib/api/Makefile
>> +++ b/tools/lib/api/Makefile
>> @@ -16,7 +16,14 @@ MAKEFLAGS += --no-print-directory
>> LIBFILE = $(OUTPUT)libapi.a
>>
>> CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
>> -CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -fPIC
>> +CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fPIC
>> +
>> +ifeq ($(DEBUG),0)
>> + ifeq ($(feature-fortify-source), 1)
>> + CFLAGS += -D_FORTIFY_SOURCE=2
>> + endif
>> +endif
>
> So how about undefining it instead and re-defining it as
> _FORTIFY_SOURCE=2?
>
> Just in case a distro sets a weaker version - lets not accept that
> weaker setting. We've always had the stronger version of it.

Yes, I was suggesting something similar (but without founded reasoning),
some time ago [1].

Would the "undefining-approch" mean that we should modify the handling
of _FORTIFY_SOURCE in tools/perf/config/Makefile as well?

Dirk

[1] https://lkml.org/lkml/2013/5/22/186
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/