tools/hotplug/Linux: Fix build
PATCH 1/1 tools/hotplug/Linux: Fix build
When building, it might happen that xen.conf in tools/hotplug/Linux/systemd/Makefile is done twice, at the same time, which leads to a not found file when calling move-if-changed.
Relevent part of an actual failed build:
make[6]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux'
[...]
make -C systemd all
make -C systemd install
make[7]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux/systemd'
make[7]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux/systemd'
mv -f compat/.xlat/grant_table.h.new compat/.xlat/grant_table.h
rm -f xen.conf.tmp
for mod in xen-evtchn xen-gntdev xen-gntalloc xen-blkback xen-netback xen-pciback evtchn gntdev netbk blkbk xen-scsibk usbbk pciback xen-acpi-processor blktap2 blktap ; do \
echo $mod ; \
done > xen.conf.tmp
rm -f xen.conf.tmp
if ! cmp -s xen.conf.tmp xen.conf; then mv -f xen.conf.tmp xen.conf; else rm -f xen.conf.tmp; fi
for mod in xen-evtchn xen-gntdev xen-gntalloc xen-blkback xen-netback xen-pciback evtchn gntdev netbk blkbk xen-scsibk usbbk pciback xen-acpi-processor blktap2 blktap ; do \
echo $mod ; \
done > xen.conf.tmp
if ! cmp -s xen.conf.tmp xen.conf; then mv -f xen.conf.tmp xen.conf; else rm -f xen.conf.tmp; fi
[ -d /build/xen-unstable/src/xen-unstable/dist/install/usr/lib/systemd/system/ ] || \
/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux/systemd/../../../../tools/cross-install -d -m0755 -p /build/xen-unstable/src/xen-unstable/dist/install/usr/lib/systemd/system/
mv: cannot stat 'xen.conf.tmp': No such file or directory
Makefile:42: recipe for target 'xen.conf' failed
make[7]: *** [xen.conf] Error 1
make[7]: Leaving directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux/systemd' /build/xen-unstable/src/xen-unstable/tools/hotplug/Linux/../../../tools/Rules.mk:116: recipe for target 'subdir-install-systemd' failed
make[6]: *** [subdir-install-systemd] Error 2
make[6]: Leaving directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux' /build/xen-unstable/src/xen-unstable/tools/hotplug/Linux/../../../tools/Rules.mk:111: recipe for target 'subdirs-install' failed
make[5]: *** [subdirs-install] Error 2
---
build have been done with make -j24. Without the patch, the problem always shows.
--- tools/hotplug/Linux/systemd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/systemd/Makefile +1 -1
@@ -21,7 +21,7 @@ ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all -all: install +all: .PHONY: clean clean:
Signature · 1 line
Anthony PERARD
Quoted 2 lines · Anthony PERARD
When building, it might happen that xen.conf in
tools/hotplug/Linux/systemd/Makefileis done twice, at the same time,
This is what eac3f5122fd4769b2885d8ad78bcbcf5df2472c1 tried to fix. Too bad my patch did not solve it.
Olaf
Quoted 4 lines · Anthony PERARD
make[6]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux' [...]
make -C systemd all
make -C systemd install
I wonder why that happens anyway, isnt that the bug? Shouldnt some "all" depend on "install", or whatever?
Olaf
Quoted 10 lines · Olaf Hering
Quoted 4 lines · Anthony PERARD
make[6]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux' [...]
make -C systemd all
make -C systemd installI wonder why that happens anyway, isnt that the bug? Shouldnt some "all" depend on "install", or whatever?
Olaf
all: should never depend on install.
all: will be the default target from make, which is expected to build components, and is specifically separate from make install DESTDIR=$foo
~Andrew
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Olaf Hering
Quoted 4 lines · Anthony PERARD
make[6]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux' [...]
make -C systemd all
make -C systemd installI wonder why that happens anyway, isnt that the bug? Shouldnt some "all" depend on "install", or whatever?
Quoted 6 lines
Quoted 1 line
Olaf
all: should never depend on install.
all: will be the default target from
make, which is expected to build components, and is specifically separate frommake install DESTDIR=$foo
That's true, and as such Olaf's eac3f5122fd4769b2885d8ad78bcbcf5df2472c1 is of course not correct, somehow I didn't manage to notice this.
I intend to revert shortly...
Ian.
Quoted 15 lines · Ian Campbell
Quoted 14 lines · Andrew Cooper
Quoted 10 lines · Olaf Hering
Quoted 4 lines · Anthony PERARD
make[6]: Entering directory '/build/xen-unstable/src/xen-unstable/tools/hotplug/Linux' [...]
make -C systemd all
make -C systemd installI wonder why that happens anyway, isnt that the bug? Shouldnt some "all" depend on "install", or whatever?
Olaf
all: should never depend on install.
Quoted 7 lines
Quoted 2 lines
all: will be the default target from
make, which is expected to build components, and is specifically separate frommake install DESTDIR=$fooThat's true, and as such Olaf's
eac3f5122fd4769b2885d8ad78bcbcf5df2472c1is of course not correct, somehow I didn't manage to notice this.I intend to revert shortly...
I've just pushed the following.
I expect the actual problem is that the buildsystem is recusing into this directory twice simultaneously for "all" and "install" at the same time. That seems likely to be an issue with the Makefile in the parent directory.
Should subdirs-install depend on subdirs-all perhaps?
commit 66bb8b04f0032ddf0aa007b0850be1ec15477d60
Author: Ian Campbell <[email protected]> Date: Fri Oct 10 09:35:34 2014 +0100
Revert "tools/hotplug: fix race during xen.conf creation"
This reverts commit eac3f5122fd4769b2885d8ad78bcbcf5df2472c1.
The "all" target should never depend on "install", it is supposed to only build not install.
tools/hotplug/Linux/systemd/Makefile +1 -2
@@ -21,11 +21,10 @@ ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all -all: install +all: $(ALL_XEN_SYSTEMD) .PHONY: clean clean: - rm -f $(ALL_XEN_SYSTEMD) .PHONY: install install: $(ALL_XEN_SYSTEMD)
Quoted 8 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
On Fri, Oct 10, 2014 at 09:44:38AM +0100, Ian Campbell wrote:
[...]
Quoted 20 lines
Should subdirs-install depend on subdirs-all perhaps?
commit
66bb8b04f0032ddf0aa007b0850be1ec15477d60Author: Ian Campbell <[email protected]> Date: Fri Oct 10 09:35:34 2014 +0100Revert "
tools/hotplug: fix race during xen.conf creation"This reverts commit
eac3f5122fd4769b2885d8ad78bcbcf5df2472c1.The "all" target should never depend on "install", it is supposed to only build not install.
Signed-off-by Ian Campbell <[email protected]>tools/hotplug/Linux/systemd/Makefile +0
-0
tools/hotplug/Linux/systemd/Makefile ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ · line 28
Quoted 10 lines
tools/hotplug/Linux/systemd/Makefile +1
-2@@ -21,11 +21,10 @@ ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all -all: install +all: $(ALL_XEN_SYSTEMD) .PHONY: clean clean: - rm -f $(ALL_XEN_SYSTEMD)
Now clean target just becomes empty...
Wei.
Quoted 28 lines · Wei Liu
On Fri, Oct 10, 2014 at 09:44:38AM +0100, Ian Campbell wrote:
[...]Quoted 26 lines
Should subdirs-install depend on subdirs-all perhaps?
commit
66bb8b04f0032ddf0aa007b0850be1ec15477d60Author: Ian Campbell <[email protected]> Date: Fri Oct 10 09:35:34 2014 +0100Revert "
tools/hotplug: fix race during xen.conf creation"This reverts commit
eac3f5122fd4769b2885d8ad78bcbcf5df2472c1.The "all" target should never depend on "install", it is supposed to only build not install.
Signed-off-by Ian Campbell <[email protected]>tools/hotplug/Linux/systemd/Makefile +1
-1@@ -21,11 +21,10 @@ ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all -all: install +all: $(ALL_XEN_SYSTEMD)
Quoted 6 lines
tools/hotplug/Linux/systemd/Makefile ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ · line 28
Quoted 4 lines
tools/hotplug/Linux/systemd/Makefile +0
-1.PHONY: clean clean: - rm -f $(ALL_XEN_SYSTEMD)Now clean target just becomes empty...
... the perils of lumping multiple changes into a single patch...
Ian.
Quoted 6 lines · Ian Campbell
I expect the actual problem is that the buildsystem is recusing into this directory twice simultaneously for "all" and "install" at the same time. That seems likely to be an issue with the
Makefilein the parent directory.Should subdirs-install depend on subdirs-all perhaps?
Anthony, how do you invoke make? While I have seen it often right now I'm unable to reproduce. There are never 'all' and 'install' targets in the log. I think my script always called make rpmball.
I think only the install rule should depend on ALL_XEN_SYSTEMD because in the end thats the only place that matters. There is nothing to build, and the single xen.conf file could also be generated on the fly during install.
But still it would be nice to know what the root cause is.
Olaf
Quoted 29 lines · Ian Campbell
Quoted 28 lines · Wei Liu
On Fri, Oct 10, 2014 at 09:44:38AM +0100, Ian Campbell wrote:
[...]Quoted 26 lines
Should subdirs-install depend on subdirs-all perhaps?
commit
66bb8b04f0032ddf0aa007b0850be1ec15477d60Author: Ian Campbell <[email protected]> Date: Fri Oct 10 09:35:34 2014 +0100Revert "
tools/hotplug: fix race during xen.conf creation"This reverts commit
eac3f5122fd4769b2885d8ad78bcbcf5df2472c1.The "all" target should never depend on "install", it is supposed to only build not install.
Signed-off-by Ian Campbell <[email protected]>tools/hotplug/Linux/systemd/Makefile +1
-1@@ -21,11 +21,10 @@ ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ $(XEN_SYSTEMD_SERVICE) .PHONY: all -all: install +all: $(ALL_XEN_SYSTEMD)
Quoted 8 lines
Quoted 6 lines
tools/hotplug/Linux/systemd/Makefile ALL_XEN_SYSTEMD = $(XEN_SYSTEMD_MODULES) \ · line 28
Quoted 4 lines
tools/hotplug/Linux/systemd/Makefile +0
-1.PHONY: clean clean: - rm -f $(ALL_XEN_SYSTEMD)Now clean target just becomes empty...
... the perils of lumping multiple changes into a single patch...
And it was wrong anyway because it will wipe everything in that dir. If at all, it should have been "rm -f $(XEN_SYSTEMD_MODULES)" to wipe the generated files.
Olaf
Quoted 7 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
I expect the actual problem is that the buildsystem is recusing into this directory twice simultaneously for "all" and "install" at the same time. That seems likely to be an issue with the
Makefilein the parent directory.
Quoted 5 lines
Quoted 1 line
Should subdirs-install depend on subdirs-all perhaps?
Anthony, how do you invoke make? While I have seen it often right now I'm unable to reproduce. There are never 'all' and 'install' targets in the log. I think my script always called make rpmball.
There are a lot of things in my build script, but it should be done to this:
git clone
./configure --enable-systemd --other-stuff
export MAKEFLAGS="-j24"
edit .config to use local git tree
make
And later in the process, a make install is called but the faillure is before that.
Quoted 6 lines
I think only the install rule should depend on
ALL_XEN_SYSTEMDbecause in the end thats the only place that matters. There is nothing to build, and the single xen.conf file could also be generated on the fly during install.But still it would be nice to know what the root cause is.
It look like hotplug stuff are done like that:
make[2]: Entering directory '/build/xen-unstable/src/xen-unstable/tools' make -C hotplug install
then calling make install on other subdir.
And after entering tools/Linux, I can see both rules "all" and "install" been called on systemd directory (unfortunatly, at the same time on this machine).
I think the problem is in tools/Linux/Makefile, where we have:
all: subdirs-all
install: all subdirs-install
Maybe the "install" rules should depend only on the things it need to install, and not an "all".
Signature · 1 line
Anthony PERARD
Quoted 6 lines · Anthony PERARD
I think the problem is in
tools/Linux/Makefile, where we have:
all: subdirs-all
install: all subdirs-installMaybe the "install" rules should depend only on the things it need to install, and not an "all".
Does removing all fix the failure for you?
Olaf
Quoted 10 lines · Olaf Hering
Quoted 6 lines · Anthony PERARD
I think the problem is in
tools/Linux/Makefile, where we have:
all: subdirs-all
install: all subdirs-installMaybe the "install" rules should depend only on the things it need to install, and not an "all".
Does removing all fix the failure for you?
Yes, it does, no more weird two calls of make on the systemd/Makefile (with all and install). There is only one call left: "make -C systemd install". And make does not fail to make xen.conf.
I've did the test on top of staging, with ian revert commit.
Here is the patch that I have tested:
Quoted 1 line
From
41cfaf5318cb0346e31a8e97939b8805145eb182Mon Sep 17 00:00:00 2001
From: Anthony PERARD <[email protected]>
Date: Fri, 10 Oct 2014 12:22:34 +0100
Subject: [PATCH] tools/hotplug/Linux: Removing of "all" dependency from
"install" rule.
--- tools/hotplug/Linux/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/Makefile +1 -1
@@ -43,7 +43,7 @@ all: subdirs-all build: .PHONY: install -install: all install-initd install-scripts install-udev subdirs-install +install: install-initd install-scripts install-udev subdirs-install # See docs/misc/distro_mapping.txt for INITD_DIR location .PHONY: install-initd
Signature · 5 lines
Anthony PERARD -- Anthony PERARD
Olaf Hering
Tested-byQuoted 3 lines · Anthony PERARD
Yes, it does, no more weird two calls of make on the systemd/Makefile (with all and install). There is only one call left: "make -C systemd install". And make does not fail to make xen.conf.
I ran into this as well just now, and removing all works for me as well.
Quoted 7 lines
From
41cfaf5318cb0346e31a8e97939b8805145eb182Mon Sep 17 00:00:00 2001
From: Anthony PERARD <[email protected]>
Date: Fri, 10 Oct 2014 12:22:34 +0100
Subject: [PATCH]tools/hotplug/Linux: Removing of "all" dependency from
"install" rule.Signed-off-by Anthony PERARD <[email protected]>
Quoted 17 lines
--- tools/hotplug/Linux/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/hotplug/Linux/Makefile +1
-1@@ -43,7 +43,7 @@ all: subdirs-all build: .PHONY: install -install: all install-initd install-scripts install-udev subdirs-install +install: install-initd install-scripts install-udev subdirs-install # See docs/misc/distro_mapping.txt for INITD_DIR location .PHONY: install-initd
Quoted 14 lines · Olaf Hering
Quoted 3 lines · Anthony PERARD
Yes, it does, no more weird two calls of make on the systemd/Makefile (with all and install). There is only one call left: "make -C systemd install". And make does not fail to make xen.conf.
I ran into this as well just now, and removing all works for me as well.
Quoted 6 lines
From
41cfaf5318cb0346e31a8e97939b8805145eb182Mon Sep 17 00:00:00 2001
From: Anthony PERARD <[email protected]>
Date: Fri, 10 Oct 2014 12:22:34 +0100
Subject: [PATCH]tools/hotplug/Linux: Removing of "all" dependency from
"install" rule.
Quoted 3 lines
Quoted 1 line
Signed-off-by Anthony PERARD <[email protected]>Tested-by Olaf Hering <[email protected]>
Great. Could someone supply a bit of explanatory text for the commit message please.
Do these indicate a similar problem:
tools/hotplug/NetBSD/Makefile:install: all install-scripts install-rcd tools/hotplug/common/Makefile:install: all install-scripts ?
I think not because no recursion is included.
Ian.
Quoted 15 lines · Ian Campbell
Quoted 14 lines · Olaf Hering
Quoted 3 lines · Anthony PERARD
Yes, it does, no more weird two calls of make on the systemd/Makefile (with all and install). There is only one call left: "make -C systemd install". And make does not fail to make xen.conf.
I ran into this as well just now, and removing all works for me as well.
Quoted 6 lines
From
41cfaf5318cb0346e31a8e97939b8805145eb182Mon Sep 17 00:00:00 2001
From: Anthony PERARD <[email protected]>
Date: Fri, 10 Oct 2014 12:22:34 +0100
Subject: [PATCH]tools/hotplug/Linux: Removing of "all" dependency from
"install" rule.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Anthony PERARD <[email protected]>Tested-by Olaf Hering <[email protected]>Great. Could someone supply a bit of explanatory text for the commit message please.
The "install" rules depends on both "all" and "subdirs-install" and "all" depends on "subdirs-all". This leads the "install" rules to call both "subdirs-all" and "subdirs-install" which create a race with two concurrent make within the same directory (systemd) trying to make the same things (xen.conf) and failing.
Ultimatly, "install" should only depend on the things it needs to install, and not on "all".
Quoted 6 lines
Do these indicate a similar problem:
tools/hotplug/NetBSD/Makefile:install: all install-scripts install-rcd tools/hotplug/common/Makefile:install: all install-scripts ?I think not because no recursion is included.
I think this could be an issue, install does not need all. But since there is no subdirs involves, there is no problem for now.
Shall I update the patch to change all "install" rules of tools/hotplug/*/Makefile ?
Signature · 1 line
Anthony PERARD
PATCH v2 1/1 tools/hotplug: Removing of "all" dependency from "install" rule.
The "install" rules depends on both "all" and "subdirs-install" and "all" depends on "subdirs-all". This leads the "install" rules to call both "subdirs-all" and "subdirs-install" which create a race with two concurrent make within the same directory (systemd) trying to make the same things (xen.conf) and failing.
Ultimatly, "install" should only depend on the things it needs to install, and not on "all".
---
Change in V2:
- Add an explanation in the commit message.
- Also change the other Makefiles under tools/hotplug
--- tools/hotplug/FreeBSD/Makefile | 2 +- tools/hotplug/Linux/Makefile | 2 +- tools/hotplug/NetBSD/Makefile | 2 +- tools/hotplug/common/Makefile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
tools/hotplug/FreeBSD/Makefile +1 -1
@@ -15,7 +15,7 @@ all: build: .PHONY: install -install: all install-scripts install-rcd +install: install-scripts install-rcd .PHONY: install-scripts install-scripts:
tools/hotplug/Linux/Makefile +1 -1
@@ -43,7 +43,7 @@ all: subdirs-all build: .PHONY: install -install: all install-initd install-scripts install-udev subdirs-install +install: install-initd install-scripts install-udev subdirs-install # See docs/misc/distro_mapping.txt for INITD_DIR location .PHONY: install-initd
tools/hotplug/NetBSD/Makefile +1 -1
@@ -17,7 +17,7 @@ all: build: .PHONY: install -install: all install-scripts install-rcd +install: install-scripts install-rcd .PHONY: install-scripts install-scripts:
tools/hotplug/common/Makefile +1 -1
@@ -19,7 +19,7 @@ all: build build: $(HOTPLUGPATH) .PHONY: install -install: all install-scripts +install: install-scripts .PHONY: install-scripts install-scripts: build
Signature · 1 line
Anthony PERARD
Re: [PATCH V2] tools/hotplug: Removing of "all" dependency from "install" rule.
Anthony PERARD writes ("[PATCH V2] tools/hotplug: Removing of "all" dependency from "install" rule."):
Quoted 5 lines
The "install" rules depends on both "all" and "subdirs-install" and "all" depends on "subdirs-all". This leads the "install" rules to call both "subdirs-all" and "subdirs-install" which create a race with two concurrent
makewithin the same directory (systemd) trying to make the same things (xen.conf) and failing.
Thanks for the investigation. I think this demonstrates that our approach to subdirs is, at the very least, excessively fragile. But this fix (or workaround, if we prefer) will do.
Thanks,
Ian.
Re: [PATCH V2] tools/hotplug: Removing of "all" dependency from "install" rule.
Quoted 7 lines · Ian Jackson
Anthony PERARD writes ("[PATCH V2]
tools/hotplug: Removing of "all" dependency from "install" rule."):Quoted 5 lines
The "install" rules depends on both "all" and "subdirs-install" and "all" depends on "subdirs-all". This leads the "install" rules to call both "subdirs-all" and "subdirs-install" which create a race with two concurrent
makewithin the same directory (systemd) trying to make the same things (xen.conf) and failing.
Quoted 5 lines
Thanks for the investigation. I think this demonstrates that our approach to subdirs is, at the very least, excessively fragile. But this fix (or workaround, if we prefer) will do.
Acked-by Ian Jackson <[email protected]>
Likewise, and applied.
Ian.
Re: [PATCH V2] tools/hotplug: Removing of "all" dependency from "install" rule.
In reply to Ian JacksonQuoted 7 lines · Ian Jackson
Anthony PERARD writes ("[PATCH V2]
tools/hotplug: Removing of "all" dependency from "install" rule."):Quoted 5 lines
The "install" rules depends on both "all" and "subdirs-install" and "all" depends on "subdirs-all". This leads the "install" rules to call both "subdirs-all" and "subdirs-install" which create a race with two concurrent
makewithin the same directory (systemd) trying to make the same things (xen.conf) and failing.
Quoted 5 lines
Thanks for the investigation. I think this demonstrates that our approach to subdirs is, at the very least, excessively fragile. But this fix (or workaround, if we prefer) will do.
Acked-by Ian Jackson <[email protected]>
Likewise, and applied.
Ian.