perf build: Use the given CC rather than clang in clang builds

The clang block is entered when CC_NO_CLANG has determined that CC is
clang, but it then ignores CC and hard codes $(CLANG), which defaults to
plain "clang". Building with a versioned compiler silently switches
compiler:

  $ make CC=clang-19		# actually builds with "clang"

Worse, the target triple is probed with $(CLANG) too, so on a machine
that only has versioned binaries installed the probe produces nothing
and the build stops:

  $ make CC=clang-19
  *** Specify CROSS_COMPILE or add CLANG_TARGET_FLAGS for x86_64

Use $(CC) in both places. Within the block CC is known to be clang, and
for "make LLVM=1" CC is already $(CLANG), so nothing changes there.

$(CLANG) is left as it is for BPF skeletons, as bpf_skel.mak builds
those with "$(CLANG) --target=bpf" whatever CC happens to be.

Fixes: 4772e66cb4 ("perf build: Support build with clang")
Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Ian Rogers 2026-09-15 23:12:15 -07:00 committed by Arnaldo Carvalho de Melo
parent c8592f8da8
commit bd874cd835

View File

@ -38,7 +38,7 @@ ifeq ($(CC_NO_CLANG), 0)
# Default to host architecture if ARCH is not explicitly given.
ifeq ($(ARCH), $(HOSTARCH))
CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple)
CLANG_TARGET_FLAGS := $(shell $(CC) -print-target-triple)
else
CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
endif
@ -53,7 +53,7 @@ ifeq ($(CC_NO_CLANG), 0)
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
endif # CROSS_COMPILE
CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
CC := $(CC) $(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