-
Notifications
You must be signed in to change notification settings - Fork 10
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
Incorrect linking of arm64 library with x86_64 compilation #17
Comments
CC @Mystery-Golden-Retriever (problem originated on his laptop) |
Thanks for the report! Could you set the environment variable Determining the architecture using CMake (regardless of what py-build-cmake does) is a bit tricky on Apple Silicon: https://cmake.org/cmake/help/latest/variable/CMAKE_HOST_SYSTEM_PROCESSOR.html#macos-platforms Note that py-build-cmake does not enable cross-compilation on its own, except for the following:
This is done in order to support cibuildwheel, which uses these environment variables to drive cross-compilation. Just thinking out loud: are you able to build your project stand-alone (without py-build-cmake, just invoking CMake directly) when using an x86_64 version of CMake on an M2 machine? Personally, I would treat building for x86 on an M2 as a cross-compilation situation. In other words, it's best to take control of the cross-compilation entirely, and write an appropriate CMake toolchain file, as well as a py-build-cmake cross-configuration as explained in https://tttapa.github.io/py-build-cmake/Cross-compilation.html. With the right CMake toolchain file, you can prevent CMake from picking up packages for the build system that were not intended for the target system. For the further improvement of py-build-cmake, we would have to determine when to switch CMake into cross-compilation mode on macOS:
|
I have an M1 mac, but don't have an Anaconda installation. I have a miniforge conda installed and would rather not try overloading it with an Anaconda unless really needed. I can try the following though.
It doesn't look like CMake releases an x86_64-only build, just a universal one, so I'll try that. When forcing
We did previously check the M2 environment and verified that no I can test manually setting different environment variables for cmake (again forcing x64_64) to imitate what you think py-build-cmake would/should do, if you'd like. |
Thanks, that's what I expected. I'm afraid that the issue you've encountered could be a fundamental limitation of running CMake under x86_64 emulation on an M2 mac. The problem here is that CMake does not know that the system libraries (e.g. the ones in There are (at least) two ways to handle this:
In any case, you need to provide a version of the library for the architecture you selected (an x86_64 version of yaml-cpp, in your case). And you have to make sure that CMake is able to locate that library. I'm not familiar with Homebrew, but from what I can gather, it does not support installing the same package for different architectures: https://github.com/orgs/Homebrew/discussions/2141 I don't own a macOS system myself, so you might get better suggestions over on the CMake forum or the CMake issue tracker (since the problem persists even without py-build-cmake). |
Thanks, I expected that, too, after seeing the initial failure through Anaconda. And again we don't actually need a solution to this using py-build-cmake. We're not going to do anything on our end to make this work. I just thought you should be aware of the behavior and I'm happy to help debug it as long as it doesn't turn my system upside down :). In case it wasn't clear, the universal cmake binary works fine from the CLI when we don't force It's also probably the correct behavior for cmake to compile for |
Thanks, I appreciate it! :) |
Hi Pieter. We ran into an interesting corner case running on an Apple M2 CPU running Anaconda installed for
x86_64
(which I suppose macOS then emulates for automatically). The most correct solution to the problem is simply to install Anaconda forarm64
, then everything works as expected. I thought we should report the experience anyway, in case you think there is something that can/should be done in py-build-cmake for it, though I'm not requesting that you do so.In short, py-build-cmake appears to have cmake compile for
x86-64
but cmake still tries to link against a dependent library (libyaml-cpp) that is built forarm64
. My layman's guess is that py-build-cmake is picking up thex86_64
arch from the conda execution environment (e.g., via distlib?), but the cross-compilation configuration is somehow incomplete.I'm not entirely sure what the correct thing to do should be, but I don't think it should get into a situation where it's trying to link libraries of the wrong architecture. Perhaps at least one of:
arm64
library path should not be searched.arm64
library itself should not "found" by cmake even if the path is searched.arm64
rather thanx86-64
.Cheers.
The text was updated successfully, but these errors were encountered: