Commit 2c9b0d37 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Only check optimization flags when useful

parent 4a78361e
...@@ -1050,79 +1050,157 @@ AS_IF([test "${enable_coverage}" != "no"], [ ...@@ -1050,79 +1050,157 @@ AS_IF([test "${enable_coverage}" != "no"], [
VLC_SAVE_FLAGS VLC_SAVE_FLAGS
dnl
dnl Enable/disable optimizations
dnl
AC_ARG_ENABLE(optimizations,
[AS_HELP_STRING([--disable-optimizations],
[disable compiler optimizations (default enabled)])],,
[enable_optimizations="yes"])
AS_IF([test "${enable_optimizations}" != "no"], [
enable_optimizations="speed"
])
dnl Check for various optimization flags dnl Check for various optimization flags
AC_CACHE_CHECK([if \$CC accepts -O4], AS_IF([test "${enable_optimizations}" != "no"], [
[ac_cv_c_o4],
[CFLAGS="${CFLAGS_save} -O4" C_O=""
AC_TRY_COMPILE([],,ac_cv_c_o4=yes, ac_cv_c_o4=no)]) dnl -O4 and -O3 only in production builds
if test "${ac_cv_c_o4}" != "no" -a "x${enable_debug}" = "xno"; then AS_IF([test "{enable_debug}" = "no"], [
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O4" AC_CACHE_CHECK([if $CC accepts -O4], [ac_cv_c_o4], [
else CFLAGS="${CFLAGS_save} -O4"
AC_CACHE_CHECK([if \$CC accepts -O3], AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
[ac_cv_c_o3], ac_cv_c_o4=yes
[CFLAGS="${CFLAGS_save} -O3" ], [
AC_TRY_COMPILE([],,ac_cv_c_o3=yes, ac_cv_c_o3=no)]) ac_cv_c_o4=no
if test "${ac_cv_c_o3}" != "no" -a "x${enable_debug}" = "xno"; then ])
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O3" ])
else AS_IF([test "${ac_cv_c_o4}" != "no"], [
AC_CACHE_CHECK([if \$CC accepts -O2], C_O="-O4"
[ac_cv_c_o2], ], [
[CFLAGS="${CFLAGS_save} -O2" AC_CACHE_CHECK([if $CC accepts -O3], [ac_cv_c_o3], [
AC_TRY_COMPILE([],,ac_cv_c_o2=yes, ac_cv_c_o2=no)]) CFLAGS="${CFLAGS_save} -O3"
if test "${ac_cv_c_o2}" != "no"; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O2" ac_cv_c_o3=yes
else ], [
AC_CACHE_CHECK([if \$CC accepts -O], ac_cv_c_o3=no
[ac_cv_c_o], ])
[CFLAGS="${CFLAGS_save} -O" ])
AC_TRY_COMPILE([],,ac_cv_c_o=yes, ac_cv_c_o=no)]) AS_IF([test "${ac_cv_c_o3}" != "no"], [
if test "${ac_cv_c_o}" != "no"; then C_O="-O3"
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -O" ])
fi ])
fi ])
fi
fi
dnl Check for -ffast-math dnl -O2 and -O in both production and debug builds
AC_CACHE_CHECK([if \$CC accepts -ffast-math], AS_IF([test "x$C_O" = "x"], [
[ac_cv_c_fast_math], AC_CACHE_CHECK([if \$CC accepts -O2], [ac_cv_c_o2], [
[CFLAGS="${CFLAGS_save} -ffast-math" CFLAGS="${CFLAGS_save} -O2"
AC_TRY_COMPILE([],,ac_cv_c_fast_math=yes, ac_cv_c_fast_math=no)]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
if test "${ac_cv_c_fast_math}" != "no"; then ac_cv_c_o2=yes
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -ffast-math" ], [
fi ac_cv_c_o2=no
])
])
AS_IF([test "${ac_cv_c_o2}" != "no"], [
C_O="-O2"
], [
AC_CACHE_CHECK([if \$CC accepts -O], [ac_cv_c_o], [
CFLAGS="${CFLAGS_save} -O"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
ac_cv_c_o=yes
], [
ac_cv_c_o=no
])
])
AS_IF([test "${ac_cv_c_o}" != "no"], [
C_O="-O"
])
])
])
dnl Check for -funroll-loops VLC_RESTORE_FLAGS
AC_CACHE_CHECK([if \$CC accepts -funroll-loops], CFLAGS="${CFLAGS} ${C_O}"
[ac_cv_c_unroll_loops], CXXFLAGS="${CXXFLAGS} ${C_O}"
[CFLAGS="${CFLAGS_save} -funroll-loops" OBJCFLAGS="${OBJCFLAGS} ${C_O}"
AC_TRY_COMPILE([],,ac_cv_c_unroll_loops=yes, ac_cv_c_unroll_loops=no)]) VLC_SAVE_FLAGS
if test "${ac_cv_c_unroll_loops}" != "no"; then
CFLAGS_OPTIM_SPEED="${CFLAGS_OPTIM_SPEED} -funroll-loops"
fi
dnl Check for -fomit-frame-pointer dnl Check for -ffast-math
AC_CACHE_CHECK([if \$CC accepts -fomit-frame-pointer], AC_CACHE_CHECK([if $CC accepts -ffast-math], [ac_cv_c_fast_math], [
[ac_cv_c_omit_frame_pointer], CFLAGS="${CFLAGS_save} -ffast-math"
[CFLAGS="${CFLAGS_save} -fomit-frame-pointer" AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
AC_TRY_COMPILE([],,ac_cv_c_omit_frame_pointer=yes, ac_cv_c_omit_frame_pointer=no)]) ac_cv_c_fast_math=yes
if test "${ac_cv_c_omit_frame_pointer}" != "no"; then ], [
if test "${SYS}" != "darwin"; then ac_cv_c_fast_math=no
CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fomit-frame-pointer" ])
else ])
AS_IF([test "${ac_cv_c_fast_math}" != "no"], [
VLC_RESTORE_FLAGS
CFLAGS="${CFLAGS} -ffast-math"
CXXFLAGS="${CXXFLAGS} -ffast-math"
OBJCFLAGS="${OBJCFLAGS} -ffast-math"
VLC_SAVE_FLAGS
])
dnl Check for -funroll-loops
AC_CACHE_CHECK([if $CC accepts -funroll-loops], [ac_cv_c_unroll_loops], [
CFLAGS="${CFLAGS_save} -funroll-loops"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
ac_cv_c_unroll_loops=yes
], [
ac_cv_c_unroll_loops=no
])
])
AS_IF([test "${ac_cv_c_unroll_loops}" != "no"], [
VLC_RESTORE_FLAGS
CFLAGS="${CFLAGS} -funroll-loops"
CXXFLAGS="${CXXFLAGS} -funroll-loops"
OBJCFLAGS="${OBJCFLAGS} -funroll-loops"
VLC_SAVE_FLAGS
])
AS_IF([test "$enable_debug" = "no"], [
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_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
ac_cv_c_omit_frame_pointer=yes
], [
ac_cv_c_omit_frame_pointer=no
])
])
AS_IF([test "${ac_cv_c_omit_frame_pointer}" != "no"], [
VLC_RESTORE_FLAGS
AS_IF([test "${SYS}" != "darwin"], [
CFLAGS="${CFLAGS} -fomit-frame-pointer"
CXXFLAGS="${CXXFLAGS} -fomit-frame-pointer"
], [
dnl On darwin we explicitely disable it. dnl On darwin we explicitely disable it.
CFLAGS_OPTIM_NODEBUG="${CFLAGS_OPTIM_NODEBUG} -fno-omit-frame-pointer" CFLAGS="${CFLAGS} -fno-omit-frame-pointer"
fi CXXFLAGS="${CXXFLAGS} -fno-omit-frame-pointer"
fi OBJCFLAGS="${OBJCFLAGS} -fno-omit-frame-pointer"
])
VLC_SAVE_FLAGS
])
])
])
dnl Check for Darwin plugin linking flags dnl Check for Darwin plugin linking flags
AC_CACHE_CHECK([if \$CC accepts -bundle -undefined error], AS_IF([test "${SYS}" = "darwin"], [
[ac_cv_ld_darwin], AC_CACHE_CHECK([if $CC accepts -bundle -undefined error],
[CFLAGS="${CFLAGS_save} -bundle -undefined error" [ac_cv_ld_darwin], [
AC_TRY_COMPILE([],,ac_cv_ld_darwin=yes, ac_cv_ld_darwin=no)]) CFLAGS="${CFLAGS_save} -bundle -undefined error"
if test "${ac_cv_ld_darwin}" != "no"; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
ac_cv_ld_darwin=yes
], [
ac_cv_ld_darwin=no
])
])
AS_IF([test "${ac_cv_ld_darwin}" != "no"], [
VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error]) VLC_ADD_LDFLAGS([plugin],[-bundle -undefined error])
fi ])
])
dnl Checks for __attribute__(aligned()) directive dnl Checks for __attribute__(aligned()) directive
AC_CACHE_CHECK([__attribute__ ((aligned ())) support], AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
...@@ -1570,16 +1648,6 @@ if test "${enable_optimize_memory}" = "yes"; then ...@@ -1570,16 +1648,6 @@ if test "${enable_optimize_memory}" = "yes"; then
AC_DEFINE(OPTIMIZE_MEMORY, 1, Define if you want to optimize memory usage over performance) AC_DEFINE(OPTIMIZE_MEMORY, 1, Define if you want to optimize memory usage over performance)
fi fi
dnl
dnl Enable/disable optimizations
dnl
AC_ARG_ENABLE(optimizations,
[AS_HELP_STRING([--disable-optimizations],
[disable compiler optimizations (default enabled)])])
if test "${enable_optimizations}" != "no"; then
enable_optimizations="speed"
fi
dnl dnl
dnl Allow running as root (useful for people running on embedded platforms) dnl Allow running as root (useful for people running on embedded platforms)
dnl dnl
......
...@@ -92,15 +92,11 @@ AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [ ...@@ -92,15 +92,11 @@ AC_DEFUN([VLC_OUTPUT_VLC_CONFIG_IN], [
rm -f vlc-config.in rm -f vlc-config.in
sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \ sed -ne '/#@1@#/q;p' < "${srcdir}/vlc-config.in.in" \
| sed -e "s/@gprof@/${enable_gprof}/" \ | sed \
-e "s/@cprof@/${enable_cprof}/" \
-e "s/@optim@/${enable_optimizations}/" \ -e "s/@optim@/${enable_optimizations}/" \
-e "s/@debug@/${enable_debug}/" \
-e "s/@PLUGINS@/${PLUGINS}/" \ -e "s/@PLUGINS@/${PLUGINS}/" \
-e "s/@BUILTINS@/${BUILTINS}/" \ -e "s/@BUILTINS@/${BUILTINS}/" \
-e "s/@CFLAGS_TUNING@/${CFLAGS_TUNING}/" \ -e "s/@CFLAGS_TUNING@/${CFLAGS_TUNING}/" \
-e "s/@CFLAGS_OPTIM_SPEED@/${CFLAGS_OPTIM_SPEED}/" \
-e "s/@CFLAGS_OPTIM_NODEBUG@/${CFLAGS_OPTIM_NODEBUG}/" \
> vlc-config.in > vlc-config.in
dnl Switch/case loop dnl Switch/case loop
......
...@@ -5,9 +5,6 @@ exec_prefix="@exec_prefix@" ...@@ -5,9 +5,6 @@ exec_prefix="@exec_prefix@"
exec_prefix_set=no exec_prefix_set=no
datarootdir="@datarootdir@" datarootdir="@datarootdir@"
debug="@debug@"
gprof="@gprof@"
cprof="@cprof@"
optim="@optim@" optim="@optim@"
plugins="@PLUGINS@ " plugins="@PLUGINS@ "
...@@ -21,8 +18,6 @@ ldflags="" ...@@ -21,8 +18,6 @@ ldflags=""
libs="" libs=""
cflags_tuning="@CFLAGS_TUNING@" cflags_tuning="@CFLAGS_TUNING@"
cflags_optim_speed="@CFLAGS_OPTIM_SPEED@"
cflags_optim_nodebug="@CFLAGS_OPTIM_NODEBUG@"
# #
# Do not touch below this place unless you really know what you are doing # Do not touch below this place unless you really know what you are doing
...@@ -84,14 +79,9 @@ cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_REENTRANT -D_THRE ...@@ -84,14 +79,9 @@ cppflags="${cppflags} -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_REENTRANT -D_THRE
# Various additional defines # Various additional defines
# #
if [ "${optim}" = speed ]; then if [ "${optim}" = speed ]; then
cflags="${cflags} ${cflags_optim_speed} ${cflags_tuning}" cflags="${cflags} ${cflags_tuning}"
cxxflags="${cxxflags} ${cflags_optim_speed} ${cflags_tuning}" cxxflags="${cxxflags} ${cflags_tuning}"
objcflags="${objcflags} ${cflags_optim_speed} ${cflags_tuning}" objcflags="${objcflags} ${cflags_tuning}"
if [ "${debug}" != yes -a "${gprof}" != yes -a "${cprof}" != yes ]; then
cflags="${cflags} ${cflags_optim_nodebug}"
cxxflags="${cxxflags} ${cflags_optim_nodebug}"
objcflags="${objcflags} ${cflags_optim_nodebug}"
fi
fi fi
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment