Hi Andrii, On Wed, Jun 15, 2022 at 10:55 PM -07, Andrii Nakryiko wrote: [...] > This patch also changes selftests/bpf Makefile to force urand_read and > liburand_read.so to be built with Clang and LLVM's lld (and explicitly > request this ELF file size optimization through -znoseparate-code linker > parameter) to validate libbpf logic and ensure regressions don't happen > in the future. I've bundled these selftests changes together with libbpf > changes to keep the above description tied with both libbpf and > selftests changes. > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > --- [...] > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index 8ad7a733a505..e08e8e34e793 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -172,13 +172,15 @@ $(OUTPUT)/%:%.c > # do not fail. Static builds leave urandom_read relying on system-wide shared libraries. > $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c > $(call msg,LIB,,$@) > - $(Q)$(CC) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $^ $(LDLIBS) -fPIC -shared -o $@ > + $(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $^ $(LDLIBS) \ > + -fuse-ld=lld -Wl,-znoseparate-code -fPIC -shared -o $@ > > $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so > $(call msg,BINARY,,$@) > - $(Q)$(CC) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ > - liburandom_read.so $(LDLIBS) \ > - -Wl,-rpath=. -Wl,--build-id=sha1 -o $@ > + $(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ > + liburandom_read.so $(LDLIBS) \ > + -fuse-ld=lld -Wl,-znoseparate-code \ > + -Wl,-rpath=. -Wl,--build-id=sha1 -o $@ [...] Not sure if this was considered - adding a dependency on Clang for the target platform makes cross-compiling bpf selftests much harder than it was. Maybe we could use $(CLANG) only when not cross-compiling, and execute $(CC) like before otherwise?