Skip to content

Commit b7892f7

Browse files
jpbruckerborkmann
authored andcommitted
tools: Ignore errors from `which' when searching a GCC toolchain
When cross-building tools with clang, we run `which $(CROSS_COMPILE)gcc` to detect whether a GCC toolchain provides the standard libraries. It is only a helper because some distros put libraries where LLVM does not automatically find them. On other systems, LLVM detects the libc automatically and does not need this. There, it is completely fine not to have a GCC at all, but some versions of `which' display an error when the command is not found: which: no aarch64-linux-gnu-gcc in ($PATH) Since the error can safely be ignored, throw it to /dev/null. Fixes: cebdb73 ("tools: Help cross-building with clang") Reported-by: Nathan Chancellor <[email protected]> Signed-off-by: Jean-Philippe Brucker <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent e2bcbd7 commit b7892f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/scripts/Makefile.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ EXTRA_WARNINGS += -Wstrict-aliasing=3
9090

9191
else ifneq ($(CROSS_COMPILE),)
9292
CLANG_CROSS_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
93-
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc))
93+
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc 2>/dev/null))
9494
ifneq ($(GCC_TOOLCHAIN_DIR),)
9595
CLANG_CROSS_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
9696
CLANG_CROSS_FLAGS += --sysroot=$(shell $(CROSS_COMPILE)gcc -print-sysroot)

0 commit comments

Comments
 (0)