Using the multilib GCC toolchain, as currently documented in depends/README.md
, has several issues, such as:
-
The
g++-multilib
package conflicts with platform-specific cross-compiler packages. This means it is not possible to cross compile fori686
and other platforms using the same set of installed packages. -
The
g++-multilib
package is not available forarm64
:
0$ sudo apt install g++-multilib
1Reading package lists... Done
2Building dependency tree... Done
3Reading state information... Done
4E: Unable to locate package g++-multilib
- Managing the multilib GCC toolchain requires additional code in both depends and Guix scripts.
This PR addresses all the issues mentioned above by switching from multilib to platform-specific toolchains.
Also see #22456.
Here are examples of building for different scenarions:
- Linux,
x86_64
orarm64
, building with depends natively:
0$ gmake -C depends -j $(nproc)
1$ cmake -B build --toolchain depends/$(./depends/config.sub $(./depends/config.guess))/toolchain.cmake
2$ cmake --build build -j $(nproc)
- Linux,
x86_64
orarm64
, cross compiling fori686-pc-linux-gnu
:
0$ sudo apt install g++-i686-linux-gnu binutils-i686-linux-gnu
1$ export HOST=i686-linux-gnu
2$ gmake -C depends -j $(nproc)
3$ cmake -B build-${HOST} --toolchain depends/${HOST}/toolchain.cmake
4$ cmake --build build-${HOST} -j $(nproc)
- Linux,
x86_64
, cross compiling forarm64
:
0$ sudo apt install g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
1$ export HOST=aarch64-linux-gnu
2$ gmake -C depends -j $(nproc)
3$ cmake -B build-${HOST} --toolchain depends/${HOST}/toolchain.cmake
4$ cmake --build build-${HOST} -j $(nproc)
- Linux,
arm64
, cross compiling forx86_64
:
0$ sudo apt install g++-x86-64-linux-gnu binutils-x86-64-linux-gnu
1$ export HOST=x86_64-linux-gnu
2$ gmake -C depends -j $(nproc)
3$ cmake -B build-${HOST} --toolchain depends/${HOST}/toolchain.cmake
4$ cmake --build build-${HOST} -j $(nproc)