Open llvmbot opened 9 years ago
OK, it seems like it's related to assertions, somehow.
../llvm-3.7.0.src/configure --prefix=/clang64rel3 --enable-targets=x86,x86_64 --enable-optimized --disable-keep-symbols --disable-debug-runtime --disable-debug-symbols CC="gcc -Wa,-mbig-obj" CXX="g++ -Wa,-mbig-obj"
produces the subtly nonworking compiler as I described, but adding --disable-assertions to a new build makes it work, defined as wxWidgets compiling to success and the demos actually working (mostly, barring some #24395 errors worked around by using static libraries).
So Release works, but Release+Asserts doesn't. Strange.
Also, trying the workaround, the compiler doesn't work right (handful of segfaults trying to compile wxWidgets 3.0.2). So this might not be a clang/LLVM issue, it could be something with the compiler used to compile clang/LLVM.
Just to throw something in here, I have the same symptoms (on a Release+Debug+Asserts build, mingw64, gcc 5.2.) Stepping through with gdb doesn't show anything particularly helpful (the string is correct right until the MakeArgString call segfaults.)
Program received signal SIGSEGV, Segmentation fault. llvm::opt::ArgList::MakeArgString (this=0x2e7afd0, Str=...) at C:/msys64/home/work/mingw2/llvm-3.7.0.src/include/llvm/Option/ArgList.h:298 298 return MakeArgStringRef(Str.toStringRef(Buf)); (gdb) bt
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/include/llvm/Option/ArgList.h:298
this=this@entry=0x2e7c380, args=..., cmdArgs=...,
rewriteKind=rewriteKind@entry=clang::driver::tools::Clang::RK_None)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Tools.cpp:5143
this=<optimized out>, this@entry=0x2e7c380, C=..., JA=..., Output=...,
Inputs=..., Args=..., LinkingOutput=LinkingOutput@entry=0x0)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Tools.cpp:4509
this=this@entry=0x22eda0, C=..., A=<optimized out>,
TC=TC@entry=0x2e7b4e0, BoundArch=BoundArch@entry=0x0, AtTopLevel=false,
MultipleArchs=MultipleArchs@entry=false,
LinkingOutput=LinkingOutput@entry=0x0, Result=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Driver.cpp:1858
this=this@entry=0x22eda0, C=..., A=<optimized out>, A@entry=0x2e7c300,
TC=0x2e7b4e0, BoundArch=BoundArch@entry=0x0,
AtTopLevel=AtTopLevel@entry=true, MultipleArchs=false, LinkingOutput=0x0,
Result=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Driver.cpp:1823
this=<optimized out>, C=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Driver.cpp:1625
this=this@entry=0x22eda0, ArgList=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Driver.cpp:476
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/tools/driver/driver.cpp:457
However! Passing -fobjc-runtime=gcc on the commandline (i.e. exactly the same as what clang internally generates:)
(gdb) finish
Run till exit from #0 std::__cxx11::basic_string<char, std::char_traits
.. causes the logic of AddObjCRuntimeArgs to be skipped, and the compilation to succeed. So, a workaround, but not a solution. Like you, it works fine in the non-Release build. (after wrangling with the ~1.8GB limit for PE32+ .exes...)
Compiling Clang/LLVM with the following configuration does not reproduce this issue:
../llvm-3.7.0.src/configure --prefix=/mingw64-64 --host=x86_64-w64-mingw32 --disable-shared --disable-optimized --enable-assertions --enable-debug-runtime --enable-debug-symbols --enable-keep-symbols --enable-targets="x86 x86_64 cpp" --disable-docs "--with-gcc-toolchain=which x86_64-w64-mingw32-gcc | xargs dirname
" CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-gcc-ar LD=x86_64-w64-mingw32-ld "CPPFLAGS=-std=c++14" "CFLAGS=-Og -g3 -ggdb -gdwarf-3" "CXXFLAGS=-Og -g3 -ggdb -gdwarf-3"
I failed to build Clang/LLVM without optimizations due to: e:/msys/mingw64-64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/as.exe: e:/Downloads/Applications/llvm/3.7/llvm-3.7.0.bin/tools/clang/lib/AST/Debug+Asserts/ASTContext.o: too many sections (37005) C:\Users\user\AppData\Local\Temp\ccYqltXC.s: Assembler messages: C:\Users\user\AppData\Local\Temp\ccYqltXC.s: Fatal error: can't write e:/Downloads/Applications/llvm/3.7/llvm-3.7.0.bin/tools/clang/lib/AST/Debug+Asserts/ASTContext.o: File too big e:/msys/mingw64-64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/as.exe: e:/Downloads/Applications/llvm/3.7/llvm-3.7.0.bin/tools/clang/lib/AST/Debug+Asserts/ASTContext.o: too many sections (37005) C:\Users\user\AppData\Local\Temp\ccYqltXC.s: Fatal error: can't close e:/Downloads/Applications/llvm/3.7/llvm-3.7.0.bin/tools/clang/lib/AST/Debug+Asserts/ASTContext.o: File too big
The assembly file in question was around 33 MB.
The crash seems to happen before the mingw toolchain (as target) is invoked and likely to be unrelated to it. I asked if you have more than one mingw toolchain installed since DLLs from different mingw have the same name and any mixup would be bad and could explain mysterious crashes.
There are regular builds of clang with mingw here:
Some ideas
1) Try a debug build (no optimizations). The stack trace will be more informative. If you can, debug and see what's going wrong. 2) I'm not sure how automake configure is up to date regarding mingw as most people are using CMAKE now. Try to build with CMAKE, it may have different flags used for building. 3) Try gcc 5.1 instead of gcc 5.2.
I would need to compile a different GCC version if needed. Is there a specific one I should try?
Do you have more than one gcc/mingw distribution installed?
Still present in trunk r246942: Starting program: E:\msys\mingw64-64\bin\clang.exe -o hello.exe hello.c [New Thread 4408.0x1570]
Program received signal SIGSEGV, Segmentation fault. llvm::opt::ArgList::MakeArgString (this=0x30bb720, Str=...) at e:/Downloads/Applications/llvm/trunk-r246942/src/include/llvm/Option/ArgList.h:301 301 return MakeArgStringRef(Str.toStringRef(Buf));
at e:/Downloads/Applications/llvm/trunk-r246942/src/include/llvm/Option/ArgList.h:301
rewriteKind=rewriteKind@entry=clang::driver::tools::Clang::RK_None)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Tools.cpp:5275
LinkingOutput=LinkingOutput@entry=0x0) at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Tools.cpp:4650
BoundArch=BoundArch@entry=0x0, AtTopLevel=false, MultipleArchs=MultipleArchs@entry=false, LinkingOutput=LinkingOutput@entry=0x0, Result=...)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Driver.cpp:1884
TC=0x30bbc80, BoundArch=BoundArch@entry=0x0, AtTopLevel=AtTopLevel@entry=true, MultipleArchs=false, LinkingOutput=0x0, Result=...)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Driver.cpp:1849
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Driver.cpp:1629
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Driver.cpp:478
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/tools/driver/driver.cpp:519
A debugging session is active.
Could you try the same with current SVN clang?
Extended Description
I am getting a segmentation fault in Clang when trying to compile a simple hello world C code with clang -o hello.exe hello.c testcase:
include
include
int main(void) { printf("Hello World!\n"); return EXIT_SUCCESS; }
Backtrace: Starting program: E:\msys\mingw64-64\bin\clang.exe -o hello.exe hello.c [New Thread 5112.0xb8c]
Program received signal SIGSEGV, Segmentation fault. llvm::opt::ArgList::MakeArgString (this=0x30ad70, Str=...) at e:/Downloads/Applications/llvm/3.7/llvm-3.7.0.src/include/llvm/Option/ArgList.h:298 298 return MakeArgStringRef(Str.toStringRef(Buf));
0 llvm::opt::ArgList::MakeArgString (this=0x30ad70, Str=...)
1 0x00000000004eb13b in clang::driver::tools::Clang::AddObjCRuntimeArgs (this=this@entry=0x30c150, args=..., cmdArgs=...,
2 0x000000000050d2f6 in clang::driver::tools::Clang::ConstructJob (this=, this@entry=0x30c150, C=..., JA=..., Output=...,
3 0x00000000004b657e in clang::driver::Driver::BuildJobsForAction (this=this@entry=0x22eda0, C=..., A=, TC=TC@entry=0x30b2d0,
4 0x00000000004b645f in clang::driver::Driver::BuildJobsForAction (this=this@entry=0x22eda0, C=..., A=, A@entry=0x30c0d0,
5 0x00000000004b6de2 in clang::driver::Driver::BuildJobs (this=, C=...)
6 0x00000000004b8180 in clang::driver::Driver::BuildCompilation (this=this@entry=0x22eda0, ArgList=...)
7 0x0000000002548308 in main (argc=, argv =)
Clang/LLVM was compiled as 64-bit debug+assert build with: ../llvm-3.7.0.src/configure --prefix=/mingw64-64 --host=x86_64-w64-mingw32 --disable-shared --enable-assertions --enable-debug-symbols --enable-keep-symbols --enable-targets="x86 x86_64 cpp" --disable-docs "--with-gcc-toolchain=
which x86_64-w64-mingw32-gcc | xargs dirname
" CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-gcc-ar LD=x86_64-w64-mingw32-ld "CPPFLAGS=-std=c++14" using gcc 5.2.0: ../../src/gcc-5.2.0/configure --host=x86_64-w64-mingw32 --enable-languages=c,c++ --enable-seh-exceptions --enable-threads=posix --disable-nls --disable-shared --enable-static --enable-fully-dynamic-string --enable-lto --enable-plugins --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-version-specific-runtime-libs --prefix=/mingw64-64 --with-sysroot=/mingw64-64 --target=x86_64-w64-mingw32 --enable-targets=all --enable-checking=release --with-gmp=/usr/new-gcc/lib/gmp-5.0.5 --with-mpfr=/usr/new-gcc/lib/mpfr-2.4.2 --with-mpc=/usr/new-gcc/lib/mpc-0.9 --with-isl=/usr/new-gcc/lib/isl-0.12.2 --with-cloog=/usr/new-gcc/lib/cloog-0.18.3 --with-host-libstdcxx='-lstdc++ -lsupc++' --disable-cloog-version-check --enable-cloog-backend=isl