Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
@ 2023-02-21 14:21 Fabrice Fontaine
  2023-02-21 14:48 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 7+ messages in thread
From: Fabrice Fontaine @ 2023-02-21 14:21 UTC (permalink / raw)
  To: buildroot; +Cc: Norbert Lange, Fabrice Fontaine, Sen Hastings, Yann E . MORIN

systemd can't be built with -Ofast since version 252 and
https://github.com/systemd/systemd/commit/60f97fee2d2f948c8e8963ea8ff767008cb93cae
resulting in the following build failure since bump to version 252.4 in
commit a2c823d1f548d5a0120d27d6c000603192360f7b:

../output-1/build/systemd-252.4/meson.build:397:8: ERROR: Problem encountered: -Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.

While at it, revert changes made by commit 9cd084b54e2223e49c37962b0cbefae7bea26ef5

Fixes:
 - http://autobuild.buildroot.org/results/8f41c4984b645851724e554c3162b83bc312bee7

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 package/systemd/Config.in  | 1 +
 package/systemd/systemd.mk | 5 -----
 system/Config.in           | 4 ++++
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 9f4d933779..5bbdbb405f 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -25,6 +25,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
 	depends on BR2_HOST_GCC_AT_LEAST_5 # host-systemd
+	depends on !BR2_OPTIMIZE_FAST
 	select BR2_PACKAGE_HAS_UDEV
 	select BR2_PACKAGE_DBUS if !BR2_PACKAGE_DBUS_BROKER # runtime
 	select BR2_PACKAGE_LIBCAP
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index cce9162f6d..edba8c2677 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -98,11 +98,6 @@ SYSTEMD_CONF_OPTS += \
 	-Dtmpfiles=true \
 	-Dumount-path=/usr/bin/umount
 
-SYSTEMD_CFLAGS = $(TARGET_CFLAGS)
-ifeq ($(BR2_OPTIMIZE_FAST),y)
-SYSTEMD_CFLAGS += -O3
-endif
-
 ifeq ($(BR2_nios2),y)
 # Nios2 ld emits warnings, make warnings not to be treated as errors
 SYSTEMD_LDFLAGS = $(TARGET_LDFLAGS) -Wl,--no-fatal-warnings
diff --git a/system/Config.in b/system/Config.in
index 1ca7690ea3..8a8b198fcd 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -127,6 +127,7 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
 	depends on BR2_HOST_GCC_AT_LEAST_5
+	depends on !BR2_OPTIMIZE_FAST
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
 	select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_ROOTFS_SKELETON_DEFAULT
@@ -140,6 +141,9 @@ comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.15, host and targe
 		!BR2_TOOLCHAIN_GCC_AT_LEAST_5 || \
 		!BR2_HOST_GCC_AT_LEAST_5
 
+comment "systemd can't be built with Optimize for fast"
+	depends on BR2_OPTIMIZE_FAST
+
 comment "systemd highly recommends Linux >= 4.15"
 	depends on BR2_INIT_SYSTEMD
 	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_15
-- 
2.39.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
  2023-02-21 14:21 [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast Fabrice Fontaine
@ 2023-02-21 14:48 ` Thomas Petazzoni via buildroot
  2023-02-21 20:08   ` Yann E. MORIN
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-02-21 14:48 UTC (permalink / raw)
  To: Fabrice Fontaine; +Cc: Norbert Lange, Sen Hastings, Yann E . MORIN, buildroot

Hello Fabrice,

On Tue, 21 Feb 2023 15:21:44 +0100
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> systemd can't be built with -Ofast since version 252 and
> https://github.com/systemd/systemd/commit/60f97fee2d2f948c8e8963ea8ff767008cb93cae
> resulting in the following build failure since bump to version 252.4 in
> commit a2c823d1f548d5a0120d27d6c000603192360f7b:
> 
> ../output-1/build/systemd-252.4/meson.build:397:8: ERROR: Problem encountered: -Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.
> 
> While at it, revert changes made by commit 9cd084b54e2223e49c37962b0cbefae7bea26ef5
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/8f41c4984b645851724e554c3162b83bc312bee7
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  package/systemd/Config.in  | 1 +
>  package/systemd/systemd.mk | 5 -----
>  system/Config.in           | 4 ++++
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 9f4d933779..5bbdbb405f 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -25,6 +25,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
>  	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
>  	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
>  	depends on BR2_HOST_GCC_AT_LEAST_5 # host-systemd
> +	depends on !BR2_OPTIMIZE_FAST

I really dislike this.

> -SYSTEMD_CFLAGS = $(TARGET_CFLAGS)
> -ifeq ($(BR2_OPTIMIZE_FAST),y)
> -SYSTEMD_CFLAGS += -O3
> -endif

And this should work. It's really systemd that is stupid to look for
-Ofast in c_flags without seeing that -O3 later overrides it.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
  2023-02-21 14:48 ` Thomas Petazzoni via buildroot
@ 2023-02-21 20:08   ` Yann E. MORIN
  2023-02-21 20:26     ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2023-02-21 20:08 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Norbert Lange, Fabrice Fontaine, Sen Hastings, buildroot

Fabrice, all,

On 2023-02-21 15:48 +0100, Thomas Petazzoni spake thusly:
> Hello Fabrice,
> 
> On Tue, 21 Feb 2023 15:21:44 +0100
> Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
> 
> > systemd can't be built with -Ofast since version 252 and
> > https://github.com/systemd/systemd/commit/60f97fee2d2f948c8e8963ea8ff767008cb93cae
> > resulting in the following build failure since bump to version 252.4 in
> > commit a2c823d1f548d5a0120d27d6c000603192360f7b:
> > 
> > ../output-1/build/systemd-252.4/meson.build:397:8: ERROR: Problem encountered: -Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.
> > 
> > While at it, revert changes made by commit 9cd084b54e2223e49c37962b0cbefae7bea26ef5
> > 
> > Fixes:
> >  - http://autobuild.buildroot.org/results/8f41c4984b645851724e554c3162b83bc312bee7
> > 
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> > ---
> >  package/systemd/Config.in  | 1 +
> >  package/systemd/systemd.mk | 5 -----
> >  system/Config.in           | 4 ++++
> >  3 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> > index 9f4d933779..5bbdbb405f 100644
> > --- a/package/systemd/Config.in
> > +++ b/package/systemd/Config.in
> > @@ -25,6 +25,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
> >  	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
> >  	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
> >  	depends on BR2_HOST_GCC_AT_LEAST_5 # host-systemd
> > +	depends on !BR2_OPTIMIZE_FAST
> I really dislike this.

Agreed.

> > -SYSTEMD_CFLAGS = $(TARGET_CFLAGS)
> > -ifeq ($(BR2_OPTIMIZE_FAST),y)
> > -SYSTEMD_CFLAGS += -O3
> > -endif
> 
> And this should work. It's really systemd that is stupid to look for
> -Ofast in c_flags without seeing that -O3 later overrides it.

Indeed. Probably something along the lines of:

    SYSTEMD_CFLAGS = $(filter-out -Ofast,$(TARGET_CFLAGS))

would do the trick?

Alternatively, as the upstream commit also implies, maybe we should in
this case keep -Ofast and just add:

    SYSTEMD_CFLAGS = $(TARGET_CFLAGS) -fno-finite-math-only

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
  2023-02-21 20:08   ` Yann E. MORIN
@ 2023-02-21 20:26     ` Thomas Petazzoni via buildroot
  2023-02-21 20:34       ` Yann E. MORIN
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-02-21 20:26 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: Norbert Lange, Fabrice Fontaine, Sen Hastings, buildroot

On Tue, 21 Feb 2023 21:08:57 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> Alternatively, as the upstream commit also implies, maybe we should in
> this case keep -Ofast and just add:
> 
>     SYSTEMD_CFLAGS = $(TARGET_CFLAGS) -fno-finite-math-only

But the upstream commit causes the build to bail out as soon as -Ofast
is in the CFLAGS, so even if you specify -Ofast -fno-finite-math-only,
systemd's meson machinery will bail out.

So your other idea of:

SYSTEMD_CFLAGS = $(filter-out -Ofast,$(TARGET_CFLAGS))

certainly looks very relevant.

Fabrice, could you give it a try?

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
  2023-02-21 20:26     ` Thomas Petazzoni via buildroot
@ 2023-02-21 20:34       ` Yann E. MORIN
  2023-02-21 20:49         ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2023-02-21 20:34 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Norbert Lange, Fabrice Fontaine, Sen Hastings, buildroot

On 2023-02-21 21:26 +0100, Thomas Petazzoni spake thusly:
> On Tue, 21 Feb 2023 21:08:57 +0100
> "Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> 
> > Alternatively, as the upstream commit also implies, maybe we should in
> > this case keep -Ofast and just add:
> > 
> >     SYSTEMD_CFLAGS = $(TARGET_CFLAGS) -fno-finite-math-only
> 
> But the upstream commit causes the build to bail out as soon as -Ofast
> is in the CFLAGS, so even if you specify -Ofast -fno-finite-math-only,
> systemd's meson machinery will bail out.

The upstream code is (split for readability):

     if (('-Ofast' in c_args or
          '-ffast-math' in c_args or
          '-ffinite-math-only' in c_args
         ) and
         not '-fno-finite-math-only' in c_args
        )

So, if -fno-finite-math-only is in c_args, then the whole condition
should evaluate to false, and thus it should not error out, right?

Or did I lose more than my grep-fu? ;-)

Regards,
Yann E. MORIN.

> So your other idea of:
> 
> SYSTEMD_CFLAGS = $(filter-out -Ofast,$(TARGET_CFLAGS))
> 
> certainly looks very relevant.
> 
> Fabrice, could you give it a try?
> 
> Thomas
> -- 
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
  2023-02-21 20:34       ` Yann E. MORIN
@ 2023-02-21 20:49         ` Thomas Petazzoni via buildroot
  2023-02-21 21:15           ` Yann E. MORIN
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-02-21 20:49 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: Norbert Lange, Fabrice Fontaine, Sen Hastings, buildroot

On Tue, 21 Feb 2023 21:34:03 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> The upstream code is (split for readability):
> 
>      if (('-Ofast' in c_args or
>           '-ffast-math' in c_args or
>           '-ffinite-math-only' in c_args
>          ) and
>          not '-fno-finite-math-only' in c_args
>         )
> 
> So, if -fno-finite-math-only is in c_args, then the whole condition
> should evaluate to false, and thus it should not error out, right?
> 
> Or did I lose more than my grep-fu? ;-)

No, tonight your grep-fu is better than mine: you're totally right! :-)

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast
  2023-02-21 20:49         ` Thomas Petazzoni via buildroot
@ 2023-02-21 21:15           ` Yann E. MORIN
  0 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2023-02-21 21:15 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Norbert Lange, Fabrice Fontaine, Sen Hastings, buildroot

Thomas, All,

On 2023-02-21 21:49 +0100, Thomas Petazzoni spake thusly:
> On Tue, 21 Feb 2023 21:34:03 +0100
> "Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> 
> > The upstream code is (split for readability):
> > 
> >      if (('-Ofast' in c_args or
> >           '-ffast-math' in c_args or
> >           '-ffinite-math-only' in c_args
> >          ) and
> >          not '-fno-finite-math-only' in c_args
> >         )
> > 
> > So, if -fno-finite-math-only is in c_args, then the whole condition
> > should evaluate to false, and thus it should not error out, right?
> > 
> > Or did I lose more than my grep-fu? ;-)
> 
> No, tonight your grep-fu is better than mine: you're totally right! :-)

Note however that upstream code is anyway buggy. If CFLAGS contain, in
that order:

    -fno-finite-math-only -ffinite-math-only

then the condition will evaluate to false, and thus the test will not
abort, but still this would be incorrect, as -ffinite-math-only would
win the setting because it comes last...

So presumably, we should even be able to do:

    SYSTEMD_CFLAGS = $(TARGET_CFLAGS) -fno-finite-math-only -ffinite-math-only

which would again break the build....

Even if we do not do that ourselves, nothing prevents a suer from
providing that in their BR2_TARGET_OPTIMIZATION. But then, we can't
protect people from shooting themselves in the foot... ;-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-21 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-21 14:21 [Buildroot] [PATCH 1/1] package/systemd: disable with -Ofast Fabrice Fontaine
2023-02-21 14:48 ` Thomas Petazzoni via buildroot
2023-02-21 20:08   ` Yann E. MORIN
2023-02-21 20:26     ` Thomas Petazzoni via buildroot
2023-02-21 20:34       ` Yann E. MORIN
2023-02-21 20:49         ` Thomas Petazzoni via buildroot
2023-02-21 21:15           ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox