Bug 7001

Summary: Inconsistent use of #if XXX vs. #ifdef XXX
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Juro Bystricky <juro.bystricky>
Component: coreAssignee: Juro Bystricky <juro.bystricky>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: meta.mr.watcher, meta.watcher
Version: unspecified   
Target Milestone: 1.7.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Juro Bystricky 2014-11-26 19:30:37 UTC
eglibc-use-option-groups.patch contains "#if __OPTION_EGLIBC_BIG_MACROS" in several files. This will generate a compiler warning such as:

../sysdeps/nptl/bits/libc-lock.h:98:6: warning: "__OPTION_EGLIBC_BIG_MACROS" is not defined [-Wundef]
 # if __OPTION_EGLIBC_BIG_MACROS != 1
      ^

The warning is issued in spite of <gnu/option-groups.h> being included. 
This is currently a compiler warning, but glibc warnings are planned to be treated as errors in the future.

This is only evident in case where __OPTION_EGLIBC_BIG_MACROS is not defined 
in <gnu/option-groups.h>, for example poky-tiny.

The fix would be to use #ifdef (#ifndef) __OPTION_EGLIBC_BIG_MACROS instead of
#if  __OPTION_EGLIBC_BIG_MACROS. In this case, we would also need to (manually) make sure that the file <gnu/option-groups> is included.

Alternatively, the file <gnu/option-groups.h> could contain

#define __OPTION_EGLIBC_BIG_MACROS 0

instead of simply not defining __OPTION_EGLIBC_BIG_MACROS at all.
The advantage would be that we don't have to check (manually) for the file <gnu/option-groups.h> being included, we would get the above warning again if not.
Comment 1 Juro Bystricky 2014-11-27 18:48:45 UTC
I submitted a patch to openembedded-core@lists.openembedded.org.

The fix consists of modified option-groups.h generation, where now
each option is defined as 1 if enabled or 0 otherwise. This fixes warnings for all disabled options, not just _OPTION_EGLIBC_BIG_MACROS reported in this bug report.

With this change we cannot use #ifdef __OPTION_XXX anymore, instead we 
have to use #if _OPTION_XXX. In most cases #if _OPTION_XXX was already used
(and hence generated the compiler warnings), so only a few #ifdefs had
to be converted into #ifs.

After this fix if we see a warning "OPTION_XXX" is not defined, it truly
means an error. The previous behaviour was not deterministic (either the 
option was not defined because it was not enabled or the file option-groups.h
was not included)
Comment 2 Juro Bystricky 2014-12-10 16:10:18 UTC
Patched merged SHA1 ID: 9fc63c57a82661a65ace3ebccdb535fe33de70f5