<div dir="ltr">I already have this queued, I&#39;m just not sending any kernel pull requests while<div>the release is finalizing.</div><div><br></div><div>So please, do not queue or merge this change.</div><div><br></div><div>Bruce</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 12, 2017 at 10:59 PM, Khem Raj <span dir="ltr">&lt;<a href="mailto:raj.khem@gmail.com" target="_blank">raj.khem@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Khem Raj &lt;<a href="mailto:raj.khem@gmail.com">raj.khem@gmail.com</a>&gt;<br>
---<br>
 ...ve-up-on-gcc-ilog2-<wbr>constant-optimizations.patch | 134 +++++++++++++++++++++<br>
 meta/recipes-kernel/linux/<a href="http://linux-yocto_4.1.bb" rel="noreferrer" target="_blank">linu<wbr>x-yocto_4.1.bb</a>       |   2 +<br>
 2 files changed, 136 insertions(+)<br>
 create mode 100644 meta/recipes-kernel/linux/<wbr>linux-yocto/0001-give-up-on-<wbr>gcc-ilog2-constant-<wbr>optimizations.patch<br>
<br>
diff --git a/meta/recipes-kernel/linux/<wbr>linux-yocto/0001-give-up-on-<wbr>gcc-ilog2-constant-<wbr>optimizations.patch b/meta/recipes-kernel/linux/<wbr>linux-yocto/0001-give-up-on-<wbr>gcc-ilog2-constant-<wbr>optimizations.patch<br>
new file mode 100644<br>
index 0000000000..35c4484f20<br>
--- /dev/null<br>
+++ b/meta/recipes-kernel/linux/<wbr>linux-yocto/0001-give-up-on-<wbr>gcc-ilog2-constant-<wbr>optimizations.patch<br>
@@ -0,0 +1,134 @@<br>
+From 273bf720b7acb5f808337fe57c5f40<wbr>0422a30051 Mon Sep 17 00:00:00 2001<br>
+From: Linus Torvalds &lt;<a href="mailto:torvalds@linux-foundation.org">torvalds@linux-foundation.org</a><wbr>&gt;<br>
+Date: Thu, 2 Mar 2017 12:17:22 -0800<br>
+Subject: [PATCH] give up on gcc ilog2() constant optimizations<br>
+<br>
+commit 474c90156c8dcc2fa815e6716cc939<wbr>4d7930cb9c upstream.<br>
+<br>
+gcc-7 has an &quot;optimization&quot; pass that completely screws up, and<br>
+generates the code expansion for the (impossible) case of calling<br>
+ilog2() with a zero constant, even when the code gcc compiles does not<br>
+actually have a zero constant.<br>
+<br>
+And we try to generate a compile-time error for anybody doing ilog2() on<br>
+a constant where that doesn&#39;t make sense (be it zero or negative).  So<br>
+now gcc7 will fail the build due to our sanity checking, because it<br>
+created that constant-zero case that didn&#39;t actually exist in the source<br>
+code.<br>
+<br>
+There&#39;s a whole long discussion on the kernel mailing about how to work<br>
+around this gcc bug.  The gcc people themselevs have discussed their<br>
+&quot;feature&quot; in<br>
+<br>
+   <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785" rel="noreferrer" target="_blank">https://gcc.gnu.org/bugzilla/<wbr>show_bug.cgi?id=72785</a><br>
+<br>
+but it&#39;s all water under the bridge, because while it looked at one<br>
+point like it would be solved by the time gcc7 was released, that was<br>
+not to be.<br>
+<br>
+So now we have to deal with this compiler braindamage.<br>
+<br>
+And the only simple approach seems to be to just delete the code that<br>
+tries to warn about bad uses of ilog2().<br>
+<br>
+So now &quot;ilog2()&quot; will just return 0 not just for the value 1, but for<br>
+any non-positive value too.<br>
+<br>
+It&#39;s not like I can recall anybody having ever actually tried to use<br>
+this function on any invalid value, but maybe the sanity check just<br>
+meant that such code never made it out in public.<br>
+<br>
+Reported-by: Laura Abbott &lt;<a href="mailto:labbott@redhat.com">labbott@redhat.com</a>&gt;<br>
+Cc: John Stultz &lt;<a href="mailto:john.stultz@linaro.org">john.stultz@linaro.org</a>&gt;,<br>
+Cc: Thomas Gleixner &lt;<a href="mailto:tglx@linutronix.de">tglx@linutronix.de</a>&gt;<br>
+Cc: Ard Biesheuvel &lt;<a href="mailto:ard.biesheuvel@linaro.org">ard.biesheuvel@linaro.org</a>&gt;<br>
+Signed-off-by: Linus Torvalds &lt;<a href="mailto:torvalds@linux-foundation.org">torvalds@linux-foundation.org</a><wbr>&gt;<br>
+Cc: Jiri Slaby &lt;<a href="mailto:jslaby@suse.cz">jslaby@suse.cz</a>&gt;<br>
+Signed-off-by: Greg Kroah-Hartman &lt;<a href="mailto:gregkh@linuxfoundation.org">gregkh@linuxfoundation.org</a>&gt;<br>
+Signed-off-by: Khem Raj &lt;<a href="mailto:raj.khem@gmail.com">raj.khem@gmail.com</a>&gt;<br>
+---<br>
+Upstream-Status: Backport<br>
+<br>
+ include/linux/log2.h       | 13 ++-----------<br>
+ tools/include/linux/log2.h | 13 ++-----------<br>
+ 2 files changed, 4 insertions(+), 22 deletions(-)<br>
+<br>
+diff --git a/include/linux/log2.h b/include/linux/log2.h<br>
+index fd7ff3d91e6a..f38fae23bdac 100644<br>
+--- a/include/linux/log2.h<br>
++++ b/include/linux/log2.h<br>
+@@ -16,12 +16,6 @@<br>
+ #include &lt;linux/bitops.h&gt;<br>
+<br>
+ /*<br>
+- * deal with unrepresentable constant logarithms<br>
+- */<br>
+-extern __attribute__((const, noreturn))<br>
+-int ____ilog2_NaN(void);<br>
+-<br>
+-/*<br>
+  * non-constant log of base 2 calculators<br>
+  * - the arch may override these in asm/bitops.h if they can be implemented<br>
+  *   more efficiently than using fls() and fls64()<br>
+@@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(<wbr>unsigned long n)<br>
+ #define ilog2(n)                              \<br>
+ (                                             \<br>
+       __builtin_constant_p(n) ? (             \<br>
+-              (n) &lt; 1 ? ____ilog2_NaN() :     \<br>
++              (n) &lt; 2 ? 0 :                   \<br>
+               (n) &amp; (1ULL &lt;&lt; 63) ? 63 :       \<br>
+               (n) &amp; (1ULL &lt;&lt; 62) ? 62 :       \<br>
+               (n) &amp; (1ULL &lt;&lt; 61) ? 61 :       \<br>
+@@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(<wbr>unsigned long n)<br>
+               (n) &amp; (1ULL &lt;&lt;  4) ?  4 :       \<br>
+               (n) &amp; (1ULL &lt;&lt;  3) ?  3 :       \<br>
+               (n) &amp; (1ULL &lt;&lt;  2) ?  2 :       \<br>
+-              (n) &amp; (1ULL &lt;&lt;  1) ?  1 :       \<br>
+-              (n) &amp; (1ULL &lt;&lt;  0) ?  0 :       \<br>
+-              ____ilog2_NaN()                 \<br>
+-                                 ) :          \<br>
++              1 ) :                           \<br>
+       (sizeof(n) &lt;= 4) ?                      \<br>
+       __ilog2_u32(n) :                        \<br>
+       __ilog2_u64(n)                          \<br>
+diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h<br>
+index 41446668ccce..d5677d39c1e4 100644<br>
+--- a/tools/include/linux/log2.h<br>
++++ b/tools/include/linux/log2.h<br>
+@@ -13,12 +13,6 @@<br>
+ #define _TOOLS_LINUX_LOG2_H<br>
+<br>
+ /*<br>
+- * deal with unrepresentable constant logarithms<br>
+- */<br>
+-extern __attribute__((const, noreturn))<br>
+-int ____ilog2_NaN(void);<br>
+-<br>
+-/*<br>
+  * non-constant log of base 2 calculators<br>
+  * - the arch may override these in asm/bitops.h if they can be implemented<br>
+  *   more efficiently than using fls() and fls64()<br>
+@@ -78,7 +72,7 @@ unsigned long __rounddown_pow_of_two(<wbr>unsigned long n)<br>
+ #define ilog2(n)                              \<br>
+ (                                             \<br>
+       __builtin_constant_p(n) ? (             \<br>
+-              (n) &lt; 1 ? ____ilog2_NaN() :     \<br>
++              (n) &lt; 2 ? 0 :                   \<br>
+               (n) &amp; (1ULL &lt;&lt; 63) ? 63 :       \<br>
+               (n) &amp; (1ULL &lt;&lt; 62) ? 62 :       \<br>
+               (n) &amp; (1ULL &lt;&lt; 61) ? 61 :       \<br>
+@@ -141,10 +135,7 @@ unsigned long __rounddown_pow_of_two(<wbr>unsigned long n)<br>
+               (n) &amp; (1ULL &lt;&lt;  4) ?  4 :       \<br>
+               (n) &amp; (1ULL &lt;&lt;  3) ?  3 :       \<br>
+               (n) &amp; (1ULL &lt;&lt;  2) ?  2 :       \<br>
+-              (n) &amp; (1ULL &lt;&lt;  1) ?  1 :       \<br>
+-              (n) &amp; (1ULL &lt;&lt;  0) ?  0 :       \<br>
+-              ____ilog2_NaN()                 \<br>
+-                                 ) :          \<br>
++              1 ) :                           \<br>
+       (sizeof(n) &lt;= 4) ?                      \<br>
+       __ilog2_u32(n) :                        \<br>
+       __ilog2_u64(n)                          \<br>
+--<br>
+2.12.2<br>
+<br>
diff --git a/meta/recipes-kernel/linux/<a href="http://linux-yocto_4.1.bb" rel="noreferrer" target="_blank">li<wbr>nux-yocto_4.1.bb</a> b/meta/recipes-kernel/linux/<a href="http://linux-yocto_4.1.bb" rel="noreferrer" target="_blank">li<wbr>nux-yocto_4.1.bb</a><br>
index bf7f266ee6..f90d5159d5 100644<br>
--- a/meta/recipes-kernel/linux/<a href="http://linux-yocto_4.1.bb" rel="noreferrer" target="_blank">li<wbr>nux-yocto_4.1.bb</a><br>
+++ b/meta/recipes-kernel/linux/<a href="http://linux-yocto_4.1.bb" rel="noreferrer" target="_blank">li<wbr>nux-yocto_4.1.bb</a><br>
@@ -24,6 +24,8 @@ SRCREV_meta ?= &quot;<wbr>7140ddb86e4b01529185e6d4a60600<wbr>1ad152b8f3&quot;<br>
 SRC_URI = &quot;git://<a href="http://git.yoctoproject.org/linux-yocto-4.1.git;name=machine;branch=${KBRANCH}" rel="noreferrer" target="_blank">git.yoctoproject.org/<wbr>linux-yocto-4.1.git;name=<wbr>machine;branch=${KBRANCH}</a>; \<br>
            git://<a href="http://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.1;destsuffix=${KMETA}" rel="noreferrer" target="_blank">git.yoctoproject.org/<wbr>yocto-kernel-cache;type=kmeta;<wbr>name=meta;branch=yocto-4.1;<wbr>destsuffix=${KMETA}</a>&quot;<br>
<br>
+SRC_URI += &quot;file://0001-give-up-on-gcc-<wbr>ilog2-constant-optimizations.<wbr>patch&quot;<br>
+<br>
 LINUX_VERSION ?= &quot;4.1.38&quot;<br>
<br>
 PV = &quot;${LINUX_VERSION}+git${SRCPV}&quot;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
--<br>
______________________________<wbr>_________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">&quot;Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end&quot;</div>
</div>