Skip to content
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

patches for building gcc on Apple Silicon #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

richard-vd
Copy link

@richard-vd richard-vd commented Aug 8, 2021

The minimal patch by @jannau in #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.

@richfelker
Copy link
Owner

Can you cite anything justifying these patches? I suspect they're right but I'd like to see some rationale.

@jannau
Copy link

jannau commented Aug 10, 2021

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.

@richard-vd
Copy link
Author

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!

@johnelliott
Copy link

johnelliott commented Oct 30, 2021

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. 👍

@richard-vd
Copy link
Author

Added gcc-10.3.0 patch to this branch.

@richard-vd
Copy link
Author

Squashed yesterday's gcc-10.3.0 patch with the initial commit of this PR.

Sourced from:
* gcc-mirror/gcc@53a9065 darwin-aarch64-config (for gcc-6.5.0 .. gcc-10.3.0)
* gcc-mirror/gcc@834c874 darwin-aarch64-self-host-driver (for gcc-6.5.0 .. gcc-10.3.0)
* gcc-mirror/gcc@590febb darwin-align-pch_address_space-to-16k (for gcc-6.5.0 .. gcc-9.2.0)
@richard-vd
Copy link
Author

Redone Apple silicon patches for gcc-6.5.0 .. gcc-10.3.0 using commits from gcc upstream.

@richard-vd
Copy link
Author

Added GCC 11.

sfackler added a commit to sfackler/crosstool-ng that referenced this pull request Mar 5, 2023
sfackler added a commit to sfackler/crosstool-ng that referenced this pull request Mar 5, 2023
sfackler added a commit to sfackler/crosstool-ng that referenced this pull request Mar 5, 2023
sfackler added a commit to sfackler/crosstool-ng that referenced this pull request Mar 7, 2023
sfackler added a commit to sfackler/crosstool-ng that referenced this pull request Mar 8, 2023
This adds backports of a couple of patches necessary to support macOS
arm64 hosts for gcc. It was ported from
richfelker/musl-cross-make#129 with some small
fixups to make the patches apply cleanly.

Signed-off-by: Steven Fackler <sfackler@gmail.com>
cpackham pushed a commit to crosstool-ng/crosstool-ng that referenced this pull request Mar 13, 2023
This adds backports of a couple of patches necessary to support macOS
arm64 hosts for gcc. It was ported from
richfelker/musl-cross-make#129 with some small
fixups to make the patches apply cleanly.

Signed-off-by: Steven Fackler <sfackler@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants