Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758142AbcLBULy (ORCPT ); Fri, 2 Dec 2016 15:11:54 -0500 Received: from mail-qk0-f181.google.com ([209.85.220.181]:35349 "EHLO mail-qk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752162AbcLBULw (ORCPT ); Fri, 2 Dec 2016 15:11:52 -0500 Date: Fri, 2 Dec 2016 15:11:50 -0500 (EST) From: Nicolas Pitre To: Paul Bolle cc: Jarod Wilson , Tony Luck , Linus Torvalds , Prarit Bhargava , linux-kernel@vger.kernel.org Subject: Re: Odd build breakage in 4.9-rc7 In-Reply-To: <1480623331.22912.3.camel@tiscali.nl> Message-ID: References: <20161130172435.GG8563@redhat.com> <1480539150.27962.11.camel@tiscali.nl> <942ca543-de49-abda-7e3b-a8a31c0c2c88@redhat.com> <222b47f2-55e0-3410-c87d-183ca5e2a0fe@redhat.com> <1480542127.27962.17.camel@tiscali.nl> <1480543047.27962.23.camel@tiscali.nl> <4330d00e-ed4f-35fe-586e-f3d5dd6db875@redhat.com> <1480582887.27962.48.camel@tiscali.nl> <1480599966.19457.4.camel@tiscali.nl> <1480623331.22912.3.camel@tiscali.nl> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2113 Lines: 59 On Thu, 1 Dec 2016, Paul Bolle wrote: > On Thu, 2016-12-01 at 12:42 -0500, Nicolas Pitre wrote: > > OK I understand what the problem is. However most of those hunks below > > are definitely wrong. ;-) > > Probably. By now I've narrowed it down to just these two hunks: And they're both wrong. ;-) There is no relation between MODVERSIONS and TRIM_UNUSED_KSYMS. > > I'm trying to determine the best way to fix it. Stay tuned. > > Will do. I'm curious to see what a proper fix might look like. Here it is: ----- >8 Subject: kbuild: fix building bzImage with CONFIG_TRIM_UNUSED_KSYMS enabled When building a specific target such as bzImage, modules aren't normally built. However if CONFIG_TRIM_UNUSED_KSYMS is enabled, no built modules means none of the exported symbols are used and therefore they will all be trimmed away from the final kernel. A subsequent "make modules" will fail because modpost cannot find the needed symbols for those modules in the kernel binary. Let's make sure modules are also built whenever CONFIG_TRIM_UNUSED_KSYMS is enabled and that the kernel binary is properly rebuilt accordingly. Signed-off-by: Nicolas Pitre diff --git a/Makefile b/Makefile index 9f9c3b577c..b816089e5d 100644 --- a/Makefile +++ b/Makefile @@ -607,6 +607,13 @@ else include/config/auto.conf: ; endif # $(dot-config) +# For the kernel to actually contain only the needed exported symbols, +# we have to build modules as well to determine what those symbols are. +# (this can be evaluated only once include/config/auto.conf has been included) +ifdef CONFIG_TRIM_UNUSED_KSYMS + KBUILD_MODULES := 1 +endif + # The all: target is the default when no target is given on the # command line. # This allow a user to issue only 'make' to build a kernel including modules @@ -944,7 +951,7 @@ ifdef CONFIG_GDB_SCRIPTS endif ifdef CONFIG_TRIM_UNUSED_KSYMS $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ - "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq" + "$(MAKE) -f $(srctree)/Makefile vmlinux" endif # standalone target for easier testing