[LLVMdev] [PATCH] llvm/llvm-gcc broken on mingw32

Julien Lerouge jlerouge at apple.com
Mon Jan 26 21:32:58 PST 2009


Hello,

Since 2.5 is near, I have been trying to build llvm and llvm-gcc for MingW, but
hit several problem (using the current trunk).

First issue is that unittests don't build for MingW, the attached patch
should fix it.

Second issue is that llvm-gcc fails for me with the following error:

/c/cygwin/home/jlerouge/buildbot/llvm-test/gcc-build/./gcc/xgcc -B/c/cygwin/home/jlerouge/buildbot/llvm-test/gcc-build/./gcc/ -L/c/cygwin/home/jlerouge/buildbot/llvm-test/gcc-build/i686-pc-mingw32/winsup/mingw -L/c/cygwin/home/jlerouge/buildbot/llvm-test/gcc-build/i686-pc-mingw32/winsup/w32api/lib -isystem /c/cygwin/home/jlerouge/buildbot/llvm-gcc4.2-src/winsup/mingw/include -isystem /c/cygwin/home/jlerouge/buildbot/llvm-gcc4.2-src/winsup/w32api/include -Bc:/cygwin/home/jlerouge/buildbot/llvm-test/i686-pc-mingw32/bin/ -Bc:/cygwin/home/jlerouge/buildbot/llvm-test/i686-pc-mingw32/lib/ -isystem c:/cygwin/home/jlerouge/buildbot/llvm-test/i686-pc-mingw32/include -isystem c:/cygwin/home/jlerouge/buildbot/llvm-test/i686-pc-mingw32/sys-include -c -DHAVE_CONFIG_H -O2 -g -O2  -I. -I../../../../llvm-gcc4.2-src/libiberty/../include  -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes -Wc++-compat ../../../../llvm-gcc4.2-src/libiberty/pex-win32.c -o pex-win32.o
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c: In function 'argv_to_cmdline':
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c:365: warning: request for implicit conversion from 'void *' to 'char *' not permitted in C++
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c: In function 'find_executable':
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c:440: warning: request for implicit conversion from 'void *' to 'char *' not permitted in C++
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c: In function 'win32_spawn':
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c:566: warning: request for implicit conversion from 'void *' to 'char **' not permitted in C++
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c:573: warning: request for implicit conversion from 'void *' to 'char *' not permitted in C++
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c: At top level:
../../../../llvm-gcc4.2-src/libiberty/pex-win32.c:900: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
make[2]: *** [pex-win32.o] Error 1
make[2]: Leaving directory `/c/cygwin/home/jlerouge/buildbot/llvm-test/gcc-build/i686-pc-mingw32/libiberty'
make[1]: *** [all-target-libiberty] Error 2
make[1]: Leaving directory `/c/cygwin/home/jlerouge/buildbot/llvm-test/gcc-build'
make: *** [all] Error 2

The regression seems to have been introduced between revision 61201 (last known
working) and 61242 (first known non working).

I'll try to find out the smallest diff, but I thought running this by the list
first couldn't hurt ;-)

Thanks,
Julien

-- 
Julien Lerouge
PGP Key Id: 0xB1964A62
PGP Fingerprint: 392D 4BAD DB8B CE7F 4E5F FA3C 62DB 4AA7 B196 4A62
PGP Public Key from: keyserver.pgp.com
-------------- next part --------------
Index: utils/unittest/googletest/gtest.cc
===================================================================
--- utils/unittest/googletest/gtest.cc	(revision 63080)
+++ utils/unittest/googletest/gtest.cc	(working copy)
@@ -1993,7 +1993,7 @@
   if (!HasSameFixtureClass()) return;
 
   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-#ifdef GTEST_OS_WINDOWS
+#if defined(GTEST_OS_WINDOWS) && !defined(__MINGW__) && !defined(__MINGW32__)
   // We are on Windows.
   impl->os_stack_trace_getter()->UponLeavingGTest();
   __try {
@@ -2025,7 +2025,7 @@
     AddExceptionThrownFailure(GetExceptionCode(), "TearDown()");
   }
 
-#else  // We are on Linux or Mac - exceptions are disabled.
+#else  // We are on Linux, Mac or MingW - exceptions are disabled.
   impl->os_stack_trace_getter()->UponLeavingGTest();
   SetUp();
 
@@ -2227,7 +2227,7 @@
   const TimeInMillis start = GetTimeInMillis();
 
   impl->os_stack_trace_getter()->UponLeavingGTest();
-#ifdef GTEST_OS_WINDOWS
+#if defined(GTEST_OS_WINDOWS) && !defined(__MINGW__) && !defined(__MINGW32__)
   // We are on Windows.
   Test* test = NULL;
 
@@ -2240,7 +2240,7 @@
                               "the test fixture's constructor");
     return;
   }
-#else  // We are on Linux or Mac OS - exceptions are disabled.
+#else  // We are on Linux, Mac OS or MingW - exceptions are disabled.
 
   // TODO(wan): If test->Run() throws, test won't be deleted.  This is
   // not a problem now as we don't use exceptions.  If we were to
@@ -3271,7 +3271,7 @@
 // We don't protect this under mutex_, as we only support calling it
 // from the main thread.
 int UnitTest::Run() {
-#ifdef GTEST_OS_WINDOWS
+#if defined(GTEST_OS_WINDOWS) && !defined(__MINGW__) && !defined(__MINGW32__)
 
 #if !defined(_WIN32_WCE)
   // SetErrorMode doesn't exist on CE.
@@ -3294,7 +3294,7 @@
   }
 
 #else
-  // We are on Linux or Mac OS.  There is no exception of any kind.
+  // We are on Linux, Mac OS or MingW.  There is no exception of any kind.
 
   return impl_->RunAllTests();
 #endif  // GTEST_OS_WINDOWS
Index: utils/unittest/googletest/Makefile
===================================================================
--- utils/unittest/googletest/Makefile	(revision 63080)
+++ utils/unittest/googletest/Makefile	(working copy)
@@ -13,6 +13,12 @@
 LIBRARYNAME = GoogleTest
 BUILD_ARCHIVE = 1
 CPP.Flags += -I$(LLVM_SRC_ROOT)/utils/unittest/googletest/include/
-CPP.Flags += -Wno-missing-field-initializers -Wno-variadic-macros
 
+ifeq ($(OS),MingW)
+  # Min requirement for MingW is GCC 3.4.X, the warnings below don't exist.
+  CPP.Flags += -DGTEST_OS_WINDOWS=1
+else
+  CPP.Flags += -Wno-missing-field-initializers -Wno-variadic-macros
+endif
+
 include $(LEVEL)/Makefile.common


More information about the llvm-dev mailing list