This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Define __GXX_WEAK__



This patch causes the preprocessor to define __GXX_WEAK__ to {0,1}
representing whether G++ can use weak symbols to handle things like
typeinfo, vtables, etc.

This patch allows the run-time library to be compiled correctly on
systems like AIX that do not support weak symbols.

Run-time and compiler patches coming next.

Tested on i686-pc-linux-gnu.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Index: gcc/cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.145
diff -c -p -r1.145 cppinit.c
*** cppinit.c	2001/02/03 20:48:32	1.145
--- cppinit.c	2001/02/04 08:24:29
*************** struct builtin
*** 643,648 ****
--- 643,649 ----
  #define OPERATOR  	0x10
  
  #define B(n, t)       { U n, 0, t, 0, BUILTIN, sizeof n - 1 }
+ #define BC(n, t)      { U n, 0, t, 0, BUILTIN | CPLUS, sizeof n - 1 }
  #define C(n, v)       { U n, v, 0, 0, 0, sizeof n - 1 }
  #define X(n, f)       { U n, 0, 0, 0, f, sizeof n - 1 }
  #define O(n, c, f)    { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 }
*************** static const struct builtin builtin_arra
*** 655,660 ****
--- 656,662 ----
    B("__LINE__",		 BT_SPECLINE),
    B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
    B("__STDC__",		 BT_STDC),
+   BC("__GXX_WEAK__",     BT_WEAK),
  
    X("__VERSION__",		VERS),
    X("__USER_LABEL_PREFIX__",	ULP),
Index: gcc/cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.162
diff -c -p -r1.162 cpplib.h
*** cpplib.h	2001/01/28 11:22:23	1.162
--- cpplib.h	2001/02/04 08:24:30
*************** enum builtin_type
*** 462,468 ****
    BT_BASE_FILE,			/* `__BASE_FILE__' */
    BT_INCLUDE_LEVEL,		/* `__INCLUDE_LEVEL__' */
    BT_TIME,			/* `__TIME__' */
!   BT_STDC			/* `__STDC__' */
  };
  
  /* There is a slot in the hashnode for use by front ends when integrated
--- 462,470 ----
    BT_BASE_FILE,			/* `__BASE_FILE__' */
    BT_INCLUDE_LEVEL,		/* `__INCLUDE_LEVEL__' */
    BT_TIME,			/* `__TIME__' */
!   BT_STDC,			/* `__STDC__' */
!   BT_WEAK                       /* Whether or not G++ supports weak 
! 				   symbols.  */
  };
  
  /* There is a slot in the hashnode for use by front ends when integrated
Index: gcc/cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.42
diff -c -p -r1.42 cppmacro.c
*** cppmacro.c	2001/02/01 19:13:53	1.42
--- cppmacro.c	2001/02/04 08:24:31
*************** builtin_macro (pfile, token)
*** 214,219 ****
--- 215,224 ----
  		   tb->tm_hour, tb->tm_min, tb->tm_sec);
  	}
        *token = node->value.builtin == BT_DATE ? pfile->date: pfile->time;
+       break;
+ 
+     case BT_WEAK:
+       make_number_token (pfile, token, SUPPORTS_ONE_ONLY);
        break;
  
      default:
Index: gcc/defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.29
diff -c -p -r1.29 defaults.h
*** defaults.h	2001/01/23 22:29:30	1.29
--- defaults.h	2001/02/04 08:24:31
*************** do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNA
*** 149,154 ****
--- 149,163 ----
  #endif
  #endif
  
+ /* This determines whether or not we support link-once semantics.  */
+ #ifndef SUPPORTS_ONE_ONLY
+ #ifdef MAKE_DECL_ONE_ONLY
+ #define SUPPORTS_ONE_ONLY 1
+ #else
+ #define SUPPORTS_ONE_ONLY 0
+ #endif
+ #endif
+ 
  /* If the target supports weak symbols, define TARGET_ATTRIBUTE_WEAK to
     provide a weak attribute.  Else define it to nothing. 
  
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.160
diff -c -p -r1.160 varasm.c
*** varasm.c	2001/01/28 01:50:07	1.160
--- varasm.c	2001/02/04 08:24:41
*************** assemble_alias (decl, target)
*** 4828,4842 ****
  #endif
  }
  
- /* This determines whether or not we support link-once semantics.  */
- #ifndef SUPPORTS_ONE_ONLY
- #ifdef MAKE_DECL_ONE_ONLY
- #define SUPPORTS_ONE_ONLY 1
- #else
- #define SUPPORTS_ONE_ONLY 0
- #endif
- #endif
- 
  /* Returns 1 if the target configuration supports defining public symbols
     so that one of them will be chosen at link time instead of generating a
     multiply-defined symbol error, whether through the use of weak symbols or
--- 4828,4833 ----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]