x86emul: use vpath uniformly in harnesses
cover x86emul: use vpath uniformly in harnesses
While seemingly independent, the latter really depends on the former, or else the fuzzing harness build's behavior would be dependent upon the test harness having been built (and hence x86_emulate/ there being absent / present, offering source files [as symlinks] which really should be taken from the xen/ subtree).
1: test: use vpath uniformly for access to code living elsewhere 2: fuzz: use vpath uniformly for access to code living elsewhere
Jan
PATCH 1/2 x86emul/test: use vpath uniformly for access to code living elsewhere
Replace the remaining non-local symlink-ing (i.e. of core emulator files) as well, to avoid mixing approaches. (The symlink-ing of test blob sources needs to remain for the time being.)
---
Unlike in the subsequent fuzzer harness patch explicit dependencies can't go away here, yet. $(DEPS_INCLUDE) would need making use of first.
tools/tests/x86_emulator/Makefile +7 -4
@@ -11,6 +11,11 @@ all: run: $(TARGET) ./$(TARGET) +# Add the core emulator to the build +vpath x86_emulate/%.c $(XEN_ROOT)/xen/arch/x86 +vpath x86_emulate/%.h $(XEN_ROOT)/xen/arch/x86 +HOSTCFLAGS += -iquote $(XEN_ROOT)/xen/arch/x86 + # Add libx86 to the build vpath %.c $(XEN_ROOT)/xen/lib/x86
@@ -287,12 +292,8 @@ else run32 clean32: %32: % endif -.PHONY: x86_emulate x86_emulate: mkdir -p $@ - ln -sf $(XEN_ROOT)/xen/arch/x86/$@/*.[ch] $@/ - -x86_emulate/%: x86_emulate ; HOSTCFLAGS-x86_64 := -fno-PIE $(call cc-option-add,HOSTCFLAGS-x86_64,HOSTCC,-no-pie)
@@ -307,6 +308,8 @@ x86_emulate.h := x86-emulate.h x86_emula $(OBJS): %.o: %.c $(x86_emulate.h) $(HOSTCC) $(HOSTCFLAGS) -c -g -o $@ $< +$(filter x86_emulate/%.o,$(OBJS)): x86_emulate + x86-emulate.o: x86_emulate/x86_emulate.c x86-emulate.o x86_emulate/%.o: HOSTCFLAGS += -D__XEN_TOOLS__
PATCH 2/2 x86emul/fuzz: use vpath uniformly for access to code living elsewhere
In reply to Jan BeulichReplace the remaining symlink-ing (of test harness and core emulator files) as well, to avoid mixing approaches. This way various explicit dependencies can also go away.
tools/fuzz/x86_instruction_emulator/Makefile +18 -22
@@ -8,22 +8,23 @@ else x86-insn-fuzz-all: endif +CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ + +# Add the core emulator to the build +vpath x86_emulate/%.c $(XEN_ROOT)/xen/arch/x86 +vpath x86_emulate/%.h $(XEN_ROOT)/xen/arch/x86 +CFLAGS += -iquote $(XEN_ROOT)/xen/arch/x86 + +# Add the emulator test harness to the build +vpath %.c ../../tests/x86_emulator +vpath %.h ../../tests/x86_emulator +CFLAGS += -iquote ../../tests/x86_emulator + # Add libx86 to the build vpath %.c $(XEN_ROOT)/xen/lib/x86 -x86_emulate: FORCE +x86_emulate: mkdir -p $@ - ln -sf $(XEN_ROOT)/xen/arch/x86/$@/*.[ch] $@/ - -x86_emulate/%.c: x86_emulate ; -x86_emulate/%.h: x86_emulate ; - -%.c: $(XEN_ROOT)/tools/tests/x86_emulator/%.c FORCE - ln -nsf $< $@ -%.h: $(XEN_ROOT)/tools/tests/x86_emulator/%.h FORCE - ln -nsf $< $@ - -CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -iquote . GCOV_FLAGS := --coverage %-cov.o: %.c
@@ -33,18 +34,13 @@ OBJS := fuzz-emul.o x86-emulate.o OBJS += x86_emulate/0f01.o x86_emulate/0fae.o x86_emulate/0fc7.o OBJS += x86_emulate/decode.o x86_emulate/fpu.o -WRAPPED = $(shell sed -n 's,^ *WRAP(\([[:alnum:]_]*\));,\1,p' x86-emulate.h) - -private.h := x86-emulate.h x86_emulate/x86_emulate.h x86_emulate/private.h - -x86-emulate.h: x86_emulate/x86_emulate.h -x86-emulate.o x86-emulate-cov.o: x86_emulate/x86_emulate.c $(private.h) -fuzz-emul.o fuzz-emul-cov.o wrappers.o: x86-emulate.h +WRAPPED = $(shell sed -n 's,^ *WRAP(\([[:alnum:]_]*\));,\1,p' \ + ../../tests/x86_emulator/x86-emulate.h) -$(filter x86_emulate/%.o,$(OBJS)): x86_emulate/%.o: x86_emulate/%.c $(private.h) +$(filter x86_emulate/%.o,$(OBJS)): x86_emulate/%.o: x86_emulate/%.c x86_emulate $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -c -o $@ $< $(APPEND_CFLAGS) -$(patsubst %.o,%-cov.o,$(filter x86_emulate/%.o,$(OBJS))): x86_emulate/%-cov.o: x86_emulate/%.c $(private.h) +$(patsubst %.o,%-cov.o,$(filter x86_emulate/%.o,$(OBJS))): x86_emulate/%-cov.o: x86_emulate/%.c x86_emulate $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) $(GCOV_FLAGS) -c -o $@ $< $(APPEND_CFLAGS) x86-insn-fuzzer.a: $(OBJS) cpuid.o
@@ -70,7 +66,7 @@ distclean: clean clean: rm -f *.a *.o $(DEPS_RM) *.gcda *.gcno *.gcov rm -f afl-harness afl-harness-cov libfuzzer-harness - rm -rf x86_emulate x86-emulate.c x86-emulate.h wrappers.c + rm -rf x86_emulate .PHONY: install install: all
Quoted 8 lines · Jan Beulich
While seemingly independent, the latter really depends on the former, or else the fuzzing harness build's behavior would be dependent upon the test harness having been built (and hence x86_emulate/ there being absent / present, offering source files [as symlinks] which really should be taken from the xen/ subtree).
1: test: use vpath uniformly for access to code living elsewhere 2: fuzz: use vpath uniformly for access to code living elsewhere