[LLVMbugs] [Bug 13137] New: MinGW 4.7.0-compiled Clang Mis-compiles Simple C++ Programs
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jun 18 08:37:38 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13137
Bug #: 13137
Summary: MinGW 4.7.0-compiled Clang Mis-compiles Simple C++
Programs
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: justin.holewinski at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
When using MinGW 4.7.0 to compile Clang on Windows, the resulting Clang binary
does not correctly compile simple C++ code. This is with ToT LLVM/Clang.
Clang build:
$ cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=<dir> -G Ninja <llvm-dir>
$ ninja
After building Clang, I tried to compile the following program:
#include <iostream>
#include <string>
int main(int argc, char** argv) {
std::string Name("me");
std::cout << Name << "\n";
return 0;
}
with
$ bin\clang++.exe test1.cpp -O0 -o test1.exe -v
The resulting executable immediately seg faults in the CRT start-up routines:
Program received signal SIGSEGV, Segmentation fault.
0x6fc65abb in libstdc++-6!_ZNKSs4sizeEv () from c:\MinGW\bin\libstdc++-6.dll
(gdb) bt
#0 0x6fc65abb in libstdc++-6!_ZNKSs4sizeEv () from
c:\MinGW\bin\libstdc++-6.dll
#1 0x6fcba6f1 in
libstdc++-6!_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKSbIS4_S5_T1_E
()
from c:\MinGW\bin\libstdc++-6.dll
#2 0x00401453 in _fu0___ZSt4cout ()
#3 0x004010b9 in __mingw_CRTStartup () at ../mingw/crt1.c:244
#4 0x00401284 in mainCRTStartup () at ../mingw/crt1.c:264
Any idea what is going on here? I'm cross-posting to llvm-dev since I'm not
sure if this is a Clang or LLVM codegen issue.
Clang verbose output:
clang version 3.2
Target: i686-pc-mingw32
Thread model: posix
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin/clang++.exe"
-cc1 -triple i686-pc-mingw32 -S -disable-free -main-file-name test1.cpp
-mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases
-target-cpu pentium4 -momit-leaf-frame-pointer -v -resource-dir
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\\..\\lib\\clang\\3.2"
-fmodule-cache-path
"C:\\Users\\JHOLEW~1\\AppData\\Local\\Temp\\clang-module-cache" -O0
-fdeprecated-macro -fno-dwarf-directory-asm -ferror-limit 19 -fmessage-length
129 -mstackrealign -fno-use-cxa-atexit -fgnu-runtime -fobjc-runtime-has-arc
-fobjc-runtime-has-weak
-fobjc-fragile-abi -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017384.s -x
c++ "..\\clang-x86-self\\test1.cpp"
clang -cc1 version 3.2 based upon LLVM 3.2svn default target i686-pc-mingw32
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.0"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.0/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.0/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.0/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.1"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.1/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.1/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.1/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.2"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.2/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.2/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.2/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.3"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.3/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.3/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.3/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.4"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.4/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.4/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.5.4/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.0"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.0/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.0/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.0/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.1"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.1/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.1/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.1/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.2"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.2/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.2/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.2/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.3"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.3/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.3/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.6.3/backward"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.7.0"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.7.0/x86_64-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.7.0/i686-w64-mingw32"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin\..\lib\clang\3.2/../../../include/c++/4.7.0/backward"
ignoring nonexistent directory "/mingw/lib/gcc/mingw32/4.5.2/include/c++"
ignoring nonexistent directory
"/mingw/lib/gcc/mingw32/4.5.2/include/c++/mingw32"
ignoring nonexistent directory
"/mingw/lib/gcc/mingw32/4.5.2/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.6.3/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.6.3/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.6.3/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.6.2/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.6.2/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.6.2/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.6.1/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.6.1/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.6.1/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.5.2/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.5.2/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.5.2/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++/backward"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin/../lib/clang/3.2/../../../i686-w64-mingw32/include"
ignoring nonexistent directory
"C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin/../lib/clang/3.2/../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
c:/MinGW/lib/gcc/mingw32/4.7.0/include/c++
c:/MinGW/lib/gcc/mingw32/4.7.0/include/c++/mingw32
c:/MinGW/lib/gcc/mingw32/4.7.0/include/c++/backward
C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin/../lib/clang/3.2/include
C:/Users/jholewinski/projects/llvm/build/clang-x86-mingw32/bin/../lib/clang/3.2/../../../include
/mingw/include
c:/mingw/include
End of search list.
"c:/MinGW/bin/g++.exe" -O0 -v -c -o
C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017385.o -x assembler
C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017384.s
Using built-in specs.
COLLECT_GCC=c:/MinGW/bin/g++.exe
Target: mingw32
Configured with: ../gcc-4.7.0/configure
--enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
--with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
--enable-libstdcxx-debug --disable-build-poststage1-with-cxx
--enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-O0' '-v' '-c' '-o'
'C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017385.o' '-shared-libgcc'
'-mtune=i386' '-march=i386'
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe -o
C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017385.o
C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017384.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.7.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../;/mingw/lib/
COLLECT_GCC_OPTIONS='-O0' '-v' '-c' '-o'
'C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017385.o' '-shared-libgcc'
'-mtune=i386' '-march=i386'
"c:/MinGW/bin/g++.exe" -O0 -v -o test1.exe
C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017385.o
Using built-in specs.
COLLECT_GCC=c:/MinGW/bin/g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.0/configure
--enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
--with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
--enable-libstdcxx-debug --disable-build-poststage1-with-cxx
--enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.7.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../;/mingw/lib/
COLLECT_GCC_OPTIONS='-O0' '-v' '-o' 'test1.exe' '-shared-libgcc' '-mtune=i386'
'-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/collect2.exe -Bdynamic -u
___register_frame_info -u ___deregister_frame_info -o test1.exe
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../crt2.o
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtbegin.o
-Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0 -Lc:/mingw/bin/../lib/gcc
-Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib
-Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../.. -L/mingw/lib
C:/Users/JHOLEW~1/AppData/Local/Temp/test1-017385.o -lstdc++ -lmingw32 -lgcc_s
-lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32
-lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtend.o
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list