Summary: | sys-devel/gcc USE=-gcj CFLAGS="-DN?DEBUG" | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Guenther Brunthaler <gb_about_gnu> |
Component: | [OLD] Core system | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
Status: | RESOLVED INVALID | ||
Severity: | minor | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: | Output of emerge --info |
Description
Guenther Brunthaler
2012-02-18 16:30:53 UTC
Created attachment 302395 [details]
Output of emerge --info
(In reply to comment #0) > -DNDEBUG disables assert() code paths, creating faster and smaller executables. Really? I suggest you remove it permanently because the outcome will never be predictable. > > -DNDEBUG disables assert() code paths, creating faster and smaller executables. > > Really? Obviously. Removing executable statements from an program can hardly make it slower or larger. > I suggest you remove it permanently because the outcome will never be > predictable. I have done this already as a workaround. However, the fact that a program exposes different behaviour whether or not NDEBUG is defined must be considered to be a bug. I quote from the ANSI/ISO C Standard 9899-1990, section 7.2: > 7.2 Diagnostics <assert.h> > > The header <assert.h> defines the assert macro and refers to another macro, > > NDEBUG > > which is nor defined by <assert.h>. If NDEBUG is defined as a macro name > at the point in the source file where <assert.h> is included. The assert > macro is defined simply as > > #define assert(ignore) ((void)0) The possibility of compiling a C source file with NDEBUG defined is therefore explicitly documented in the Standard. And, BTW, I have 1800+ Ebuilds installed, all but a hand full of which have been compiled with -DNDEBUG and are working fine. The remaining few, gcc with gcj USE flag included, fail when NDEBUG is defined, most of them because they are using side-effects of assert() which is clearly a bug. But in the case of gjc, it's not even that - the -D option is mismatched; the bug also occurs if a different symbol than NDEBUG is defined. See http://forums.gentoo.org/viewtopic-p-6875340.html?sid=d3f66a2ad9ec5d6e16327d5bb1961e39 for an example. This *is* a bug. Use CPPFLAGS for preprocessor definitions. CPPFLAGS is not a documented item of $ man 5 make.conf There are only CFLAGS and CXXFLAGS listed. Is this a portage documentation bug? I am using sys-apps/portage-2.1.10.44. No, since CPPFLAGS isn't something the average user should be setting. Neither should you, but if you want to do it CPPFLAGS is the place. Confirming: gcc compiles fine with USE=gjc and CPPFLAGS="-DNDEBUG". I likewise detected the undocumented LDFLAGS in the output of "emerge --info", and moved my linker-related flags from CFLAGS there: LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" This also worked fine. Thanks for the instructions! Issue resolved. |