Skip to content

Commit 1da8c29

Browse files
iainsfxcoudert
authored andcommitted
Darwin, Arm64 : Base build changes to Darwin common code.
It seems that the arm64 port will not make use of traditional mach-o pic but instead use a GOT - as such, the target-dependent parts of darwin.c are made NOP for this. We still expect to apply other Mach-O constraints. Most of the change is about the support for giving the user an error message when they try to invoke the compiler with multiple -arch flags. There is no provision in the initial port to handle the arm64_32 variant. This is (understood to be) only used in watchOS which we are not supporting initially. + No machopic indirections for Arm64 personality/LSDA entries. As for x86-64 (64bit code), the personality and LSDA .cfi_xxx entries do not require an indirection in the compiler code. + Accept arm64 in arch flags, for aarch64 compilers. We were checking for this and complaining if it was present for an X86 or PPC compiler, but we also need to accept (and ignore it) for an aarch64 / Arm64 compiler.
1 parent 0e197cc commit 1da8c29

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

gcc/config/darwin-driver.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,13 @@ darwin_driver_init (unsigned int *decoded_options_count,
277277
bool seenX86_64 = false;
278278
bool seenPPC = false;
279279
bool seenPPC64 = false;
280+
#if !DARWIN_ARM64
281+
bool seenArm64 = false;
280282
bool seenM32 = false;
281283
bool seenM64 = false;
282284
bool appendM32 = false;
283285
bool appendM64 = false;
286+
#endif
284287
const char *vers_string = NULL;
285288
bool seen_version_min = false;
286289
bool seen_sysroot_p = false;
@@ -305,6 +308,12 @@ darwin_driver_init (unsigned int *decoded_options_count,
305308
seenPPC = true;
306309
else if (!strcmp ((*decoded_options)[i].arg, "ppc64"))
307310
seenPPC64 = true;
311+
else if (!strcmp ((*decoded_options)[i].arg, "arm64"))
312+
#if !DARWIN_ARM64
313+
seenArm64 = true;
314+
#else
315+
; /* We accept the option, but don't need to act on it. */
316+
#endif
308317
else
309318
error ("this compiler does not support %s",
310319
(*decoded_options)[i].arg);
@@ -318,15 +327,15 @@ darwin_driver_init (unsigned int *decoded_options_count,
318327
--i;
319328
--*decoded_options_count;
320329
break;
321-
330+
#if !DARWIN_ARM64
322331
case OPT_m32:
323332
seenM32 = true;
324333
break;
325334

326335
case OPT_m64:
327336
seenM64 = true;
328337
break;
329-
338+
#endif
330339
case OPT_filelist:
331340
case OPT_framework:
332341
++*decoded_options_count;
@@ -391,6 +400,8 @@ darwin_driver_init (unsigned int *decoded_options_count,
391400
#if DARWIN_X86
392401
if (seenPPC || seenPPC64)
393402
warning (0, "this compiler does not support PowerPC (arch flags ignored)");
403+
else if (seenArm64)
404+
warning (0, "this compiler does not support Arm64 (arch flags ignored)");
394405
if (seenX86)
395406
{
396407
if (seenX86_64 || seenM64)
@@ -410,6 +421,8 @@ darwin_driver_init (unsigned int *decoded_options_count,
410421
#elif DARWIN_PPC
411422
if (seenX86 || seenX86_64)
412423
warning (0, "this compiler does not support X86 (arch flags ignored)");
424+
else if (seenArm64)
425+
warning (0, "this compiler does not support Arm64 (arch flags ignored)");
413426
if (seenPPC)
414427
{
415428
if (seenPPC64 || seenM64)
@@ -426,8 +439,14 @@ darwin_driver_init (unsigned int *decoded_options_count,
426439
else if (! seenM64) /* Add -m64 if the User didn't. */
427440
appendM64 = true;
428441
}
442+
#elif DARWIN_ARM64
443+
if (seenPPC || seenPPC64)
444+
warning (0, "this compiler does not support PowerPC (arch flags ignored)");
445+
if (seenX86 || seenX86_64)
446+
warning (0, "this compiler does not support X86 (arch flags ignored)");
429447
#endif
430448

449+
#if !DARWIN_ARM64
431450
if (appendM32 || appendM64)
432451
{
433452
++*decoded_options_count;
@@ -437,6 +456,7 @@ darwin_driver_init (unsigned int *decoded_options_count,
437456
generate_option (appendM32 ? OPT_m32 : OPT_m64, NULL, 1, CL_DRIVER,
438457
&(*decoded_options)[*decoded_options_count - 1]);
439458
}
459+
#endif
440460

441461
if (! seen_sysroot_p)
442462
{

gcc/config/darwin.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static bool ld_init_term_start_labels = false;
115115
section * darwin_sections[NUM_DARWIN_SECTIONS];
116116

117117
/* While we transition to using in-tests instead of ifdef'd code. */
118-
#if !HAVE_lo_sum
118+
#if !HAVE_lo_sum || DARWIN_ARM64
119119
#define gen_macho_high(m,a,b) (a)
120120
#define gen_macho_low(m,a,b,c) (a)
121121
#endif
@@ -1049,6 +1049,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg)
10491049
return pic_ref;
10501050
}
10511051

1052+
#if !DARWIN_ARM64
10521053
/* Callbacks to output the stub or non-lazy pointers.
10531054
Each works on the item in *SLOT,if it has been used.
10541055
DATA is the FILE* for assembly output.
@@ -1204,6 +1205,7 @@ machopic_finish (FILE *asm_out_file)
12041205
machopic_indirections->traverse_noresize
12051206
<FILE *, machopic_output_indirection> (asm_out_file);
12061207
}
1208+
#endif
12071209

12081210
int
12091211
machopic_operand_p (rtx op)
@@ -2236,6 +2238,8 @@ darwin_emit_except_table_label (FILE *file)
22362238
rtx
22372239
darwin_make_eh_symbol_indirect (rtx orig, bool ARG_UNUSED (pubvis))
22382240
{
2241+
if (DARWIN_ARM64)
2242+
return orig;
22392243
if (DARWIN_PPC == 0 && TARGET_64BIT)
22402244
return orig;
22412245

@@ -3047,7 +3051,12 @@ darwin_file_end (void)
30473051
fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags);
30483052
}
30493053

3054+
#if !DARWIN_ARM64
30503055
machopic_finish (asm_out_file);
3056+
#else
3057+
gcc_checking_assert (!machopic_indirections);
3058+
#endif
3059+
30513060
if (flag_apple_kext)
30523061
{
30533062
/* These sections are only used for kernel code. */

gcc/config/darwin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
4242

4343
#define DARWIN_X86 0
4444
#define DARWIN_PPC 0
45+
#define DARWIN_ARM64 0
4546

4647
/* Suppress g++ attempt to link in the math library automatically. */
4748
#define MATH_LIBRARY ""

0 commit comments

Comments
 (0)