All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: Ignore errors from `which' when searching a GCC toolchain
@ 2022-02-01  9:31 Jean-Philippe Brucker
  2022-02-01 16:01 ` Nathan Chancellor
  2022-02-01 22:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jean-Philippe Brucker @ 2022-02-01  9:31 UTC (permalink / raw)
  To: nathan; +Cc: ndesaulniers, llvm, bpf, andrii, quentin, Jean-Philippe Brucker

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: cebdb7374577 ("tools: Help cross-building with clang")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 tools/scripts/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index b0be5f40a3f1..79d102304470 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -90,7 +90,7 @@ EXTRA_WARNINGS += -Wstrict-aliasing=3
 
 else ifneq ($(CROSS_COMPILE),)
 CLANG_CROSS_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
-GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc))
+GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc 2>/dev/null))
 ifneq ($(GCC_TOOLCHAIN_DIR),)
 CLANG_CROSS_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
 CLANG_CROSS_FLAGS += --sysroot=$(shell $(CROSS_COMPILE)gcc -print-sysroot)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: Ignore errors from `which' when searching a GCC toolchain
  2022-02-01  9:31 [PATCH] tools: Ignore errors from `which' when searching a GCC toolchain Jean-Philippe Brucker
@ 2022-02-01 16:01 ` Nathan Chancellor
  2022-02-01 22:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2022-02-01 16:01 UTC (permalink / raw)
  To: Jean-Philippe Brucker; +Cc: ndesaulniers, llvm, bpf, andrii, quentin

On Tue, Feb 01, 2022 at 09:31:20AM +0000, Jean-Philippe Brucker wrote:
> 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: cebdb7374577 ("tools: Help cross-building with clang")
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Thanks a lot for the quick fix!

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

It would be nice if this could go in via bpf, as cebdb7374577 was merged
in 5.17-rc1.

> ---
>  tools/scripts/Makefile.include | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> index b0be5f40a3f1..79d102304470 100644
> --- a/tools/scripts/Makefile.include
> +++ b/tools/scripts/Makefile.include
> @@ -90,7 +90,7 @@ EXTRA_WARNINGS += -Wstrict-aliasing=3
>  
>  else ifneq ($(CROSS_COMPILE),)
>  CLANG_CROSS_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
> -GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc))
> +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc 2>/dev/null))
>  ifneq ($(GCC_TOOLCHAIN_DIR),)
>  CLANG_CROSS_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
>  CLANG_CROSS_FLAGS += --sysroot=$(shell $(CROSS_COMPILE)gcc -print-sysroot)
> -- 
> 2.34.1
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: Ignore errors from `which' when searching a GCC toolchain
  2022-02-01  9:31 [PATCH] tools: Ignore errors from `which' when searching a GCC toolchain Jean-Philippe Brucker
  2022-02-01 16:01 ` Nathan Chancellor
@ 2022-02-01 22:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-01 22:10 UTC (permalink / raw)
  To: Jean-Philippe Brucker; +Cc: nathan, ndesaulniers, llvm, bpf, andrii, quentin

Hello:

This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue,  1 Feb 2022 09:31:20 +0000 you wrote:
> 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:
> 
> [...]

Here is the summary with links:
  - tools: Ignore errors from `which' when searching a GCC toolchain
    https://git.kernel.org/bpf/bpf/c/b7892f7d5cb2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-01 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01  9:31 [PATCH] tools: Ignore errors from `which' when searching a GCC toolchain Jean-Philippe Brucker
2022-02-01 16:01 ` Nathan Chancellor
2022-02-01 22:10 ` patchwork-bot+netdevbpf

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.