Slackware ARM64 AArch64 on a Raspberry Pi
SARPi64 How-To ... Build A gcc-9.2.x AArch64 Cross-Compiler
To build your own gcc-9.2.x ARM64 AArch64 cross-compiler you can go about it in two ways.
1. Build manually.
2. Use an automated bash script to build for you.
Both methods can be realised from the information contained within this page. It's up to you and whichever way works best to suit your needs. The manual method is advised just for the learning curve. ;-)
IMPORTANT! The procedures on this page should all be carried out as a normal user on your system and NOT 'root' user!
When things go unexpectedly and inexplicably awry, which they OFTEN do during experimental binary compilations, you do not want to run any build process as 'root' user, because it can have an adverse effect on the integrity of your operating system. Never use 'root' user unless you specifically need to.
The Manual Method
The manual method of building your own gcc-9.2.x ARM64 AArch64 cross-compiler is by far the better route to success. The process involves downloading the source code and compiling it piece by piece, in a set order. Much like baking a cake. The end result is a tonne of education and experience of how to construct toolchains, the packages and commands [structure] involved, in an end-to-end process. However, the SARPi64 Project is not going to re-invent the wheel in terms of offering a walk-through tutorial on how to achieve this, because it's already been documented and published, by Exaga, on the Slackware Documentation Project website.
See the following SlackDocs webpage, a step-by-step guide on how to build a gcc-9.2.0 aarch64-linux- cross-compiler from scratch with Slackware ARM on the Raspberry Pi 4: https://docs.slackware.com/howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler
The SARPi64 Project's AArch64 Linux kernel 4.19.58 .config is available to download.
The SARPi64 Project's AArch64 Linux kernel 5.2.1 .config is available to download.
These kernel .config files will most likely save you a shedload of time, effort, and much perturbation, in trying to work out the right 64-bit CONFIG_ settings for the Raspberry Pi 4 device hardware yourself. If you plan on creating your own 64-bit kernels and modules, these .configs are a great way to get your build processes configured, and compiling, very quickly. Courtesy of the SARPi64 Project. :-)
The Automated Method
The automated method is as easy as copying a file [code], renaming it, changing the file permissions, and executing [running] the script. Although this is the easiest and most effortless method, you don't learn anything from doing it. So if this is your preferred method you'll need to; download the following text file to a 'BUILD' directory on your system, rename the file, and set owner permissions to make it executable. For example, if you are working in the /tmp directory:
user@slackbox:/tmp$ cd /tmp/build_dir
user@slackbox:/tmp/build_dir$ wget http://sarpi64.fatdog.eu/files/extra/SARPi64.SlackBuild-aarch64-cc.txt
user@slackbox:/tmp/build_dir$ cp SARPi64.SlackBuild-aarch64-cc.txt SARPi64.SlackBuild-aarch64-cc.sh
user@slackbox:/tmp/build_dir$ chmod a+x SARPi64.SlackBuild-aarch64-cc.sh
Alternatively, once inside your 'BUILD' directory, you can download the script file, rename it, and set the owner persmissions to executable in a 'one-liner' if you prefer.
-O SARPi64.SlackBuild-aarch64-cc.sh && chmod a+x SARPi64.SlackBuild-aarch64-cc.sh
For those who are not using a terminal, here's a clickable link to download the SARPi64.SlackBuild-aarch64-cc.txt build [bash] script.
When you have the script file in place within your 'BUILD' directory, run it by using the following:
Now you should see your gcc-9.2.0 ARM64 AArch64 cross-compiler build process jump to life and fill the screen with running code; downloading packages and the Linux kernel source, decompressing source archives, and configuring settings. All automagically without any input from you. Soon, the compile processes will commence and then it starts to look a bit like the Matrix digital rain, but in black and white and C++. :-D
Read on for some general hints and tips which you may already be aware of, but are always worth reviewing. The notes at the bottom of this page are also worth perusing.
On Slackware you have a command named 'screen' which comes installed with the OS. The 'screen' program originally came from UNIX and it's a very useful tool indeed. 'screen' allows you to start a "screen session" and then open any number of iterations (i.e. virtual terminals) inside that "screen session". A "screen session" will continue to be active, even after you have disconnected, or the running processes within the "screen session" terminate themselves, until you intentionally terminate that "screen session".
The 'screen' options mean; '-S' = start a new screen session, and 'gcc-cc' is the name (ID) of our screen session [always a good thing to do] and you can select any name or number for the name. To exit the screen and leave it running press "CTRL+A+D" and you will disonnect. To re-attach to the "screen session" type 'screen -x gcc-cc' [or 'screen -r' if you have only one "screen session" running] and you will re-connect to the "screen session". When you want to end and quit the "screen session" type 'exit' while you are in the "screen session" and it will terminate.
When you need to record the time a process takes from inception to completion, or termination, there's a very neat and easy command you can use on Linux base systems. Just put 'time' before the command which runs the job. Yes, it's that simple. In our case it's the gcc cross-compiler build [bash] script. Use the 'time' command like this:
The build process will take some hours to compile and complete. The process is completely autonomous and can be terminated by using the "CTRL+C" key combination.
KNOWN ISSUE: If you have any problems compiling 'glibc' or the build crashes unexpectedly, you might want to think about reading through the docs.slackware.com/howtos:hardware:arm:gcc_aarch64_cross-compiler guide. Particularly on the section about patching gcc-9.2.0 when compiling 'glibc'.
If you encounter any issues, or need a patch file to resolve the above problem, refer to the following notes.
Things To Note
• The gcc compiler you are downloading MUST match the gcc version you have currently installed on your system. You can check this easily by using the following command: 'gcc --version'
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Strange things might, and probably will, happen during compilation if you do not adhere to the above precondition.
• The 'PATH' to your 'aarch64-linux-gcc/bin' directory needs to be in the $PATH before the build script will run successfully. If you have not modified the default install directory [specified by the INSTALL_PATH variable in the build script] then using the following command will achieve this:
NB: '/tmp/.gcc-cross' being the directory in which our AArch64 gcc-9.2.0 cross-compiler was installed. If yours has been installed into another directory then adjust the '/path/to/your/gcc-cross/bin' directory parameter accordingly. An ERROR notice should appear informing you that the cross-compiler PATH is not in the $PATH, and the script will 'exit 1' if you have neglected to do this beforehand.
• There's a possibility you will have to patch a C++ source code file in order for the entire build process to be successfull.
If you're not familiar with the patching process and need the patch file in order to follow instructions then you can download the SARPi64-asan_linux-cc_patch.tar.gz file. This should to be carried out in your 'BUILD' directory to keep everything collated. To achieve this use the following commands:
user@slackbox:/tmp/build_dir$ wget http://sarpi64.fatdog.eu/files/extra/SARPi64-asan_linux-cc_patch.tar.gz
user@slackbox:/tmp/build_dir$ tar -zxvf SARPi64-asan_linux-cc_patch.tar.gz
user@slackbox:/tmp/build_dir$ patch -b gcc-9.2.0/libsanitizer/asan/asan_linux.cc asan_linux-cc.patch
The 'asan_linux-cc.patch' file was created by the SARPi64 Project specifically to solve the issue with building 'glibc' with gcc-9.2.0 for AArch64 architecture.
NB: using 'patch -b' option will automagically make a backup of the original file and give it a '.orig' file extension. Which is very handy indeed for if/when things go pear-shaped. In the event you wish to copy this original file to a safe location, the back-up of the file you have just patched is located here: /tmp/_build-dir/gcc-9.2.0/libsanitizer/asan/asan_linux.cc.orig
Keep the 'asan_linux.cc.orig' file in case you ever need to reverse what you did by patching it. If so, just delete the patched 'asan_linux.cc' file and copy/rename the 'asan_linux.cc.orig' back to it's original location and filename. Then start-over.
Support for Slackware ARM
If you're in need of help, or have something to contribute, one of the best places to get (and offer) support for Slackware ARM is on the Linux Questions Forum. Another valuable resource is the Slackware Documentation Project.
Updated: 06 Jan 2020 00:03:17