diff mbox series

[01/13] Makefile: detect HOST_ARCH properly when CROSS_COMPILE is multi-word

Message ID 7de6a75453d11fa56ae81f3ad3d0f16f0d12546e.1724846454.git.jerome.forissier@linaro.org
State Superseded
Headers show
Series Miscellaneous fixes | expand

Commit Message

Jerome Forissier Aug. 28, 2024, 12:10 p.m. UTC
When CROSS_COMPILE contains multiple words, HOST_ARCH is not properly
detected and the sandbox build fail. It typically happens when using
ccache. For example:

 $ make sandbox_defconfig
 $ make CROSS_COMPILE="ccache x86_64-linux-gnu-" \
        CC="ccache x86_64-linux-gnu-gcc"
 [...]
 In file included from boot/bootmeth_efi.c:16:
 include/efi_default_filename.h:33:2: error: #error Unsupported UEFI architecture
    33 | #error Unsupported UEFI architecture
       |  ^~~~~

A similar error occurs when the build is done via buildman and
~/.buildman contains:

  [toolchain-wrapper]
  wrapper = ccache

Fix the issue by considering only the last word in $(CROSS_COMPILE).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilias Apalodimas Aug. 29, 2024, 7:31 a.m. UTC | #1
On Wed, 28 Aug 2024 at 15:10, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> When CROSS_COMPILE contains multiple words, HOST_ARCH is not properly
> detected and the sandbox build fail. It typically happens when using
> ccache. For example:
>
>  $ make sandbox_defconfig
>  $ make CROSS_COMPILE="ccache x86_64-linux-gnu-" \
>         CC="ccache x86_64-linux-gnu-gcc"
>  [...]
>  In file included from boot/bootmeth_efi.c:16:
>  include/efi_default_filename.h:33:2: error: #error Unsupported UEFI architecture
>     33 | #error Unsupported UEFI architecture
>        |  ^~~~~
>
> A similar error occurs when the build is done via buildman and
> ~/.buildman contains:
>
>   [toolchain-wrapper]
>   wrapper = ccache
>
> Fix the issue by considering only the last word in $(CROSS_COMPILE).
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index f90e48f58a..dc7bdd7942 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -21,7 +21,7 @@ include include/host_arch.h
>  ifeq ("", "$(CROSS_COMPILE)")
>    MK_ARCH="${shell uname -m}"
>  else
> -  MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
> +  MK_ARCH="${shell echo ${lastword $(CROSS_COMPILE)} | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
>  endif
>  unexport HOST_ARCH
>  ifeq ("x86_64", $(MK_ARCH))
> --
> 2.40.1
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index f90e48f58a..dc7bdd7942 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@  include include/host_arch.h
 ifeq ("", "$(CROSS_COMPILE)")
   MK_ARCH="${shell uname -m}"
 else
-  MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
+  MK_ARCH="${shell echo ${lastword $(CROSS_COMPILE)} | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
 endif
 unexport HOST_ARCH
 ifeq ("x86_64", $(MK_ARCH))