For all of you maintaining you own toolchain for work and guilty pleasures I come with good news. How about taking 14GB of your toolchain and making them disappear?

Since I received my pine time developer kit I have been working with a multi lib toolchain. This means that I compiled GCC to be support both Cortex M0 (armv6) and Cortex M4 (armv7).

This multilib toolchain is “baked” with Cross-Tools NG and the whole process is quite easy. Select “multilib” from the menu, choose the “rmprofile” as the one you want and there you go!

The problem is that the “rmprofile” provides support for armv6, armv7 and armv8. And every combination of Soft FP, Hard FP, single and double precision. This combinatorial explosion leaves around a lot of bytes (about 20 GB of them) I would not have used as the hardware I target are the nRF51822 (M0) and the nRF52832 (M4+hfp).

So after seeing my toolchain build fail another time because of resource exhaustion (literally filled the partition!) I set to prune this combinatorial madness.

And with some help I managed to take the whole armv8 support out of the toolchain reducing to a mere 7 GB!

The process is actually quite easy, when GCC is compiled the profile chosen specifies which combinations will be built by looking at the makefile with the same name.

Each profile is stored in gcc/config and looks like this

# Arch and FPU variants to build libraries with

MULTI_ARCH_OPTS_RM	= march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp/march=armv8-m.base/march=armv8-m.main/march=armv8-m.main+fp/march=armv8-m.main+fp.dp/march=armv8.1-m.main+mve
MULTI_ARCH_DIRS_RM	= v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp v8.1-m.main+mve

# Base M-profile (no fp)
MULTILIB_REQUIRED	+= mthumb/march=armv6s-m/mfloat-abi=soft
MULTILIB_REQUIRED	+= mthumb/march=armv7-m/mfloat-abi=soft
MULTILIB_REQUIRED	+= mthumb/march=armv7e-m/mfloat-abi=soft
MULTILIB_REQUIRED	+= mthumb/march=armv8-m.base/mfloat-abi=soft
MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main/mfloat-abi=soft

# ARMv7e-M with FP (single and double precision variants)
MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp/mfloat-abi=hard
MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp/mfloat-abi=softfp
MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp.dp/mfloat-abi=hard
MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp.dp/mfloat-abi=softfp

# ARMv8-M with FP (single and double precision variants)
MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp/mfloat-abi=hard
MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp/mfloat-abi=softfp
MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp.dp/mfloat-abi=hard
MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp.dp/mfloat-abi=softfp
MULTILIB_REQUIRED	+= mthumb/march=armv8.1-m.main+mve/mfloat-abi=hard

...

So if we were to take out the last part we would drop support for armv8 with FP and then we can go on and take armv8 away from the first two line.

The patch is as follows and applying it was super easy. Cross-Tools will look up local patches in the patches directory and you just have to put it under patches/gcc/your.gcc.version to have it picked up at build time.

--- a/gcc/config/arm/t-rmprofile
+++ b/gcc/config/arm/t-rmprofile
@@ -27,15 +27,13 @@
 
 # Arch and FPU variants to build libraries with
 
-MULTI_ARCH_OPTS_RM	= march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp/march=armv8-m.base/march=armv8-m.main/march=armv8-m.main+fp/march=armv8-m.main+fp.dp
-MULTI_ARCH_DIRS_RM	= v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp
+MULTI_ARCH_OPTS_RM	= march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp
+MULTI_ARCH_DIRS_RM	= v6-m v7-m v7e-m v7e-m+fp v7e-m+dp
 
 # Base M-profile (no fp)
 MULTILIB_REQUIRED	+= mthumb/march=armv6s-m/mfloat-abi=soft
 MULTILIB_REQUIRED	+= mthumb/march=armv7-m/mfloat-abi=soft
 MULTILIB_REQUIRED	+= mthumb/march=armv7e-m/mfloat-abi=soft
-MULTILIB_REQUIRED	+= mthumb/march=armv8-m.base/mfloat-abi=soft
-MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main/mfloat-abi=soft
 
 # ARMv7e-M with FP (single and double precision variants)
 MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp/mfloat-abi=hard
@@ -43,26 +41,13 @@
 MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp.dp/mfloat-abi=hard
 MULTILIB_REQUIRED	+= mthumb/march=armv7e-m+fp.dp/mfloat-abi=softfp
 
-# ARMv8-M with FP (single and double precision variants)
-MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp/mfloat-abi=hard
-MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp/mfloat-abi=softfp
-MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp.dp/mfloat-abi=hard
-MULTILIB_REQUIRED	+= mthumb/march=armv8-m.main+fp.dp/mfloat-abi=softfp
-
-
-
 # Arch Matches
 MULTILIB_MATCHES	+= march?armv6s-m=march?armv6-m
 
-# Map all v8-m.main+dsp FP variants down the the variant without DSP.
-MULTILIB_MATCHES	+= march?armv8-m.main=march?armv8-m.main+dsp \
-			   $(foreach FP, +fp +fp.dp, \
-			     march?armv8-m.main$(FP)=march?armv8-m.main+dsp$(FP))
-
 # For single-precision only fpv5, use the base fp libraries
 MULTILIB_MATCHES	+= march?armv7e-m+fp=march?armv7e-m+fpv5
 
 # Softfp but no FP.  Use the soft-float libraries.
-MULTILIB_REUSE		+= $(foreach ARCH, armv6s-m armv7-m armv7e-m armv8-m\.base armv8-m\.main, \
+MULTILIB_REUSE		+= $(foreach ARCH, armv6s-m armv7-m armv7e-m, \
 			     mthumb/march.$(ARCH)/mfloat-abi.soft=mthumb/march.$(ARCH)/mfloat-abi.softfp)

It also worked first try once I placed in the correct patch directory! So in the end I have 14 GB less for two hours of waiting for GCC to compile, not bad at all!