This patch series allows building a toolchain that supports ARM64X builds,
see [1] for a patch to llvm-mingw that implements this. ARM64X images are
PE files that can act as either a native ARM64 image or an ARM64EC image,
depending on how they are loaded. To build such an image, all code needs
to be compiled twice (once as ARM64 and once as ARM64EC) and passed together
to the linker.

This solution depends on a very recent LLVM git commit for the new additions
to -marm64x handling; see [2] for the RFC with more details. Although it
was technically possible to attempt ARM64X without it, doing so was highly
impractical because no build systems expected such a workflow. Clang can
now handle this complexity by performing a double compilation when passed
-marm64x, embedding the results into a single object file and ensuring that
the linker and archive tools process it appropriately.

On the CRT side, this requires that a single prefix can handle both native
and EC requirements. In practice, this means that instead of using
a separate arm64ec-w64-mingw32 prefix, the aarch64-w64-mingw32 prefix is
built with -marm64x. This alone is sufficient for most of the llvm-mingw
stack, except for mingw-w64-crt, which requires extra care. Most of the
required changes involve passing both native and EC .def files to dlltool
(even if it often means passing the same .def file twice).

[1] 
https://github.com/cjacek/llvm-mingw/commit/798eab4558d6acd36ec762dae8db04a6294e588b
[2] 
https://discourse.llvm.org/t/multi-architecture-coff-object-files-for-arm64x-using-an-extra-section/91030

Jacek Caban (3):
  configure: Introduce the --enable-arm64ec option.
  makefile: Use with -marm64x when ARM64X is enabled.
  makefile: Pass both native and EC def files to dlltool when ARM64X is
    enabled.

 mingw-w64-crt/Makefile.am            | 119 +++++++++++++++++++++++----
 mingw-w64-crt/configure.ac           |  14 +++-
 mingw-w64-crt/crt/chpe.S             |   4 +
 mingw-w64-crt/math/fabsf.c           |   5 ++
 mingw-w64-crt/misc/arm64ec/longjmp.c |   4 +
 mingw-w64-crt/misc/arm64ec/setjmp.c  |   4 +
 mingw-w64-crt/stdio/scanf.S          |   2 +-
 7 files changed, 132 insertions(+), 20 deletions(-)

-- 
2.53.0



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to