Skip to contentSkip to conversation

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

PATCH In review Jan Beulich 3 participants 4 messages Dec 16, 2025 – Dec 18, 2025

lore
Share & tools
lore
#0 lore raw

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

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.

---
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.

tools/fuzz/libelf/Makefile +3 -5
@@ -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
tools/fuzz/x86_instruction_emulator/Makefile +2 -4
@@ -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
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

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.

Quoted 4 lines

---
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.

#2 lore raw
In reply to Jan Beulich
Quoted 3 lines · Jan Beulich

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,

Signature · 1 line
Anthony PERARD
#3 lore raw
Quoted 8 lines · Anthony PERARD
Quoted 3 lines · Jan Beulich

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.

Quoted 1 line

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