-
Notifications
You must be signed in to change notification settings - Fork 17
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
Failed to build for apple darwin targets jemalloc-sys #53
Comments
I agree with all of this, however there is a much easier solution I think! |
No, in the current example, the current problem is that CC_ has been set, not because of this setting, but because after the installed cctools carries the version suffix, the osxcross tool clang wrapper cannot correctly find its own linker (possibly other There are also more problems with c/c++ code compilation, at least jemalloc/ring cannot be compiled). Note: the problem is that we build non native rust project (non pure rust project), so c/c++ compilation needs a cross-compile linker, but osxcross wrapper does not use the correct cross-compile linker. |
Well, it seems that things may not be that simple, and such a fix will cause osxcross to be unable to find the sdk based on the darwin version of the tool itself. |
Well, --target=arm64-apple-darwin does not seem to match the prefix of cctool=aarch64-apple-darwin20.4-clang.
|
After create symlink for x86_64-apple-darwin-clang target, we can build it. After create symlink for aarch64-apple-darwin-clang target, we can not build it, because cc-rs generate a target arm64-apple-darwin for the osxcross clang wrapper, which does not match the prefix ot the osxcross clang wrapper, then we change the arm64 to aarch64, it works. In conclusion: UPD: when we use the target flag carries darwin version, we do not need to create symlinks for the clang wrapper. |
UPD: Without modifying cross-rs, a simple solution like this worked for me: # Cross.toml
[target.x86_64-apple-darwin]
image = "your image"
#pre-build = ["rm /usr/bin/ld && ln -s /opt/osxcross/bin/x86_64-apple-darwin20.4-ld /usr/bin/ld"]
env.passthrough = ["CFLAGS_x86_64_apple_darwin=-fuse-ld=x86_64-apple-darwin20.4-ld"]
[target.aarch64-apple-darwin]
image = "your image"
#pre-build = ["rm /usr/bin/ld && ln -s /opt/osxcross/bin/aarch64-apple-darwin20.4-ld /usr/bin/ld"]
env.passthrough = ["CFLAGS_aarch64_apple_darwin=-fuse-ld=aarch64-apple-darwin20.4-ld"] |
Try to build jemalloc-sys (0.5.4, 0.3.2), always get a ld linker error:
Follow issues:
Our cross image already sets osxcross path (/opt/osxcross/bin) in PATH.
Furthermore, we can find that the tools generated under the osxcross bin path all have the darwin version suffix (such as x86_64-apple-darwin20.04-clang), which will cause clang to be unable to find the correct ld (x86_64-apple-darwin-clang) when linking, and fallback to the default ld (/usr/bin/ld).
Why generated targets with darwin version suffix, becasue osxcross build.sh does that by default:
How to solve these problems:
First we need to remove the darwin version suffix from the tool chain of the compiled target to make some cctools work correctly, so the most intuitive way we use is to generate new cctool symlinks without darwin version for cctools.
Then we need put symlink in bin path such /usr/bin, if we won't do that, we need to ensure that osxcross bin path takes precedence over other bin path which containing ld searches. Since cross put the osxcross bin path at the end of PATH, we can put symlinks in /usr/bin, which will not conflict with other bin toolchains. Fixed by:
The text was updated successfully, but these errors were encountered: