[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cross Compilation with CMake and mk-sbuild



> if your question is about how to do cross compilation on a Debian system then
> you came to the right place!

Looks like I'm at least partially in the right place, thanks for the welcome!

> I happen to be the maintainer of sbuild in Debian and I never heard of the
> mk-sbuild tool. Where do you have this from and what does it do?

Oh, it seems like I'm a bit off-base here:

- https://wiki.debian.org/mk-sbuild

It seems like `mk-sbuild` is actually some kind of wrapper script for Ubuntu,
rather than a Debian tool, however it only seems to be direct convenience
wrappers around `sbuild` and `schroot` as far as I can tell.

> Why do you want to use a sysroot? Just use multi-arch and install the foreign
> architecture packages directly on your system without a foreign architecture
> chroot somewhere.

> I'm also curious where you found the information to use a sysroot for cross
> compilation. This is outdated for several years now and I do not know anybody
> who does this these days. Is there any reason you need to use a sysroot over
> just using multiarch?

Oh interesting, this is all things I've pieced together from far arguably too
many sources (basically from googling "cross compiling aarch64"), I went ahead and
dug some of them up here just in case:

- http://hypernephelist.com/2015/03/09/cross-compilation-made-easy-on-ubuntu-with-sbuild.html
- https://discourse.cmake.org/t/linux-cross-compile-x64-to-aarch64/1752
- https://discourse.cmake.org/t/cross-compile-for-aarch64-on-ubuntu/2161
- https://github.com/rsenn/cmake-toolchains/blob/master/aarch64-linux-gnu.toolchain.cmake
- https://github.com/sony/flutter-embedded-linux/blob/master/cmake/cross-toolchain-aarch64-template.cmake

I had some previous experience with using sysroots for Android which is
apparently still used extensively, so I didn't see anything all that wrong with
using that for cross-compiling for other systems (Aarch64 in my case).

Additionally, most of this worked just fine until I used `find_library` (which
is recommended for CMake to get the -lm library) hence the confusion when
everything stopped working.

My main reason for using sysroots is really just to have an easy place to collect thirdparty
packages from, which in my case are zlib, libpng, libOpenEXR and a few others,
but from what you mention here it seems like a lot of this information is
out-of-date or incorrect. I didn't really come across "mutliarch" at all while I was looking this up.

I did a bit more googling (using the multiarch keyword now). I guess this is a good
place to read-up on using multiarch packages to download my dependencies?

- https://wiki.debian.org/Multiarch/HOWTO

Best regards,
Gustaf

Den ons 1 feb. 2023 kl 10:45 skrev Johannes Schauer Marin Rodrigues <josch@debian.org>:
Hi,

Quoting Gustaf Waldemarson (2023-02-01 10:17:07)
> Apologies in advance if this is the wrong place to ask this, but anyway:

if your question is about how to do cross compilation on a Debian system then
you came to the right place!

> Recently, I tried to use some Debian tools (mk-sbuild) to set up a sysroot
> for cross-compiling some CMake projects. The details of this as well as a
> test project is available:
>
>
> https://stackoverflow.com/questions/75247387/modern-cmake-cross-compiling-to-aarch64-with-sysroots/75277478
>
> Long story short though: Since the libraries in the sysroot use symlinks to
> absolute paths (relative to the root of the sysroot), they are broken during
> compilation, but are still picked up by CMake.
>
> So, I guess my question boils down to mk-sbuild itself: Is this tool really
> intended for cross-compilation, or is there a more appropriate one available?

I happen to be the maintainer of sbuild in Debian and I never heard of the
mk-sbuild tool. Where do you have this from and what does it do?

> Alternatively, is there some way of re-configuring the sysroot to use
> relative symlinks for all libraries to avoid these kinds of issues?

Why do you want to use a sysroot? Just use multi-arch and install the foreign
architecture packages directly on your system without a foreign architecture
chroot somewhere.

I'm also curious where you found the information to use a sysroot for cross
compilation. This is outdated for several years now and I do not know anybody
who does this these days. Is there any reason you need to use a sysroot over
just using multiarch?

Thanks!

cheers, josch

Reply to: