From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Sam James <sam@gentoo.org>, libc-alpha@sourceware.org
Subject: Re: [PATCH] stdlib: tests: don't double-define _FORTIFY_SOURCE
Date: Mon, 8 Aug 2022 09:26:26 -0400 [thread overview]
Message-ID: <294385d7-3974-9089-e190-782bffd40af8@gotplt.org> (raw)
In-Reply-To: <20220805201358.2348750-1-sam@gentoo.org>
On 2022-08-05 16:13, Sam James via Libc-alpha wrote:
> If using -D_FORITFY_SOURCE=3 (in my case, I've patched GCC to add
> =3 instead of =2 (we've done =2 for years in Gentoo)), building
> glibc tests will fail on testmb like:
> ```
> <command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
> <built-in>: note: this is the location of the previous definition
> cc1: all warnings being treated as errors
> make[2]: *** [../o-iterator.mk:9: /var/tmp/portage/sys-libs/glibc-2.36/work/build-x86-x86_64-pc-linux-gnu-nptl/stdlib/testmb.o] Error 1
> make[2]: *** Waiting for unfinished jobs....
> ```
>
> It's just because we're always setting -D_FORTIFY_SOURCE=2
> rather than unsetting it first. If F_S is already 2, it's harmless,
> but if it's another value (say, 1, or 3), the compiler will bawk.
>
> (I'm not aware of a reason this couldn't be tested with =3,
> but the toolchain support is limited for that (too new), and we want
> to run the tests everywhere possible.)
>
> Signed-off-by: Sam James <sam@gentoo.org>
> ---
> stdlib/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/stdlib/Makefile b/stdlib/Makefile
> index f7b25c1981..d8b59022cc 100644
> --- a/stdlib/Makefile
> +++ b/stdlib/Makefile
> @@ -380,7 +380,7 @@ CFLAGS-tst-qsort.c += $(stack-align-test-flags)
> CFLAGS-tst-makecontext.c += -funwind-tables
> CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
>
> -CFLAGS-testmb.c += -D_FORTIFY_SOURCE=2 -Wall -Werror
> +CFLAGS-testmb.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Werror
I think we'll be better off with -D_FORTIFY_SOURCE=3 here since the
intent is to test the fortified versions of the mb functions and =3 will
give the maximum coverage. The downside is that it will emit a warning
when building with older gcc (because _FORTIFY_SOURCE=3 is not supported
there and protection will downgrade to _FORTIFY_SOURCE=2) so the -Werror
will need to go away and maybe even need -Wno-error.
Alternatively, some magic here to determine the maximum fortification
level wouldn't hurt, but I won't gate your patch on that :) I can work
on that bit.
Thanks,
Sid
next prev parent reply other threads:[~2022-08-08 13:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-05 20:13 Sam James
2022-08-08 13:26 ` Siddhesh Poyarekar [this message]
2022-08-08 22:30 ` Sam James
2022-08-10 14:29 ` Siddhesh Poyarekar
2022-08-10 15:06 ` Sam James
2023-02-02 18:21 ` Sam James
2023-02-03 4:01 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=294385d7-3974-9089-e190-782bffd40af8@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=libc-alpha@sourceware.org \
--cc=sam@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).