pybind / pybind11_bazel

Bazel wrapper around the pybind11 repository
Other
100 stars 54 forks source link

Cross compile how to #67

Closed zhzhzoo-autra closed 8 months ago

zhzhzoo-autra commented 9 months ago

I'm cross compiling my code to aarch64 from an amd64 machine. Any idea on what I should change this repo to support cross compiling? Thanks!

rwgk commented 9 months ago

@junyer, @rickeylev in case they have suggestions.

I'm not sure this ever worked for cross-compiling. I'd guess not.

junyer commented 9 months ago

I think it's less about pybind11_bazel and more about toolchains, but I must defer to @rickeylev's expertise in these matters. (When building the google-re2 wheels, we currently just pass --cpu=darwin_arm64 to Bazel in order to cross-compile from Intel to ARM on macOS, but it's entirely possible that this works only due to sheer luck...)

junyer commented 8 months ago

Indeed, the google-re2 wheels no longer build with Bazel 7. Apart from RE2 needing to replace uses of --cpu, it's possible that pybind11_bazel itself will need some tweaking. :(

junyer commented 8 months ago

Okay, the google-re2 wheels are building with Bazel 7. @zhzhzoo-autra, are you able to disclose anything more about your build? I can hopefully now provide some useful advice. pybind11_bazel itself shouldn't require changes, but Bazel 7 will need some additional configuration with regard to platforms and toolchains. (None of which is really about pybind11_bazel, but it's arguably one of the simpler contexts in which to learn about these things...)

zhzhzoo-autra commented 8 months ago

Okay, the google-re2 wheels are building with Bazel 7. @zhzhzoo-autra, are you able to disclose anything more about your build? I can hopefully now provide some useful advice. pybind11_bazel itself shouldn't require changes, but Bazel 7 will need some additional configuration with regard to platforms and toolchains. (None of which is really about pybind11_bazel, but it's arguably one of the simpler contexts in which to learn about these things...)

Thanks very much for your attention! I properly configured platforms and toolchains. The problem I met was that bazel couldn't find /usr/include/aarch64-linux-gnu/python3.8/pyconfig.h. This should not be pybind11_bazel's problem. This was because I didn't set up python toolchain correctly. After adding include/aarch64-linux-gnu/python3.8/pyconfig.h to my python toolchain configuration I managed to build everything.

junyer commented 8 months ago

Ahh. Glad to hear. :)