From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Norbert Lange <nolange79@gmail.com>,
Sen Hastings <sen@phobosdpl.com>,
buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] package/systemd: fix build with -Ofast
Date: Sun, 13 Nov 2022 22:01:31 +0100 [thread overview]
Message-ID: <20221113220131.710a51e4@windsurf> (raw)
In-Reply-To: <20221113110901.4065729-1-yann.morin.1998@free.fr>
On Sun, 13 Nov 2022 12:09:01 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> systemd does not build with -Ofast (at least with gcc-12), leading to
> build errors like:
>
> ../src/shared/condition.c: In function ‘condition_dump_list’:
> ../src/shared/condition.c:1227:33: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> 1227 | "%s\t%s: %s%s%s %s\n",
> | ^~
> cc1: some warnings being treated as errors
>
> It is not really clear what the reason is, but it smells like a compiler
> error.
>
> Indeed, the failing format is passed to an fprintf, and the parameter
> corresponding to the failing %s directive is a call to a function
> which prototype is defined but the implementation only comes later in
> the same compilation unit, but is the result of macro expansion, which
> yields a function defintion like:
>
> const char foo_to_string(foo_type i) {
> if (i < 0 || i >= (foo_type) ELEMENTSOF(foo_table))
> return NULL;
> return foo_table[i]
> }
>
> (where ELEMENTSOF(x) is a macros arounf sizeof(x) to determine the
> number of elements in the array foo_table).
>
> However, in the failing case, foo_table is a static const array indexed
> with constants from an enum, and foo_to_string() is only ever called
> with variables that are only ever set to one of those enum values.
>
> Since -Ofast is also explicitly documented as breaking otehrwise
> conformant programs, we're not going to debug further the reason for the
> build failure.
I think it would still make sense to report the bug to gcc upstream.
> Instead, just revert to the best alternate optimisation level. We chose
> -O3, as -Ofast is based on -O3 with breaking optimisation flags.
>
> With -O3, the build succeeds.
>
> Fixes:
> http://autobuild.buildroot.org/results/3ffaa9b3ecacc6ac326be78196af1ad613f195ed/ (sparc64)
> http://autobuild.buildroot.org/results/3f6ae2e503dd1539e4240f344865da4881879204/ (arm)
> http://autobuild.buildroot.org/results/68c17056490d441c7f862349e9c7e471b4570162/ (ppc64)
> ...
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Norbert Lange <nolange79@gmail.com>
> Cc: Sen Hastings <sen@phobosdpl.com>
> ---
> package/systemd/systemd.mk | 5 +++++
> 1 file changed, 5 insertions(+)
But anyway: applied to master, thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
prev parent reply other threads:[~2022-11-13 21:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-13 11:09 [Buildroot] [PATCH] package/systemd: fix build with -Ofast Yann E. MORIN
2022-11-13 21:01 ` Thomas Petazzoni via buildroot [this message]
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=20221113220131.710a51e4@windsurf \
--to=buildroot@buildroot.org \
--cc=nolange79@gmail.com \
--cc=sen@phobosdpl.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=yann.morin.1998@free.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.