[PATCH] tools/fuzz: use vpath uniformly for access to hypervisor library code

Jan Beulich posted 1 patch 1 month, 3 weeks ago
Failed in applying to current master (apply log)
[PATCH] tools/fuzz: use vpath uniformly for access to hypervisor library code
Posted by Jan Beulich 1 month, 3 weeks ago
It's not quite clear why for libelf and the emulator we use symlink-ing,
while elsewhere we use vpath. Do so for these two as well, thus also
eliminating the need for custom -iquote options and custom cleaning.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Of course for the emulator fuzzer we could go farther and use vpath also
for the references into the test harness dir as well as the core emulator
one.

--- a/tools/fuzz/libelf/Makefile
+++ b/tools/fuzz/libelf/Makefile
@@ -1,17 +1,15 @@
 XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+vpath %.c $(XEN_ROOT)/xen/common/libelf
+
 LIBELF_OBJS := libelf-tools.o libelf-loader.o libelf-dominfo.o
 
-CFLAGS += -iquote ../../../xen/common/libelf
 $(LIBELF_OBJS): CFLAGS += -Wno-pointer-sign
 $(LIBELF_OBJS): CFLAGS += -DFUZZ_NO_LIBXC $(CFLAGS_xeninclude)
 
 libelf-fuzzer.o: CFLAGS += $(CFLAGS_xeninclude)
 
-$(LIBELF_OBJS:.o=.c): libelf-%.c: ../../../xen/common/libelf/libelf-%.c FORCE
-	ln -nsf $< $@
-
 libelf.a: libelf-fuzzer.o $(LIBELF_OBJS)
 	$(AR) rc $@ $^
 
@@ -30,7 +28,7 @@ distclean: clean
 
 .PHONY: clean
 clean:
-	rm -f *.o .*.d *.a *-libelf-fuzzer $(LIBELF_OBJS:.o=.c)
+	rm -f *.o .*.d *.a *-libelf-fuzzer
 
 .PHONY: install
 install: all
--- a/tools/fuzz/x86_instruction_emulator/Makefile
+++ b/tools/fuzz/x86_instruction_emulator/Makefile
@@ -9,8 +9,7 @@ x86-insn-fuzz-all:
 endif
 
 # Add libx86 to the build
-%.c: $(XEN_ROOT)/xen/lib/x86/%.c FORCE
-	ln -nsf $< $@
+vpath %.c $(XEN_ROOT)/xen/lib/x86
 
 x86_emulate: FORCE
 	mkdir -p $@
@@ -25,7 +24,6 @@ x86_emulate/%.h: x86_emulate ;
 	ln -nsf $< $@
 
 CFLAGS += $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -iquote .
-cpuid.o: CFLAGS += -iquote $(XEN_ROOT)/xen/lib/x86
 
 GCOV_FLAGS := --coverage
 %-cov.o: %.c
@@ -72,7 +70,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 cpuid.c
+	rm -rf x86_emulate x86-emulate.c x86-emulate.h wrappers.c
 
 .PHONY: install
 install: all
Re: [PATCH] tools/fuzz: use vpath uniformly for access to hypervisor library code
Posted by Anthony PERARD 1 month, 2 weeks ago
On Tue, Dec 16, 2025 at 04:34:31PM +0100, Jan Beulich wrote:
> It's not quite clear why for libelf and the emulator we use symlink-ing,
> while elsewhere we use vpath. Do so for these two as well, thus also
> eliminating the need for custom -iquote options and custom cleaning.

It was an attempt to rework the "tools/" makefiles to be non-recursive,
via the use of subdirmk. `vpath` wouldn't have worked in that
configuration as stated in the commit introducing the symlink.
But I never managed to finish this conversion.

Cheers,

-- 
Anthony PERARD
Re: [PATCH] tools/fuzz: use vpath uniformly for access to hypervisor library code
Posted by Jan Beulich 1 month, 2 weeks ago
On 18.12.2025 14:41, Anthony PERARD wrote:
> On Tue, Dec 16, 2025 at 04:34:31PM +0100, Jan Beulich wrote:
>> It's not quite clear why for libelf and the emulator we use symlink-ing,
>> while elsewhere we use vpath. Do so for these two as well, thus also
>> eliminating the need for custom -iquote options and custom cleaning.
> 
> It was an attempt to rework the "tools/" makefiles to be non-recursive,
> via the use of subdirmk. `vpath` wouldn't have worked in that
> configuration as stated in the commit introducing the symlink.

Hmm, I see it says so, yet it says nothing as to why.

> But I never managed to finish this conversion.

Plus the symlinking also comes with downsides. They may get in the way of
moving build and/or source trees, for example. (Not that the tools/ subtree
would support out-of-tree builds yet, but still.)

Jan
Re: [PATCH] tools/fuzz: use vpath uniformly for access to hypervisor library code
Posted by Andrew Cooper 1 month, 3 weeks ago
On 16/12/2025 3:34 pm, Jan Beulich wrote:
> It's not quite clear why for libelf and the emulator we use symlink-ing,
> while elsewhere we use vpath. Do so for these two as well, thus also
> eliminating the need for custom -iquote options and custom cleaning.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

> ---
> Of course for the emulator fuzzer we could go farther and use vpath also
> for the references into the test harness dir as well as the core emulator
> one.

Doing everything consistently sounds like a good thing.