From patchwork Fri Dec 2 20:11:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 86355 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp425537qgi; Fri, 2 Dec 2016 12:12:03 -0800 (PST) X-Received: by 10.84.204.133 with SMTP id b5mr99997186ple.49.1480709523151; Fri, 02 Dec 2016 12:12:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si6389804plk.59.2016.12.02.12.12.02; Fri, 02 Dec 2016 12:12:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758145AbcLBULy (ORCPT + 25 others); 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 Received: by mail-qk0-f181.google.com with SMTP id n204so290546365qke.2 for ; Fri, 02 Dec 2016 12:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=6PVdimdXU+/cH9Qdf+x77uofot4r3vmPaKJJxzIFX8c=; b=cn9G3ozjBpU1em8PYxhMqmv4C2rGgQwHbcEuDEfZbdaKITPD4f0nC2Nn7QVm1e1nke yAKHX9i883n6UHkKbErA6kaPuGtWRbaBgO7gzwB1+OtHH0ZMtBArOnM2wfrQprmp4/sV OJ1OotFvVkoWn1e0PA8LZoWXT9VT0ZtF8YVgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=6PVdimdXU+/cH9Qdf+x77uofot4r3vmPaKJJxzIFX8c=; b=iJS0FdkcHUpRfGBzdvY5BRBgKa4j6WvNY3YOqtH8WOyFa3KjD5yjQpIlqRTpsDnlCP f9vtC7gaZy3mguGlP3hoM35JfPmKMWA1FRS4xPLsWagAgaV6zxEqVmKmhWyu1LQqFXs7 BDtY/qE2neC8gVXTxz1Nnuz2oCV7z2dySM1fbrUHS+Or10Vhg6QPI7WZCRZnXmZM3DwX 46sDTlHix/eTmunftRvItvjVbKwSb+wNYAhDsgnRAUVeAefyswGdmtNlXPgFrCLBshEb XlDepJONBP+JLeEyz0naQBqqCoKJ9HJ3+KepdgtpkLgHVAjnr9gZ7Sb3rX+iHVDAd0sF VcRA== X-Gm-Message-State: AKaTC00fKNN+yCQhsh+EP9ULnhDYZrpfbhbyHdW2xsgNc6UnNsomNSyfUGl5iDzLhbkp2wNN X-Received: by 10.55.6.11 with SMTP id 11mr37698199qkg.29.1480709511876; Fri, 02 Dec 2016 12:11:51 -0800 (PST) Received: from xanadu.home ([2607:fa48:6e39:d410:feaa:14ff:fea7:ed77]) by smtp.gmail.com with ESMTPSA id p19sm3405072qtp.4.2016.12.02.12.11.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 12:11:51 -0800 (PST) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Jarod Wilson 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