[or-cvs] r18351: {tor} When building with GCC, use -fno-strict-aliasing GCC's inter (tor/trunk)

nickm at seul.org nickm at seul.org
Sat Jan 31 07:51:03 UTC 2009


Author: nickm
Date: 2009-01-31 02:51:02 -0500 (Sat, 31 Jan 2009)
New Revision: 18351

Modified:
   tor/trunk/ChangeLog
   tor/trunk/configure.in
Log:
When building with GCC, use -fno-strict-aliasing

GCC's interpretation of the C99 aliasing rules, to be charitable,
creates a dialect of C intended for a better programmers than I am
certain of my ability to be in all times.  I just spent 2 hours
tracking down a platform-hyperspecific libevent bug that turned out to
be because of this, and darned if I ever want to do *that* again.

One of Linus's recent rants will give you a picture of why GCC's
behavior here can lead to fun surprises in your binaries:
http://lwn.net/Articles/316126/

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2009-01-31 04:35:30 UTC (rev 18350)
+++ tor/trunk/ChangeLog	2009-01-31 07:51:02 UTC (rev 18351)
@@ -32,7 +32,12 @@
     - Add a 'getinfo status/clients-seen' controller command, in case
       controllers want to hear clients_seen events but connect late.
 
+  o Build changes
+    - Disable GCC's strict alias optimization by default, to avoid the
+      likelihood of its introducing subtle bugs whenever our code violates
+      the letter of C99's alias rules.
 
+
 Changes in version 0.2.1.11-alpha - 2009-01-20
   o Security fixes:
     - Fix a heap-corruption bug that may be remotely triggerable on

Modified: tor/trunk/configure.in
===================================================================
--- tor/trunk/configure.in	2009-01-31 04:35:30 UTC (rev 18350)
+++ tor/trunk/configure.in	2009-01-31 07:51:02 UTC (rev 18351)
@@ -754,8 +754,11 @@
 
 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
 # than autoconf's macros like.
-if test "$ac_cv_c_compiler_gnu" = yes; then
+if test "$GCC" = yes; then
   CFLAGS="$CFLAGS -Wall -g -O2"
+  # Disable GCC's strict aliasing checks.  They are an hours-to-debug
+  # accident waiting to happen.
+  CFLAGS="$CFLAGS -fno-strict-aliasing"
 else
   CFLAGS="$CFLAGS -g -O"
   enable_gcc_warnings=no



More information about the tor-commits mailing list