Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1877339ybt; Thu, 2 Jul 2020 16:42:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5J8OZbySEtDRr7syKbCJK8SpfwHokzWyH+LTKZZBIQSKqoXaWnJqt37G2ilQ9i//XuSUI X-Received: by 2002:aa7:da89:: with SMTP id q9mr38058705eds.273.1593733363270; Thu, 02 Jul 2020 16:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593733363; cv=none; d=google.com; s=arc-20160816; b=ck+8PVSq5qgE5Tn26VtdhNlnGryIRce0iCoBr3UFhuA6802STIJYf95M+zUonmLjZ1 wUClRPB+C1WiJZCuvrUtKzfFws6FUS8qtmZQwlP9bGgky0Hs5dvwDXQ9Rti6jmKHmJUL PhXa909eWCP10ma5YpLW0mGstbv2hcI+xGuUmizZLwOaX5XcReUXnCKv76IKBybpZ09m I6kxkGKUe6Qo58fb9cJMd2J2DSzUDHkBun8mR7OAvxnN8UYegmIR4oCa/UKSqkIKNbpD 0vX3gFfkxTvDLFF7wJUlzUgz967hp5ucMAWYXYoPtOycYvxSnTVG+qbn8vT4zZWaDCFN qMPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=aUKX8t6lKl6VE3fnEcWtgjKc9bud69PiShCeCobiMYA=; b=FFO17hp09gpaVb8nICN8X0X36GzHP+kuLAqsvt6HsaphsbBWDmq0n18CKsD6dhzrZT NKHKNakB+5xsXot/G6c80WfjN3JMYelnvIDBhly1lEOHfb0qZ2u8S2L0L3XLKIAN734b diPqXjlt0zTWXKceMIdtCosNAC77DP6zvL2fpLWiqggBEvKCpZV0DRwahHbHCF7NKLYL hpI6GNsjnrJx/ZcpZGRiv3xJbxxkc+fv5KCfnqgqksfXwWGfz+D+fP2GQ8hnl01/umy9 iT1xNSi4Q+jyMaX6nPTv9PKigHQ7H5zmM2zOXupjRfLQLssw/MNDQQSUnukDCaJIpI18 FV0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdrag0n.dev header.s=fm1 header.b=EfqiGped; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=hnVWUEOl; 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=kdrag0n.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq6si6789814ejb.108.2020.07.02.16.42.19; Thu, 02 Jul 2020 16:42:43 -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=@kdrag0n.dev header.s=fm1 header.b=EfqiGped; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=hnVWUEOl; 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=kdrag0n.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbgGBXjf (ORCPT + 99 others); Thu, 2 Jul 2020 19:39:35 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:55243 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbgGBXjf (ORCPT ); Thu, 2 Jul 2020 19:39:35 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B03BD5C016C; Thu, 2 Jul 2020 19:39:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 02 Jul 2020 19:39:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kdrag0n.dev; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=aUKX8t6lKl6VE3fnEcWtgjKc9b ud69PiShCeCobiMYA=; b=EfqiGpedOuskUcm4EYggaVqmYhJKSGz/JT+V1rLHHO EBJyNtsEaVWjnQHclxQSxKC5csQrwkNjFvfaoO8wOZnP2EFTw8uooWBZ4gE1T4dB o3qz0myHQrb2aGJGkKemJTN3E0l+2bO/uHd5W43MZK3klSDbNzHF5EYoZpLxFtq8 j9Cc3P6RzVmqLDez/C3v1hCl2PMsPGeOq/JNMsgAk1jxyLIry7wLCScmQNhkMAU/ dj5aD3TZbguT40rUYuAEumoAYnV5NfWvs3btSUC9cbl7i2KOr8R9bUl2/4F1I1VQ /EXpobCJOB8p1/5pPC5WxH4MYVvH4/HUEaLStrL5fiFg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=aUKX8t6lKl6VE3fnE cWtgjKc9bud69PiShCeCobiMYA=; b=hnVWUEOlXL9MpHbzPilmVr6Ns3AIQlBc/ t6NYU8RoJ5e+//X/RQ+IKPWsbda+rVzPqpE4MmhHKQlCGxfpWKiw6+/folOusKyA s4xSdjIRpnhTp8mSqolGznbIsQ/Esxl7vsYX5PA4LtY2Z1xwtQuclutAsNeV7tjR 1tsqJSrR3cK+iU6n81RvZ/fIBg0f4bn8bAXF7PioQ0mUgD453oXIY1MLOswyX7JZ 0Sp5zAOc1Y+NH3eu+hQQQO9fQMDdsj6fC7WoA5IeELNE1ZNvHH32XUDxmWavtrA8 vic71hzk9XSYs3JzN1hKTQWWgNotL9Zf2wq6mYB25syrZZbWyX9BQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtdehgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepffgrnhhnhicunfhi nhcuoegurghnnhihsehkughrrghgtdhnrdguvghvqeenucggtffrrghtthgvrhhnpefhie fhgfelgfdufedvudelvdefvdefgfeiueeufeegteffudekgefhvedtieefteenucfkphep jeefrddvvdehrdegrddufeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepuggrnhhnhieskhgurhgrghdtnhdruggvvh X-ME-Proxy: Received: from pinwheel.hsd1.wa.comcast.net (c-73-225-4-138.hsd1.wa.comcast.net [73.225.4.138]) by mail.messagingengine.com (Postfix) with ESMTPA id F0DB73060062; Thu, 2 Jul 2020 19:39:31 -0400 (EDT) From: Danny Lin To: Masahiro Yamada , Michal Marek Cc: Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Kees Cook , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Danny Lin Subject: [PATCH] kbuild: Allow Clang global merging if !MODULES Date: Thu, 2 Jul 2020 16:39:29 -0700 Message-Id: <20200702233929.181409-1-danny@kdrag0n.dev> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The old reasoning for disabling Clang's global merging optimization is that it breaks modpost by coalescing many symbols into _MergedGlobals. However, modpost is only used in builds with dynamic modules; vmlinux.symvers is still created during standalone builds, but it's effectively just an empty dummy file. Enabling the optimization whenever possible allows us to reap the benefits of reduced register pressure when many global variables are used in the same function. An x86 defconfig kernel built with this optimization boots fine in qemu, and a downstream 4.14 kernel has been used on arm64 for nearly a year without any issues caused by this optimization. Signed-off-by: Danny Lin --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index a60c98519c37..f04c3639cf61 100644 --- a/Makefile +++ b/Makefile @@ -772,10 +772,13 @@ ifdef CONFIG_CC_IS_CLANG KBUILD_CPPFLAGS += -Qunused-arguments KBUILD_CFLAGS += -Wno-format-invalid-specifier KBUILD_CFLAGS += -Wno-gnu + +ifdef CONFIG_MODULES # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the # source of a reference will be _MergedGlobals and not on of the whitelisted names. # See modpost pattern 2 KBUILD_CFLAGS += -mno-global-merge +endif else # These warnings generated too much noise in a regular build. -- 2.27.0