aboutsummaryrefslogtreecommitdiff
blob: 669b31722f112086209ad5a51027ae12e19468f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- trunk/c++/src/build-system/configure        2012/12/21 15:12:14     56664
+++ trunk/c++/src/build-system/configure        2012/12/27 15:43:29     56694
@@ -3151,6 +3151,13 @@
  ;;
 esac
 
+# Check for custom optimization flags before potentially going with defaults.
+skip_fast_flags=no
+if test -z "${DEF_FAST_FLAGS}${FAST_CXXFLAGS}"; then
+   case " $CFLAGS $CXXFLAGS" in
+      *\ -O* | *\ -xO* ) skip_fast_flags=yes ;;
+   esac
+fi
 
 #### Always define this
 
@@ -5715,7 +5722,7 @@
 wsrx="[$wschars]"
 
 #### Flags to enable (potentially unsafe) extra optimization.
-if test -z "$DEF_FAST_FLAGS"  -o  -z "$FAST_CXXFLAGS" ; then
+if test "$skip_fast_flags" = no -a -z "$DEF_FAST_FLAGS" ; then
    case "$compiler:$compiler_version" in
       GCC:2* | GCC:344 )
         # GCC 2.9x sometimes experiences internal errors at high optimization;
@@ -5786,8 +5793,6 @@
         DEF_FAST_FLAGS="-O"
         ;;
    esac
-else
-   DEF_FAST_FLAGS="-O"
 fi
 
 : ${FAST_CFLAGS="$DEF_FAST_FLAGS"}
@@ -8936,9 +8941,15 @@
          CXXFLAGS="$CXXFLAGS -O" ; fi
       if echo " $LDFLAGS "  | grep -v "$optrx" >/dev/null ; then
          LDFLAGS="$LDFLAGS -O" ; fi
-      FAST_CFLAGS="$NOPT_CFLAGS $FAST_CFLAGS"
-      FAST_CXXFLAGS="$NOPT_CXXFLAGS $FAST_CXXFLAGS"
-      FAST_LDFLAGS="$NOPT_LDFLAGS $FAST_LDFLAGS"
+      if test "$skip_fast_flags" = yes ; then
+         FAST_CFLAGS="$CFLAGS"
+         FAST_CXXFLAGS="$CXXFLAGS"
+         FAST_LDFLAGS="$LDFLAGS"
+      else
+         FAST_CFLAGS="$NOPT_CFLAGS $FAST_CFLAGS"
+         FAST_CXXFLAGS="$NOPT_CXXFLAGS $FAST_CXXFLAGS"
+         FAST_LDFLAGS="$NOPT_LDFLAGS $FAST_LDFLAGS"
+      fi
    fi
 fi