MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

mingw-w64-cross-clang: prefixed cross-compiling wrappers for clang

Open jeremyd2019 opened this issue 3 years ago • 8 comments

Related to discussion #8736.

Based on wrappers from llvm-mingw. Also adds a package that provides "foreign" compiler-rt libs.

The clang wrapper could be simplified (have some of the options removed) if the package is only provided for CLANG*. I haven't tested them under MINGW*.

jeremyd2019 avatar May 25 '21 01:05 jeremyd2019

This seems to be working quite well. I can use this to cross-compile python. The packaging is a bit odd, but it seems to do the job.

jeremyd2019 avatar Nov 22 '21 02:11 jeremyd2019

Wonder how will this work with things like cmake, meson and ninja? Can I use mingw64 cmake with aarch64-w64-mingw32-clang to cross compile ARM64 binaries on x86_64?

driver1998 avatar Mar 29 '22 05:03 driver1998

Wonder how will this work with things like cmake, meson and ninja? Can I use mingw64 cmake with aarch64-w64-mingw32-clang to cross compile ARM64 binaries on x86_64?

Note I haven't bothered tested the GCC-based MSYSTEMs with this, they should work but who knows...

But with clang64, absolutely! All the major build systems have a mechanism to configure them to cross-compile. In fact, I had good luck with cmake not even bothering configuring a toolchain file, and instead just specifying options:

        -DCMAKE_{ASM,C,CXX}_COMPILER_TARGET="aarch64-w64-mingw32" \
        -DCMAKE_{ASM,C,CXX}_COMPILER_WORKS=ON \
        -DCMAKE_CROSSCOMPILING=ON \
        -DCMAKE_SYSROOT="/clangarm64" \
        -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
        -DCMAKE_FIND_ROOT_PATH_MODE_{LIBRARY,INCLUDE,PACKAGE}=ONLY \

You may not even need to override "compiler works" for normal packages, I was trying to cross-compile libc++ at the time for a prefix lacking it, so the C++ compiler didn't entirely work yet.

jeremyd2019 avatar Mar 29 '22 05:03 jeremyd2019

The way I'm doing a "standalone" compiler-rt build here is apparently deprecated. I'll have to investigate how they intend it to be done now, hopefully it doesn't require downloading the llvm sources.

jeremyd2019 avatar Nov 06 '22 23:11 jeremyd2019

How about installing all architectures supported by us on every architecture instead of creating new compiler-rt packages? It's 35 MiB right now so that would add 70 MiB which doesn't seem so bad considering size and price of today's storage.

mati865 avatar Nov 14 '22 22:11 mati865

How difficult would that be? Is that possible from the existing mingw-w64-headers-git install or would we need to install the 'foreign' -headers-git like I do for the cross-compiler-rt package here? (compiler-rt only seems to need the headers, thankfully, as it is a static library. Don't know about the sanitizers, haven't tried to do those for this cross compilation thing yet).

jeremyd2019 avatar Nov 14 '22 23:11 jeremyd2019

Right, forgot about mingw-w64. That would make it even harder than current approach...

mati865 avatar Nov 15 '22 00:11 mati865