Received: by 2002:a9a:4c47:0:b029:116:c383:538 with SMTP id u7csp765577lko; Tue, 13 Jul 2021 09:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybnVbIgDojx3swgbkyOnVokVA51CUrFQCqZRf/eVFQ7qCcqYesMUWnOMcYWzIPTNVISnfW X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr7024039ejc.188.1626194702364; Tue, 13 Jul 2021 09:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626194702; cv=none; d=google.com; s=arc-20160816; b=ZGFp0wYsm+Fuj2MeOX/XzOnuM3H0x+/H9vtd85VINvtsex/ESrtl+/K+j3kqussqPI gr5TPjqjVQLf87eGlLBwLrNH29CzH/drZUjuMP6kmH5vfHbaXw7C+GqAXiXeYRT12bLG hxQdE+L3ygpkQWdjXboCXNcDm/qezouizofPlINn8xXImq1XRxAJhGxOGJc/KPebmTn1 epG63zOWVUTCN3d18dk3U72I++Is5GjHk5sF3kdomTQ7QxCuEyw3IBK2BhMjNcrmUQQD UM6C9rNfONSMcGzERI1bpGROOU087XaL3R0asEuxD5OEu5tlYV27eekm4wR4Y2kC1Mf1 435A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:date:message-id:cc:to:subject:from:dkim-signature :dkim-signature; bh=AdGwqYiU2Exy6QI/bwNjAGF2kjHGEu0qjw5lXgO0IGQ=; b=y9s5rpighPbx0fKWaBe2M8/COchSbLepZCf4NOglbU7jYj9j1No78aZyOG+NCIfkPs jCwYsfZUaqqaUpENhbZh2cgbrG9el5yjimLQnV17KVJxu0jvmaROJAWNSp4Eo7qR0wVT 8YOGqkh/zCZVfKjHTeDel4jWoNccakeBevIZKEBvPg3JaQNyNA6eEtMeukc5MIe/CpMK WldJGE2OVgen0lvxE+UTWk4fD1zGarLtaBtOP9mQSDbFhMuai7lhNfxvRjK18BI9X+FF u/NKn9odRbEcVvom8O4WlVMk8RPP9ox3BibMUjis2ZA3rFKyXS7clRts2LvhGJib2n2f io2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=L3LEee6P; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b="oVta/ZFq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=mailbox.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn9si17884001edb.505.2021.07.13.09.44.39; Tue, 13 Jul 2021 09:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=L3LEee6P; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b="oVta/ZFq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=mailbox.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbhGMQon (ORCPT + 99 others); Tue, 13 Jul 2021 12:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbhGMQom (ORCPT ); Tue, 13 Jul 2021 12:44:42 -0400 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050::465:201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 485A5C0613DD; Tue, 13 Jul 2021 09:41:52 -0700 (PDT) Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4GPRHK3bh8zQkBw; Tue, 13 Jul 2021 18:41:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-transfer-encoding:content-language:content-type :content-type:mime-version:date:date:message-id:subject:subject :from:from:received; s=mail20150812; t=1626194506; bh=bV2Ub8Dl4O AgCpbhC2OayemUg8DzgSFkQuYDlxX+F58=; b=L3LEee6PizP4XDGS0wMtxrgVgH +v5Ghs4n+tUkwimR/vJ+4nyBMEHCAv4kG//HzA8obWQ7ccZBkSvImCHGvSLU3UGU WBJDvvnHP61F1CMyBVl7BjDTnsANnY53dx0f7T7UDindB5LYquiyOT6vgUmXPmBE HpRaSn7nY8isBlkk2Ue2zw6pH2fzRhswvXy8EJ5HKikYjP3WQ0EAUgc4y20o8yaS eEvZjT0NImfmUHFvECLJhar/ePy+NuWRgo3wRYSeu/r9XmN+oho29ZDyW+LNFwkI 342F81cnKI8h+XS9fPYwI899clU4BzIGxmiYbjQ1C3DZ7KtoMaNa+R2Zpv8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1626194507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AdGwqYiU2Exy6QI/bwNjAGF2kjHGEu0qjw5lXgO0IGQ=; b=oVta/ZFqucfokDYWa7xAKmuJfepzbUlhW3Vo/G4xHI7xHXjpRTmQZO5uaCrXDtGDC8GWfd yk7GkgH5O3tTYiREVfZDkJ3Tuqh5odbMr7jG0KeJBbA4K5DNeowyfVOMP++a9F8AGPiOek 9zYfKjUd1Zzva63+LcLxva6ABMsMtagY5HVTaCCoAIpwJP7Wdbpv04gzeoX6x7w9bApR9I Fz8srvKaX819/mTO77z+zATSLwN4pRY+2pNopQX75mgtJTecRPecq1uLtzfgJqH3icCLEY MqLXw8kXJWENGZi9GzQSR5U1G/vhCifDjzuEaWzbB0Zcj8GxDRJezXheovkbQA== X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id Bf6s8kN6VwLN; Tue, 13 Jul 2021 18:41:46 +0200 (CEST) From: Tor Vic Subject: [PATCH v2 1/1] Kbuild, clang: add option for choosing a ThinLTO cache directory To: "linux-kernel@vger.kernel.org" , masahiroy@kernel.org, Nathan Chancellor , "ndesaulniers@google.com" , keescook@chromium.org Cc: linux-kbuild@vger.kernel.org, "clang-built-linux@googlegroups.com" Message-ID: Date: Tue, 13 Jul 2021 16:41:38 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.69 / 15.00 / 15.00 X-Rspamd-Queue-Id: 478F21819 X-Rspamd-UID: 1fac34 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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