From ec6045fcf5a46123b54029a675d08d89a5e30f21 Mon Sep 17 00:00:00 2001
From: Alberto Garcia <berto@igalia.com>
Date: Sun, 25 Apr 2021 18:45:13 +0000
Subject: [PATCH] Reduce memory usage when not using the Gold linker

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 Source/cmake/OptionsCommon.cmake | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Source/cmake/OptionsCommon.cmake b/Source/cmake/OptionsCommon.cmake
index dd4da682..71ad6106 100644
--- a/Source/cmake/OptionsCommon.cmake
+++ b/Source/cmake/OptionsCommon.cmake
@@ -101,6 +101,11 @@ option(GCC_OFFLINEASM_SOURCE_MAP
   ${GCC_OFFLINEASM_SOURCE_MAP_DEFAULT})
 
 option(USE_APPLE_ICU "Use Apple's internal ICU" ${APPLE})
+# Pass --reduce-memory-overheads to the bfd linker in order to save memory
+if (NOT USE_LD_GOLD)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--reduce-memory-overheads")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--reduce-memory-overheads")
+endif ()
 
 # Enable the usage of OpenMP.
 #  - At this moment, OpenMP is only used as an alternative implementation
