davidsch / rpms / bout++

Forked from rpms/bout++ 2 years ago
Clone

Blame parallel-race.patch

David Schwörer 86b481b
commit 6612b6ab8f07f10065cfc8ec0925addb910cecb8
David Schwörer 86b481b
Author: David Schwörer <schword2@mail.dcu.ie>
David Schwörer 86b481b
Date:   Mon Nov 25 13:44:23 2019 +0000
David Schwörer 86b481b
David Schwörer 86b481b
    Try to prevent race condition while building.
David Schwörer 86b481b
    
David Schwörer 86b481b
    This improves the current situation, as before it could happen that
David Schwörer 86b481b
    building failed, because the .a was not yet created. Now it waits for
David Schwörer 86b481b
    it to be created. Switching to atomic mv rather then to create it
David Schwörer 86b481b
    inplace, ensures that if the file is seen, it is valid.
David Schwörer 86b481b
    This does not address the case when the .a is recreated, and the
David Schwörer 86b481b
    dependend file is checked before whether the .a has changed.
David Schwörer 86b481b
David Schwörer 86b481b
diff --git a/make.config.in b/make.config.in
David Schwörer 86b481b
index df80ed2ad..a183cf2e8 100644
David Schwörer 86b481b
--- a/make.config.in
David Schwörer 86b481b
+++ b/make.config.in
David Schwörer 86b481b
@@ -242,11 +242,15 @@ endif
David Schwörer 86b481b
 
David Schwörer 86b481b
 ifeq ("$(TARGET)", "sub")
David Schwörer 86b481b
 LIB=$(MODULE_DIR)/$(SUB_NAME).a
David Schwörer 86b481b
-sub: makefile $(BOUT_CONFIG_FILE) $(BOUT_TOP)/include $(BOUT_TOP)/lib $(OBJ)
David Schwörer 86b481b
+sub:$(LIB)
David Schwörer 86b481b
+
David Schwörer 86b481b
+$(LIB): makefile $(BOUT_CONFIG_FILE) $(BOUT_TOP)/include $(BOUT_TOP)/lib $(OBJ)
David Schwörer 86b481b
 ifneq ("$(OBJ)foo", "foo")
David Schwörer 86b481b
 	@echo "  Adding $(OBJ) to $(LIB)"
David Schwörer 86b481b
-	@$(AR) $(ARFLAGS) $(LIB) $(OBJ)
David Schwörer 86b481b
-	@$(RANLIB) $(LIB)
David Schwörer 86b481b
+	@LIBT=$(LIB).$$$$.a && \
David Schwörer 86b481b
+		$(AR) $(ARFLAGS) $${LIBT} $(OBJ) && \
David Schwörer 86b481b
+		$(RANLIB) $${LIBT} && \
David Schwörer 86b481b
+		mv $${LIBT} $(LIB)
David Schwörer 86b481b
 endif
David Schwörer 86b481b
 endif
David Schwörer 86b481b
 
David Schwörer 86b481b
@@ -282,6 +286,7 @@ $(SUB_LIBS):$(DIRS__)
David Schwörer 86b481b
 
David Schwörer 86b481b
 $(SOURCEC): checklib
David Schwörer 86b481b
 $(SOURCEC:%.cxx=%.o): $(LIB)
David Schwörer 86b481b
+$(TARGET): | $(DIRS)
David Schwörer 86b481b
 $(TARGET): makefile $(BOUT_CONFIG_FILE) $(OBJ) $(SUB_LIBS)
David Schwörer 86b481b
 	@echo "  Linking" $(TARGET)
David Schwörer 86b481b
 	@$(LD) $(LDFLAGS) -o $(TARGET) $(OBJ) $(SUB_LIBS) $(BOUT_LIBS)