Show HN: macOS-cross-compiler – Compile binaries for macOS on Linux
github.com
github.com
I’m curious what the blockers are for rustc to cross-compile like zig does natively.
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.
Rust did not do the legwork that zig did to bundle libc and a working linker, and Cargo is exceptionally naive in its default configuration, so it won't even find a usable cross-linker on the system, nor even try the chronically-unfinished rustc-lld integration there is.
You can specify your own linker if you want, mold is a very popular one, and cargo-zigbuild does the same behind the scenes with zig cc as the linker.
I did something similar a couple of months ago (or a year ago? I don't remember exactly). I managed to cross-compile to windows-msvc on Linux using Wine, there's a project that provides the scripts to make this easier, including the linker wrapper: <https://github.com/est31/msvc-wine-rust>. It was just for fun because Rust can already target windows-gnu and it'll use mingw64 linker.
Rust's approach to things is normally to provide the basic foundation and let the community build on top of it. I personally like this approach, but it also has this downside of people not knowing they may need an external/community built tool to accomplish what they want.
Zig ships all the bits you need for a C/C++ toolchain including things like the C library in some cases (IIUC).
Rust could use libclang to make a "rustc cc" just like zig's. But I get the sense that it is probably not a goal of the project to have this functionality.
https://github.com/floooh/sokol-tools/blob/master/build.zig
Here is a tutorial: https://www.zvm.app/tutorials/zig-build-cpp.html
Dependencies in build.zig.zon are downloaded in to ~/.cache/zig/p/<hash> (incidentally, this means you need to mangle the hash if you are copying and pasting the hash for a dependency, at least currently. Dependency hashes are a sore spot tbh, and needs to be better)
Then when you are using said dependency in your build.zig, the function provided will refer to that source artifact in .cache.
At least this seems to be the case. I write a decent amount of zig, but haven’t dove too much in to the build system till recently, when I tried (and failed due to translate-c bugs), to get some C libraries added to zig using only zig build.
.dependencies = .{
.zstd = .{
.url = "git+https://github.com/facebook/zstd.git#v1.5.5",
.hash = "1220185ad79a437fd9f148d1422ff756287534c79a0712105039b4034031480e41a9",
},
},
You then refer to that with dep = b.dependency(...) and can get paths to the unpacked source with dep.path(...)I looked into some of these solutions earlier and the licensing status of doing this is pretty grey and likely violates some of the toolchain licenses.
For personal use, that's not really an issue. It's far easier than trying to get a decently performing OSX runner somewhere, and I don't see Apple caring at all.
Use caution if you are bringing this into a commercial environment.
Theoretically this could be avoided by making a stub library, but the way namespacing works on OS X means that's tricky.
And also header files which are also part of macOS SDK, as the project claims to support C codes.
That said I wonder what Apple would do if this is used outside of that case...
0: https://brandingirons.com/products/basic-fire-heated-brandin...
They don't mind what people do for personal use. Just don't try and turn it into a commercial product.
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...
GOOS=darwin GOARCH=arm64 go build -o bin/app-silicon-darwin app.goBecause at the moment, "cross-compilation" with Crystal still requires you to be on the targeted system.
https://crystal-lang.org/reference/1.11/syntax_and_semantics...
The good part of this is that I can use a standard Linux host now to just build everything. Very nice!
Code signing is required for aarch64 macs unless they have SIP disabled, so this is kind of important.
I get away with distributing internal tools to my team completely ad-hoc signed, as long as I download them with cURL or SFTP. Downloading with a browser taints them, of course, and gatekeeper will prevent you from running them.
You can avoid gatekeeper problems by clearing the xattrs on the file. If they're internal you can also just distribute over a network share and it's not an issue.
*the building blocks
Maybe an artist (for example, you) could donate his or her time and provide them with a better logo for free.
Surely they could ask an artist to volunteer their time just as they volunteered theirs?
Unfortunately "I spent a lot of time on this thing you have no interest in or relation to" is not a very convincing argument in the FOSS world.
Neither is "I'm not going to contribute a damned thing, but nonetheless the team behind this free product needs to spend more time and/or money to make me happy."
If you don't like the logo, well... that sounds a lot like a personal problem to me.
Even if you take a hard line on the debate on model training data, this is an utterly harmless case, and certainly not worth the gut punch threads like this cause to someone who is just trying to share their open source project with the community.
Also, you don’t in fact know that the model used to generate this was trained with art used without consent.
It is just as easy to grab some CC-licensed images and throw them together in an image editor, like nearly every other FOSS project does at this stage.
I'm more than happy to make to make the switch and give credit to a proper artist if there's one willing to work for free.
I wanted to add some sort of image to the repository README, and it seemed like the simplest way to do so.
https://en.m.wikipedia.org/wiki/Cross_compilation
So compile on Linux, run on macOS without Rosetta