diff mbox series

[bpf-next,v2,03/10] selftests/bpf: Disable feature-llvm for vmtest

Message ID 20240904141951.1139090-4-pulehui@huaweicloud.com (mailing list archive)
State Superseded
Headers show
Series Local vmtest enhancement and RV64 enabled | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Pu Lehui Sept. 4, 2024, 2:19 p.m. UTC
From: Pu Lehui <pulehui@huawei.com>

After commit b991fc520700 ("selftests/bpf: utility function to get
program disassembly after jit"), Makefile will link libLLVM* related
libraries to the user binary execution file when detecting that
feature-llvm is enabled, which will cause the local vmtest to appear as
follows mistake:

  ./test_progs: error while loading shared libraries: libLLVM-17.so.1:
    cannot open shared object file: No such file or directory

Considering that the get_jited_program_text() function is a useful tool
for user debugging and will not be relied upon by the entire bpf
selftests, let's turn it off in local vmtest.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
---
 tools/testing/selftests/bpf/Makefile  | 2 ++
 tools/testing/selftests/bpf/vmtest.sh | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Eduard Zingerman Sept. 4, 2024, 7:37 p.m. UTC | #1
On Wed, 2024-09-04 at 14:19 +0000, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> After commit b991fc520700 ("selftests/bpf: utility function to get
> program disassembly after jit"), Makefile will link libLLVM* related
> libraries to the user binary execution file when detecting that
> feature-llvm is enabled, which will cause the local vmtest to appear as
> follows mistake:
> 
>   ./test_progs: error while loading shared libraries: libLLVM-17.so.1:
>     cannot open shared object file: No such file or directory
> 
> Considering that the get_jited_program_text() function is a useful tool
> for user debugging and will not be relied upon by the entire bpf
> selftests, let's turn it off in local vmtest.
> 
> Signed-off-by: Pu Lehui <pulehui@huawei.com>
> ---

I actually don't agree.
The __jited tag is supposed to be used by selftests
(granted, used by a single selftest for now).
Maybe add an option to forgo LLVM linkage when test_progs are compiled?
Regarding base image lacking libLLVM -- I need to fix this.
Eduard Zingerman Sept. 4, 2024, 11:08 p.m. UTC | #2
On Wed, 2024-09-04 at 12:37 -0700, Eduard Zingerman wrote:
> On Wed, 2024-09-04 at 14:19 +0000, Pu Lehui wrote:
> > From: Pu Lehui <pulehui@huawei.com>
> > 
> > After commit b991fc520700 ("selftests/bpf: utility function to get
> > program disassembly after jit"), Makefile will link libLLVM* related
> > libraries to the user binary execution file when detecting that
> > feature-llvm is enabled, which will cause the local vmtest to appear as
> > follows mistake:
> > 
> >   ./test_progs: error while loading shared libraries: libLLVM-17.so.1:
> >     cannot open shared object file: No such file or directory
> > 
> > Considering that the get_jited_program_text() function is a useful tool
> > for user debugging and will not be relied upon by the entire bpf
> > selftests, let's turn it off in local vmtest.
> > 
> > Signed-off-by: Pu Lehui <pulehui@huawei.com>
> > ---
> 
> I actually don't agree.
> The __jited tag is supposed to be used by selftests
> (granted, used by a single selftest for now).
> Maybe add an option to forgo LLVM linkage when test_progs are compiled?
> Regarding base image lacking libLLVM -- I need to fix this.
> 

Please consider using my commit [1] instead of this patch, it forces
static linking form LLVM libraries, thus avoiding issues with rootfs.
(This was suggested by Andrii off list).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ez/bpf-next.git/commit/?h=selftest-llvm-static-linking&id=263bacf2f20fbc17204fd912609e26bdf6ac5a13
Pu Lehui Sept. 5, 2024, 8:36 a.m. UTC | #3
On 2024/9/5 7:08, Eduard Zingerman wrote:
> On Wed, 2024-09-04 at 12:37 -0700, Eduard Zingerman wrote:
>> On Wed, 2024-09-04 at 14:19 +0000, Pu Lehui wrote:
>>> From: Pu Lehui <pulehui@huawei.com>
>>>
>>> After commit b991fc520700 ("selftests/bpf: utility function to get
>>> program disassembly after jit"), Makefile will link libLLVM* related
>>> libraries to the user binary execution file when detecting that
>>> feature-llvm is enabled, which will cause the local vmtest to appear as
>>> follows mistake:
>>>
>>>    ./test_progs: error while loading shared libraries: libLLVM-17.so.1:
>>>      cannot open shared object file: No such file or directory
>>>
>>> Considering that the get_jited_program_text() function is a useful tool
>>> for user debugging and will not be relied upon by the entire bpf
>>> selftests, let's turn it off in local vmtest.
>>>
>>> Signed-off-by: Pu Lehui <pulehui@huawei.com>
>>> ---
>>
>> I actually don't agree.
>> The __jited tag is supposed to be used by selftests
>> (granted, used by a single selftest for now).
>> Maybe add an option to forgo LLVM linkage when test_progs are compiled?
>> Regarding base image lacking libLLVM -- I need to fix this.
>>
> 
> Please consider using my commit [1] instead of this patch, it forces
> static linking form LLVM libraries, thus avoiding issues with rootfs.
> (This was suggested by Andrii off list).
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/ez/bpf-next.git/commit/?h=selftest-llvm-static-linking&id=263bacf2f20fbc17204fd912609e26bdf6ac5a13

Happy to see this modification only on llvm lib. I test it works good 
and have picked this in next version. Thanks
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9905e3739dd0..47aa4f113fed 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -197,6 +197,7 @@  OUTPUT := $(patsubst %/,%,$(OUTPUT))
 endif
 endif
 
+ifneq ($(FORCE_FEAT_LLVM_OFF),1)
 ifeq ($(feature-llvm),1)
   LLVM_CFLAGS  += -DHAVE_LLVM_SUPPORT
   LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets
@@ -209,6 +210,7 @@  ifeq ($(feature-llvm),1)
   endif
   LLVM_LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags)
 endif
+endif
 
 SCRATCH_DIR := $(OUTPUT)/tools
 BUILD_DIR := $(SCRATCH_DIR)/build
diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh
index 65d14f3bbe30..ae2e5a5ca279 100755
--- a/tools/testing/selftests/bpf/vmtest.sh
+++ b/tools/testing/selftests/bpf/vmtest.sh
@@ -162,7 +162,7 @@  update_selftests()
 	local selftests_dir="${kernel_checkout}/tools/testing/selftests/bpf"
 
 	cd "${selftests_dir}"
-	${make_command}
+	FORCE_FEAT_LLVM_OFF=1 ${make_command}
 
 	# Mount the image and copy the selftests to the image.
 	mount_image