diff mbox series

[v3,01/16] Makefile: detect HOST_ARCH properly when CROSS_COMPILE is multi-word

Message ID a5617c0cb57624d004c4b4f42861822016edb2e9.1725351676.git.jerome.forissier@linaro.org
State New
Headers show
Series Miscellaneous fixes | expand

Commit Message

Jerome Forissier Sept. 3, 2024, 8:37 a.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>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Sept. 6, 2024, 3:02 p.m. UTC | #1
Hi Jerome,

On Tue, 3 Sept 2024 at 02:38, 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>
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index f90e48f58a5..dc7bdd79420 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
>

I've lost track of this, but did you pull in [1] first?

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/patch/20240815195746.749042-2-sjg@chromium.org/
Jerome Forissier Sept. 6, 2024, 3:10 p.m. UTC | #2
Hello Simon,

On 9/6/24 17:02, Simon Glass wrote:
> Hi Jerome,
> 
> On Tue, 3 Sept 2024 at 02:38, 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>
>> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
>> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
>> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
>> ---
>>  Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index f90e48f58a5..dc7bdd79420 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
>>
> 
> I've lost track of this, but did you pull in [1] first?

Oops! No I didn't :-/ In fact I could not find the reference to the patch
in your initial email, then I forgot about it.
Would you like me to resend the whole series as v4 with your patch included?

> 
> Regards,
> Simon
> 
> [1] https://patchwork.ozlabs.org/project/uboot/patch/20240815195746.749042-2-sjg@chromium.org/

Thanks,
Simon Glass Sept. 10, 2024, 6:44 p.m. UTC | #3
Hi Jerome,

On Fri, 6 Sept 2024 at 09:10, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> Hello Simon,
>
> On 9/6/24 17:02, Simon Glass wrote:
> > Hi Jerome,
> >
> > On Tue, 3 Sept 2024 at 02:38, 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>
> >> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> >> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> >> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> >> ---
> >>  Makefile | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/Makefile b/Makefile
> >> index f90e48f58a5..dc7bdd79420 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
> >>
> >
> > I've lost track of this, but did you pull in [1] first?
>
> Oops! No I didn't :-/ In fact I could not find the reference to the patch
> in your initial email, then I forgot about it.
> Would you like me to resend the whole series as v4 with your patch included?

I just want to know that there is still a problem, with my patch. So
yes please try it and update the commit messages as needed for the two
affected patches.

Regards,
Simon


>
> >
> > Regards,
> > Simon
> >
> > [1] https://patchwork.ozlabs.org/project/uboot/patch/20240815195746.749042-2-sjg@chromium.org/
>
> Thanks,
> --
> Jerome
Jerome Forissier Sept. 11, 2024, 9:44 a.m. UTC | #4
Hi Simon,

TL;DR: I am dropping this patch in v4.

On 9/10/24 20:44, Simon Glass wrote:
> Hi Jerome,
> 
> On Fri, 6 Sept 2024 at 09:10, Jerome Forissier
> <jerome.forissier@linaro.org> wrote:
>>
>> Hello Simon,
>>
>> On 9/6/24 17:02, Simon Glass wrote:
>>> Hi Jerome,
>>>
>>> On Tue, 3 Sept 2024 at 02:38, 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
>>>>        |  ^~~~~

As you mentioned in your reply to this patch in v2 [1], this is not
a valid use case (CROSS_COMPILE should not be set for sandbox).

[1] http://patchwork.ozlabs.org/project/uboot/patch/e2f0809aa4b9d81cf1709a6b82d803a21ea1fac7.1725012294.git.jerome.forissier@linaro.org/#3377679

>>>>
>>>> A similar error occurs when the build is done via buildman and
>>>> ~/.buildman contains:
>>>>
>>>>   [toolchain-wrapper]
>>>>   wrapper = ccache


This problem is still present in -next though (which does have your
patch "buildman: Support building within a Python venv" [2]).

It is my patch "buildman/toolchain.py: do not set CROSS_COMPILE for
sandbox" [3] that solves the problem.

[2] https://patchwork.ozlabs.org/project/uboot/patch/20240815195746.749042-2-sjg@chromium.org/
[3] http://patchwork.ozlabs.org/project/uboot/patch/f4defe07f87f6c9761b401d435da03460b3b0947.1725351676.git.jerome.forissier@linaro.org/

So all in all this patch is not needed.

Regards,
Simon Glass Sept. 12, 2024, 1 a.m. UTC | #5
Hi Jerome,

On Wed, 11 Sept 2024 at 03:44, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> Hi Simon,
>
> TL;DR: I am dropping this patch in v4.
>
> On 9/10/24 20:44, Simon Glass wrote:
> > Hi Jerome,
> >
> > On Fri, 6 Sept 2024 at 09:10, Jerome Forissier
> > <jerome.forissier@linaro.org> wrote:
> >>
> >> Hello Simon,
> >>
> >> On 9/6/24 17:02, Simon Glass wrote:
> >>> Hi Jerome,
> >>>
> >>> On Tue, 3 Sept 2024 at 02:38, 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
> >>>>        |  ^~~~~
>
> As you mentioned in your reply to this patch in v2 [1], this is not
> a valid use case (CROSS_COMPILE should not be set for sandbox).
>
> [1] http://patchwork.ozlabs.org/project/uboot/patch/e2f0809aa4b9d81cf1709a6b82d803a21ea1fac7.1725012294.git.jerome.forissier@linaro.org/#3377679
>
> >>>>
> >>>> A similar error occurs when the build is done via buildman and
> >>>> ~/.buildman contains:
> >>>>
> >>>>   [toolchain-wrapper]
> >>>>   wrapper = ccache
>
>
> This problem is still present in -next though (which does have your
> patch "buildman: Support building within a Python venv" [2]).
>
> It is my patch "buildman/toolchain.py: do not set CROSS_COMPILE for
> sandbox" [3] that solves the problem.
>
> [2] https://patchwork.ozlabs.org/project/uboot/patch/20240815195746.749042-2-sjg@chromium.org/
> [3] http://patchwork.ozlabs.org/project/uboot/patch/f4defe07f87f6c9761b401d435da03460b3b0947.1725351676.git.jerome.forissier@linaro.org/
>
> So all in all this patch is not needed.

OK, thank you for digging into this.

>
> Regards,
> --
> Jerome
>
> >>>> Fix the issue by considering only the last word in $(CROSS_COMPILE).
> >>>>
> >>>> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> >>>> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> >>>> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> >>>> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
> >>>> ---
> >>>>  Makefile | 2 +-
> >>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/Makefile b/Makefile
> >>>> index f90e48f58a5..dc7bdd79420 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
> >>>>
> >>>
> >>> I've lost track of this, but did you pull in [1] first?
> >>
> >> Oops! No I didn't :-/ In fact I could not find the reference to the patch
> >> in your initial email, then I forgot about it.
> >> Would you like me to resend the whole series as v4 with your patch included?
> >
> > I just want to know that there is still a problem, with my patch. So
> > yes please try it and update the commit messages as needed for the two
> > affected patches.
> >
> > Regards,
> > Simon
> >
> >
> >>
> >>>
> >>> Regards,
> >>> Simon
> >>>
> >>> [1] https://patchwork.ozlabs.org/project/uboot/patch/20240815195746.749042-2-sjg@chromium.org/
> >>
> >> Thanks,
> >> --
> >> Jerome

Regards,
Simon
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index f90e48f58a5..dc7bdd79420 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))