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]
Other format: [Raw text]

Re: Fix -fsection-anchors on Darwin


On Thu, Jun 08, 2006 at 03:44:20PM -0700, Mike Stump wrote:
> Well, given the time and the wrong code gen, I've disabled -fsection- 
> anchors for darwin.  It is safer than doing things like disappearing  
> data on people, which is the direction Geoff wanted to go.  I think we 
> need a new linker feature for multiple entry points to really make this 
> work well, and if not that, then turning off subsections_via_symbols and 
> ensuring that works well.

Mike,
   Could you update your comments on this? Since it seems unlikely
that the linker will ever been changed on darwin to support section-anchors,
it seems to leave on the turning off subsections_via_symbols if we
wanted to implement section-anchors support on darwin, no?

>
> If the optimizer wants to jam all the data together into one object  
> itself, and then write out that object, that would work as well, and  
> there is something appealing about that.  Also, to get nice codegen and 
> dead code stripping, I think we want LTO to manage this issue.

Since it appears that Mach-O LTO will be possible, I assume this can
be handled through that option.
                   Jack

>
> This fixes a regression introduced by:
>
> 2006-04-30  David Edelsohn  <edelsohn@gnu.org>
>
>         * config/rs6000/rs6000.c (rs6000_override_options): Enable
>         TARGET_NO_FP_IN_TOC for section anchors.
>         (optimization_options): Enable section anchors for all
>         non-"Objective" languages.
>

> 2006-06-08  Mike Stump  <mrs@apple.com>
> 
> 	PR target/26427
> 	* config/darwin.c (darwin_asm_output_anchor): Disable
> 	-fsection-anchors on darwin for now.
> 	* config/darwin.h (TARGET_ASM_OUTPUT_ANCHOR): Likewise.
> 	* rs6000/rs6000.c (optimization_options): Likewise.
> 
> 	PR target/26427
> 	* gcc.dg/pr26427.c: Test to ensure that -fsection-anchors doesn't
> 	produce bad code on darwin.
> 
> Doing diffs in .:
> --- ./config/darwin.c.~1~	2006-06-06 05:36:45.000000000 -0700
> +++ ./config/darwin.c	2006-06-08 14:52:31.000000000 -0700
> @@ -1524,6 +1524,8 @@ darwin_binds_local_p (tree decl)
>    return default_binds_local_p_1 (decl, 0);
>  }
>  
> +#if 0
> +/* See TARGET_ASM_OUTPUT_ANCHOR for why we can't do this yet.  */
>  /* The Darwin's implementation of TARGET_ASM_OUTPUT_ANCHOR.  Define the
>     anchor relative to ".", the current section position.  We cannot use
>     the default one because ASM_OUTPUT_DEF is wrong for Darwin.  */
> @@ -1536,6 +1538,7 @@ darwin_asm_output_anchor (rtx symbol)
>    fprintf (asm_out_file, ", . + " HOST_WIDE_INT_PRINT_DEC "\n",
>  	   SYMBOL_REF_BLOCK_OFFSET (symbol));
>  }
> +#endif
>  
>  /* Set the darwin specific attributes on TYPE.  */
>  void
> --- ./config/darwin.h.~1~	2006-06-06 05:36:45.000000000 -0700
> +++ ./config/darwin.h	2006-06-08 14:52:31.000000000 -0700
> @@ -812,8 +812,6 @@ enum machopic_addr_class {
>  	goto DONE;									\
>        }
>  
> -#define TARGET_ASM_OUTPUT_ANCHOR darwin_asm_output_anchor
> -
>  /* Experimentally, putting jump tables in text is faster on SPEC.
>     Also this is needed for correctness for coalesced functions.  */
>  
> @@ -852,6 +850,7 @@ void add_framework_path (char *);
>  #define TARGET_POSIX_IO
>  
>  /* All new versions of Darwin have C99 functions.  */
> +
>  #define TARGET_C99_FUNCTIONS 1
>  
>  #define WINT_TYPE "int"
> @@ -859,7 +858,20 @@ void add_framework_path (char *);
>  /* Every program on darwin links against libSystem which contains the pthread
>     routines, so there's no need to explicitly call out when doing threaded
>     work.  */
> +
>  #undef GOMP_SELF_SPECS
>  #define GOMP_SELF_SPECS ""
>  
> +/* Darwin can't support anchors until we can cope with the adjustments
> +   to size that ASM_DECLARE_OBJECT_NAME and ASM_DECLARE_CONSTANT_NAME
> +   when outputting members of an anchor block and the linker can be
> +   taught to keep them together or we find some other suitable
> +   code-gen technique.  */
> +
> +#if 0
> +#define TARGET_ASM_OUTPUT_ANCHOR darwin_asm_output_anchor
> +#else
> +#define TARGET_ASM_OUTPUT_ANCHOR NULL
> +#endif
> +
>  #endif /* CONFIG_DARWIN_H */
> --- ./config/rs6000/rs6000.c.~1~	2006-06-06 05:36:45.000000000 -0700
> +++ ./config/rs6000/rs6000.c	2006-06-08 14:52:31.000000000 -0700
> @@ -1633,7 +1633,7 @@ optimization_options (int level ATTRIBUT
>    /* Enable section anchors by default.
>       Skip section anchors for Objective C and Objective C++
>       until front-ends fixed.  */
> -  if (lang_hooks.name[4] != 'O')
> +  if (!TARGET_MACHO && lang_hooks.name[4] != 'O')
>      flag_section_anchors = 1;
>  }
>  
> --- ./testsuite/gcc.dg/pr26427.c.~1~	2006-06-08 14:52:31.000000000 -0700
> +++ ./testsuite/gcc.dg/pr26427.c	2006-06-08 14:54:07.000000000 -0700
> @@ -0,0 +1,24 @@
> +/* { dg-warning "this target does not support" } */
> +/* { dg-do run { target { *-*-darwin* } } } */
> +/* { dg-options { -fsection-anchors -O } } */
> +/* PR target/26427 */
> +
> +struct a {};
> +static const int d = 1;
> +static const struct a b = {};
> +static const int c = 1;
> +int f(const int *, const struct a *, const int*, const int*);
> +
> +int g(void) {
> +  return f(&c, &b, &d, &c);
> +}
> +
> +int f(const int *b, const struct a *c, const int *d, const int *e) {
> +  return *b == *d;
> +}
> +
> +int main(void) {
> +  if (!g())
> +    __builtin_abort();
> +  return 0;
> +}
> --------------



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