Re: [PATCH] Makefile: Add HOST_GCC_SUFFIX and CROSS_GCC_SUFFIX

From: Masahiro Yamada
Date: Fri Jan 19 2024 - 00:30:31 EST


On Fri, Jan 19, 2024 at 4:20 AM Palmer Dabbelt <palmer@xxxxxxxxxxxx> wrote:
>
> From: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
>
> I was just trying to track down a build bug with an old toolchain.
> Turns out Ubuntu installs old GCCs as something like
> riscv64-linux-gnu-gcc-10, which is a bit clunky to point the build at
> without a way to append a suffix to CC.


You can do:

make CROSS_COMPILE=riscv64-linux-gnu- CC=riscv64-linux-gnu-gcc-10





>
> There's already LLVM_SUFFIX, but nothing similar for GCC. I've split
> out the host and target suffixes as users probably don't have the same
> version of for both (unlike LLVM, where the cross compiler is likely to
> support the host target).
>
> Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
> ---
> I've only given this some very minimal testing, but it at least works
> for my simple use case.
> ---
> Makefile | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index f1b2fd977275..36ce336cda3b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -433,8 +433,8 @@ endif
> HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> HOSTCXX = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX)
> else
> -HOSTCC = gcc
> -HOSTCXX = g++
> +HOSTCC = gcc$(HOST_GCC_SUFFIX)
> +HOSTCXX = g++$(HOST_GCC_SUFFIX)
> endif
> HOSTRUSTC = rustc
> HOSTPKG_CONFIG = pkg-config
> @@ -480,7 +480,7 @@ OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
> READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
> STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
> else
> -CC = $(CROSS_COMPILE)gcc
> +CC = $(CROSS_COMPILE)gcc$(CROSS_GCC_SUFFIX)
> LD = $(CROSS_COMPILE)ld
> AR = $(CROSS_COMPILE)ar
> NM = $(CROSS_COMPILE)nm
> --
> 2.43.0
>
>


--
Best Regards
Masahiro Yamada