⛏️ index : buildtools.git

author Alex Smith <alex@alex-smith.me.uk> 2012-04-05 11:16:24.0 +01:00:00
committer Ingo Weinhold <ingo_weinhold@gmx.de> 2012-04-05 12:49:49.0 +02:00:00
commit
cc75156e51a0824ebb1ff1af6f7d451f4377e4de [patch]
tree
1b004e7f1d6f3bff8c6b703825bc761acd2401be
parent
5bdd342ffa415e91e17436d39b79d0b61d7b3826
download
cc75156e51a0824ebb1ff1af6f7d451f4377e4de.tar.gz

Updated the x86_64 toolchain to fix build failures and to be more correct.

* A build failure occurs as TARGET_64BIT is no longer a compile-time
  constant in GCC.
* Made some changes so that generated code matches the i386 Haiku target when
  generating 32-bit code, and follows the x86_64 ABI for 64-bit code.
* Added a comment stating that DEFAULT_PCC_STRUCT_RETURN needs to be defined
  to follow the ABI for 32-bit code, it is ignored for 64-bit.
* Remove definition of __x86_64__, already defined by GCC's i386-c.c.
* Remove -z max-page-size from LINK_SPEC as it shouldn't be necessary: the
  default page size is 2MB but this won't result in large binaries, it just
  changes the alignment of the sections and would make it easier to map
  binaries using large pages in the future.

Signed-off-by: Ingo Weinhold <ingo_weinhold@gmx.de>

Diff

 gcc/gcc/config/i386/haiku64.h | 110 +++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
 gcc/gcc/config/i386/t-haiku64 |   8 ++++++--
 2 files changed, 64 insertions(+), 54 deletions(-)

diff --git a/gcc/gcc/config/i386/haiku64.h b/gcc/gcc/config/i386/haiku64.h
index 44ef197..649816b 100644
--- a/gcc/gcc/config/i386/haiku64.h
+++ a/gcc/gcc/config/i386/haiku64.h
@@ -20,7 +20,7 @@
Boston, MA 02111-1307, USA.  */


#if TARGET_64BIT

#if TARGET_64BIT_DEFAULT

#define TARGET_VERSION fprintf (stderr, " (x86-64 Haiku/ELF)");
#else
#define TARGET_VERSION fprintf (stderr, " (i386 Haiku/ELF)");
@@ -30,10 +30,8 @@
#define ASM_COMMENT_START " #"

/* The SVR4 ABI for the i386 says that records and unions are returned
 *   in memory.
 *
 *   TODO: Linux64 doesn't use pcc_struct_return scheme. Does haiku?
 *         If not this could be removed.
 * in memory. For 64-bit compilation this definition is ignored, however
 * it is necessary for correct 32-bit code generation.
 */
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 1
@@ -42,65 +40,74 @@
#define DBX_REGISTER_NUMBER(n) \
  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])

#if TARGET_64BIT

#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__x86_64__");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");				\
      builtin_define ("__HAIKU__");					\
      if (!TARGET_64BIT)						\
        {								\
          builtin_define ("__INTEL__");					\
          builtin_define ("__X86__");					\
        }								\
      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
      builtin_define ("__STDC_ISO_10646__=201103L");			\
      builtin_assert ("system=haiku");					\
    }									\
  while (0)
#else
#define TARGET_OS_CPP_BUILTINS()					\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__INTEL__");					\
	builtin_define ("__X86__");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");				\
    }									\
  while (0)
#endif

/* Provide a LINK_SPEC appropriate for Haiku.  Here we provide support
   for the special GCC options -static and -shared, which allow us to
   link things in one of these three modes by applying the appropriate
   combinations of options at link-time.  */

#undef	LINK_SPEC
#if TARGET_64BIT

#define LINK_SPEC "-m elf_x86_64 -z max-page-size=0x1000 -shared %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
#if TARGET_64BIT_DEFAULT

#define SPEC_32 "m32"
#define SPEC_64 "!m32"
#else
#define LINK_SPEC "-m elf_i386_haiku -shared %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
#define SPEC_32 "!m64"
#define SPEC_64 "m64"
#endif

#undef	LINK_SPEC
#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386_haiku} \
	-shared %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"

/* A C statement (sans semicolon) to output to the stdio stream
   FILE the assembler definition of uninitialized global DECL named
   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
   Try to use asm_output_aligned_bss to implement this macro.  */
   Try to use x86_output_aligned_bss to implement this macro.  */

#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)

/* A C statement to output to the stdio stream FILE an assembler
   command to advance the location counter to a multiple of 1<<LOG
   bytes if it is within MAX_SKIP bytes.
  x86_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)

   This is used to align code labels according to Intel recommendations.  */
/* This is used to align code labels according to Intel recommendations.  */

#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
  if ((LOG)!=0) \
    if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
    else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
  do {									\
    if ((LOG) != 0) {							\
      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
      else {								\
        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
        /* Make sure that we have at least 8 byte alignment if > 8 byte	\
           alignment is preferred.  */					\
        if ((LOG) > 3							\
            && (1 << (LOG)) > ((MAX_SKIP) + 1)				\
            && (MAX_SKIP) >= 7)						\
          fputs ("\t.p2align 3\n", (FILE));				\
      }									\
    }									\
  } while (0)
#undef  ASM_OUTPUT_MAX_SKIP_PAD
#define ASM_OUTPUT_MAX_SKIP_PAD(FILE, LOG, MAX_SKIP)			\
  if ((LOG) != 0)							\
    {									\
      if ((MAX_SKIP) == 0)						\
        fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
      else								\
        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
    }
#endif


@@ -109,7 +116,7 @@

#undef ASM_SPEC
#define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} \
 %{Wa,*:%*} %{m32:--32} %{m64:--64}"
 %{Wa,*:%*} %{" SPEC_32 ":--32} %{" SPEC_64 ":--64}"

#undef  ASM_OUTPUT_ALIGNED_COMMON
#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
@@ -118,16 +125,15 @@

/* i386 System V Release 4 uses DWARF debugging info.
   x86-64 ABI specifies DWARF2.  */
#if TARGET_64BIT

	#define DWARF2_DEBUGGING_INFO 1
	#define DWARF2_UNWIND_INFO 1

	#undef PREFERRED_DEBUGGING_TYPE
	#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
#define DWARF2_DEBUGGING_INFO 1
#define DWARF2_UNWIND_INFO 1

	#undef TARGET_ASM_SELECT_SECTION
	#define TARGET_ASM_SELECT_SECTION  x86_64_elf_select_section
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG

	#undef TARGET_ASM_UNIQUE_SECTION
	#define TARGET_ASM_UNIQUE_SECTION  x86_64_elf_unique_section
#endif
#undef TARGET_ASM_SELECT_SECTION
#define TARGET_ASM_SELECT_SECTION  x86_64_elf_select_section

#undef TARGET_ASM_UNIQUE_SECTION
#define TARGET_ASM_UNIQUE_SECTION  x86_64_elf_unique_section
diff --git a/gcc/gcc/config/i386/t-haiku64 b/gcc/gcc/config/i386/t-haiku64
index f6fbc4b..d207663 100644
--- a/gcc/gcc/config/i386/t-haiku64
+++ a/gcc/gcc/config/i386/t-haiku64
@@ -1,3 +1,7 @@
MULTILIB_OPTIONS = m32 
MULTILIB_DIRNAMES = legacy 
MULTILIB_OSDIRNAMES = legacy 
MULTILIB_DIRNAMES = 32

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib

EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o