[m-rev.] diff: avoid using non-MSVC command line options with MSVC
Julien Fischer
jfischer at opturion.com
Tue Mar 4 15:01:12 AEDT 2014
Branches: master, 14.01
----------------
Avoid using non-MSVC command line options with MSVC.
The configure script tests the for the presence of various C compiler command
line options by attempting to compile a small test program with those options.
Testing for command line options this way does not work with MSVC since it will
print a warning about the option not being recognised and then carry on as normal.
There is no way to tell MSVC to treat this warning as an error.
The above behaviour resulted in the Mercury.config file for installations
configured to use MSVC containing flags for non-MSVC compilers.
configure.ac:
Avoid testing for non-MSVC command line options by compiling a test
program when we are using MSVC as the C compiler.
Fix a typo: s/boostrap/bootstrap/
Julien.
diff --git a/configure.ac b/configure.ac
index 05a7a83..f8f98f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -580,7 +580,7 @@ fi
if test "$BOOTSTRAP_MC" = ""
then
- # If we do not have a working boostrap Mercury compiler, then work out
+ # If we do not have a working bootstrap Mercury compiler, then work out
# whether any .c files we do have were compiled with --highlevel code or
# not. At this point we only check a single file -- this is enough to
# allow us to determine a value for BOOTSTRAP_GRADE below -- we check
@@ -885,6 +885,22 @@ esac
#-----------------------------------------------------------------------------#
+# Test whether specific command line options are supported by the C compiler.
+# We do this by attempting to compile a program with the option whose presence
+# we are testing for. This will not work for MSVC since it prints a warning
+# about any unknown options and then proceeds as normal. There is no way to
+# tell it to treat that warning as an error (in particular, this warning is not
+# affected by the -WX option).
+
+if test "$MERCURY_HAVE_MSVC" = "yes"
+then
+
+ CFLAGS_FOR_ERRMSG_FILTER=""
+ CFLAGS_FOR_NO_MOVE_LOOP_INVARIANTS=
+ CFLAGS_FOR_NO_REORDER_FUNCTIONS=""
+
+else
+
cat > conftest.c << EOF
struct MR_TypeInfo_Almost_Struct {
int MR_almost;
@@ -915,40 +931,41 @@ cat > conftest.c << EOF
}
EOF
-AC_MSG_CHECKING(whether we can make error messages filterable)
-if $CC -ftrack-macro-expansion=0 -fno-diagnostics-show-caret -c conftest.c \
- </dev/null >&AC_FD_CC 2>&1
-then
- AC_MSG_RESULT(yes)
- CFLAGS_FOR_ERRMSG_FILTER="-ftrack-macro-expansion=0 -fno-diagnostics-show-caret"
-else
- AC_MSG_RESULT(no)
- CFLAGS_FOR_ERRMSG_FILTER=""
-fi
+ AC_MSG_CHECKING(whether we can make error messages filterable)
+ if $CC -ftrack-macro-expansion=0 -fno-diagnostics-show-caret -c conftest.c \
+ </dev/null >&AC_FD_CC 2>&1
+ then
+ AC_MSG_RESULT(yes)
+ CFLAGS_FOR_ERRMSG_FILTER="-ftrack-macro-expansion=0 -fno-diagnostics-show-caret"
+ else
+ AC_MSG_RESULT(no)
+ CFLAGS_FOR_ERRMSG_FILTER=""
+ fi
-AC_MSG_CHECKING(whether we can use -fno-move-loop-invariants)
-if $CC -fno-move-loop-invariants -c conftest.c \
- </dev/null >&AC_FD_CC 2>&1
-then
- AC_MSG_RESULT(yes)
- CFLAGS_FOR_NO_MOVE_LOOP_INVARIANTS="-fno-move-loop-invariants"
-else
- AC_MSG_RESULT(no)
- CFLAGS_FOR_NO_MOVE_LOOP_INVARIANTS=
-fi
+ AC_MSG_CHECKING(whether we can use -fno-move-loop-invariants)
+ if $CC -fno-move-loop-invariants -c conftest.c \
+ </dev/null >&AC_FD_CC 2>&1
+ then
+ AC_MSG_RESULT(yes)
+ CFLAGS_FOR_NO_MOVE_LOOP_INVARIANTS="-fno-move-loop-invariants"
+ else
+ AC_MSG_RESULT(no)
+ CFLAGS_FOR_NO_MOVE_LOOP_INVARIANTS=
+ fi
-AC_MSG_CHECKING(whether we can use -fno-reorder-functions)
-if $CC -fno-reorder-functions -c conftest.c \
- </dev/null >&AC_FD_CC 2>&1
-then
- AC_MSG_RESULT(yes)
- CFLAGS_FOR_NO_REORDER_FUNCTIONS="-fno-reorder-functions"
-else
- AC_MSG_RESULT(no)
- CFLAGS_FOR_NO_REORDER_FUNCTIONS=""
-fi
+ AC_MSG_CHECKING(whether we can use -fno-reorder-functions)
+ if $CC -fno-reorder-functions -c conftest.c \
+ </dev/null >&AC_FD_CC 2>&1
+ then
+ AC_MSG_RESULT(yes)
+ CFLAGS_FOR_NO_REORDER_FUNCTIONS="-fno-reorder-functions"
+ else
+ AC_MSG_RESULT(no)
+ CFLAGS_FOR_NO_REORDER_FUNCTIONS=""
+ fi
-rm -f conftest*
+ rm -f conftest*
+fi
#-----------------------------------------------------------------------------#
# Make sure we search /usr/local/include and /usr/local/lib for
More information about the reviews
mailing list