Skip to contentSkip to conversation

build/xen: fail to rebuild if Kconfig fails

PATCH In review Roger Pau Monne 3 participants 17 messages Feb 15, 2024 – Feb 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build/xen: fail to rebuild if Kconfig fails

When doing a rebuild with an xen/include/config/auto.conf already present in the tree, failures from Kconfig are ignored since the target is present:

gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen' tools/kconfig/conf --syncconfig Kconfig common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
UPD include/xen/compile.h
Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
gmake[2]: 'arch/x86/include/asm/asm-offsets.h' is up to date.

Ultimately leading to a successful build despite the Kconfig error.

Fix this by first removing xen/include/config/auto.conf before attempting to regenerate, and then also make xen/include/config/auto.conf a hard dependency of the build process (ie: drop the leading '-') and reordering so the .cmd target is executed before including the configuration file.

This leads to the build properly failing if the config file cannot be re-generated:

gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf --syncconfig Kconfig common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1 gmake[1]: *** [Makefile:379: include/config/auto.conf] Error 2 gmake[1]: Leaving directory '/root/src/xen/xen'
gmake: *** [Makefile:143: install-xen] Error 2

---
Maybe there's a better way for dealing with all this, my makefile foo is very limited.

---
 xen/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/Makefile +2 -1
index 21832d640225..7e6860a58a1d 100644
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf
 
 # Allow people to just run `make` as before and not force them to configure
 # Only run defconfig if $(KCONFIG_CONFIG) is missing
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
Signature · 1 line
2.43.0
#1 lore raw

xen/Makefile config: tools_fixdep outputmakefile FORCE · line 364

Quoted 11 lines · Roger Pau Monne
xen/Makefile +1 -1
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf

With the - dropped, ...

xen/Makefile $(KCONFIG_CONFIG): tools_fixdep · line 379

Quoted 6 lines
xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig

... is this really necessary? The error status from the sub-make is ignored only because of the -, isn't it?

I also don't really follow the need to re-order the include-s above. Their ordering ought to be benign, as per make's doc stating "If an included makefile cannot be found in any of these directories it is not an immediately fatal error; processing of the makefile containing the include continues." While the description talks about this, I'm afraid I don't really understand "... the .cmd target is executed before including ...":
What .cmd target are you talking about there? That's merely another include (and what is included doesn't provide any .cmd target afaics), so will be dealt with the same as the config/auto.conf one itself.

Jan

#2 lore raw
Quoted 15 lines · Jan Beulich

xen/Makefile config: tools_fixdep outputmakefile FORCE · line 364

Quoted 11 lines · Roger Pau Monne
xen/Makefile +1 -1
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf

With the - dropped, ...

Quoted 9 lines

xen/Makefile $(KCONFIG_CONFIG): tools_fixdep · line 379

Quoted 6 lines
xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig

... is this really necessary? The error status from the sub-make is ignored only because of the -, isn't it?

Without the rm the include/config/auto.conf is not removed by Kconfig on error, so the include will still succeed but use the stale auto.conf file.

Keep in mind on rebuilds include/config/auto.conf is already present, so the rule is only executed for the include/config/auto.conf.cmd target.

Quoted 8 lines

I also don't really follow the need to re-order the include-s above. Their ordering ought to be benign, as per make's doc stating "If an included makefile cannot be found in any of these directories it is not an immediately fatal error; processing of the makefile containing the include continues." While the description talks about this, I'm afraid I don't really understand "... the .cmd target is executed before including ...":
What .cmd target are you talking about there?

Without the reordering the include of include/config/auto.conf will always succeed on rebuilds, because the include is done before executing the include/config/%.conf.cmd target that does the rm.

With the current order the include of include/config/%.conf.cmd that triggers the re-build of auto.conf happens after having included the file already.

Thanks, Roger.

#3 lore raw
Quoted 26 lines · Roger Pau Monné
Quoted 15 lines · Jan Beulich

xen/Makefile config: tools_fixdep outputmakefile FORCE · line 364

Quoted 11 lines · Roger Pau Monne
xen/Makefile +1 -1
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf

With the - dropped, ...

Quoted 9 lines

xen/Makefile $(KCONFIG_CONFIG): tools_fixdep · line 379

Quoted 6 lines
xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig

... is this really necessary? The error status from the sub-make is ignored only because of the -, isn't it?

Quoted 7 lines

Without the rm the include/config/auto.conf is not removed by Kconfig on error, so the include will still succeed but use the stale auto.conf file.

Keep in mind on rebuilds include/config/auto.conf is already present, so the rule is only executed for the include/config/auto.conf.cmd target.

But the sub-make ought to return failure, which ought to then stop the build process?

Quoted 11 lines
Quoted 7 lines

I also don't really follow the need to re-order the include-s above. Their ordering ought to be benign, as per make's doc stating "If an included makefile cannot be found in any of these directories it is not an immediately fatal error; processing of the makefile containing the include continues." While the description talks about this, I'm afraid I don't really understand "... the .cmd target is executed before including ...":
What .cmd target are you talking about there?

Without the reordering the include of include/config/auto.conf will always succeed on rebuilds, because the include is done before executing the include/config/%.conf.cmd target that does the rm.

That's a dual target: It also handles include/config/%.conf. I.e. because of this ...

Quoted 3 lines

With the current order the include of include/config/%.conf.cmd that triggers the re-build of auto.conf happens after having included the file already.

... either include would trigger this same rule. IOW I'm afraid I'm still not seeing what is gained by the re-ordering. I'm also unconvinced that "triggers" in the sense you use it is actually applicable. Quoting make doc again: "Once it has finished reading makefiles, make will try to remake any that are out of date or don’t exist." To me this means that first all makefile reading will finish, and then whichever included files need re-making will be re-made.

Jan

#4 lore raw
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 15 lines · Jan Beulich

xen/Makefile config: tools_fixdep outputmakefile FORCE · line 364

Quoted 11 lines · Roger Pau Monne
xen/Makefile +1 -1
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf

With the - dropped, ...

Quoted 9 lines

xen/Makefile $(KCONFIG_CONFIG): tools_fixdep · line 379

Quoted 6 lines
xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig

... is this really necessary? The error status from the sub-make is ignored only because of the -, isn't it?

Without the rm the include/config/auto.conf is not removed by Kconfig on error, so the include will still succeed but use the stale auto.conf file.

Quoted 6 lines
Quoted 3 lines

Keep in mind on rebuilds include/config/auto.conf is already present, so the rule is only executed for the include/config/auto.conf.cmd target.

But the sub-make ought to return failure, which ought to then stop the build process?

For some reason it doesn't, not at least with GNU Make 4.3.

It stops the build if the '-' is dropped from the include of include/config/auto.conf.cmd. But that will always fail as include/config/auto.conf.cmd is never created.

Maybe there's something weird with our makefile, I certainly don't know that much, but as noted in the commit message, include/config/auto.conf.cmd failing doesn't cause the build to stop.

Quoted 19 lines
Quoted 11 lines
Quoted 7 lines

I also don't really follow the need to re-order the include-s above. Their ordering ought to be benign, as per make's doc stating "If an included makefile cannot be found in any of these directories it is not an immediately fatal error; processing of the makefile containing the include continues." While the description talks about this, I'm afraid I don't really understand "... the .cmd target is executed before including ...":
What .cmd target are you talking about there?

Without the reordering the include of include/config/auto.conf will always succeed on rebuilds, because the include is done before executing the include/config/%.conf.cmd target that does the rm.

That's a dual target: It also handles include/config/%.conf. I.e. because of this ...

Quoted 3 lines

With the current order the include of include/config/%.conf.cmd that triggers the re-build of auto.conf happens after having included the file already.

Quoted 7 lines

... either include would trigger this same rule. IOW I'm afraid I'm still not seeing what is gained by the re-ordering. I'm also unconvinced that "triggers" in the sense you use it is actually applicable. Quoting make doc again: "Once it has finished reading makefiles, make will try to remake any that are out of date or don’t exist." To me this means that first all makefile reading will finish, and then whichever included files need re-making will be re-made.

Without the re-ordering the execution is not stopped on failure to generate include/config/auto.conf:

# gmake -j8 xen clang=y
gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf  --syncconfig Kconfig
common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
gmake[1]: Failed to remake makefile 'include/config/auto.conf'.
  UPD     include/xen/compile.h
 Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
[...]

With the re-ordering:

# gmake -j8 xen clang=y
gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf  --syncconfig Kconfig
common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
gmake[1]: *** [Makefile:379: include/config/auto.conf] Error 2
gmake[1]: Leaving directory '/root/src/xen/xen'
gmake: *** [Makefile:143: install-xen] Error 2
#

So the re-ordering is meaningful.

Thanks, Roger.

#5 lore raw
Quoted 53 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 3 lines · Roger Pau Monné

Without the reordering the include of include/config/auto.conf will always succeed on rebuilds, because the include is done before executing the include/config/%.conf.cmd target that does the rm.

That's a dual target: It also handles include/config/%.conf. I.e. because of this ...

Quoted 3 lines

With the current order the include of include/config/%.conf.cmd that triggers the re-build of auto.conf happens after having included the file already.

Quoted 7 lines

... either include would trigger this same rule. IOW I'm afraid I'm still not seeing what is gained by the re-ordering. I'm also unconvinced that "triggers" in the sense you use it is actually applicable. Quoting make doc again: "Once it has finished reading makefiles, make will try to remake any that are out of date or don’t exist." To me this means that first all makefile reading will finish, and then whichever included files need re-making will be re-made.

Without the re-ordering the execution is not stopped on failure to generate include/config/auto.conf:

# gmake -j8 xen clang=y
gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf  --syncconfig Kconfig
common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
gmake[1]: Failed to remake makefile 'include/config/auto.conf'.
  UPD     include/xen/compile.h
 Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
[...]

With the re-ordering:

# gmake -j8 xen clang=y
gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf  --syncconfig Kconfig
common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
gmake[1]: *** [Makefile:379: include/config/auto.conf] Error 2
gmake[1]: Leaving directory '/root/src/xen/xen'
gmake: *** [Makefile:143: install-xen] Error 2
#
Quoted 1 line

So the re-ordering is meaningful.

Hmm, I was about to say "no, it isn't" but then remembered to try newer make. With 3.81 all is working as intended with no re-ordering. I wonder if this isn't something with make, rather than our makefiles ...

Jan

#6 lore raw
Quoted 54 lines · Jan Beulich
Quoted 53 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 3 lines · Roger Pau Monné

Without the reordering the include of include/config/auto.conf will always succeed on rebuilds, because the include is done before executing the include/config/%.conf.cmd target that does the rm.

That's a dual target: It also handles include/config/%.conf. I.e. because of this ...

Quoted 3 lines

With the current order the include of include/config/%.conf.cmd that triggers the re-build of auto.conf happens after having included the file already.

Quoted 7 lines

... either include would trigger this same rule. IOW I'm afraid I'm still not seeing what is gained by the re-ordering. I'm also unconvinced that "triggers" in the sense you use it is actually applicable. Quoting make doc again: "Once it has finished reading makefiles, make will try to remake any that are out of date or don’t exist." To me this means that first all makefile reading will finish, and then whichever included files need re-making will be re-made.

Without the re-ordering the execution is not stopped on failure to generate include/config/auto.conf:

# gmake -j8 xen clang=y
gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf  --syncconfig Kconfig
common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
gmake[1]: Failed to remake makefile 'include/config/auto.conf'.
  UPD     include/xen/compile.h
 Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
[...]

With the re-ordering:

# gmake -j8 xen clang=y
gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen'
rm -rf include/config/auto.conf
tools/kconfig/conf  --syncconfig Kconfig
common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
gmake[1]: *** [Makefile:379: include/config/auto.conf] Error 2
gmake[1]: Leaving directory '/root/src/xen/xen'
gmake: *** [Makefile:143: install-xen] Error 2
#
Quoted 5 lines
Quoted 1 line

So the re-ordering is meaningful.

Hmm, I was about to say "no, it isn't" but then remembered to try newer make. With 3.81 all is working as intended with no re-ordering. I wonder if this isn't something with make, rather than our makefiles ...

And indeed it's quite strange: The same effect can be had by dropping the
- from the other include (and no re-ordering). Extending the sub-make invocation to

	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig || { err=$$?; echo "$@: error $$err" >&2; exit $$err; }

I can see that it's the latter of the includes which is reported as $@, and failure of the sub-make is conveyed only when it's the latter of the includes which has no -. When really any of the targets being subject of "include" without - should respect failure.

I'll play with this some more, but considering the overall situation maybe (perhaps just partly) reverting the commit Anthony pointed out is then the least bad option, accepting the warnings with old make.

Jan

#7 lore raw
In reply to Roger Pau Monné
Quoted 41 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 15 lines · Jan Beulich

xen/Makefile config: tools_fixdep outputmakefile FORCE · line 364

Quoted 11 lines · Roger Pau Monne
xen/Makefile +1 -1
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf

With the - dropped, ...

Quoted 9 lines

xen/Makefile $(KCONFIG_CONFIG): tools_fixdep · line 379

Quoted 6 lines
xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig

... is this really necessary? The error status from the sub-make is ignored only because of the -, isn't it?

Without the rm the include/config/auto.conf is not removed by Kconfig on error, so the include will still succeed but use the stale auto.conf file.

Quoted 6 lines
Quoted 3 lines

Keep in mind on rebuilds include/config/auto.conf is already present, so the rule is only executed for the include/config/auto.conf.cmd target.

But the sub-make ought to return failure, which ought to then stop the build process?

For some reason it doesn't, not at least with GNU Make 4.3.

Quoted 8 lines

It stops the build if the '-' is dropped from the include of include/config/auto.conf.cmd. But that will always fail as include/config/auto.conf.cmd is never created.

Maybe there's something weird with our makefile, I certainly don't know that much, but as noted in the commit message, include/config/auto.conf.cmd failing doesn't cause the build to stop.

How about the below as an alternative? I'm not overly happy with the double ifneq, but I also don't see a good other option.

This way the missing auto.conf is detected slightly later, but this may well be good enough. Then again I might be overlooking yet something else that this breaks ...

Jan

xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
xen/Rules.mk +5 -1
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
#8 lore raw
Quoted 46 lines · Jan Beulich
Quoted 45 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 15 lines · Jan Beulich

xen/Makefile config: tools_fixdep outputmakefile FORCE · line 364

Quoted 11 lines · Roger Pau Monne
xen/Makefile +1 -1
@@ -358,10 +358,10 @@ config: tools_fixdep outputmakefile FORCE
 else # !config-build
 
 ifeq ($(need-config),y)
--include include/config/auto.conf
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected.
 -include include/config/auto.conf.cmd
+include include/config/auto.conf

With the - dropped, ...

Quoted 9 lines

xen/Makefile $(KCONFIG_CONFIG): tools_fixdep · line 379

Quoted 6 lines
xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	rm -rf include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig

... is this really necessary? The error status from the sub-make is ignored only because of the -, isn't it?

Without the rm the include/config/auto.conf is not removed by Kconfig on error, so the include will still succeed but use the stale auto.conf file.

Quoted 6 lines
Quoted 3 lines

Keep in mind on rebuilds include/config/auto.conf is already present, so the rule is only executed for the include/config/auto.conf.cmd target.

But the sub-make ought to return failure, which ought to then stop the build process?

For some reason it doesn't, not at least with GNU Make 4.3.

It stops the build if the '-' is dropped from the include of include/config/auto.conf.cmd. But that will always fail as include/config/auto.conf.cmd is never created.

Quoted 7 lines
Quoted 4 lines

Maybe there's something weird with our makefile, I certainly don't know that much, but as noted in the commit message, include/config/auto.conf.cmd failing doesn't cause the build to stop.

How about the below as an alternative? I'm not overly happy with the double ifneq, but I also don't see a good other option.

Hm, yes, having the checks against specific paths is IMO not ideal.

Quoted 19 lines

This way the missing auto.conf is detected slightly later, but this may well be good enough. Then again I might be overlooking yet something else that this breaks ...

Jan

xen/Makefile +1 -0
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/$*.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)

xen/Rules.mk srcdir := $(srctree)/$(src) · line 22

Quoted 9 lines
xen/Rules.mk +5 -1
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif

Trying to understand this, I assume it's to avoid an infinite dependency loop that generating include/config/auto.conf requires some tools that are build using xen/Rules.mk?

Thanks, Roger.

#9 lore raw
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
xen/Rules.mk +0 -0
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
Quoted 10 lines

xen/Rules.mk srcdir := $(srctree)/$(src) · line 22

Quoted 6 lines
xen/Rules.mk +5 -1
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif

Trying to understand this, I assume it's to avoid an infinite dependency loop that generating include/config/auto.conf requires some tools that are build using xen/Rules.mk?

The file has dependencies only in xen/Makefile. This is about the file simply not being there when initially building. Perhaps the patch description helps that I've written in the meantime:

"Because of using "-include", failure to (re)build auto.conf (with
auto.conf.cmd produced as a secondary target) won't stop make from continuing the build. Arrange for it being possible to drop the - from Rules.mk, requiring that the include be skipped for tools-only targets. Note that relying on the inclusion in those cases wouldn't be correct anyway, as it might be a stale file (yet to be rebuilt) which would be included, while during initial build, the file would be absent altogether."

Jan

#10 lore raw
Quoted 19 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
xen/Rules.mk +0 -0
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
Quoted 10 lines

xen/Rules.mk srcdir := $(srctree)/$(src) · line 22

Quoted 6 lines
xen/Rules.mk +5 -1
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif

Trying to understand this, I assume it's to avoid an infinite dependency loop that generating include/config/auto.conf requires some tools that are build using xen/Rules.mk?

Quoted 8 lines

The file has dependencies only in xen/Makefile. This is about the file simply not being there when initially building. Perhaps the patch description helps that I've written in the meantime:

"Because of using "-include", failure to (re)build auto.conf (with
auto.conf.cmd produced as a secondary target) won't stop make from continuing the build. Arrange for it being possible to drop the - from Rules.mk, requiring that the include be skipped for tools-only targets.

Wouldn't it be more reliable if we skipped the include for any paths in $(obj) that start with 'tools', rather than hardcoding 'tools' and 'tools/kconfig'?

Thanks, Roger.

#11 lore raw
Quoted 24 lines · Roger Pau Monné
Quoted 23 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
xen/Rules.mk +0 -0
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
Quoted 10 lines

xen/Rules.mk srcdir := $(srctree)/$(src) · line 22

Quoted 6 lines
xen/Rules.mk +5 -1
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif

Trying to understand this, I assume it's to avoid an infinite dependency loop that generating include/config/auto.conf requires some tools that are build using xen/Rules.mk?

The file has dependencies only in xen/Makefile. This is about the file simply not being there when initially building. Perhaps the patch description helps that I've written in the meantime:

Quoted 8 lines
Quoted 4 lines

"Because of using "-include", failure to (re)build auto.conf (with
auto.conf.cmd produced as a secondary target) won't stop make from continuing the build. Arrange for it being possible to drop the - from Rules.mk, requiring that the include be skipped for tools-only targets.

Wouldn't it be more reliable if we skipped the include for any paths in $(obj) that start with 'tools', rather than hardcoding 'tools' and 'tools/kconfig'?

I was first meaning to do so, but the expression would end up more complex than I'd like (for it needing to be an exact match of "tools" and a prefix match of "tools/"). Thinking of it,

ifneq ($(obj),tools)
ifneq ($(patsubst tools/%,$(obj)),)

might do (and not be as complex as I first thought, when intending to put all in a single "if").

Yet then it's not entirely impossible that we might gain a build tool which is actually to be built after .config was (re)generated, i.e. in the know of the target configuration. Thoughts?

Jan

#12 lore raw
Quoted 38 lines · Jan Beulich
Quoted 24 lines · Roger Pau Monné
Quoted 23 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
xen/Rules.mk +0 -0
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
Quoted 10 lines

xen/Rules.mk srcdir := $(srctree)/$(src) · line 22

Quoted 6 lines
xen/Rules.mk +5 -1
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif

Trying to understand this, I assume it's to avoid an infinite dependency loop that generating include/config/auto.conf requires some tools that are build using xen/Rules.mk?

The file has dependencies only in xen/Makefile. This is about the file simply not being there when initially building. Perhaps the patch description helps that I've written in the meantime:

Quoted 8 lines
Quoted 4 lines

"Because of using "-include", failure to (re)build auto.conf (with
auto.conf.cmd produced as a secondary target) won't stop make from continuing the build. Arrange for it being possible to drop the - from Rules.mk, requiring that the include be skipped for tools-only targets.

Wouldn't it be more reliable if we skipped the include for any paths in $(obj) that start with 'tools', rather than hardcoding 'tools' and 'tools/kconfig'?

I was first meaning to do so, but the expression would end up more complex than I'd like (for it needing to be an exact match of "tools" and a prefix match of "tools/"). Thinking of it,

Quoted 5 lines

ifneq ($(obj),tools)
ifneq ($(patsubst tools/%,$(obj)),)

might do (and not be as complex as I first thought, when intending to put all in a single "if").

Would something like the rune below work?

ifneq ($(word 1, $(subst /, ,$(obj))),tools)

That should allow to have a single condition, and should match both 'tools' and 'tools/*'

Thanks, Roger.

#13 lore raw
Quoted 45 lines · Roger Pau Monné
Quoted 38 lines · Jan Beulich
Quoted 24 lines · Roger Pau Monné
Quoted 23 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
xen/Rules.mk +0 -0
@@ -15,7 +15,11 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
Quoted 10 lines

xen/Rules.mk srcdir := $(srctree)/$(src) · line 22

Quoted 6 lines
xen/Rules.mk +5 -1
--include $(objtree)/include/config/auto.conf
+ifneq ($(obj),tools)
+ifneq ($(obj),tools/kconfig)
+include $(objtree)/include/config/auto.conf
+endif
+endif

Trying to understand this, I assume it's to avoid an infinite dependency loop that generating include/config/auto.conf requires some tools that are build using xen/Rules.mk?

The file has dependencies only in xen/Makefile. This is about the file simply not being there when initially building. Perhaps the patch description helps that I've written in the meantime:

Quoted 8 lines
Quoted 4 lines

"Because of using "-include", failure to (re)build auto.conf (with
auto.conf.cmd produced as a secondary target) won't stop make from continuing the build. Arrange for it being possible to drop the - from Rules.mk, requiring that the include be skipped for tools-only targets.

Wouldn't it be more reliable if we skipped the include for any paths in $(obj) that start with 'tools', rather than hardcoding 'tools' and 'tools/kconfig'?

I was first meaning to do so, but the expression would end up more complex than I'd like (for it needing to be an exact match of "tools" and a prefix match of "tools/"). Thinking of it,

Quoted 5 lines

ifneq ($(obj),tools)
ifneq ($(patsubst tools/%,$(obj)),)

might do (and not be as complex as I first thought, when intending to put all in a single "if").

Quoted 6 lines

Would something like the rune below work?

ifneq ($(word 1, $(subst /, ,$(obj))),tools)

That should allow to have a single condition, and should match both 'tools' and 'tools/*'

Hmm, yes, that works. $(subst ...) is something I usually try to avoid, in favor of $(patsubst ...).

Jan

#14 lore raw
In reply to Roger Pau Monne
Quoted 14 lines · Roger Pau Monne

When doing a rebuild with an xen/include/config/auto.conf already present in the tree, failures from Kconfig are ignored since the target is present:

gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen' tools/kconfig/conf --syncconfig Kconfig common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
UPD include/xen/compile.h
Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
gmake[2]: 'arch/x86/include/asm/asm-offsets.h' is up to date.

Quoted 6 lines

Ultimately leading to a successful build despite the Kconfig error.

Fix this by first removing xen/include/config/auto.conf before attempting to regenerate, and then also make xen/include/config/auto.conf a hard dependency of the build process (ie: drop the leading '-') and reordering so the .cmd target is executed before including the configuration file.

Could you try to revert commit 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*") instead? With a much shorter message like "Don't ignore Kconfig error anymore".

Cheers,

Signature · 1 line
Anthony PERARD
#15 lore raw
Quoted 17 lines · Anthony PERARD
Quoted 16 lines · Roger Pau Monne

When doing a rebuild with an xen/include/config/auto.conf already present in the tree, failures from Kconfig are ignored since the target is present:

gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen' tools/kconfig/conf --syncconfig Kconfig common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
UPD include/xen/compile.h
Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
gmake[2]: 'arch/x86/include/asm/asm-offsets.h' is up to date.

Ultimately leading to a successful build despite the Kconfig error.

Quoted 8 lines
Quoted 4 lines

Fix this by first removing xen/include/config/auto.conf before attempting to regenerate, and then also make xen/include/config/auto.conf a hard dependency of the build process (ie: drop the leading '-') and reordering so the .cmd target is executed before including the configuration file.

Could you try to revert commit 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*") instead? With a much shorter message like "Don't ignore Kconfig error anymore".

But that'll introduce the problem that was addressed there, won't it?

Jan

#16 lore raw
In reply to Anthony PERARD
Quoted 17 lines · Anthony PERARD
Quoted 16 lines · Roger Pau Monne

When doing a rebuild with an xen/include/config/auto.conf already present in the tree, failures from Kconfig are ignored since the target is present:

gmake -C xen install
gmake[1]: Entering directory '/root/src/xen/xen' tools/kconfig/conf --syncconfig Kconfig common/Kconfig:2: syntax error
common/Kconfig:1: invalid statement
gmake[2]: *** [tools/kconfig/Makefile:73: syncconfig] Error 1
UPD include/xen/compile.h
Xen 4.19-unstable
gmake[3]: Nothing to be done for 'all'.
gmake[2]: 'arch/x86/include/asm/asm-offsets.h' is up to date.

Ultimately leading to a successful build despite the Kconfig error.

Quoted 8 lines
Quoted 4 lines

Fix this by first removing xen/include/config/auto.conf before attempting to regenerate, and then also make xen/include/config/auto.conf a hard dependency of the build process (ie: drop the leading '-') and reordering so the .cmd target is executed before including the configuration file.

Could you try to revert commit 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*") instead? With a much shorter message like "Don't ignore Kconfig error anymore".

Yes that seems to solve it also. I guess the point is that for the target failure to stop execution the include that triggered it needs to be non-optional (so not - prefixed).

I'm unsure about the consequences of reverting 8d4c17a90b0a, so would prefer if you could take care of that.

Thanks, Roger.