osandov / drgn

Programmable debugger
Other
1.78k stars 165 forks source link

Support cross-compiling drgn #431

Closed osandov closed 1 month ago

osandov commented 2 months ago

I have heard a handful of anecdotes about drgn failing to cross-compile, although I haven't tried it myself. I'm guessing that the issue is mainly how we conflate the build Python, which we to generate code in several places, and the host/target Python. We should make this work. If anyone has a specific way they've tried to cross-compile that doesn't work, I'd love to see it.

osandov commented 2 months ago

The latest reported issue was Gentoo-specific. This is the fix to the ebuild: https://gist.github.com/osandov/59dd12a575c8026bda009d609e184f93.

osandov commented 2 months ago

Filed a Gentoo bug: https://bugs.gentoo.org/939942

osandov commented 1 month ago

Cross-compiling does seem to work in general. gpep517 seems to work pretty well for this. Something along these lines should work:

$ target=aarch64-linux-gnu
$ sysroot=/path/to/sysroot
$ wheel_dir=/path/to/output
$ CC="$target-gcc" CFLAGS="--sysroot $sysroot -isystem $sysroot/usr/include" CONFIGURE_FLAGS="--host=$target" gpep517 build-wheel --backend setuptools.build_meta:__legacy__ --sysroot "$sysroot" --output-fd 1 --wheel-dir "$wheel_dir"

It's also possible to do the same thing without gpep517 with some effort.