summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Hochstein <tom.hochstein@nxp.com>2019-11-14 18:09:36 -0600
committerOtavio Salvador <otavio@ossystems.com.br>2019-11-18 14:43:29 -0300
commitde48050fe0e9015413a01c60bbf5e0469fc1ca50 (patch)
tree161aacdbc298dd2378da42251db67a983a33b778
parent8791f78b8c990e53704b013117f6c53570119ce5 (diff)
downloadmeta-freescale-de48050fe0e9015413a01c60bbf5e0469fc1ca50.tar.gz
linux-fslc-imx_4.9-1.0.x: Backport patches to fix building with gcc 9
Closes #192. Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
-rw-r--r--recipes-kernel/linux/linux-fslc-imx/0001-compiler-attributes-add-support-for-copy-gcc-9.patch132
-rw-r--r--recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch135
-rw-r--r--recipes-kernel/linux/linux-fslc-imx_4.9-1.0.x.bb3
3 files changed, 270 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-fslc-imx/0001-compiler-attributes-add-support-for-copy-gcc-9.patch b/recipes-kernel/linux/linux-fslc-imx/0001-compiler-attributes-add-support-for-copy-gcc-9.patch
new file mode 100644
index 00000000..a234c0c3
--- /dev/null
+++ b/recipes-kernel/linux/linux-fslc-imx/0001-compiler-attributes-add-support-for-copy-gcc-9.patch
@@ -0,0 +1,132 @@
1From mboxrd@z Thu Jan 1 00:00:00 1970
2Return-Path: <SRS0=AQQw=UD=vger.kernel.org=stable-owner@kernel.org>
3X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
4 aws-us-west-2-korg-lkml-1.web.codeaurora.org
5X-Spam-Level:
6X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,
7 DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,
8 SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT
9 autolearn=ham autolearn_force=no version=3.4.0
10Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
11 by smtp.lore.kernel.org (Postfix) with ESMTP id 354C8C282CE
12 for <stable@archiver.kernel.org>; Tue, 4 Jun 2019 13:25:01 +0000 (UTC)
13Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
14 by mail.kernel.org (Postfix) with ESMTP id 0D01C24291
15 for <stable@archiver.kernel.org>; Tue, 4 Jun 2019 13:25:01 +0000 (UTC)
16Authentication-Results: mail.kernel.org;
17 dkim=pass (1024-bit key) header.d=agner.ch header.i=@agner.ch header.b="HG5nfXC5"
18Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
19 id S1727392AbfFDNZA (ORCPT <rfc822;stable@archiver.kernel.org>);
20 Tue, 4 Jun 2019 09:25:00 -0400
21Received: from mail.kmu-office.ch ([178.209.48.109]:48336 "EHLO
22 mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
23 with ESMTP id S1727340AbfFDNZA (ORCPT
24 <rfc822;stable@vger.kernel.org>); Tue, 4 Jun 2019 09:25:00 -0400
25Received: from trochilidae.toradex.int (unknown [46.140.72.82])
26 by mail.kmu-office.ch (Postfix) with ESMTPSA id 8BE845C2138;
27 Tue, 4 Jun 2019 15:24:55 +0200 (CEST)
28DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim;
29 t=1559654695;
30 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
31 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
32 content-transfer-encoding:content-transfer-encoding:in-reply-to:
33 references; bh=2lQNwDLO9/HfsHTvSmLn5csGG1S09yt0LuSYqXeE0y0=;
34 b=HG5nfXC5qPZvu4E7tM2iveXY8wtjralMObB8KMvD1S6NWkkOwkeLjXonm495Hz+G+geOig
35 NlbMrAg5b6wYCzvMgqUeSBmGkYCjB/7IFlotEiTcUNmOCorD2pTasqUOcpObuc6WqBkEjM
36 3seyrLJVs51y9A3weXf9CMO3OMOXwRA=
37From: Stefan Agner <stefan@agner.ch>
38To: gregkh@linuxfoundation.org
39Cc: stable@vger.kernel.org,
40 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
41 Martin Sebor <msebor@gcc.gnu.org>,
42 Nick Desaulniers <ndesaulniers@google.com>,
43 Stefan Agner <stefan@agner.ch>
44Subject: [PATCH BACKPORT 4.19 1/2] Compiler Attributes: add support for __copy (gcc >= 9)
45Date: Tue, 4 Jun 2019 15:24:40 +0200
46Message-Id: <20190604132441.15383-1-stefan@agner.ch>
47X-Mailer: git-send-email 2.21.0
48MIME-Version: 1.0
49Content-Type: text/plain; charset=UTF-8
50Content-Transfer-Encoding: 8bit
51Sender: stable-owner@vger.kernel.org
52Precedence: bulk
53List-ID: <stable.vger.kernel.org>
54X-Mailing-List: stable@vger.kernel.org
55Archived-At: <https://lore.kernel.org/stable/20190604132441.15383-1-stefan@agner.ch/>
56List-Archive: <https://lore.kernel.org/stable/>
57List-Post: <mailto:stable@vger.kernel.org>
58
59From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
60
61[ Upstream commit c0d9782f5b6d7157635ae2fd782a4b27d55a6013 ]
62
63>From the GCC manual:
64
65 copy
66 copy(function)
67
68 The copy attribute applies the set of attributes with which function
69 has been declared to the declaration of the function to which
70 the attribute is applied. The attribute is designed for libraries
71 that define aliases or function resolvers that are expected
72 to specify the same set of attributes as their targets. The copy
73 attribute can be used with functions, variables, or types. However,
74 the kind of symbol to which the attribute is applied (either
75 function or variable) must match the kind of symbol to which
76 the argument refers. The copy attribute copies only syntactic and
77 semantic attributes but not attributes that affect a symbol’s
78 linkage or visibility such as alias, visibility, or weak.
79 The deprecated attribute is also not copied.
80
81 https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
82
83The upcoming GCC 9 release extends the -Wmissing-attributes warnings
84(enabled by -Wall) to C and aliases: it warns when particular function
85attributes are missing in the aliases but not in their target, e.g.:
86
87 void __cold f(void) {}
88 void __alias("f") g(void);
89
90diagnoses:
91
92 warning: 'g' specifies less restrictive attribute than
93 its target 'f': 'cold' [-Wmissing-attributes]
94
95Using __copy(f) we can copy the __cold attribute from f to g:
96
97 void __cold f(void) {}
98 void __copy(f) __alias("f") g(void);
99
100This attribute is most useful to deal with situations where an alias
101is declared but we don't know the exact attributes the target has.
102
103For instance, in the kernel, the widely used module_init/exit macros
104define the init/cleanup_module aliases, but those cannot be marked
105always as __init/__exit since some modules do not have their
106functions marked as such.
107
108Cc: <stable@vger.kernel.org> # 4.14+
109Suggested-by: Martin Sebor <msebor@gcc.gnu.org>
110Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
111Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
112Signed-off-by: Stefan Agner <stefan@agner.ch>
113---
114 include/linux/compiler-gcc.h | 4 ++++
115 include/linux/compiler_types.h | 4 ++++
116 2 files changed, 8 insertions(+)
117
118Index: git/include/linux/compiler-gcc.h
119===================================================================
120--- git.orig/include/linux/compiler-gcc.h
121+++ git/include/linux/compiler-gcc.h
122@@ -282,6 +282,10 @@
123
124 #endif /* gcc version >= 40000 specific checks */
125
126+#if GCC_VERSION >= 90100
127+#define __copy(symbol) __attribute__((__copy__(symbol)))
128+#endif
129+
130 #if !defined(__noclone)
131 #define __noclone /* not needed */
132 #endif
diff --git a/recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch b/recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch
new file mode 100644
index 00000000..758a8a07
--- /dev/null
+++ b/recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-init-exit-attrs-to-.patch
@@ -0,0 +1,135 @@
1From mboxrd@z Thu Jan 1 00:00:00 1970
2Return-Path: <SRS0=AQQw=UD=vger.kernel.org=stable-owner@kernel.org>
3X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
4 aws-us-west-2-korg-lkml-1.web.codeaurora.org
5X-Spam-Level:
6X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,
7 DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,
8 SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT
9 autolearn=ham autolearn_force=no version=3.4.0
10Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
11 by smtp.lore.kernel.org (Postfix) with ESMTP id 63BF0C46470
12 for <stable@archiver.kernel.org>; Tue, 4 Jun 2019 13:25:01 +0000 (UTC)
13Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
14 by mail.kernel.org (Postfix) with ESMTP id 3D9B223D29
15 for <stable@archiver.kernel.org>; Tue, 4 Jun 2019 13:25:01 +0000 (UTC)
16Authentication-Results: mail.kernel.org;
17 dkim=pass (1024-bit key) header.d=agner.ch header.i=@agner.ch header.b="QWkQ/3jN"
18Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
19 id S1727340AbfFDNZA (ORCPT <rfc822;stable@archiver.kernel.org>);
20 Tue, 4 Jun 2019 09:25:00 -0400
21Received: from mail.kmu-office.ch ([178.209.48.109]:48348 "EHLO
22 mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
23 with ESMTP id S1727343AbfFDNZA (ORCPT
24 <rfc822;stable@vger.kernel.org>); Tue, 4 Jun 2019 09:25:00 -0400
25Received: from trochilidae.toradex.int (unknown [46.140.72.82])
26 by mail.kmu-office.ch (Postfix) with ESMTPSA id A3CC45C1F29;
27 Tue, 4 Jun 2019 15:24:57 +0200 (CEST)
28DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim;
29 t=1559654697;
30 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
31 to:to:cc:cc:mime-version:mime-version:content-type:
32 content-transfer-encoding:content-transfer-encoding:
33 in-reply-to:in-reply-to:references:references;
34 bh=tc6JvYRo2QJoJQVnFd/oGDG0/z6TF30OxAP+nBfruDc=;
35 b=QWkQ/3jNBkysiiD5SMb2UF+0YtSMCbOyP2/dUXeDQChYIal8jUex+QvYHjBh6l4Gff6WwG
36 3Zd44X6jE/KqxygBkoglOSb/dHwZ5AS8B8vpUM8vh2CzhrW4fD9eguoEIImOJJZ9RHgx0b
37 Gwno+ZPPhuPOcFbSrBwNsKK6mZLGttY=
38From: Stefan Agner <stefan@agner.ch>
39To: gregkh@linuxfoundation.org
40Cc: stable@vger.kernel.org,
41 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
42 Martin Sebor <msebor@gcc.gnu.org>,
43 Jessica Yu <jeyu@kernel.org>, Stefan Agner <stefan@agner.ch>
44Subject: [PATCH BACKPORT 4.19 2/2] include/linux/module.h: copy __init/__exit attrs to init/cleanup_module
45Date: Tue, 4 Jun 2019 15:24:41 +0200
46Message-Id: <20190604132441.15383-2-stefan@agner.ch>
47X-Mailer: git-send-email 2.21.0
48In-Reply-To: <20190604132441.15383-1-stefan@agner.ch>
49References: <20190604132441.15383-1-stefan@agner.ch>
50MIME-Version: 1.0
51Content-Transfer-Encoding: 8bit
52Sender: stable-owner@vger.kernel.org
53Precedence: bulk
54List-ID: <stable.vger.kernel.org>
55X-Mailing-List: stable@vger.kernel.org
56Archived-At: <https://lore.kernel.org/stable/20190604132441.15383-2-stefan@agner.ch/>
57List-Archive: <https://lore.kernel.org/stable/>
58List-Post: <mailto:stable@vger.kernel.org>
59
60From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
61
62[ Upstream commit a6e60d84989fa0e91db7f236eda40453b0e44afa ]
63
64The upcoming GCC 9 release extends the -Wmissing-attributes warnings
65(enabled by -Wall) to C and aliases: it warns when particular function
66attributes are missing in the aliases but not in their target.
67
68In particular, it triggers for all the init/cleanup_module
69aliases in the kernel (defined by the module_init/exit macros),
70ending up being very noisy.
71
72These aliases point to the __init/__exit functions of a module,
73which are defined as __cold (among other attributes). However,
74the aliases themselves do not have the __cold attribute.
75
76Since the compiler behaves differently when compiling a __cold
77function as well as when compiling paths leading to calls
78to __cold functions, the warning is trying to point out
79the possibly-forgotten attribute in the alias.
80
81In order to keep the warning enabled, we decided to silence
82this case. Ideally, we would mark the aliases directly
83as __init/__exit. However, there are currently around 132 modules
84in the kernel which are missing __init/__exit in their init/cleanup
85functions (either because they are missing, or for other reasons,
86e.g. the functions being called from somewhere else); and
87a section mismatch is a hard error.
88
89A conservative alternative was to mark the aliases as __cold only.
90However, since we would like to eventually enforce __init/__exit
91to be always marked, we chose to use the new __copy function
92attribute (introduced by GCC 9 as well to deal with this).
93With it, we copy the attributes used by the target functions
94into the aliases. This way, functions that were not marked
95as __init/__exit won't have their aliases marked either,
96and therefore there won't be a section mismatch.
97
98Note that the warning would go away marking either the extern
99declaration, the definition, or both. However, we only mark
100the definition of the alias, since we do not want callers
101(which only see the declaration) to be compiled as if the function
102was __cold (and therefore the paths leading to those calls
103would be assumed to be unlikely).
104
105Cc: <stable@vger.kernel.org> # 4.14+
106Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/
107Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/
108Suggested-by: Martin Sebor <msebor@gcc.gnu.org>
109Acked-by: Jessica Yu <jeyu@kernel.org>
110Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
111Signed-off-by: Stefan Agner <stefan@agner.ch>
112---
113 include/linux/module.h | 4 ++--
114 1 file changed, 2 insertions(+), 2 deletions(-)
115
116Index: git/include/linux/module.h
117===================================================================
118--- git.orig/include/linux/module.h
119+++ git/include/linux/module.h
120@@ -129,13 +129,13 @@ extern void cleanup_module(void);
121 #define module_init(initfn) \
122 static inline initcall_t __inittest(void) \
123 { return initfn; } \
124- int init_module(void) __attribute__((alias(#initfn)));
125+ int init_module(void) __copy(initfn) __attribute__((alias(#initfn)));
126
127 /* This is only required if you want to be unloadable. */
128 #define module_exit(exitfn) \
129 static inline exitcall_t __exittest(void) \
130 { return exitfn; } \
131- void cleanup_module(void) __attribute__((alias(#exitfn)));
132+ void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn)));
133
134 #endif
135
diff --git a/recipes-kernel/linux/linux-fslc-imx_4.9-1.0.x.bb b/recipes-kernel/linux/linux-fslc-imx_4.9-1.0.x.bb
index aff27bbf..3f4371d3 100644
--- a/recipes-kernel/linux/linux-fslc-imx_4.9-1.0.x.bb
+++ b/recipes-kernel/linux/linux-fslc-imx_4.9-1.0.x.bb
@@ -12,5 +12,8 @@ PV .= "+git${SRCPV}"
12 12
13SRCBRANCH = "4.9-1.0.x-imx" 13SRCBRANCH = "4.9-1.0.x-imx"
14SRCREV = "953c6e30c9701fda69ef08e2476c541dc4fb1453" 14SRCREV = "953c6e30c9701fda69ef08e2476c541dc4fb1453"
15SRC_URI += "file://0001-compiler-attributes-add-support-for-copy-gcc-9.patch \
16 file://0002-include-linux-module.h-copy-init-exit-attrs-to-.patch \
17 "
15 18
16COMPATIBLE_MACHINE = "(mx6|mx7)" 19COMPATIBLE_MACHINE = "(mx6|mx7)"