From e230e8172a80cfde96f780af5f6be901b55bfbd0 Mon Sep 17 00:00:00 2001
From: Sam Thursfield <sam.thursfield@codethink.co.uk>
Date: Fri, 3 Nov 2017 12:46:07 +0000
Subject: gnu-toolchain: Split rule improvements

This includes many fixes that result in us being able to produce a
minimal OS image or initramfs of a reasonable size. I have built an
initramfs of 16MB uncompressed with this change: still a bit bigger
than necessary, but much better than the comical ~700MB thing complete
with kernel source code and C++ compiler that I got before these
changes.

Note that the gnu-toolchain stack now puts all the toolchain binaries
into the 'devel' artifact. The 'runtime' artifact just contains
libraries needed to run programs that are built with that toolchain.
We should split this up further in future so that C programs don't
depend on libstdc++.

Special care is taken for GCC and GLIBC to handle the lib/ and lib64/
split that they do on some 64-bit platforms.

We also globally put /usr/src into the devel artifact, which is only
useful for the linux.bsp element at present but makes sense as a global
rule.
---
 elements/gnu-toolchain/gcc.bst | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

(limited to 'elements/gnu-toolchain/gcc.bst')

diff --git a/elements/gnu-toolchain/gcc.bst b/elements/gnu-toolchain/gcc.bst
index bf6eca66..37f7a5b6 100644
--- a/elements/gnu-toolchain/gcc.bst
+++ b/elements/gnu-toolchain/gcc.bst
@@ -35,6 +35,9 @@ variables:
                         --with-fpu=vfpv3-d16
                         --with-float=hard
 
+    - arch in ["armv8b64", "armv8l64", "ppc64b", "ppc64l", "x86_64"]:
+        lib: lib64
+
 environment:
   PATH: /usr/bin:/bin:/usr/sbin:/sbin:/tools/bin:/tools/sbin
 
@@ -93,3 +96,38 @@ config:
           (<):
           - sed -i "s/--host=none/--host=armv7a/" o/Makefile
           - sed -i "s/--target=none/--target=armv7a/" o/Makefile
+
+public:
+  bst:
+    split-rules:
+      runtime:
+        - |
+          %{prefix}/%{lib}/lib*.so*
+
+      devel:
+        (>):
+        - |
+          %{bindir}/*
+        - |
+          %{prefix}/%{lib}/lib*.a
+        - |
+          %{prefix}/%{lib}/lib*.las
+        - |
+          %{prefix}/lib/gcc
+        - |
+          %{prefix}/lib/gcc/**
+        - |
+          %{libexecdir}/gcc
+        - |
+          %{libexecdir}/gcc/**
+        - |
+          %{prefix}/%{target}
+        - |
+          %{prefix}/%{target}/*
+
+      debug:
+        (>):
+        - |
+          %{datadir}/gcc-*/
+        - |
+          %{datadir}/gcc-*/**
-- 
cgit v1.2.1

