From: Leo Yan <leo.yan@arm.com>
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Ian Rogers" <irogers@google.com>,
"Namhyung Kim" <namhyung@kernel.org>,
"James Clark" <james.clark@linaro.org>,
"Kees Cook" <kees@kernel.org>, "Quentin Monnet" <qmo@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Daniel Lezcano" <daniel.lezcano@kernel.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"William Breathitt Gray" <wbg@kernel.org>,
"Barry Song" <baohua@kernel.org>,
"Qinxin Xia" <xiaqinxin@huawei.com>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"Kent Gibson" <warthog618@gmail.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Dexuan Cui" <decui@microsoft.com>,
"Long Li" <longli@microsoft.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Willy Tarreau" <w@1wt.eu>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Robert Moore" <robert.moore@intel.com>,
"Len Brown" <lenb@kernel.org>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"Tejun Heo" <tj@kernel.org>, "David Vernet" <void@manifault.com>,
"Andrea Righi" <arighi@nvidia.com>,
"Changwoo Min" <changwoo@igalia.com>,
"Mark Brown" <broonie@kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Gabriele Monaco" <gmonaco@redhat.com>,
"Shuah Khan" <shuah@kernel.org>, "Jiri Kosina" <jikos@kernel.org>,
"Benjamin Tissoires" <bentiss@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, bpf@vger.kernel.org,
linux-perf-users@vger.kernel.org, Leo Yan <leo.yan@arm.com>
Subject: [PATCH v5 03/26] tools: lib: thermal: Initialize CFLAGS before including Makefile.include
Date: Wed, 18 Mar 2026 09:16:47 +0000 [thread overview]
Message-ID: <20260318-tools_build_fix_zero_init-v5-3-bbeffd8da199@arm.com> (raw)
In-Reply-To: <20260318-tools_build_fix_zero_init-v5-0-bbeffd8da199@arm.com>
tools/scripts/Makefile.include may expand EXTRA_CFLAGS in a future
change. This could alter the initialization of CFLAGS in the thermal
Makefile, as the default options "-g -Wall" would never be set once
EXTRA_CFLAGS is expanded.
Prepare for this by moving the CFLAGS initialization before including
tools/scripts/Makefile.include, so it is not affected by the extended
EXTRA_CFLAGS.
Append EXTRA_CFLAGS to CFLAGS only after including Makefile.include and
place it last so that the extra flags propagate properly and can
override the default options.
Acked-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/lib/thermal/Makefile | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/lib/thermal/Makefile b/tools/lib/thermal/Makefile
index 09d8f4ba6a0ab7ab9c99ac7f64d52d0268bee340..b55fa42cefa47628b7f2fac32fc08fcd82580a0e 100644
--- a/tools/lib/thermal/Makefile
+++ b/tools/lib/thermal/Makefile
@@ -23,6 +23,14 @@ INSTALL = install
DESTDIR ?=
DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
+# Defer assigning EXTRA_CFLAGS to CFLAGS until after including
+# tools/scripts/Makefile.include, as it may add flags to EXTRA_CFLAGS.
+ifdef EXTRA_CFLAGS
+ CFLAGS :=
+else
+ CFLAGS := -g -Wall
+endif
+
include $(srctree)/tools/scripts/Makefile.include
include $(srctree)/tools/scripts/Makefile.arch
@@ -39,13 +47,6 @@ libdir = $(prefix)/$(libdir_relative)
libdir_SQ = $(subst ','\'',$(libdir))
libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
-# Set compile option CFLAGS
-ifdef EXTRA_CFLAGS
- CFLAGS := $(EXTRA_CFLAGS)
-else
- CFLAGS := -g -Wall
-endif
-
NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null)
ifeq ($(NL3_CFLAGS),)
NL3_CFLAGS = -I/usr/include/libnl3
@@ -68,6 +69,7 @@ override CFLAGS += $(INCLUDES)
override CFLAGS += -fvisibility=hidden
override CFLAGS += -Wl,-L.
override CFLAGS += -Wl,-lthermal
+override CFLAGS += $(EXTRA_CFLAGS)
all:
--
2.34.1
next prev parent reply other threads:[~2026-03-18 9:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 9:16 [PATCH v5 00/26] tools build: Append -fzero-init-padding-bits=all option Leo Yan
2026-03-18 9:16 ` [PATCH v5 01/26] tools: lib: thermal: Fix typo Leo Yan
2026-03-18 9:16 ` [PATCH v5 02/26] tools/thermal: " Leo Yan
2026-03-18 9:16 ` Leo Yan [this message]
2026-03-18 9:16 ` [PATCH v5 04/26] tools/thermal: Initialize CFLAGS before including Makefile.include Leo Yan
2026-03-18 9:16 ` [PATCH v5 05/26] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Leo Yan
2026-03-18 9:16 ` [PATCH v5 06/26] tools build: Append -fzero-init-padding-bits=all to extra cflags Leo Yan
2026-03-18 16:38 ` Ian Rogers
2026-03-23 14:23 ` Leo Yan
2026-03-18 9:16 ` [PATCH v5 07/26] bpftool: Append extra host flags Leo Yan
2026-03-18 9:16 ` [PATCH v5 08/26] perf build: " Leo Yan
2026-03-18 9:16 ` [PATCH v5 09/26] tools build: Append extra host cflags Leo Yan
2026-03-18 9:16 ` [PATCH v5 10/26] tools: bootconfig: Append extra cflags Leo Yan
2026-03-18 9:16 ` [PATCH v5 11/26] tools: counter: " Leo Yan
2026-03-18 9:16 ` [PATCH v5 12/26] tools: dma: " Leo Yan
2026-03-18 9:16 ` [PATCH v5 13/26] tools: gpio: " Leo Yan
2026-03-18 9:16 ` [PATCH v5 14/26] tools: hv: " Leo Yan
2026-03-18 9:16 ` [PATCH v5 15/26] tools: iio: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 16/26] tools: mm: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 17/26] tools: objtool: Append extra host cflags Leo Yan
2026-03-18 9:17 ` [PATCH v5 18/26] tools: power: acpi: Append extra cflags Leo Yan
2026-03-18 9:17 ` [PATCH v5 19/26] tools: power: x86/intel-speed-select: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 20/26] tools: sched_ext: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 21/26] tools: spi: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 22/26] tools: tracing: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 23/26] tools: usb: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 24/26] selftests/hid: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 25/26] selftests/nolibc: " Leo Yan
2026-03-18 9:17 ` [PATCH v5 26/26] selftests/sched_ext: " Leo Yan
2026-03-18 11:53 ` [PATCH v5 00/26] tools build: Append -fzero-init-padding-bits=all option Peter Zijlstra
2026-03-18 15:13 ` Leo Yan
2026-03-18 14:56 ` Quentin Monnet
2026-03-18 15:09 ` Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260318-tools_build_fix_zero_init-v5-3-bbeffd8da199@arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii@kernel.org \
--cc=andy@kernel.org \
--cc=arighi@nvidia.com \
--cc=ast@kernel.org \
--cc=baohua@kernel.org \
--cc=bentiss@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brgl@kernel.org \
--cc=broonie@kernel.org \
--cc=changwoo@igalia.com \
--cc=daniel.lezcano@kernel.org \
--cc=daniel@iogearbox.net \
--cc=decui@microsoft.com \
--cc=dlechner@baylibre.com \
--cc=eddyz87@gmail.com \
--cc=gmonaco@redhat.com \
--cc=haiyangz@microsoft.com \
--cc=haoluo@google.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kys@microsoft.com \
--cc=lenb@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=llvm@lists.linux.dev \
--cc=longli@microsoft.com \
--cc=lukasz.luba@arm.com \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nsc@kernel.org \
--cc=nuno.sa@analog.com \
--cc=peterz@infradead.org \
--cc=qmo@kernel.org \
--cc=rafael@kernel.org \
--cc=robert.moore@intel.com \
--cc=rostedt@goodmis.org \
--cc=rui.zhang@intel.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tj@kernel.org \
--cc=void@manifault.com \
--cc=w@1wt.eu \
--cc=warthog618@gmail.com \
--cc=wbg@kernel.org \
--cc=wei.liu@kernel.org \
--cc=xiaqinxin@huawei.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.