As discussed in:

http://gcc.gnu.org/ml/gcc-patches/2011-11/msg00927.html

This puts "flag_next_runtime" into the global options structure

-- hopefully this will pave the way for extracting the information from objects when doing LTO and making sure that it is (a) consistent - and (b) that the correct values are set for the backend - - this does affect Darwin where the ObjC meta-data are put into different sections depending on the choice of runtime - thus it would be good to be able to verify things when doing LTO.

--

In order to do this I had to address a number of bits & pieces to do with dependencies on the flag when setting other defaults.

Essentially we have:

  *  runtime (gnu/next)
  *  abi-version
  *  exceptions model.

which must be consistent - the determination of this has been moved to ObjC init

---

I am probably missing something
- but there doesn't seem to be a ready way to set the Init() value of a flag depending on the target - the flag_next_runtime value is used on Darwin very early during building the includes lists - which happens before the options_override is called () so it would be nice to be able to do that (although I've worked around it for now).

---

I needed to deal with '-fobjc-sjlj-exceptions' and elected to remove it - - this is because there is only one valid exception model for each permutation of runtime and ABI - thus the User flag is just clutter.

It is now ignored as a User flag - and the relevant selection actions are all local to Objective C.

(yay! got rid of one exceptions-related flag :-)) ....

---

tested on i686-darwin9 (Objective-C and Objective-C++) with :

-m32/-fobjc-abi-version=0,-m32/-fobjc-abi-version=1,-m64

which exercises both GNU and NeXT runtimes for all current ABIs.

no regressions,

OK for trunk?
Iain


gcc:

        * flags.h (flag_next_runtime): Remove.
        * toplev.c (flag_next_runtime): Remove.
        * config/darwin-c.c (darwin_register_objc_includes): Check if the
        GNU runtime is explicitly selected.
        * config/darwin.c (darwin_override_options): Set defaults for
        Objective C runtime and ABI dependent on the target.  Check for
        incompatible ABI/target pairs.
        * config/darwin.h (SUBTARGET_C_COMMON_OVERRIDE_OPTIONS):
        Remove Objective-C flags checks.

gcc/c-family:

        * c.opt (fgnu-runtime) Fill in information required to generate.
        (fnext-runtime): Likewise.
        (fobjc-sjlj-exceptions): Ignore and warn that it has no effect.
        * c-opts.c (c_common_handle_option): Remove references to
        Objective-C runtime flags.
        (c_common_post_options): Remove Objective-C code adjusting
        Objective-C exceptions models.

gcc/objc:

        * objc-next-runtime-abi-01.c (objc_next_runtime_abi_01_init):
        Handle checking and setting the exception model.
        * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Likewise.
        * objc-gnu-runtime-abi-01.c (objc_gnu_runtime_abi_01_init): Likewise.
        * objc-act.h (flag_objc_sjlj_exceptions): Declare.
        * objc-act.c (flag_objc_sjlj_exceptions): Define default.

Index: gcc/flags.h
===================================================================
--- gcc/flags.h (revision 181206)
+++ gcc/flags.h (working copy)
@@ -56,10 +56,6 @@ extern bool final_insns_dump_p;
 /* Nonzero means make permerror produce warnings instead of errors.  */
 
 extern int flag_permissive;
-
-/* Generate code for GNU or NeXT Objective-C runtime environment.  */
-
-extern int flag_next_runtime;
 
 /* Other basic status info about current function.  */
 
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt  (revision 181206)
+++ gcc/c-family/c.opt  (working copy)
@@ -810,7 +810,7 @@ C++ ObjC++ Var(flag_no_gnu_keywords, 0)
 Recognize GNU-defined keywords
 
 fgnu-runtime
-ObjC ObjC++
+ObjC ObjC++ Report RejectNegative Var(flag_next_runtime,0)
 Generate code for GNU runtime environment
 
 fgnu89-inline
@@ -872,7 +872,7 @@ fnew-abi
 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
 
 fnext-runtime
-ObjC ObjC++
+ObjC ObjC++ Report RejectNegative Var(flag_next_runtime)
 Generate code for NeXT (Apple Mac OS X) runtime environment
 
 fnil-receivers
@@ -919,8 +919,8 @@ Enable inline checks for nil receivers with the Ne
 
 ; Nonzero means that we generate NeXT setjmp based exceptions.
 fobjc-sjlj-exceptions
-ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)
-Enable Objective-C setjmp exception handling runtime
+ObjC ObjC++ Ignore Warn(switch %qs has been removed and is set automaticaly 
where required)
+Option removed
 
 fobjc-std=objc1
 ObjC ObjC++ Var(flag_objc1_only)
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c       (revision 181206)
+++ gcc/c-family/c-opts.c       (working copy)
@@ -604,14 +604,6 @@ c_common_handle_option (size_t scode, const char *
       cpp_opts->extended_identifiers = value;
       break;
 
-    case OPT_fgnu_runtime:
-      flag_next_runtime = !value;
-      break;
-
-    case OPT_fnext_runtime:
-      flag_next_runtime = value;
-      break;
-
     case OPT_foperator_names:
       cpp_opts->operator_names = value;
       break;
@@ -902,12 +894,6 @@ c_common_post_options (const char **pfilename)
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
 
-  /* Default to ObjC sjlj exception handling if NeXT runtime.  */
-  if (flag_objc_sjlj_exceptions < 0)
-    flag_objc_sjlj_exceptions = flag_next_runtime;
-  if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
-    flag_exceptions = 1;
-
   /* -Wextra implies the following flags
      unless explicitly overridden.  */
   if (warn_type_limits == -1)
Index: gcc/objc/objc-next-runtime-abi-01.c
===================================================================
--- gcc/objc/objc-next-runtime-abi-01.c (revision 181206)
+++ gcc/objc/objc-next-runtime-abi-01.c (working copy)
@@ -145,14 +145,19 @@ static tree finish_try_stmt (struct objc_try_conte
 bool
 objc_next_runtime_abi_01_init (objc_runtime_hooks *rthooks)
 {
-  if (flag_objc_exceptions
-      && !flag_objc_sjlj_exceptions)
-    {
-      warning_at (UNKNOWN_LOCATION, OPT_Wall,
-               "%<-fobjc-sjlj-exceptions%> is the only supported exceptions "
-               "system for %<-fnext-runtime%> with %<-fobjc-abi-version%> < 
2");
-    }
 
+  /* flag_objc_sjlj_exceptions has been removed as a User option.  For now,
+     we'll simply force this on - since, for the foreseeable future the only
+     supported exceptions scheme for NeXT V0/1 is SjLj.  It's always on, for
+     NeXT ABI 0 and 1.  */
+
+  flag_objc_sjlj_exceptions = true;
+
+  if (flag_objc_exceptions)
+    /* ??? Should we warn that this is incompatible, if the user has set it.
+       For now, just force it it off.  */
+    flag_exceptions = 0;
+
   rthooks->initialize = next_runtime_01_initialize;
   rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME;
   rthooks->tag_getclass = TAG_GETCLASS;
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 181206)
+++ gcc/objc/objc-act.c (working copy)
@@ -267,6 +267,11 @@ FILE *gen_declaration_file;
 /* Hooks for stuff that differs between runtimes.  */
 objc_runtime_hooks runtime;
 
+/* We've removed the SjLj switch, but there is still one case where the
+   code generated here needs to account for it.  */
+
+bool flag_objc_sjlj_exceptions = false;
+
 /* Create a temporary variable of type 'type'.  If 'name' is set, uses
    the specified name, else use no name.  Returns the declaration of
    the type.  The 'name' is mostly useful for debugging.
Index: gcc/objc/objc-next-runtime-abi-02.c
===================================================================
--- gcc/objc/objc-next-runtime-abi-02.c (revision 181206)
+++ gcc/objc/objc-next-runtime-abi-02.c (working copy)
@@ -239,11 +239,17 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks
 {
   extern_names = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE);
 
-  if (flag_objc_exceptions && flag_objc_sjlj_exceptions)
+  if (flag_objc_exceptions)
     {
-      inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for "
-                               "%<-fnext-runtime%> when %<-fobjc-abi-version%> 
>= 2");
-      flag_objc_sjlj_exceptions = 0;
+      /* If the User has not specified fexceptions, set it silently.  */
+      if (!global_options_set.x_flag_exceptions)
+       flag_exceptions = 1;
+      else if (!flag_exceptions)
+        /* If the User has explicitly specified -fno-exceptions together
+           with -fobjc-exceptions, this is an error.  */
+        error_at (UNKNOWN_LOCATION, "%<-fobjc-exceptions%> requires"
+                                   "%<-fexceptions%> for the 64 bit NeXT"
+                                   " runtime");
     }
 
   rthooks->initialize = next_runtime_02_initialize;
Index: gcc/objc/objc-act.h
===================================================================
--- gcc/objc/objc-act.h (revision 181206)
+++ gcc/objc/objc-act.h (working copy)
@@ -689,6 +689,11 @@ struct objc_try_context
   tree rethrow_decl;
 };
 
+/* We've removed the SjLj switch, but there is still one case where the
+   code generated in objc-act.c needs to account for it.  */
+
+extern bool flag_objc_sjlj_exceptions;
+
 /*  A small number of routines used by the FE parser and the runtime code
    generators.  Put here as inlines for efficiency in non-lto builds rather
    than making them externs.  */
Index: gcc/objc/objc-gnu-runtime-abi-01.c
===================================================================
--- gcc/objc/objc-gnu-runtime-abi-01.c  (revision 181206)
+++ gcc/objc/objc-gnu-runtime-abi-01.c  (working copy)
@@ -132,12 +132,17 @@ objc_gnu_runtime_abi_01_init (objc_runtime_hooks *
       flag_objc_gc = 0;
     }
 
-  /* Although I guess we could, we don't currently support SJLJ exceptions for 
the
-     GNU runtime.  */
-  if (flag_objc_sjlj_exceptions)
+  /* Objective C exceptions implies -fexceptions for the GNU Runtime.  */
+  if (flag_objc_exceptions)
     {
-      inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for 
%<-fgnu-runtime%>");
-      flag_objc_sjlj_exceptions = 0;
+      /* If the User has not specified fexceptions, set it silently.  */
+      if (!global_options_set.x_flag_exceptions)
+       flag_exceptions = 1;
+      else if (!flag_exceptions)
+        /* If the User has explicitly specified -fno-exceptions together
+           with -fobjc-exceptions, this is an error.  */
+        error_at (UNKNOWN_LOCATION, "%<-fobjc-exceptions%> requires"
+                                   "%<-fexceptions%> for the GNU runtime");
     }
 
   /* TODO: Complain if -fobjc-abi-version=N was used.  */
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c        (revision 181206)
+++ gcc/toplev.c        (working copy)
@@ -146,14 +146,6 @@ HOST_WIDE_INT random_seed;
 
 /* -f flags.  */
 
-/* Generate code for GNU or NeXT Objective-C runtime environment.  */
-
-#ifdef NEXT_OBJC_RUNTIME
-int flag_next_runtime = 1;
-#else
-int flag_next_runtime = 0;
-#endif
-
 /* Nonzero means make permerror produce warnings instead of errors.  */
 
 int flag_permissive = 0;
Index: gcc/config/darwin-c.c
===================================================================
--- gcc/config/darwin-c.c       (revision 181206)
+++ gcc/config/darwin-c.c       (working copy)
@@ -478,9 +478,12 @@ darwin_register_objc_includes (const char *sysroot
   fname = GCC_INCLUDE_DIR "-gnu-runtime";
 
   /* Register the GNU OBJC runtime include path if we are compiling  OBJC
-    with GNU-runtime.  */
+    with GNU-runtime.  We 'know' that the default is NeXT, since we're 
+    targetting Darwin.  However, the flag overrides have not be called yet.  */
 
-  if (c_dialect_objc () && !flag_next_runtime)
+  if (c_dialect_objc () 
+      && global_options_set.x_flag_next_runtime
+      && !flag_next_runtime)
     {
       char *str;
       /* See if our directory starts with the standard prefix.
Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c (revision 181206)
+++ gcc/config/darwin.c (working copy)
@@ -2934,6 +2937,36 @@ darwin_override_options (void)
       /* Earlier versions are not specifically accounted, until required.  */
     }
 
+  /* In principle, this should be c-family only.  However, we really need to
+     set sensible defaults for LTO as well, since the section selection stuff
+     should check for correctness re. the ABI.  TODO: check and provide the
+     flags (runtime & ABI) from the lto wrapper).  */
+
+  if (!global_options_set.x_flag_next_runtime)
+    flag_next_runtime = 1;
+
+  /* Unless set, force ABI=2 for NeXT and m64, 0 otherwise.  */
+  if (!global_options_set.x_flag_objc_abi)
+    global_options.x_flag_objc_abi
+       = (!flag_next_runtime)
+               ? 0
+               : (TARGET_64BIT ? 2
+                               : (generating_for_darwin_version >= 9) ? 1
+                                                                      : 0);
+
+  /* Objective-C family ABI 2 is only valid for next/m64 at present.  */
+  if (global_options_set.x_flag_objc_abi && flag_next_runtime)
+    {
+      if (TARGET_64BIT && global_options.x_flag_objc_abi < 2)
+       error_at (UNKNOWN_LOCATION, "%<-fobjc-abi-version%> >= 2 must be"
+                                   " used for %<-m64%> targets with"
+                                   " %<-fnext-runtime%>");
+      if (!TARGET_64BIT && global_options.x_flag_objc_abi >= 2)
+       error_at (UNKNOWN_LOCATION, "%<-fobjc-abi-version%> >= 2 is not"
+                                   " supported on %<-m32%> targets with"
+                                   " %<-fnext-runtime%>");
+    }
+
   /* Don't emit DWARF3/4 unless specifically selected.  This is a 
      workaround for tool bugs.  */
   if (!global_options_set.x_dwarf_strict) 
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h (revision 181206)
+++ gcc/config/darwin.h (working copy)
@@ -140,21 +140,6 @@ extern GTY(()) int darwin_ms_struct;
   } while (0)
 
 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do {                        \
-  /* Unless set, force ABI=2 for NeXT and m64, 0 otherwise.  */                
\
-  if (!global_options_set.x_flag_objc_abi)                             \
-    global_options.x_flag_objc_abi                                     \
-       = (flag_next_runtime && TARGET_64BIT) ? 2 : 0;                  \
-  /* Objective-C family ABI 2 is only valid for next/m64 at present. */        
\
-  if (global_options_set.x_flag_objc_abi && flag_next_runtime)         \
-    if (TARGET_64BIT && global_options.x_flag_objc_abi < 2)            \
-      error_at (UNKNOWN_LOCATION, "%<-fobjc-abi-version%> >= 2 is only"        
\
-               " supported on %<-m64%> targets for"                    \
-               " %<-fnext-runtime%>");                                 \
-  /* Sort out ObjC exceptions: If the runtime is NeXT we default to    \
-     sjlj for m32 only.  */                                            \
-  if (!global_options_set.x_flag_objc_sjlj_exceptions)                 \
-    global_options.x_flag_objc_sjlj_exceptions =                       \
-                               flag_next_runtime && !TARGET_64BIT;     \
     if (flag_mkernel || flag_apple_kext)                               \
       {                                                                        
\
        if (flag_use_cxa_atexit == 2)                                   \



Reply via email to