tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.81k stars 320 forks source link

Add support for aarch64 builds #326

Closed alex-berger closed 2 years ago

alex-berger commented 2 years ago

This PR adds support for aarch64 builds to osxcross.

So far osxcross only worked on x86_64 hosts, with this changes osxcross will also work on aarch64 (ARM 64 bit) hosts. This is necessary to support for example cross compiling from aarch64 based Linux hosts.

tpoechtrager commented 2 years ago

OSXCross already works on AArch64 hosts. In fact I have been using OSXCross for several years on AArch64 now. Theses changes are unnecessary. There is no reason to replace x86_64. It's just a tool prefix. The produced tools are able to handle ARM and x86, no matter what you pass to --target.

alex-berger commented 2 years ago

OSXCross already works on AArch64 hosts. In fact I have been using OSXCross for several years on AArch64 now. Theses changes are unnecessary. There is no reason to replace x86_64. It's just a tool prefix. The produced tools are able to handle ARM and x86, no matter what you pass to --target.

@tpoechtrager Very interesting, because it did not work for us until we applied those changes. Without those changes the binaries were always compiled for x86_64 and thus could not be run on an aarch64 Linux host. We are using clang (not gcc) to compile osxcross.

tpoechtrager commented 2 years ago

You must either add -arch arm64 to your compiler flags or use the correct tool set.

xcrun clang -arch arm64 arm64-apple-darwinXX-clang

Alexander Berger @.***> schrieb am Fr., 21. Jän. 2022, 11:25:

OSXCross already works on AArch64 hosts. In fact I have been using OSXCross for several years on AArch64 now. Theses changes are unnecessary. There is no reason to replace x86_64. It's just a tool prefix. The produced tools are able to handle ARM and x86, no matter what you pass to --target.

@tpoechtrager https://github.com/tpoechtrager Very interesting, because it did not work for us until we applied those changes. Without those changes the binaries were always compiled for x86_64 and thus could not be run on an aarch64 Linux host. We are using clang (not gcc) to compile osxcross.

— Reply to this email directly, view it on GitHub https://github.com/tpoechtrager/osxcross/pull/326#issuecomment-1018376055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASY5JEIPFMNMMM3K57BGSTUXEYBJANCNFSM5MPDIIVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

tpoechtrager commented 2 years ago

Nvm. I think I got you wrong. Could you provide me the output of OCDEBUG=1 ./build.sh without the patch applied? Thanks!

alex-berger commented 2 years ago

@tpoechtrager My bad, you are right. Now I can build aarch64 binaries on an aarch64 host. I guess there must have been something wrong with our CI setup (at the time we stumbled over this). I will investigate further, but in the mean time please ignore this PR. I am sorry for the irritation.