Re: kernel bpf test_progs - vm wrong libc version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 15, 2021 at 10:06 AM Jussi Maki <joamaki@xxxxxxxxx> wrote:
>
> On Tue, Jun 15, 2021 at 8:28 AM Andrii Nakryiko
> <andrii.nakryiko@xxxxxxxxx> wrote:
> > It seems kind of silly to update our perfectly working image just
> > because a new version of glibc was released. Is there any way for you
> > to down-grade glibc or build it in some compatibility mode, etc?
> > selftests don't really rely on any bleeding-edge features of glibc.
>
> I've also hit this issue as Ubuntu 21.04 ships with glibc 2.33. I
> ended up solving it the hard way by rebuilding the image (I needed few
> other tools at the time anyway). Definitely agree it's a bit silly if
> we'd need to bump the image every time there's a new glibc version out
> there. I did try and see if there's a way to build against newer
> glibc, but target older versions and I didn't find a way to do that.
> Would statically linking test-progs be an option to avoid this kind of
> breakage in the future?

I think static linking tests_progs is the only real way one can solve this.
Even if we keep updating the image, there will still be users that will hit
glibc version issues.

Andrii, Maybe we can have a mode for vmtest.sh can build test_progs
statically?

maybe something like:

git diff
diff --git a/tools/testing/selftests/bpf/Makefile
b/tools/testing/selftests/bpf/Makefile
index f405b20c1e6c..5ab0b7e6a95d 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -450,7 +450,7 @@ $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS)
                 \
                             $(RESOLVE_BTFIDS)                          \
                             | $(TRUNNER_BINARY)-extras
        $$(call msg,BINARY,,$$@)
-       $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) -o $$@
+       $(Q)$$(CC) $$(CFLAGS) $(TRUNNER_LDFLAGS) $$(filter %.a
%.o,$$^) $$(LDLIBS) -o $$@
        $(Q)$(RESOLVE_BTFIDS) --no-fail --btf $(TRUNNER_OUTPUT)/btf_data.o $$@

 endef
diff --git a/tools/testing/selftests/bpf/vmtest.sh
b/tools/testing/selftests/bpf/vmtest.sh
index 8889b3f55236..331072074014 100755
--- a/tools/testing/selftests/bpf/vmtest.sh
+++ b/tools/testing/selftests/bpf/vmtest.sh
@@ -138,7 +138,7 @@ update_selftests()
        local selftests_dir="${kernel_checkout}/tools/testing/selftests/bpf"

        cd "${selftests_dir}"
-       ${make_command}
+       TRUNNER_LDFLAGS=-static ${make_command}

        # Mount the image and copy the selftests to the image.
        mount_image

file test_progs
test_progs: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
statically linked,
BuildID[sha1]=b1915565b344c412f3eaa07eef4bfdd4a0fc672e, for GNU/Linux
3.2.0, with debug_info, not stripped

I tried with simply doing LDFLAGS=-static but that breaks other binaries:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/crtbeginT.o: relocation
R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when
making a shared object
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:167:
/home/kpsingh/projects/krsi/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.so.0.5.0]
Error 1
make[1]: *** [Makefile:135: all] Error 2
make: *** [Makefile:228:
/home/kpsingh/projects/krsi/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.a]
Error 2
make: *** Deleting file
'/home/kpsingh/projects/krsi/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.a'

Let me know if this works for you.




-



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux