From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B373141A55C; Mon, 10 Aug 2026 15:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786376694; cv=none; b=ktc1mV9pGNjVZ0b2eWM94JVaziAjrv51PsgDcV1XXOF3ic7952px7h9CzXgleUfbBO3hAZNZ25E1J79LMIpTV7MMqHsN2jkj+Z8KqjoWevEZLoG4xlaspN+t+gtjtKAQIOXnIbL8GLL0UrsBWkvxFpcLtgwj8PMrzhF+BvgxyHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786376694; c=relaxed/simple; bh=qykzTSewci9esBlVxQBueg/DrKwmCyH/1yhDffAV0zw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YYYe9hC73jZsMW5d/bY6zbbqIEh/wZZ3+NoIe0mzefadLm+EHRGcX2q6MnJNyIIdZl4ffEJ52JNnLt5x48P1uTwuVxZZR6m8AVx8a2/a824XqDpkK3ulZWbAQ9wdnikw4bkuSiBeqqdcitL3H33r0EwoQxL3a1XmYr8WYWt2VfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ENZkS5wL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ENZkS5wL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F21E1F00A3D; Mon, 10 Aug 2026 15:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786376693; bh=GrJ7rfAhix+7NfVhXf1iNwwqNGxcqdolfXZK+/krpY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ENZkS5wLr3VldhLcwhzWxpHLTcSnVPa/0LpxM2bJwyOKDxwjyARjr/XMTEYICX499 RCudUZJGELEB9r0tkxTPN0k/xnH+GPaycxQqBASnXwuz3nNwMbip2Ve2Mwt30U7duR 8dUFSamSuhxkDpOyUqU9aS8OE8vDwG9ZZYuy59QPqCmyYOjgsp0Gyg6mzVAXkdhiOY 0OGTdySob95PVB0vF2+ST/67zfU2/a3wQrUsSNaxwXFn2fU40wDI0C0SNKb4vO7sN5 Gku2zWFFTcTSbTRR3bOVTPBntxx8AmO4g79TDxXGJkDuIOuGAtMEGbKGnzbRWnqxXK +gYC3ka57JzOA== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , James Clark , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo Subject: [PATCH 1/7] tools build: Only probe the compiler at parse time when it is installed Date: Mon, 10 Aug 2026 12:44:31 -0300 Message-ID: <20260810154437.15946-2-acme@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260810154437.15946-1-acme@kernel.org> References: <20260810154437.15946-1-acme@kernel.org> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnaldo Carvalho de Melo Two parse-time probes still invoke $(CC) unconditionally: - LP64 in tools/scripts/Makefile.arch, probing with $(CC) -E -x c, pulled in twice by tools/perf/Makefile.perf; - CC_NO_CLANG in tools/scripts/Makefile.include, probing with $(CC) -dM -E -x c /dev/null. In the corner case where gcc is not yet installed, the very setup the install-build-deps target, added in the next patch of this series, is meant for, these probes make even targets that never compile parse-time spew errors like: /bin/sh: 1: gcc: not found /bin/sh: 1: gcc: not found /bin/sh: 1: gcc: not found Guard both probes with 'command -v' using the first word of CC so a missing compiler is handled silently with the same result as a failing probe (CC_NO_CLANG and LP64 unset/0), and with no behavior change when the compiler is installed. Only the first word is consulted because CC may carry arguments such as 'ccache gcc', and shell implementations differ in how 'command -v' handles multiple words (dash only checks the first, bash any of them), so validating the whole CC value would silently disable both probes on some make SHELLs. Assisted-by: opencode:deepseek-v4-flash-free Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Arnaldo Carvalho de Melo --- tools/scripts/Makefile.arch | 2 +- tools/scripts/Makefile.include | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch index eabfe9f411d914b9..e0bca6808ec44ed8 100644 --- a/tools/scripts/Makefile.arch +++ b/tools/scripts/Makefile.arch @@ -38,7 +38,7 @@ ifeq ($(ARCH),loongarch64) SRCARCH := loongarch endif -LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) +LP64 := $(shell if command -v $(firstword ${CC}) >/dev/null 2>&1; then echo __LP64__ | ${CC} ${CFLAGS} -E -x c -; fi | tail -n 1) ifeq ($(LP64), 1) IS_64_BIT := 1 else diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 46a3872b87624a7b..fff453aac187536e 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -98,7 +98,7 @@ else $(call allow-override,LLVM_STRIP,llvm-strip) endif -CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) +CC_NO_CLANG := $(shell if command -v $(firstword $(CC)) >/dev/null 2>&1; then $(CC) -dM -E -x c /dev/null; fi | grep -Fq "__clang__"; echo $$?) # Some tools require bpftool SYSTEM_BPFTOOL ?= bpftool -- 2.55.0