-
Notifications
You must be signed in to change notification settings - Fork 719
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
Cross-compiling from Linux to aarch64-apple-darwin
(Apple Silicon) doesn't work with osxcross
#1442
Comments
If you look at arm_arch.h you can see that it is expecting the compiler to set The discussion in rust-lang/rust-bindgen#1211 makes me think that maybe rust-lang/cc-rs#542 is the issue, as |
Oh, that's a good hunch. Yes, I'm pretty sure that in "apple lingo" the architecture is called "arm64", not aarch64. I was actually surprised that the rust triple was aarch64. It's understandable that the Rust team went with a unified arch name though (we faced the same issue at work in a different context and also opted for aarch64 everywhere). Is |
It can be patched. Patching might provide some kind of temporary workaround. But the real issue is "Why isn't the C compiler defining the symbols it should be defining?" Because there might be other things it's not correctly configured to do, which impact the rest of the C and assembly code. |
|
|
I am on |
@rnbguy I'm not entirely convinced that you are seeing the same issue I do (though they might be related) |
@sztomi I think you are right. but |
Ok, for some weird reason this works:
But only the aarch command gives:
|
any ideas? |
I am digging in to this issue as well. No idea why clang couldn't handle these |
From what I saw digging in this, it's something missing from clang osx, it was missing |
"worked" could compile but didn't test it |
I am getting the same error, I am on an m1 mac running an |
Look at build.rs for the logic around setting the
Try expanding this to macOS by changing the conditions to allow macos. |
I apologize if this question is stupid, forgive me, I just picked up rust. |
This GitHub issue is about targetting |
I wanted to know what the build.rs was seeing, added this panic:
so now I know what I'm looking for. trying a specific flavor:
perhaps too restrictive by arch but just a proof of concept. and when I build I still get a failure like:
|
The stuff regarding |
running into a related problem trying to cross compile on x86_64 linux to aarch64-apple-darwin:
|
it's using cc not aarch64-apple-darwin, whats your |
it's empty - i also noticed after the fact that cross doesn't have a Docker image for |
I do, if you really need it https://github.com/orgs/Higenku/packages/container/package/b%2Fbase |
Cross-compiling from arm64 to x86 is broken due to briansmith/ring#1442
Cross-compiling from arm64 to x86 is broken due to briansmith/ring#1442
Hi, |
If you are using Linux or windows under WSL, you can compile it with osxcross can't remember if they have clang 21.1 you might need to compile clang and llvm to get that version. |
Hello there! lets go first with your configuration file :) [target.x86_64-apple-darwin]
ar = "/home/developer/osxcross/target/bin/..." # I known there is a ar here somewhere, you might wanna try using it
linker = "/home/developer/osxcross/target/bin/o64-clang" # it's better to use this one as I found issues trying to use the extended name (don't known why tho)
# In my tests, leaving the profile configuration as default worked better than trying to mess with it In your first error:
It's trying to use ld, which in linux doesn't have -dynamic flag, I think this solves itself once you change the ALSO: out of curiosity, why are you trying to compile rust's source code? They already provide binaries for apple's systems Recommendation! Take a look at https://github.com/cross-rs/cross for cross compilation, they did a pretty nice job there |
can you maybe share your source code in a gists so that I can take a look at it? |
@lmtr0 Good advice, I did exactly as you suggest (in .cargo/config.toml):
^ so you need to set both the linker and ar.
It's not fun and you are almost certainly better off building clang if you are targeting macOS. Otherwise with gcc, you will have to have one toolchain per target. I suggest either using something like ct-ng to build it or fetch a prebuilt one from toolchains.bootlin.com. |
thanks tryed binary files from toolchains.bootlin.com but did not work for me error: linking with error: could not compile where did you get the binary files: x86_64-apple-darwin21.2-clang x86_64-apple-darwin21.2-ar ? when running: build_apple_clang.sh got only: osxcross/build/clang-17/build_stage1/bin/clang-17 |
https://github.com/tpoechtrager/osxcross |
OK, I think there has been a misunderstanding on how the cross compilation works. Let me try to explain it: After successfully building your toolchain, you must locate your binaries (If I remember correctly they should be inside a target folder. make records of the necessary Now the most important part: [target.x86_64-apple-darwin]
linker = "{THE PATH YOU RECORDED}/x86_64-apple-darwin{something}-clang"
ar = "{THE PATH YOU RECORDED}/x86_64-apple-darwin{something}-ar"
[target.aarch64-apple-darwin]
linker = "{THE PATH YOU RECORDED}/aarch64-apple-darwin{something}-clang"
ar = "{THE PATH YOU RECORDED}/aarch64-apple-darwin{something}-ar" as pointed out in the start of the discussion The reason why @ds2k5 build didn't work is that you are trying to build a macos binary with a linux compiler, That will not work. now running |
hi thanks when using and run ./build.sh got this error:
|
Hmm, can you try other sdks? |
I use version 11.3 |
sure I did in the past.... 10.12 works .... but there is no aarch64-apple-darwin{something}-clang |
Ok will try |
there is no aarch-apple-darwin*-clang after run ./build.sh with MacOSX10.13.sdk.tar.xz in tarballs dir
|
I am sorry..... did not expand so I did't see the: https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz will build again |
Ok. FYI @ds2k5, the osxcross github states
|
Thanks a lot - and sorry for my fault lrwxrwxrwx 1 developer developer 31 Sep 18 15:57 aarch64-apple-darwin20.4-clang -> x86_64-apple-darwin20.4-wrapper But building did not work: cargo build --target aarch64-apple-darwin --release ~/.cargo/config.toml
|
Did you run cargo clean and then cargo run? |
yes
|
Do you have lld installed? |
yes
|
What happens when you try
|
thank you so much !!! - works with warning
|
awesome, please test the executables inside a macos environment to make sure :) |
I dont have this kind of hardware ..... will ask some people..... and let you know! thanks at lot again! |
Awesome 👍
Obter o Outlook para Android<https://aka.ms/AAb9ysg>
…________________________________
From: ds2k5 ***@***.***>
Sent: Monday, September 18, 2023 12:23:27 PM
To: briansmith/ring ***@***.***>
Cc: lmtr0 ***@***.***>; Mention ***@***.***>
Subject: Re: [briansmith/ring] Cross-compiling from Linux to `aarch64-apple-darwin` (Apple Silicon) (Issue #1442)
awesome, please test the executables inside a macos environment to make sure :)
I dont have this kind of hardware ..... will ask some people.....
and let you know!
thanks at lot again!
—
Reply to this email directly, view it on GitHub<#1442 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANXP6KRY4HBBRT3ZG2Z4N3LX3BRO7ANCNFSM5KNYXVGA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
or did you know a way to emulate with qemu a M1 CPU ? intel based mac there is a project at github https://github.com/kholia/OSX-KVM |
yeah, i only known that one, and i got it working once |
aarch64-apple-darwin
(Apple Silicon)aarch64-apple-darwin
(Apple Silicon) doesn't work with osxcross
Hi friends. Please post a PR that adds support for |
so is there any fix for it? |
I'm able to cross compile ring from Linux to
x86_64-apple-darwin
by using the osxcross toolchain. I set the following in .config/cargo.toml:And I set
CC=o64-clang
andCXX=o64-clang++
before calingcargo build --target <target>
. This works fine for x86_64 but for aarch64 I get the following:The Apple SDK is 12.0 so it should in theory support building for M1. Note that this issue is the opposite of #1332: that issue is about cross-compiling from an M1 host to Linux, this one is the other way around.
The text was updated successfully, but these errors were encountered: