Commit 476d9098 by Geoffrey Keating Committed by Geoffrey Keating

Makefile.in (host_hook_obj): New.

	* Makefile.in (host_hook_obj): New.
	(OBJS): Add $(host_hook_obj).
	(host_default.o): New rule.
	* config.gcc (host_hook_obj): New, default to host-default.o.
	(powerpc-*-darwin*): Use host-darwin.o.
	(out_host_hook_obj): New.
	* configure: Regenerate.
	* configure.in: Print information about out_host_hook_obj, substitute
	into output files.
	* host-default.c: New file.
	* hosthooks.h: New file.
	* toplev.c (general_init): Call host_hooks.extra_signals.
	* config/rs6000/host-darwin.c: New file.
	* config/rs6000/x-darwin: New file.
	* doc/hostconfig.texi: Add documentation for new host hook.
	Rearrange existing documentation.

From-SVN: r62470
parent dbdd3489
2003-02-05 Geoffrey Keating <geoffk@apple.com>
* Makefile.in (host_hook_obj): New.
(OBJS): Add $(host_hook_obj).
(host_default.o): New rule.
* config.gcc (host_hook_obj): New, default to host-default.o.
(powerpc-*-darwin*): Use host-darwin.o.
(out_host_hook_obj): New.
* configure: Regenerate.
* configure.in: Print information about out_host_hook_obj, substitute
into output files.
* host-default.c: New file.
* hosthooks.h: New file.
* toplev.c (general_init): Call host_hooks.extra_signals.
* config/rs6000/host-darwin.c: New file.
* config/rs6000/x-darwin: New file.
* doc/hostconfig.texi: Add documentation for new host hook.
Rearrange existing documentation.
2003-02-05 Roger Sayle <roger@eyesopen.com>
* dwarf2out.c (mem_loc_descriptor): Replace ASM_SIMPLIFY_DWARF_ADDR
......
......@@ -315,6 +315,7 @@ target_cpu_default=@target_cpu_default@
GCC_THREAD_FILE=@thread_file@
OBJC_BOEHM_GC=@objc_boehm_gc@
GTHREAD_FLAGS=@gthread_flags@
host_hook_obj=@out_host_hook_obj@
# Be prepared for gcc2 merges.
gcc_version=@gcc_version@
gcc_version_trigger=@gcc_version_trigger@
......@@ -784,7 +785,8 @@ OBJS = alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \
sibcall.o simplify-rtx.o ssa.o ssa-ccp.o ssa-dce.o stmt.o \
stor-layout.o stringpool.o timevar.o toplev.o tracer.o tree.o tree-dump.o \
tree-inline.o unroll.o varasm.o varray.o version.o vmsdbgout.o xcoffout.o \
alloc-pool.o et-forest.o $(GGC) $(out_object_file) $(EXTRA_OBJS)
alloc-pool.o et-forest.o \
$(GGC) $(out_object_file) $(EXTRA_OBJS) $(host_hook_obj)
BACKEND = main.o libbackend.a
......@@ -1428,12 +1430,15 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_
dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) \
ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \
langhooks.h insn-flags.h options.h cfglayout.h real.h cfgloop.h
langhooks.h insn-flags.h options.h cfglayout.h real.h cfgloop.h hosthooks.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DTARGET_NAME=\"$(target_alias)\" \
-c $(srcdir)/toplev.c $(OUTPUT_OPTION)
main.o : main.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) toplev.h
host-default.o : host-default.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
hosthooks.h hosthooks-def.h
rtl-error.o: rtl-error.c $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(INSN_ATTR_H) \
insn-config.h input.h toplev.h intl.h diagnostic.h $(CONFIG_H)
......
......@@ -99,6 +99,8 @@
# host_extra_gcc_objs List of extra host-dependent objects that should
# be linked into the gcc driver.
#
# out_host_hook_obj An object file that provides the host hooks.
#
# c_target_objs List of extra target-dependent objects that be
# linked into the C compiler only.
#
......@@ -169,6 +171,8 @@
# the compiler proper when this system is a host,
# for host_extra_objs.
#
# host_hook_obj An object file that provides the host hooks.
#
# install_headers_dir Makefile-target for how the header file directory
# is installed, when this system is a build system,
# for build_install_headers_dir.
......@@ -194,6 +198,7 @@ extra_host_objs=
extra_gcc_objs=
c_target_objs=
cxx_target_objs=
host_hook_obj=host-default.o
tm_defines=
xm_defines=
# Set this to force installation and use of collect2.
......@@ -1980,6 +1985,9 @@ powerpc-*-darwin*)
extra_headers=altivec.h
# override ppc default
need_64bit_hwint=
# powerpc-darwin host support.
host_hook_obj=host-darwin.o
xmake_file=rs6000/x-darwin
;;
powerpc*-*-freebsd*)
tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file} rs6000/sysv4.h rs6000/freebsd.h"
......@@ -2956,6 +2964,7 @@ else
host_extra_gcc_objs=$extra_gcc_objs
host_extra_objs=$extra_host_objs
host_exeext=$exeext
out_host_hook_obj=$host_hook_obj
pass2done=yes
fi
fi
/* Darwin/powerpc host-specific hook definitions.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include <signal.h>
#include <sys/ucontext.h>
#include "hosthooks.h"
#include "hosthooks-def.h"
#include "toplev.h"
static void segv_crash_handler PARAMS ((int));
static void segv_handler PARAMS ((int, siginfo_t *, void *));
static void darwin_rs6000_extra_signals PARAMS ((void));
/* No prototype for this, filed as Radar 3150910. */
extern int sigaltstack(const stack_t *, stack_t *);
#undef HOST_HOOKS_EXTRA_SIGNALS
#define HOST_HOOKS_EXTRA_SIGNALS darwin_rs6000_extra_signals
/* On Darwin/powerpc, a stack fault can be detected as a SIGSEGV that
faulted on an instruction that's either
or
stwux %r1,xxx,%r1
*/
static void
segv_crash_handler (sig)
int sig ATTRIBUTE_UNUSED;
{
internal_error ("Segmentation Fault (code)");
}
static void
segv_handler (sig, sip, scp)
int sig ATTRIBUTE_UNUSED;
siginfo_t *sip ATTRIBUTE_UNUSED;
void *scp;
{
ucontext_t *uc = (ucontext_t *)scp;
unsigned faulting_insn;
/* The fault might have happened when trying to run some instruction, in
which case the next line will segfault _again_. Handle this case. */
signal (SIGSEGV, segv_crash_handler);
faulting_insn = *(unsigned *)uc->uc_mcontext->ss.srr0;
/* Note that this only has to work for GCC, so we don't have to deal
with all the possible cases (GCC has no AltiVec code, for
instance). It's complicated because Darwin allows stores to
below the stack pointer, and the prologue code takes advantage of
this. */
if ((faulting_insn & 0xFFFF8000) == 0x94218000 /* stwu %r1, -xxx(%r1) */
|| (faulting_insn & 0xFFFF03FF) == 0x7C21016E /* stwux %r1, xxx, %r1 */
|| (faulting_insn & 0xFC1F8000) == 0x90018000 /* stw xxx, -yyy(%r1) */
|| (faulting_insn & 0xFC1F8000) == 0xD8018000 /* stfd xxx, -yyy(%r1) */
|| (faulting_insn & 0xFC1F8000) == 0xBC018000 /* stmw xxx, -yyy(%r1) */)
{
char *shell_name;
fnotice (stderr, "Out of stack space.\n");
shell_name = getenv ("SHELL");
if (shell_name != NULL)
shell_name = strrchr (shell_name, '/');
if (shell_name != NULL)
{
static const char * shell_commands[][2] = {
{ "sh", "ulimit -S -s unlimited" },
{ "bash", "ulimit -S -s unlimited" },
{ "tcsh", "limit stacksize unlimited" },
{ "csh", "limit stacksize unlimited" },
/* zsh doesn't have "unlimited", this will work under the
default configuration. */
{ "zsh", "limit stacksize 32m" }
};
size_t i;
for (i = 0; i < ARRAY_SIZE (shell_commands); i++)
if (strcmp (shell_commands[i][0], shell_name + 1) == 0)
{
fnotice (stderr,
"Try running `%s' in the shell to raise its limit.\n",
shell_commands[i][1]);
}
}
exit (FATAL_EXIT_CODE);
}
fprintf (stderr, "[address=%08lx pc=%08x]\n",
uc->uc_mcontext->es.dar, uc->uc_mcontext->ss.srr0);
internal_error ("Segmentation Fault");
exit (FATAL_EXIT_CODE);
}
static void
darwin_rs6000_extra_signals ()
{
struct sigaction sact;
stack_t sigstk;
sigstk.ss_sp = xmalloc (SIGSTKSZ);
sigstk.ss_size = SIGSTKSZ;
sigstk.ss_flags = 0;
if (sigaltstack (&sigstk, NULL) < 0)
fatal_io_error ("While setting up signal stack");
sigemptyset(&sact.sa_mask);
sact.sa_flags = SA_ONSTACK | SA_SIGINFO;
sact.sa_sigaction = segv_handler;
if (sigaction (SIGSEGV, &sact, 0) < 0)
fatal_io_error ("While setting up signal handler");
}
const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
host-darwin.o : $(srcdir)/config/rs6000/host-darwin.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h hosthooks.h hosthooks-def.h toplev.h
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(srcdir)/config/rs6000/host-darwin.c
......@@ -956,6 +956,7 @@ else
echo " $srcdir/config/$f"
done
fi
echo "Using ${out_host_hook_obj} for host machine hooks."
if test "$host_xm_file" != "$build_xm_file"; then
count=a
......@@ -2858,6 +2859,7 @@ AC_SUBST(host_extra_gcc_objs)
AC_SUBST(host_xm_file_list)
AC_SUBST(host_xm_file)
AC_SUBST(host_xm_defines)
AC_SUBST(out_host_hook_obj)
AC_SUBST(install)
AC_SUBST(lang_options_files)
AC_SUBST(lang_specs_files)
......
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
@c 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
@c 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@c For copying conditions, see the file gccint.texi.
@node Host Config
@chapter Host Configuration Headers
@chapter Host Configuration
@cindex host configuration
Most details about the machine and system on which the compiler is
actually running are detected by the @command{configure} script. Some
things are impossible for @command{configure} to detect; these are
described in two ways, either by macros defined in a file named
@file{xm-@var{machine}.h} or by hook functions in the file specified
by the @var{out_host_hook_obj} variable in @file{config.gcc}. (The
intention is that very few hosts will need a header file but nearly
every fully supported host will need to override some hooks.)
If you need to define only a few macros, and they have simple
definitions, consider using the @code{xm_defines} variable in your
@file{config.gcc} entry instead of creating a host configuration
header. @xref{System Config}.
@menu
* Host Common:: Things every host probably needs implemented.
* Filesystem:: Your host can't have the letter `a' in filenames?
* Host Misc:: Rare configuration options for hosts.
@end menu
@node Host Common
@section Host Common
@cindex host hooks
@cindex host functions
Some things are just not portable, even between similar operating systems,
and are too difficult for autoconf to detect. They get implemented using
hook functions in the file specified by the @var{host_hook_obj}
variable in @file{config.gcc}.
@deftypefn {Host Hook} void HOST_HOOKS_EXTRA_SIGNALS (void)
This host hook is used to set up handling for extra signals. The most
common thing to do in this hook is to detect stack overflow.
@end deftypefn
@node Filesystem
@section Host Filesystem
@cindex configuration file
@cindex @file{xm-@var{machine}.h}
Host configuration headers contain macro definitions that describe the
machine and system on which the compiler is running. They are usually
unnecessary. Most of the things GCC needs to know about the host
system can be deduced by the @command{configure} script.
If your host does need a special configuration header, it should be
named @file{xm-@var{machine}.h}, where @var{machine} is a short mnemonic
for the machine. Here are some macros which this header can define.
GCC supports some filesystems that are very different to standard Unix
filesystems. These macros, defined in @file{xm-@var{machine}.h},
let you choose.
@ftable @code
@item VMS
Define this macro if the host system is VMS@.
@item FATAL_EXIT_CODE
A C expression for the status code to be returned when the compiler
exits after serious errors. The default is the system-provided macro
@samp{EXIT_FAILURE}, or @samp{1} if the system doesn't define that
macro. Define this macro only if these defaults are incorrect.
@item SUCCESS_EXIT_CODE
A C expression for the status code to be returned when the compiler
exits without serious errors. (Warnings are not serious errors.) The
default is the system-provided macro @samp{EXIT_SUCCESS}, or @samp{0} if
the system doesn't define that macro. Define this macro only if these
defaults are incorrect.
@item USE_C_ALLOCA
Define this macro if GCC should use the C implementation of @code{alloca}
provided by @file{libiberty.a}. This only affects how some parts of the
compiler itself allocate memory. It does not change code generation.
When GCC is built with a compiler other than itself, the C @code{alloca}
is always used. This is because most other implementations have serious
bugs. You should define this macro only on a system where no
stack-based @code{alloca} can possibly work. For instance, if a system
has a small limit on the size of the stack, GCC's builtin @code{alloca}
will not work reliably.
@item HAVE_DOS_BASED_FILE_SYSTEM
Define this macro if the host file system obeys the semantics defined by
MS-DOS instead of Unix. DOS file systems are case insensitive, file
......@@ -86,14 +95,6 @@ you do not define this macro, GCC will use @samp{/dev/null} as the bit
bucket. If the host does not support a bit bucket, define this macro to
an invalid filename.
@item COLLECT2_HOST_INITIALIZATION
If defined, a C statement (sans semicolon) that performs host-dependent
initialization when @code{collect2} is being initialized.
@item GCC_DRIVER_HOST_INITIALIZATION
If defined, a C statement (sans semicolon) that performs host-dependent
initialization when a compilation driver is being initialized.
@item UPDATE_PATH_HOST_CANONICALIZE (@var{path})
If defined, a C statement (sans semicolon) that performs host-dependent
canonicalization when a path used in a compilation driver or
......@@ -112,6 +113,46 @@ unique to each dump file kind, e.g. @samp{rtl}.
If you do not define this macro, GCC will use @samp{.%02d.}. You should
define this macro if using the default will create an invalid file name.
@end ftable
@node Host Misc
@section Host Misc
@cindex configuration file
@cindex @file{xm-@var{machine}.h}
@ftable @code
@item FATAL_EXIT_CODE
A C expression for the status code to be returned when the compiler
exits after serious errors. The default is the system-provided macro
@samp{EXIT_FAILURE}, or @samp{1} if the system doesn't define that
macro. Define this macro only if these defaults are incorrect.
@item SUCCESS_EXIT_CODE
A C expression for the status code to be returned when the compiler
exits without serious errors. (Warnings are not serious errors.) The
default is the system-provided macro @samp{EXIT_SUCCESS}, or @samp{0} if
the system doesn't define that macro. Define this macro only if these
defaults are incorrect.
@item USE_C_ALLOCA
Define this macro if GCC should use the C implementation of @code{alloca}
provided by @file{libiberty.a}. This only affects how some parts of the
compiler itself allocate memory. It does not change code generation.
When GCC is built with a compiler other than itself, the C @code{alloca}
is always used. This is because most other implementations have serious
bugs. You should define this macro only on a system where no
stack-based @code{alloca} can possibly work. For instance, if a system
has a small limit on the size of the stack, GCC's builtin @code{alloca}
will not work reliably.
@item COLLECT2_HOST_INITIALIZATION
If defined, a C statement (sans semicolon) that performs host-dependent
initialization when @code{collect2} is being initialized.
@item GCC_DRIVER_HOST_INITIALIZATION
If defined, a C statement (sans semicolon) that performs host-dependent
initialization when a compilation driver is being initialized.
@item SMALL_ARG_MAX
Define this macro if the host system has a small limit on the total
......@@ -123,8 +164,3 @@ In addition, if @command{configure} generates an incorrect definition of
any of the macros in @file{auto-host.h}, you can override that
definition in a host configuration header. If you need to do this,
first see if it is possible to fix @command{configure}.
If you need to define only a few of these macros, and they have simple
definitions, consider using the @code{xm_defines} variable in your
@file{config.gcc} entry instead of creating a host configuration header.
@xref{System Config}.
/* Default host-specific hook definitions.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "hosthooks.h"
#include "hosthooks-def.h"
const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
/* Default macros to initialize the lang_hooks data structure.
Copyright 2003 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef GCC_HOST_HOOKS_DEF_H
#define GCC_HOST_HOOKS_DEF_H
#include "hooks.h"
#define HOST_HOOKS_EXTRA_SIGNALS hook_void_void
/* The structure is defined in hosthooks.h. */
#define HOST_HOOKS_INITIALIZER { \
HOST_HOOKS_EXTRA_SIGNALS \
}
#endif /* GCC_HOST_HOOKS_DEF_H */
/* The host_hooks data structure.
Copyright 2003 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef GCC_HOST_HOOKS_H
#define GCC_HOST_HOOKS_H
struct host_hooks
{
void (*extra_signals) PARAMS((void));
/* Whenever you add entries here, make sure you adjust hosthooks-def.h. */
};
/* Each host provides its own. */
extern const struct host_hooks host_hooks;
#endif /* GCC_LANG_HOOKS_H */
......@@ -74,6 +74,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "langhooks.h"
#include "cfglayout.h"
#include "cfgloop.h"
#include "hosthooks.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
......@@ -4759,6 +4760,9 @@ general_init (argv0)
signal (SIGFPE, crash_signal);
#endif
/* Other host-specific signal setup. */
(*host_hooks.extra_signals)();
/* Initialize the diagnostics reporting machinery, so option parsing
can give warnings and errors. */
diagnostic_initialize (global_dc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment