Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3692589pxv; Mon, 26 Jul 2021 09:31:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVOWN3gtie/hV/qFIwAMUYsOkaerhrvg21CHxgTOIBH9z1D9XSJoJ/Sbd6lc3TnGmgUXvD X-Received: by 2002:a92:c845:: with SMTP id b5mr14426502ilq.158.1627317070361; Mon, 26 Jul 2021 09:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627317070; cv=none; d=google.com; s=arc-20160816; b=gsJkCBBkEplXscoAQXuP5pzJnOCCwP5ZWVWhBS4JCGemX/X0dKOEzqtg6utby0CvoK jS40VpzP2mqXkb/UWXjYuei/fs/LxM4nxBTkJZjTdsbaqZdxme6ml4/FDipJ7tmtVDeV SNHO/jC2J1xdQV8OcBo5RTzu8yKLy26hNcMk1kawmCGLeZyjx4xBma6iu7GnrToGMmRl hkEk4SJFqWDaygEA6jnOTeNtxBE1aNgaIuwRLU9NuFefZBQ3W5hxDISA9btsSuGkcoR9 wF4uOimEwXMmYfUm7OzEabmKsGpxnc49JaBLD8HmrnztrRSubtrNB8lsr6XERrg6JPGX 8MKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yQLDo53D6vdLejyE/5tgAaPQir7H+c/0ARoeiL08pn4=; b=DuQYBjqiUebkTms/VRnY1QJIrGWSnPJGpYt8vXC0HADqHMWoh5+7SYctvda6AN3rrK udqU3FTR22JhyGj3wYB5NlQsl637bBI9HIvhr5ZDSlZE7vqcUcbhfz1dbi6ZQ+yraKBW GrzmefnfqXBhijtFi7ERy4X6RwRDNeRmSXkOwsNiJoriIpQJ4Dk/qmrjYWICCMVOspaa V8QXxgUanN47JcO9nK8fHRNByzPbd8YFnDxDhKsqlzNw89nRXxX4AsYbh5lhZ2YwfNdu d54sYh08IbVETVgUm+oR8u5RhWpenvsLqZbDqbimORVSnxT5s+t4odugH8UcWY7hsAfc U9sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DnUStnm2; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si305609ilq.87.2021.07.26.09.30.45; Mon, 26 Jul 2021 09:31:10 -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=@linuxfoundation.org header.s=korg header.b=DnUStnm2; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238876AbhGZPrk (ORCPT + 99 others); Mon, 26 Jul 2021 11:47:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:41562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237907AbhGZP32 (ORCPT ); Mon, 26 Jul 2021 11:29:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A1CAD60F6E; Mon, 26 Jul 2021 16:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315789; bh=kLv7WAjwTg8wAJhfsSxiyevIiTlTubskzz45JLD7Wng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnUStnm2Ae/gTyYsAhwNmXsVoUhagQPOLP7Em8BVZHXKOL2OuCxCeebYz9qvHJF8s nyrRpY+djUhWZvyXaQQpLR/wCeRsYozsLjSG9WKwAUghTRM8i7DcZOeMhU6BkFnRcS kWFwMJl2t6ddn75ToMld+dh+rm1PdhiuZ+N8xxSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lecopzer Chen , Masahiro Yamada , Sasha Levin , Sami Tolvanen Subject: [PATCH 5.13 066/223] Kbuild: lto: fix module versionings mismatch in GNU make 3.X Date: Mon, 26 Jul 2021 17:37:38 +0200 Message-Id: <20210726153848.417277780@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lecopzer Chen [ Upstream commit 1d11053dc63094075bf9e4809fffd3bb5e72f9a6 ] When building modules(CONFIG_...=m), I found some of module versions are incorrect and set to 0. This can be found in build log for first clean build which shows WARNING: EXPORT symbol "XXXX" [drivers/XXX/XXX.ko] version generation failed, symbol will not be versioned. But in second build(incremental build), the WARNING disappeared and the module version becomes valid CRC and make someone who want to change modules without updating kernel image can't insert their modules. The problematic code is + $(foreach n, $(filter-out FORCE,$^), \ + $(if $(wildcard $(n).symversions), \ + ; cat $(n).symversions >> $@.symversions)) For example: rm -f fs/notify/built-in.a.symversions ; rm -f fs/notify/built-in.a; \ llvm-ar cDPrST fs/notify/built-in.a fs/notify/fsnotify.o \ fs/notify/notification.o fs/notify/group.o ... `foreach n` shows nothing to `cat` into $(n).symversions because `if $(wildcard $(n).symversions)` return nothing, but actually they do exist during this line was executed. -rw-r--r-- 1 root root 168580 Jun 13 19:10 fs/notify/fsnotify.o -rw-r--r-- 1 root root 111 Jun 13 19:10 fs/notify/fsnotify.o.symversions The reason is the $(n).symversions are generated at runtime, but Makefile wildcard function expends and checks the file exist or not during parsing the Makefile. Thus fix this by use `test` shell command to check the file existence in runtime. Rebase from both: 1. [https://lore.kernel.org/lkml/20210616080252.32046-1-lecopzer.chen@mediatek.com/] 2. [https://lore.kernel.org/lkml/20210702032943.7865-1-lecopzer.chen@mediatek.com/] Fixes: 38e891849003 ("kbuild: lto: fix module versioning") Co-developed-by: Sami Tolvanen Signed-off-by: Lecopzer Chen Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 34d257653fb4..c6bd62f518ff 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -388,7 +388,7 @@ ifeq ($(CONFIG_LTO_CLANG) $(CONFIG_MODVERSIONS),y y) cmd_update_lto_symversions = \ rm -f $@.symversions \ $(foreach n, $(filter-out FORCE,$^), \ - $(if $(wildcard $(n).symversions), \ + $(if $(shell test -s $(n).symversions && echo y), \ ; cat $(n).symversions >> $@.symversions)) else cmd_update_lto_symversions = echo >/dev/null -- 2.30.2