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]

Build breakage on darwin and pa64-hpux [was Re: Use -fbuilding-libgcc for more target macros used in libgcc]


On Fri, 2014-09-05 at 01:15 +0000, Joseph S. Myers wrote:
> It is desirable for various reasons to stop target libraries from
> using host-side tm.h: making the headers work on both host and target
> (and on build as well) is fragile (especially when dealing with macros
> depending on command-line options, which need different definitions
> when being used for the target), prevents configuring and building
> target libraries separately from host-side tools (consider a process
> of bootstapping tools and libraries, where the host side of GCC should
> be built before building libc but the final versions of target
> libraries can only be configured and built after libc) and any target
> macro used in target-side code cannot be turned into a target hook.
> 
> Some target macros used only in target-side code can be moved into
> libgcc_tm.h; the trickier cases are macros that are actually used on
> both the host and the target.  We have a -fbuilding-libgcc option to
> cause GCC to predefine additional macros for such cases, to
> communicate the target macro setting to code built for the target.
> This patch moves various additional target macros used on both the
> host and the target to use this mechanism instead of using the target
> macro directly in code built for the target.
> 
> The set of macros converted is smaller than the list I put on
> <https://gcc.gnu.org/wiki/Top-Level_Libgcc_Migration> some time ago;
> as well as excluding some used on the target only for a single target
> architecture (where I think target-specific predefines if
> -fbuilding-libgcc would be reasonable), there are others I think
> should be investigated further to work out the best way to communicate
> the relevant information to libgcc.
> 
> In general the conversions of the libgcc code here are mechanical.  I
> removed conditional definitions of DWARF_FRAME_REGISTERS to
> FIRST_PSEUDO_REGISTER (defaults.h has such a definition, meaning in
> fact DWARF_FRAME_REGISTERS is always defined on the host and the
> definition and uses of __LIBGCC_DWARF_FRAME_REGISTERS__ can safely be
> unconditional).  This gets rid of uses of FIRST_PSEUDO_REGISTER in
> target-side code.  In the case of TARGET_VTABLE_USES_DESCRIPTORS, I
> made __LIBGCC_VTABLE_USES_DESCRIPTORS__ correspond to the host-side
> value rather than to whether TARGET_VTABLE_USES_DESCRIPTORS is defined
> by the target (note that defaults.h has a default definition of
> TARGET_VTABLE_USES_DESCRIPTORS if not already defined, but in a
> section of defaults.h that's only used on the host, so the #ifdef in
> the target-side code was effective despire the default definition and
> this is a correct translation to the -fbuilding-libgcc approach).
> 
> For ARM, CTORS_SECTION_ASM_OP and DTORS_SECTION_ASM_OP are defined (or
> not) in arm.h differently depending on IN_LIBGCC2.  So this patch has
> the effect that __LIBGCC_CTORS_SECTION_ASM_OP__ and
> __LIBGCC_DTORS_SECTION_ASM_OP__ will be defined in libgcc for EABI
> targets when the previous target macros were not.  But this is of no
> effect because in fact CTOR_LIST_BEGIN, CTOR_LIST_END, DTOR_LIST_BEGIN
> and DTOR_LIST_END being defined mean that nothing depends on whether
> __LIBGCC_CTORS_SECTION_ASM_OP__ and __LIBGCC_DTORS_SECTION_ASM_OP__
> are defined.  Rather than attempt a partial cleanup of the relevant
> code and comments in arm.h, it seems better to leave that until
> CTOR_LIST_BEGIN, CTOR_LIST_END, DTOR_LIST_BEGIN and DTOR_LIST_END move
> to libgcc_tm.h.  (I don't believe there are any other cases where the
> current definitions of affected target macros depend on whether tm.h
> is being used for the target.)
> 
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
> commit?
> 
> gcc/c-family:
> 2014-09-05  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* c-cppbuiltin.c (c_cpp_builtins): Also define
> 	__LIBGCC_EH_TABLES_CAN_BE_READ_ONLY__,
> 	__LIBGCC_EH_FRAME_SECTION_NAME__, __LIBGCC_JCR_SECTION_NAME__,
> 	__LIBGCC_CTORS_SECTION_ASM_OP__, __LIBGCC_DTORS_SECTION_ASM_OP__,
> 	__LIBGCC_TEXT_SECTION_ASM_OP__, __LIBGCC_INIT_SECTION_ASM_OP__,
> 	__LIBGCC_INIT_ARRAY_SECTION_ASM_OP__,
> 	__LIBGCC_STACK_GROWS_DOWNWARD__,
> 	__LIBGCC_DONT_USE_BUILTIN_SETJMP__,
> 	__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__,
> 	__LIBGCC_DWARF_FRAME_REGISTERS__,
> 	__LIBGCC_EH_RETURN_STACKADJ_RTX__, __LIBGCC_JMP_BUF_SIZE__,
> 	__LIBGCC_STACK_POINTER_REGNUM__ and
> 	__LIBGCC_VTABLE_USES_DESCRIPTORS__ for -fbuilding-libgcc.
> 	(builtin_define_with_value): Handle backslash-escaping in string
> 	macro values.
> 
> libgcc:
> 2014-09-05  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* Makefile.in (CRTSTUFF_CFLAGS): Add -fbuilding-libgcc.
> 	* config/aarch64/linux-unwind.h (STACK_POINTER_REGNUM): Change all
> 	uses to __LIBGCC_STACK_POINTER_REGNUM__.
> 	(DWARF_ALT_FRAME_RETURN_COLUMN): Change all uses to
> 	__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__.
> 	* config/alpha/vms-unwind.h (DWARF_ALT_FRAME_RETURN_COLUMN):
> 	Change use to __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__.
> 	* config/cr16/unwind-cr16.c (STACK_GROWS_DOWNWARD): Change all
> 	uses to __LIBGCC_STACK_GROWS_DOWNWARD__.
> 	(DWARF_FRAME_REGISTERS): Change all uses to
> 	__LIBGCC_DWARF_FRAME_REGISTERS__.
> 	(EH_RETURN_STACKADJ_RTX): Change all uses to
> 	__LIBGCC_EH_RETURN_STACKADJ_RTX__.
> 	* config/cr16/unwind-dw2.h (DWARF_FRAME_REGISTERS): Change use to
> 	__LIBGCC_DWARF_FRAME_REGISTERS__.  Remove conditional definition.
> 	* config/i386/cygming-crtbegin.c (EH_FRAME_SECTION_NAME): Change
> 	use to __LIBGCC_EH_FRAME_SECTION_NAME__.
> 	(JCR_SECTION_NAME): Change use to __LIBGCC_JCR_SECTION_NAME__.
> 	* config/i386/cygming-crtend.c (EH_FRAME_SECTION_NAME): Change use
> 	to __LIBGCC_EH_FRAME_SECTION_NAME__.
> 	(JCR_SECTION_NAME): Change use to __LIBGCC_JCR_SECTION_NAME__
> 	* config/mips/linux-unwind.h (STACK_POINTER_REGNUM): Change use to
> 	__LIBGCC_STACK_POINTER_REGNUM__.
> 	(DWARF_ALT_FRAME_RETURN_COLUMN): Change all uses to
> 	__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__.
> 	* config/nios2/linux-unwind.h (STACK_POINTER_REGNUM): Change use
> 	to __LIBGCC_STACK_POINTER_REGNUM__.
> 	* config/pa/hpux-unwind.h (DWARF_ALT_FRAME_RETURN_COLUMN): Change
> 	all uses to __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__.
> 	* config/pa/linux-unwind.h (DWARF_ALT_FRAME_RETURN_COLUMN): Change
> 	all uses to __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__.
> 	* config/rs6000/aix-unwind.h (DWARF_ALT_FRAME_RETURN_COLUMN):
> 	Change all uses to __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__.
> 	(STACK_POINTER_REGNUM): Change all uses to
> 	__LIBGCC_STACK_POINTER_REGNUM__.
> 	* config/rs6000/darwin-fallback.c (STACK_POINTER_REGNUM): Change
> 	use to __LIBGCC_STACK_POINTER_REGNUM__.
> 	* config/rs6000/linux-unwind.h (STACK_POINTER_REGNUM): Change all
> 	uses to __LIBGCC_STACK_POINTER_REGNUM__.
> 	* config/sparc/linux-unwind.h (DWARF_FRAME_REGISTERS): Change use
> 	to __LIBGCC_DWARF_FRAME_REGISTERS__.
> 	* config/sparc/sol2-unwind.h (DWARF_FRAME_REGISTERS): Change use
> 	to __LIBGCC_DWARF_FRAME_REGISTERS__.
> 	* config/tilepro/linux-unwind.h (STACK_POINTER_REGNUM): Change use
> 	to __LIBGCC_STACK_POINTER_REGNUM__.
> 	* config/xtensa/unwind-dw2-xtensa.h (DWARF_FRAME_REGISTERS):
> 	Remove conditional definition.
> 	* crtstuff.c (TEXT_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_TEXT_SECTION_ASM_OP__.
> 	(EH_FRAME_SECTION_NAME): Change all uses to
> 	__LIBGCC_EH_FRAME_SECTION_NAME__.
> 	(EH_TABLES_CAN_BE_READ_ONLY): Change all uses to
> 	__LIBGCC_EH_TABLES_CAN_BE_READ_ONLY__.
> 	(CTORS_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_CTORS_SECTION_ASM_OP__.
> 	(DTORS_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_DTORS_SECTION_ASM_OP__.
> 	(JCR_SECTION_NAME): Change all uses to
> 	__LIBGCC_JCR_SECTION_NAME__.
> 	(INIT_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_INIT_SECTION_ASM_OP__.
> 	(INIT_ARRAY_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_INIT_ARRAY_SECTION_ASM_OP__.
> 	* generic-morestack.c (STACK_GROWS_DOWNWARD): Change all uses to
> 	__LIBGCC_STACK_GROWS_DOWNWARD__.
> 	* libgcc2.c (INIT_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_INIT_SECTION_ASM_OP__.
> 	(INIT_ARRAY_SECTION_ASM_OP): Change all uses to
> 	__LIBGCC_INIT_ARRAY_SECTION_ASM_OP__.
> 	(EH_FRAME_SECTION_NAME): Change all uses to
> 	__LIBGCC_EH_FRAME_SECTION_NAME__.
> 	* libgcov-profiler.c (VTABLE_USES_DESCRIPTORS): Remove conditional
> 	definitions.  Change all uses to
> 	__LIBGCC_VTABLE_USES_DESCRIPTORS__.
> 	* unwind-dw2.c (STACK_GROWS_DOWNWARD): Change all uses to
> 	__LIBGCC_STACK_GROWS_DOWNWARD__.
> 	(DWARF_FRAME_REGISTERS): Change all uses to
> 	__LIBGCC_DWARF_FRAME_REGISTERS__.
> 	(EH_RETURN_STACKADJ_RTX): Change all uses to
> 	__LIBGCC_EH_RETURN_STACKADJ_RTX__.
> 	* unwind-dw2.h (DWARF_FRAME_REGISTERS): Remove conditional
> 	definition.  Change use to __LIBGCC_DWARF_FRAME_REGISTERS__.
> 	* unwind-sjlj.c (DONT_USE_BUILTIN_SETJMP): Change all uses to
> 	__LIBGCC_DONT_USE_BUILTIN_SETJMP__.
> 	(JMP_BUF_SIZE): Change use to __LIBGCC_JMP_BUF_SIZE__.
> 
> Index: gcc/c-family/c-cppbuiltin.c
> ===================================================================
> --- gcc/c-family/c-cppbuiltin.c	(revision 214898)
> +++ gcc/c-family/c-cppbuiltin.c	(working copy)
> @@ -943,10 +943,75 @@ c_cpp_builtins (cpp_reader *pfile)

[...snip...]

> +#ifdef INIT_SECTION_ASM_OP
> +      builtin_define_with_value ("__LIBGCC_INIT_SECTION_ASM_OP__",
> +				 INIT_SECTION_ASM_OP, 1);
> +#endif

I believe the above hunk in r214954 (aka
325b8c3ceb2723870dd89f0da419841e2454b273) broke the build for the
following configurations in contrib/config-list.mk:
  hppa64-hpux11.0OPT-enable-sjlj-exceptions=yes
  hppa64-hpux11.3
  i686-apple-darwin
  i686-apple-darwin10
  i686-apple-darwin9
  powerpc64-darwin
  powerpc-darwin7
  powerpc-darwin8
  x86_64-apple-darwin

giving this error:
./src/gcc/c-family/c-cppbuiltin.c: In function âvoid c_cpp_builtins(cpp_reader*)â:
./src/gcc/c-family/c-cppbuiltin.c:972:25: error: expected primary-expression before â,â token
      INIT_SECTION_ASM_OP, 1);

due to these empty macros, in gcc/config/darwin.h:
#undef	INIT_SECTION_ASM_OP
#define INIT_SECTION_ASM_OP

and in gcc/config/pa/pa64-hpux.h

/* Since HP uses the .init and .fini sections for array initializers
   and finalizers, we need different defines for INIT_SECTION_ASM_OP
   and FINI_SECTION_ASM_OP.  With the implementation adopted below,
   the sections are not actually used.  However, we still must provide
   defines to select the proper code path.  */
#undef INIT_SECTION_ASM_OP
#define INIT_SECTION_ASM_OP



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