Replies: 9 comments 35 replies
-
I was thinking about this, and if there are options to clang/lld/etc to override their search paths (and I assume there are), including for compiler-rt, it seems like should be possible to make a mingw-w64-cross-clang type package that consists entirely of scripts that pass the proper args to the host arch's mingw-w64-clang to use the target arch's mingw-w64-compiler-rt, libc++, crt, etc... Such a package could depend on host mingw-w64-clang packages, and target mingw-w64-* packages but that would kind of break the self-contained-ness of each prefix I guess |
Beta Was this translation helpful? Give feedback.
-
#!/bin/bash
_target=aarch64-w64-mingw32
_targetprefix=/clangarm64
_prefix=cross-aarch64/bin
_resourcever="$(basename "$(clang -print-resource-dir)")"
for tool in as cc clang gas gcc; do
printf "#!/bin/bash\n\n${MINGW_PREFIX}/bin/clang -target ${_target} --sysroot=${_targetprefix} -resource-dir=${_targetprefix}/lib/clang/${_resourcever} \"\$@\"" | tee "${_prefix}/${tool}" "${_prefix}/${_target}-${tool}" > /dev/null
done
for tool in c++ clang++ g++; do
printf "#!/bin/bash\n\n${MINGW_PREFIX}/bin/clang++ -target ${_target} --sysroot=${_targetprefix} -resource-dir=${_targetprefix}/lib/clang/${_resourcever} \"\$@\"" | tee "${_prefix}/${tool}" "${_prefix}/${_target}-${tool}" > /dev/null
done
for tool in windres; do
printf "#!/bin/bash\n\nexec -a ${MINGW_PREFIX}/bin/${_target}-${tool} ${MINGW_PREFIX}/bin/${tool} \"\$@\"" | tee "${_prefix}/${tool}" "${_prefix}/${_target}-${tool}" > /dev/null
done I was able to cross build ntldd with this at least. I am having issues with windres though, I need to set |
Beta Was this translation helpful? Give feedback.
-
I threw together a PKGBUILD based on my ideas: #8762 |
Beta Was this translation helpful? Give feedback.
-
Did I get it correctly that it will be a new package |
Beta Was this translation helpful? Give feedback.
-
If we need native wrappers, we're going to wind up with something pretty similar to llvm-mingw. Is there really any benefit to reinventing that here? If so, maybe starting with @mstorsjo's wrappers would be a good idea |
Beta Was this translation helpful? Give feedback.
-
I was thinking about this some more, and if there are native wrappers in the 'host' prefix, they will need some way to get the path to the 'target' prefix. I don't know how that would best be accomplished... calling out to |
Beta Was this translation helpful? Give feedback.
-
I finally came back to this, still in #8762. I went ahead and built/packaged compiler-rt for the 'foreign' windows arches rather than messing around with I had to 'resurrect' a dlltool and windres wrapper, because the generic llvm-wrapper doesn't work with them, as they overwrite their argv[0]. Also, there was a bit of annoyance with having to pass a sysroot to windres: apparently something is eating backslashes from the I left the defaults in clang-target-wrapper for things like lld/libunwind/rtlib/libc++. I think they may be necessary if these are to work with the MINGW*/UCRT* tools as well (there's no guarantee that they have to though, and it may be simpler to declare that you must use CLANG* with this, and remove those defaults). |
Beta Was this translation helpful? Give feedback.
-
Resurrecting this old discussion, it sounds like something like this could be useful for Git for Windows. /cc @dscho @dennisameling My concern with #8762 is the cross-repo dependencies. You need the target mingw-w64-headers-git to build the target compiler-rt, and you do need at least a few core libraries for the cross-compilers to be useful. I'm pretty sure no cross-repo dependencies like that currently exist (with the limited exception of dependencies on msys packages), and that autobuild does not handle such a case. |
Beta Was this translation helpful? Give feedback.
-
I recently came across this blog post: https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/ Perhaps these config files can be used instead of wrappers passing different "default" arguments for cross-compiling? And/or instead of patches that change defaults in mingw-w64-clang package? It sounds like there is new behavior regarding these config files coming in clang 16.x (which gentoo partially backported to 15.x) that might make that a good opportunity to explore the possibilities there. |
Beta Was this translation helpful? Give feedback.
-
A
clang64-cross
environment that expects anx86_64
host, but has all the necessary base toolchain + libs to cross-compile for all targets (i686
,x86_64
,armv7
,aarch64
).i.e. Similar to https://github.com/mstorsjo/llvm-mingw, but with the benefit of all of msys2's patches and tweaks and surrounding infrastructure (ex. msys2/setup-msys2 GitHub Action).
Useful for local or hosted CI that doesn't offer appropriate target architecture runners. (i.e.
clangarm64
expects to be run on ARM64, but - at least as of 2020 - there were no plans to bring hosted ARM64 Windows environments to GitHub Actions)Theoretically, various other libraries could come from
clang32
,clang64
,clangarm64
, but the open-source projects that I contribute to build all dependencies withvcpkg
anyway (and this works well with mingw), so a simple clang/llvm cross-compilation msys2 environment would be sufficient as a fantastic start.Thoughts? Ideas?
Beta Was this translation helpful? Give feedback.
All reactions