+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-06-16 Iain Sandoe <iain@sandoe.co.uk>
* config/darwin.opt (prebind, noprebind, seglinkedit,
of MACHO_SYMBOL_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 */
rtx
machopic_indirect_call_target (rtx target)
{
- if (! darwin_emit_branch_islands)
+ if (! darwin_picsymbol_stubs)
return target;
if (GET_CODE (target) != MEM)
flag_unwind_tables = 0;
flag_asynchronous_unwind_tables = 0;
/* We still need to emit branch islands for kernel context. */
- darwin_emit_branch_islands = true;
+ darwin_picsymbol_stubs = true;
}
if (flag_var_tracking_uninit == 0
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_picsymbol_stubs)
+ {
+ if (darwin_target_linker) {
+ if (strverscmp (darwin_target_linker, MIN_LD64_OMIT_STUBS) < 0)
+ darwin_picsymbol_stubs = true;
+ } else if (generating_for_darwin_version < 9)
+ /* We know no better than to assume the use of an earlier linker. */
+ darwin_picsymbol_stubs = true;
+ }
+ else if (DARWIN_X86 && darwin_picsymbol_stubs && TARGET_64BIT)
+ {
+ inform (input_location,
+ "%<-mpic-symbol-stubs%> is not required for 64b code (ignored)");
+ darwin_picsymbol_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);
_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 PIC 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
Target RejectNegative Report Var(darwin_one_byte_bool)
Set sizeof(bool) to 1.
+mpic-symbol-stubs
+Target Report Var(darwin_picsymbol_stubs) Init(0)
+Force generation of PIC symbol stubs.
+
; Some code-gen may be improved / adjusted if the linker is sufficiently modern.
mtarget-linker=
Target RejectNegative Joined Report Alias(mtarget-linker)
#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_PICSYM_STUBS
+#define TARGET_MACHO_PICSYM_STUBS (darwin_picsymbol_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)
#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE, LABELNO) \
do { \
- if (TARGET_MACHO_BRANCH_ISLANDS \
+ if (TARGET_MACHO_PICSYM_STUBS \
&& MACHOPIC_INDIRECT && !TARGET_64BIT) \
{ \
const char *name = machopic_mcount_stub_name (); \
break;
case SYMBOL_REF:
- if (TARGET_64BIT || ! TARGET_MACHO_BRANCH_ISLANDS)
+ if (TARGET_64BIT || ! TARGET_MACHO_PICSYM_STUBS)
output_addr_const (file, x);
else
{
/* 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_PICSYM_STUBS 0
#define MACHOPIC_ATT_STUB 0
/* (b) Macros defined in config/darwin.h */
#define MACHO_DYNAMIC_NO_PIC_P 0
} \
while (0)
-/* Generate branch islands stubs if this is true. */
-extern int darwin_emit_branch_islands;
+/* Generate pic symbol stubs if this is true. */
+extern int darwin_emit_picsym_stub;
#define SUBTARGET_OVERRIDE_OPTIONS darwin_rs6000_override_options ()
{
const char *name = XSTR (x, 0);
#if TARGET_MACHO
- if (darwin_emit_branch_islands
+ if (darwin_picsymbol_stubs
&& MACHOPIC_INDIRECT
&& machopic_classify_symbol (x) == MACHOPIC_UNDEFINED_FUNCTION)
name = machopic_indirection_name (x, /*stub_p=*/true);
if ((cookie_val & CALL_LONG) != 0
&& GET_CODE (func_desc) == SYMBOL_REF)
{
- if (darwin_emit_branch_islands && TARGET_32BIT)
+ /* FIXME: the longcall opt should not hang off picsymbol stubs. */
+ if (darwin_picsymbol_stubs && TARGET_32BIT)
make_island = true; /* Do nothing yet, retain the CALL_LONG flag. */
else
{