Skip to contentSkip to conversation

sandbox: allow cross-compiling sandbox

PATCH Superseded Heinrich Schuchardt 3 participants 9 messages Feb 8, 2021 – Feb 9, 2021 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +14 -0
index 60ee1e0741..0dd9edc8cb 100644
@@ -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

#1 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Hi Heinrich,

Quoted 3 lines · Heinrich Schuchardt

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

architecture-specific

Quoted 5 lines

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?

Quoted 28 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 9 lines
doc/arch/sandbox.rst +6 -0
@@ -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?

Quoted 12 lines
doc/arch/sandbox.rst +8 -1
+
+.. 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
 -------------
--
Quoted 2 lines

2.30.0

Regards,
Simon

#2 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Quoted 49 lines · Simon Glass

Hi Heinrich,

Quoted 3 lines · Heinrich Schuchardt

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

architecture-specific

Quoted 5 lines

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?

Quoted 31 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644
@@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
 
 Note that standalone/API support is not available at present.
 
Quoted 9 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 6 lines
doc/arch/sandbox.rst +6 -0
+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.)

Quoted 1 line

Does MK mean make?

I prefer another name for clarity.

-Takahiro Akashi

Quoted 18 lines
Quoted 13 lines
doc/arch/sandbox.rst +8 -1
+
+.. 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
 -------------
--
Quoted 2 lines

2.30.0

Regards,
Simon

#3 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Am 9. Februar 2021 06:30:31 MEZ schrieb AKASHI Takahiro <[email protected]>:

Quoted 62 lines · Simon Glass
Quoted 3 lines

Hi Heinrich,

On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

UEFI test files like helloworld.efi require an architecture

specific

Quoted 6 lines
Quoted 1 line

PE-COFF header.

architecture-specific

Quoted 2 lines

For non-sandbox the PE-COFF header is chosen by the target

architecture.

Quoted 1 line
Quoted 1 line

For the sandbox we use the host architecture. This is not helpful

for cross

Quoted 1 line
Quoted 1 line

compiling. Allow specifying the target architecture of the sandbox

via

Quoted 34 lines
Quoted 1 line

environment variable MK_ARCH, e.g.

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

Quoted 29 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644
@@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
 
Quoted 6 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 6 lines
doc/arch/sandbox.rst +4 -0
 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

Quoted 1 line

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 40

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+architecture must be specified using the MK_ARCH environment

variable using one

Quoted 8 lines
Quoted 1 line

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64,

e.g.

Quoted 3 lines

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.

Quoted 7 lines

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

Quoted 26 lines
Quoted 2 lines

Does MK mean make?

I prefer another name for clarity.

-Takahiro Akashi

Quoted 8 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 8 lines
doc/arch/sandbox.rst +7 -0
+
+.. 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.

Quoted 10 lines
Quoted 7 lines
doc/arch/sandbox.rst +1 -1
+The graphical console will not be available.
 
 Prerequisites
 -------------
--

2.30.0

Regards,
Simon

#4 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Quoted 66 lines · Heinrich Schuchardt

Am 9. Februar 2021 06:30:31 MEZ schrieb AKASHI Takahiro <[email protected]>:

Quoted 65 lines · Simon Glass
Quoted 3 lines

Hi Heinrich,

On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

UEFI test files like helloworld.efi require an architecture

specific

Quoted 6 lines
Quoted 1 line

PE-COFF header.

architecture-specific

Quoted 2 lines

For non-sandbox the PE-COFF header is chosen by the target

architecture.

Quoted 1 line
Quoted 1 line

For the sandbox we use the host architecture. This is not helpful

for cross

Quoted 1 line
Quoted 1 line

compiling. Allow specifying the target architecture of the sandbox

via

Quoted 34 lines
Quoted 1 line

environment variable MK_ARCH, e.g.

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

Quoted 29 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644
@@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
 
Quoted 6 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 6 lines
doc/arch/sandbox.rst +4 -0
 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

Quoted 1 line

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 40

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+architecture must be specified using the MK_ARCH environment

variable using one

Quoted 1 line

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64,

e.g.

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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?

Quoted 11 lines

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

Quoted 7 lines

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

Quoted 38 lines

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

Quoted 26 lines
Quoted 2 lines

Does MK mean make?

I prefer another name for clarity.

-Takahiro Akashi

Quoted 8 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 8 lines
doc/arch/sandbox.rst +7 -0
+
+.. 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.

Quoted 10 lines
Quoted 7 lines
doc/arch/sandbox.rst +1 -1
+The graphical console will not be available.
 
 Prerequisites
 -------------
--

2.30.0

Regards,
Simon

#5 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Quoted 70 lines · AKASHI Takahiro
Quoted 69 lines · Heinrich Schuchardt

Am 9. Februar 2021 06:30:31 MEZ schrieb AKASHI Takahiro <[email protected]>:

Quoted 68 lines · Simon Glass
Quoted 3 lines

Hi Heinrich,

On Mon, 8 Feb 2021 at 15:06, Heinrich Schuchardt <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

UEFI test files like helloworld.efi require an architecture

specific

Quoted 6 lines
Quoted 1 line

PE-COFF header.

architecture-specific

Quoted 2 lines

For non-sandbox the PE-COFF header is chosen by the target

architecture.

Quoted 1 line
Quoted 1 line

For the sandbox we use the host architecture. This is not helpful

for cross

Quoted 1 line
Quoted 1 line

compiling. Allow specifying the target architecture of the sandbox

via

Quoted 34 lines
Quoted 1 line

environment variable MK_ARCH, e.g.

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

Quoted 29 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644
@@ -33,6 +33,20 @@ integers can only be built on 64-bit hosts.
 
Quoted 6 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 6 lines
doc/arch/sandbox.rst +4 -0
 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

Quoted 1 line

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 40

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+architecture must be specified using the MK_ARCH environment

variable using one

Quoted 1 line

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+of the values aarch64, armv7l, i386, riscv32, riscv64, x86_64,

e.g.

Quoted 3 lines

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

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 57 lines
Quoted 7 lines

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

Quoted 4 lines

to always enforce users to explicitly specify "target" architecture. How about trying the following first?
$(CC) -v | grep "Target: " | sed -e 's/-*$//'

Quoted 5 lines
Quoted 3 lines

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

Quoted 38 lines

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

Quoted 26 lines
Quoted 2 lines

Does MK mean make?

I prefer another name for clarity.

-Takahiro Akashi

Quoted 8 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 8 lines
doc/arch/sandbox.rst +7 -0
+
+.. 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.

Quoted 10 lines
Quoted 7 lines
doc/arch/sandbox.rst +1 -1
+The graphical console will not be available.
 
 Prerequisites
 -------------
--

2.30.0

Regards,
Simon

#6 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

In reply to Simon Glass

Am 9. Februar 2021 05:29:43 MEZ schrieb Simon Glass <[email protected]>:

Quoted 13 lines

Hi Heinrich,

Quoted 3 lines · Heinrich Schuchardt

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

architecture-specific

Quoted 2 lines

For non-sandbox the PE-COFF header is chosen by the target

architecture.

Quoted 8 lines
Quoted 1 line

For the sandbox we use the host architecture. This is not helpful for

cross

Quoted 1 line

compiling. Allow specifying the target architecture of the sandbox

via

Quoted 1 line

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

Quoted 37 lines
Quoted 29 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 39

Quoted 7 lines
doc/arch/sandbox.rst +4 -0
@@ -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

Quoted 6 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 40

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+architecture must be specified using the MK_ARCH environment

variable using one

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+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.

Quoted 2 lines

Does MK mean make?

What name do you suggest?

Best regards

Heinrich

Quoted 19 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts.

Quoted 8 lines
doc/arch/sandbox.rst +7 -0
+
+.. 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.

Quoted 7 lines
doc/arch/sandbox.rst +1 -1
+The graphical console will not be available.
 
 Prerequisites
 -------------
--

2.30.0

Regards,
Simon

#7 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Hi Heinrich,

Quoted 17 lines · Heinrich Schuchardt

Am 9. Februar 2021 05:29:43 MEZ schrieb Simon Glass <[email protected]>:

Quoted 15 lines

Hi Heinrich,

Quoted 3 lines · Heinrich Schuchardt

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

architecture-specific

Quoted 2 lines

For non-sandbox the PE-COFF header is chosen by the target

architecture.

Quoted 1 line

For the sandbox we use the host architecture. This is not helpful for

cross

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

compiling. Allow specifying the target architecture of the sandbox

via

Quoted 1 line

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.

Quoted 47 lines
Quoted 40 lines
Quoted 32 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 39

Quoted 7 lines
doc/arch/sandbox.rst +4 -0
@@ -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

Quoted 6 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 40

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+architecture must be specified using the MK_ARCH environment

variable using one

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+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.

Quoted 6 lines

See above.

Quoted 2 lines

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

#8 lore raw

PATCH 1/1 sandbox: allow cross-compiling sandbox

Quoted 24 lines · Simon Glass

Hi Heinrich,

Quoted 21 lines · Heinrich Schuchardt

Am 9. Februar 2021 05:29:43 MEZ schrieb Simon Glass <[email protected]>:

Quoted 19 lines

Hi Heinrich,

Quoted 3 lines · Heinrich Schuchardt

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

architecture-specific

Quoted 2 lines

For non-sandbox the PE-COFF header is chosen by the target

architecture.

Quoted 1 line

For the sandbox we use the host architecture. This is not helpful for

cross

Quoted 1 line

compiling. Allow specifying the target architecture of the sandbox

via

Quoted 1 line

environment variable MK_ARCH, e.g.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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.

Quoted 3 lines

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.

Quoted 3 lines

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

Quoted 61 lines
Quoted 48 lines
Quoted 41 lines
Quoted 33 lines

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

---
 Makefile             |  2 +-
 doc/arch/sandbox.rst | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
Makefile +1 -1
index 23dd11f723..286e5148ae 100644
@@ -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)
doc/arch/sandbox.rst +0 -0
index 60ee1e0741..0dd9edc8cb 100644

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 39

Quoted 7 lines
doc/arch/sandbox.rst +4 -0
@@ -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

Quoted 6 lines

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 40

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+architecture must be specified using the MK_ARCH environment

variable using one

doc/arch/sandbox.rst integers can only be built on 64-bit hosts. · line 41

Quoted 1 line
doc/arch/sandbox.rst +1 -0
+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.

Quoted 6 lines

See above.

Quoted 2 lines

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