Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| externaltoolchain [2015/04/12 20:56] – CraigRodrigues | externaltoolchain [2020/09/15 15:51] (current) – BrooksDavis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ==== External Toolchain Support ==== | + | ====== External Toolchain Support |
| %%FreeBSD%% needs support for external toolchains to ease testing of new compiler versions, support compilers that don't make sense to integrate into the base, and speed builds (by avoiding building of bootstrap compilers). | %%FreeBSD%% needs support for external toolchains to ease testing of new compiler versions, support compilers that don't make sense to integrate into the base, and speed builds (by avoiding building of bootstrap compilers). | ||
| - | ===== XCC ===== | + | ===== Using pre-built toolchain packages |
| + | |||
| + | The simplest way to do this is with the pre-built toolchain packages. | ||
| + | |||
| + | ==== Cross-building with a pre-built toolchain package ==== | ||
| + | |||
| + | For example, to build powerpc64 using GCC 6, you would do: | ||
| + | |||
| + | < | ||
| + | pkg install powerpc64-gcc6 | ||
| + | make CROSS_TOOLCHAIN=powerpc64-gcc6 TARGET=powerpc TARGET_ARCH=powerpc64 buildworld | ||
| + | make CROSS_TOOLCHAIN=powerpc64-gcc6 TARGET=powerpc TARGET_ARCH=powerpc64 installworld DESTDIR=/ | ||
| + | make CROSS_TOOLCHAIN=powerpc64-gcc6 TARGET=powerpc TARGET_ARCH=powerpc64 distribution DESTDIR=/ | ||
| + | </ | ||
| + | |||
| + | To build arm64 with LLVM11, you would do: | ||
| + | |||
| + | < | ||
| + | pkg install llvm11 | ||
| + | make CROSS_TOOLCHAIN=llvm11 TARGET=arm64 buildworld | ||
| + | make CROSS_TOOLCHAIN=llvm11 TARGET=arm64 installworld DESTDIR=/ | ||
| + | make CROSS_TOOLCHAIN=llvm11 TARGET=arm64 distribution DESTDIR=/ | ||
| + | </ | ||
| + | |||
| + | ==== Use cross compiler to build native compiler ==== | ||
| + | |||
| + | < | ||
| + | cd / | ||
| + | make CROSS_TOOLCHAIN=powerpc64-gcc6 TARGET=powerpc TARGET_ARCH=powerpc64 CROSS_SYSROOT=/ | ||
| + | cd / | ||
| + | make CROSS_TOOLCHAIN=powerpc64-gcc6 TARGET=powerpc TARGET_ARCH=powerpc64 CROSS_SYSROOT=/ | ||
| + | </ | ||
| + | |||
| + | ===== Under the hood ===== | ||
| + | |||
| + | The rest of this page provides details on how this works and how to override individual components if desired. | ||
| + | |||
| + | ==== XCC ==== | ||
| The XCC approach works with top level build targets (buildworld, | The XCC approach works with top level build targets (buildworld, | ||
| - | ====== How to use ====== | + | ==== How to use ==== |
| If is possible to replace both the compiler and binutils. | If is possible to replace both the compiler and binutils. | ||
| Line 13: | Line 50: | ||
| Both the compiler and binutils must be configured to support --sysroot to find headers and libraries. | Both the compiler and binutils must be configured to support --sysroot to find headers and libraries. | ||
| - | ===== Using an external compiler | + | ==== Using an external compiler ==== |
| To use an external compiler such as clang, set the variables XCC, XCXX, and XCPP when building and installing. | To use an external compiler such as clang, set the variables XCC, XCXX, and XCPP when building and installing. | ||
| Line 33: | Line 70: | ||
| If the compiler is clang and the target architecture is not the same as the build host then an appropriate target triple will be created and passed to clang to support native cross compilation. | If the compiler is clang and the target architecture is not the same as the build host then an appropriate target triple will be created and passed to clang to support native cross compilation. | ||
| - | ===== Using an external binutils | + | ==== Using an external binutils ==== |
| To use an external binutils, set the XAS, XAR, XLD, XNM, XOBJDUMP, XRANLIB, and XSTRINGS. | To use an external binutils, set the XAS, XAR, XLD, XNM, XOBJDUMP, XRANLIB, and XSTRINGS. | ||
| - | ====== Caveats | + | ==== Caveats ==== |
| To use XCC, you must not set any of the variables that can be overridden by X* variables in / | To use XCC, you must not set any of the variables that can be overridden by X* variables in / | ||
| - | External, cross-building gcc toolchains support is still somewhat weak (which means doesn' | + | ===== See Also ===== |
| - | Cross building generally works only with clang 3.4 or whatever the current in-tree compiler is (and often slightly newer tress). | + | [[ExternalGCC]] |
| - | There are some bootstrapping issues still if you want to build the in-tree compiler as part of the build. | + | ---- |
| - | ====== Status ====== | + | {{tag>Project}} |
| - | Patches have been committed to HEAD. | + | |
| - | Works with: | + | |
| - | * [[https:// | + | |
| - | * [[https:// | + | |
| - | + | ||
| - | ====== Use pre seeded configurations ====== | + | |
| - | + | ||
| - | The following xtoolchain ports are available: | + | |
| - | * devel/ | + | |
| - | * devel/ | + | |
| - | * devel/ | + | |
| - | + | ||
| - | For example, to build using powerpc64-xtoolchain-gcc, | + | |
| - | + | ||
| - | < | + | |
| - | pkg install devel/ | + | |
| - | make CROSS_TOOLCHAIN=powerpc64-gcc TARGET=powerpc TARGET_ARCH=powerpc64 buildworld | + | |
| - | </code> | + | |