[vlc-devel] [PATCH 4/8] add compiler detection variables and apply the correct optimization flags
Francois Cartegnie
fcvlcdev at free.fr
Wed Apr 14 16:53:16 CEST 2010
---
configure.ac | 68 +++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/configure.ac b/configure.ac
index 27a05b8..66844b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -979,6 +979,22 @@ 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
+VLC_COMPILER=`$CC -v 2>&1 | tail -n 1`
+if echo "${VLC_COMPILER}" | grep GCC; then
+ AC_DEFINE_UNQUOTED(VLC_COMPILER, "${VLC_COMPILER}", [compiler])
+ VLC_COMPILER_BRAND="GCC"
+else
+ if echo "${VLC_COMPILER}" | grep "cc \-flags"; then
+ dnl Looks like Sun Studio's error
+ AC_DEFINE_UNQUOTED(VLC_COMPILER, "`$CC -V 2>&1 | head -n 1`", [compiler])
+ VLC_COMPILER_BRAND="SUNCC"
+ else
+ AC_DEFINE_UNQUOTED(VLC_COMPILER, "${VLC_COMPILER}", [compiler])
+ VLC_COMPILER_BRAND="UNKNOWN"
+ fi
+fi
+
dnl Check for various optimization flags
AC_CACHE_CHECK([if \$CC accepts -Os],
[ac_cv_c_os],
@@ -1039,17 +1055,24 @@ 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 "${VLC_COMPILER_BRAND}" != "SUNCC"
+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
+else
+ dnl Enable optimisations for Sun's cc
+ CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -fast"
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" && test "${VLC_COMPILER_BRAND}" != "SUNCC"
then
AC_CACHE_CHECK([if \$CC accepts -funroll-loops],
[ac_cv_c_unroll_loops],
@@ -1058,20 +1081,27 @@ then
if test "${ac_cv_c_unroll_loops}" != "no"; then
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -funroll-loops"
fi
+else
+ if test "${VLC_COMPILER_BRAND}" == "SUNCC"; then
+ CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -xunroll=4"
+ fi
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 "${VLC_COMPILER_BRAND}" != "SUNCC"
+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
@@ -4751,7 +4781,7 @@ 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.6.3
More information about the vlc-devel
mailing list