[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler [2019/07/25 19:31 (UTC)] – [Downloading required source and configuration] updated notes exagahowtos:hardware:arm:gcc-9.x_aarch64_cross-compiler [2020/02/25 19:07 (UTC)] (current) – updated to gcc-9.2.0 exaga
Line 1: Line 1:
-====== Slackware ARM gcc-9.1.x armv8 arm64 aarch64 cross-compiler for the Raspberry Pi 4 ======+====== Slackware ARM gcc-9.2.x armv8 arm64 aarch64 cross-compiler for the Raspberry Pi 4 ======
  
 === Preface === === Preface ===
  
-With the recent congruous updates to [[http://arm.slackware.com|Slackware ARM]] [~24 June 2019 - "A MILLION THANKS to MoZes!"] and the surprise arrival of the Raspberry Pi 4, this just had to be done. Creating a gcc-9.1.0 armv8 arm64 aarch64 cross-compiler with the intention of building aarch64-linux binaries from source code and turning them into Slackware packages. +With the recent congruous updates to [[http://arm.slackware.com|Slackware ARM]] [~24 June 2019 - "A MILLION THANKS to MoZes!"] and the surprise arrival of the Raspberry Pi 4, this just had to be done. Creating a 64-bit gcc-9.2.0 arm64 aarch64 cross-compiler with the intention of building aarch64-linux binaries from source code and turning them into Slackware packages. 
  
-Previous [[howtos:hardware:arm:gcc_aarch64_cross-compiler|work in this area]] had already been done in 2016/2017. However, this time we'll be compiling with gcc-9.1.0 and not gcc-5.4.0 and we'll be using a Raspberry Pi 4 Model B and not a Mk3 version. The old build scripts weren't totally useless and some of the code was reused for this project, to save time.+Previous [[howtos:hardware:arm:gcc_aarch64_cross-compiler|work in this area]] had already been done since 2016/2017. However, this time we'll be compiling with gcc-9.2.0 and not gcc-5.4.0 and we'll be using a Raspberry Pi 4 Model B and not a Mk3 version. The old build scripts weren't totally useless and some of the code was reused for this project, to save time.
  
 === Notes === === Notes ===
  
-Slackware ARM current was used on a Raspberry Pi 4 to build and install the gcc-9.1.0 aarch64-linux cross-compiler, and build the armv8 Linux kernel, modules, and device tree blob(s). This was to achieve the highest degree of compatibility possible.+Slackware ARM current was used on a Raspberry Pi 4 to build and install the gcc-9.2.0 aarch64-linux cross-compiler, and build the armv8 Linux kernel, modules, and device tree blob(s). This was to achieve the highest degree of compatibility possible.
  
 In this guide we are using '/tmp/build-dir' for our temporary 'BUILD' directory and '/tmp/.gcc-cross' as our permanent 'INSTALL' directory. '/tmp/.gcc-cross' is the location where the gcc cross-compiler will be located after it's been compiled. You can, of course, use your own locations for both of these directories. In this guide we are using '/tmp/build-dir' for our temporary 'BUILD' directory and '/tmp/.gcc-cross' as our permanent 'INSTALL' directory. '/tmp/.gcc-cross' is the location where the gcc cross-compiler will be located after it's been compiled. You can, of course, use your own locations for both of these directories.
  
-**NB:** The gcc-9.1.0 'libsanitizer asan' might need patching before building glibc-2.29 if the compile crashes unexpectedly. If this is a problem for you then patching the offending gcc-9.1.0/libsanitizer/asan/asan_linux.cc source file will get around this issue. The issue itself is that no PATH_MAX has been defined in the source and there needs to be a value set in order for it to compile successfully. Instructions on how to successfully patch this file are included herein, should they be needed.+**NB:** The gcc-9.2.0 'libsanitizer asan' might need patching before building glibc-2.29 if the compile crashes unexpectedly. If this is a problem for you then patching the offending gcc-9.2.0/libsanitizer/asan/asan_linux.cc source file will get around this issue. The issue itself is that no PATH_MAX has been defined in the source and there needs to be a value set in order for it to compile successfully. Instructions on how to successfully patch this file are included herein, should they be needed.
  
 === Requirements === === Requirements ===
Line 24: Line 24:
 === What's involved === === What's involved ===
 This tutorial will enable you to; This tutorial will enable you to;
-  * download the required package source(s) in order to build a gcc-9.1.0 cross-compiler on Slackware ARM. \\ +  * download the required package source(s) in order to build a gcc-9.2.0 cross-compiler on Slackware ARM. \\ 
   * download the Raspberry Pi Linux kernel [[https://www.github.com/raspberrypi/linux|GitHub]] tree rpi-5.2.y development branch. \\    * download the Raspberry Pi Linux kernel [[https://www.github.com/raspberrypi/linux|GitHub]] tree rpi-5.2.y development branch. \\ 
-  * configure, and install, a gcc-9.1.0 aarch64-linux (armv8) cross-compiler on your Raspberry Pi 4. \\ +  * configure, and install, a gcc-9.2.0 aarch64-linux (armv8) cross-compiler on your Raspberry Pi 4. \\ 
   * build the aarch64 (armv8) Linux kernel, modules, and device tree blob(s), and install them on your [spare] Slackware ARM current microSD card. \\    * build the aarch64 (armv8) Linux kernel, modules, and device tree blob(s), and install them on your [spare] Slackware ARM current microSD card. \\ 
   * successfully boot Slackware ARM current on your Raspberry Pi 4 running an aarch64 (armv8) kernel.   * successfully boot Slackware ARM current on your Raspberry Pi 4 running an aarch64 (armv8) kernel.
Line 61: Line 61:
 When that's done you should see a message that 'origin/rpi-5.2.y' is the current branch. When that's done you should see a message that 'origin/rpi-5.2.y' is the current branch.
  
-You can select which kernel source you would like to build instead of rpi-5.2.y branch. Just substitute it in the 'git checkout -f rpi-5.2.y' command for your chosen branch. To see a list of available branches use this command:+<note tip>You can select which kernel source you would like to build instead of rpi-5.2.y branch. Just substitute it in the 'git checkout -f rpi-5.2.y' command for your chosen branch. To see a list of available branches use this command while in your Linux source directory:
  
 <code> <code>
 git branch -a git branch -a
-</code>+</code></note>
  
  
Line 71: Line 71:
 === Downloading required package source === === Downloading required package source ===
  
-Before downloading the package source needed to build the gcc cross-compiler, be aware that more recent package versions may exist than the ones shown here. You may wish to install newer versions. It's always a good idea to check. To keep things simple, you might consider downloading a version of gcc which matches the one you currently have installed. I've read lots of articles about this and most advise to install the //latest and greatest// version of gcc available. However, if you're running Slackware ARM current you'll have gcc-9.1.0 installed and this is adequate for what you need.+Before downloading the package source needed to build the gcc cross-compiler, be aware that more recent package versions may exist than the ones shown here. You may wish to install newer versions. It's always a good idea to check. To keep things simple, you might consider downloading a version of gcc which matches the one you currently have installed. I've read lots of articles about this and most advise to install the //latest and greatest// version of gcc available. However, if you're running Slackware ARM current you'll have gcc-9.2.0 installed and this is adequate for what you need.
  
 So, first move back into the 'BUILD' directory and then download the packages below. So, first move back into the 'BUILD' directory and then download the packages below.
Line 79: Line 79:
 wget -nc https://ftp.gnu.org/gnu/binutils/binutils-2.32   wget -nc https://ftp.gnu.org/gnu/binutils/binutils-2.32  
 wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1    wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1   
-wget -nc https://ftp.gnu.org/gnu/gcc/gcc-9.1.0  +wget -nc https://ftp.gnu.org/gnu/gcc/gcc-9.2.0  
 wget -nc https://ftp.gnu.org/gnu/glibc/glibc-2.29   wget -nc https://ftp.gnu.org/gnu/glibc/glibc-2.29  
 wget -nc https://ftp.gnu.org/gnu/gmp/gmp-6.1.2   wget -nc https://ftp.gnu.org/gnu/gmp/gmp-6.1.2  
Line 99: Line 99:
 === Creating gcc dependency symlinks === === Creating gcc dependency symlinks ===
  
-Now you are going to create some symbolic links in the gcc-9.1.0 directory. These will point to some of the source directories you have just unpacked, which are dependencies of gcc, and when these symbolic links are present gcc will build them automatically.+Now you are going to create some symbolic links in the gcc-9.2.0 directory. These will point to some of the source directories you have just unpacked, which are dependencies of gcc, and when these symbolic links are present gcc will build them automatically.
  
 <code> <code>
-cd gcc-9.1.0+cd gcc-9.2.0
 ln -sf ../cloog-0.18.1 cloog ln -sf ../cloog-0.18.1 cloog
 ln -sf ../gmp-6.1.2 gmp ln -sf ../gmp-6.1.2 gmp
Line 113: Line 113:
  
 <code> <code>
-cd gcc-9.1.0+cd gcc-9.2.0
 ./contrib/download_prerequisites ./contrib/download_prerequisites
 </code> </code>
Line 119: Line 119:
 Personally, I always prefer the manual method because then I know what's being downloaded/installed and what to expect. It's up to you which method you use. Personally, I always prefer the manual method because then I know what's being downloaded/installed and what to expect. It's up to you which method you use.
  
-=== Creating gcc-9.1.0 cross-compiler install directory  ===+=== Creating gcc-9.2.0 cross-compiler install directory  ===
  
 The next thing to do is create an 'INSTALL' directory. This is the directory where the gcc cross-compiler will be installed. As before, I like to work from the '/tmp' directory so the install directory is where I will locate it. The next thing to do is create an 'INSTALL' directory. This is the directory where the gcc cross-compiler will be installed. As before, I like to work from the '/tmp' directory so the install directory is where I will locate it.
Line 131: Line 131:
 === Exporting install directory PATH === === Exporting install directory PATH ===
  
-You need to export the installation directory's '/bin' folder to your user's $PATH. The PATH of your gcc-9.1.0 cross-compiler bin needs to be the __FIRST__ item in the $PATH in order to be successful.+You need to export the installation directory's '/bin' folder to your user's $PATH. The PATH of your gcc-9.2.0 cross-compiler bin needs to be the __FIRST__ item in the $PATH in order to be successful.
  
 <code> <code>
Line 157: Line 157:
 === Building binutils === === Building binutils ===
  
-First move back into the 'BUILD' directory and then create a build directory for binutils. You'll notice the various build options but as a quick explanation; '--with-sysroot' basically tells binutils to enable 'sysroot' support in the cross-compiler by pointing it to a default empty directory, '--target=aarch64-linux' is the target system type (arm64), and '--disable-multilib' means that we only want binutils to work with the aarch64 instruction set and nothing else. +First move back into the 'BUILD' directory and then create a build directory for binutils. You'll notice the various CFLAGS but as a quick explanation; '--with-sysroot' basically tells binutils to enable 'sysroot' support in the cross-compiler by pointing it to a default empty directory, '--target=aarch64-linux' is the target system type (arm64), and '--disable-multilib' means that we only want binutils to work with the aarch64 instruction set and nothing else. 
  
 <code> <code>
Line 163: Line 163:
 mkdir build-binutils mkdir build-binutils
 cd build-binutils cd build-binutils
-../binutils-2.32/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --disable-multilib+../binutils-2.32/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --with-sysroot --disable-multilib
 make -j4  make -j4 
 make install make install
Line 185: Line 185:
 mkdir build-gcc mkdir build-gcc
 cd build-gcc cd build-gcc
-../gcc-9.1.0/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib+../gcc-9.2.0/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
 make -j4 all-gcc make -j4 all-gcc
 make -j4 install-gcc make -j4 install-gcc
Line 192: Line 192:
 === Patching gcc before compiling glibc === === Patching gcc before compiling glibc ===
  
-If you find that compiling glibc is problematic, or crashes every time, and it concerns 'libsantizer asan' you will need to patch gcc-9.1.0 before it will compile successfully.+If you find that compiling glibc is problematic, or crashes every time, and it concerns 'libsantizer asan' you will need to patch gcc-9.2.0 before it will compile successfully.
  
 First, move into your 'BUILD' directory and create the patch file. First, move into your 'BUILD' directory and create the patch file.
Line 223: Line 223:
  
 <code> <code>
-patch -b gcc-9.1.0/libsanitizer/asan/asan_linux.cc asan_linux-cc.patch+patch -b gcc-9.2.0/libsanitizer/asan/asan_linux.cc asan_linux-cc.patch
 </code> </code>
  
 This will patch the file and create a backup [option -b] in case things don't go as planned. Now you should find that glibc compiles without any problem(s). This will patch the file and create a backup [option -b] in case things don't go as planned. Now you should find that glibc compiles without any problem(s).
  
-NB: The location of the backed up file is: gcc-9.1.0/libsanitizer/asan/asan_linux.cc.orig+NB: The location of the backed up file is: gcc-9.2.0/libsanitizer/asan/asan_linux.cc.orig
  
  
Line 294: Line 294:
 Using built-in specs. Using built-in specs.
 COLLECT_GCC=aarch64-linux-gcc COLLECT_GCC=aarch64-linux-gcc
-COLLECT_LTO_WRAPPER=/tmp/.gcc-cross/libexec/gcc/aarch64-linux/9.1.0/lto-wrapper+COLLECT_LTO_WRAPPER=/tmp/.gcc-cross/libexec/gcc/aarch64-linux/9.2.0/lto-wrapper
 Target: aarch64-linux Target: aarch64-linux
-Configured with: ../gcc-9.1.0/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib : (reconfigured) ../gcc-9.1.0/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib+Configured with: ../gcc-9.2.0/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib : (reconfigured) ../gcc-9.2.0/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
 Thread model: posix Thread model: posix
-gcc version 9.1.0 (GCC)+gcc version 9.2.0 (GCC)
  
 </code> </code>
Line 314: Line 314:
 ==== Building the arm64 kernel, modules, and device tree blob (DTB) ==== ==== Building the arm64 kernel, modules, and device tree blob (DTB) ====
  
-To build the aarch64 kernel, modules and device tree blob(s) is exactly the same method as you would carry it out under normal circumstances. Commands such as 'make bzImage && make modules && make modules_install' may be all too familiar to you. The major difference when cross-compiling is that you'll use certain Makefile options/variables/arguments/switches, commonly known as CFLAGS. In our case, CFLAGS will be used to instruct the gcc cross-compiler to build for the aarch64 (arm64) architecture specifically.+To build the aarch64 kernel, modules and device tree blob(s) is exactly the same method as you would carry it out under normal circumstances. Commands such as 'make bzImage && make modules && make modules_install' may be all too familiar to you. The major difference when cross-compiling is that you'll use certain Makefile variables/arguments/switches, commonly known as //build options//<. In our case, //build options// will be used to instruct the gcc cross-compiler to build for the aarch64 (arm64) architecture specifically.
  
 === Creating the arm64 kernel .config === === Creating the arm64 kernel .config ===
Line 325: Line 325:
 </code> </code>
  
-<note important>Make a note here of the CFLAGS which have been specified. They should be self-explanatory by now. Pay special attention to the trailing '-' of 'CROSS_COMPILE=aarch64-linux-' because that's **NOT** a typo. __It needs to be like that!__</note>+<note important>Make a note here of the //build options// [ARCH=arm64 CROSS_COMPILE=aarch64-linux-] which have been specified. They should be self-explanatory by now. Pay special attention to the trailing '-' of 'CROSS_COMPILE=aarch64-linux-' because that's **NOT** a typo. __It needs to be like that!__</note>
  
 Now that you've created a kernel .config which contains the default settings for your hardware, some settings within need to be checked and possibly modified. The Raspberry Pi 4's "VideoCore VI" GPU is not //64-bit compatible// and the build process will crash each time you attempt to compile the module's source code for ARMv8 architecture. Now that you've created a kernel .config which contains the default settings for your hardware, some settings within need to be checked and possibly modified. The Raspberry Pi 4's "VideoCore VI" GPU is not //64-bit compatible// and the build process will crash each time you attempt to compile the module's source code for ARMv8 architecture.
Line 373: Line 373:
 === Building the arm64 kernel === === Building the arm64 kernel ===
  
-Next up is building the kernel, based on the .config file you have just created. Again, you'll use the same CFLAGS as before. You can even set a 'LOCALVERSION' here which appends whatever you set to the end of the kernel version (e.g. LOCALVERSION="-aarch64" would eventually give you 5.2.1-v8-aarch64) once the kernel and modules have been built. Just as an example we'll use it here. Run the following command to start building the arm64 Linux kernel:+Next up is building the kernel, based on the .config file you have just created. Again, you'll use the same //build options// as before. You can even set a 'LOCALVERSION' here which appends whatever you set to the end of the kernel version (e.g. LOCALVERSION="-aarch64" would eventually give you 5.2.1-v8-aarch64) once the kernel and modules have been built. Just as an example we'll use it here. Run the following command to start building the arm64 Linux kernel:
  
 <code> <code>
Line 406: Line 406:
 === Installing the arm64 modules === === Installing the arm64 modules ===
  
-Once the modules have been built, you have to 'make modules_install' The process will install your kernel modules to '/tmp/lib/modules/5.2.1-v8-aarch64'+Once the modules have been built, you have to 'make modules_install' The process will install your kernel modules to '/lib/modules/5.2.1-v8-aarch64'
  
-You could build  //out-of-tree// kernel modules but, to keep things simple, you're going to install them to the usual location. Again, you will use the same CFLAGS as before but without any 'LOCALVERSION' set.+You could build  //out-of-tree// kernel modules but, to keep things simple, you're going to install them to the usual location. Again, you will use the same //build options// as before but without any 'LOCALVERSION' set.
  
 First you need become '**root**' user and enter a passwd when prompted. To install the aarch64 modules run the following commands: First you need become '**root**' user and enter a passwd when prompted. To install the aarch64 modules run the following commands:
Line 492: Line 492:
 <code> <code>
 ls -lah rpi-boot/boot/kernel* ls -lah rpi-boot/boot/kernel*
-ls -lah rpi-boot/boot/bcm*-rpi-3-b.dtb +ls -lah rpi-boot/boot/bcm*-rpi-4-b.dtb 
 ls -lah rpi-root/lib/modules/5.2.1-v8* ls -lah rpi-root/lib/modules/5.2.1-v8*
 </code> </code>
Line 529: Line 529:
 Linux 5.2.1-v8-aarch64. Linux 5.2.1-v8-aarch64.
 root@drie:~# cat /proc/version root@drie:~# cat /proc/version
-Linux version 5.2.1-v8-aarch64 (exaga@torq) (gcc version 9.1.0 (GCC)) #1 SMP Thu Jul 18 18:19:49 BST 2019+Linux version 5.2.1-v8-aarch64 (exaga@torq) (gcc version 9.2.0 (GCC)) #1 SMP Thu Jul 18 18:19:49 BST 2019
 exaga@torq:~# uname -a exaga@torq:~# uname -a
 Linux torq 5.2.1-v8-aarch64 #2 SMP Thu Jul 18 18:19:49 BST 2019 aarch64 GNU/Linux Linux torq 5.2.1-v8-aarch64 #2 SMP Thu Jul 18 18:19:49 BST 2019 aarch64 GNU/Linux
Line 547: Line 547:
 There's a new SARPi64 Project website which focusses on all things Slackware AArch64 ARM64 ARMv8 related. From here we hope to develop and distribute experimental binary  packages and installer disk images for Slackware ARM, amongst other content. The SARPi64 Project website URL is: [[http://sarpi64.fatdog.eu/]] There's a new SARPi64 Project website which focusses on all things Slackware AArch64 ARM64 ARMv8 related. From here we hope to develop and distribute experimental binary  packages and installer disk images for Slackware ARM, amongst other content. The SARPi64 Project website URL is: [[http://sarpi64.fatdog.eu/]]
  
-An automated gcc-9.1.0 aarch64 cross-compiler build [bash] script is available here: [[http://sarpi64.fatdog.eu/files/extra/SARPi64.SlackBuild-aarch64-cc.txt]]+An automated gcc-9.2.0 aarch64 cross-compiler build [bash] script is available here: [[http://sarpi64.fatdog.eu/files/extra/SARPi64.SlackBuild-aarch64-cc.txt]]
  
 Thanks for being interested. <3 Thanks for being interested. <3
  
 ====== Sources ====== ====== Sources ======
-# If you need to install any of the packages above [* check for updates!]:+# If you need to install any of the software above [* check for updates!]:
  
 [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/a/gawk-5.0.1-arm-1.txz]]  # Slackware ARM current - gawk package. \\ [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/a/gawk-5.0.1-arm-1.txz]]  # Slackware ARM current - gawk package. \\
Line 566: Line 566:
 [[slackwarearm:faq|http://arm.slackware.com/FAQs]] # Slackware ARM Linux Project Frequently Asked Questions. \\  [[slackwarearm:faq|http://arm.slackware.com/FAQs]] # Slackware ARM Linux Project Frequently Asked Questions. \\ 
 [[http://wiki.osdev.org/GCC_Cross-Compiler]] # gcc cross-compiler documentation. \\  [[http://wiki.osdev.org/GCC_Cross-Compiler]] # gcc cross-compiler documentation. \\ 
 +[[howtos:hardware:arm:gcc_aarch64_cross-compiler|Slackware ARM GCC aarch64-linux cross-compiler]] for the Raspberry Pi. \\
 [[https://www.raspberrypi.org/documentation/linux/kernel]] # Raspberry Pi Linux kernel documentation. \\  [[https://www.raspberrypi.org/documentation/linux/kernel]] # Raspberry Pi Linux kernel documentation. \\ 
  
 howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler ()