Skip to contentSkip to conversation

Makefile.am: Avoid redirection of input and output files

PATCH Superseded Khem Raj 2 participants 3 messages Nov 5, 2019 Kbuild

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 Makefile.am: Avoid redirection of input and output files

This can cause a build race in a highly parallelised build where a directory is not yet created but output file is being written using redirection e.g.

rst2man.py --strict --no-raw --no-generator --no-datestamp < ../git/monitor/iwmon.rst > monitor/iwmon.1 /bin/sh: monitor/iwmon.1: No such file or directory
make[1]: *** [Makefile:3544: monitor/iwmon.1] Error 1

---
 Makefile.am | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Makefile.am +4 -4
index 823b7d02..21dd707c 100644
@@ -627,7 +627,7 @@ SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
 
 if RUN_RST2MAN
 RST2MAN_PROCESS = $(AM_V_GEN)$(RST2MAN) --strict --no-raw --no-generator \
-			--no-datestamp < $< > $@
+			--no-datestamp
 else
 RST2MAN_PROCESS = $(AM_V_GEN)test -f $@ || \
 		{ echo "Generated manual page $@ does not exist"; false; }
@@ -637,13 +637,13 @@ endif
 	$(SED_PROCESS)
 
 %.1: %.rst Makefile
-	$(RST2MAN_PROCESS)
+	$(RST2MAN_PROCESS) $< $@
 
 %.5: %.rst Makefile
-	$(RST2MAN_PROCESS)
+	$(RST2MAN_PROCESS) $< $@
 
 %.8: %.rst Makefile
-	$(RST2MAN_PROCESS)
+	$(RST2MAN_PROCESS) $< $@
 
 install-data-local:
 if !SYSTEMD_SERVICE
Signature · 1 line
2.24.0
#1 lore raw

Hi Khem,

Quoted 21 lines

This can cause a build race in a highly parallelised build where a directory is not yet created but output file is being written using redirection e.g.

rst2man.py --strict --no-raw --no-generator --no-datestamp < ../git/monitor/iwmon.rst > monitor/iwmon.1 /bin/sh: monitor/iwmon.1: No such file or directory
make[1]: *** [Makefile:3544: monitor/iwmon.1] Error 1
---
Makefile.am | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
Makefile.am +0 -0
index 823b7d02..21dd707c 100644
@@ -627,7 +627,7 @@ SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
 

if RUN_RST2MAN
RST2MAN_PROCESS = $(AM_V_GEN)$(RST2MAN) --strict --no-raw --no-generator \

Makefile.am +1 -1
-			--no-datestamp < $< > $@
+			--no-datestamp

else

Quoted 2 lines
RST2MAN_PROCESS = $(AM_V_GEN)test -f $@ || \
		{ echo "Generated manual page $@ does not exist"; false; }

so this is bad in case the else clause is used.

Quoted 12 lines
Makefile.am +0 -0
@@ -637,13 +637,13 @@ endif
 	$(SED_PROCESS)
 

%.1: %.rst Makefile

Makefile.am +1 -1
-	$(RST2MAN_PROCESS)
+	$(RST2MAN_PROCESS) $< $@

%.5: %.rst Makefile

Makefile.am +1 -1
-	$(RST2MAN_PROCESS)
+	$(RST2MAN_PROCESS) $< $@

%.8: %.rst Makefile

Makefile.am

Quoted 2 lines
Makefile.am +1 -1
-	$(RST2MAN_PROCESS)
+	$(RST2MAN_PROCESS) $< $@

Is adding this to the RST2MAN_PROCESS variable not working?

Regards

Marcel

author
#2 lore raw
Quoted 43 lines · Marcel Holtmann

Hi Khem,

Quoted 1 line

This can cause a build race in a highly parallelised build where a

directory is not yet created but

Quoted 3 lines

output file is being written using redirection e.g.

rst2man.py --strict --no-raw --no-generator --no-datestamp <

../git/monitor/iwmon.rst > monitor/iwmon.1

Makefile.am SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) &&

Quoted 11 lines

/bin/sh: monitor/iwmon.1: No such file or directory make[1]: *** [Makefile:3544: monitor/iwmon.1] Error 1
---
Makefile.am | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
Makefile.am +0 -0
index 823b7d02..21dd707c 100644
@@ -627,7 +627,7 @@ SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) &&

$(SED) \

Quoted 3 lines

if RUN_RST2MAN
RST2MAN_PROCESS = $(AM_V_GEN)$(RST2MAN) --strict --no-raw --no-generator

\

Quoted 5 lines
Makefile.am +1 -1
-                     --no-datestamp < $< > $@
+                     --no-datestamp

else

RST2MAN_PROCESS = $(AM_V_GEN)test -f $@ || \
              { echo "Generated manual page $@ does not exist"; false; }

so this is bad in case the else clause is used.

Quoted 11 lines
Makefile.am +0 -0
@@ -637,13 +637,13 @@ endif
      $(SED_PROCESS)
 

%.1: %.rst Makefile

Makefile.am +1 -1
-     $(RST2MAN_PROCESS)
+     $(RST2MAN_PROCESS) $< $@

%.5: %.rst Makefile

Makefile.am +1 -1
-     $(RST2MAN_PROCESS)
+     $(RST2MAN_PROCESS) $< $@
Quoted 5 lines

Makefile.am

Quoted 3 lines

%.8: %.rst Makefile

Makefile.am +1 -1
-     $(RST2MAN_PROCESS)
+     $(RST2MAN_PROCESS) $< $@

Is adding this to the RST2MAN_PROCESS variable not working?

I think that will work fine I just moved it here for Convenience I can move it back I think real race is that directory is not created before a file inside the directory is being redirected to. This happens when doing out of tree build so the directory is not pre existing

Quoted 7 lines

Regards

Marcel