Difference between revisions of "Cross Compiler"

From Void Linux Wiki
Jump to: navigation, search
m (Installation: --regex seems to always work when it's placed before the -Rs)
(Installation)
 
Line 7: Line 7:
 
= Installation =
 
= Installation =
 
Void offers pre-build toolchains. Check which toolchains are available.
 
Void offers pre-build toolchains. Check which toolchains are available.
{{bc|xbps-query --regex -Rs 'cross-(\w)+-(\w)+(\w)+'}}
+
{{bc|xbps-query --regex -Rs 'cross-(\w)+-(\w)+-(\w)+'}}
  
 
Once you have found your target architecture, os and libc implementation, you can install it. The example below will install the original Raspberry Pi's toolchain.
 
Once you have found your target architecture, os and libc implementation, you can install it. The example below will install the original Raspberry Pi's toolchain.

Latest revision as of 05:46, 9 August 2019

Void Linux's cross-compiler toolchains. These allow you to compile binaries for a foreign host.

Compared to most other Linux distributions, Void linux uses triplet tuples to distinguish toolchains. Other distro's tuples generally follow the ARCH-VENDOR-OS-LIBC model, however on Void Linux, we use ARCH-OS-LIBC tuples to identify our toolchains.

For example, other distro's may use arm-unknown-linux-gnueabihf. Void Linux's comparable toolchain would be arm-linux-gnueabihf. The package has removed the VENDOR identifier from the toolchain name.

Installation

Void offers pre-build toolchains. Check which toolchains are available.

xbps-query --regex -Rs 'cross-(\w)+-(\w)+-(\w)+'

Once you have found your target architecture, os and libc implementation, you can install it. The example below will install the original Raspberry Pi's toolchain.

xbps-install -Sy cross-arm-linux-gnueabihf

Use with Xbps-src

Xbps-src packages may be cross-compiled if the build script been adapted to it. You may see which cross-compilers are currently available by using:

./xbps-src -h

Using the arm-linux-gnueabihf toolchain we installed above, we can can cross compile with it.

./xbps-src -a armv6hf pkg <pkgname>