From c80c2de8798202bf05575fb050883dd78a64f7c3 Mon Sep 17 00:00:00 2001
From: Mehdi Chinoune <mehdi.chinoune@hotmail.com>
Date: Sat, 13 Nov 2021 08:27:49 +0100
Subject: [PATCH 23/N] Fix building staticlibs with LTO

Unless `-ffat-lto-objects` get passed to the compiler, It will only generate LTO bytecode.

see:
https://wiki.ubuntu.com/ToolChain/LTO : Implementation
https://fedoraproject.org/wiki/Changes/LTOBuildImprovements
---
 scripts/libmakepkg/buildenv/lto.sh.in | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/libmakepkg/buildenv/lto.sh.in b/scripts/libmakepkg/buildenv/lto.sh.in
index 7fc12a5..fd3bb65 100644
--- a/scripts/libmakepkg/buildenv/lto.sh.in
+++ b/scripts/libmakepkg/buildenv/lto.sh.in
@@ -35,5 +35,9 @@ buildenv_lto() {
 		append_once CFLAGS "${LTOFLAGS:--flto}"
 		append_once CXXFLAGS "${LTOFLAGS:--flto}"
 		append_once LDFLAGS "${LTOFLAGS:--flto}"
+		if check_option "staticlibs" "y"; then
+			append_once CFLAGS "-ffat-lto-objects"
+			append_once CXXFLAGS "-ffat-lto-objects"
+		fi
 	fi
 }
