Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jeremyd2019
Copy link
Member

@jeremyd2019 jeremyd2019 commented May 25, 2021

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 jeremyd2019 force-pushed the cross-clang-for-discussion branch 4 times, most recently from f697209 to 35e58f8 Compare November 5, 2021 01:19
@jeremyd2019 jeremyd2019 force-pushed the cross-clang-for-discussion branch 2 times, most recently from c7af15d to b803395 Compare November 21, 2021 06:36
@jeremyd2019 jeremyd2019 changed the title mingw-w64-cross-clang: add idea for discussion mingw-w64-cross-clang: prefixed cross-compiling wrappers for clang Nov 21, 2021
@jeremyd2019
Copy link
Member Author

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.

@driver1998
Copy link
Contributor

driver1998 commented Mar 29, 2022

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?

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented Mar 29, 2022

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 jeremyd2019 force-pushed the cross-clang-for-discussion branch 3 times, most recently from 7b79bd9 to b23897a Compare April 6, 2022 05:19
@jeremyd2019 jeremyd2019 force-pushed the cross-clang-for-discussion branch 3 times, most recently from 83095c2 to 66c68ce Compare August 14, 2022 20:30
@jeremyd2019 jeremyd2019 force-pushed the cross-clang-for-discussion branch 3 times, most recently from 1dc144f to 054fa05 Compare September 11, 2022 22:52
@jeremyd2019
Copy link
Member Author

I set up a github repository with a release to keep binaries of this, and set up a pacman repo for the latest version.

The files are in the release https://github.com/msys2-arm/cross-clang/releases/repo. To use, add the following in /etc/pacman.conf:

[cross-clang]
Server = https://github.com/msys2-arm/cross-clang/releases/download/repo
SigLevel = Never

@jeremyd2019 jeremyd2019 force-pushed the cross-clang-for-discussion branch 6 times, most recently from d51b214 to 1770351 Compare April 6, 2023 18:41
to provide compiler-rt builtins for foreign Windows arches
This allows using clang to target other Windows arches using prefixed
cross tools (ie, aarch64-w64-mingw32-clang).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants