Closed Bug 413253 Opened 12 years ago Closed 12 years ago

build with -fno-strict-aliasing on GCC platforms

Categories

(Firefox Build System :: General, defect, P1)

x86
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sayrer, Assigned: sayrer)

References

Details

Attachments

(1 file)

msvc has this off by default. We get way too many warnings to ship with this turned on.
Flags: blocking1.9?
This should solve bug 403783 and bug 409881
Where in configure.in should this go?
Version: unspecified → Trunk
If -fno-strict-aliasing works on all versions of GCC, then probably here: http://mxr.mozilla.org/mozilla/source/configure.in#1235

CFLAGS="$CFLAGS -fno-strict-aliasing"

and below in the equivalent C++ block.

If we need to do a configure check, then you'll have to put it below, something like this: http://mxr.mozilla.org/mozilla/source/configure.in#2663
Strict aliasing was a perf win on older GCCs when turned on, IIRC. I remember in JS we did some work to use unions and GCC extensions. Anyone remember or have a bug with data to cite?

Would like to get stricter, cross-platform, for Mozilla 2. Thoughts on how to get there?

/be
-fno-strict-aliasing is available on all the versions of GCC we use.

From the manual's description of -fstrict-aliasing: "Allows the compiler to assume the strictest aliasing rules applicable to the language being compiled. For C (and C++), this activates optimizations based on the type of expressions. In particular, an object of one type is assumed never to reside at the same address as an object of a different type, unless the types are almost the same. For example, an unsigned int can alias an int, but not a void* or a double."

So with -fno-strict-aliasing, the compiler is being more conservative, and possibly losing some optimization opportunities. The right thing for best performance longterm is to clear out all the warnings, so this flag is no longer needed.


Flags: blocking1.9? → blocking1.9+
Priority: -- → P1
If we do change this, we should grep an existing log for this error and attach it to a followup so it can be fixed in the future.  (Maybe via automated rewrite?)
Does "all the versions of GCC we use" include 3.4? We need to keep working with GCC 3.4 for a while yet because elsa doesn't work on newer versions.
Yes, the flag goes back to version 2 at least, maybe even version 1.

Ping on this since b3 freeze comin up!
How about adding the -fno-strict-aliasing flag by default, and providing a configure option to disable adding that for anyone who wants to take a stab at fixing some of them?
Does -fno-strict-aliasing disable the warnings? We could explicitly re-enable them with -Wstrict-aliasing
-fno-strict-aliasing disables the warnings, and makes -Wstrict-aliasing a no-op.
Doesn't -fstrict-aliasing turn it back on?
Sure, I thought what bsmedberg was trying to accomplish was allowing the warnings to be there for people who want to fix them, but still turning off optimizations based on strict aliasing rules, which isn't possible.
Who owns this?  
Got it.
Assignee: nobody → sayrer
Attachment #300084 - Flags: review?(ted.mielczarek)
Comment on attachment 300084 [details] [diff] [review]
add to default gcc flags

Should have an XXX comment with a followup bug, but r=me.
Attachment #300084 - Flags: review?(ted.mielczarek) → review+
Depends on: 414641
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
So, if you'd put the -fno-strict-aliasing first, wouldn't that have allowed people to override it in their mozconfigs if they wanted to?
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.