-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
stage1: cross compile to x86_64 and arm64 macOS from anywhere with LLVM #7318
Conversation
Some update on cross-compiling C++ with
@andrewrk, have you perhaps seen something like this before? |
Ugh, when linking against But this is what we get instead: whereas the |
OK, surprisingly, the output from LLD when linking in archives when cross compiling is pretty messed up. I'll need to noodle on it some more, and see whether there is anything I can do to fix it, or whether it should really be fixed in the LLD itself. In the meantime, my suggestion here is to still go with these changes (after they are refactored ofc!). At the very least, cross compiling Zig and C seems to work fine for the simple cases which already is a major step forward for the macOS platform support in Zig. |
Yes. We need to get off of The path forward here is to switch to master branch |
So my plan here is to refactor this PR as promised so that we get some cross-compilation available with the current LLVM backend (i.e., this then excludes |
Also, do not try to fixup missing libSystem for dylibs.
src/glibc.zig
Outdated
try args.append("-I"); | ||
try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "any-macos-any")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building glibc files we should not pass any-macos-any as an include directory
src/link/MachO.zig
Outdated
try self.writeHeader(); | ||
} | ||
if (self.code_signature_cmd_index == null) { | ||
if (target.cpu.arch != .aarch64) return; // This is currently needed only for aarch64 targets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to return
here? I think you meant break :block_name;
and to give a block name to the if statement block on the previous line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh crap, yeah, you're absolutely right. Thanks for spotting that one!
With this branch landing (after it's thoroughly cleaned up), we'll be able to cross-compile binaries targeting
x86_64
andaarch64
macOS from anywhere. What does it mean exactly, well this: