From: Tor Vic <torvic9@mailbox.org>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
masahiroy@kernel.org, Nathan Chancellor <nathan@kernel.org>,
"ndesaulniers@google.com" <ndesaulniers@google.com>,
keescook@chromium.org
Cc: linux-kbuild@vger.kernel.org,
"clang-built-linux@googlegroups.com"
<clang-built-linux@googlegroups.com>
Subject: [PATCH v2 1/1] Kbuild, clang: add option for choosing a ThinLTO cache directory
Date: Tue, 13 Jul 2021 16:41:38 +0000 [thread overview]
Message-ID: <a6eea2c4-6d90-3ddf-33d6-973d1ae917e7@mailbox.org> (raw)
On some distros and configurations, it might be useful to allow for
specifying a directory where Clang stores its ThinLTO cache.
More specifically, when building the VirtualBox extramodules on Arch with
its proper 'makepkg' build system and DKMS, against an already installed
ThinLTO kernel, the build fails because it tries to create the ThinLTO
cache in a directory that is not user-writable.
A similar problem has been reported with openSUSE's OBS build system.
Add a Kconfig option that allows users to choose a directory in which
Clang's ThinLTO can store its cache.
Link: https://github.com/ClangBuiltLinux/linux/issues/1104
Signed-off-by: Tor Vic <torvic9@mailbox.org>
---
Changes from v1 to v2: remove unneeded changes in scripts/Makefile
Makefile | 5 +++--
arch/Kconfig | 10 ++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index c3f9bd191b89..472bc8bfff03 100644
--- a/Makefile
+++ b/Makefile
@@ -932,7 +932,8 @@ endif
ifdef CONFIG_LTO_CLANG
ifdef CONFIG_LTO_CLANG_THIN
CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
-KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod_prefix).thinlto-cache
+export thinlto-dir = $(if
$(CONFIG_LTO_CLANG_THIN_CACHEDIR),$(CONFIG_LTO_CLANG_THIN_CACHEDIR)/)
+KBUILD_LDFLAGS +=
--thinlto-cache-dir=$(thinlto-dir)$(extmod_prefix).thinlto-cache
else
CC_FLAGS_LTO := -flto
endif
@@ -1728,7 +1729,7 @@ PHONY += compile_commands.json
clean-dirs := $(KBUILD_EXTMOD)
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
$(KBUILD_EXTMOD)/modules.nsdeps \
- $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
+ $(KBUILD_EXTMOD)/compile_commands.json
$(thinlto-dir)$(KBUILD_EXTMOD)/.thinlto-cache
PHONY += help
help:
diff --git a/arch/Kconfig b/arch/Kconfig
index 129df498a8e1..19e4d140e12a 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -696,6 +696,16 @@ config LTO_CLANG_THIN
https://clang.llvm.org/docs/ThinLTO.html
If unsure, say Y.
+
+config LTO_CLANG_THIN_CACHEDIR
+ string "Clang ThinLTO cache directory"
+ depends on LTO_CLANG_THIN
+ default ""
+ help
+ This option allows users to choose a directory that stores
+ Clang's ThinLTO cache.
+ Leave empty for default.
+
endchoice
config ARCH_SUPPORTS_CFI_CLANG
--
2.32.0
next reply other threads:[~2021-07-13 16:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 16:41 Tor Vic [this message]
2021-07-14 2:46 ` [PATCH v2 1/1] Kbuild, clang: add option for choosing a ThinLTO cache directory Masahiro Yamada
2021-07-14 6:12 ` Tor Vic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6eea2c4-6d90-3ddf-33d6-973d1ae917e7@mailbox.org \
--to=torvic9@mailbox.org \
--cc=clang-built-linux@googlegroups.com \
--cc=keescook@chromium.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).