]> git.pond.sub.org Git - empserver/commitdiff
configure: Use -fno-strict-aliasing -fno-strict-overflow
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 18 Oct 2015 15:48:15 +0000 (17:48 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 5 Dec 2015 12:19:38 +0000 (13:19 +0100)
Contemporary compilers can squeeze out some extra performance by
assuming the program never executes code that has undefined behavior
according to the C standard.  Unfortunately, this can break programs.
Pointing out that these programs are non-conforming is as correct as
it is unhelpful, at least as long as the compiler is unable to
diagnose the non-conformingness.

Since keeping our programs working is a lot more important to us than
running them as fast as possible, forbid some assumptions that are
known to break real-world programs:

* Aliasing: perfectly clean programs don't engage in type-punning, and
  perfectly conforming programs do it only in full accordance with the
  standard's (subtle!) aliasing rules.  Neither kind of perfection is
  realistic for us, therefore -fno-strict-aliasing.

* Signed integer overflow: perfectly clean programs won't ever do
  signed integer arithmetic that overflows.  This is an imperfect
  program, therefore -fno-strict-overflow.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
configure.ac

index a80a95af70c15c3068715f49264838080dfa35f2..f5dd1b5855c5bcb644ca20486f62b3e05a7ec0de 100644 (file)
@@ -114,6 +114,32 @@ MY_APPEND_COMPILE_FLAGS([-fno-builtin-carg -Wno-incompatible-library-redeclarati
 # No multiple definitions of uninitialized global variables
 MY_APPEND_COMPILE_FLAGS([-fno-common])
 
+# Reign in overzealous optimizers
+#
+# Contemporary compilers can squeeze out some extra performance by
+# assuming the program never executes code that has undefined behavior
+# according to the C standard.  Unfortunately, this can break
+# programs.  Pointing out that these programs are non-conforming is as
+# correct as it is unhelpful, at least as long as the compiler is
+# unable to diagnose the non-conformingness.
+#
+# Since keeping our programs working is a lot more important to us
+# than running them as fast as possible, forbid some assumptions that
+# are known to break real-world programs:
+#
+# * Aliasing: perfectly clean programs don't engage in type-punning,
+#   and perfectly conforming programs do it only in full accordance
+#   with the standard's (subtle!) aliasing rules.  Neither kind of
+#   perfection is realistic for us, therefore -fno-strict-aliasing.
+#
+# * Signed integer overflow: perfectly clean programs won't ever do
+#   signed integer arithmetic that overflows.  This is an imperfect
+#   program, therefore -fno-strict-overflow.
+#
+MY_APPEND_COMPILE_FLAGS([dnl
+-fno-strict-aliasing dnl
+-fno-strict-overflow])
+
 
 ### Checks for library functions