Difference between revisions of "Cross Compiler"

From Void Linux Wiki
Jump to: navigation, search
(Introduction to installing pre-built cross compilers.)
 
m (Installation: --regex seems to always work when it's placed before the -Rs)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Void Linux's pre-built cross-compiler toolchains. These allow you to compile binaries for a foreign host.
+
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 for distinguishing toolchains. Other distro's tuples generally follow the ARCH-VENDOR-OS-LIBC model, however on void, we use ARCH-OS-LIBC tuples to identify our toolchains.
+
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 {{ic|arm-unknown-linux-gnueabihf}}. Void Linux's comparable toolchain would be {{ic|arm-linux-gnueabihf}}. The package name has removed the $VENDOR identifier from the toolchain name.
+
For example, other distro's may use {{ic|arm-unknown-linux-gnueabihf}}. Void Linux's comparable toolchain would be {{ic|arm-linux-gnueabihf}}. The package has removed the VENDOR identifier from the toolchain name.
  
 
= 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 -Rs --regex 'cross-(\w)+-(\w)+(\w)+'}}
+
{{bc|xbps-query --regex -Rs 'cross-(\w)+-(\w)+(\w)+'}}
  
Once you have found your target architecture, os and glibc 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.
 
{{bc|xbps-install -Sy cross-arm-linux-gnueabihf}}
 
{{bc|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:
 +
{{bc|./xbps-src -h}}
 +
 +
Using the {{ic|arm-linux-gnueabihf}} toolchain we installed above, we can can cross compile with it.
 +
{{bc|./xbps-src -a armv6hf pkg <pkgname>}}
  
 
[[Category:Packages]]
 
[[Category:Packages]]

Revision as of 11:58, 9 June 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>