[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200702233929.181409-1-danny@kdrag0n.dev>
Date: Thu, 2 Jul 2020 16:39:29 -0700
From: Danny Lin <danny@...ag0n.dev>
To: Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>
Cc: Nathan Chancellor <natechancellor@...il.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Kees Cook <keescook@...omium.org>,
linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
clang-built-linux@...glegroups.com, Danny Lin <danny@...ag0n.dev>
Subject: [PATCH] kbuild: Allow Clang global merging if !MODULES
The old reasoning for disabling Clang's global merging optimization is
that it breaks modpost by coalescing many symbols into _MergedGlobals.
However, modpost is only used in builds with dynamic modules;
vmlinux.symvers is still created during standalone builds, but it's
effectively just an empty dummy file.
Enabling the optimization whenever possible allows us to reap the
benefits of reduced register pressure when many global variables are
used in the same function.
An x86 defconfig kernel built with this optimization boots fine in qemu,
and a downstream 4.14 kernel has been used on arm64 for nearly a year
without any issues caused by this optimization.
Signed-off-by: Danny Lin <danny@...ag0n.dev>
---
Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index a60c98519c37..f04c3639cf61 100644
--- a/Makefile
+++ b/Makefile
@@ -772,10 +772,13 @@ ifdef CONFIG_CC_IS_CLANG
KBUILD_CPPFLAGS += -Qunused-arguments
KBUILD_CFLAGS += -Wno-format-invalid-specifier
KBUILD_CFLAGS += -Wno-gnu
+
+ifdef CONFIG_MODULES
# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
# source of a reference will be _MergedGlobals and not on of the whitelisted names.
# See modpost pattern 2
KBUILD_CFLAGS += -mno-global-merge
+endif
else
# These warnings generated too much noise in a regular build.
--
2.27.0
Powered by blists - more mailing lists