[PATCH] build: fix exporting for make 3.82

Jan Beulich posted 1 patch 1 year, 10 months ago
Failed in applying to current master (apply log)
[PATCH] build: fix exporting for make 3.82
Posted by Jan Beulich 1 year, 10 months ago
GNU make 3.82 apparently has a quirk where exporting an undefined
variable prevents its value from subsequently being updated. This
situation can arise due to our adding of -rR to MAKEFLAGS, which takes
effect also on make simply re-invoking itself. Once these flags are in
effect, CC (in particular) is empty (undefined), and would be defined
only via Config.mk including StdGNU.mk or alike. With the quirk, CC
remains empty, yet with an empty CC the compiler minimum version check
fails, breaking the build.

Move the exporting of the various tool stack component variables past
where they gain their (final) values.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
There may be further factors playing into the described quirk, as I've
also observed that simply running make as 2nd time would lead to
successful building of xen/.

While this wasn't a problem until several weeks back, I've not been able
to identify which exact commit would have caused the breakage. Hence no
Fixes: tag.

--- a/xen/Makefile
+++ b/xen/Makefile
@@ -44,8 +44,6 @@ export ARCH SRCARCH
 # Allow someone to change their config file
 export KCONFIG_CONFIG ?= .config
 
-export CC CXX LD NM OBJCOPY OBJDUMP ADDR2LINE
-
 export TARGET := xen
 
 .PHONY: dist
@@ -244,6 +242,7 @@ export TARGET_ARCH     := $(shell echo $
                                 -e s'/riscv.*/riscv/g')
 
 export CONFIG_SHELL := $(SHELL)
+export CC CXX LD NM OBJCOPY OBJDUMP ADDR2LINE
 export YACC = $(if $(BISON),$(BISON),bison)
 export LEX = $(if $(FLEX),$(FLEX),flex)
Re: [PATCH] build: fix exporting for make 3.82
Posted by Anthony PERARD 1 year, 10 months ago
On Tue, Jun 14, 2022 at 05:40:27PM +0200, Jan Beulich wrote:
> GNU make 3.82 apparently has a quirk where exporting an undefined
> variable prevents its value from subsequently being updated. This
> situation can arise due to our adding of -rR to MAKEFLAGS, which takes
> effect also on make simply re-invoking itself. Once these flags are in
> effect, CC (in particular) is empty (undefined), and would be defined
> only via Config.mk including StdGNU.mk or alike. With the quirk, CC
> remains empty, yet with an empty CC the compiler minimum version check
> fails, breaking the build.
> 
> Move the exporting of the various tool stack component variables past
> where they gain their (final) values.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> There may be further factors playing into the described quirk, as I've
> also observed that simply running make as 2nd time would lead to
> successful building of xen/.
> 
> While this wasn't a problem until several weeks back, I've not been able
> to identify which exact commit would have caused the breakage. Hence no
> Fixes: tag.

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Looks like this happened before: be63d9d47f ("build: tweak variable exporting for make 3.82")
So, maybe the issue is started again with 15a0578ca4 ("build: shuffle
main Makefile"), which move the include of Config.mk even later.

Thanks,

-- 
Anthony PERARD
Re: [PATCH] build: fix exporting for make 3.82
Posted by Jan Beulich 1 year, 10 months ago
On 14.06.2022 18:00, Anthony PERARD wrote:
> On Tue, Jun 14, 2022 at 05:40:27PM +0200, Jan Beulich wrote:
>> GNU make 3.82 apparently has a quirk where exporting an undefined
>> variable prevents its value from subsequently being updated. This
>> situation can arise due to our adding of -rR to MAKEFLAGS, which takes
>> effect also on make simply re-invoking itself. Once these flags are in
>> effect, CC (in particular) is empty (undefined), and would be defined
>> only via Config.mk including StdGNU.mk or alike. With the quirk, CC
>> remains empty, yet with an empty CC the compiler minimum version check
>> fails, breaking the build.
>>
>> Move the exporting of the various tool stack component variables past
>> where they gain their (final) values.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> ---
>> There may be further factors playing into the described quirk, as I've
>> also observed that simply running make as 2nd time would lead to
>> successful building of xen/.
>>
>> While this wasn't a problem until several weeks back, I've not been able
>> to identify which exact commit would have caused the breakage. Hence no
>> Fixes: tag.
> 
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks.

> Looks like this happened before: be63d9d47f ("build: tweak variable exporting for make 3.82")

Ah yes. I did think I had to deal with that before, but I did check patches
only back to early 2021. But it's somewhat worse than described there: It's
not just the origin which changes, but (as explained) it actually prevents
the variable to further change its value.

> So, maybe the issue is started again with 15a0578ca4 ("build: shuffle
> main Makefile"), which move the include of Config.mk even later.

Yes, that's certainly it. Thanks for spotting - I'll add a Fixes: tag.

Jan
Re: [PATCH] build: fix exporting for make 3.82
Posted by Jan Beulich 1 year, 10 months ago
On 14.06.2022 17:40, Jan Beulich wrote:
> GNU make 3.82 apparently has a quirk where exporting an undefined
> variable prevents its value from subsequently being updated. This
> situation can arise due to our adding of -rR to MAKEFLAGS, which takes
> effect also on make simply re-invoking itself. Once these flags are in
> effect, CC (in particular) is empty (undefined), and would be defined
> only via Config.mk including StdGNU.mk or alike. With the quirk, CC
> remains empty, yet with an empty CC the compiler minimum version check
> fails, breaking the build.
> 
> Move the exporting of the various tool stack component variables past
> where they gain their (final) values.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> There may be further factors playing into the described quirk, as I've
> also observed that simply running make as 2nd time would lead to
> successful building of xen/.

Albeit perhaps that's simply because then no re-invocation of make is
involved, as auto.conf and auto.conf.cmd then already exist (and are
up-to-date).

Jan

> While this wasn't a problem until several weeks back, I've not been able
> to identify which exact commit would have caused the breakage. Hence no
> Fixes: tag.
> 
> --- a/xen/Makefile
> +++ b/xen/Makefile
> @@ -44,8 +44,6 @@ export ARCH SRCARCH
>  # Allow someone to change their config file
>  export KCONFIG_CONFIG ?= .config
>  
> -export CC CXX LD NM OBJCOPY OBJDUMP ADDR2LINE
> -
>  export TARGET := xen
>  
>  .PHONY: dist
> @@ -244,6 +242,7 @@ export TARGET_ARCH     := $(shell echo $
>                                  -e s'/riscv.*/riscv/g')
>  
>  export CONFIG_SHELL := $(SHELL)
> +export CC CXX LD NM OBJCOPY OBJDUMP ADDR2LINE
>  export YACC = $(if $(BISON),$(BISON),bison)
>  export LEX = $(if $(FLEX),$(FLEX),flex)
>  
>