[commit: ghc] master: Change the ranlib detection (c548fec)

Ian Lynagh igloo at earth.li
Wed Jul 3 17:22:14 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/c548fec4f11920244e81b9f83ebb2aaf7d08ba40

>---------------------------------------------------------------

commit c548fec4f11920244e81b9f83ebb2aaf7d08ba40
Author: Ian Lynagh <ian at well-typed.com>
Date:   Wed Jul 3 00:16:16 2013 +0100

    Change the ranlib detection
    
    On Windows, the ranlib in the path may not be the right ranlib (it may
    be the 32bit ranlib when we are making a Win64 compiler, or vice-versa).
    Therefore we can't leave it up to libffi to detect the right ranlib, but
    need to tell it which ranlib to use. This means that we need to find
    ranlib even if we don't actually need it ourselves.

>---------------------------------------------------------------

 aclocal.m4                  | 60 +++++++++++++++++++++++++++------------------
 configure.ac                |  1 +
 ghc.mk                      |  2 +-
 libffi/ghc.mk               |  1 +
 mk/config.mk.in             |  3 ++-
 rules/build-package-data.mk |  2 +-
 6 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index af492df..0852dbf 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1096,30 +1096,42 @@ AC_SUBST([ArArgs], ["$fp_prog_ar_args"])
 
 # FP_PROG_AR_NEEDS_RANLIB
 # -----------------------
-# Sets the output variable RANLIB to "ranlib" if it is needed and found,
-# to "true" otherwise.
-AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],
-[AC_REQUIRE([FP_PROG_AR_IS_GNU])
-AC_REQUIRE([FP_PROG_AR_ARGS])
-AC_REQUIRE([AC_PROG_CC])
-AC_CACHE_CHECK([whether ranlib is needed], [fp_cv_prog_ar_needs_ranlib],
-[if test $fp_prog_ar_is_gnu = yes; then
-  fp_cv_prog_ar_needs_ranlib=no
-elif echo $TargetPlatform | grep "^.*-apple-darwin$"  > /dev/null 2> /dev/null; then
-  # It's quite tedious to check for Apple's crazy timestamps in .a files,
-  # so we hardcode it.
-  fp_cv_prog_ar_needs_ranlib=yes
-elif echo $fp_prog_ar_args | grep "s" > /dev/null 2> /dev/null; then
-  fp_cv_prog_ar_needs_ranlib=no
-else
-  fp_cv_prog_ar_needs_ranlib=yes
-fi])
-if test $fp_cv_prog_ar_needs_ranlib = yes; then
-   AC_PROG_RANLIB
-else
-  RANLIB="true"
-  AC_SUBST([RANLIB])
-fi
+# Sets the output variable RANLIB_CMD to "ranlib" if it is needed and
+# found, to "true" otherwise. Sets REAL_RANLIB_CMD to the ranlib program,
+# even if we don't need ranlib (libffi might still need it).
+AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
+    AC_REQUIRE([FP_PROG_AR_IS_GNU])
+    AC_REQUIRE([FP_PROG_AR_ARGS])
+    AC_REQUIRE([AC_PROG_CC])
+
+    AC_PROG_RANLIB
+
+    if test $fp_prog_ar_is_gnu = yes
+    then
+        fp_cv_prog_ar_needs_ranlib=no
+    elif test "$TargetOS_CPP" = "darwin"
+    then
+        # It's quite tedious to check for Apple's crazy timestamps in
+        # .a files, so we hardcode it.
+        fp_cv_prog_ar_needs_ranlib=yes
+    else
+        case $fp_prog_ar_args in
+        *s*)
+            fp_cv_prog_ar_needs_ranlib=no;;
+        *)
+            fp_cv_prog_ar_needs_ranlib=yes;;
+        esac
+    fi
+
+    REAL_RANLIB_CMD="$RANLIB"
+    if test $fp_cv_prog_ar_needs_ranlib = yes
+    then
+        RANLIB_CMD="$RANLIB"
+    else
+        RANLIB_CMD="true"
+    fi
+    AC_SUBST([REAL_RANLIB_CMD])
+    AC_SUBST([RANLIB_CMD])
 ])# FP_PROG_AR_NEEDS_RANLIB
 
 
diff --git a/configure.ac b/configure.ac
index 7bbeca6..8d8136f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -328,6 +328,7 @@ then
     CC="${mingwbin}gcc.exe"
     LD="${mingwbin}ld.exe"
     NM="${mingwbin}nm.exe"
+    RANLIB="${mingwbin}ranlib.exe"
     OBJDUMP="${mingwbin}objdump.exe"
     fp_prog_ar="${mingwbin}ar.exe"
 
diff --git a/ghc.mk b/ghc.mk
index 87b6ac8..4754ad6 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -815,7 +815,7 @@ define installLibsTo
 		case $$i in \
 		  *.a) \
 		    $(call INSTALL_DATA,$(INSTALL_OPTS),$$i,$2); \
-		    $(RANLIB) $2/`basename $$i` ;; \
+		    $(RANLIB_CMD) $2/`basename $$i` ;; \
 		  *.dll) \
 		    $(call INSTALL_PROGRAM,$(INSTALL_OPTS),$$i,$2) ; \
 		    $(STRIP_CMD) $2/`basename $$i` ;; \
diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index ffef273..d761a43 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -86,6 +86,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
 	    LD=$(LD) \
 	    AR=$(AR_STAGE1) \
 	    NM=$(NM) \
+	    RANLIB=$(REAL_RANLIB_CMD) \
         CFLAGS="$(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -w" \
         LDFLAGS="$(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE1) -w" \
         "$(SHELL)" ./configure \
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 1235798..2e36be5 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -636,7 +636,8 @@ LN_S			= @LN_S@
 MV			= mv
 PERL 			= @PerlCmd@
 PIC			= pic
-RANLIB			= @RANLIB@
+RANLIB_CMD = @RANLIB_CMD@
+REAL_RANLIB_CMD = @REAL_RANLIB_CMD@
 SED			= @SedCmd@
 SHELL			= /bin/sh
 
diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk
index 2429942..82a2535 100644
--- a/rules/build-package-data.mk
+++ b/rules/build-package-data.mk
@@ -86,7 +86,7 @@ endif
 
 $1_$2_CONFIGURE_OPTS += --configure-option=--with-cc="$$(CC_STAGE$3)"
 $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)"
-$1_$2_CONFIGURE_OPTS += --with-ranlib="$$(RANLIB)"
+$1_$2_CONFIGURE_OPTS += --with-ranlib="$$(REAL_RANLIB_CMD)"
 $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)")
 $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)")
 





More information about the ghc-commits mailing list