Clangのバグと戦うために173210氏に助けを求めた話
暗中模索
敗北
@yumetodo clang詰んだので最小限の再現方法とスタックトレースだけ貼っとく。無念。 gist.github.com/173210/bcd1ed3… なんかこのスタックトレースもぶっ壊れてる感はある。
2016-09-19 21:38:41@yumetodo 諦めた。これ以上調べるには、膨大なclangとllvmのコミットの中からmasterとrelease_38の間で例の問題が発現しなくなるコミットを見つけるか、SLP Vectorization関連のコードをひたすら洗うしかない。
2016-09-20 15:42:24@yumetodo Revisionsを見ればわかるけど、スタックトレースの内容が変わっている。NEONが見えたのはCMAKE_BUILD_TYPEが設定されていなかったとき。Releaseにすると消える。
2016-09-20 15:43:47msys2側で動きが
https://github.com/Alexpux/MINGW-packages/issues/1669#issuecomment-249714934
Fixed in upcoming Clang 3.9 package.
https://github.com/Alexpux/MINGW-packages/issues/1669#issuecomment-249723596
@mati865 Wow, that sounds brilliant. May I know what was the cause?
ん?msys2 mingw32 clangが-O2でコケる問題、次のclang 3.9でfixしたっぽい? github.com/Alexpux/MINGW-… @173210
2016-09-27 14:54:58https://github.com/Alexpux/MINGW-packages/issues/1669#issuecomment-249728631
Wait, that's weird. i686 toolchain is in fact 64 bit toolchain:
$ clang -v
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: D:\projekty\msys2\clang\msys64\mingw32\bin
Something terrible must have happened in build system, looks like a lot of digging.
EDIT: file shows: clang.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows
EDIT2: Looks like target defaults to 64 bit but Clang itself is 32 bit and is able to build 32 bit test case from this issue after adding -target i686-pc-windows-gnu:
$ llvm-objdump -d clang_test.o
clang_test.o: file format COFF-i386
Disassembly of section .text:
_main:
0: 55 pushl %ebp
1: 89 e5 movl %esp, %ebp
3: e8 00 00 00 00 calll 0 <_main+0x8>
8: 80 3d 00 00 00 00 00 cmpb $0, 0
f: 74 0a je 10 <_main+0x1B>
11: b9 00 00 00 00 movl $0, %ecx
16: e8 00 00 00 00 calll 0 <_main+0x1B>
1b: 31 c0 xorl %eax, %eax
1d: 5d popl %ebp
1e: c3 retl
Still need to do some digging.
https://github.com/Alexpux/MINGW-packages/issues/1669#issuecomment-250028024
Ok, resolved for good with new Clang: clang -cc1 version 3.9.0 based upon LLVM 3.9.0 default target i686-w64-windows-gnu.
総括
- なんか知らないけどclang3.8からclang3.9の間でいつのまにかfixされていた。
- pacmanでclang3.9が落ちてくる頃にはfixの恩恵が受けられそう
なおmsys2のclang3.9にする作業ページはここ
https://github.com/Alexpux/MINGW-packages/pull/1768