Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Squash] Treewide: Update for ld.lld usage
kbuild: Allow forcing the alternative LLD linker via Kconfig LLD is a relatively new linker from the LLVM Project that aims to be a faster and more modern alternative to the GNU gold and bfd linkers from binutils: https://lld.llvm.org/ I've also found that it offers more insightful diagnostics when something goes wrong, e.g. when there are undefined references. It does also appear to speed up the overall build time by 4-10s as compared to ld.bfd. These new config options will only allow fully-working configurations: - gold/lld when Clang LTO is enabled - bfd/lld otherwise Signed-off-by: Danny Lin <[email protected]> Signed-off-by: Adam W. Willis <[email protected]> Signed-off-by: Yaroslav Furman <[email protected]> BACKPORT: FROMLIST: Makefile: lld: set -O2 linker flag when linking w… …ith LLD For arm64: 0.34% size improvement with lld -O2 over lld for vmlinux. 3.3% size improvement with lld -O2 over lld for Image.lz4-dtb. Link: ClangBuiltLinux/linux#343 Suggested-by: Rui Ueyama <[email protected]> Suggested-by: Nathan Chancellor <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> (am from https://patchwork.kernel.org/patch/10806729/) Signed-off-by: Adam W. Willis <[email protected]> Signed-off-by: Yaroslav Furman <[email protected]> BACKPORT: FROMLIST: Makefile: lld: tell clang to use lld This is needed because clang doesn't select which linker to use based on $LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}. This is problematic especially for cc-ldoption, which checks for linker flag support via invoking the compiler, rather than the BACKPORT: FROMLIST: Makefile: lld: tell clang to use lld This is needed because clang doesn't select which linker to use based on $LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}. This is problematic especially for cc-ldoption, which checks for linker flag support via invoking the compiler, rather than the linker. Select the linker via absolute path from $PATH via `which`. This allows you to build with: $ make LD=ld.lld $ make LD=ld.lld-8 $ make LD=/path/to/ld.lld Add -Qunused-arguments to KBUILD_CPPFLAGS sooner, as otherwise Clang likes to complain about -fuse-lld= being unused when compiling but not linking (-c) such as when cc-option is used. There's no need to guard with cc-option. Link: ClangBuiltLinux/linux#342 Link: ClangBuiltLinux/linux#366 Link: ClangBuiltLinux/linux#357 Suggested-by: Nathan Chancellor <[email protected]> Suggested-by: Masahiro Yamada <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Reviewed-by: Nathan Chancellor <natechancellor@gmail Signed-off-by: Divyanshu-Modi <[email protected]> Signed-off-by: Kunmun <[email protected]>
- Loading branch information