[PATCH v2 00/30] Allow building sandbox with MSYS2

Simon Glass sjg at chromium.org
Sun Apr 30 03:29:33 CEST 2023


This expands the existing work to allow sandbox to build and run
natively on Windows using MSYS2.

This produces a native application that can run on Windows. This is quite
different from using WSL to cross-compile a Linux application, which is
then run in a virtual environment.

It also fixes a few issues so that binman can be used.

There are various limitations and some features do not work fully yet. In
particular, weak functions are not well supported on Windows so these are
disabled. Various minor compiler-flag and filename adjustments are also
needed.

This does not support SDL, so U-Boot has no display. This is potentially
possible, but requires using minggw instead of the base toolchain [1] so
needs to be dealt with separately.

Note: This series is split into two parts: generic fixes and MSYS2 stuff.

Patches up until this one should be ready to be applied:

   Makefile: Disable LTO when not building with gcc

After that, some of the MSYS2 stuff may need more work, depending on
review comments.

[1] https://gist.github.com/thales17/fb2e4cff60890a51d9dddd4c6e832ad2

Changes in v2:
- Split out u_boot_pylib from the subprocess patch
- move u_boot_pylib changes to a separate patch
- Use LIBEXT instead of SOEXT
- Update comment and use zz to make it less likely we have a problem
- Make LTO depend on !MSYS2 rather than adding another check
- Also disable LTO for clang, except with sandbox
- Update commit message to mention other OSes
- Check for __MSYS__ instead of __linux
- Use cc-option and ld-option instead
- Use EXEEXT instead of ELFEXT
- Add an awk script to augment the built-in link script
- Clearify the documentation to explain the environment better
- Update the cover letter to better explain the motivation

Simon Glass (30):
  u_boot_pylib: Correct name of readme
  u_boot_pylib: Avoid deleting the test_util.py file
  u_boot_pylib: Make pty optional
  binman: Avoid using a symlink
  pylibfdt: Allow building on Windows
  Fix Makefile warning about parallel targets
  mkimage: Correct checking of configuration node
  sandbox: Drop dead code from Makefile
  sandbox: Correct SDL.h header inclusion
  sandbox: Include errno.h in the test header
  sections: Drop use of linux/types.h
  sandbox: Drop incorrect inclusion of linux/types.h
  sandbox: Drop inclusion of os.h in sscanf.c
  test: Avoid strange symbols in the assembler file
  ctype: Avoid using a symlink
  Makefile: Disable LTO when not building with gcc
  Kbuild: Detect including an MSYS2 path
  sandbox: Disable raw Ethernet on MSYS2
  sandbox: Drop signal handling for MSYS2
  sandbox: Fix up setting of monitor_len on MSYS2
  Makefile: Disable unsupported compiler options with PE
  Makefile: Correct the ans1_compiler rule for MSYS2
  sandbox: Augment the linker script for MSYS2
  sandbox: Provide an EFI link script for PE
  sandbox: Allow weak symbols to be dropped
  build: Disable weak symbols for MSYS2
  doc: Update the MSYS2 packages and versions
  doc: Show how to build sandbox for MSYS2
  Makefile: Drop unwind tables for MSYS
  CI: Enable sandbox build for Windows

 .azure-pipelines.yml                  | 27 +++++++++
 Kconfig                               | 17 ++++++
 Makefile                              | 31 ++++++++--
 arch/sandbox/Makefile                 |  7 ---
 arch/sandbox/config.mk                | 23 +++++++-
 arch/sandbox/cpu/Makefile             |  2 +
 arch/sandbox/cpu/os.c                 |  3 +-
 arch/sandbox/cpu/sdl.c                |  2 +-
 arch/sandbox/cpu/u-boot-pe.lds.in     | 25 ++++++++
 arch/sandbox/include/asm/test.h       |  1 +
 arch/x86/lib/crt0_x86_64_efi.S        |  2 +
 arch/x86/lib/pe_x86_64_efi.lds        | 83 +++++++++++++++++++++++++++
 cmd/bootefi.c                         |  3 +-
 cmd/bootz.c                           |  3 +
 common/board_f.c                      |  2 +-
 common/usb.c                          |  3 +
 doc/build/gcc.rst                     | 40 +++++++++++++
 doc/build/tools.rst                   | 20 ++++---
 drivers/core/root.c                   |  3 +
 drivers/net/Makefile                  |  2 +
 drivers/spi/sandbox_spi.c             |  3 +
 env/env.c                             |  6 ++
 include/asm-generic/sections.h        | 16 +++---
 include/ctype.h                       |  7 ++-
 include/linux/compiler_attributes.h   |  4 ++
 include/os.h                          |  2 -
 include/test/test.h                   |  6 +-
 lib/efi_loader/Makefile               |  8 +++
 lib/efi_loader/efi_image_loader.c     |  3 +
 lib/efi_loader/efi_runtime.c          |  4 ++
 lib/lmb.c                             |  4 +-
 lib/sscanf.c                          |  1 -
 lib/time.c                            |  3 +
 scripts/Kbuild.include                |  3 +-
 scripts/Makefile.build                |  2 +-
 scripts/Makefile.lib                  |  9 ++-
 scripts/add_to_rdata.awk              | 25 ++++++++
 scripts/dtc/pylibfdt/Makefile         | 16 +++---
 scripts/make_pip.sh                   |  7 ++-
 tools/Makefile                        | 11 +++-
 tools/binman/binman                   | 11 +++-
 tools/image-host.c                    |  4 +-
 tools/u_boot_pylib/README.rst         |  2 +-
 tools/u_boot_pylib/cros_subprocess.py | 28 +++++++--
 tools/u_boot_pylib/pyproject.toml     |  2 +-
 45 files changed, 420 insertions(+), 66 deletions(-)
 create mode 100644 arch/sandbox/cpu/u-boot-pe.lds.in
 create mode 100644 arch/x86/lib/pe_x86_64_efi.lds
 mode change 120000 => 100644 include/ctype.h
 create mode 100644 scripts/add_to_rdata.awk
 mode change 120000 => 100755 tools/binman/binman

-- 
2.40.1.495.gc816e09b53d-goog



More information about the U-Boot mailing list