diff options
-rw-r--r-- | gcc/ChangeLog | 36 | ||||
-rw-r--r-- | gcc/config/darwin.c | 38 | ||||
-rw-r--r-- | gcc/config/darwin.h | 6 | ||||
-rw-r--r-- | gcc/config/darwin.opt | 4 | ||||
-rw-r--r-- | gcc/config/i386/darwin.h | 30 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 2 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 2 | ||||
-rw-r--r-- | gcc/config/rs6000/darwin.h | 3 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/stubify-1.mm | 2 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/stubify-2.mm | 2 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/stubify-1.m | 2 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/stubify-2.m | 2 |
14 files changed, 103 insertions, 40 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c3eea050d30..f343586ceab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,42 @@ 2019-11-01 Iain Sandoe <iain@sandoe.co.uk> Backport from mainline + 2019-08-13 Iain Sandoe <iain@sandoe.co.uk> + + * config/darwin.c (machopic_indirect_call_target): Rename symbol stub + flag. + (darwin_override_options): Likewise. + * config/darwin.h: Likewise. + * config/darwin.opt: Likewise. + * config/i386/i386.c (output_pic_addr_const): Likewise. + * config/rs6000/darwin.h: Likewise. + * config/rs6000/rs6000.c (rs6000_call_darwin_1): Likewise. + * config/i386/darwin.h (TARGET_MACHO_PICSYM_STUBS): Rename to ... + ... this TARGET_MACHO_SYMBOL_STUBS. + (FUNCTION_PROFILER):Likewise. + * config/i386/i386.h: Likewise. + + Backport from mainline + 2019-06-16 Iain Sandoe <iain@sandoe.co.uk> + + * config/darwin.c (machopic_indirect_call_target): Use renamed + darwin_picsymbol_stubs to decide on output. + (darwin_override_options): Handle darwin_picsymbol_stubs. + * config/darwin.h (MIN_LD64_OMIT_STUBS): New. + (LD64_VERSION): Revise default. + * config/darwin.opt: (mpic-symbol-stubs): New option. + (darwin_picsymbol_stubs): New variable. + * config/i386/darwin.h (TARGET_MACHO_BRANCH_ISLANDS): + rename to TARGET_MACHO_PICSYM_STUBS. + * config/i386/i386.c (output_pic_addr_const): Likewise. + * config/i386/i386.h Likewise. + * config/rs6000/darwin.h: Likewise. + * config/rs6000/rs6000.c (rs6000_call_darwin_1): Use renamed + darwin_picsymbol_stubs. + +2019-11-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline 2019-06-28 Iain Sandoe <iain@sandoe.co.uk> * config.gcc (powerpc-*-darwin*, powerpc64-*-darwin*): Remove diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 541f4589465..ba0506cf353 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -74,12 +74,6 @@ along with GCC; see the file COPYING3. If not see of MACHO_SYMBOL_FLAG_STATIC for the code that handles @code{static} symbol indirection. */ -/* For darwin >= 9 (OSX 10.5) the linker is capable of making the necessary - branch islands and we no longer need to emit darwin stubs. - However, if we are generating code for earlier systems (or for use in the - kernel) the stubs might still be required, and this will be set true. */ -int darwin_emit_branch_islands = false; - typedef struct GTY(()) cdtor_record { rtx symbol; int priority; /* [con/de]structor priority */ @@ -806,7 +800,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg) rtx machopic_indirect_call_target (rtx target) { - if (! darwin_emit_branch_islands) + if (! darwin_symbol_stubs) return target; if (GET_CODE (target) != MEM) @@ -3306,11 +3300,31 @@ darwin_override_options (void) flag_pic = 2; } - /* It is assumed that branch island stubs are needed for earlier systems. */ - if (generating_for_darwin_version < 9) - darwin_emit_branch_islands = true; - else - emit_aligned_common = true; /* Later systems can support aligned common. */ + /* Linkers >= ld64-62.1 (at least) are capable of making the necessary PIC + indirections and we no longer need to emit pic symbol stubs. + However, if we are generating code for earlier ones (or for use in the + kernel) the stubs might still be required, and this will be set true. + If the user sets it on or off - then that takes precedence. */ + + if (!global_options_set.x_darwin_symbol_stubs) + { + if (darwin_target_linker) { + if (strverscmp (darwin_target_linker, MIN_LD64_OMIT_STUBS) < 0) + darwin_symbol_stubs = true; + } else if (generating_for_darwin_version < 9) + /* We know no better than to assume the use of an earlier linker. */ + darwin_symbol_stubs = true; + } + else if (DARWIN_X86 && darwin_symbol_stubs && TARGET_64BIT) + { + inform (input_location, + "%<-msymbol-stubs%> is not required for 64b code (ignored)"); + darwin_symbol_stubs = false; + } + + if (generating_for_darwin_version >= 9) + /* Later systems can support aligned common. */ + emit_aligned_common = true; /* The c_dialect...() macros are not available to us here. */ darwin_running_cxx = (strstr (lang_hooks.name, "C++") != 0); diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 5b2eb97d432..b83e36aeecd 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -1016,8 +1016,12 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); _tested_ version known to support this so far. */ #define MIN_LD64_NO_COAL_SECTS "236.4" +/* From at least version 62.1, ld64 can build symbol indirection stubs as + needed, and there is no need for the compiler to emit them. */ +#define MIN_LD64_OMIT_STUBS "85.2" + #ifndef LD64_VERSION -#define LD64_VERSION "85.2" +#define LD64_VERSION "62.1" #else #define DEF_LD64 LD64_VERSION #endif diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt index 0df8fe4fc56..018cb2cadcf 100644 --- a/gcc/config/darwin.opt +++ b/gcc/config/darwin.opt @@ -75,6 +75,10 @@ mone-byte-bool Target RejectNegative Report Var(darwin_one_byte_bool) Set sizeof(bool) to 1. +msymbol-stubs +Target Report Var(darwin_symbol_stubs) Init(0) +Force generation of external symbol indirection stubs. + ; Some code-gen may be improved / adjusted if the linker is sufficiently modern. mtarget-linker= Target RejectNegative Joined Report Alias(mtarget-linker) diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index f0d3cd1d338..234e892e6ba 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -89,14 +89,12 @@ along with GCC; see the file COPYING3. If not see #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 32 -/* Generate branch islands stubs if this is true. */ -extern int darwin_emit_branch_islands; - -#undef TARGET_MACHO_BRANCH_ISLANDS -#define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands +/* Generate pic symbol indirection stubs if this is true. */ +#undef TARGET_MACHO_SYMBOL_STUBS +#define TARGET_MACHO_SYMBOL_STUBS (darwin_symbol_stubs) /* For compatibility with OSX system tools, use the new style of pic stub - if this is set. */ + if this is set (default). */ #undef MACHOPIC_ATT_STUB #define MACHOPIC_ATT_STUB (darwin_macho_att_stub) @@ -241,16 +239,16 @@ extern int darwin_emit_branch_islands; /* Darwin profiling -- call mcount. */ #undef FUNCTION_PROFILER #define FUNCTION_PROFILER(FILE, LABELNO) \ - do { \ - if (TARGET_MACHO_BRANCH_ISLANDS \ - && MACHOPIC_INDIRECT && !TARGET_64BIT) \ - { \ - const char *name = machopic_mcount_stub_name (); \ - fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \ - machopic_validate_stub_or_non_lazy_ptr (name); \ - } \ - else fprintf (FILE, "\tcall mcount\n"); \ - } while (0) + do { \ + if (TARGET_MACHO_SYMBOL_STUBS \ + && MACHOPIC_INDIRECT && !TARGET_64BIT) \ + { \ + const char *name = machopic_mcount_stub_name (); \ + fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \ + machopic_validate_stub_or_non_lazy_ptr (name); \ + } \ + else fprintf (FILE, "\tcall mcount\n"); \ + } while (0) #define C_COMMON_OVERRIDE_OPTIONS \ do { \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 97bbb2477d7..de71f56be6b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -17394,7 +17394,7 @@ output_pic_addr_const (FILE *file, rtx x, int code) break; case SYMBOL_REF: - if (TARGET_64BIT || ! TARGET_MACHO_BRANCH_ISLANDS) + if (TARGET_64BIT || ! TARGET_MACHO_SYMBOL_STUBS) output_addr_const (file, x); else { diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 0fe4c8b2caa..8e31c30787d 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -590,7 +590,7 @@ extern tree x86_mfence; /* Replace MACH-O, ifdefs by in-line tests, where possible. (a) Macros defined in config/i386/darwin.h */ #define TARGET_MACHO 0 -#define TARGET_MACHO_BRANCH_ISLANDS 0 +#define TARGET_MACHO_SYMBOL_STUBS 0 #define MACHOPIC_ATT_STUB 0 /* (b) Macros defined in config/darwin.h */ #define MACHO_DYNAMIC_NO_PIC_P 0 diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 8f4f6e7d61c..58a2b811ea7 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -75,9 +75,6 @@ } \ while (0) -/* Generate branch islands stubs if this is true. */ -extern int darwin_emit_branch_islands; - #define SUBTARGET_OVERRIDE_OPTIONS darwin_rs6000_override_options () #define C_COMMON_OVERRIDE_OPTIONS do { \ diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 93d7c714862..af0c7ce1656 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24096,7 +24096,7 @@ print_operand (FILE *file, rtx x, int code) { const char *name = XSTR (x, 0); #if TARGET_MACHO - if (darwin_emit_branch_islands + if (darwin_symbol_stubs && MACHOPIC_INDIRECT && machopic_classify_symbol (x) == MACHOPIC_UNDEFINED_FUNCTION) name = machopic_indirection_name (x, /*stub_p=*/true); @@ -36025,7 +36025,7 @@ output_call (rtx_insn *insn, rtx *operands, int dest_operand_number, int cookie_operand_number) { static char buf[256]; - if (darwin_emit_branch_islands + if (darwin_symbol_stubs && GET_CODE (operands[dest_operand_number]) == SYMBOL_REF && (INTVAL (operands[cookie_operand_number]) & CALL_LONG)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b93a8cce8de..54690a22d33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,16 @@ 2019-11-01 Iain Sandoe <iain@sandoe.co.uk> Backport from mainline. + 2019-08-13 Iain Sandoe <iain@sandoe.co.uk> + + * obj-c++.dg/stubify-1.mm: Rename symbol stub option. + * obj-c++.dg/stubify-2.mm: Likewise. + * objc.dg/stubify-1.m: Likewise. + * objc.dg/stubify-2.m: Likewise. + +2019-11-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. 2019-05-15 Iain Sandoe <iain@sandoe.co.uk> * lib/target-supports.exp diff --git a/gcc/testsuite/obj-c++.dg/stubify-1.mm b/gcc/testsuite/obj-c++.dg/stubify-1.mm index c2355437afc..46ce3fb8158 100644 --- a/gcc/testsuite/obj-c++.dg/stubify-1.mm +++ b/gcc/testsuite/obj-c++.dg/stubify-1.mm @@ -4,7 +4,7 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-Os -mdynamic-no-pic -fno-exceptions -mmacosx-version-min=10.4" } */ +/* { dg-options "-Os -mdynamic-no-pic -fno-exceptions -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; diff --git a/gcc/testsuite/obj-c++.dg/stubify-2.mm b/gcc/testsuite/obj-c++.dg/stubify-2.mm index a9f66cac5d2..dd88974e259 100644 --- a/gcc/testsuite/obj-c++.dg/stubify-2.mm +++ b/gcc/testsuite/obj-c++.dg/stubify-2.mm @@ -4,7 +4,7 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4" } */ +/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; diff --git a/gcc/testsuite/objc.dg/stubify-1.m b/gcc/testsuite/objc.dg/stubify-1.m index 91bf73a14f7..97d5b598380 100644 --- a/gcc/testsuite/objc.dg/stubify-1.m +++ b/gcc/testsuite/objc.dg/stubify-1.m @@ -4,7 +4,7 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-Os -mdynamic-no-pic -mmacosx-version-min=10.4" } */ +/* { dg-options "-Os -mdynamic-no-pic -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; diff --git a/gcc/testsuite/objc.dg/stubify-2.m b/gcc/testsuite/objc.dg/stubify-2.m index eaf4b964e4b..a07992a5a9e 100644 --- a/gcc/testsuite/objc.dg/stubify-2.m +++ b/gcc/testsuite/objc.dg/stubify-2.m @@ -4,7 +4,7 @@ /* { dg-do compile { target powerpc*-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4" } */ +/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; |