Skip to contentSkip to conversation

Makefile: Check for more dangling scratch files in out-of-tree builds

PATCH In review Philippe Mathieu-Daudé 2 participants 2 messages Jun 9, 2018 – Jun 15, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Makefile: Check for more dangling scratch files in out-of-tree builds

It is easy to catch the generated 'config-host.mak' in the source tree, however qemu-version.h and qemu-options.def are also generated files and are hidden by .gitignore rules.

Improve the out-of-tree safety net rule added in d1bd2423a90, by also checking for these two files.

This solves building issues with out-of-tree builds from a source tree that has been built in:

- /qemu-version.h existing in source tree:

/source/qemu/qemu-nbd.c: In function ‘version’:
/source/qemu/qemu-nbd.c:133:6: error: expected ‘)’ before ‘QEMU_FULL_VERSION’
"%s " QEMU_FULL_VERSION "\n"
^~~~~~~~~~~~~~~~~~
)
/source/qemu/qemu-nbd.c:133:3: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
"%s " QEMU_FULL_VERSION "\n"
~^
cc1: all warnings being treated as errors

- /qemu-options.def existing in source tree:

/source/qemu/vl.c: In function ‘main’:
/source/qemu/vl.c:3052:18: error: ‘QEMU_OPTION_blockdev’ undeclared (first use in this function); did you mean ‘QEMU_OPTION_clock’?
case QEMU_OPTION_blockdev:
^~~~~~~~~~~~~~~~~~~~
QEMU_OPTION_clock
/source/qemu/vl.c:3052:18: note: each undeclared identifier is reported only once for each function it appears in

---
Since v1 http://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg02254.html:
Peter noticed [1] those files already are in GENERATED_FILES

[1] http://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg02338.html

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
index 023b3437ec..521009964c 100644
@@ -55,7 +55,8 @@ endif
 # Check that we're not trying to do an out-of-tree build from
 # a tree that's been used for an in-tree build.
 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
-ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
+scratch_files = config-host.mak qemu-version.h qemu-options.def
+ifneq ($(wildcard $(addprefix $(SRC_PATH)/,$(scratch_files))),)
 $(error This is an out of tree build but your source tree ($(SRC_PATH)) \
 seems to have been used for an in-tree build. You can fix this by running \
 "$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 26 lines · Philippe Mathieu-Daudé

It is easy to catch the generated 'config-host.mak' in the source tree, however qemu-version.h and qemu-options.def are also generated files and are hidden by .gitignore rules.

Improve the out-of-tree safety net rule added in d1bd2423a90, by also checking for these two files.

This solves building issues with out-of-tree builds from a source tree that has been built in:

- /qemu-version.h existing in source tree:

/source/qemu/qemu-nbd.c: In function ‘version’:
/source/qemu/qemu-nbd.c:133:6: error: expected ‘)’ before ‘QEMU_FULL_VERSION’
"%s " QEMU_FULL_VERSION "\n"
^~~~~~~~~~~~~~~~~~
)
/source/qemu/qemu-nbd.c:133:3: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
"%s " QEMU_FULL_VERSION "\n"
~^
cc1: all warnings being treated as errors

- /qemu-options.def existing in source tree:

Quoted 8 lines

/source/qemu/vl.c: In function ‘main’:
/source/qemu/vl.c:3052:18: error: ‘QEMU_OPTION_blockdev’ undeclared (first use in this function); did you mean ‘QEMU_OPTION_clock’?
case QEMU_OPTION_blockdev:
^~~~~~~~~~~~~~~~~~~~
QEMU_OPTION_clock
/source/qemu/vl.c:3052:18: note: each undeclared identifier is reported only once for each function it appears in

This commit message should I think also mention that it is only needed to deal with source trees that have these stale files from failed build attempts that predate commit 428952cfa966f5af8. Otherwise the existing test on config-host.mak is sufficient.

Quoted 25 lines

---
Since v1 http://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg02254.html:
Peter noticed [1] those files already are in GENERATED_FILES

[1] http://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg02338.html

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -2
index 023b3437ec..521009964c 100644
@@ -55,7 +55,8 @@ endif
 # Check that we're not trying to do an out-of-tree build from
 # a tree that's been used for an in-tree build.
 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
-ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
+scratch_files = config-host.mak qemu-version.h qemu-options.def
+ifneq ($(wildcard $(addprefix $(SRC_PATH)/,$(scratch_files))),)
 $(error This is an out of tree build but your source tree ($(SRC_PATH)) \
 seems to have been used for an in-tree build. You can fix this by running \
 "$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
--
Quoted 1 line

2.17.1

Otherwise

thanks
-- PMM