From patchwork Fri Mar 4 15:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 12769279 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F23CFC433F5 for ; Fri, 4 Mar 2022 15:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbiCDPID (ORCPT ); Fri, 4 Mar 2022 10:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238059AbiCDPID (ORCPT ); Fri, 4 Mar 2022 10:08:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91D51BE137 for ; Fri, 4 Mar 2022 07:07:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 58A59B82A05 for ; Fri, 4 Mar 2022 15:07:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5937C340E9; Fri, 4 Mar 2022 15:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646406433; bh=x5ZRj+CGv8iKJ9GdTQLORgWIHUbzwClfF0XPRtvYz7k=; h=From:To:Cc:Subject:Date:From; b=RnyENdkRZAGp96jsvepj7N0vqF+ao15SHeZ20nRWOW8VN5NjqdrRLTjNUYMX86M1O ZKizuZhULztld7kRTUQOmvgh3jqYfNvP5IEgiV5TJGcIvsHOB5ebhq6f2GFGkSN/fc bSWS3IfcZxNj6RpAsHQbUvEXgfCNYHy9yOeEPuN2MykH4tu6vYArdEctAuaMHqm3Q/ RBSmJchWRW4qp5V+aRZWL+t28DCRf+sYL2pt75wL28DAEyQDrQZ75p59su8vz+Q6LP WFN6T0FDbl5bT040B6YYGKJ2FaO6qDENjWz1XGFkCAodFF92mheQ/UjkAFM2iRCvSO y8QuAkstIHunA== From: KP Singh To: bpf@vger.kernel.org Cc: "Geyslan G. Bem" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Subject: [PATCH v2 bpf-next] bpf/selftests: Allow vmtest.sh to build statically linked test_progs. Date: Fri, 4 Mar 2022 15:07:08 +0000 Message-Id: <20220304150708.729904-1-kpsingh@kernel.org> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Dynamic linking when compiling on the host can cause issues when the libc version does not match the one in the VM image. Allow the user to use static compilation when this issue arises: Before: ./vmtest.sh -- ./test_progs -t test_ima ./test_progs: /usr/lib/libc.so.6: version `GLIBC_2.33' not found (required by ./test_progs) After: TRUNNER_LDFLAGS=-static ./vmtest.sh -- ./test_progs -t test_ima test_ima:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Not using static as the default as some distros may not have dependent static libraries. Reported-by: "Geyslan G. Bem" Signed-off-by: KP Singh --- tools/testing/selftests/bpf/Makefile | 4 ++-- tools/testing/selftests/bpf/vmtest.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index fe12b4f5fe20..2473c9b0cb2e 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -162,7 +162,7 @@ $(MAKE_DIRS): $(OUTPUT)/%.o: %.c $(call msg,CC,,$@) - $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@ + $(Q)$(CC) $(CFLAGS) $(TRUNNER_LDFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@ $(OUTPUT)/%:%.c $(call msg,BINARY,,$@) @@ -468,7 +468,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) --btf $(TRUNNER_OUTPUT)/btf_data.o $$@ $(Q)ln -sf $(if $2,..,.)/tools/build/bpftool/bootstrap/bpftool $(if $2,$2/)bpftool diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh index e0bb04a97e10..9e4d8eefcd07 100755 --- a/tools/testing/selftests/bpf/vmtest.sh +++ b/tools/testing/selftests/bpf/vmtest.sh @@ -37,6 +37,7 @@ NUM_COMPILE_JOBS="$(nproc)" LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")" LOG_FILE="${LOG_FILE_BASE}.log" EXIT_STATUS_FILE="${LOG_FILE_BASE}.exit_status" +TRUNNER_LDFLAGS="${TRUNNER_LDFLAGS:=""}" usage() { @@ -155,7 +156,7 @@ update_selftests() local selftests_dir="${kernel_checkout}/tools/testing/selftests/bpf" cd "${selftests_dir}" - ${make_command} + ${make_command} TRUNNER_LDFLAGS="${TRUNNER_LDFLAGS}" # Mount the image and copy the selftests to the image. mount_image