Skip to content

Instantly share code, notes, and snippets.

@mvaisakh
Created December 31, 2020 17:45
Show Gist options
  • Save mvaisakh/8e15f2740194e7206effbc673950cf0b to your computer and use it in GitHub Desktop.
Save mvaisakh/8e15f2740194e7206effbc673950cf0b to your computer and use it in GitHub Desktop.
From 33c6a4b53675e72cac7bbc26582a8be4c1fdf7c5 Mon Sep 17 00:00:00 2001
From: Vaisakh Murali <vaisakhmurali@gmail.com>
Date: Thu, 31 Dec 2020 23:08:02 +0530
Subject: [PATCH] kernel: Add support for usage of inline LLD with GCC Cross
Compilers
* LLD has shown to be much faster than the GCC Standard BFD ld and Gold ld.
* With newer android kernels, usage of these GCC Standard linkers becomes difficult as they
don't support relative relocations.
* LLD supports such relocations, being a modern linker and with the amazing linking speed, it
is a useful addition to GCC.
* This patch is for LLD integrated into GCC Cross Compiler
---
Makefile | 4 ++++
scripts/gcc-plugins/Kconfig | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/Makefile b/Makefile
index 1bf6734cc3d2..05ba67f069cb 100644
--- a/Makefile
+++ b/Makefile
@@ -392,7 +392,11 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
+ifeq ($(CONFIG_GCC_LLD),y)
+LD = $(CROSS_COMPILE)ld.lld
+else
LD = $(CROSS_COMPILE)ld
+endif
REAL_CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
diff --git a/scripts/gcc-plugins/Kconfig b/scripts/gcc-plugins/Kconfig
index 21f4b68eb273..d018b2368ba4 100644
--- a/scripts/gcc-plugins/Kconfig
+++ b/scripts/gcc-plugins/Kconfig
@@ -13,6 +13,11 @@ config HAVE_GCC_PLUGINS
An arch should select this symbol if it supports building with
GCC plugins.
+config GCC_LLD
+ bool
+ help
+ Allow the usage of LLVM LLD linker with GCC.
+
config GCC_PLUGINS
bool
depends on HAVE_GCC_PLUGINS
--
2.29.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment