summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-07-31 10:22:15 -0400
committerJeffrey Walton <noloader@gmail.com>2015-07-31 10:22:15 -0400
commitb1085b7384d91fb81e4e66e3bcd57f5900d83984 (patch)
tree2b99d612acfee2da7b09fd41b9d92c861b0ec8b4
parent5f2c32af37152da7607c25df82b392597d05a3c9 (diff)
downloadcryptopp-git-b1085b7384d91fb81e4e66e3bcd57f5900d83984.tar.gz
Changed Cygwin to use -O2 instead of -O3 with GCC 4.9 due to crash
-rw-r--r--GNUmakefile15
-rw-r--r--smartptr.h6
2 files changed, 19 insertions, 2 deletions
diff --git a/GNUmakefile b/GNUmakefile
index b403bb12..58aaf0cd 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -50,9 +50,14 @@ endif
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(ICC\)")
SUN_COMPILER = $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun")
+GCC_COMPILER = $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "^gcc version")
+ifneq ($(GCC_COMPILER),0)
IS_GCC_41 = $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "^gcc version 4\.1\.")
IS_GCC_42 = $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "^gcc version 4\.2\.")
+IS_GCC_45 = $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "^gcc version 4\.5\.")
+IS_GCC_49 = $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "^gcc version 4\.9\.")
+endif
# Also see LLVM Bug 24200 (https://llvm.org/bugs/show_bug.cgi?id=24200)
# CLANG_ASSEMBLER ?= $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -i -c "^clang")
@@ -198,13 +203,19 @@ CXXFLAGS := $(subst -fPIC,,$(CXXFLAGS))
endif # -fPIC
# -O3 fails to link with GCC 4.5.3
-IS_GCC45 = $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "^gcc version 4\.5\.[0-9]")
-ifneq ($(IS_GCC45),0)
+ifneq ($(IS_GCC_45),0)
ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
CXXFLAGS := $(subst -O3,-O2,$(CXXFLAGS))
endif # -O3
endif # GCC 4.5
+# -O3 crash in MQV validation with GCC 4.9.3
+ifneq ($(IS_GCC_49),0)
+ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
+CXXFLAGS := $(subst -O3,-O2,$(CXXFLAGS))
+endif # -O3
+endif # GCC 4.9
+
endif # Cygwin work arounds
#########################
diff --git a/smartptr.h b/smartptr.h
index 82937333..057f5213 100644
--- a/smartptr.h
+++ b/smartptr.h
@@ -79,6 +79,12 @@ public:
T *old_p = m_p;
m_p = 0;
return old_p;
+
+#ifdef __GNUC__
+ // From Andrew Haley (GCC Dev), to tame the optimizer so the assignment is always performed.
+ // See "Disable optimizations in one function" on the GCC mailing list.
+ asm volatile ("" : : : "memory");
+#endif
}
void reset(T *p = 0);