[m-rev.] diff: fix problem with mgnuc script and Xcode 5

Julien Fischer jfischer at opturion.com
Mon Feb 3 12:30:50 AEDT 2014


Avoid C compiler warnings on OS X with Xcode 5.

In the mgnuc script, do not use the name of the C compiler to determine its
type since on OS X with Xcode 5 the executable "gcc" is actually clang.
Instead use the value of C_COMPILER_TYPE determined by the configure script to
set C compiler type, as elsewhere in the Mercury system.

Incorrectly identifying the C compiler type was resulting in lots of
compilation warnings because we were using the warning flags intended for GCC
with clang.  Further warnings were being generated because GCC-only
optimization flags would also be passed to clang.

scripts/mgnuc.in:
 	As above.

Julien.

diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index 1d8aac4..57136ed 100644
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -21,6 +21,7 @@ NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}

  DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
  CC=${MERCURY_C_COMPILER="@CC@"}
+C_COMPILER_TYPE=${MERCURY_C_COMPILER_TYPE="@C_COMPILER_TYPE@"}
  CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@"
  CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
  CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
@@ -30,8 +31,8 @@ BYTES_PER_WORD="@BYTES_PER_WORD@"
  MKTEMP=@MKTEMP@
  TMPDIR=${TMPDIR=/tmp}

-case "$CC" in
-    *gcc*)
+case "$C_COMPILER_TYPE" in
+    gcc*)
          ANSI_OPTS="-ansi"
          CHECK_OPTS="
              -Wall -Wwrite-strings
@@ -70,7 +71,7 @@ case "$CC" in
          DISABLE_OPTS_OPT="-O0"
          COMPILER=gcc
          ;;
-    *clang*)
+    clang*)
          ANSI_OPTS="-ansi"
          CHECK_OPTS="-w"
          OPT_OPTS="@OPT_FLAGS_FOR_CLANG@ $CFLAGS_FOR_NO_STRICT_ALIASING -fomit-frame-pointer"
@@ -78,7 +79,7 @@ case "$CC" in
          DISABLE_OPTS_OPT="-O0"
          COMPILER=clang
          ;;
-    *lcc*)
+    lcc*)
          ANSI_OPTS=
          CHECK_OPTS="-w"     # turn off all warnings due to spurious warnings.
          OPT_OPTS=""
@@ -86,7 +87,7 @@ case "$CC" in
          DISABLE_OPTS_OPT="-O0"
          COMPILER=lcc
          ;;
-    *cl* | *CL*)
+    msvc*)
          ANSI_OPTS=""
          CHECK_OPTS="-nologo"    # Suppress the MSVC banner message.
          OPT_OPTS=""



More information about the reviews mailing list