From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9404340FDBE for ; Thu, 30 Apr 2026 12:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777553636; cv=none; b=tbC/TLjKT4/qyoWaFB64tq6w6AN8/GNHlSUuP+PGi0oxYG4wOW6EUHp4ou/BYC3mG8Ac+UbWgOmSwHHFZv21jB9Br8g+AAO6Jh+ST80xb7n+gJG5E8wbs7HdAzj2W0QJm7E72N3Nu6Ss7mhzbxiuGrZtcDUPQY6a1Om3AOepQgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777553636; c=relaxed/simple; bh=I2jxLztduWlfcb809/jc6vkR7pIiCKbFQIGItdln2/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N1wYuompRmMgzlGh6d/3bCFnmO/6zLAT0M+TvLJPiP6A29zxIaLk0xCvzdWdNPHqFHo4R4csPrXfH0oIShR9pAHO2TLDe0uIu4U7Tv0qaZMBpquoHCylI8uRbU7WkgRUAyzNdqA48bQOHvuQeO9PEZWFgmwpT5gZU1OUfnj+G1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=U/6MQlw6; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="U/6MQlw6" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-488a9033b2cso8384545e9.2 for ; Thu, 30 Apr 2026 05:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1777553630; x=1778158430; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q+XbIgjuLQuX1ZjiX/bxTtSVSE3u4tQE56sxmhIL67k=; b=U/6MQlw6i3VPQIReT8bkpkgWOQiaApuJQQ30NrlDSP6FP/zKOCx3G5MKHavp99xZ78 d/UnMFG0yq5QDHd9HUIuv+xzPXVMRFkCpdw91vAqlAjf0jlEMlbUAse7qB/dxv51FJNF sa8D20APeAJxVZcrAeaI8oyjNsDDAtZs/hiYhk4LWiLpMGMEb1EiqwZmMYGoUWgYemmR v7bnbytM3LAEQ9uhSju1npLzVqPYjyg+MswOx7TZtZnAa6iX3L9+Q4+eWvS1JDM7eKfa mVebM9xF12XpyZhKEBY39Ba0zusHQTtdGS7ZMCDDe1t5y5bfX76etASiT3ij2MZGSyl8 HqFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777553630; x=1778158430; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q+XbIgjuLQuX1ZjiX/bxTtSVSE3u4tQE56sxmhIL67k=; b=Ly/2GwGAEwwjGkt14+79idCRG49dtH4jzIKbW4nmqZRUqbpKUlpN5Pp6iKF9Afvl/r fZCTAswxKq/c1Pr42BETbhnfUXkqnOTss9eGdgjDL2Jwz0qR2r0JIlkZ9yID6wTQyIrt 1V4mfu8tn2PovSpOJhit6TgfKxqLXFbt/c3CqLd+fEevHrnrg8TOwgu3WvNIFXoXc9cx pgobiofPKq0tmXpAmwxjG7VP7kGCvkEnLueEWU5lRDEt0dgq8XXb8lDkGZiwAJCGemAh gHN+sTjH+1QnaXsgokme91QuuC5R0+PuGvOSNdh4VM0lKsuV8qvlK9dLcDCKRMss2oJR btbQ== X-Forwarded-Encrypted: i=1; AFNElJ/BqUbtcyIG11xFtkS31YE67Bul52flFfuKKiHA0GMjgRsQte0MKCvCj8gXD2unj4gsgboyjKQs3jSh7MM=@vger.kernel.org X-Gm-Message-State: AOJu0YzNOP3ShdgEJ1JZXjSGl4zg3Ev7hg1LM4L5tlhl7edjF7ZEK9ll NGmHPetJjmbcJU6F7qDRk1qQZaG4svWO3oXULkMSJNiI7aUjxiqPt7vd+q9RNwMI0fNKNed1yj/ SmSOx+8k= X-Gm-Gg: AeBDiesY/8wpphOhYtt/FNjYaMLcdpzgRZRPMrCiHeUFtYU70swuAEh8Rocv2bFbb8p 3uHpwN2aeDj6mO3qSRaiWUJr2mi3/AZrLg6a5cU6JwE8q+QXHDrCip/SA5RF0YRGMoKIEGE4LJr dIPl3I1/ZCbCheeFHJkscm1kg8z9IeujeQuyu13s8han4hvp3kOm6xqxP3F3U+Xq3EVgHRcAzBD fCtvBaVDfRDws7Lm/D+lB4nUXyJLzEylrE5Ww2kXkg+Ib8tOkqgfilD/01HbIeR+Bd+D1IP8UmV 3srHw54KoYw3H4IZw61BZK4RkziS7t3KzDRGqSBdjet6D7WFXSHb3JWQjMBnK3eZuSFoIrxKTaO 8yoR6PwPHLeUi8KJ9ijz7QNt6DU3upzJ3sKXfB0qzZKw6a7tcNCMr1A0uhKLQjtbVm/HjPHlSET ZDfDvIf9KLidEPJjq6hjtKgUZR X-Received: by 2002:a05:600c:4688:b0:48a:5342:36b5 with SMTP id 5b1f17b1804b1-48a8444d7a9mr50732385e9.21.1777553629800; Thu, 30 Apr 2026 05:53:49 -0700 (PDT) Received: from localhost ([2804:7f0:b765:105d:ce28:aaff:fe86:149c]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ed1c07058esm8543218eec.15.2026.04.30.05.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 05:53:48 -0700 (PDT) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Thu, 30 Apr 2026 09:53:20 -0300 Subject: [PATCH bpf-next v10 08/11] selftests/bpf: Allow test_progs to link with a partial object set Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260430-selftests-bpf_misconfig-v10-8-cd302a31af16@suse.com> References: <20260430-selftests-bpf_misconfig-v10-0-cd302a31af16@suse.com> In-Reply-To: <20260430-selftests-bpf_misconfig-v10-0-cd302a31af16@suse.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Alan Maguire , "Ricardo B. Marliere" X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1777553600; l=3578; i=rbm@suse.com; h=from:subject:message-id; bh=I2jxLztduWlfcb809/jc6vkR7pIiCKbFQIGItdln2/s=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QKqqdQsm33ueetLi82n66giduvjncuOEMLEwyV2vO+e5ZLsOaGwzTZasZ7Pb+J1KfYDzndi4FiJ 5jpUI9g0qewY= X-Developer-Key: i=rbm@suse.com; a=openssh; fpr=SHA256:pzhe0fJpYLz+3cZ33FFPhIfaUElk9CXPFFXmalIH+1g When individual test files are skipped due to compilation failures, their .test.o files are absent. The linker step currently lists all expected .test.o files as explicit prerequisites, so make considers any missing one an error. In permissive mode, declare the test objects that already exist on disk (via parse-time $(wildcard ...)) as normal prerequisites of the binary so that modifications to a test source still trigger a relink, and keep the full TRUNNER_TEST_OBJS list as order-only prerequisites so that initial fresh builds still produce them and missing objects do not abort the link. The recipe filter is split per mode: in permissive mode it combines a recipe-time $(wildcard ...) (which catches objects freshly produced via the order-only path on a fresh build) with $(filter-out $(TRUNNER_TEST_OBJS),$^) (which keeps the non-test inputs from $^ but drops the parse-time wildcard duplicates). This avoids passing the same .test.o twice to the linker while still presenting test objects before libbpf.a so that GNU ld, which scans static archives left-to-right, pulls in archive members referenced exclusively by test objects (e.g. ring_buffer__new from ringbuf.c). In default (strict) mode the recipe remains the simple $(filter %.a %.o,$^) since TRUNNER_TEST_OBJS is part of $^ exactly once. Gate the partial-link behavior on $(if $(filter test_progs%,$1),...) so it only applies to test_progs and its flavors. test_maps and similar runners using strong cross-object references would link-fail with a partial set and intentionally retain strict link semantics. Note: adding a brand-new test_*.c file in permissive mode requires removing the binary (or a clean rebuild) before the new test is linked in, because the parse-time $(wildcard ...) is evaluated when the Makefile is read and will not yet see the new .test.o. This is acceptable since permissive mode targets tolerant CI builds rather than incremental development. Signed-off-by: Ricardo B. Marlière --- tools/testing/selftests/bpf/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 9becc077eb23..a64e822dc540 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -773,14 +773,15 @@ endif # some X.test.o files have runtime dependencies on Y.bpf.o files $(OUTPUT)/$(TRUNNER_BINARY): | $(TRUNNER_BPF_OBJS) -$(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \ +$(OUTPUT)/$(TRUNNER_BINARY): $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),$$(wildcard $(TRUNNER_TEST_OBJS)),$(TRUNNER_TEST_OBJS)),$(TRUNNER_TEST_OBJS)) \ $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \ $(TRUNNER_LIB_OBJS) \ $(TRUNNER_BPFTOOL) \ $(OUTPUT)/veristat \ - | $(TRUNNER_BINARY)-extras + | $(TRUNNER_BINARY)-extras \ + $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),$(TRUNNER_TEST_OBJS))) $$(call msg,BINARY,,$$@) - $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@ + $(Q)$$(CC) $$(CFLAGS) $(if $(filter test_progs%,$1),$(if $(PERMISSIVE),$$(filter %.a %.o,$$(wildcard $(TRUNNER_TEST_OBJS)) $$(filter-out $(TRUNNER_TEST_OBJS),$$^)),$$(filter %.a %.o,$$^)),$$(filter %.a %.o,$$^)) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@ $(Q)ln -sf $(if $2,..,.)/tools/build/bpftool/$(USE_BOOTSTRAP)bpftool \ $(OUTPUT)/$(if $2,$2/)bpftool -- 2.54.0