[patch] moving macro definitions to defaults.h

Andrew MacLeod amacleod@redhat.com
Mon Sep 22 16:26:00 GMT 2014


After being reminded of the tm.h issues brought up last november (here:  
https://gcc.gnu.org/ml/gcc-patches/2013-11/msg01731.html ), I started 
looking back into it.

The general summary is the any header file which has a conditional on a  
target macro could be affected by include file reordering... ie,  if a 
header file has
#ifdef BLAH
  <whatever>

and we move the header files around a bit, it wouldn't be immediately 
obvious if the order where changes and BLAH was define later in the 
include structure.  The results for this header files would be different 
because <whatever> would no longer be in the preprocess source, and it 
may take a long time to discover the difference.

Josephs solution was to identify these and instead put a default 
definition in default.h ...  then change all the uses to #if instead.. ie,
#if BLAH

This way we can ensure that the definition has been seen and it will be 
a compile error if not.


I looked at all the target macros listed by Joseph, and decide to start 
with the ones which are used *only* in an "if defined" situation in a .h 
files of some sort.
ie
#ifdef
#ifndef
or #if define()

If this happens in a .c file, then changing the order of .h's shouldn't 
matter. (Unless the .c file is doing something really screwy.  So for 
the moment, ignoring that.)

So looking at only .h files, I found a number of default definitions in 
rtl.h, which this patch moves to defaults.h.  I was going to #error if 
defaults.h wasn't included, but found that to be unnecessary since it 
uses some of those macros and would cause a compile failure anyway if it 
wasn't included. All the other uses of these particular macros use the 
#if model, so no further adjustment is required for them.

This patch bootstraps on x86_64-unknown-linux-gnu, and regressions are 
running.  Assuming no issues show up, OK for mainline?

The remaining macros I will have a closer look at and most will likely 
need the full treatment moving from #ifdef to the #if model.  I plan to 
do these next.  The macros which fit this category for potential header 
trouble (along with their usage count) are:

2  USE_COLLECT2
3  TARGET_TERMINATE_DW2_EH_FRAME_INFO
3  TARGET_HAVE_CTORS_DTORS
3  REGMODE_NATURAL_SIZE
4  CC_STATUS_MDEP_INIT
4  CC_STATUS_MDEP_INIT
4  MODE_BASE_REG_REG_CLASS
4  REGNO_MODE_OK_FOR_REG_BASE_P
5  MODE_BASE_REG_CLASS
5  XCOFF_DEBUGGING_INFO
6  VMS_DEBUGGING_INFO
6  TARGET_ASM_OUTPUT_ANCHOR
6  EH_FRAME_SECTION_NAME
8  MODE_CODE_BASE_REG_CLASS
9  HARD_REGNO_CALLER_SAVE_MODE
9  HARD_REGNO_CALL_PART_CLOBBERED
9  SDB_DEBUGGING_INFO
9  CC_STATUS_MDEP
9  REGNO_MODE_CODE_OK_FOR_BASE_P
10 SECONDARY_RELOAD_CLASS
10 TARGET_VXWORKS_RTP
14 NO_DOT_IN_LABEL
14 REGNO_MODE_OK_FOR_BASE_P
17 STACK_REGS
19 TARGET_ASM_DESTRUCTOR
20 OBJECT_FORMAT_ELF
20 TARGET_ASM_CONSTRUCTOR
24 NO_DOLLAR_IN_LABEL
26 DBX_DEBUGGING_INFO
30 CPLUSPLUS_CPP_SPEC
42 ASM_OUTPUT_DEF




-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtldefs.diff
Type: text/x-patch
Size: 7604 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140922/aef6cced/attachment.bin>


More information about the Gcc-patches mailing list