aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/darwin.c
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2019-06-16 16:21:28 +0000
committerIain Sandoe <iains@gcc.gnu.org>2019-06-16 16:21:28 +0000
commitce3a201593d0ed5b606360c064778de34b5b04ef (patch)
treebd7d33e097373aee442013ac23887e1909209af5 /gcc/config/darwin.c
parent4827824f799e15bb28c12482de6c01089fea7abe (diff)
downloadgcc-ce3a201593d0ed5b606360c064778de34b5b04ef.zip
gcc-ce3a201593d0ed5b606360c064778de34b5b04ef.tar.gz
gcc-ce3a201593d0ed5b606360c064778de34b5b04ef.tar.bz2
[Darwin] The need for picsym stubs is dependent on linker used, not OS rev.
For very old toolchains, the compiler generated pic symbol stubs that provide the necessary indirections. We no longer need this (since xcode 3 era) and it's more efficient for the linker to make one stub when it knows a symbol is needed that for us to emit them speculatively in every object. Our current codegen is making the assumption that a specific OS version uses a specific linker version - and therefore the presence of support could be based on the target OS rev. Of course, that's way too simplistic (most likely bogus for cross-toolchains) and we want to make things explict. Since we have detection of the linker version, we can use that directly (A config test for support for stub-less linking might also be feasible but much more involved). Finally, should the user wish to generate code that caters for export to use in an environment with an older toolchain, the generation of stubs can be forced from the command line. In addition to the points above, branch islanding and a long branch opt for PowerPC Darwin has become conflated with the emission of these stubs (which is confusing, and will be rectified in a following patch). 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. From-SVN: r272356
Diffstat (limited to 'gcc/config/darwin.c')
-rw-r--r--gcc/config/darwin.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 17e1801..00fa652 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -78,12 +78,6 @@ along with GCC; see the file COPYING3. If not see
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 */
@@ -790,7 +784,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
rtx
machopic_indirect_call_target (rtx target)
{
- if (! darwin_emit_branch_islands)
+ if (! darwin_picsymbol_stubs)
return target;
if (GET_CODE (target) != MEM)
@@ -3235,7 +3229,7 @@ darwin_override_options (void)
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
@@ -3259,11 +3253,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_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);