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,
|
20 | 20 | Boston, MA 02111-1307, USA. */ |
21 | 21 | |
22 | 22 | |
23 | | #if TARGET_64BIT |
| 23 | #if TARGET_64BIT_DEFAULT |
24 | 24 | #define TARGET_VERSION fprintf (stderr, " (x86-64 Haiku/ELF)"); |
25 | 25 | #else |
26 | 26 | #define TARGET_VERSION fprintf (stderr, " (i386 Haiku/ELF)"); |
… |
… |
Boston, MA 02111-1307, USA. */
|
30 | 30 | #define ASM_COMMENT_START " #" |
31 | 31 | |
32 | 32 | /* 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. |
37 | 35 | */ |
38 | 36 | #undef DEFAULT_PCC_STRUCT_RETURN |
39 | 37 | #define DEFAULT_PCC_STRUCT_RETURN 1 |
… |
… |
Boston, MA 02111-1307, USA. */
|
42 | 40 | #define DBX_REGISTER_NUMBER(n) \ |
43 | 41 | (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n]) |
44 | 42 | |
45 | | #if TARGET_64BIT |
46 | 43 | #define TARGET_OS_CPP_BUILTINS() \ |
47 | 44 | do \ |
48 | 45 | { \ |
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"); \ |
55 | 56 | } \ |
56 | 57 | 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 |
71 | 58 | |
72 | 59 | /* Provide a LINK_SPEC appropriate for Haiku. Here we provide support |
73 | 60 | for the special GCC options -static and -shared, which allow us to |
74 | 61 | link things in one of these three modes by applying the appropriate |
75 | 62 | combinations of options at link-time. */ |
76 | 63 | |
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" |
80 | 67 | #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" |
82 | 70 | #endif |
83 | 71 | |
| 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}}" |
84 | 75 | |
85 | 76 | /* A C statement (sans semicolon) to output to the stdio stream |
86 | 77 | FILE the assembler definition of uninitialized global DECL named |
87 | 78 | 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. */ |
89 | 80 | |
90 | 81 | #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) |
92 | 83 | |
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. */ |
98 | 85 | |
99 | 86 | #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 | } |
104 | 111 | #endif |
105 | 112 | |
106 | 113 | |
… |
… |
Boston, MA 02111-1307, USA. */
|
109 | 116 | |
110 | 117 | #undef ASM_SPEC |
111 | 118 | #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}" |
113 | 120 | |
114 | 121 | #undef ASM_OUTPUT_ALIGNED_COMMON |
115 | 122 | #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ |
… |
… |
Boston, MA 02111-1307, USA. */
|
118 | 125 | |
119 | 126 | /* i386 System V Release 4 uses DWARF debugging info. |
120 | 127 | x86-64 ABI specifies DWARF2. */ |
121 | | #if TARGET_64BIT |
122 | | #define DWARF2_DEBUGGING_INFO 1 |
123 | | #define DWARF2_UNWIND_INFO 1 |
124 | 128 | |
125 | | #undef PREFERRED_DEBUGGING_TYPE |
126 | | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG |
| 129 | #define DWARF2_DEBUGGING_INFO 1 |
| 130 | #define DWARF2_UNWIND_INFO 1 |
127 | 131 | |
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 |
130 | 134 | |
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 |
diff --git a/gcc/gcc/config/i386/t-haiku64 b/gcc/gcc/config/i386/t-haiku64
index f6fbc4b..d207663 100644
a
|
b
|
|
1 | 1 | MULTILIB_OPTIONS = m32 |
2 | | MULTILIB_DIRNAMES = legacy |
3 | | MULTILIB_OSDIRNAMES = legacy |
| 2 | MULTILIB_DIRNAMES = 32 |
| 3 | |
| 4 | LIBGCC = stmp-multilib |
| 5 | INSTALL_LIBGCC = install-multilib |
| 6 | |
| 7 | EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o |