You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When configuring to cross compile darwin-x86 -> darwin-aarch64 or darwin-aarch64 -> darwin-x86, toolchains_llvm seems to be selecting some linker flags that prevent compilation. I'm working to support cross compilation on Sorbet (here's the PR sorbet/sorbet#8162).
First, the documentation says that when cross compiling it will try to use libstdc++ instead of libc++. However, that leads to an error telling the developer to switch to using libc++. There's some more context in this forum answer where they say libstdc++ is deprecated for MacOS.
I was able to move further by setting stdlib=libc++, but then on this line we enter the else statement because is_xcompile is true. Linking will then fail saying that hash-style, build-id and z are unknown arguments to the linker.
After patching that spot, then I was able to cross compile darwin-arm64 -> darwin-x86. We put our patches in sorbet#10 because I don't know what the general solution would be, but it does get Sorbet to build and produces a valid x86 binary.
Note
If you check the PR on Sorbet, you'll see that I added the MacOS SDK as a local repository to be able to give the llvm_toolchain definition a sysroot, enabling me to cross compile.
I'm not sure if that's the intended approach. It feels a bit weird given that it's the same SDK and I would assume the regular toolchain already has that configured somewhere. Please, let me know if I'm setting up something wrong.
It would be nice to add examples of how to configure cross compilation on Darwin to the documentation. If the approach is considered to be correct, then we can contribute some docs.
The text was updated successfully, but these errors were encountered:
When configuring to cross compile
darwin-x86 -> darwin-aarch64
ordarwin-aarch64 -> darwin-x86
,toolchains_llvm
seems to be selecting some linker flags that prevent compilation. I'm working to support cross compilation on Sorbet (here's the PR sorbet/sorbet#8162).First, the documentation says that when cross compiling it will try to use
libstdc++
instead oflibc++
. However, that leads to an error telling the developer to switch to usinglibc++
. There's some more context in this forum answer where they saylibstdc++
is deprecated for MacOS.I was able to move further by setting
stdlib=libc++
, but then on this line we enter theelse
statement becauseis_xcompile
is true. Linking will then fail saying thathash-style
,build-id
andz
are unknown arguments to the linker.After patching that part to not enter the
else
statement, it then fails further down because it always sets stdlib to be stdc++ when cross compiling, which adds another incompatible linker flag.After patching that spot, then I was able to cross compile
darwin-arm64 -> darwin-x86
. We put our patches in sorbet#10 because I don't know what the general solution would be, but it does get Sorbet to build and produces a valid x86 binary.Note
If you check the PR on Sorbet, you'll see that I added the MacOS SDK as a local repository to be able to give the
llvm_toolchain
definition a sysroot, enabling me to cross compile.I'm not sure if that's the intended approach. It feels a bit weird given that it's the same SDK and I would assume the regular toolchain already has that configured somewhere. Please, let me know if I'm setting up something wrong.
It would be nice to add examples of how to configure cross compilation on Darwin to the documentation. If the approach is considered to be correct, then we can contribute some docs.
The text was updated successfully, but these errors were encountered: