All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] sandbox: allow cross-compiling sandbox
@ 2021-02-08 22:06 Heinrich Schuchardt
  2021-02-09  4:29 ` Simon Glass
  0 siblings, 1 reply; 9+ messages in thread
From: Heinrich Schuchardt @ 2021-02-08 22:06 UTC (permalink / raw)
  To: u-boot

UEFI test files like helloworld.efi require an architecture specific
PE-COFF header.

For non-sandbox the PE-COFF header is chosen by the target architecture.
For the sandbox we use the host architecture. This is not helpful for cross
compiling. Allow specifying the target architecture of the sandbox via
environment variable MK_ARCH, e.g.

    make sandbox_defconfig NO_SDL=1
    CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 23dd11f723..286e5148ae 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)

 # Determine host architecture
 include include/host_arch.h
-MK_ARCH="${shell uname -m}"
+MK_ARCH?="${shell uname -m}"
 unexport HOST_ARCH
 ifeq ("x86_64", $(MK_ARCH))
   export HOST_ARCH=$(HOST_ARCH_X86_64)
diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
index 60ee1e0741..0dd9edc8cb 100644
--- a/doc/arch/sandbox.rst
+++ b/doc/arch/sandbox.rst
@@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.

 Note that standalone/API support is not available at present.

+Cross compiling
+---------------
+
+When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y the target
+architecture must be specified using the MK_ARCH environment variable using one
+of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64, e.g.
+
+.. code-block:: bash
+
+    NO_SDL=1 make sandbox_defconfig
+    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
+
+NO_SDL=1 was chosen in the example to remove the dependency on the SDL library.
+The graphical console will not be available.

 Prerequisites
 -------------
--
2.30.0

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-08 22:06 [PATCH 1/1] sandbox: allow cross-compiling sandbox Heinrich Schuchardt
@ 2021-02-09  4:29 ` Simon Glass
  2021-02-09  5:30   ` AKASHI Takahiro
  2021-02-09  6:26   ` Heinrich Schuchardt
  0 siblings, 2 replies; 9+ messages in thread
From: Simon Glass @ 2021-02-09  4:29 UTC (permalink / raw)
  To: u-boot

Hi Heinrich,

On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> UEFI test files like helloworld.efi require an architecture specific
> PE-COFF header.

architecture-specific

>
> For non-sandbox the PE-COFF header is chosen by the target architecture.
> For the sandbox we use the host architecture. This is not helpful for cross
> compiling. Allow specifying the target architecture of the sandbox via
> environment variable MK_ARCH, e.g.

What exactly is the target arch? Is the the one that sandbox is
running on, or something else?

>
>     make sandbox_defconfig NO_SDL=1
>     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  Makefile             |  2 +-
>  doc/arch/sandbox.rst | 14 ++++++++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 23dd11f723..286e5148ae 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
>
>  # Determine host architecture
>  include include/host_arch.h
> -MK_ARCH="${shell uname -m}"
> +MK_ARCH?="${shell uname -m}"
>  unexport HOST_ARCH
>  ifeq ("x86_64", $(MK_ARCH))
>    export HOST_ARCH=$(HOST_ARCH_X86_64)
> diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
> index 60ee1e0741..0dd9edc8cb 100644
> --- a/doc/arch/sandbox.rst
> +++ b/doc/arch/sandbox.rst
> @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
>
>  Note that standalone/API support is not available at present.
>
> +Cross compiling
> +---------------
> +
> +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y the target
> +architecture must be specified using the MK_ARCH environment variable using one
> +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64, e.g.

OK, but what is the target architecture? I'm just not sure from your
comments what this actually means.

Does MK mean make?

> +
> +.. code-block:: bash
> +
> +    NO_SDL=1 make sandbox_defconfig
> +    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
> +
> +NO_SDL=1 was chosen in the example to remove the dependency on the SDL library.
> +The graphical console will not be available.
>
>  Prerequisites
>  -------------
> --
> 2.30.0
>

Regards,
Simon

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09  4:29 ` Simon Glass
@ 2021-02-09  5:30   ` AKASHI Takahiro
  2021-02-09  6:40     ` Heinrich Schuchardt
  2021-02-09  6:26   ` Heinrich Schuchardt
  1 sibling, 1 reply; 9+ messages in thread
From: AKASHI Takahiro @ 2021-02-09  5:30 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 08, 2021 at 09:29:43PM -0700, Simon Glass wrote:
> Hi Heinrich,
> 
> On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> >
> > UEFI test files like helloworld.efi require an architecture specific
> > PE-COFF header.
> 
> architecture-specific
> 
> >
> > For non-sandbox the PE-COFF header is chosen by the target architecture.
> > For the sandbox we use the host architecture. This is not helpful for cross
> > compiling. Allow specifying the target architecture of the sandbox via
> > environment variable MK_ARCH, e.g.
> 
> What exactly is the target arch? Is the the one that sandbox is
> running on, or something else?
> 
> >
> >     make sandbox_defconfig NO_SDL=1
> >     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
> >
> > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > ---
> >  Makefile             |  2 +-
> >  doc/arch/sandbox.rst | 14 ++++++++++++++
> >  2 files changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 23dd11f723..286e5148ae 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
> >
> >  # Determine host architecture
> >  include include/host_arch.h
> > -MK_ARCH="${shell uname -m}"
> > +MK_ARCH?="${shell uname -m}"
> >  unexport HOST_ARCH
> >  ifeq ("x86_64", $(MK_ARCH))
> >    export HOST_ARCH=$(HOST_ARCH_X86_64)
> > diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
> > index 60ee1e0741..0dd9edc8cb 100644
> > --- a/doc/arch/sandbox.rst
> > +++ b/doc/arch/sandbox.rst
> > @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
> >
> >  Note that standalone/API support is not available at present.
> >
> > +Cross compiling
> > +---------------
> > +
> > +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y the target
> > +architecture must be specified using the MK_ARCH environment variable using one
> > +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64, e.g.
> 
> OK, but what is the target architecture? I'm just not sure from your
> comments what this actually means.

I'm not quite sure if it is very useful to be able to cross-compile
the sandbox application. But any way, it is not very convenient
to always enforce users to explicitly specify "target" architecture.
How about trying the following first?
$(CC) -v | grep "Target: " | sed -e 's/-*$//'

It will give us a hint about the architecture.
("--print-multiarch" shows a similar triple, but this option won't
work for some pre-built gcc, like aarch64 gcc from Arm.)

> Does MK mean make?

I prefer another name for clarity.

-Takahiro Akashi

> 
> > +
> > +.. code-block:: bash
> > +
> > +    NO_SDL=1 make sandbox_defconfig
> > +    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
> > +
> > +NO_SDL=1 was chosen in the example to remove the dependency on the SDL library.
> > +The graphical console will not be available.
> >
> >  Prerequisites
> >  -------------
> > --
> > 2.30.0
> >
> 
> Regards,
> Simon

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09  4:29 ` Simon Glass
  2021-02-09  5:30   ` AKASHI Takahiro
@ 2021-02-09  6:26   ` Heinrich Schuchardt
  2021-02-09 15:25     ` Simon Glass
  1 sibling, 1 reply; 9+ messages in thread
From: Heinrich Schuchardt @ 2021-02-09  6:26 UTC (permalink / raw)
  To: u-boot

Am 9. Februar 2021 05:29:43 MEZ schrieb Simon Glass <sjg@chromium.org>:
>Hi Heinrich,
>
>On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de>
>wrote:
>>
>> UEFI test files like helloworld.efi require an architecture specific
>> PE-COFF header.
>
>architecture-specific
>
>>
>> For non-sandbox the PE-COFF header is chosen by the target
>architecture.
>> For the sandbox we use the host architecture. This is not helpful for
>cross
>> compiling. Allow specifying the target architecture of the sandbox
>via
>> environment variable MK_ARCH, e.g.
>
>What exactly is the target arch? Is the the one that sandbox is
>running on, or something else?

It is the architecture that the binary can be run on



>
>>
>>     make sandbox_defconfig NO_SDL=1
>>     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>>  Makefile             |  2 +-
>>  doc/arch/sandbox.rst | 14 ++++++++++++++
>>  2 files changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 23dd11f723..286e5148ae 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
>>
>>  # Determine host architecture
>>  include include/host_arch.h
>> -MK_ARCH="${shell uname -m}"
>> +MK_ARCH?="${shell uname -m}"
>>  unexport HOST_ARCH
>>  ifeq ("x86_64", $(MK_ARCH))
>>    export HOST_ARCH=$(HOST_ARCH_X86_64)
>> diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
>> index 60ee1e0741..0dd9edc8cb 100644
>> --- a/doc/arch/sandbox.rst
>> +++ b/doc/arch/sandbox.rst
>> @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
>>
>>  Note that standalone/API support is not available at present.
>>
>> +Cross compiling
>> +---------------
>> +
>> +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y the
>target
>> +architecture must be specified using the MK_ARCH environment
>variable using one
>> +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64, e.g.
>
>OK, but what is the target architecture? I'm just not sure from your
>comments what this actually means.

See above.

>
>Does MK mean make?

What name do you suggest?

Best regards

Heinrich

>
>> +
>> +.. code-block:: bash
>> +
>> +    NO_SDL=1 make sandbox_defconfig
>> +    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
>> +
>> +NO_SDL=1 was chosen in the example to remove the dependency on the
>SDL library.
>> +The graphical console will not be available.
>>
>>  Prerequisites
>>  -------------
>> --
>> 2.30.0
>>
>
>Regards,
>Simon

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09  5:30   ` AKASHI Takahiro
@ 2021-02-09  6:40     ` Heinrich Schuchardt
  2021-02-09 11:31       ` AKASHI Takahiro
  0 siblings, 1 reply; 9+ messages in thread
From: Heinrich Schuchardt @ 2021-02-09  6:40 UTC (permalink / raw)
  To: u-boot

Am 9. Februar 2021 06:30:31 MEZ schrieb AKASHI Takahiro <takahiro.akashi@linaro.org>:
>On Mon, Feb 08, 2021 at 09:29:43PM -0700, Simon Glass wrote:
>> Hi Heinrich,
>> 
>> On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de>
>wrote:
>> >
>> > UEFI test files like helloworld.efi require an architecture
>specific
>> > PE-COFF header.
>> 
>> architecture-specific
>> 
>> >
>> > For non-sandbox the PE-COFF header is chosen by the target
>architecture.
>> > For the sandbox we use the host architecture. This is not helpful
>for cross
>> > compiling. Allow specifying the target architecture of the sandbox
>via
>> > environment variable MK_ARCH, e.g.
>> 
>> What exactly is the target arch? Is the the one that sandbox is
>> running on, or something else?
>> 
>> >
>> >     make sandbox_defconfig NO_SDL=1
>> >     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
>> >
>> > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> > ---
>> >  Makefile             |  2 +-
>> >  doc/arch/sandbox.rst | 14 ++++++++++++++
>> >  2 files changed, 15 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/Makefile b/Makefile
>> > index 23dd11f723..286e5148ae 100644
>> > --- a/Makefile
>> > +++ b/Makefile
>> > @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
>> >
>> >  # Determine host architecture
>> >  include include/host_arch.h
>> > -MK_ARCH="${shell uname -m}"
>> > +MK_ARCH?="${shell uname -m}"
>> >  unexport HOST_ARCH
>> >  ifeq ("x86_64", $(MK_ARCH))
>> >    export HOST_ARCH=$(HOST_ARCH_X86_64)
>> > diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
>> > index 60ee1e0741..0dd9edc8cb 100644
>> > --- a/doc/arch/sandbox.rst
>> > +++ b/doc/arch/sandbox.rst
>> > @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
>> >
>> >  Note that standalone/API support is not available at present.
>> >
>> > +Cross compiling
>> > +---------------
>> > +
>> > +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y
>the target
>> > +architecture must be specified using the MK_ARCH environment
>variable using one
>> > +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64,
>e.g.
>> 
>> OK, but what is the target architecture? I'm just not sure from your
>> comments what this actually means.
>
>I'm not quite sure if it is very useful to be able to cross-compile
>the sandbox application. But any way, it is not very convenient

Building the sandbox on ARMv7 is broken due to patch introduced in 2020. We get loads of warnings when building for 32bit.

We should integrate building the sandbox for different architectures into Gitlab CI.

>to always enforce users to explicitly specify "target" architecture.
>How about trying the following first?
>$(CC) -v | grep "Target: " | sed -e 's/-*$//'
>
>It will give us a hint about the architecture.
>("--print-multiarch" shows a similar triple, but this option won't
>work for some pre-built gcc, like aarch64 gcc from Arm.)

Did you check clang?

Is the output format specified? Will this be stable for compiler versions to come? Given the --print-multiarch failure probably not.

When compiling Linux you also have to supply CROSS_COMPILER and ARCH.

For me it is anyway a Gitlab CI thing. Nothing a user would typically use.

Best regards

Heinrich


>
>> Does MK mean make?
>
>I prefer another name for clarity.
>
>-Takahiro Akashi
>
>> 
>> > +
>> > +.. code-block:: bash
>> > +
>> > +    NO_SDL=1 make sandbox_defconfig
>> > +    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
>> > +
>> > +NO_SDL=1 was chosen in the example to remove the dependency on the
>SDL library.
>> > +The graphical console will not be available.
>> >
>> >  Prerequisites
>> >  -------------
>> > --
>> > 2.30.0
>> >
>> 
>> Regards,
>> Simon

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09  6:40     ` Heinrich Schuchardt
@ 2021-02-09 11:31       ` AKASHI Takahiro
  2021-02-09 12:25         ` Heinrich Schuchardt
  0 siblings, 1 reply; 9+ messages in thread
From: AKASHI Takahiro @ 2021-02-09 11:31 UTC (permalink / raw)
  To: u-boot

On Tue, Feb 09, 2021 at 07:40:23AM +0100, Heinrich Schuchardt wrote:
> Am 9. Februar 2021 06:30:31 MEZ schrieb AKASHI Takahiro <takahiro.akashi@linaro.org>:
> >On Mon, Feb 08, 2021 at 09:29:43PM -0700, Simon Glass wrote:
> >> Hi Heinrich,
> >> 
> >> On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de>
> >wrote:
> >> >
> >> > UEFI test files like helloworld.efi require an architecture
> >specific
> >> > PE-COFF header.
> >> 
> >> architecture-specific
> >> 
> >> >
> >> > For non-sandbox the PE-COFF header is chosen by the target
> >architecture.
> >> > For the sandbox we use the host architecture. This is not helpful
> >for cross
> >> > compiling. Allow specifying the target architecture of the sandbox
> >via
> >> > environment variable MK_ARCH, e.g.
> >> 
> >> What exactly is the target arch? Is the the one that sandbox is
> >> running on, or something else?
> >> 
> >> >
> >> >     make sandbox_defconfig NO_SDL=1
> >> >     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
> >> >
> >> > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >> > ---
> >> >  Makefile             |  2 +-
> >> >  doc/arch/sandbox.rst | 14 ++++++++++++++
> >> >  2 files changed, 15 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/Makefile b/Makefile
> >> > index 23dd11f723..286e5148ae 100644
> >> > --- a/Makefile
> >> > +++ b/Makefile
> >> > @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
> >> >
> >> >  # Determine host architecture
> >> >  include include/host_arch.h
> >> > -MK_ARCH="${shell uname -m}"
> >> > +MK_ARCH?="${shell uname -m}"
> >> >  unexport HOST_ARCH
> >> >  ifeq ("x86_64", $(MK_ARCH))
> >> >    export HOST_ARCH=$(HOST_ARCH_X86_64)
> >> > diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
> >> > index 60ee1e0741..0dd9edc8cb 100644
> >> > --- a/doc/arch/sandbox.rst
> >> > +++ b/doc/arch/sandbox.rst
> >> > @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
> >> >
> >> >  Note that standalone/API support is not available at present.
> >> >
> >> > +Cross compiling
> >> > +---------------
> >> > +
> >> > +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y
> >the target
> >> > +architecture must be specified using the MK_ARCH environment
> >variable using one
> >> > +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64,
> >e.g.
> >> 
> >> OK, but what is the target architecture? I'm just not sure from your
> >> comments what this actually means.
> >
> >I'm not quite sure if it is very useful to be able to cross-compile
> >the sandbox application. But any way, it is not very convenient
> 
> Building the sandbox on ARMv7 is broken due to patch introduced in 2020. We get loads of warnings when building for 32bit.

Are you using "cross-compiling" sandbox on armv7 machine?
For what target architecture?

> We should integrate building the sandbox for different architectures into Gitlab CI.
> 
> >to always enforce users to explicitly specify "target" architecture.
> >How about trying the following first?
> >$(CC) -v | grep "Target: " | sed -e 's/-*$//'
> >
> >It will give us a hint about the architecture.
> >("--print-multiarch" shows a similar triple, but this option won't
> >work for some pre-built gcc, like aarch64 gcc from Arm.)
> 
> Did you check clang?

I don't know, but we must specify "--target" option explicitly
in clang case, and according to U-Boot's Makefile, it will be uniquely
determined from "CROSS_COMPILE".

-Takahiro Akashi

> Is the output format specified? Will this be stable for compiler versions to come? Given the --print-multiarch failure probably not.
> 
> When compiling Linux you also have to supply CROSS_COMPILER and ARCH.
> 
> For me it is anyway a Gitlab CI thing. Nothing a user would typically use.
> 
> Best regards
> 
> Heinrich
> 
> 
> >
> >> Does MK mean make?
> >
> >I prefer another name for clarity.
> >
> >-Takahiro Akashi
> >
> >> 
> >> > +
> >> > +.. code-block:: bash
> >> > +
> >> > +    NO_SDL=1 make sandbox_defconfig
> >> > +    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
> >> > +
> >> > +NO_SDL=1 was chosen in the example to remove the dependency on the
> >SDL library.
> >> > +The graphical console will not be available.
> >> >
> >> >  Prerequisites
> >> >  -------------
> >> > --
> >> > 2.30.0
> >> >
> >> 
> >> Regards,
> >> Simon
> 

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09 11:31       ` AKASHI Takahiro
@ 2021-02-09 12:25         ` Heinrich Schuchardt
  0 siblings, 0 replies; 9+ messages in thread
From: Heinrich Schuchardt @ 2021-02-09 12:25 UTC (permalink / raw)
  To: u-boot

On 09.02.21 12:31, AKASHI Takahiro wrote:
> On Tue, Feb 09, 2021 at 07:40:23AM +0100, Heinrich Schuchardt wrote:
>> Am 9. Februar 2021 06:30:31 MEZ schrieb AKASHI Takahiro <takahiro.akashi@linaro.org>:
>>> On Mon, Feb 08, 2021 at 09:29:43PM -0700, Simon Glass wrote:
>>>> Hi Heinrich,
>>>>
>>>> On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> wrote:
>>>>>
>>>>> UEFI test files like helloworld.efi require an architecture
>>> specific
>>>>> PE-COFF header.
>>>>
>>>> architecture-specific
>>>>
>>>>>
>>>>> For non-sandbox the PE-COFF header is chosen by the target
>>> architecture.
>>>>> For the sandbox we use the host architecture. This is not helpful
>>> for cross
>>>>> compiling. Allow specifying the target architecture of the sandbox
>>> via
>>>>> environment variable MK_ARCH, e.g.
>>>>
>>>> What exactly is the target arch? Is the the one that sandbox is
>>>> running on, or something else?
>>>>
>>>>>
>>>>>     make sandbox_defconfig NO_SDL=1
>>>>>     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
>>>>>
>>>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>>>> ---
>>>>>  Makefile             |  2 +-
>>>>>  doc/arch/sandbox.rst | 14 ++++++++++++++
>>>>>  2 files changed, 15 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/Makefile b/Makefile
>>>>> index 23dd11f723..286e5148ae 100644
>>>>> --- a/Makefile
>>>>> +++ b/Makefile
>>>>> @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
>>>>>
>>>>>  # Determine host architecture
>>>>>  include include/host_arch.h
>>>>> -MK_ARCH="${shell uname -m}"
>>>>> +MK_ARCH?="${shell uname -m}"
>>>>>  unexport HOST_ARCH
>>>>>  ifeq ("x86_64", $(MK_ARCH))
>>>>>    export HOST_ARCH=$(HOST_ARCH_X86_64)
>>>>> diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
>>>>> index 60ee1e0741..0dd9edc8cb 100644
>>>>> --- a/doc/arch/sandbox.rst
>>>>> +++ b/doc/arch/sandbox.rst
>>>>> @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
>>>>>
>>>>>  Note that standalone/API support is not available at present.
>>>>>
>>>>> +Cross compiling
>>>>> +---------------
>>>>> +
>>>>> +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y
>>> the target
>>>>> +architecture must be specified using the MK_ARCH environment
>>> variable using one
>>>>> +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64,
>>> e.g.
>>>>
>>>> OK, but what is the target architecture? I'm just not sure from your
>>>> comments what this actually means.
>>>
>>> I'm not quite sure if it is very useful to be able to cross-compile
>>> the sandbox application. But any way, it is not very convenient
>>
>> Building the sandbox on ARMv7 is broken due to patch introduced in 2020. We get loads of warnings when building for 32bit.
>
> Are you using "cross-compiling" sandbox on armv7 machine?
> For what target architecture?

Compiling sandbox_defconfig without cross-compiling fails on ARMv7.

Best regards

Heinrich

>
>> We should integrate building the sandbox for different architectures into Gitlab CI.
>>
>>> to always enforce users to explicitly specify "target" architecture.
>>> How about trying the following first?
>>> $(CC) -v | grep "Target: " | sed -e 's/-*$//'
>>>
>>> It will give us a hint about the architecture.
>>> ("--print-multiarch" shows a similar triple, but this option won't
>>> work for some pre-built gcc, like aarch64 gcc from Arm.)
>>
>> Did you check clang?
>
> I don't know, but we must specify "--target" option explicitly
> in clang case, and according to U-Boot's Makefile, it will be uniquely
> determined from "CROSS_COMPILE".
>
> -Takahiro Akashi
>
>> Is the output format specified? Will this be stable for compiler versions to come? Given the --print-multiarch failure probably not.
>>
>> When compiling Linux you also have to supply CROSS_COMPILER and ARCH.
>>
>> For me it is anyway a Gitlab CI thing. Nothing a user would typically use.
>>
>> Best regards
>>
>> Heinrich
>>
>>
>>>
>>>> Does MK mean make?
>>>
>>> I prefer another name for clarity.
>>>
>>> -Takahiro Akashi
>>>
>>>>
>>>>> +
>>>>> +.. code-block:: bash
>>>>> +
>>>>> +    NO_SDL=1 make sandbox_defconfig
>>>>> +    CROSS_COMPILE=aarch64-linux-gnu- MK_ARCH=aarch64 NO_SDL=1 make
>>>>> +
>>>>> +NO_SDL=1 was chosen in the example to remove the dependency on the
>>> SDL library.
>>>>> +The graphical console will not be available.
>>>>>
>>>>>  Prerequisites
>>>>>  -------------
>>>>> --
>>>>> 2.30.0
>>>>>
>>>>
>>>> Regards,
>>>> Simon
>>

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09  6:26   ` Heinrich Schuchardt
@ 2021-02-09 15:25     ` Simon Glass
  2021-02-09 17:52       ` Heinrich Schuchardt
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Glass @ 2021-02-09 15:25 UTC (permalink / raw)
  To: u-boot

Hi Heinrich,

On Mon, 8 Feb 2021 at 23:26, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Am 9. Februar 2021 05:29:43 MEZ schrieb Simon Glass <sjg@chromium.org>:
> >Hi Heinrich,
> >
> >On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de>
> >wrote:
> >>
> >> UEFI test files like helloworld.efi require an architecture specific
> >> PE-COFF header.
> >
> >architecture-specific
> >
> >>
> >> For non-sandbox the PE-COFF header is chosen by the target
> >architecture.
> >> For the sandbox we use the host architecture. This is not helpful for
> >cross
> >> compiling. Allow specifying the target architecture of the sandbox
> >via
> >> environment variable MK_ARCH, e.g.
> >
> >What exactly is the target arch? Is the the one that sandbox is
> >running on, or something else?
>
> It is the architecture that the binary can be run on

You mean the sandbox binary. So it means that the sandbox binary runs
natively on the machine it is being built on? Or are you saying you
want to support building a 32-bit x86 sandbox binary on a 64-bit ARM
machine, for example?

Absent any cross-compiling,I think we should auto-detect it if
possible, like other programs do.

>
>
>
> >
> >>
> >>     make sandbox_defconfig NO_SDL=1
> >>     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
> >>
> >> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >> ---
> >>  Makefile             |  2 +-
> >>  doc/arch/sandbox.rst | 14 ++++++++++++++
> >>  2 files changed, 15 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/Makefile b/Makefile
> >> index 23dd11f723..286e5148ae 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
> >>
> >>  # Determine host architecture
> >>  include include/host_arch.h
> >> -MK_ARCH="${shell uname -m}"
> >> +MK_ARCH?="${shell uname -m}"
> >>  unexport HOST_ARCH
> >>  ifeq ("x86_64", $(MK_ARCH))
> >>    export HOST_ARCH=$(HOST_ARCH_X86_64)
> >> diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
> >> index 60ee1e0741..0dd9edc8cb 100644
> >> --- a/doc/arch/sandbox.rst
> >> +++ b/doc/arch/sandbox.rst
> >> @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
> >>
> >>  Note that standalone/API support is not available at present.
> >>
> >> +Cross compiling
> >> +---------------
> >> +
> >> +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y the
> >target
> >> +architecture must be specified using the MK_ARCH environment
> >variable using one
> >> +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64, e.g.
> >
> >OK, but what is the target architecture? I'm just not sure from your
> >comments what this actually means.
>
> See above.
>
> >
> >Does MK mean make?
>
> What name do you suggest?

That name is fine, I was just asking. I think using TARGET_ARCH would
get very confusing.

Regards,
Simon

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

* [PATCH 1/1] sandbox: allow cross-compiling sandbox
  2021-02-09 15:25     ` Simon Glass
@ 2021-02-09 17:52       ` Heinrich Schuchardt
  0 siblings, 0 replies; 9+ messages in thread
From: Heinrich Schuchardt @ 2021-02-09 17:52 UTC (permalink / raw)
  To: u-boot

On 09.02.21 16:25, Simon Glass wrote:
> Hi Heinrich,
>
> On Mon, 8 Feb 2021 at 23:26, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> Am 9. Februar 2021 05:29:43 MEZ schrieb Simon Glass <sjg@chromium.org>:
>>> Hi Heinrich,
>>>
>>> On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> wrote:
>>>>
>>>> UEFI test files like helloworld.efi require an architecture specific
>>>> PE-COFF header.
>>>
>>> architecture-specific
>>>
>>>>
>>>> For non-sandbox the PE-COFF header is chosen by the target
>>> architecture.
>>>> For the sandbox we use the host architecture. This is not helpful for
>>> cross
>>>> compiling. Allow specifying the target architecture of the sandbox
>>> via
>>>> environment variable MK_ARCH, e.g.
>>>
>>> What exactly is the target arch? Is the the one that sandbox is
>>> running on, or something else?
>>
>> It is the architecture that the binary can be run on
>
> You mean the sandbox binary. So it means that the sandbox binary runs
> natively on the machine it is being built on?

The target architecture in cross-compiling is the machine where the
binary is run. E.g. I build an ARM binary on a an RISC-V machine. Then
ARM is the target architecture and RISC-V is the host architecture.

I can only run that binary on an ARM machine or using QEMU.

> Or are you saying you
> want to support building a 32-bit x86 sandbox binary on a 64-bit ARM
> machine, for example?

That would be a use case for this patch.

>
> Absent any cross-compiling,I think we should auto-detect it if
> possible, like other programs do.

I will give it a try. Takahiro already made a suggestion.

Best regards

Heinrich

>
>>
>>
>>
>>>
>>>>
>>>>     make sandbox_defconfig NO_SDL=1
>>>>     CROSS_COMPILE=aarch64-linux-gnu- NO_SDL=1 MK_ARCH=aarch64 make
>>>>
>>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>>> ---
>>>>  Makefile             |  2 +-
>>>>  doc/arch/sandbox.rst | 14 ++++++++++++++
>>>>  2 files changed, 15 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Makefile b/Makefile
>>>> index 23dd11f723..286e5148ae 100644
>>>> --- a/Makefile
>>>> +++ b/Makefile
>>>> @@ -19,7 +19,7 @@ MAKEFLAGS += -rR --include-dir=$(CURDIR)
>>>>
>>>>  # Determine host architecture
>>>>  include include/host_arch.h
>>>> -MK_ARCH="${shell uname -m}"
>>>> +MK_ARCH?="${shell uname -m}"
>>>>  unexport HOST_ARCH
>>>>  ifeq ("x86_64", $(MK_ARCH))
>>>>    export HOST_ARCH=$(HOST_ARCH_X86_64)
>>>> diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
>>>> index 60ee1e0741..0dd9edc8cb 100644
>>>> --- a/doc/arch/sandbox.rst
>>>> +++ b/doc/arch/sandbox.rst
>>>> @@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
>>>>
>>>>  Note that standalone/API support is not available at present.
>>>>
>>>> +Cross compiling
>>>> +---------------
>>>> +
>>>> +When cross compiling the U-Boot sandbox with CONFIG_EFI_LOADER=y the
>>> target
>>>> +architecture must be specified using the MK_ARCH environment
>>> variable using one
>>>> +of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64, e.g.
>>>
>>> OK, but what is the target architecture? I'm just not sure from your
>>> comments what this actually means.
>>
>> See above.
>>
>>>
>>> Does MK mean make?
>>
>> What name do you suggest?
>
> That name is fine, I was just asking. I think using TARGET_ARCH would
> get very confusing.
>
> Regards,
> Simon
>

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

end of thread, other threads:[~2021-02-09 17:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 22:06 [PATCH 1/1] sandbox: allow cross-compiling sandbox Heinrich Schuchardt
2021-02-09  4:29 ` Simon Glass
2021-02-09  5:30   ` AKASHI Takahiro
2021-02-09  6:40     ` Heinrich Schuchardt
2021-02-09 11:31       ` AKASHI Takahiro
2021-02-09 12:25         ` Heinrich Schuchardt
2021-02-09  6:26   ` Heinrich Schuchardt
2021-02-09 15:25     ` Simon Glass
2021-02-09 17:52       ` Heinrich Schuchardt

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.