[vlc-devel] [PATCH] restrict from applying gcc only flags
Francois Cartegnie
fcvlcdev at free.fr
Mon Jun 14 18:36:54 CEST 2010
testings of gcc's optimization variables against other compilers can't be
trusted as they might just propagate them to linker, without throwing
an error to autoconf. In the suncc case, the linker will fail later.
---
configure.ac | 86 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 53 insertions(+), 33 deletions(-)
diff --git a/configure.ac b/configure.ac
index 37ed6d1..1894cf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -983,6 +983,18 @@ CFLAGS="${CFLAGS_save}"
RDC_PROG_CC_WFLAGS([all extra sign-compare undef pointer-arith bad-function-cast write-strings missing-prototypes volatile-register-var error-implicit-function-declaration])
RDC_PROG_CC_FLAGS([-pipe])
+dnl Set up version & compiler variables for various hacks
+if test "$GCC" = "yes"; then
+ AC_DEFINE_UNQUOTED(VLC_COMPILER, "`$CC -v 2>&1 | tail -n 1`", [compiler])
+else
+ AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
+ if test "$SUNCC" = "yes"; then
+ AC_DEFINE_UNQUOTED(VLC_COMPILER, "`$CC -V 2>&1 | head -n 1`", [compiler])
+ else
+ AC_DEFINE_UNQUOTED(VLC_COMPILER, "unknown", [compiler])
+ fi
+fi
+
dnl Check for various optimization flags
AC_CACHE_CHECK([if \$CC accepts -Os],
[ac_cv_c_os],
@@ -1043,17 +1055,21 @@ if test "${ac_cv_c_o0}" != "no"; then
fi
dnl Check for -ffast-math
-AC_CACHE_CHECK([if \$CC accepts -ffast-math],
- [ac_cv_c_fast_math],
- [CFLAGS="${CFLAGS_save} -ffast-math"
- AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
-if test "${ac_cv_c_fast_math}" != "no"; then
- CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -ffast-math"
+dnl We need to sanitize SunCC options as unknown ones are passed to ld
+if test "$SUNCC" != "yes"
+then
+ AC_CACHE_CHECK([if \$CC accepts -ffast-math],
+ [ac_cv_c_fast_math],
+ [CFLAGS="${CFLAGS_save} -ffast-math"
+ AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)])
+ if test "${ac_cv_c_fast_math}" != "no"; then
+ CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -ffast-math"
+ fi
fi
dnl Check for -funroll-loops
dnl Disabled on BeOS because BeOS' gcc is buggy and may crash with it
-if test "${SYS}" != "beos"
+if test "${SYS}" != "beos" -a "$SUNCC" != "yes"
then
AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
[ac_cv_c_unroll_loops],
@@ -1065,17 +1081,20 @@ then
fi
dnl Check for -fomit-frame-pointer
-AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer],
- [ac_cv_c_omit_frame_pointer],
- [CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
- AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
-if test "${ac_cv_c_omit_frame_pointer}" != "no"; then
- if test "${SYS}" != "darwin"; then
- CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
- else
- dnl On darwin we explicitely disable it.
- CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fno-omit-frame-pointer"
- fi
+if test "$SUNCC" != "yes"
+then
+ AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer],
+ [ac_cv_c_omit_frame_pointer],
+ [CFLAGS="${CFLAGS_save} -fomit-frame-pointer"
+ AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)])
+ if test "${ac_cv_c_omit_frame_pointer}" != "no"; then
+ if test "${SYS}" != "darwin"; then
+ CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer"
+ else
+ dnl On darwin we explicitely disable it.
+ CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fno-omit-frame-pointer"
+ fi
+ fi
fi
dnl Check for Darwin plugin linking flags
@@ -1494,20 +1513,22 @@ dnl
AC_ARG_WITH(tuning,
[ --with-tuning=ARCH enable special tuning for an architecture
(default Pentium 2 on IA-32 and G4 on PPC)])
-if test -n "${with_tuning}"; then
- if test "${with_tuning}" != "no"; then
- CFLAGS_TUNING="-mtune=${with_tuning}"
- fi
-else
- if test "${SYS}" = "darwin" -a "${host_cpu}" != "powerpc"; then
- CFLAGS_TUNING="-march=prescott -mtune=generic"
- elif test "${host_cpu}" = "i686" -o "${host_cpu}" = "i586" -o "${host_cpu}" = "i486" -o "${host_cpu}" = "i386"; then
- CFLAGS_TUNING="-mtune=pentium2"
- elif test "${host_cpu}" = "x86_64"; then
- CFLAGS_TUNING="-mtune=athlon64"
- elif test "${host_cpu}" = "powerpc"; then
- CFLAGS_TUNING="-mtune=G4";
- fi
+if test "$SUNCC" != "yes"; then
+ if test -n "${with_tuning}"; then
+ if test "${with_tuning}" != "no"; then
+ CFLAGS_TUNING="-mtune=${with_tuning}"
+ fi
+ else
+ if test "${SYS}" = "darwin" -a "${host_cpu}" != "powerpc"; then
+ CFLAGS_TUNING="-march=prescott -mtune=generic"
+ elif test "${host_cpu}" = "i686" -o "${host_cpu}" = "i586" -o "${host_cpu}" = "i486" -o "${host_cpu}" = "i386"; then
+ CFLAGS_TUNING="-mtune=pentium2"
+ elif test "${host_cpu}" = "x86_64"; then
+ CFLAGS_TUNING="-mtune=athlon64"
+ elif test "${host_cpu}" = "powerpc"; then
+ CFLAGS_TUNING="-mtune=G4";
+ fi
+ fi
fi
dnl NOTE: this can't be cached cleanly
@@ -4650,7 +4671,6 @@ AC_SUBST(VERSION_EXTRA)
AC_SUBST(COPYRIGHT_YEARS)
AC_DEFINE_UNQUOTED(VLC_COMPILE_BY, "`whoami`", [user who ran configure])
AC_DEFINE_UNQUOTED(VLC_COMPILE_HOST, "`hostname -f 2>/dev/null || hostname`", [host which ran configure])
-AC_DEFINE_UNQUOTED(VLC_COMPILER, "`$CC -v 2>&1 | tail -n 1`", [compiler])
dnl Win32 need s a numerical version_extra.
case $( echo ${VERSION_EXTRA}|wc -m ) in
"1") VERSION_EXTRA_RC="0";;
--
1.5.6.5
More information about the vlc-devel
mailing list