From nobody Sun Feb 8 22:05:30 2026 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (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 26C852D2496 for ; Tue, 23 Dec 2025 08:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766479444; cv=none; b=h2t2pwSgfDSjX6bEPDTRWoa2LhKYRBcepWUfJdiCxHWdLc2SbE02VxS8KKNiDDox6dnSq8nCqbWvN0Zgxwld+E3rVuGrdWJpSLOf3l/cUUjT/uQteKezxL/O8dQtjONUpcv03AMwXbnAzxnVBnQwFsPdW8U9GCraikB/+PiUVdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766479444; c=relaxed/simple; bh=JNcxDi8XtzEu3xbpObOr3vCN2IHmRD7IAR2ObU+ycjA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9bu7uMENdSm83mDtqjk7bTbJmQSguxrvfLPITB4ufQa4xm70MZ3iAUjfrcJ1/RjiHQQoAI66ZvA2b3+g7BhuoAhr5vXZ/vyQslMVjWqq0p0aqAPbJpV7vZsoq2i6LhEBrBQ3fL/xKJMDYkp/3us7hkdnOQfLR4VdmE+5bxJl48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kX3YAH7I; arc=none smtp.client-ip=209.85.215.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kX3YAH7I" Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-c03ec27c42eso2729559a12.1 for ; Tue, 23 Dec 2025 00:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766479442; x=1767084242; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oNT47R5lyHr6s83aFhP7qeMV+Nwtti6xzxLjC7+hnjk=; b=kX3YAH7ITnk4k8ju8X+TWFVqTsEzrnfcrALl1eA145Rurcfg330eqNSTrxN+EzsUof 3EF6kKH5Jn4xDLfzrEY76wheOaVgR7lfq/IsKaD0rCqDdOvoXMjE1182ypqf5j4YFzvL okPnncOmCJzlUUw3rHHSnhtP/kb1M6nzDoAKvYJESCrLARfjE/St0/yPSezUfytcA6HV F2+yByzdh/83fAObVUBWzE5dITDnbMF4Cv8tCak9LKQAgKTq4Yekkt8+Nx94YWEKNhdo pFVTNbcETqLAXMSX51vt2qMQBnuFYgtZMS1RYXyK9xwNgaik2Qqc8M1BwFcivtfj2zGB zM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766479442; x=1767084242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=oNT47R5lyHr6s83aFhP7qeMV+Nwtti6xzxLjC7+hnjk=; b=LXB/ny2S/5nTEPgFA+rSnIO0H5ZNfuchuInVh7usa3wa0bfQ3jbbcUu+tAL6642NL+ S62wy+AVr0qMoQKoi82IF16Spkkn/M//5T4MxEp5FRH9uGGbP7R57XvP1s0EzEXIbgmQ vnjq8KX+SPFCxFfHihJu0yKUlhABpT/S1LSFd9zahOJgtpGEEJ7GdajBRcg4rAck7Si7 lT7vozXdJLx9vblxVEaCdedqblLenAPn0nxfxR19/oLJ2ROTwJ5SQJCfHnVhppXxM4yy DnZVW4X8DdnO/laOepLG98f6WjNq8fWqqqAcKc4s2j9O5BND8L3xsxYhDGTo/DwMgnbl 0rvQ== X-Forwarded-Encrypted: i=1; AJvYcCU0oPJpCxpKu4gLPR2FAb6wmh5rbtS6x7eIlfWFWs7kydDInu36vk7oR8zclFYPlQPGJ2s+zhLHTRu1W4Q=@vger.kernel.org X-Gm-Message-State: AOJu0YybRc3pPDTE/zs0wmsGWRdVpEhU0FfASixSiLj5L+qHjF26pF8r JV8VAwjXMwsBHJMbKv9X0ln6+p5W+M6aUi65Ae2NQyE6xnSu+Nw6EN7F X-Gm-Gg: AY/fxX7rlxhYW8WA8JC1knZMWBo6Rp/ZIpu1vRhGKEJ7QMiB8aX5xx1MXJIP8ARCB6R DAhA4K+4IJLAv/RoHpy7/JHIfeLzy1fyOLzV1548kUP9IXLJKTbwzBQrBVBKKr2GsJScJNIZZ0l HF4nJ0WYfNSrgRugZ1akQZ9Yp8pLB6uWTuPl2LYseRjkShBskRpJ62vmIyeknHQCTe3sVuCM5Uh zSuILVhDH9jjyP0Dfg5+OYfhasmrI0pt2Gm88EdcfyRat62kfiVF4i6jpQXzWGdgMoiEgJIbE/R GREBmxdEh21r/4g6dNy/XObeSbsaITv8aQxtSzQv+ozDNJjJvCCG9WEJIS0K8goky/hl1VzSp23 t2MPMg2p73EefWxUdtOpgxj3/a+PEEa/+BqBmgx04WLHYxIRgE0wOKwDJfgIJSvm00OD09Wc0cK QUxYAWUtz2vOvtukFgAx8QtgZrOA== X-Google-Smtp-Source: AGHT+IHYU+Os1x0yRwca4Pe17iWLQntYr4tzo/e2hIsHQnCg2+Cy7uhXYlQBCpFNDm7a2HU6WuZDfQ== X-Received: by 2002:a05:7300:50e2:b0:2ae:5b2e:9d45 with SMTP id 5a478bee46e88-2b05ecb39c4mr10097700eec.38.1766479442294; Tue, 23 Dec 2025 00:44:02 -0800 (PST) Received: from HUC.. ([149.34.251.245]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm56720887c88.13.2025.12.23.00.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 00:44:01 -0800 (PST) From: hupu To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, james.clark@linaro.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, hupu.gm@gmail.com Subject: [RFC 1/2] perf build: Allow passing extra Clang flags via EXTRA_BPF_FLAGS Date: Tue, 23 Dec 2025 16:43:34 +0800 Message-ID: <20251223084337.3789-2-hupu.gm@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223084337.3789-1-hupu.gm@gmail.com> References: <20251223084337.3789-1-hupu.gm@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for EXTRA_BPF_FLAGS in the eBPF skeleton build, allowing users to pass additional Clang options such as --sysroot or custom include paths when cross-compiling perf. This is primarily intended for cross-build scenarios where the default host include paths do not match the target kernel version. Example usage: make perf ARCH=3D"arm64" EXTRA_BPF_FLAGS=3D"--sysroot=3D..." Change history: v5: - Update commit message v4: - Apply EXTRA_BPF_FLAGS directly to BPF skeleton build command instead of modifying CLANG_OPTIONS v3: - Move the variable description comment to the top of Makefile.perf - Update commit message v2: - Rename EXTRA_CLANG_FLAGS to EXTRA_BPF_FLAGS - Update commit message v1: - Introduce EXTRA_CLANG_FLAGS to allow passing extra Clang options Signed-off-by: hupu Reviewed-by: Namhyung Kim --- tools/perf/Makefile.perf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index b3f481a626af..8b8647fd4f41 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -35,6 +35,9 @@ include ../scripts/utilities.mak # # Define EXTRA_CFLAGS=3D-m64 or EXTRA_CFLAGS=3D-m32 as appropriate for cro= ss-builds. # +# Define EXTRA_BPF_FLAGS=3D"--sysroot=3D" or other custom include pa= ths for +# cross-compiling BPF skeletons +# # Define EXCLUDE_EXTLIBS=3D-lmylib to exclude libmylib from the auto-gener= ated # EXTLIBS. # @@ -1250,7 +1253,7 @@ endif $(SKEL_TMP_OUT)/%.bpf.o: $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_ver= sion.h | $(SKEL_TMP_OUT) $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlin= ux.h $(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=3Dbpf \ - $(CLANG_OPTIONS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \ + $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE= ) \ -include $(OUTPUT)PERF-VERSION-FILE -include util/bpf_skel/perf_version= .h \ -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ =20 --=20 2.43.0 From nobody Sun Feb 8 22:05:30 2026 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 9D54D320A04 for ; Tue, 23 Dec 2025 08:44:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766479450; cv=none; b=AodbG7DpgyQn3e+CFXVkmeC7LTJ8XicA8Mstgg40NyvRjLun6s9A/OVaY4TL8e+73YOVJBjEZO0wCw0T9gACSn6P1PXcobYOU7R/St8SQZT1pLj91joFSDJzbsrcKe56p1hpujTxCxjWJjfMga4IcYTUvGBYesAJ0NYqfSE12co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766479450; c=relaxed/simple; bh=m43rCnWF6W4flnZfWPAFH2zPZg0lP1fMO8rg5+/cqio=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FCX0c5hEEeN30XzY9j3pMs+f7MJZT4CE6LU9KZw1khizl1LapGwfNLx7osIwvXSliSIoOam99Aagj4y7VlvEw5rdubRnocvr4/4f47VwiLEs1nFf1X7epM9KVq1ke8FLvSSIPJLl1bxRuOirSWcqTC63CCvgfpYPSbrccPKWgvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i+jbnGCY; arc=none smtp.client-ip=209.85.216.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i+jbnGCY" Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-34ca40c1213so3986235a91.0 for ; Tue, 23 Dec 2025 00:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766479448; x=1767084248; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sYARJPf4DCJHMSVJhsQ64ZrdejW7DqNqW01daFc7LNc=; b=i+jbnGCY+Tjw5cMI9Wya7LlBzHZpJpTT0InGTrCdtlkgr1/HMKdNnTXyvt+nzSgpZh wCWTVR2GxwUnZntnH5uFrsp80V/RFDHLxhxgUuTmQ3Dv9wzyQzi8/Ij/XGERrr0FM2hV AldNj1O7vw76ruMbdDHMxMtBTmXtQV6eWSVBACD6s3XJez5wxZFyy2exnh3rq+rckZDb mIPof01F+UE6pc5c52mJteg90cxNKgBtTnGCxjiDazy+Q+Fc5ykkxa7qTezEA9cHQPf1 fOccBGZvnW29c2+sFzYEB8pEvlDfmE/sUj9o5wbWo51Hy2myUPMlVfpPEl0GW6uNLvxg DWeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766479448; x=1767084248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sYARJPf4DCJHMSVJhsQ64ZrdejW7DqNqW01daFc7LNc=; b=UtOABHov+Q4FgNXj4PbK0uf3mp5JneSTRmBiKHo91Yz1AYrtEiQcLp+lOtJlRgd0v+ v8WTZzpnJ21rDtHytZaLOOK3rarJR7cty9RvTeV1HtvQRaMqbz9PqG+w6BMRKjtki916 g0DbAUQubQN5gKqhh34yt3oWRxF5kFj7j3tpkFIYQIjAgXP41DpBcLcghzPAz+ytfR8q mK5mkmzBdKQnw1LY8jhz8wQ30EdkSJ+6j0hz+h3Y6fgc59QKzEo6gvsKLruOPwIZ+VzO 0cxyT8KM4BrxrBhfaN3COQLKc+s9O7Tj2JAUa8LYFGUWWV+0Pif3VKhG90q7lZw1RdjJ gt5g== X-Forwarded-Encrypted: i=1; AJvYcCWiI7LYX94DlLtZ606nsK/uYTOh+tj5HkpSeVNkBMNrxzJsMGTUo7DTej6RRqNPVCoeGUVBgjp/H1hMm1Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxD1b6N+36koYtAxOjybxJnsEfkSRQxvTwgF7FtEsNfiqY5gZFx drBsR0HP8Zfqwo3n8NxjcbBIwlfsitLWGt5lT+jJe1mL/rsMkWCUnnbl X-Gm-Gg: AY/fxX6TXEhQoa+CaEJABavU+EZiLUcVALZgspTmT6p4kCZU6KHLqLgqIKIYRSCW0kn YqTvTCSnIDpW10V28x0beu+kHNuLLfYVK+5IiJzV6WJ8jUK9chKFiLl3V0IuH77FFYZAIIoChz2 dRTR2GFQNRx20H0pI36l319+98lLirWuZuevNnBqoyuz5IYZkdCk7kVytAb8FDaJ80SDwhyVwjj ck5DAplfX83Ryx1OkkCfoEcB+c5Ckxk3ign8hXMyIYhXR+2CWqUZaUuHoaGZOCgx233jCaJb6Jr r+BFWArEWsl3fyuNoE1mnVhFi2KJYWWRjpoj/ieByqmd7ba2puWYJbk9ZTkuqm45YmLotMotf9/ 6DE9uZuugOpymlWCo56EKv27IG+WZjYpc2WvrxdN2xVijSt50KK8HocwSaRTAhNmWJ/hoUPV1Xc sRi+0xAfFNovEScdLsfnpio9HVL1CO8Tw0DNbD X-Google-Smtp-Source: AGHT+IEPBzpa+JSlltoi2sicjexlhwpONg+WQbBsfL7i+rkHPN4HgKra3RHsx7N07jEuGnZtt+CPGw== X-Received: by 2002:a05:701b:250f:b0:11b:9386:a3cb with SMTP id a92af1059eb24-12172310ff9mr8272832c88.44.1766479447624; Tue, 23 Dec 2025 00:44:07 -0800 (PST) Received: from HUC.. ([149.34.251.245]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm56720887c88.13.2025.12.23.00.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 00:44:07 -0800 (PST) From: hupu To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, james.clark@linaro.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, hupu.gm@gmail.com Subject: [RFC 2/2] perf build: Prefer kernel source headers for BPF skeletons Date: Tue, 23 Dec 2025 16:43:35 +0800 Message-ID: <20251223084337.3789-3-hupu.gm@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223084337.3789-1-hupu.gm@gmail.com> References: <20251223084337.3789-1-hupu.gm@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When building eBPF skeletons with Clang, prefer header files provided by the kernel source tree over headers installed on the host system. While host-installed UAPI headers can be sufficient today, they are tightly coupled to the host environment and may diverge from the target kernel version over time as the kernel evolves. Relying on kernel source headers helps ensure that the headers used during the build remain consistent with the target kernel version and reduces dependence on the host build environment. This change adds the kernel source UAPI and generated header paths to the BPF include list and places them before the system include paths, while still keeping host headers (CLANG_SYS_INCLUDES) as a fallback. Signed-off-by: hupu --- tools/perf/Makefile.perf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 8b8647fd4f41..57c73ab98703 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -1203,7 +1203,13 @@ endif =20 CLANG_OPTIONS =3D -Wall CLANG_SYS_INCLUDES =3D $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARC= H)) -BPF_INCLUDE :=3D -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCL= UDES) + +KHDR_INCLUDES :=3D -I$(abspath $(OUTPUT)../../usr/include) \ +-I$(abspath $(OUTPUT)../../arch/$(SRCARCH)/include/generated/uapi) \ +-I$(abspath $(OUTPUT)../../arch/$(SRCARCH)/include/uapi) + +BPF_INCLUDE :=3D -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) \ + $(KHDR_INCLUDES) $(CLANG_SYS_INCLUDES) TOOLS_UAPI_INCLUDE :=3D -I$(srctree)/tools/include/uapi =20 ifneq ($(WERROR),0) --=20 2.43.0