From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D8FC3B8931; Fri, 13 Mar 2026 16:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773418060; cv=none; b=dhMdBSaSK8qv2kelqi3+hyHKSFb0Riu6xpx+Omh0HMQJ6a7Rp5WSbdKY2Re/lM48HUSRKU6Lnb51/kcLDnPOrCiOAQF/vxslaIt/GWsHqz/pbjHIqS2rWbP3J81Avc7RxAkfnW+NfLk6dUuKvl7oHNkaQuyciQ8iHDJ+rsrB+ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773418060; c=relaxed/simple; bh=feZUlarptZPrYxvImHDUNpleH6LT/h6P2Am574Gwy78=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VknwBD7bmp9VhXfK80iI87nEXnzUWURI3htOZiLmQYapnZPKDZdFFv4n2fqYVtYnm/YnjEEO/jaQE4TS6alRr0QVKsJK8/w3R6UAESwyDsL9AdpUSKiPPJyZ64AGGauscqjvLNTEG/c8NVt8d0uuiE9eSozr30mLj1L57EzMvXU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YxPtlYeA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YxPtlYeA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 595E0C19425; Fri, 13 Mar 2026 16:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773418059; bh=feZUlarptZPrYxvImHDUNpleH6LT/h6P2Am574Gwy78=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=YxPtlYeAu4fkddIcE0Pe4G3DZNznWFpSd9tZclLayJmwjl0c12ZPiMAogDbEMdecK S1YmNtxYURFH1Ow1Zr3Owhh15Im1ym4zlSGStsOSimLf9fmJNk03K3OC47iiPI0Tdh 1guM8JWZ7+aOJmQjdbUOWrsz5pkJCTrNbha/1mm1254hUEu3L8Dd0c+IkA4HdpfFTZ Kzv4mrSEyKzrT0njYf7vV9YxvpCE1LqLd63B8dSHQHWzmcnAgQvMCTvX0jUDYpIbUm IxDr00empqPAp4cjE7XVwVhbxCxCo8gvyqW93Nx4Hjb5cj/jkoICP7wCk4Um8skQV3 UczgN7U2Nphow== Message-ID: Date: Fri, 13 Mar 2026 16:07:27 +0000 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 05/30] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS To: Leo Yan , Ian Rogers Cc: Arnaldo Carvalho de Melo , Namhyung Kim , James Clark , Kees Cook , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Adrian Hunter , Masami Hiramatsu , William Breathitt Gray , Barry Song , Qinxin Xia , Bartosz Golaszewski , Kent Gibson , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Jonathan Cameron , David Lechner , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Andrew Morton , Willy Tarreau , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , Josh Poimboeuf , Robert Moore , Len Brown , Srinivas Pandruvada , Tejun Heo , David Vernet , Andrea Righi , Changwoo Min , Mark Brown , Steven Rostedt , Gabriele Monaco , Shuah Khan , Jiri Kosina , Benjamin Tissoires , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20260311-tools_build_fix_zero_init-v4-0-9e35bdb99cb3@arm.com> <20260311-tools_build_fix_zero_init-v4-5-9e35bdb99cb3@arm.com> <20260313155600.GP4153946@e132581.arm.com> From: Quentin Monnet Content-Language: en-GB In-Reply-To: <20260313155600.GP4153946@e132581.arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2026-03-13 15:56 UTC+0000 ~ Leo Yan > On Thu, Mar 12, 2026 at 10:19:01AM -0700, Ian Rogers wrote: >> On Wed, Mar 11, 2026 at 1:30 AM Leo Yan wrote: >>> >>> Prepare for future changes where EXTRA_CFLAGS may include flags not >>> applicable to the host compiler. >>> >>> Move the HOST_CFLAGS assignment before appending EXTRA_CFLAGS to >>> CFLAGS so that HOST_CFLAGS does not inherit flags from EXTRA_CFLAGS. >>> >>> Acked-by: Quentin Monnet >>> Signed-off-by: Leo Yan >>> --- >>> tools/bpf/bpftool/Makefile | 8 ++++++-- >>> 1 file changed, 6 insertions(+), 2 deletions(-) >>> >>> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile >>> index 519ea5cb8ab1c0ee31acc67fc5f96b40e21005c2..3e7d8359e1b2a81a29a47544be8539e3b191a0e8 100644 >>> --- a/tools/bpf/bpftool/Makefile >>> +++ b/tools/bpf/bpftool/Makefile >>> @@ -81,6 +81,12 @@ CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ >>> ifneq ($(BPFTOOL_VERSION),) >>> CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' >>> endif >>> + >>> +# This must be done before appending EXTRA_CFLAGS to CFLAGS to avoid >>> +# including flags that are not applicable to the host compiler. >>> +HOST_CFLAGS := $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\ >>> + $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) >>> + >>> ifneq ($(EXTRA_CFLAGS),) >>> CFLAGS += $(EXTRA_CFLAGS) >>> endif >>> @@ -88,8 +94,6 @@ ifneq ($(EXTRA_LDFLAGS),) >>> LDFLAGS += $(EXTRA_LDFLAGS) >>> endif >>> >>> -HOST_CFLAGS := $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\ >>> - $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) >>> HOST_LDFLAGS := $(LDFLAGS) >> >> Should HOST_LDFLAGS be similarly moved? Otherwise, it seems target >> flags in EXTRA_LDFLAGS will be added for the host. > > Though this series is irrelevant to LDFLAGS, I am fine to move > HOST_LDFLAGS together. If we move the HOST_LDFLAGS earlier so that they no longer receive the EXTRA_LDFLAGS, then we lose the possibility to use any EXTRA variable to pass additional flags to HOST_LDFLAGS. So OK to move, but maybe add a "HOST_LDFLAGS += $(HOST_EXTRALDFLAGS)" to it for consistency with the processing of HOST_CFLAGS? Quentin