<div dir="ltr"><div><div><div><div><div>Hi all<br><br></div>Sorry for the big delay on this issue.<br><br></div>Now that I've spent a few hours looking at the code, I can firmly say this is a compiler bug.<br><br></div>


I've studied beecrypt's sha384.c code (openssl and others implement exactly the same code from a common source) and I've managed to reduce the code to what I think is a minimal example of bug triggering code.<br>


<br>After requesting gcc to preprocess the source, the same error still happens. Almost any minimal change I've tried to the preprocessed source makes the error go away (indexes or values seem to be irrelevant, I've just mantained the numbers the code came from). An optimization flag is required to trigger the bug (-Os, -O1,2,3). I haven't been successful trying to find which specific optimization flag is the one that causes the error.<br>


<br></div>I've manually merged both (original and preprocessed files) to ease the analysis of the original source code and the resulting code. I'm sorry I can't provide any more information, I really don't have any grasp of gcc's internals.<br>


<br></div>Best regards<br><br><div><br>~buildroot/output/build/beecrypt-4.2.1 (bug-microblaze)$ cat minimal-preprocessed.c<br># 1 "minimal.c"<br># 1 "<built-in>"<br># 1 "<command-line>"<br>


# 1 "minimal.c"<br>typedef unsigned long long int uint64_t;<br># 3 "minimal.c"<br>/*<br>#define ROTR64(x, s) (((x) >> (s)) | ((x) << (64 - (s))))<br><br>#define S(x,s) ROTR64(x, s)<br>#define CH(x,y,z) ((x&(y^z))^z)<br>


#define MAJ(x,y,z) (((x|y)&z)|(x&y))<br>#define SIG0(x) (S(x,28) ^ S(x,34) ^ S(x,39))<br>#define SIG1(x) (S(x,14) ^ S(x,18) ^ S(x,41))<br><br>#define ROUND(a,b,c,d,e,f,g,h,w,k)    \<br>    temp = h + SIG1(e) + CH(e,f,g) + k + w;    \<br>


    h = temp + SIG0(a) + MAJ(a,b,c);    \<br>    d += temp<br>*/<br># 16 "minimal.c"<br>void sha384Process(uint64_t *hh)<br>{<br> uint64_t a, b, c, d, e, f, g, h, temp;<br> uint64_t *w;<br> const uint64_t *k;<br>


 unsigned char t;<br><br> /* Expansion of ROUND(f,g,h,a,b,c,d,e,w[75],k[75]); */<br> temp = e + ((((b) >> (14)) | ((b) << (64 - (14)))) ^ (((b) >> (18)) | ((b) << (64 - (18)))) ^ (((b) >> (41)) | ((b) << (64 - (41))))) + ((b&(c^d))^d) + k[75] + w[75];<br>


 e = temp + ((((f) >> (28)) | ((f) << (64 - (28)))) ^ (((f) >> (34)) | ((f) << (64 - (34)))) ^ (((f) >> (39)) | ((f) << (64 - (39))))) + (((f|g)&h)|(f&g));<br> a += temp;<br><br>


 /* Expansion of ROUND(e,f,g,h,a,b,c,d,w[76],k[76]); */<br> temp = d + ((((a) >> (14)) | ((a) << (64 - (14)))) ^ (((a) >> (18)) | ((a) << (64 - (18)))) ^ (((a) >> (41)) | ((a) << (64 - (41))))) + ((a&(b^c))^c) + k[76] + w[76];<br>


 d = temp + ((((e) >> (28)) | ((e) << (64 - (28)))) ^ (((e) >> (34)) | ((e) << (64 - (34)))) ^ (((e) >> (39)) | ((e) << (64 - (39))))) + (((e|f)&g)|(e&f));<br> h += temp;<br><br>


 /* Expansion of ROUND(d,e,f,g,h,a,b,c,w[77],k[77]); */<br> temp = c + ((((h) >> (14)) | ((h) << (64 - (14)))) ^ (((h) >> (18)) | ((h) << (64 - (18)))) ^ (((h) >> (41)) | ((h) << (64 - (41))))) + ((h&(a^b))^b) + k[77] + w[77];<br>


 c = temp + ((((d) >> (28)) | ((d) << (64 - (28)))) ^ (((d) >> (34)) | ((d) << (64 - (34)))) ^ (((d) >> (39)) | ((d) << (64 - (39))))) + (((d|e)&f)|(d&e));<br> g += temp;<br><br>


 /* Expansion of ROUND(c,d,e,f,g,h,a,b,w[78],k[78]); */<br> temp = b + ((((g) >> (14)) | ((g) << (64 - (14)))) ^ (((g) >> (18)) | ((g) << (64 - (18)))) ^ (((g) >> (41)) | ((g) << (64 - (41))))) + ((g&(h^a))^a) + k[78] + w[78];<br>


 b = temp + ((((c) >> (28)) | ((c) << (64 - (28)))) ^ (((c) >> (34)) | ((c) << (64 - (34)))) ^ (((c) >> (39)) | ((c) << (64 - (39))))) + (((c|d)&e)|(c&d));<br> f += temp;<br><br>


 hh[0] += a;<br> hh[1] += b;<br> hh[2] += c;<br> hh[3] += d;<br> hh[4] += e;<br> hh[5] += f;<br> hh[6] += g;<br> hh[7] += h;<br>}<br><br><br>~buildroot/output/build/beecrypt-4.2.1 (bug-microblaze)$ ../../host/usr/bin/microblazeel-unknown-linux-gnu-gcc  -Os -c minimal-preprocessed.c<br>


minimal.c: In function 'sha384Process':<br>minimal.c:51:1: internal compiler error: in reload, at reload1.c:1059<br>Please submit a full bug report,<br>with preprocessed source if appropriate.<br>See <<a href="http://gcc.gnu.org/bugs.html" target="_blank">http://gcc.gnu.org/bugs.html</a>> for instructions.<br>


<br><br><br><div><br><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/6 Alvaro Gamez <span dir="ltr"><<a href="mailto:alvaro.gamez@hazent.com" target="_blank">alvaro.gamez@hazent.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi Thomas, hi all!<br><br>The last three errors seem to be the same. It's apparently triggered by a loop in which several macros are called one after the other, repeatedly.<br>

</div></div>
<br>Although I don't know much (nothing, really) about gcc, I also think it's a compiler bug, so maybe the best way of action is, as you said, supporting Microblaze directly on the internal toolchain, without relaying on Xilinx's.<br>


<br></div>Looking a bit on files reload1.c and emit-rtl.c, I can only tell it's got something to do with pseudo registers, which I don't know what they are, but maybe that gives someone an idea of what the problem is.<br>


<br>Anyway, I'll try to replicate the issue on the next few days and will try to at least make a minimal (and preprocessed) code example, just in case we want to continue using Xilinx's toolchain and we can patch some code to workaround that or provide a more extensive bug report to Xilinx.<br>


<br></div>Regards<br></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">2013/10/6 Thomas Petazzoni <span dir="ltr"><<a href="mailto:thomas.petazzoni@free-electrons.com" target="_blank">thomas.petazzoni@free-electrons.com</a>></span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Jan, Chris, Alvaro, Spenser,<br>
<br>
You are amongst the four persons who contributed Microblaze related<br>
changes to Buildroot. We are currently having various build problems in<br>
our autobuilders caused by the Microblaze support, and it would be nice<br>
if you could help us fixing those issues and generally maintain the<br>
Microblaze support in a good shape in Buildroot.<br>
<br>
At the moment, here are the latest autobuilder issues we have on<br>
Microblaze:<br>
<br>
 * libglib2 fails to build<br>
   <a href="http://autobuild.buildroot.org/results/32f/32fca009984ca0de4b4026ff6b4029104d0396c5/build-end.log" target="_blank">http://autobuild.buildroot.org/results/32f/32fca009984ca0de4b4026ff6b4029104d0396c5/build-end.log</a><br>



<br>
   undefined reference to `__sync_fetch_and_or_4'<br>
<br>
   probably caused by the compiler not providing the right intrinsics,<br>
   or libglib2 not falling back to other solutions when  the intrinsics<br>
   are not available.<br>
<br>
 * nettle fails to build<br>
   <a href="http://autobuild.buildroot.org/results/20b/20b2e2573985a687be29220a7df3b11a32894ba2/build-end.log" target="_blank">http://autobuild.buildroot.org/results/20b/20b2e2573985a687be29220a7df3b11a32894ba2/build-end.log</a><br>



<br>
   sha512-compress.c: In function '_nettle_sha512_compress':<br>
   sha512-compress.c:180:1: internal compiler error: in reload, at reload1.c:1059<br>
   Please submit a full bug report,<br>
<br>
   compiler bug, apparently.<br>
<br>
 * openssl fails to build<br>
   <a href="http://autobuild.buildroot.org/results/a050faaabbf89f9d3f324b821da84f8991a5aebb/build-end.log" target="_blank">http://autobuild.buildroot.org/results/a050faaabbf89f9d3f324b821da84f8991a5aebb/build-end.log</a><br>



<br>
   sha512.c: In function 'sha512_block_data_order':<br>
   sha512.c:585:2: internal compiler error: in reload, at reload1.c:1059<br>
   Please submit a full bug report,<br>
   with preprocessed source if appropriate.<br>
<br>
   looks pretty much the same compiler bug as the one triggered by the<br>
   nettle build.<br>
<br>
 * cairo fails to build<br>
   <a href="http://autobuild.buildroot.org/results/7054d168729c4e257000db93ab5137af1e1583cc/build-end.log" target="_blank">http://autobuild.buildroot.org/results/7054d168729c4e257000db93ab5137af1e1583cc/build-end.log</a><br>



<br>
   dragon.c: In function 'do_dragon':<br>
   dragon.c:162:1: internal compiler error: in gen_reg_rtx, at emit-rtl.c:862<br>
   Please submit a full bug report,<br>
   with preprocessed source if appropriate.<br>
<br>
   another compiler error.<br>
<br>
Maybe those problems can be solved by using another Microblaze external<br>
toolchain, but I couldn't find any other available on the Web. Or maybe<br>
we should remove the external Microblaze toolchains and instead support<br>
Microblaze in the internal Buildroot toolchain backend?<br>
<br>
Thanks for your help,<br>
<br>
Thomas<br>
<br>
For reference, the last 30 Microblaze build failures were:<br>
<br>
+---------------------+----------------------------------------------------------------------------------+-----------------+<br>
| 2013-10-06 05:31:03 | <a href="http://autobuild.buildroot.org/results/e570445aafab51ce497da9e0d864157f50ff75d7/" target="_blank">http://autobuild.buildroot.org/results/e570445aafab51ce497da9e0d864157f50ff75d7/</a> | libglib2-2.36.3 |<br>



| 2013-10-05 22:37:36 | <a href="http://autobuild.buildroot.org/results/20b2e2573985a687be29220a7df3b11a32894ba2/" target="_blank">http://autobuild.buildroot.org/results/20b2e2573985a687be29220a7df3b11a32894ba2/</a> | nettle-2.7.1    |<br>



| 2013-10-05 21:59:39 | <a href="http://autobuild.buildroot.org/results/32fca009984ca0de4b4026ff6b4029104d0396c5/" target="_blank">http://autobuild.buildroot.org/results/32fca009984ca0de4b4026ff6b4029104d0396c5/</a> | libglib2-2.36.3 |<br>



| 2013-10-05 19:32:44 | <a href="http://autobuild.buildroot.org/results/166ab2a8c2efffa0b518f07d7f1dcdfe8c85614f/" target="_blank">http://autobuild.buildroot.org/results/166ab2a8c2efffa0b518f07d7f1dcdfe8c85614f/</a> | nettle-2.7.1    |<br>



| 2013-10-05 17:39:45 | <a href="http://autobuild.buildroot.org/results/4ec0f495f4ff77bb35e7b1ab8446671c8d260cd6/" target="_blank">http://autobuild.buildroot.org/results/4ec0f495f4ff77bb35e7b1ab8446671c8d260cd6/</a> | libglib2-2.36.3 |<br>



| 2013-10-05 09:44:38 | <a href="http://autobuild.buildroot.org/results/ce1c9a2ca389c2fb1c8955c75212737c7d57a803/" target="_blank">http://autobuild.buildroot.org/results/ce1c9a2ca389c2fb1c8955c75212737c7d57a803/</a> | cairo-1.12.10   |<br>



| 2013-10-05 07:21:48 | <a href="http://autobuild.buildroot.org/results/b1d6d56d2c8bcd3df47e2685ed8e7de8742a7c73/" target="_blank">http://autobuild.buildroot.org/results/b1d6d56d2c8bcd3df47e2685ed8e7de8742a7c73/</a> | nettle-2.7.1    |<br>



| 2013-10-05 01:45:57 | <a href="http://autobuild.buildroot.org/results/a050faaabbf89f9d3f324b821da84f8991a5aebb/" target="_blank">http://autobuild.buildroot.org/results/a050faaabbf89f9d3f324b821da84f8991a5aebb/</a> | openssl-1.0.1e  |<br>



| 2013-10-04 23:20:14 | <a href="http://autobuild.buildroot.org/results/ac8992a75b97f0baab55fe6e93ed0a8eeca08bcf/" target="_blank">http://autobuild.buildroot.org/results/ac8992a75b97f0baab55fe6e93ed0a8eeca08bcf/</a> | openssl-1.0.1e  |<br>



| 2013-10-04 18:15:46 | <a href="http://autobuild.buildroot.org/results/80a0d575d2afac933c8cb2fb596a0347c50e4912/" target="_blank">http://autobuild.buildroot.org/results/80a0d575d2afac933c8cb2fb596a0347c50e4912/</a> | libglib2-2.36.3 |<br>



| 2013-10-04 15:36:19 | <a href="http://autobuild.buildroot.org/results/9a3027a69dac63b4e621529eff18035530796e7e/" target="_blank">http://autobuild.buildroot.org/results/9a3027a69dac63b4e621529eff18035530796e7e/</a> | nettle-2.7.1    |<br>



| 2013-10-04 12:14:21 | <a href="http://autobuild.buildroot.org/results/4611c835d904fb5728ae5531bcc41ed33e1f5de6/" target="_blank">http://autobuild.buildroot.org/results/4611c835d904fb5728ae5531bcc41ed33e1f5de6/</a> | nettle-2.7.1    |<br>



| 2013-10-04 10:34:37 | <a href="http://autobuild.buildroot.org/results/c1332dd02817e25ab8ecd0ceab8c4953b65c9f50/" target="_blank">http://autobuild.buildroot.org/results/c1332dd02817e25ab8ecd0ceab8c4953b65c9f50/</a> | pcsc-lite-1.8.6 |<br>



| 2013-10-04 09:39:00 | <a href="http://autobuild.buildroot.org/results/517e2754256d39864d38befeeccd54c153e28971/" target="_blank">http://autobuild.buildroot.org/results/517e2754256d39864d38befeeccd54c153e28971/</a> | libglib2-2.36.3 |<br>



| 2013-10-03 14:04:25 | <a href="http://autobuild.buildroot.org/results/7054d168729c4e257000db93ab5137af1e1583cc/" target="_blank">http://autobuild.buildroot.org/results/7054d168729c4e257000db93ab5137af1e1583cc/</a> | cairo-1.12.10   |<br>



| 2013-10-02 05:50:46 | <a href="http://autobuild.buildroot.org/results/0a26b484f1cc01d6c150f6f855b2b8c7b03d585b/" target="_blank">http://autobuild.buildroot.org/results/0a26b484f1cc01d6c150f6f855b2b8c7b03d585b/</a> | libglib2-2.36.3 |<br>



| 2013-10-02 00:53:35 | <a href="http://autobuild.buildroot.org/results/2b10358b3540f9a12fc777bc37afbfb6072d2a47/" target="_blank">http://autobuild.buildroot.org/results/2b10358b3540f9a12fc777bc37afbfb6072d2a47/</a> | binutils-2.21   |<br>



| 2013-10-01 22:25:57 | <a href="http://autobuild.buildroot.org/results/5f691a60ffed41f0f4099179a07d7fc6c0251823/" target="_blank">http://autobuild.buildroot.org/results/5f691a60ffed41f0f4099179a07d7fc6c0251823/</a> | openssl-1.0.1e  |<br>



| 2013-10-01 19:14:35 | <a href="http://autobuild.buildroot.org/results/d9115507421d121b0c317a2d1b52ef33199e913f/" target="_blank">http://autobuild.buildroot.org/results/d9115507421d121b0c317a2d1b52ef33199e913f/</a> | libglib2-2.36.3 |<br>



| 2013-10-01 11:35:25 | <a href="http://autobuild.buildroot.org/results/0ad3e345fe1a9666bc18562549621aa28987b846/" target="_blank">http://autobuild.buildroot.org/results/0ad3e345fe1a9666bc18562549621aa28987b846/</a> | libglib2-2.36.3 |<br>



| 2013-10-01 06:48:37 | <a href="http://autobuild.buildroot.org/results/1a373593d5f9d55f2e7e9113ecdb4adb8e6baaa7/" target="_blank">http://autobuild.buildroot.org/results/1a373593d5f9d55f2e7e9113ecdb4adb8e6baaa7/</a> | libglib2-2.36.3 |<br>



| 2013-09-30 18:09:09 | <a href="http://autobuild.buildroot.org/results/a44af8dee49fea322824f99da31b82c828728476/" target="_blank">http://autobuild.buildroot.org/results/a44af8dee49fea322824f99da31b82c828728476/</a> | libglib2-2.36.3 |<br>



| 2013-09-30 11:54:37 | <a href="http://autobuild.buildroot.org/results/74284d1087fc5677787882681c7f38a8f19e4402/" target="_blank">http://autobuild.buildroot.org/results/74284d1087fc5677787882681c7f38a8f19e4402/</a> | openssl-1.0.1e  |<br>



| 2013-09-29 14:55:24 | <a href="http://autobuild.buildroot.org/results/af53648189dd9ea40ea20d3e173e6ff391d73279/" target="_blank">http://autobuild.buildroot.org/results/af53648189dd9ea40ea20d3e173e6ff391d73279/</a> | nettle-2.7.1    |<br>



| 2013-09-29 13:47:53 | <a href="http://autobuild.buildroot.org/results/7cb55407f7f3e156cc04fd66da284a6c4178c776/" target="_blank">http://autobuild.buildroot.org/results/7cb55407f7f3e156cc04fd66da284a6c4178c776/</a> | libglib2-2.36.3 |<br>



| 2013-09-29 12:54:59 | <a href="http://autobuild.buildroot.org/results/5031115f6e2c8e6c32309bab3d982b9e55e69fc3/" target="_blank">http://autobuild.buildroot.org/results/5031115f6e2c8e6c32309bab3d982b9e55e69fc3/</a> | libglib2-2.36.3 |<br>



| 2013-09-29 10:57:54 | <a href="http://autobuild.buildroot.org/results/f12f692a4cf24e93d71f511362704e57766e2127/" target="_blank">http://autobuild.buildroot.org/results/f12f692a4cf24e93d71f511362704e57766e2127/</a> | libglib2-2.36.3 |<br>



| 2013-09-29 07:56:39 | <a href="http://autobuild.buildroot.org/results/c486ba7eebd2bbbef69b3a68323e0329cc65f79d/" target="_blank">http://autobuild.buildroot.org/results/c486ba7eebd2bbbef69b3a68323e0329cc65f79d/</a> | openssl-1.0.1e  |<br>



| 2013-09-29 07:31:02 | <a href="http://autobuild.buildroot.org/results/f0dd5afd1e49e967d60c7ec7e62a924942e9a3ea/" target="_blank">http://autobuild.buildroot.org/results/f0dd5afd1e49e967d60c7ec7e62a924942e9a3ea/</a> | libglib2-2.36.3 |<br>



| 2013-09-29 00:39:25 | <a href="http://autobuild.buildroot.org/results/767177028f4d0b53a3b9898f293526b234394463/" target="_blank">http://autobuild.buildroot.org/results/767177028f4d0b53a3b9898f293526b234394463/</a> | libglib2-2.36.3 |<br>



+---------------------+----------------------------------------------------------------------------------+-----------------+<br>
<span><font color="#888888"><br>
--<br>
Thomas Petazzoni, Free Electrons<br>
Embedded Linux, Kernel and Android engineering<br>
<a href="http://free-electrons.com" target="_blank">http://free-electrons.com</a><br>
</font></span></blockquote></div><br><br clear="all"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br>Álvaro Gámez Machado<br>
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br>Álvaro Gámez Machado<br>
</div>