musl-cross-make
musl-cross-make copied to clipboard
patches for building gcc on Apple Silicon
The minimal patch by @jannau in richfelker/musl-cross-make#116 enables building gcc and running it natively on Apple Silicon. As I understand and have experienced it, the resulting gcc is not fully functional but for the purpose of cross compiling it is. Therefore I think this patch would be a good addition to this project.
This PR adds patches for all supported gcc versions from 6.5.0 and up.
Can you cite anything justifying these patches? I suspect they're right but I'd like to see some rationale.
Justification for the gcc/config/aarch64/aarch64.h
change is there is no CPU detection for darwin/arm64 implemented.
I have no good justification for the host_hooks change except that seems to be done in every other host-*.c file. I'm puzzled why x86 darwin works without it and I wouldn't be surprised if the patch breaks it.
I have tested the patch and it's looking good:
Using a MacBook Air M1 (Apple Silicon) and an iMac (Intel), on both machines I successfully compiled targets x86_64 and aarch64 for all gcc versions that this patch has been applied to. Then I compiled a Hello World C++ program with the resulting gcc-5.3.0 and gcc-9.2.0 and successfully ran the binaries in Linux on a Raspberry Pi 4 (aarch64) and on a Supermicro server (x86_64).
Fortunately the patch doesn't seem to break anything!
Thanks for putting this together Richard.
I just tested this branch on an M1 machine. I compiled the x86_64 target, compiled my go/cgo/sqlite program using the x86_64 target output, then ran my built program on x86. Everything seems to work. 👍
Added gcc-10.3.0 patch to this branch.
Squashed yesterday's gcc-10.3.0 patch with the initial commit of this PR.
Redone Apple silicon patches for gcc-6.5.0 .. gcc-10.3.0 using commits from gcc upstream.
Added GCC 11.