From patchwork Sun Apr 24 19:08:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12825076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A681C433F5 for ; Sun, 24 Apr 2022 19:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237625AbiDXTOv (ORCPT ); Sun, 24 Apr 2022 15:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238681AbiDXTON (ORCPT ); Sun, 24 Apr 2022 15:14:13 -0400 Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA1F20F42; Sun, 24 Apr 2022 12:10:19 -0700 (PDT) Received: from grover.sesame (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-10.nifty.com with ESMTP id 23OJ8o6F019069; Mon, 25 Apr 2022 04:09:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com 23OJ8o6F019069 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1650827344; bh=CrEQSNseNqVPSEyOmW1wMEqoTuu9UdoKdG4Y5C9XoQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tb6OQXWbhXZYmJG283mBaFIK12vCPcqqcD0/TJH0ztShZ1+g8zurcr/nZYjNAVfjB fKzWRT9wm5tG5P6TXNuwWjmr8EJo34ztvJg967BIF9DjqYumLliQAEpMjfoqSqrLgR Zv4o/ZG1z8wf4dQwlWJ/pUxhy/eFnuWPWOLFrRUDVhbdfbEAWHNnGear3thGEZrDXS esHmGjVVrWuGf7C+L327U0n6nkKZ3iy+NLxg66la3+Mdjus38Q976UCiT4ZJi8aQHo nkvc2ipYLQoElydSJ5osWBqv4hwr+f8ahNtmCSpoS2WtId2NGw3i5BuPlETxGCi+Wv jEUt4tg7PFJbA== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Michal Marek , Nathan Chancellor , Nick Desaulniers , llvm@lists.linux.dev Subject: [PATCH 21/27] kbuild: record symbol versions in *.cmd files Date: Mon, 25 Apr 2022 04:08:05 +0900 Message-Id: <20220424190811.1678416-22-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220424190811.1678416-1-masahiroy@kernel.org> References: <20220424190811.1678416-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When CONFIG_MODVERSIONS=y, the output from genksyms is saved in separate *.symversions files, and will be used much later when CONFIG_LTO_CLANG=y because it is impossible to update LLVM bit code here. This approach is not robust because: - *.symversions may or may not exist. If *.symversions does not exist, we never know if it is missing for legitimate reason (i.e. no EXPORT_SYMBOL) or something bad has happened (for example, the user accidentally deleted it). Once it occurs, it is not self-healing because *.symversions is generated as a side effect of the build rule of the object. - stale (i.e. invalid) *.symversions might be picked up if an object is generated in a non-ordinary way, and corresponding *.symversions (, which was generated by old builds) just happen to exist. A more robust approach is to save symbol versions in *.cmd files because: - *.cmd always exists (if the object is generated by if_changed rule or friends). Even if the user accidentally deletes it, it will be regenerated in the next build. - *.cmd is always re-generated when the object is updated. This avoid stale version information being picked up. I will remove *.symversions later. Signed-off-by: Masahiro Yamada Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier --- scripts/Makefile.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f6a506318795..e03e85c90b26 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -175,6 +175,8 @@ gen_symversions = \ if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \ $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $@.symversions; \ + echo >> $(dot-target).cmd ; \ + sed 's/\(.*\) = \(.*\);/$(pound)\1=\2/' $@.symversions >> $(dot-target).cmd ; \ else \ rm -f $@.symversions; \ fi