diff mbox series

[v2] glibc: build: honor toplevel BR2_TARGET_OPTIMIZATION

Message ID 20240214230114.551779-1-vineetg@rivosinc.com
State New
Headers show
Series [v2] glibc: build: honor toplevel BR2_TARGET_OPTIMIZATION | expand

Commit Message

Vineet Gupta Feb. 14, 2024, 11:01 p.m. UTC
glibc though part of toolchain is technically target binary and thus
needs to be built with BR2_TARGET_OPTIMIZATION in case users want to
force a certain build toogle from top level.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
---
Changes since v1:
  - Add to exisiting GLIBC_EXTRA_CFLAGS if any
---
 package/glibc/glibc.mk | 3 +++
 1 file changed, 3 insertions(+)

Comments

Arnout Vandecappelle Feb. 15, 2024, 7:53 a.m. UTC | #1
On 15/02/2024 00:01, Vineet Gupta wrote:
> glibc though part of toolchain is technically target binary and thus
> needs to be built with BR2_TARGET_OPTIMIZATION in case users want to
> force a certain build toogle from top level.

  BR2_TARGET_OPTIMIZATION is encoded in the toolchain wrapper, and as far as I 
can see glibc is built with the toolchain wrapper... I haven't (re)tested it, 
but it should be the case...

  BR2_TARGET_OPTIMIZATION was added to the wrapper in commit 
b95e436ee0c9e4638dc79766da0d17927c6641ce in 2011.

  The wrapper was added to host-gcc-initial (which is used in the glibc build) 
in commit 919c06c28295f19ca49459b98d8954148b381360 in 2015.

  Regards,
  Arnout

> 
> Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
> ---
> Changes since v1:
>    - Add to exisiting GLIBC_EXTRA_CFLAGS if any
> ---
>   package/glibc/glibc.mk | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/package/glibc/glibc.mk b/package/glibc/glibc.mk
> index d198d6f04cb2..ebcd7b2bdb21 100644
> --- a/package/glibc/glibc.mk
> +++ b/package/glibc/glibc.mk
> @@ -80,6 +80,9 @@ GLIBC_INSTALL_STAGING = YES
>   
>   GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install
>   
> +# Seed with any special toggles user may have setup in config
> +GLIBC_EXTRA_CFLAGS += $(BR2_TARGET_OPTIMIZATION)
> +
>   # Thumb build is broken, build in ARM mode
>   ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
>   GLIBC_EXTRA_CFLAGS += -marm
Vineet Gupta Feb. 16, 2024, 8:09 p.m. UTC | #2
On 2/14/24 23:53, Arnout Vandecappelle wrote:
>
> On 15/02/2024 00:01, Vineet Gupta wrote:
>> glibc though part of toolchain is technically target binary and thus
>> needs to be built with BR2_TARGET_OPTIMIZATION in case users want to
>> force a certain build toogle from top level.
>   BR2_TARGET_OPTIMIZATION is encoded in the toolchain wrapper, and as far as I 
> can see glibc is built with the toolchain wrapper... I haven't (re)tested it, 
> but it should be the case...

Indeed the toggles are effectively being used in the build, even if not
visible in the build logs, which is what tripped me up in the first
place. And before sending the patch I did wonder how buildroot could
have such an obvious deficiency for so long. In the past I've myself
sent a few patches to defconfigs to affect such build toggles in first
place ;-)

   2021-01-16 32113c8a25c0 configs/snps_archs38_hsdk_defconfig: use
hard-float  


>   BR2_TARGET_OPTIMIZATION was added to the wrapper in commit 
> b95e436ee0c9e4638dc79766da0d17927c6641ce in 2011.
>
>   The wrapper was added to host-gcc-initial (which is used in the glibc build) 
> in commit 919c06c28295f19ca49459b98d8954148b381360 in 2015.

I still think that an explicit comment such as below will help a poor
lost soul of future going git grep.

---------->
From 5b82e169aa21916833b62fe5122c844cec62f486 Mon Sep 17 00:00:00 2001
From: Vineet Gupta <vineetg@rivosinc.com>
Date: Fri, 16 Feb 2024 12:07:07 -0800
Subject: [PATCH] glibc: build: add comment about BR2_TARGET_OPTIMIZATION

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
---
 package/glibc/glibc.mk | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/package/glibc/glibc.mk b/package/glibc/glibc.mk
index d198d6f04cb2..facad0b29958 100644
--- a/package/glibc/glibc.mk
+++ b/package/glibc/glibc.mk
@@ -80,6 +80,9 @@ GLIBC_INSTALL_STAGING = YES
 
 GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install
 
+# Note that BR2_TARGET_OPTIMIZATION toggles are implicitly passed
+# here via the toolchain wrapper setup
+
 # Thumb build is broken, build in ARM mode
 ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
 GLIBC_EXTRA_CFLAGS += -marm
diff mbox series

Patch

diff --git a/package/glibc/glibc.mk b/package/glibc/glibc.mk
index d198d6f04cb2..ebcd7b2bdb21 100644
--- a/package/glibc/glibc.mk
+++ b/package/glibc/glibc.mk
@@ -80,6 +80,9 @@  GLIBC_INSTALL_STAGING = YES
 
 GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install
 
+# Seed with any special toggles user may have setup in config
+GLIBC_EXTRA_CFLAGS += $(BR2_TARGET_OPTIMIZATION)
+
 # Thumb build is broken, build in ARM mode
 ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
 GLIBC_EXTRA_CFLAGS += -marm