Live data from Hacker News

Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

github.com

21–30 of 76 posts

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#21
post #9

Does this not need any xcode/macos license?

Why would it? You can cross compile for macos with the go toolchain on Linux too and that doesn't even require an additional compiler. Just GOOS=darwin GOARCH=arm64 and then the regular command. Apple can't regulate everything

If you need the macOS SDK, then you need to obey the developer licensing rules. Does this need the SDK?

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#22

Speaking of cross compilers - I was able to use the zig toolchain in order to cross compile for macos apple silicon, arm Linux, windows x64, windows arm and x86_64 Linux musl (statically linked). It's super handy and works as a drop in.

Interestingly you can use zig within your Rust build to more easily cross-compile: https://github.com/rust-cross/cargo-zigbuild I’m curious what the blockers are for rustc to cross-compile like zig does natively.

There is cargo-zigbuild, which uses zig as a linker, but I have yet to try it out.

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#23

Speaking of cross compilers - I was able to use the zig toolchain in order to cross compile for macos apple silicon, arm Linux, windows x64, windows arm and x86_64 Linux musl (statically linked). It's super handy and works as a drop in.

Interestingly you can use zig within your Rust build to more easily cross-compile: https://github.com/rust-cross/cargo-zigbuild I’m curious what the blockers are for rustc to cross-compile like zig does natively.

That's actually exactly how this cross-compiler works for Rust!

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#24
Currently I cross-compile the other way since the story is easier. Getting dependencies, etc. especially if you want something libssl is an annoying nightmare if you're trying to cross-compile targeting MacOS on a host on Linux. But if you're going the other way, very easy to use Docker.

The good part of this is that I can use a standard Linux host now to just build everything. Very nice!

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#25
I'll plug some work I've been doing to (attempt to) enable cross compilation of Python wheels. I put together a small example [1] that builds the zstandard wheel, and can build macos wheels on linux and linux wheels on macos using zig cc.

macos wheels must still be adhoc signed (codesign) and binary patched (install_name_tool), so I re-implemented those functions in Python [2].

[1] https://github.com/jvolkman/bazel-pycross-zstandard-example

[2] https://github.com/jvolkman/repairwheel/tree/main/src/repair...

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#26
post #9

Does this not need any xcode/macos license?

Why would it? You can cross compile for macos with the go toolchain on Linux too and that doesn't even require an additional compiler. Just GOOS=darwin GOARCH=arm64 and then the regular command. Apple can't regulate everything

The most obvious answer is you need the system frameworks to link against.

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#27
post #3

What is happening with that first picture?? Is that an extra penguin arm coming out of the apple?

I actually didn't notice that!

I wanted to add some sort of image to the repository README, and it seemed like the simplest way to do so.

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#28

Earlier quoted context omitted.

Interestingly you can use zig within your Rust build to more easily cross-compile: https://github.com/rust-cross/cargo-zigbuild I’m curious what the blockers are for rustc to cross-compile like zig does natively.

Just add another arch with rustup. Am I missing something?

That would solve the compilation problem, but there is more to create a working binary. For MacOS the official (and I believe only legal) way is to use a Mac with XCode installed for linking.

Now, you can download all the necessary files from a Mac and build a cross-compilation toolchain on your Linux system. I believe you could not legally distribute a project doing this and that is why these projects don't exist or are usually short-lived (with the notable exception of zig).

We will see how that goes for OP.

So, solutions like osxcross resort to shipping scripts that help you to acquire the necessary files and make that process easier.

The OP builds on osxcross, but is "batteries included".

zig has an even more difficult problem to solve because it tries to compile and link for many platforms. Shipping all the different requirements in their original form would make a zig distribution huge. So it does some clever magic I do not fully understand to create the necessary files from just the necessary subset of data. This reduces the size because there is overlap between platforms. It also means that they are not shipping the Mac files in their complete and original form and have gotten away with this legally so far.

At least that is what I believe is happening. I hope someone with more knowledge about zig could explain it better.

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#29

Speaking of cross compilers - I was able to use the zig toolchain in order to cross compile for macos apple silicon, arm Linux, windows x64, windows arm and x86_64 Linux musl (statically linked). It's super handy and works as a drop in.

I'm commenting to add a critical mass around Zig. If you are prisoner of CMake, autoconf, templates, makefiles, etc.. please try the Zig toolchain for your c/c++ projects. It is worth every second of investment

Re: Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux

#30

Earlier quoted context omitted.

Apple ships extra stickers with their logo in the box with a lot of their products, maybe slap one on your computer and see how far it gets you in court?

Which is why they changed the wording from "Apple-labeled" to "Apple-branded" around the time of Snow Leopard IIRC.

How much could a branding iron cost?
Post reply on HN