1 Description: allow building with make -jN
2 without this there are sporadic segmentation faults
4 it seems that when gpre opens a database, it clashes with other gpre
5 processes that have the database open. perhaps this is because at
6 this stage of the build the compiled firebird engine lacks ability for
7 synchronisation. So, wrap all engine-using calls with a lock file
8 Author: Damyan Ivanov <dmn@debian.org>
11 --- Firebird-3.0.10.33601-0/builds/posix/Makefile.in.orig 2022-06-24 13:13:29.537501538 +0200
12 +++ Firebird-3.0.10.33601-0/builds/posix/Makefile.in 2022-06-24 13:15:39.739885352 +0200
15 metadata.fdb: $(RUN_ISQL) $(SRC_ROOT)/dbs/metadata.sql
17 - $(RUN_ISQL) -q -i $(SRC_ROOT)/dbs/metadata.sql
18 - $(RUN_GFIX) -mode read_only $@
19 + $(call LOCK_RUN,$(RUN_ISQL) -q -i $(SRC_ROOT)/dbs/metadata.sql)
20 + $(call LOCK_RUN,$(RUN_GFIX) -mode read_only $@)
27 help.fdb: $(BLD_ROOT)/misc/help.gbak
28 - $(RUN_GBAK) -MODE read_only -replace $< $@
29 + $(call LOCK_RUN,$(RUN_GBAK) -MODE read_only -replace $< $@)
32 $(SECURITY_FDB): security.fdb
34 security.fdb: $(SRC_ROOT)/dbs/security.sql
36 -$(RM) $(SECURITY_TMP)
37 - echo create database \'$(SECURITY_TMP)\'\; | $(RUN_ISQL)
38 - $(RUN_GFIX) -write async $(SECURITY_TMP)
39 - $(RUN_ISQL) -i $^ $(SECURITY_TMP)
40 + $(call LOCK_RUN,echo create database \'$(SECURITY_TMP)\'\; | $(RUN_ISQL))
41 + $(call LOCK_RUN,$(RUN_GFIX) -write async $(SECURITY_TMP))
42 + $(call LOCK_RUN,$(RUN_ISQL) -i $^ $(SECURITY_TMP))
43 $(CHMOD) a=rw $(SECURITY_TMP)
44 $(CP) $(SECURITY_TMP) $@
45 - $(RUN_GFIX) -write sync $@
46 + $(call LOCK_RUN,$(RUN_GFIX) -write sync $@)
48 msg.timestamp: $(MSG_FILES)
50 - echo create database \'msg.fdb\'\; | $(RUN_ISQL)
51 - $(RUN_GFIX) -write async msg.fdb
52 - for sql in $(MSG_FILES); do (echo $$sql; $(RUN_ISQL) -i $$sql msg.fdb) || exit; done
53 + $(call LOCK_RUN,echo create database \'msg.fdb\'\; | $(RUN_ISQL))
54 + $(call LOCK_RUN,$(RUN_GFIX) -write async msg.fdb)
55 + $(call LOCK_RUN,for sql in $(MSG_FILES); do (echo $$sql; $(RUN_ISQL) -i $$sql msg.fdb) || exit; done)
62 gen_codes: $(CODES) msg.timestamp
63 - $(CODES) $(SRC_ROOT)/include/gen $(LNG_ROOT)
64 + $(call LOCK_RUN,$(CODES) $(SRC_ROOT)/include/gen $(LNG_ROOT))
66 $(CODES): $(CODES_Objects) $(COMMON_LIB)
67 $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)
69 message_file: $(FIREBIRD_MSG)
71 $(FIREBIRD_MSG): $(BUILD_FILE) msg.timestamp
72 - $(BUILD_FILE) -d msg.fdb -f $@
73 + $(call LOCK_RUN,$(BUILD_FILE) -d msg.fdb -f $@)
76 $(BUILD_FILE): $(BUILD_Objects) $(COMMON_LIB)
77 diff -urNp -x '*.orig' Firebird-3.0.7.33374-0.org/builds/posix/Makefile.in.examples Firebird-3.0.7.33374-0/builds/posix/Makefile.in.examples
78 --- Firebird-3.0.7.33374-0.org/builds/posix/Makefile.in.examples 2020-10-20 08:40:05.000000000 +0000
79 +++ Firebird-3.0.7.33374-0/builds/posix/Makefile.in.examples 2022-04-04 17:53:33.598825549 +0000
80 @@ -123,8 +123,8 @@ $(EXAMPLES_DEST)% : $(EXAMPLES_SRC)%
82 $(EMPLOYEE_DB): $(EXAMPLES_DEST)/empbuild$(EXEC_EXT) $(INPUT_Sources) $(EXAMPLES_DEST)/isql$(EXEC_EXT)
84 - ./empbuild $(EMPLOYEE_DB)
85 - $(GFIX) -write sync $(EMPLOYEE_DB)
86 + $(call LOCK_RUN,./empbuild $(EMPLOYEE_DB))
87 + $(call LOCK_RUN,$(GFIX) -write sync $(EMPLOYEE_DB))
88 -$(CHMOD_6) $(EMPLOYEE_DB)
90 # To get past the fact isql is called from the programs, we create a local link in this directory
91 @@ -140,7 +140,7 @@ $(EXAMPLES_DEST)/empbuild.c: $(EXAMPLES_
93 $(EXAMPLES_DEST)/empbuild.fdb : $(EXAMPLES_DEST)/empddl.sql $(EXAMPLES_DEST)/empbld.sql $(EXAMPLES_DEST)/isql$(EXEC_EXT)
94 -$(RM) $(EXAMPLES_DEST)/empbuild.fdb
95 - $(EXAMPLES_DEST)/isql$(EXEC_EXT) -i empbld.sql
96 + $(call LOCK_RUN,$(EXAMPLES_DEST)/isql$(EXEC_EXT) -i empbld.sql)
98 # The chain for intlemp.fdb is the same a script file to create an empty database
99 # to allow a .e program to be compiled, to then create and populate with data
100 @@ -148,7 +148,7 @@ $(EXAMPLES_DEST)/empbuild.fdb : $(EXAMPL
102 $(EXAMPLES_DEST)/intlemp.fdb: $(EXAMPLES_DEST)/intlbld$(EXEC_EXT) $(INTL_Sources) $(EXAMPLES_DEST)/isql$(EXEC_EXT)
104 - ./intlbld intlemp.fdb
105 + $(call LOCK_RUN,./intlbld intlemp.fdb)
106 -$(CHMOD_6) intlemp.fdb
108 $(EXAMPLES_DEST)/intlbld$(EXEC_EXT): $(INTLBLD_Objects) $(COMMON_LIB)
109 @@ -158,7 +158,7 @@ $(EXAMPLES_DEST)/intlbld.c: $(EXAMPLES_D
111 $(EXAMPLES_DEST)/intlbuild.fdb : $(EXAMPLES_DEST)/intlddl.sql $(EXAMPLES_DEST)/intlbld.sql $(EXAMPLES_DEST)/isql$(EXEC_EXT)
113 - $(EXAMPLES_DEST)/isql$(EXEC_EXT) -i intlbld.sql
114 + $(call LOCK_RUN,$(EXAMPLES_DEST)/isql$(EXEC_EXT) -i intlbld.sql)
117 $(EXAMPLES_DEST)/%.sql: $(EXAMPLES_SRC)/empbuild/%.sql
118 diff -urNp -x '*.orig' Firebird-3.0.7.33374-0.org/builds/posix/make.defaults Firebird-3.0.7.33374-0/builds/posix/make.defaults
119 --- Firebird-3.0.7.33374-0.org/builds/posix/make.defaults 2022-04-04 17:53:31.949821738 +0000
120 +++ Firebird-3.0.7.33374-0/builds/posix/make.defaults 2022-04-04 17:53:33.598825549 +0000
121 @@ -397,6 +397,7 @@ GPRE_BOOT = $(RBIN)/gpre_boot$(EXE
122 GPRE = $(BIN)/gpre$(EXEC_EXT)
123 RUN_GPRE = $(RBIN)/gpre$(EXEC_EXT)
124 GPRE_CURRENT = $(RBIN)/gpre_current$(EXEC_EXT)
125 +LOCK_RUN = sh -x -c "lockfile -1 $(BIN)/build-db.lock && $(subst $$,\$$,$(1)); res=\$$?; rm -f $(BIN)/build-db.lock; exit \$$res"
129 diff -urNp -x '*.orig' Firebird-3.0.7.33374-0.org/builds/posix/make.rules Firebird-3.0.7.33374-0/builds/posix/make.rules
130 --- Firebird-3.0.7.33374-0.org/builds/posix/make.rules 2020-10-20 08:40:05.000000000 +0000
131 +++ Firebird-3.0.7.33374-0/builds/posix/make.rules 2022-04-04 17:53:33.598825549 +0000
132 @@ -72,17 +72,17 @@ ISQL_GPRE_FLAGS = -m -z -n -ocxx
133 .SUFFIXES: .c .e .epp .cpp
136 - $(GPRE_CURRENT) $(GPRE_FLAGS) $< $@
137 + $(call LOCK_RUN,$(GPRE_CURRENT) $(GPRE_FLAGS) $< $@)
140 $(OBJ)/jrd/%.cpp: $(SRC_ROOT)/jrd/%.epp
141 - $(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $(firstword $<) $@
142 + $(call LOCK_RUN,$(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $(firstword $<) $@)
144 $(OBJ)/isql/%.cpp: $(SRC_ROOT)/isql/%.epp
145 - $(GPRE_CURRENT) $(ISQL_GPRE_FLAGS) $< $@
146 + $(call LOCK_RUN,$(GPRE_CURRENT) $(ISQL_GPRE_FLAGS) $< $@)
148 $(OBJ)/%.cpp: $(SRC_ROOT)/%.epp
149 - $(GPRE_CURRENT) $(GPRE_FLAGS) $(firstword $<) $@
150 + $(call LOCK_RUN,$(GPRE_CURRENT) $(GPRE_FLAGS) $(firstword $<) $@)
153 .SUFFIXES: .lo .o .cpp .c
154 diff -urNp -x '*.orig' Firebird-3.0.7.33374-0.org/builds/posix/make.shared.targets Firebird-3.0.7.33374-0/builds/posix/make.shared.targets
155 --- Firebird-3.0.7.33374-0.org/builds/posix/make.shared.targets 2020-10-20 08:40:05.000000000 +0000
156 +++ Firebird-3.0.7.33374-0/builds/posix/make.shared.targets 2022-04-04 17:53:33.598825549 +0000
157 @@ -65,13 +65,13 @@ $(OBJ)/dsql/Parser.o $(OBJ)/common/keywo
159 # Special cases for building cpp from epp
160 $(OBJ)/dsql/metd.cpp: $(SRC_ROOT)/dsql/metd.epp
161 - $(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@
162 + $(call LOCK_RUN,$(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@)
164 $(OBJ)/dsql/DdlNodes.cpp: $(SRC_ROOT)/dsql/DdlNodes.epp
165 - $(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@
166 + $(call LOCK_RUN,$(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@)
168 $(OBJ)/dsql/PackageNodes.cpp: $(SRC_ROOT)/dsql/PackageNodes.epp
169 - $(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@
170 + $(call LOCK_RUN,$(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@)
172 # Adding resources as prerequisite for some files