From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Thomas Richter <tmricht@linux.ibm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: [PATCH 5/9] perf build: Only pass clang flags to CXX when CXX is clang
Date: Tue, 15 Sep 2026 23:12:14 -0700 [thread overview]
Message-ID: <20260916061218.3061216-6-irogers@google.com> (raw)
In-Reply-To: <20260916061218.3061216-1-irogers@google.com>
Building with "make CC=clang" appends clang's --target= and
-fintegrated-as to CXX, but CXX is only set to clang++ by "make LLVM=1".
With just CC=clang, CXX is still g++ and every C++ feature test dies:
g++: error: unrecognized command-line option '--target=...'
g++: error: unrecognized command-line option '-fintegrated-as'
The failures are silent, as feature tests are allowed to fail, so the
build quietly loses libllvm and C++ demangling support:
$ make CC=clang && grep LIBLLVM .config-detected
(nothing, whereas a gcc build reports CONFIG_LIBLLVM=y)
The block is entered when CC_NO_CLANG says CC is clang, which says
nothing about CXX. Probe CXX the same way tools/scripts/Makefile.include
probes CC, and only add the flags when CXX really is clang++.
Mixing a clang-built C with a g++-built C++ is fine here, the C++ code
is linked with -lstdc++ already.
Fixes: 4772e66cb45e ("perf build: Support build with clang")
Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
tools/perf/Makefile.config | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 4ee7393a39f9..31e4cbe192b9 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -54,7 +54,14 @@ ifeq ($(CC_NO_CLANG), 0)
endif # CROSS_COMPILE
CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
- CXX := $(CXX) $(CLANG_FLAGS) -fintegrated-as
+
+ # CC being clang says nothing about CXX: "make LLVM=1" overrides both, but
+ # "make CC=clang" leaves CXX as g++. Probe CXX the way Makefile.include
+ # probes CC rather than assuming the two match.
+ CXX_NO_CLANG := $(shell if command -v $(firstword $(CXX)) >/dev/null 2>&1; then $(CXX) -dM -E -x c++ /dev/null; fi | grep -Fq "__clang__"; echo $$?)
+ ifeq ($(CXX_NO_CLANG), 0)
+ CXX := $(CXX) $(CLANG_FLAGS) -fintegrated-as
+ endif
# Enabled Wthread-safety analysis for clang builds.
CFLAGS += -Wthread-safety
--
2.55.0.1032.g73a4cd73de-goog
next prev parent reply other threads:[~2026-09-16 6:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 6:12 [PATCH 0/9] perf build: Fix builds with clang and BUILD_NONDISTRO Ian Rogers
2026-09-16 6:12 ` [PATCH 1/9] perf libbfd: Fix the clang -Wthread-safety build failure Ian Rogers
2026-09-16 6:12 ` [PATCH 2/9] perf symbol: Fix the build when demangling with libbfd Ian Rogers
2026-09-16 6:12 ` [PATCH 3/9] perf libbfd: Include the headers that are used Ian Rogers
2026-09-16 6:12 ` [PATCH 4/9] perf pmu: " Ian Rogers
2026-09-16 6:12 ` Ian Rogers [this message]
2026-09-16 6:12 ` [PATCH 6/9] perf build: Use the given CC rather than clang in clang builds Ian Rogers
2026-09-16 6:12 ` [PATCH 7/9] perf build: Check the version of the compiler that is used Ian Rogers
2026-09-16 6:12 ` [PATCH 8/9] perf build: Remove leftovers of removed build options Ian Rogers
2026-09-16 6:12 ` [PATCH 9/9] perf test: Add build tests for clang and libbfd demangling Ian Rogers
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=20260916061218.3061216-6-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=tmricht@linux.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®