Open
Bug 666609
Opened 13 years ago
Updated 2 years ago
STL headers like <algorithm> and <vector> don't mix well with g++ -c -fno-exceptions and objC++ on 10.5
Categories
(Firefox Build System :: General, defect)
Tracking
(Not tracked)
NEW
People
(Reporter: jrmuizel, Unassigned)
Details
For example: #import <Foundation/Foundation.h> #include <algorithm> void f() { @try { } @catch(NSException *_exn) { } } gives the following errors: reduc.mm:5: error: stray ‘@’ in program reduc.mm:6: error: stray ‘@’ in program
Comment 1•13 years ago
|
||
Odd. I wouldn't think -fno-exceptions would imply -fno-objc-exceptions. If you stick -fobj-exceptions in the CXXFLAGS after -fno-exceptions, does this compile?
Reporter | ||
Comment 2•13 years ago
|
||
(In reply to comment #1) > Odd. I wouldn't think -fno-exceptions would imply -fno-objc-exceptions. If > you stick -fobj-exceptions in the CXXFLAGS after -fno-exceptions, does this > compile? No. Building with: g++ -c -fno-exceptions -fobjc-exceptions reduc.mm gives the error taking out #include <algorithm> fixes it.
Comment 3•13 years ago
|
||
Okay, that's odd. We wrap the STL headers in order to force exceptions off. For GCC, the template is here: http://mxr.mozilla.org/mozilla-central/source/config/gcc-stl-wrapper.template.h Presumably the bug lies in there somewhere, or in one of the headers it includes. You can find the generated version in $objdir/dist/stl_wrappers/algorithm
I don't fully understand ... the error in comment 0 sure sounds like lack of objc exceptions, and the same error in comment 2 sounds like more of same. If you remove the -fno-exceptions from the compile line entirely, what happens? (That might trump -fobjc-exceptions.)
Reporter | ||
Comment 5•13 years ago
|
||
Removing -fno-exceptions fixes the problem.
Reporter | ||
Comment 6•13 years ago
|
||
(In reply to comment #3) > Okay, that's odd. We wrap the STL headers in order to force exceptions off. > For GCC, the template is here: > http://mxr.mozilla.org/mozilla-central/source/config/gcc-stl-wrapper. > template.h > > Presumably the bug lies in there somewhere, or in one of the headers it > includes. You can find the generated version in > $objdir/dist/stl_wrappers/algorithm I was reproducing the problem with out using our wrappers. Perhaps they're not getting picked up?
Reporter | ||
Comment 7•13 years ago
|
||
(In reply to comment #6) > (In reply to comment #3) > > Okay, that's odd. We wrap the STL headers in order to force exceptions off. > > For GCC, the template is here: > > http://mxr.mozilla.org/mozilla-central/source/config/gcc-stl-wrapper. > > template.h > > > > Presumably the bug lies in there somewhere, or in one of the headers it > > includes. You can find the generated version in > > $objdir/dist/stl_wrappers/algorithm I don't have a $objdir/dist/stl_wrappers directory or any files named 'algorithm' in my objdir
For gcc, the wrappers just ensure that (C++) exceptions are off. My guess here would be that <algorithm> and <vector> end up pulling in some objc-specific library code that doesn't honor -fno-(objc)-exceptions.
What do these STL_FLAGS = -I$(DIST)/stl_wrappers WRAP_STL_INCLUDES = 1 MOZ_MSVC_STL_WRAP__Throw= MOZ_MSVC_STL_WRAP__RAISE= say in your $objdir/config/autoconf.mk?
Reporter | ||
Comment 10•13 years ago
|
||
STL_FLAGS = WRAP_STL_INCLUDES = MOZ_MSVC_STL_WRAP__Throw= MOZ_MSVC_STL_WRAP__RAISE= On both 10.5 and 10.6
Summary: STL headers like <algorithm> and <vector> don't mix well with g++ -c -fno-exceptions and objC++ → STL headers like <algorithm> and <vector> don't mix well with g++ -c -fno-exceptions and objC++ on 10.5
Looks like that's due to a gcc bug that was fixed in 4.2, if I read gcc's bugzilla correctly. Thanks apple. That's not good but not The Real Bug.
Comment 12•13 years ago
|
||
Somewhat related: bug 685927.
Reporter | ||
Comment 13•13 years ago
|
||
A reduced test case is #include <exception_defines.h> void f() { @try { } @finally { } } exception_defines redefines 'try' and 'catch' which explains why this goes bad: #ifndef __EXCEPTIONS // Iff -fno-exceptions, transform error handling code to work without it. # define try if (true) # define catch(X) if (false) # define __throw_exception_again #else // Else proceed normally. # define __throw_exception_again throw #endif
Reporter | ||
Comment 14•13 years ago
|
||
adding #define __EXCEPTIONS at the beginning of the file seems to avoid this redefinition.
Reporter | ||
Comment 15•13 years ago
|
||
Alternatively, using #define _EXCEPTION_DEFINES_H might be cleaner
Updated•6 years ago
|
Product: Core → Firefox Build System
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•