Skip to content

Commit 9bb12d9

Browse files
committed
build: sort sources to build in a more deterministic way
It has been observed that binaries contents are depending on the order of linked objects. This order is caused by GNU make's wildcard function and the position of sources on filesystem. This change tries to prevent this kind of randomness. Also consider building using -j1 flag to make it even more reproductible. Change-Id: Ie8eee7f336e6f1fa2863c4150d967afd15519f1d Bug: http://bugzilla.syslinux.org/show_bug.cgi?id=57#related Signed-off-by: Philippe Coval <philippe.coval at open.eurogiciel.org>
1 parent b7db160 commit 9bb12d9

File tree

15 files changed

+27
-27
lines changed

15 files changed

+27
-27
lines changed

codepage/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VPATH = $(SRC)
22
PERL = perl
3-
CPSRC = $(wildcard $(SRC)/*.txt)
3+
CPSRC = $(sort $(wildcard $(SRC)/*.txt))
44
CPOBJ = $(notdir $(CPSRC))
55
GENFILES = $(patsubst %.txt,%.cp,$(CPOBJ))
66

com32/cmenu/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
3232
libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o \
3333
$(objdir)/com32/libutil/libutil.c32 $(objdir)/com32/lib/libcom32.c32
3434

35-
CMENUS = $(patsubst %.c,%.c32,$(wildcard $(SRC)/*.c))
36-
IMENUS = $(patsubst %.menu,%.c32,$(wildcard $(SRC)/*.menu))
35+
CMENUS = $(patsubst %.c,%.c32,$(sort $(wildcard $(SRC)/*.c)))
36+
IMENUS = $(patsubst %.menu,%.c32,$(sort $(wildcard $(SRC)/*.menu)))
3737

3838
MENUS = $(LIBS) $(subst $(SRC)/,,$(CMENUS) $(IMENUS))
3939

@@ -62,7 +62,7 @@ clean: tidy menuclean
6262
rm -f *.lss *.com
6363

6464
menuclean:
65-
rm -f $(patsubst %.menu,%.c,$(wildcard *.menu))
65+
rm -f $(patsubst %.menu,%.c,$(sort $(wildcard *.menu)))
6666

6767
spotless: clean libclean menuclean
6868
rm -f *~ \#* *.c32

com32/gpllib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include $(MAKEDIR)/lib.mk
88
REQFLAGS += -I$(SRC)/../gplinclude -I$(SRC)/../gplinclude/zzjson
99

1010
GPLDIRS := $(SRC) $(addprefix $(SRC)/,disk dmi vpd acpi zzjson)
11-
LIBOBJS := $(subst $(SRC)/,,$(foreach dir,$(GPLDIRS),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c))))
11+
LIBOBJS := $(subst $(SRC)/,,$(foreach dir,$(GPLDIRS),$(patsubst %.c,%.o,$(sort $(wildcard $(dir)/*.c)))))
1212

1313
BINDIR = /usr/bin
1414
LIBDIR = /usr/lib

com32/hdt/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CFLAGS += -I$(com32)/cmenu/libmenu -I$(com32)
2525
MODULES = hdt.c32
2626
TESTFILES =
2727

28-
OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
28+
OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(sort $(wildcard $(SRC)/*.c))))
2929
VERSION = $(shell $(SED) -n 's/\#define VERSION \"\(.*\)\"/\1/p' hdt.h)
3030
CODENAME = $(shell $(SED) -n 's/\#define CODENAME \"\(.*\)\"/\1/p' hdt.h)
3131
NODASH_VERSION = $(shell echo $(VERSION) | $(SED) -e 's/-/_/g' | $(SED) -e 's/\./_/g')

com32/libupload/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include $(MAKEDIR)/com32.mk
44

55
REQFLAGS += -I$(SRC)
66

7-
LIBOBJS := $(notdir $(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
7+
LIBOBJS := $(notdir $(patsubst %.c,%.o,$(sort $(wildcard $(SRC)/*.c))))
88

99
BINDIR = /usr/bin
1010
LIBDIR = /usr/lib

com32/rosh/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ include $(MAKEDIR)/rosh.mk
2727
# official release. Otherwise, substitute a hex string that is pretty much
2828
# guaranteed to be unique to be unique from build to build.
2929
ifndef HEXDATE
30-
HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(wildcard *.h))
30+
HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(sort $(wildcard *.h)))
3131
endif
3232
ifndef DATE
3333
DATE := $(shell sh $(topdir)/gen-id.sh $(VERSION) $(HEXDATE))

com32/sysdump/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ CFLAGS += -I$(com32) -I$(topdir)
2727
MODULES = sysdump.c32
2828
TESTFILES =
2929

30-
SRCS = $(wildcard $(SRC)/*.c)
30+
SRCS = $(sort $(wildcard $(SRC)/*.c))
3131
OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(SRCS)))
3232

3333
# The DATE is set on the make command line when building binaries for
3434
# official release. Otherwise, substitute a hex string that is pretty much
3535
# guaranteed to be unique to be unique from build to build.
3636
ifndef HEXDATE
37-
HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(wildcard *.h))
37+
HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(sort $(wildcard *.h)))
3838
endif
3939
ifndef DATE
4040
DATE := $(shell sh $(topdir)/gen-id.sh $(VERSION) $(HEXDATE))

core/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ BTARGET = kwdhash.gen \
3939
isolinux.bin isolinux-debug.bin pxelinux.0 lpxelinux.0
4040

4141
# All primary source files for the main syslinux files
42-
NASMSRC := $(wildcard $(SRC)/*.asm)
43-
NASMHDR := $(wildcard $(SRC)/*.inc)
42+
NASMSRC := $(sort $(wildcard $(SRC)/*.asm))
43+
NASMHDR := $(sort $(wildcard $(SRC)/*.inc))
4444
CSRC := $(shell find $(SRC) -name '*.c' -print)
4545
SSRC := $(shell find $(SRC) -name '*.S' -print)
4646
CHDR := $(shell find $(SRC) -name '*.h' -print)
@@ -80,9 +80,9 @@ FILTER_OBJS = %rawcon.o %plaincon.o %pxelinux-c.o %ldlinux-c.o \
8080
ifdef EFI_BUILD
8181
# EFI is single-threaded, and doesn't use the LZO assembly decoder
8282
FILTER_OBJS += $(subst $(SRC)/,, \
83-
$(patsubst %.S,%.o, $(wildcard $(SRC)/lzo/*.S)) \
84-
$(patsubst %.c,%.o, $(wildcard $(SRC)/thread/*.c)) \
85-
$(patsubst %.S,%.o, $(wildcard $(SRC)/thread/*.S)))
83+
$(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/lzo/*.S))) \
84+
$(patsubst %.c,%.o, $(sort $(wildcard $(SRC)/thread/*.c))) \
85+
$(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/thread/*.S))))
8686
endif
8787

8888
COBJS = $(filter-out $(FILTER_OBJS),$(COBJ))

dos/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ SRCS = syslinux.c \
3434
../libinstaller/getopt/getopt_long.c \
3535
../libinstaller/bootsect_bin.c \
3636
../libinstaller/mbr_bin.c \
37-
$(wildcard $(SRC)/../libfat/*.c)
37+
$(sort $(wildcard $(SRC)/../libfat/*.c))
3838
OBJS = header.o crt0.o ldlinux.o \
3939
$(patsubst %.c,%.o,$(notdir $(SRCS)))
4040
LIBOBJS = int2526.o conio.o memcpy.o memset.o memmove.o skipatou.o atou.o \

gpxe/src/Makefile.housekeeping

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ endif
246246
#
247247
# BIN has the form bin[-[arch-]platform]
248248

249-
ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
249+
ARCHS := $(patsubst arch/%,%,$(sort $(wildcard arch/*)))
250250
PLATFORMS := $(patsubst config/defaults/%.h,%,\
251-
$(wildcard config/defaults/*.h))
251+
$(sort $(wildcard config/defaults/*.h)))
252252
archs :
253253
@$(ECHO) $(ARCHS)
254254

@@ -307,8 +307,8 @@ srcdirs :
307307

308308
# SRCS lists all .c or .S files found in any SRCDIR
309309
#
310-
SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
311-
SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
310+
SRCS += $(sort $(wildcard $(patsubst %,%/*.c,$(SRCDIRS))))
311+
SRCS += $(sort $(wildcard $(patsubst %,%/*.S,$(SRCDIRS))))
312312
srcs :
313313
@$(ECHO) $(SRCS)
314314

@@ -677,7 +677,7 @@ endef
677677
$(BIN)/%.objs : $(BIN)/%.tmp
678678
$(Q)$(ECHO) $(call objs_list,$<)
679679
$(BIN)/%.sizes : $(BIN)/%.tmp
680-
$(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(wildcard $(BIN)/$(subst _,?,$(OBJ)).o)) | \
680+
$(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(sort $(wildcard $(BIN)/$(subst _,?,$(OBJ)).o))) | \
681681
sort -g
682682

683683
# Get dependency list for the specified target
@@ -807,7 +807,7 @@ $(BIN)/%.o : payload/%.img
807807
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
808808
--defsym obj_$*=0
809809

810-
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
810+
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(sort $(wildcard payload/*.img)))
811811

812812
# The "allXXXs" targets for each suffix
813813
#

0 commit comments

Comments
 (0)