Update reproducible builds patches
[deb_dpdk.git] / debian / patches / mk-order-CFLAGS-so-that-ISCDIR-comes-before-IRTE_OUT.patch
1 Description: mk: set -ISCDIR before -IRTE_OUT/include in CFLAGS
2
3 A race condition can happen during parallel builds, where a header
4 might be installed in RTE_OUT/include before CFLAGS is recursively
5 expanded. This causes GCC to sometimes pick the header path as
6 SRCDIR/... and sometimes as RTE_OUT/include/... making the build
7 unreproducible, as the full path is used for the expansion of
8 __FILE__ and in the DWARF directory listing.
9 Always pass -ISRCDIR first to CFLAGS so that it's deterministic.
10
11 Origin: http://dpdk.org/dev/patchwork/patch/27512/
12 Forwarded: yes
13 Author: Luca Boccassi <luca.boccassi@gmail.com>
14 Last-Update: 2017-08-10
15 ---
16  lib/librte_acl/Makefile              | 10 ++++++++--
17  lib/librte_bitratestats/Makefile     |  9 ++++++++-
18  lib/librte_cmdline/Makefile          |  9 ++++++++-
19  lib/librte_distributor/Makefile      | 10 ++++++++--
20  lib/librte_eal/linuxapp/eal/Makefile |  8 +++++++-
21  lib/librte_efd/Makefile              | 10 ++++++++--
22  lib/librte_hash/Makefile             | 10 ++++++++--
23  lib/librte_ip_frag/Makefile          | 10 ++++++++--
24  lib/librte_jobstats/Makefile         | 10 ++++++++--
25  lib/librte_kni/Makefile              |  9 ++++++++-
26  lib/librte_kvargs/Makefile           |  9 ++++++++-
27  lib/librte_latencystats/Makefile     |  9 ++++++++-
28  lib/librte_lpm/Makefile              | 10 ++++++++--
29  lib/librte_mbuf/Makefile             |  9 ++++++++-
30  lib/librte_mempool/Makefile          |  9 ++++++++-
31  lib/librte_metrics/Makefile          |  9 ++++++++-
32  lib/librte_net/Makefile              |  9 ++++++++-
33  lib/librte_pdump/Makefile            | 10 ++++++++--
34  lib/librte_power/Makefile            |  9 ++++++++-
35  lib/librte_reorder/Makefile          | 10 ++++++++--
36  lib/librte_ring/Makefile             |  9 ++++++++-
37  lib/librte_timer/Makefile            |  9 ++++++++-
38  lib/librte_vhost/Makefile            |  9 ++++++++-
39  23 files changed, 183 insertions(+), 32 deletions(-)
40
41 diff --git a/lib/librte_acl/Makefile b/lib/librte_acl/Makefile
42 index 59767920a..bce78813b 100644
43 --- a/lib/librte_acl/Makefile
44 +++ b/lib/librte_acl/Makefile
45 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
46  # library name
47  LIB = librte_acl.a
48  
49 -CFLAGS += -O3
50 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
51 +# Include the source dir first, so that headers paths are always picked
52 +# from there. By including it last race conditions might happen during paralle
53 +# builds, and headers might be already installed in RTE_OUT/include when the
54 +# variable is recursively expanded, thus causing GCC to sometimes use the
55 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
56 +# reproducible.
57 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
58 +CFLAGS += $(WERROR_FLAGS) -O3
59  
60  EXPORT_MAP := rte_acl_version.map
61  
62 diff --git a/lib/librte_bitratestats/Makefile b/lib/librte_bitratestats/Makefile
63 index 58a20ea09..26a3f4908 100644
64 --- a/lib/librte_bitratestats/Makefile
65 +++ b/lib/librte_bitratestats/Makefile
66 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
67  # library name
68  LIB = librte_bitratestats.a
69  
70 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
71 +# Include the source dir first, so that headers paths are always picked
72 +# from there. By including it last race conditions might happen during paralle
73 +# builds, and headers might be already installed in RTE_OUT/include when the
74 +# variable is recursively expanded, thus causing GCC to sometimes use the
75 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
76 +# reproducible.
77 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
78 +CFLAGS += $(WERROR_FLAGS) -O3
79  
80  EXPORT_MAP := rte_bitratestats_version.map
81  
82 diff --git a/lib/librte_cmdline/Makefile b/lib/librte_cmdline/Makefile
83 index 644f68e47..9dd75f2d2 100644
84 --- a/lib/librte_cmdline/Makefile
85 +++ b/lib/librte_cmdline/Makefile
86 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
87  # library name
88  LIB = librte_cmdline.a
89  
90 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
91 +# Include the source dir first, so that headers paths are always picked
92 +# from there. By including it last race conditions might happen during paralle
93 +# builds, and headers might be already installed in RTE_OUT/include when the
94 +# variable is recursively expanded, thus causing GCC to sometimes use the
95 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
96 +# reproducible.
97 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
98 +CFLAGS += $(WERROR_FLAGS) -O3
99  
100  EXPORT_MAP := rte_cmdline_version.map
101  
102 diff --git a/lib/librte_distributor/Makefile b/lib/librte_distributor/Makefile
103 index b417ee7be..a51d7c8b2 100644
104 --- a/lib/librte_distributor/Makefile
105 +++ b/lib/librte_distributor/Makefile
106 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
107  # library name
108  LIB = librte_distributor.a
109  
110 -CFLAGS += -O3
111 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
112 +# Include the source dir first, so that headers paths are always picked
113 +# from there. By including it last race conditions might happen during paralle
114 +# builds, and headers might be already installed in RTE_OUT/include when the
115 +# variable is recursively expanded, thus causing GCC to sometimes use the
116 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
117 +# reproducible.
118 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
119 +CFLAGS += $(WERROR_FLAGS) -O3
120  
121  EXPORT_MAP := rte_distributor_version.map
122  
123 diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile
124 index 90bca4d68..f5eee1c6a 100644
125 --- a/lib/librte_eal/linuxapp/eal/Makefile
126 +++ b/lib/librte_eal/linuxapp/eal/Makefile
127 @@ -41,7 +41,13 @@ LIBABIVER := 5
128  
129  VPATH += $(RTE_SDK)/lib/librte_eal/common
130  
131 -CFLAGS += -I$(SRCDIR)/include
132 +# Include the source dir first, so that headers paths are always picked
133 +# from there. By including it last race conditions might happen during paralle
134 +# builds, and headers might be already installed in RTE_OUT/include when the
135 +# variable is recursively expanded, thus causing GCC to sometimes use the
136 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
137 +# reproducible.
138 +CFLAGS := -I$(SRCDIR)/include $(CFLAGS)
139  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
140  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include
141  CFLAGS += $(WERROR_FLAGS) -O3
142 diff --git a/lib/librte_efd/Makefile b/lib/librte_efd/Makefile
143 index b9277bc5d..b169e3240 100644
144 --- a/lib/librte_efd/Makefile
145 +++ b/lib/librte_efd/Makefile
146 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
147  # library name
148  LIB = librte_efd.a
149  
150 -CFLAGS += -O3
151 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
152 +# Include the source dir first, so that headers paths are always picked
153 +# from there. By including it last race conditions might happen during paralle
154 +# builds, and headers might be already installed in RTE_OUT/include when the
155 +# variable is recursively expanded, thus causing GCC to sometimes use the
156 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
157 +# reproducible.
158 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
159 +CFLAGS += $(WERROR_FLAGS) -O3
160  
161  EXPORT_MAP := rte_efd_version.map
162  
163 diff --git a/lib/librte_hash/Makefile b/lib/librte_hash/Makefile
164 index 9cf13a045..677d494e7 100644
165 --- a/lib/librte_hash/Makefile
166 +++ b/lib/librte_hash/Makefile
167 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
168  # library name
169  LIB = librte_hash.a
170  
171 -CFLAGS += -O3
172 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
173 +# Include the source dir first, so that headers paths are always picked
174 +# from there. By including it last race conditions might happen during paralle
175 +# builds, and headers might be already installed in RTE_OUT/include when the
176 +# variable is recursively expanded, thus causing GCC to sometimes use the
177 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
178 +# reproducible.
179 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
180 +CFLAGS += $(WERROR_FLAGS) -O3
181  
182  EXPORT_MAP := rte_hash_version.map
183  
184 diff --git a/lib/librte_ip_frag/Makefile b/lib/librte_ip_frag/Makefile
185 index 4e693bf8f..de45ec2d3 100644
186 --- a/lib/librte_ip_frag/Makefile
187 +++ b/lib/librte_ip_frag/Makefile
188 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
189  # library name
190  LIB = librte_ip_frag.a
191  
192 -CFLAGS += -O3
193 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
194 +# Include the source dir first, so that headers paths are always picked
195 +# from there. By including it last race conditions might happen during paralle
196 +# builds, and headers might be already installed in RTE_OUT/include when the
197 +# variable is recursively expanded, thus causing GCC to sometimes use the
198 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
199 +# reproducible.
200 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
201 +CFLAGS += $(WERROR_FLAGS) -O3
202  
203  EXPORT_MAP := rte_ipfrag_version.map
204  
205 diff --git a/lib/librte_jobstats/Makefile b/lib/librte_jobstats/Makefile
206 index 561a0678c..57329b18e 100644
207 --- a/lib/librte_jobstats/Makefile
208 +++ b/lib/librte_jobstats/Makefile
209 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
210  # library name
211  LIB = librte_jobstats.a
212  
213 -CFLAGS += -O3
214 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
215 +# Include the source dir first, so that headers paths are always picked
216 +# from there. By including it last race conditions might happen during paralle
217 +# builds, and headers might be already installed in RTE_OUT/include when the
218 +# variable is recursively expanded, thus causing GCC to sometimes use the
219 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
220 +# reproducible.
221 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
222 +CFLAGS += $(WERROR_FLAGS) -O3
223  
224  EXPORT_MAP := rte_jobstats_version.map
225  
226 diff --git a/lib/librte_kni/Makefile b/lib/librte_kni/Makefile
227 index 70f1ca8f6..130d6fd74 100644
228 --- a/lib/librte_kni/Makefile
229 +++ b/lib/librte_kni/Makefile
230 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
231  # library name
232  LIB = librte_kni.a
233  
234 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -fno-strict-aliasing
235 +# Include the source dir first, so that headers paths are always picked
236 +# from there. By including it last race conditions might happen during paralle
237 +# builds, and headers might be already installed in RTE_OUT/include when the
238 +# variable is recursively expanded, thus causing GCC to sometimes use the
239 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
240 +# reproducible.
241 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
242 +CFLAGS += $(WERROR_FLAGS) -O3 -fno-strict-aliasing
243  
244  EXPORT_MAP := rte_kni_version.map
245  
246 diff --git a/lib/librte_kvargs/Makefile b/lib/librte_kvargs/Makefile
247 index 564dd3102..7c332c110 100644
248 --- a/lib/librte_kvargs/Makefile
249 +++ b/lib/librte_kvargs/Makefile
250 @@ -36,7 +36,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
251  # library name
252  LIB = librte_kvargs.a
253  
254 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
255 +# Include the source dir first, so that headers paths are always picked
256 +# from there. By including it last race conditions might happen during paralle
257 +# builds, and headers might be already installed in RTE_OUT/include when the
258 +# variable is recursively expanded, thus causing GCC to sometimes use the
259 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
260 +# reproducible.
261 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
262 +CFLAGS += $(WERROR_FLAGS) -O3
263  
264  EXPORT_MAP := rte_kvargs_version.map
265  
266 diff --git a/lib/librte_latencystats/Makefile b/lib/librte_latencystats/Makefile
267 index eaacbb731..46a8ecd34 100644
268 --- a/lib/librte_latencystats/Makefile
269 +++ b/lib/librte_latencystats/Makefile
270 @@ -33,7 +33,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
271  # library name
272  LIB = librte_latencystats.a
273  
274 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
275 +# Include the source dir first, so that headers paths are always picked
276 +# from there. By including it last race conditions might happen during paralle
277 +# builds, and headers might be already installed in RTE_OUT/include when the
278 +# variable is recursively expanded, thus causing GCC to sometimes use the
279 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
280 +# reproducible.
281 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
282 +CFLAGS += $(WERROR_FLAGS) -O3
283  LDLIBS += -lm
284  LDLIBS += -lpthread
285  
286 diff --git a/lib/librte_lpm/Makefile b/lib/librte_lpm/Makefile
287 index 32be46b3b..6a97fdc97 100644
288 --- a/lib/librte_lpm/Makefile
289 +++ b/lib/librte_lpm/Makefile
290 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
291  # library name
292  LIB = librte_lpm.a
293  
294 -CFLAGS += -O3
295 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
296 +# Include the source dir first, so that headers paths are always picked
297 +# from there. By including it last race conditions might happen during paralle
298 +# builds, and headers might be already installed in RTE_OUT/include when the
299 +# variable is recursively expanded, thus causing GCC to sometimes use the
300 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
301 +# reproducible.
302 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
303 +CFLAGS += $(WERROR_FLAGS) -O3
304  
305  EXPORT_MAP := rte_lpm_version.map
306  
307 diff --git a/lib/librte_mbuf/Makefile b/lib/librte_mbuf/Makefile
308 index 548273054..4d51191ee 100644
309 --- a/lib/librte_mbuf/Makefile
310 +++ b/lib/librte_mbuf/Makefile
311 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
312  # library name
313  LIB = librte_mbuf.a
314  
315 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
316 +# Include the source dir first, so that headers paths are always picked
317 +# from there. By including it last race conditions might happen during paralle
318 +# builds, and headers might be already installed in RTE_OUT/include when the
319 +# variable is recursively expanded, thus causing GCC to sometimes use the
320 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
321 +# reproducible.
322 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
323 +CFLAGS += $(WERROR_FLAGS) -O3
324  
325  EXPORT_MAP := rte_mbuf_version.map
326  
327 diff --git a/lib/librte_mempool/Makefile b/lib/librte_mempool/Makefile
328 index 7b5bdfee7..33678192f 100644
329 --- a/lib/librte_mempool/Makefile
330 +++ b/lib/librte_mempool/Makefile
331 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
332  # library name
333  LIB = librte_mempool.a
334  
335 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
336 +# Include the source dir first, so that headers paths are always picked
337 +# from there. By including it last race conditions might happen during paralle
338 +# builds, and headers might be already installed in RTE_OUT/include when the
339 +# variable is recursively expanded, thus causing GCC to sometimes use the
340 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
341 +# reproducible.
342 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
343 +CFLAGS += $(WERROR_FLAGS) -O3
344  
345  EXPORT_MAP := rte_mempool_version.map
346  
347 diff --git a/lib/librte_metrics/Makefile b/lib/librte_metrics/Makefile
348 index d4990e839..195bd4d56 100644
349 --- a/lib/librte_metrics/Makefile
350 +++ b/lib/librte_metrics/Makefile
351 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
352  # library name
353  LIB = librte_metrics.a
354  
355 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
356 +# Include the source dir first, so that headers paths are always picked
357 +# from there. By including it last race conditions might happen during paralle
358 +# builds, and headers might be already installed in RTE_OUT/include when the
359 +# variable is recursively expanded, thus causing GCC to sometimes use the
360 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
361 +# reproducible.
362 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
363 +CFLAGS += $(WERROR_FLAGS) -O3
364  
365  EXPORT_MAP := rte_metrics_version.map
366  
367 diff --git a/lib/librte_net/Makefile b/lib/librte_net/Makefile
368 index 56727c4df..a08a7dd8b 100644
369 --- a/lib/librte_net/Makefile
370 +++ b/lib/librte_net/Makefile
371 @@ -33,7 +33,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
372  
373  LIB = librte_net.a
374  
375 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
376 +# Include the source dir first, so that headers paths are always picked
377 +# from there. By including it last race conditions might happen during paralle
378 +# builds, and headers might be already installed in RTE_OUT/include when the
379 +# variable is recursively expanded, thus causing GCC to sometimes use the
380 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
381 +# reproducible.
382 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
383 +CFLAGS += $(WERROR_FLAGS) -O3
384  
385  EXPORT_MAP := rte_net_version.map
386  LIBABIVER := 1
387 diff --git a/lib/librte_pdump/Makefile b/lib/librte_pdump/Makefile
388 index 1c03bcbb7..8923d7499 100644
389 --- a/lib/librte_pdump/Makefile
390 +++ b/lib/librte_pdump/Makefile
391 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
392  # library name
393  LIB = librte_pdump.a
394  
395 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
396 -CFLAGS += -D_GNU_SOURCE
397 +# Include the source dir first, so that headers paths are always picked
398 +# from there. By including it last race conditions might happen during paralle
399 +# builds, and headers might be already installed in RTE_OUT/include when the
400 +# variable is recursively expanded, thus causing GCC to sometimes use the
401 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
402 +# reproducible.
403 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
404 +CFLAGS += $(WERROR_FLAGS) -O3 -D_GNU_SOURCE
405  LDLIBS += -lpthread
406  
407  EXPORT_MAP := rte_pdump_version.map
408 diff --git a/lib/librte_power/Makefile b/lib/librte_power/Makefile
409 index 06cd10e86..b76ad689e 100644
410 --- a/lib/librte_power/Makefile
411 +++ b/lib/librte_power/Makefile
412 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
413  # library name
414  LIB = librte_power.a
415  
416 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -fno-strict-aliasing
417 +# Include the source dir first, so that headers paths are always picked
418 +# from there. By including it last race conditions might happen during paralle
419 +# builds, and headers might be already installed in RTE_OUT/include when the
420 +# variable is recursively expanded, thus causing GCC to sometimes use the
421 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
422 +# reproducible.
423 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
424 +CFLAGS += $(WERROR_FLAGS) -O3 -fno-strict-aliasing
425  
426  EXPORT_MAP := rte_power_version.map
427  
428 diff --git a/lib/librte_reorder/Makefile b/lib/librte_reorder/Makefile
429 index 4e44e72f0..51b5d490d 100644
430 --- a/lib/librte_reorder/Makefile
431 +++ b/lib/librte_reorder/Makefile
432 @@ -34,8 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
433  # library name
434  LIB = librte_reorder.a
435  
436 -CFLAGS += -O3
437 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
438 +# Include the source dir first, so that headers paths are always picked
439 +# from there. By including it last race conditions might happen during paralle
440 +# builds, and headers might be already installed in RTE_OUT/include when the
441 +# variable is recursively expanded, thus causing GCC to sometimes use the
442 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
443 +# reproducible.
444 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
445 +CFLAGS += $(WERROR_FLAGS) -O3
446  
447  EXPORT_MAP := rte_reorder_version.map
448  
449 diff --git a/lib/librte_ring/Makefile b/lib/librte_ring/Makefile
450 index 3e2f4b873..e5248a2c1 100644
451 --- a/lib/librte_ring/Makefile
452 +++ b/lib/librte_ring/Makefile
453 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
454  # library name
455  LIB = librte_ring.a
456  
457 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
458 +# Include the source dir first, so that headers paths are always picked
459 +# from there. By including it last race conditions might happen during paralle
460 +# builds, and headers might be already installed in RTE_OUT/include when the
461 +# variable is recursively expanded, thus causing GCC to sometimes use the
462 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
463 +# reproducible.
464 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
465 +CFLAGS += $(WERROR_FLAGS) -O3
466  
467  EXPORT_MAP := rte_ring_version.map
468  
469 diff --git a/lib/librte_timer/Makefile b/lib/librte_timer/Makefile
470 index 03a15390e..0c57cc6d3 100644
471 --- a/lib/librte_timer/Makefile
472 +++ b/lib/librte_timer/Makefile
473 @@ -34,7 +34,14 @@ include $(RTE_SDK)/mk/rte.vars.mk
474  # library name
475  LIB = librte_timer.a
476  
477 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
478 +# Include the source dir first, so that headers paths are always picked
479 +# from there. By including it last race conditions might happen during parallel
480 +# builds, and headers might be already installed in RTE_OUT/include when the
481 +# variable is recursively expanded, thus causing GCC to sometimes use the
482 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
483 +# reproducible.
484 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
485 +CFLAGS += $(WERROR_FLAGS) -O3
486  
487  EXPORT_MAP := rte_timer_version.map
488  
489 diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
490 index 4a116fe31..ef0d86990 100644
491 --- a/lib/librte_vhost/Makefile
492 +++ b/lib/librte_vhost/Makefile
493 @@ -38,7 +38,14 @@ EXPORT_MAP := rte_vhost_version.map
494  
495  LIBABIVER := 4
496  
497 -CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64
498 +# Include the source dir first, so that headers paths are always picked
499 +# from there. By including it last race conditions might happen during parallel
500 +# builds, and headers might be already installed in RTE_OUT/include when the
501 +# variable is recursively expanded, thus causing GCC to sometimes use the
502 +# SRCDIR path and sometimes the RTE_OUT/include, making the builds not
503 +# reproducible.
504 +CFLAGS := -I$(SRCDIR) $(CFLAGS)
505 +CFLAGS += $(WERROR_FLAGS) -O3 -D_FILE_OFFSET_BITS=64
506  CFLAGS += -I vhost_user
507  LDLIBS += -lpthread
508  
509 -- 
510 2.11.0
511