[PATCH] Don't claim C++ compiler exists if it's not installed

Richard W.M. Jones rjones at redhat.com
Sat Jan 24 17:51:27 UTC 2009


I've just spent a good day tracking down a very odd and unreproducible
bug where libtool would fail to install DLLs properly.

It turns out this was caused because we set the CXX and CXXFLAGS for
./configure even if there is no C++ compiler actually installed
(ie. if mingw32-gcc-c++ is not installed).  Autoconf and libtool get
very confused by this.  It appears they believe you if you claim the
compiler is installed (even though patently nothing works) but then
all of their tests fail and you get a broken libtool.

The attached patch fixes this by setting CXX and CXXFLAGS to the empty
string if the C++ compiler isn't detected.  I've also moved the
automatic variables above the C/C++ compiler specific setting, so that
the automatic variables don't override what we are specifically
setting.

I'm going to apply this, although at the moment I'm also chasing a
second bug.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
? noarch
Index: mingw32-filesystem.spec
===================================================================
RCS file: /cvs/pkgs/rpms/mingw32-filesystem/devel/mingw32-filesystem.spec,v
retrieving revision 1.10
diff -u -r1.10 mingw32-filesystem.spec
--- mingw32-filesystem.spec	14 Jan 2009 10:20:03 -0000	1.10
+++ mingw32-filesystem.spec	24 Jan 2009 17:47:48 -0000
@@ -1,8 +1,8 @@
 %define debug_package %{nil}
 
 Name:           mingw32-filesystem
-Version:        42
-Release:        1%{?dist}
+Version:        43
+Release:        5%{?dist}
 Summary:        MinGW base filesystem and environment
 
 Group:          Development/Libraries
@@ -145,6 +145,10 @@
 
 
 %changelog
+* Sat Jan 24 2009 Richard W.M. Jones <rjones at redhat.com> - 43-5
+- Don't claim C++ compiler exists if it's not installed, as this
+  breaks autoconf and (in particular) libtool.
+
 * Wed Jan 14 2009 Richard W.M. Jones <rjones at redhat.com> - 42-1
 - Add pseudo-provides secur32.dll
 
Index: mingw32-macros.mingw32
===================================================================
RCS file: /cvs/pkgs/rpms/mingw32-filesystem/devel/mingw32-macros.mingw32,v
retrieving revision 1.6
diff -u -r1.6 mingw32-macros.mingw32
--- mingw32-macros.mingw32	18 Dec 2008 10:53:30 -0000	1.6
+++ mingw32-macros.mingw32	24 Jan 2009 17:47:48 -0000
@@ -55,16 +55,21 @@
 
 %_mingw32_env HOST_CC=gcc; export HOST_CC; \
   PKG_CONFIG_PATH="%{_mingw32_libdir}/pkgconfig"; export PKG_CONFIG_PATH; \
-  CC="${MINGW32_CC:-%_mingw32_cc}"; export CC; \
-  CXX="${MINGW32_CXX:-%_mingw32_cxx}"; export CXX; \
-  CFLAGS="${MINGW32_CFLAGS:-%_mingw32_cflags}"; export CFLAGS; \
-  CXXFLAGS="${MINGW32_CXXFLAGS:-%_mingw32_cflags}"; export CXXFLAGS; \
   _PREFIX="%{_bindir}/%{_mingw32_target}-"; \
-  for i in `ls ${_PREFIX}*|egrep -v "gcc-"`; do \
+  for i in `ls -1 ${_PREFIX}* | grep -v 'gcc-'`; do \
     x=`echo $i|sed "s,${_PREFIX},,"|tr "a-z+-" "A-ZX_"`; \
     declare -x $x="$i" ; export $x; \
   done; \
   unset _PREFIX; \
+  CC="${MINGW32_CC:-%_mingw32_cc}"; export CC; \
+  CFLAGS="${MINGW32_CFLAGS:-%_mingw32_cflags}"; export CFLAGS; \
+  if [ -x "%{_bindir}/%{_mingw32_cxx}" ]; then \
+    CXX="${MINGW32_CXX:-%_mingw32_cxx}"; export CXX; \
+    CXXFLAGS="${MINGW32_CXXFLAGS:-%_mingw32_cflags}"; export CXXFLAGS; \
+  else \
+    CXX=; export CXX; \
+    CXXFLAGS=; export CXXFLAGS; \
+  fi; \
   for i in `ls %{_mingw32_bindir}/*|grep -- "-config\$"` ; do \
     x=`basename $i|tr "a-z+-" "A-ZX_"`; \
     declare -x $x="$i" ; export $x; \


More information about the mingw mailing list