Open Quuxplusone opened 9 years ago
Bugzilla Link | PR24728 |
Status | NEW |
Importance | P normal |
Reported by | Daniel Starke (daniel.f.starke@freenet.de) |
Reported on | 2015-09-06 04:58:30 -0700 |
Last modified on | 2015-12-09 14:31:38 -0800 |
Version | 3.7 |
Hardware | PC Windows XP |
CC | anrp+llvm@anrp.net, llvm-bugs@lists.llvm.org, yaron.keren@gmail.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Could you try the same with current SVN clang?
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));
#0 llvm::opt::ArgList::MakeArgString (this=0x30bb720, Str=...)
at e:/Downloads/Applications/llvm/trunk-r246942/src/include/llvm/Option/ArgList.h:301
#1 0x00000000004eca2b in clang::driver::tools::Clang::AddObjCRuntimeArgs
(this=this@entry=0x30bcb00, args=..., cmdArgs=...,
rewriteKind=rewriteKind@entry=clang::driver::tools::Clang::RK_None)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Tools.cpp:5275
#2 0x000000000051015a in clang::driver::tools::Clang::ConstructJob
(this=this@entry=0x30bcb00, C=..., JA=..., Output=..., Inputs=..., Args=...,
LinkingOutput=LinkingOutput@entry=0x0) at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Tools.cpp:4650
#3 0x00000000004b66c5 in clang::driver::Driver::BuildJobsForAction
(this=this@entry=0x22eda0, C=..., A=<optimized out>, TC=TC@entry=0x30bbc80,
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
#4 0x00000000004b65bd in clang::driver::Driver::BuildJobsForAction
(this=this@entry=0x22eda0, C=..., A=<optimized out>, A@entry=0x30bca80,
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
#5 0x00000000004b6f22 in clang::driver::Driver::BuildJobs (this=<optimized
out>, C=...)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Driver.cpp:1629
#6 0x00000000004b82d0 in clang::driver::Driver::BuildCompilation
(this=this@entry=0x22eda0, ArgList=...)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/lib/Driver/Driver.cpp:478
#7 0x00000000025ccb0d in main (argc_=<optimized out>, argv_=<optimized out>)
at e:/Downloads/Applications/llvm/trunk-r246942/src/tools/clang/tools/driver/driver.cpp:519
A debugging session is active.
Do you have more than one gcc/mingw distribution installed?
I would need to compile a different GCC version if needed. Is there a specific one I should try?
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:
http://bb.pgr.jp/grid
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 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.
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"
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
#0 llvm::opt::ArgList::MakeArgString (this=0x2e7afd0, Str=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/include/llvm/Option/ArgList.h:298
#1 0x00000000004eae8b in clang::driver::tools::Clang::AddObjCRuntimeArgs (
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
#2 0x000000000050d116 in clang::driver::tools::Clang::ConstructJob (
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
#3 0x00000000004b643e in clang::driver::Driver::BuildJobsForAction (
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
#4 0x00000000004b631f in clang::driver::Driver::BuildJobsForAction (
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
#5 0x00000000004b6ca2 in clang::driver::Driver::BuildJobs (
this=<optimized out>, C=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Driver.cpp:1625
#6 0x00000000004b8040 in clang::driver::Driver::BuildCompilation (
this=this@entry=0x22eda0, ArgList=...)
at C:/msys64/home/work/mingw2/llvm-3.7.0.src/tools/clang/lib/Driver/Driver.cpp:476
#7 0x000000000244bca3 in main (argc_=<optimized out>, argv_=<optimized out>)
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<char>,
std::allocator<char> >::_M_dispose (this=<optimized out>)
at C:/msys64/mingw64/include/c++/5.2.0/bits/basic_string.h:179
clang::driver::tools::Clang::AddObjCRuntimeArgs (this=this@entry=0x303c380,
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
5143 args.MakeArgString("-fobjc-runtime=" + runtime.getAsString()));
(gdb) s
llvm::Twine::Twine (this=0x22d760, Str="-fobjc-runtime=gcc")
.. 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...)
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.
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.