FiloSottile / homebrew-musl-cross

Homebrew Formula for static-friendly musl-based GCC macOS-to-Linux cross-compilers

Home Page:https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide symlink for `musl-gcc`?

WesleyAC opened this issue · comments

Many scripts expect the command musl-gcc to exist. Making a symlink in my $PATH from musl-gcc to $(which x86_64-linux-musl-gcc) caused scripts that have this expectation to work. Seems like it'd be useful to provide this by default?

I am not sure we should assume x86_64 like that. Is there a convention around it, @richfelker?

I don't think it's a good idea for scripts to assume musl-gcc, or to symlink it to cross compilers. That's the wrapper script shipped for minimal out-of-the-box use of musl on a glibc host without actually installing a proper toolchain, and its arch corresponds to whatever arch your glibc-based host is, i.e. it's a "native" compiler not a cross one.

In that sense though doesn't it do the same thing that x86_64-linux-musl-gcc does on an x86_64 macOS?

Semantically, musl-gcc matching the wrapper shipped with musl would produce musl-linked binaries that you could run on your Mac, which isn't a thing. x86_64-linux-musl-gcc on the other hand is a cross compiler that produces musl-linked binaries to run on x86_64 Linux.

Fair enough, it sounds like these scripts might get confused if they can't then run the binaries they compiled, and users might want to target different architectures at that point. We'll let them explicitly symlink /usr/local/bin/musl-gcc to /usr/local/opt/musl-cross/bin/x86_64-linux-musl-gcc if they wish.

@FiloSottile I almost gave up on trying to compile to x86_64-unknown-linux-musl from "macOS Mojave", until I randomly try this small note from an article on AWS blog

On my system, some of the dependencies did not pick up the configured linker automatically and tried to use musl-gcc anyway. To get around this quickly, I simply created a symlink to the new linker:

$ ln -s /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

Now I can finally use FiloSottile/homebrew-musl-cross as expected, but without this symlink stuff, the ring dependency of rustls-tls failed to compile in my project.

I'd suggest to copy your previous comment in the README of this repository, because it seems like really important to know for ppl which just want to make things work quickly.

Thank you