public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* IMA: rearrange handling of file-scope constructors
@ 2004-07-08  7:49 Zack Weinberg
  2004-07-12 22:04 ` sh-elf broken (Was: IMA: rearrange handling of file-scope constructors) Joern Rennecke
  0 siblings, 1 reply; 3+ messages in thread
From: Zack Weinberg @ 2004-07-08  7:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski, Geoff Keating


The purpose of this patch is to move the creation of the
static-constructor helper functions (for systems without .ctors
sections) and the mudflap initializer routines, from a point where
they're done once per input file, to a point where they're done once
per object file.  This is slightly less necessary than it used to be -
before we had cgraph_build_static_cdtor, once-per-input-file would get
us multiply defined symbol errors; now it's just an inefficiency.
However, an inefficiency it remains, and I think it's good to have the
static-constructor-helper handling all in one file, too.

Contrariwise, we move the call to cgraph_finalize_compilation_unit
from a once-per-object-file location to a once-per-input-file
location, following the recommendation at the top of cgraphunit.c.

The Objective-C front end changes are the minimum necessary to avoid
regressions in 'make check-objc'; objc-act.c badly needs a going over
with a chain saw.

Bootstrapped amd64-linux, for a change, and I also built a cross
compiler to vax-bsd and verified that the static-constructor-helper
logic works.

Andrew: this should be the last patch necessary to make your patch
work.  I'll check this in tomorrow, when I'm not falling asleep, and
then I'll test your patch.

zw

        * c-decl.c (static_ctors, static_dtors): Make static.
        (pop_file_scope): Call c_common_write_pch and
        cgraph_finalize_compilation_unit here.
        (build_cdtor): Moved here from c-objc-common.c; simplify.
        (c_write_global_declarations_1): Clarify comment.
        (c_write_global_declarations): Close the external scope before
        doing anything else.  Call build_cdtor, cgraph_optimize, and
        mudflap_finish_file here.
        * c-lang.c (finish_file): Don't call c_objc_common_finish_file.
        Clarify comment.
        * c-objc-common.c: No need to include cgraph.h.
        (build_cdtor): Moved to c-decl.c.
        (c_objc_common_finish_file): Delete.
        * c-tree.h: Update to match.
        * objc/objc-act.c (finish_file): Don't call c_objc_common_finish_file.
        (generate_static_references): Set TREE_USED before calling finish_decl.
        Eliminate unnecessary dummy declaration.  Call rest_of_decl_compilation
        on the static_instances_decl.

===================================================================
Index: c-decl.c
--- c-decl.c	6 Jul 2004 02:20:05 -0000	1.528
+++ c-decl.c	8 Jul 2004 06:57:39 -0000
@@ -377,7 +377,8 @@ static bool next_is_function_body;
 
 /* Functions called automatically at the beginning and end of execution.  */
 
-tree static_ctors, static_dtors;
+static GTY(()) tree static_ctors;
+static GTY(()) tree static_dtors;
 
 /* Forward declarations.  */
 static tree lookup_name_in_scope (tree, struct c_scope *);
@@ -851,17 +852,19 @@ pop_file_scope (void)
      still works without it.  */
   finish_fname_decls ();
 
-  /* Kludge: don't actually pop the file scope if generating a
-     precompiled header, so that macros and local symbols are still
-     visible to the PCH generator.  */
+  /* This is the point to write out a PCH if we're doing that.
+     In that case we do not want to do anything else.  */
   if (pch_file)
-    return;
+    {
+      c_common_write_pch ();
+      return;
+    }
 
-  /* And pop off the file scope.  */
+  /* Pop off the file scope and close this translation unit.  */
   pop_scope ();
   file_scope = 0;
-
   cpp_undef_all (parse_in);
+  cgraph_finalize_compilation_unit ();
 }
 
 /* Insert BLOCK at the end of the list of subblocks of the current
@@ -6569,7 +6572,26 @@ make_pointer_declarator (tree type_quals
   return build1 (INDIRECT_REF, quals, itarget);
 }
 
-/* Perform final processing on file-scope data.  */
+/* Synthesize a function which calls all the global ctors or global
+   dtors in this file.  This is only used for targets which do not
+   support .ctors/.dtors sections.  FIXME: Migrate into cgraph.  */
+static void
+build_cdtor (int method_type, tree cdtors)
+{
+  tree body = 0;
+
+  if (!cdtors)
+    return;
+
+  for (; cdtors; cdtors = TREE_CHAIN (cdtors))
+    append_to_statement_list (build_function_call (TREE_VALUE (cdtors), 0),
+			      &body);
+
+  cgraph_build_static_cdtor (method_type, body);
+}
+
+/* Perform final processing on one file scope's declarations (or the
+   external scope's declarations), GLOBALS.  */
 static void
 c_write_global_declarations_1 (tree globals)
 {
@@ -6591,20 +6613,38 @@ c_write_global_declarations_1 (tree glob
 void
 c_write_global_declarations (void)
 {
-  tree t;
+  tree ext_block, t;
 
   /* We don't want to do this if generating a PCH.  */
   if (pch_file)
     return;
 
-  /* Process all file scopes in this compilation.  */
+  /* Close the external scope.  */
+  ext_block = pop_scope ();
+  external_scope = 0;
+  if (current_scope)
+    abort ();
+
+  /* Process all file scopes in this compilation, and the external_scope,
+     through wrapup_global_declarations and check_global_declarations.  */
   for (t = all_translation_units; t; t = TREE_CHAIN (t))
     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
+  c_write_global_declarations_1 (BLOCK_VARS (ext_block));
 
-  /* Now do the same for the externals scope.  */
-  t = pop_scope ();
-  if (t)
-    c_write_global_declarations_1 (BLOCK_VARS (t));
+  /* Generate functions to call static constructors and destructors
+     for targets that do not support .ctors/.dtors sections.  These
+     functions have magic names which are detected by collect2.  */
+  build_cdtor ('I', static_ctors); static_ctors = 0;
+  build_cdtor ('D', static_dtors); static_dtors = 0;
+
+  /* We're done parsing; proceed to optimize and emit assembly.
+     FIXME: shouldn't be the front end's responsibility to call this.  */
+  cgraph_optimize ();
+
+  /* Presently this has to happen after cgraph_optimize.
+     FIXME: shouldn't be the front end's responsibility to call this.  */
+  if (flag_mudflap)
+    mudflap_finish_file ();
 }
 
 #include "gt-c-decl.h"
===================================================================
Index: c-lang.c
--- c-lang.c	5 Jul 2004 17:28:33 -0000	1.129
+++ c-lang.c	8 Jul 2004 06:57:39 -0000
@@ -195,10 +195,11 @@ const char *const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
+/* Final processing of file-scope data.  The Objective-C version of
+   this function still does something.  */
 void
 finish_file (void)
 {
-  c_objc_common_finish_file ();
 }
 
 int
===================================================================
Index: c-objc-common.c
--- c-objc-common.c	1 Jul 2004 08:52:25 -0000	1.50
+++ c-objc-common.c	8 Jul 2004 06:57:39 -0000
@@ -38,7 +38,6 @@ Software Foundation, 59 Temple Place - S
 #include "langhooks.h"
 #include "tree-mudflap.h"
 #include "target.h"
-#include "cgraph.h"
 
 static bool c_tree_printer (pretty_printer *, text_info *);
 
@@ -183,50 +182,6 @@ c_objc_common_init (void)
   return true;
 }
 
-/* Synthesize a function which calls all the global ctors or global dtors
-   in this file.  */
-
-static void
-build_cdtor (int method_type, tree cdtors)
-{
-  tree body;
-
-  body = push_stmt_list ();
-
-  for (; cdtors; cdtors = TREE_CHAIN (cdtors))
-    add_stmt (build_function_call (TREE_VALUE (cdtors), NULL_TREE));
-
-  body = pop_stmt_list (body);
-
-  cgraph_build_static_cdtor (method_type, body);
-}
-
-/* Called at end of parsing, but before end-of-file processing.  */
-
-void
-c_objc_common_finish_file (void)
-{
-  if (pch_file)
-    c_common_write_pch ();
-
-  if (static_ctors)
-    {
-      build_cdtor ('I', static_ctors);
-      static_ctors = 0;
-    }
-  if (static_dtors)
-    {
-      build_cdtor ('D', static_dtors);
-      static_dtors = 0;
-    }
-
-  cgraph_finalize_compilation_unit ();
-  cgraph_optimize ();
-
-  if (flag_mudflap)
-    mudflap_finish_file ();
-}
-
 /* Called during diagnostic message formatting process to print a
    source-level entity onto BUFFER.  The meaning of the format specifiers
    is as follows:
===================================================================
Index: c-tree.h
--- c-tree.h	5 Jul 2004 17:28:33 -0000	1.161
+++ c-tree.h	8 Jul 2004 06:57:39 -0000
@@ -197,7 +197,6 @@ extern int c_cannot_inline_tree_fn (tree
 extern bool c_objc_common_init (void);
 extern bool c_missing_noreturn_ok_p (tree);
 extern tree c_objc_common_truthvalue_conversion (tree expr);
-extern void c_objc_common_finish_file (void);
 extern int defer_fn (tree);
 extern bool c_warn_unused_global_decl (tree);
 extern void c_initialize_diagnostics (diagnostic_context *);
@@ -298,9 +297,6 @@ extern void *get_current_scope (void);
 extern void objc_mark_locals_volatile (void *);
 extern void c_write_global_declarations (void);
 
-extern GTY(()) tree static_ctors;
-extern GTY(()) tree static_dtors;
-
 /* In order for the format checking to accept the C frontend
    diagnostic framework extensions, you must include this file before
    toplev.h, not after.  */
===================================================================
Index: objc/objc-act.c
--- objc/objc-act.c	5 Jul 2004 09:35:43 -0000	1.229
+++ objc/objc-act.c	8 Jul 2004 06:57:39 -0000
@@ -519,7 +519,6 @@ void
 finish_file (void)
 {
   mark_referenced_methods ();
-  c_objc_common_finish_file ();
 
   /* Finalize Objective-C runtime data.  No need to generate tables
      and code if only checking syntax.  */
@@ -1959,7 +1958,7 @@ generate_static_references (void)
 {
   tree decls = NULL_TREE, ident, decl_spec, expr_decl, expr = NULL_TREE;
   tree class_name, class, decl, initlist;
-  tree cl_chain, in_chain, type;
+  tree cl_chain, in_chain;
   int num_inst, num_class;
   char buf[256];
 
@@ -1982,6 +1981,7 @@ generate_static_references (void)
       decl = start_decl (expr_decl, decl_spec, 1, NULL_TREE);
       DECL_CONTEXT (decl) = 0;
       DECL_ARTIFICIAL (decl) = 1;
+      TREE_USED (decl) = 1;
 
       /* Output {class_name, ...}.  */
       class = TREE_VALUE (cl_chain);
@@ -2002,12 +2002,6 @@ generate_static_references (void)
 
       expr = objc_build_constructor (TREE_TYPE (decl), nreverse (initlist));
       finish_decl (decl, expr, NULL_TREE);
-      TREE_USED (decl) = 1;
-
-      type = build_array_type (build_pointer_type (void_type_node), 0);
-      decl = build_decl (VAR_DECL, ident, type);
-      TREE_USED (decl) = 1;
-      TREE_STATIC (decl) = 1;
       decls
 	= tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, decl, 1), decls);
     }
@@ -2026,6 +2020,7 @@ generate_static_references (void)
   expr = objc_build_constructor (TREE_TYPE (static_instances_decl),
 			    nreverse (decls));
   finish_decl (static_instances_decl, expr, NULL_TREE);
+  rest_of_decl_compilation (static_instances_decl, 0, 0, 0);
 }
 
 /* Output all strings.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* sh-elf broken (Was: IMA: rearrange handling of file-scope constructors)
  2004-07-08  7:49 IMA: rearrange handling of file-scope constructors Zack Weinberg
@ 2004-07-12 22:04 ` Joern Rennecke
  2004-07-14 13:09   ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: Joern Rennecke @ 2004-07-12 22:04 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: gcc-patches, Andrew Pinski, Geoff Keating

>         * c-decl.c (static_ctors, static_dtors): Make static.
>         (pop_file_scope): Call c_common_write_pch and
>         cgraph_finalize_compilation_unit here.
>         (build_cdtor): Moved here from c-objc-common.c; simplify.
>         (c_write_global_declarations_1): Clarify comment.
>         (c_write_global_declarations): Close the external scope before
>         doing anything else.  Call build_cdtor, cgraph_optimize, and
>         mudflap_finish_file here.
>         * c-lang.c (finish_file): Don't call c_objc_common_finish_file.
>         Clarify comment.
>         * c-objc-common.c: No need to include cgraph.h.
>         (build_cdtor): Moved to c-decl.c.
>         (c_objc_common_finish_file): Delete.
>         * c-tree.h: Update to match.
>         * objc/objc-act.c (finish_file): Don't call c_objc_common_finish_file.
>         (generate_static_references): Set TREE_USED before calling finish_decl.
>         Eliminate unnecessary dummy declaration.  Call rest_of_decl_compilation
>         on the static_instances_decl.

This breaks newlib building on sh-elf and sh64-elf.  Building syscalls.c
fails with this error:
../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c: In function `_sbrk':
../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c:9: error: register name 
not specified for 'stack_ptr'

c_write_global_declarations is called before _sbrk is expanded to rtl,
and causes check_global_declarations to be called, which clears the
decl.rtl for this variable:

register char *stack_ptr asm ("r15");

When _sbrk is eventually compiled, the DECL_RTL macro finds decl.rtl
to be cleared, and calls make_decl_rtl again.  It is still known
then that this is a register variable, but the asmspec is missing.

Following is the preprocessed source file.  It was compiled with
./cc1 -fpreprocessed syscalls.i -quiet -ml -g -O2 -fno-builtin -o syscalls.s ,
although -O2 is sufficient to demonstrate the problem.

# 1 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c"
# 1 "/swbuild/nightly/2004-07-08/sh64-elf/sh64-elf/ml/newlib/libc/sys/sh//"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c"
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/_ansi.h" 1 3 4
# 15 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/_ansi.h" 3 4
# 1 "/swbuild/nightly/2004-07-08/sh64-elf/sh64-elf/ml/newlib/targ-include/newlib.h" 1 3 4
# 16 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/_ansi.h" 2 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/config.h" 1 3 4



# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/machine/ieeefp.h" 1 3 4
# 5 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/config.h" 2 3 4
# 17 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/_ansi.h" 2 3 4
# 2 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c" 2
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 1 3 4
# 24 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 3 4
typedef short int __int16_t;
typedef unsigned short int __uint16_t;





typedef int __int32_t;
typedef unsigned int __uint32_t;






__extension__ typedef long long __int64_t;
__extension__ typedef unsigned long long __uint64_t;






# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/_types.h" 1 3 4
# 12 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/_types.h" 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/lock.h" 1 3 4





typedef int _LOCK_T;
typedef int _LOCK_RECURSIVE_T;
# 13 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/_types.h" 2 3 4

typedef long _off_t;
__extension__ typedef long long _off64_t;


typedef int _ssize_t;





# 1 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 1 3 4
# 355 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 25 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/_types.h" 2 3 4


typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;
} _mbstate_t;

typedef _LOCK_RECURSIVE_T _flock_t;


typedef void *_iconv_t;
# 48 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 2 3 4







# 1 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 1 3 4
# 152 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 3 4
typedef long int ptrdiff_t;
# 214 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 326 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 3 4
typedef int wchar_t;
# 56 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 2 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/machine/types.h" 1 3 4
# 36 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/machine/types.h" 3 4
typedef long int __off_t;
typedef int __pid_t;

__extension__ typedef long long int __loff_t;
# 57 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 2 3 4
# 78 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 3 4
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;



typedef unsigned short ushort;
typedef unsigned int uint;



typedef unsigned long clock_t;




typedef long time_t;




struct timespec {
  time_t tv_sec;
  long tv_nsec;
};

struct itimerspec {
  struct timespec it_interval;
  struct timespec it_value;
};


typedef long daddr_t;
typedef char * caddr_t;
# 121 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 3 4
typedef unsigned short ino_t;
# 155 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 3 4
typedef short dev_t;




typedef long off_t;

typedef unsigned short uid_t;
typedef unsigned short gid_t;


typedef int pid_t;

typedef long key_t;

typedef _ssize_t ssize_t;
# 184 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 3 4
typedef unsigned int mode_t __attribute__ ((__mode__ (__SI__)));




typedef unsigned short nlink_t;
# 211 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/types.h" 3 4
typedef long fd_mask;







typedef struct _types_fd_set {
 fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof (fd_mask) * 8)))];
} _types_fd_set;
# 3 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c" 2
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/stat.h" 1 3 4
# 9 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/stat.h" 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 1 3 4
# 10 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/_ansi.h" 1 3 4
# 11 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 2 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 1 3 4
# 19 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
typedef unsigned long __ULong;
# 40 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
struct _Bigint
{
  struct _Bigint *_next;
  int _k, _maxwds, _sign, _wds;
  __ULong _x[1];
};


struct __tm
{
  int __tm_sec;
  int __tm_min;
  int __tm_hour;
  int __tm_mday;
  int __tm_mon;
  int __tm_year;
  int __tm_wday;
  int __tm_yday;
  int __tm_isdst;
};







struct _on_exit_args {
 void * _fnargs[32];
 __ULong _fntypes;

};
# 80 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
struct _atexit {
 struct _atexit *_next;
 int _ind;
 void (*_fns[32])(void);
        struct _on_exit_args _on_exit_args;
};
# 95 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
struct __sbuf {
 unsigned char *_base;
 int _size;
};






typedef long _fpos_t;
# 160 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
struct __sFILE {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;






  void * _cookie;

  int (*_read) (void * _cookie, char *_buf, int _n);
  int (*_write) (void * _cookie, const char *_buf, int _n);

  _fpos_t (*_seek) (void * _cookie, _fpos_t _offset, int _whence);
  int (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _offset;


  struct _reent *_data;



  _flock_t _lock;

};
# 253 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
typedef struct __sFILE __FILE;


struct _glue
{
  struct _glue *_next;
  int _niobs;
  __FILE *_iobs;
};
# 284 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
struct _rand48 {
  unsigned short _seed[3];
  unsigned short _mult[3];
  unsigned short _add;




};
# 555 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
struct _reent
{
  int _errno;




  __FILE *_stdin, *_stdout, *_stderr;

  int _inc;
  char _emergency[25];

  int _current_category;
  const char *_current_locale;

  int __sdidinit;

  void (*__cleanup) (struct _reent *);


  struct _Bigint *_result;
  int _result_k;
  struct _Bigint *_p5s;
  struct _Bigint **_freelist;


  int _cvtlen;
  char *_cvtbuf;

  union
    {
      struct
        {
          unsigned int _unused_rand;
          char * _strtok_last;
          char _asctime_buf[26];
          struct __tm _localtime_buf;
          int _gamma_signgam;
          __extension__ unsigned long long _rand_next;
          struct _rand48 _r48;
          _mbstate_t _mblen_state;
          _mbstate_t _mbtowc_state;
          _mbstate_t _wctomb_state;
          char _l64a_buf[8];
          char _signal_buf[24];
          int _getdate_err;
          _mbstate_t _mbrlen_state;
          _mbstate_t _mbrtowc_state;
          _mbstate_t _mbsrtowcs_state;
          _mbstate_t _wcrtomb_state;
          _mbstate_t _wcsrtombs_state;
        } _reent;



      struct
        {

          unsigned char * _nextf[30];
          unsigned int _nmalloc[30];
        } _unused;
    } _new;


  struct _atexit *_atexit;
  struct _atexit _atexit0;


  void (**(_sig_func))(int);




  struct _glue __sglue;
  __FILE __sf[3];
};
# 789 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/reent.h" 3 4
extern struct _reent *_impure_ptr ;
extern struct _reent *const _global_impure_ptr ;

void _reclaim_reent (struct _reent *);
# 12 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 2 3 4






# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/machine/time.h" 1 3 4
# 19 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 2 3 4
# 27 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 3 4
# 1 "/swbuild/nightly/2004-07-08/sh64-elf/gcc/include/stddef.h" 1 3 4
# 28 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 2 3 4





struct tm
{
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_wday;
  int tm_yday;
  int tm_isdst;
};

clock_t clock (void);
double difftime (time_t _time2, time_t _time1);
time_t mktime (struct tm *_timeptr);
time_t time (time_t *_timer);

char *asctime (const struct tm *_tblock);
char *ctime (const time_t *_time);
struct tm *gmtime (const time_t *_timer);
struct tm *localtime (const time_t *_timer);

size_t strftime (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t);

char *asctime_r (const struct tm *, char *);
char *ctime_r (const time_t *, char *);
struct tm *gmtime_r (const time_t *, struct tm *);
struct tm *localtime_r (const time_t *, struct tm *);








char *strptime (const char *, const char *, struct tm *);
void tzset (void);
void _tzset_r (struct _reent *);
# 98 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 3 4
extern time_t _timezone;
extern int _daylight;
extern char *_tzname[2];
# 126 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 3 4
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/features.h" 1 3 4
# 127 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/time.h" 2 3 4
# 10 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/stat.h" 2 3 4
# 25 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/stat.h" 3 4
struct stat
{
  dev_t st_dev;
  ino_t st_ino;
  mode_t st_mode;
  nlink_t st_nlink;
  uid_t st_uid;
  gid_t st_gid;
  dev_t st_rdev;
  off_t st_size;






  time_t st_atime;
  long st_spare1;
  time_t st_mtime;
  long st_spare2;
  time_t st_ctime;
  long st_spare3;
  long st_blksize;
  long st_blocks;
  long st_spare4[2];

};
# 119 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/stat.h" 3 4
int chmod ( const char *__path, mode_t __mode );
int fchmod (int __fd, mode_t __mode);
int fstat ( int __fd, struct stat *__sbuf );
int mkdir ( const char *_path, mode_t __mode );
int mkfifo ( const char *__path, mode_t __mode );
int stat ( const char *__path, struct stat *__sbuf );
mode_t umask ( mode_t __mask );
# 4 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c" 2
# 1 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/time.h" 1 3 4
# 16 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/time.h" 3 4
struct timeval {
  long tv_sec;
  long tv_usec;
};

struct timezone {
  int tz_minuteswest;
  int tz_dsttime;
};
# 36 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/time.h" 3 4
struct itimerval {
  struct timeval it_interval;
  struct timeval it_value;
};
# 73 "/swbuild/nightly/2004-07-08/srcw/newlib/libc/include/sys/time.h" 3 4
int gettimeofday (struct timeval *__p, struct timezone *__z);
int settimeofday (const struct timeval *, const struct timezone *);
int utimes (const char *__path, struct timeval *__tvp);
int getitimer (int __which, struct itimerval *__value);
int setitimer (int __which, const struct itimerval *__value, struct itimerval *__ovalue);
# 5 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c" 2
# 1 "../../../../../../../srcw/newlib/libc/sys/sh/sys/syscall.h" 1
# 6 "../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c" 2
int errno;


register char *stack_ptr asm ("r15");

int
_read (int file,
       char *ptr,
       int len)
{
  return __trap34 (3, file, ptr, len);
}

int
_lseek (int file,
 int ptr,
 int dir)
{
  return __trap34 (19, file, ptr, dir);
}

int
_write ( int file,
  char *ptr,
  int len)
{
  return __trap34 (4, file, ptr, len);
}

int
_close (int file)
{
  return __trap34 (6, file, 0, 0);
}

int
_link (char *old, char *new)
{
  return -1;
}

caddr_t
_sbrk (int incr)
{
  extern char end;
  static char *heap_end;
  char *prev_heap_end;

  if (heap_end == 0)
    {
      heap_end = &end;
    }
  prev_heap_end = heap_end;
  if (heap_end + incr > stack_ptr)
    {
      _write (1, "Heap and stack collision\n", 25);
      abort ();
    }
  heap_end += incr;
  return (caddr_t) prev_heap_end;
}

int
_fstat (int file,
 struct stat *st)
{
  st->st_mode = 0020000;
  return 0;
}

int
_open (const char *path,
 int flags)
{
  return __trap34 (5, path, flags, 0);
}

int
_creat (const char *path,
 int mode)
{
  return __trap34 (8, path, mode, 0);
}

int
_unlink ()
{
  return -1;
}

isatty (fd)
     int fd;
{
  return 1;
}

_exit (n)
{
  return __trap34 (1, n, 0, 0);
}

_kill (n, m)
{
  return __trap34 (1, 0xdead, 0, 0);
}

_getpid (n)
{
  return 1;
}

_raise ()
{
}

int
_stat (const char *path, struct stat *st)

{
  return __trap34 (38, path, st, 0);
}

int
_chmod (const char *path, short mode)
{
  return __trap34 (15, path, mode);
}

int
_chown (const char *path, short owner, short group)
{
  return __trap34 (16, path, owner, group);
}

int
_utime (path, times)
     const char *path;
     char *times;
{
  return __trap34 (201, path, times);
}

int
_fork ()
{
  return __trap34 (2);
}

int
_wait (statusp)
     int *statusp;
{
  return __trap34 (202);
}

int
_execve (const char *path, char *const argv[], char *const envp[])
{
  return __trap34 (59, path, argv, envp);
}

int
_execv (const char *path, char *const argv[])
{
  return __trap34 (11, path, argv);
}

int
_pipe (int *fd)
{
  return __trap34 (42, fd);
}



clock_t
_times (struct tms *tp)
{
  return -1;
}

int
_gettimeofday (struct timeval *tv, struct timezone *tz)
{
  tv->tv_usec = 0;
  tv->tv_sec = __trap34 (23);
  return 0;
}

static inline int
__setup_argv_for_main (int argc)
{
  char **argv;
  int i = argc;

  argv = __builtin_alloca ((1 + argc) * sizeof (*argv));

  argv[i] = ((void *)0);
  while (i--) {
    argv[i] = __builtin_alloca (1 + __trap34 (173, i));
    __trap34 (174, i, argv[i]);
  }

  return main (argc, argv);
}

int
__setup_argv_and_call_main ()
{
  int argc = __trap34 (172);

  if (argc <= 0)
    return main (argc, ((void *)0));
  else
    return __setup_argv_for_main (argc);
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sh-elf broken (Was: IMA: rearrange handling of file-scope constructors)
  2004-07-12 22:04 ` sh-elf broken (Was: IMA: rearrange handling of file-scope constructors) Joern Rennecke
@ 2004-07-14 13:09   ` Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2004-07-14 13:09 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Zack Weinberg, gcc-patches, Andrew Pinski, Geoff Keating

On Jul 12, 2004, Joern Rennecke <joern.rennecke@superh.com> wrote:

> ../../../../../../../srcw/newlib/libc/sys/sh/syscalls.c:9: error: register name 
> not specified for 'stack_ptr'

> c_write_global_declarations is called before _sbrk is expanded to rtl,
> and causes check_global_declarations to be called, which clears the
> decl.rtl for this variable:

> register char *stack_ptr asm ("r15");

Fixed with:

2004-07-12  Alexandre Oliva  <aoliva@redhat.com>

	* passes.c (rest_of_decl_compilation): Don't defer call of
	assemble_variable if its DECL_RTL is already set.

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-14  3:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-08  7:49 IMA: rearrange handling of file-scope constructors Zack Weinberg
2004-07-12 22:04 ` sh-elf broken (Was: IMA: rearrange handling of file-scope constructors) Joern Rennecke
2004-07-14 13:09   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).