From 35439d927d9d641263e85c90e7588165228c311f Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Mon, 25 Feb 2019 16:07:56 -0700
Subject: [PATCH] Compile some recipes with LTO

---
 cook.sh                                                     | 3 ++-
 recipes/drivers/recipe.sh                                   | 3 ++-
 recipes/ipcd/recipe.sh                                      | 1 +
 recipes/nulld/recipe.sh                                     | 1 +
 recipes/orbital/recipe.sh                                   | 1 +
 recipes/orbterm/recipe.sh                                   | 1 +
 recipes/{orbutils-minimal => orbutils-background}/recipe.sh | 2 +-
 recipes/orbutils-launcher/recipe.sh                         | 4 ++++
 recipes/orbutils-orblogin/recipe.sh                         | 4 ++++
 recipes/ptyd/recipe.sh                                      | 1 +
 recipes/randd/recipe.sh                                     | 1 +
 recipes/uutils/recipe.sh                                    | 2 +-
 recipes/zerod/recipe.sh                                     | 1 +
 13 files changed, 21 insertions(+), 4 deletions(-)
 rename recipes/{orbutils-minimal => orbutils-background}/recipe.sh (59%)
 create mode 100644 recipes/orbutils-launcher/recipe.sh
 create mode 100644 recipes/orbutils-orblogin/recipe.sh

diff --git a/cook.sh b/cook.sh
index 3ec8b698c..07936d1bf 100755
--- a/cook.sh
+++ b/cook.sh
@@ -6,6 +6,7 @@ source config.sh
 
 # Variables to be overriden by recipes
 export BINDIR=bin
+export CARGOBUILD=rustc
 export CARGOFLAGS=
 export DEBUG=
 export PREPARE_COPY=1
@@ -311,7 +312,7 @@ function op {
             if [ "$skip" -eq "0" ]
             then
                 cp -p "$ROOT/Xargo.toml" "Xargo.toml"
-                xargo rustc --target "$TARGET" $release_flag $CARGOFLAGS
+                xargo "$CARGOBUILD" --target "$TARGET" $release_flag $CARGOFLAGS
             fi
             popd > /dev/null
             ;;
diff --git a/recipes/drivers/recipe.sh b/recipes/drivers/recipe.sh
index eb3653f2b..4c5becb8c 100644
--- a/recipes/drivers/recipe.sh
+++ b/recipes/drivers/recipe.sh
@@ -1,5 +1,6 @@
 GIT=https://gitlab.redox-os.org/redox-os/drivers.git
-CARGOFLAGS=--all
+CARGOBUILD="build"
+CARGOFLAGS="--all"
 
 function recipe_version {
     echo "0.1.1"
diff --git a/recipes/ipcd/recipe.sh b/recipes/ipcd/recipe.sh
index 23eadd83a..d500b6447 100644
--- a/recipes/ipcd/recipe.sh
+++ b/recipes/ipcd/recipe.sh
@@ -1 +1,2 @@
 GIT=https://gitlab.redox-os.org/redox-os/ipcd.git
+CARGOFLAGS="--bin ipcd -- -C lto"
diff --git a/recipes/nulld/recipe.sh b/recipes/nulld/recipe.sh
index 0d8a74221..a5944d526 100644
--- a/recipes/nulld/recipe.sh
+++ b/recipes/nulld/recipe.sh
@@ -1 +1,2 @@
 GIT=https://gitlab.redox-os.org/redox-os/nulld.git
+CARGOFLAGS="--bin nulld -- -C lto"
diff --git a/recipes/orbital/recipe.sh b/recipes/orbital/recipe.sh
index 0bf99461c..68484f398 100644
--- a/recipes/orbital/recipe.sh
+++ b/recipes/orbital/recipe.sh
@@ -1,2 +1,3 @@
 GIT=https://gitlab.redox-os.org/redox-os/orbital.git
+CARGOFLAGS="--bin orbital -- -C lto"
 DEPENDS="orbdata"
diff --git a/recipes/orbterm/recipe.sh b/recipes/orbterm/recipe.sh
index 5c79b26c3..9976d87ac 100644
--- a/recipes/orbterm/recipe.sh
+++ b/recipes/orbterm/recipe.sh
@@ -1,3 +1,4 @@
 GIT=https://gitlab.redox-os.org/redox-os/orbterm.git
 BINDIR=/ui/bin
+CARGOFLAGS="--bin orbterm -- -C lto"
 DEPENDS="orbital"
diff --git a/recipes/orbutils-minimal/recipe.sh b/recipes/orbutils-background/recipe.sh
similarity index 59%
rename from recipes/orbutils-minimal/recipe.sh
rename to recipes/orbutils-background/recipe.sh
index b00327c70..2105db9fd 100644
--- a/recipes/orbutils-minimal/recipe.sh
+++ b/recipes/orbutils-background/recipe.sh
@@ -1,4 +1,4 @@
 GIT=https://gitlab.redox-os.org/redox-os/orbutils.git
 BINDIR=/ui/bin
-CARGOFLAGS="--bin background --bin launcher --bin orblogin"
+CARGOFLAGS="--bin background -- -C lto"
 DEPENDS="orbital"
diff --git a/recipes/orbutils-launcher/recipe.sh b/recipes/orbutils-launcher/recipe.sh
new file mode 100644
index 000000000..b2504a222
--- /dev/null
+++ b/recipes/orbutils-launcher/recipe.sh
@@ -0,0 +1,4 @@
+GIT=https://gitlab.redox-os.org/redox-os/orbutils.git
+BINDIR=/ui/bin
+CARGOFLAGS="--bin launcher -- -C lto"
+DEPENDS="orbital"
diff --git a/recipes/orbutils-orblogin/recipe.sh b/recipes/orbutils-orblogin/recipe.sh
new file mode 100644
index 000000000..43aeddcd9
--- /dev/null
+++ b/recipes/orbutils-orblogin/recipe.sh
@@ -0,0 +1,4 @@
+GIT=https://gitlab.redox-os.org/redox-os/orbutils.git
+BINDIR=/ui/bin
+CARGOFLAGS="--bin orblogin -- -C lto"
+DEPENDS="orbital"
diff --git a/recipes/ptyd/recipe.sh b/recipes/ptyd/recipe.sh
index affeb268f..558bbf5d4 100644
--- a/recipes/ptyd/recipe.sh
+++ b/recipes/ptyd/recipe.sh
@@ -1 +1,2 @@
 GIT=https://gitlab.redox-os.org/redox-os/ptyd.git
+CARGOFLAGS="--bin ptyd -- -C lto"
diff --git a/recipes/randd/recipe.sh b/recipes/randd/recipe.sh
index 376731488..a3e93aada 100644
--- a/recipes/randd/recipe.sh
+++ b/recipes/randd/recipe.sh
@@ -1 +1,2 @@
 GIT=https://gitlab.redox-os.org/redox-os/randd.git
+CARGOFLAGS="--bin randd -- -C lto"
diff --git a/recipes/uutils/recipe.sh b/recipes/uutils/recipe.sh
index 1782913a1..67c7f51c4 100644
--- a/recipes/uutils/recipe.sh
+++ b/recipes/uutils/recipe.sh
@@ -1,6 +1,6 @@
 GIT=https://gitlab.redox-os.org/redox-os/uutils.git
 GIT_UPSTREAM=https://github.com/uutils/coreutils.git
-CARGOFLAGS="--no-default-features --features redox"
+CARGOFLAGS="--no-default-features --features redox --bin uutils -- -C lto"
 
 BINS=(
   base32
diff --git a/recipes/zerod/recipe.sh b/recipes/zerod/recipe.sh
index a201dacfd..5006bda6e 100644
--- a/recipes/zerod/recipe.sh
+++ b/recipes/zerod/recipe.sh
@@ -1 +1,2 @@
 GIT=https://gitlab.redox-os.org/redox-os/zerod.git
+CARGOFLAGS="--bin zerod -- -C lto"
-- 
GitLab