open_posix_testsuite/generate-makefiles.sh: Avoid inconsistencies with make version
PATCH 1/3 open_posix_testsuite/generate-makefiles.sh: Avoid inconsistencies with make version
With make 4.1, INSTALL_TARGETS+=<tab> will add a space to the variable whereas with make 4.3, it will not. This leads to differing run.sh files in installed in packages which is undesireable. If tests is empty we don't have to add the line to the makefiles at all which seems like the easiest way to avoid the differences in make behaviour.
--- .../open_posix_testsuite/scripts/generate-makefiles.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
testcases/open_posix_testsuite/scripts/generate-makefiles.sh +5 -1
@@ -148,8 +148,12 @@ EOF fi - cat >> "$makefile.2" <<EOF + if [ ! -z "${tests}" ]; then + cat >> "$makefile.2" <<EOF INSTALL_TARGETS+= ${tests} +EOF + fi + cat >> "$makefile.2" <<EOF MAKE_TARGETS+= ${targets} EOF
Signature · 1 line
2.27.0
PATCH 2/3 Makefile: Avoid wildcard determinism issues
wildcard used in Makefiles preserves the order of the files on disk which leads to differences in the order the binaries are linked.
This patch tweaks the usage of wildcard to also have a sort, making the binaries reproducible. A previous patch massively improved the situation but wider testing showed that these other changes can have an effect on some binaries, this patch avoids those issues as exposed by our wider testing.
--- include/mk/env_post.mk | 2 +- include/mk/module.mk | 2 +- runtest/Makefile | 2 +- scenario_groups/Makefile | 2 +- testcases/commands/ldd/datafiles/Makefile | 2 +- testcases/kernel/hotplug/memory_hotplug/Makefile | 3 ++- testcases/kernel/io/disktest/Makefile | 2 +- testcases/kernel/io/disktest/Makefile.linux | 4 ++-- testcases/kernel/sched/hyperthreading/ht_affinity/Makefile | 2 +- testcases/kernel/sched/hyperthreading/ht_enabled/Makefile | 2 +- testcases/kernel/sched/sched_stress/Makefile | 2 +- testcases/kernel/syscalls/lchown/Makefile | 2 +- testcases/kernel/syscalls/migrate_pages/Makefile | 2 +- testcases/kernel/syscalls/move_pages/Makefile | 2 +- testcases/kernel/syscalls/utils/compat_16.mk | 2 +- testcases/kernel/syscalls/utils/newer_64.mk | 2 +- testcases/misc/math/float/Makefile | 2 +- testcases/network/nfs/nfs_stress/nfs05_make_tree.c | 4 ++-- testcases/network/nfsv4/locks/Makefile | 2 +- utils/sctp/func_tests/Makefile | 2 +- 20 files changed, 23 insertions(+), 22 deletions(-)
include/mk/env_post.mk +1 -1
@@ -47,7 +47,7 @@ LDFLAGS += -L$(top_builddir)/lib/android_libpthread LDFLAGS += -L$(top_builddir)/lib/android_librt endif -MAKE_TARGETS ?= $(notdir $(patsubst %.c,%,$(wildcard $(abs_srcdir)/*.c))) +MAKE_TARGETS ?= $(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c)))) MAKE_TARGETS := $(filter-out $(FILTER_OUT_MAKE_TARGETS),$(MAKE_TARGETS)) # with only *.dwo, .[0-9]+.dwo can not be cleaned
include/mk/module.mk +1 -1
@@ -42,7 +42,7 @@ endif ifneq ($(filter install clean,$(MAKECMDGOALS)),) MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS)) -MAKE_TARGETS += $(wildcard *.ko) +MAKE_TARGETS += $(sort $(wildcard *.ko)) endif CLEAN_TARGETS += .dep_modules *.mod built-in.a
runtest/Makefile +1 -1
@@ -36,7 +36,7 @@ ifneq ($(WITH_POWER_MANAGEMENT_TESTSUITE),yes) UNWANTED_FILES += power_management_tests endif -INSTALL_TARGETS := $(filter-out $(UNWANTED_FILES),$(notdir $(patsubst $(abs_srcdir)/%,%,$(wildcard $(abs_srcdir)/*)))) +INSTALL_TARGETS := $(filter-out $(UNWANTED_FILES),$(notdir $(patsubst $(abs_srcdir)/%,%,$(sort $(wildcard $(abs_srcdir)/*))))) MAKE_TARGETS :=
scenario_groups/Makefile +1 -1
@@ -31,7 +31,7 @@ UNWANTED_FILES := Makefile INSTALL_MODE := 00644 -INSTALL_TARGETS := $(filter-out $(UNWANTED_FILES),$(notdir $(patsubst $(abs_srcdir)/%,%,$(wildcard $(abs_srcdir)/*)))) +INSTALL_TARGETS := $(filter-out $(UNWANTED_FILES),$(notdir $(patsubst $(abs_srcdir)/%,%,$(sort $(wildcard $(abs_srcdir)/*))))) MAKE_TARGETS :=
testcases/commands/ldd/datafiles/Makefile +1 -1
@@ -21,7 +21,7 @@ CPPFLAGS += -fpic INSTALL_TARGETS := ldd*.so lddfile.out -LDD_C_FILES := $(wildcard $(abs_srcdir)/lddfile*.c) +LDD_C_FILES := $(sort $(wildcard $(abs_srcdir)/lddfile*.c)) LDD_SO_FILES := $(patsubst $(abs_srcdir)/%.c,%.obj.so,$(LDD_C_FILES)) MAKE_TARGETS := lddfile.out CLEAN_TARGETS += *.obj $(LDD_SO_FILES)
testcases/kernel/hotplug/memory_hotplug/Makefile +2 -1
@@ -31,6 +31,7 @@ LDLIBS := $(filter-out -lltp,$(LDLIBS)) MAKE_TARGETS := memtoy -memtoy: $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c)) +memtoy: $(patsubst $(abs_srcdir)/%.c,%.o,$(sort $(wildcard $(abs_srcdir)/*.c))) + include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/io/disktest/Makefile +1 -1
@@ -209,7 +209,7 @@ LDLIBS += -lpthread MAKE_TARGETS := disktest -OBJS := $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c)) +OBJS := $(patsubst $(abs_srcdir)/%.c,%.o,$(sort $(wildcard $(abs_srcdir)/*.c))) disktest-$(VER): mkdir -p "$@"
testcases/kernel/io/disktest/Makefile.linux +2 -2
@@ -167,8 +167,8 @@ mandir=/usr/share/man VER=`grep VER_STR main.h | awk -F\" '{print $$2}'` GBLHDRS=main.h globals.h defs.h -ALLHDRS=$(wildcard *.h) -SRCS=$(wildcard *.c) +ALLHDRS=$(sort $(wildcard *.h)) +SRCS=$(sort $(wildcard *.c)) OBJS=$(SRCS:.c=.o) CFLAGS += -g -Wall -O -D"LINUX" -D"_THREAD_SAFE" -D"_GNU_SOURCE" -D"_LARGE_FILES" -D"_LARGEFILE64_SOURCE" -D"_FILE_OFFSET_BITS=64" $(RPM_OPT_FLAGS)
testcases/kernel/sched/hyperthreading/ht_affinity/Makefile +1 -1
@@ -28,6 +28,6 @@ INSTALL_TARGETS := smt_smp_affinity.sh MAKE_TARGETS := ht_affinity -$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c)) +$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(sort $(wildcard $(abs_srcdir)/*.c))) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/sched/hyperthreading/ht_enabled/Makefile +1 -1
@@ -28,6 +28,6 @@ INSTALL_TARGETS := smt_smp_enabled.sh MAKE_TARGETS := ht_enabled -$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c)) +$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(sort $(wildcard $(abs_srcdir)/*.c))) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/sched/sched_stress/Makefile +1 -1
@@ -10,7 +10,7 @@ INSTALL_TARGETS := sched_stress.sh LDLIBS += -lpthread -MAKE_TARGETS := $(filter-out sched,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c))) +MAKE_TARGETS := $(filter-out sched,$(patsubst $(abs_srcdir)/%.c,%,$(sort $(wildcard $(abs_srcdir)/*.c)))) RM += -r
testcases/kernel/syscalls/lchown/Makefile +1 -1
@@ -5,7 +5,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -SRCS := $(wildcard $(abs_srcdir)/lchown*.c) +SRCS := $(sort $(wildcard $(abs_srcdir)/lchown*.c)) include $(abs_srcdir)/../utils/compat_16.mk
testcases/kernel/syscalls/migrate_pages/Makefile +1 -1
@@ -5,7 +5,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*[0-9].c)) +MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(sort $(wildcard $(abs_srcdir)/*[0-9].c))) $(MAKE_TARGETS): %: migrate_pages_common.o CPPFLAGS += -I$(abs_srcdir)/../utils/
testcases/kernel/syscalls/move_pages/Makefile +1 -1
@@ -7,7 +7,7 @@ include $(top_srcdir)/include/mk/testcases.mk CPPFLAGS += -I$(abs_srcdir)/../utils -MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*[0-9].c)) +MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(sort $(wildcard $(abs_srcdir)/*[0-9].c))) $(MAKE_TARGETS): %: move_pages_support.o
testcases/kernel/syscalls/utils/compat_16.mk +1 -1
@@ -50,7 +50,7 @@ CPPFLAGS += -I$(abs_srcdir) -I$(abs_srcdir)/../utils -SRCS ?= $(wildcard $(abs_srcdir)/*.c) +SRCS ?= $(sort $(wildcard $(abs_srcdir)/*.c)) MAKE_TARGETS := $(notdir $(patsubst %.c,%,$(SRCS))) MAKE_TARGETS_OBJS_WO_COMPAT_16 := $(addsuffix .o,$(MAKE_TARGETS))
testcases/kernel/syscalls/utils/newer_64.mk +1 -1
@@ -25,7 +25,7 @@ CPPFLAGS += -I$(abs_srcdir) -I$(abs_srcdir)/../utils -SRCS ?= $(wildcard $(abs_srcdir)/*.c) +SRCS ?= $(sort $(wildcard $(abs_srcdir)/*.c)) MAKE_TARGETS := $(notdir $(patsubst %.c,%,$(SRCS)))
testcases/misc/math/float/Makefile +1 -1
@@ -27,6 +27,6 @@ include $(top_srcdir)/include/mk/testcases.mk LDLIBS += -lpthread -lm # main.c doesn't compile... -MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/float*.c)) +MAKE_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(sort $(wildcard $(abs_srcdir)/float*.c))) include $(top_srcdir)/include/mk/generic_trunk_target.mk
testcases/network/nfs/nfs_stress/nfs05_make_tree.c +2 -2
@@ -104,7 +104,7 @@ static void *thread_fn(LTP_ATTRIBUTE_UNUSED void *args)"\treturn 0;\n}\n" ;const char make_buf_n[] ="CFLAGS := -O -w -g\n" -"SRCS=$(wildcard *.c)\n" +"SRCS=$(sort $(wildcard *.c))\n" "TARGETS=$(SRCS:.c=)\n" "all: $(TARGETS)\n" "$(TARGETS): %: %.c\n"
@@ -114,7 +114,7 @@ static void *thread_fn(LTP_ATTRIBUTE_UNUSED void *args)const char make_buf[] ="CFLAGS := -O -w -g\n" "SUBDIR = dir\n" -"SRCS=$(wildcard *.c)\n" +"SRCS=$(sort $(wildcard *.c))\n" "TARGETS=$(SRCS:.c=)\n" "all: $(SUBDIR) $(TARGETS)\n" "$(TARGETS): %: %.c\n"
testcases/network/nfsv4/locks/Makefile +1 -1
@@ -28,6 +28,6 @@ MAKE_TARGETS := locktests LDLIBS += -lpthread -$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c)) +$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(sort $(wildcard $(abs_srcdir)/*.c))) include $(top_srcdir)/include/mk/generic_leaf_target.mk
utils/sctp/func_tests/Makefile +1 -1
@@ -30,7 +30,7 @@ LDFLAGS += $(addprefix -L$(abs_builddir)/../,lib testlib) LDLIBS += -lsctputil -lsctp -lpthread -V4_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)) +V4_TARGETS := $(patsubst $(abs_srcdir)/%.c,%,$(sort $(wildcard $(abs_srcdir)/*.c))) V6_TARGETS := test_basic_v6 test_fragments_v6 test_getname_v6 \ test_inaddr_any_v6 test_peeloff_v6 \
Signature · 1 line
2.27.0
PATCH 3/3 syscalls/swapon/swapoff: Move common library to libs/
In reply to Richard PurdieThere is a race/determinism issue with libswapon currently as depending on which makefile path builds it, the debug paths may be "../swapon/libswapon.c" or "libswapon.c". To avoid the determinism issue, move libswapon to libs/ and use it from the shared location.
The header is moved to the common includes directory to match and the Makefile.inc fragment can be dropped.
---
.../kernel/syscalls/swapon => include}/libswapon.h | 0
libs/libltpswapon/Makefile | 12 ++++++++++++
.../swapon => libs/libltpswapon}/libswapon.c | 0
testcases/kernel/syscalls/swapoff/Makefile | 7 +++++--
testcases/kernel/syscalls/swapoff/Makefile.inc | 6 ------
testcases/kernel/syscalls/swapoff/swapoff01.c | 2 +-
testcases/kernel/syscalls/swapoff/swapoff02.c | 2 +-
testcases/kernel/syscalls/swapon/Makefile | 6 +++---
8 files changed, 22 insertions(+), 13 deletions(-)
rename {testcases/kernel/syscalls/swapon => include}/libswapon.h (100%)
create mode 100644 libs/libltpswapon/Makefile
rename {testcases/kernel/syscalls/swapon => libs/libltpswapon}/libswapon.c (100%)
delete mode 100644 testcases/kernel/syscalls/swapoff/Makefile.incinclude/libswapon.h renamed from testcases/kernel/syscalls/swapon/libswapon.h +0 -0
libs/libltpswapon/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) Richard Purdie <[email protected]> + +top_srcdir ?= ../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INTERNAL_LIB := libltpswapon.a + +include $(top_srcdir)/include/mk/lib.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
libs/libltpswapon/libswapon.c renamed from testcases/kernel/syscalls/swapon/libswapon.c +0 -0
testcases/kernel/syscalls/swapoff/Makefile +5 -2
@@ -3,7 +3,10 @@ top_srcdir ?= ../../../.. +LTPLIBS = ltpswapon + include $(top_srcdir)/include/mk/testcases.mk -include $(abs_srcdir)/./Makefile.inc + +LTPLDLIBS = -lltpswapon + include $(top_srcdir)/include/mk/generic_leaf_target.mk -$(MAKE_TARGETS): %: ../swapon/libswapon.o
testcases/kernel/syscalls/swapoff/Makefile.inc deleted +0 -6
@@ -1,6 +0,0 @@ -LIBDIR += ../swapon/ -LIBSWAPON := $(LIBDIR)/libswapon.o -$(LIBSWAPON): - $(MAKE) -C $(LIBDIR) -CPPFLAGS += -I$(abs_srcdir)/$(LIBDIR) -LDFLAGS += -L$(abs_builddir)/$(LIBDIR)
testcases/kernel/syscalls/swapoff/swapoff01.c +1 -1
@@ -25,7 +25,7 @@#include <stdlib.h> #include "config.h" #include "lapi/syscalls.h" -#include "../swapon/libswapon.h" +#include "libswapon.h" static void setup (void );static void cleanup (void );
testcases/kernel/syscalls/swapoff/swapoff02.c +1 -1
@@ -33,7 +33,7 @@#include "test.h" #include "lapi/syscalls.h" #include "safe_macros.h" -#include "../swapon/libswapon.h" +#include "libswapon.h" static void setup (void );static void cleanup (void );
testcases/kernel/syscalls/swapon/Makefile +3 -3
@@ -8,10 +8,10 @@ endif top_srcdir ?= ../../../.. +LTPLIBS = ltpswapon + include $(top_srcdir)/include/mk/testcases.mk -FILTER_OUT_MAKE_TARGETS := libswapon +LTPLDLIBS = -lltpswapon include $(top_srcdir)/include/mk/generic_leaf_target.mk - -$(MAKE_TARGETS): %: libswapon.o
Signature · 1 line
2.27.0
PATCH 1/3 open_posix_testsuite/generate-makefiles.sh: Avoid inconsistencies with make version
In reply to Richard PurdieHi!
Patchset pushed, thanks.
Also it looks like the wildcard used to be sorted but they removed that in a few make versions and nobody knows why:
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/3 open_posix_testsuite/generate-makefiles.sh: Avoid inconsistencies with make version
Quoted 7 lines · Cyril Hrubis
Hi!
Patchset pushed, thanks.Also it looks like the wildcard used to be sorted but they removed that in a few make versions and nobody knows why:
Thanks. That decision in make was unfortunate and I think we'll be living with it for a while.
The good news is I think with these changes we have ltp behaving consistently within Yocto Project :)
Cheers,
Richard