Ticket #8415: buildtools-x86_64.patch

File buildtools-x86_64.patch, 7.9 KB (added by xyzzy, 8 years ago)

Patch to build tools for x86_64

  • gcc/gcc/config/i386/haiku64.h

    From 31790e352dd21aeccc46f21e0f2dd875b6723c4c Mon Sep 17 00:00:00 2001
    From: Alex Smith <alex@alex-smith.me.uk>
    Date: Thu, 5 Apr 2012 11:16:24 +0100
    Subject: [PATCH] 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.
    ---
     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 b the Free Software Foundation, 59 Temple Place - Suite 330,  
    2020Boston, MA 02111-1307, USA.  */
    2121
    2222
    23 #if TARGET_64BIT
     23#if TARGET_64BIT_DEFAULT
    2424#define TARGET_VERSION fprintf (stderr, " (x86-64 Haiku/ELF)");
    2525#else
    2626#define TARGET_VERSION fprintf (stderr, " (i386 Haiku/ELF)");
    Boston, MA 02111-1307, USA. */  
    3030#define ASM_COMMENT_START " #"
    3131
    3232/* The SVR4 ABI for the i386 says that records and unions are returned
    33  *   in memory.
    34  *
    35  *   TODO: Linux64 doesn't use pcc_struct_return scheme. Does haiku?
    36  *         If not this could be removed.
     33 * in memory. For 64-bit compilation this definition is ignored, however
     34 * it is necessary for correct 32-bit code generation.
    3735 */
    3836#undef DEFAULT_PCC_STRUCT_RETURN
    3937#define DEFAULT_PCC_STRUCT_RETURN 1
    Boston, MA 02111-1307, USA. */  
    4240#define DBX_REGISTER_NUMBER(n) \
    4341  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
    4442
    45 #if TARGET_64BIT
    4643#define TARGET_OS_CPP_BUILTINS()                    \
    4744  do                                    \
    4845    {                                   \
    49     builtin_define ("__HAIKU__");                   \
    50     builtin_define ("__x86_64__");                  \
    51     builtin_define ("__stdcall=__attribute__((__stdcall__))");  \
    52     builtin_define ("__cdecl=__attribute__((__cdecl__))");      \
    53     builtin_define ("__STDC_ISO_10646__=201103L"); \
    54     builtin_assert ("system=haiku");                \
     46      builtin_define ("__HAIKU__");                 \
     47      if (!TARGET_64BIT)                        \
     48        {                               \
     49          builtin_define ("__INTEL__");                 \
     50          builtin_define ("__X86__");                   \
     51        }                               \
     52      builtin_define ("__stdcall=__attribute__((__stdcall__))");    \
     53      builtin_define ("__cdecl=__attribute__((__cdecl__))");        \
     54      builtin_define ("__STDC_ISO_10646__=201103L");            \
     55      builtin_assert ("system=haiku");                  \
    5556    }                                   \
    5657  while (0)
    57 #else
    58 #define TARGET_OS_CPP_BUILTINS()                    \
    59   do                                    \
    60     {                                   \
    61     builtin_define ("__HAIKU__");                   \
    62     builtin_define ("__INTEL__");                   \
    63     builtin_define ("__X86__");                 \
    64     builtin_define ("__stdcall=__attribute__((__stdcall__))");  \
    65     builtin_define ("__cdecl=__attribute__((__cdecl__))");      \
    66     builtin_define ("__STDC_ISO_10646__=201103L"); \
    67     builtin_assert ("system=haiku");                \
    68     }                                   \
    69   while (0)
    70 #endif
    7158
    7259/* Provide a LINK_SPEC appropriate for Haiku.  Here we provide support
    7360   for the special GCC options -static and -shared, which allow us to
    7461   link things in one of these three modes by applying the appropriate
    7562   combinations of options at link-time.  */
    7663
    77 #undef  LINK_SPEC
    78 #if TARGET_64BIT
    79 #define LINK_SPEC "-m elf_x86_64 -z max-page-size=0x1000 -shared %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
     64#if TARGET_64BIT_DEFAULT
     65#define SPEC_32 "m32"
     66#define SPEC_64 "!m32"
    8067#else
    81 #define LINK_SPEC "-m elf_i386_haiku -shared %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
     68#define SPEC_32 "!m64"
     69#define SPEC_64 "m64"
    8270#endif
    8371
     72#undef  LINK_SPEC
     73#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386_haiku} \
     74    -shared %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}}"
    8475
    8576/* A C statement (sans semicolon) to output to the stdio stream
    8677   FILE the assembler definition of uninitialized global DECL named
    8778   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
    88    Try to use asm_output_aligned_bss to implement this macro.  */
     79   Try to use x86_output_aligned_bss to implement this macro.  */
    8980
    9081#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
    91   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
     82  x86_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
    9283
    93 /* A C statement to output to the stdio stream FILE an assembler
    94    command to advance the location counter to a multiple of 1<<LOG
    95    bytes if it is within MAX_SKIP bytes.
    96 
    97    This is used to align code labels according to Intel recommendations.  */
     84/* This is used to align code labels according to Intel recommendations.  */
    9885
    9986#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
    100 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
    101   if ((LOG)!=0) \
    102     if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
    103     else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
     87#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)            \
     88  do {                                  \
     89    if ((LOG) != 0) {                           \
     90      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));  \
     91      else {                                \
     92        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
     93        /* Make sure that we have at least 8 byte alignment if > 8 byte \
     94           alignment is preferred.  */                  \
     95        if ((LOG) > 3                           \
     96            && (1 << (LOG)) > ((MAX_SKIP) + 1)              \
     97            && (MAX_SKIP) >= 7)                     \
     98          fputs ("\t.p2align 3\n", (FILE));             \
     99      }                                 \
     100    }                                   \
     101  } while (0)
     102#undef  ASM_OUTPUT_MAX_SKIP_PAD
     103#define ASM_OUTPUT_MAX_SKIP_PAD(FILE, LOG, MAX_SKIP)            \
     104  if ((LOG) != 0)                           \
     105    {                                   \
     106      if ((MAX_SKIP) == 0)                      \
     107        fprintf ((FILE), "\t.p2align %d\n", (LOG));         \
     108      else                              \
     109        fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
     110    }
    104111#endif
    105112
    106113
    Boston, MA 02111-1307, USA. */  
    109116
    110117#undef ASM_SPEC
    111118#define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} \
    112  %{Wa,*:%*} %{m32:--32} %{m64:--64}"
     119 %{Wa,*:%*} %{" SPEC_32 ":--32} %{" SPEC_64 ":--64}"
    113120
    114121#undef  ASM_OUTPUT_ALIGNED_COMMON
    115122#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)      \
    Boston, MA 02111-1307, USA. */  
    118125
    119126/* i386 System V Release 4 uses DWARF debugging info.
    120127   x86-64 ABI specifies DWARF2.  */
    121 #if TARGET_64BIT
    122     #define DWARF2_DEBUGGING_INFO 1
    123     #define DWARF2_UNWIND_INFO 1
    124128
    125     #undef PREFERRED_DEBUGGING_TYPE
    126     #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
     129#define DWARF2_DEBUGGING_INFO 1
     130#define DWARF2_UNWIND_INFO 1
    127131
    128     #undef TARGET_ASM_SELECT_SECTION
    129     #define TARGET_ASM_SELECT_SECTION  x86_64_elf_select_section
     132#undef PREFERRED_DEBUGGING_TYPE
     133#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
    130134
    131     #undef TARGET_ASM_UNIQUE_SECTION
    132     #define TARGET_ASM_UNIQUE_SECTION  x86_64_elf_unique_section
    133 #endif
     135#undef TARGET_ASM_SELECT_SECTION
     136#define TARGET_ASM_SELECT_SECTION  x86_64_elf_select_section
     137
     138#undef TARGET_ASM_UNIQUE_SECTION
     139#define TARGET_ASM_UNIQUE_SECTION  x86_64_elf_unique_section
  • gcc/gcc/config/i386/t-haiku64

    diff --git a/gcc/gcc/config/i386/t-haiku64 b/gcc/gcc/config/i386/t-haiku64
    index f6fbc4b..d207663 100644
    a b  
    11MULTILIB_OPTIONS = m32
    2 MULTILIB_DIRNAMES = legacy
    3 MULTILIB_OSDIRNAMES = legacy
     2MULTILIB_DIRNAMES = 32
     3
     4LIBGCC = stmp-multilib
     5INSTALL_LIBGCC = install-multilib
     6
     7EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o