aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorIain Sandoe <iain@codesourcery.com>2016-11-27 15:07:22 +0000
committerIain Sandoe <iains@gcc.gnu.org>2016-11-27 15:07:22 +0000
commitb410cf1dc056aab195c5408871ffca932df8a78a (patch)
treedc142613e84e7693a450028b7c1073978b9092b4 /gcc/config
parent03f82a6a634ddfa5828843b647c896968aee3702 (diff)
downloadgcc-b410cf1dc056aab195c5408871ffca932df8a78a.zip
gcc-b410cf1dc056aab195c5408871ffca932df8a78a.tar.gz
gcc-b410cf1dc056aab195c5408871ffca932df8a78a.tar.bz2
[Darwin] fix PR67710 by updating 'as' specs to handle newer assembler versions.
A/ Newer versions of ld64 check the min_version command, and newer versions of the system assembler inserts this in response to "-mmacosx-version-min=" on the assembler line. Unless one makes sensible versions, some object is bound to conflict. B/ Additionally, there's a difference in behaviour between "as" and "ld" when presented with xx.yy.zz (ld truncates to xx.yy, as doesn't); net result is that one needs to pass a truncated version to "as". So (if the assembler supports minversion commands) (a) provide a truncated minversion (as asm_macosx_version_min, which is a driver-only var). (b) pass this to "as" (c) Update tests to determine 'HAVE_AS_MMACOSX_VERSION_MIN_OPTION' (Rainer's patch) (d) For some reason the testcases are "run" (it's not obvious they need to be, they are checking compile-time issues) - anyway, to preserve the status quo, I've left them as exec. However, the minimum version that can be code-gened for is target-dependent (there are no released x86 versions before 10.4, for example). To avoid conflicts where the "as" is assuming some minimum, I've set the testversion to 10.5 (which is supported by all the archs we have) (e) We need to ensure that libgcc and crts are generated with a sufficiently old minversion not to conflict. gcc/ 2016-11-27 Iain Sandoe <iain@codesourcery.com> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> PR target/67710 * config.in: Regenerate * config/darwin-driver.c (darwin_driver_init): Emit a version string for the assembler. * config/darwin.h(ASM_MMACOSX_VERSION_MIN_SPEC): New, new tests. * config/darwin.opt(asm_macosx_version_min): New. * config/i386/darwin.h: Handle ASM_MMACOSX_VERSION_MIN_SPEC. * configure: Regenerate * configure.ac: Check for mmacosx-version-min handling. gcc/testsuite/ 2016-11-27 Iain Sandoe <iain@codesourcery.com> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> Dominique d'Humieres <dominiq@lps.ens.fr> PR target/67710 * gcc.dg/darwin-minversion-1.c: Update min version check. * gcc.dg/darwin-minversion-2.c: Likewise. * gcc.dg/darwin-minversion-3.c: Likewise. libgcc/ 2016-11-27 Iain Sandoe <iain@codesourcery.com> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> PR target/67710 * config/t-darwin: Default builds to 10.5 codegen. Co-Authored-By: Dominique d'Humieres <dominiq@lps.ens.fr> Co-Authored-By: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> From-SVN: r242898
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/darwin-driver.c28
-rw-r--r--gcc/config/darwin.h21
-rw-r--r--gcc/config/darwin.opt3
-rw-r--r--gcc/config/i386/darwin.h5
4 files changed, 52 insertions, 5 deletions
diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c
index db8d72c..f80c9ed 100644
--- a/gcc/config/darwin-driver.c
+++ b/gcc/config/darwin-driver.c
@@ -73,7 +73,8 @@ darwin_find_version_from_kernel (void)
component. */
if (major_vers - 4 <= 4)
/* On 10.4 and earlier, the old linker is used which does not
- support three-component system versions. */
+ support three-component system versions.
+ FIXME: we should not assume this - a newer linker could be used. */
asprintf (&new_flag, "10.%d", major_vers - 4);
else
asprintf (&new_flag, "10.%d.%s", major_vers - 4, minor_vers);
@@ -294,4 +295,29 @@ darwin_driver_init (unsigned int *decoded_options_count,
&(*decoded_options)[*decoded_options_count - 1]);
}
}
+ /* Create and push the major version for assemblers that need it. */
+ if (vers_string != NULL)
+ {
+ char *asm_major = NULL;
+ char *first_period = strchr(vers_string, '.');
+ if (first_period != NULL)
+ {
+ char *second_period = strchr(first_period+1, '.');
+ if (second_period != NULL)
+ asm_major = xstrndup (vers_string, second_period-vers_string);
+ else
+ asm_major = xstrdup (vers_string);
+ }
+ /* Else we appear to have a weird macosx version with no major number.
+ Punt on this for now. */
+ if (asm_major != NULL)
+ {
+ ++*decoded_options_count;
+ *decoded_options = XRESIZEVEC (struct cl_decoded_option,
+ *decoded_options,
+ *decoded_options_count);
+ generate_option (OPT_asm_macosx_version_min_, asm_major, 1, CL_DRIVER,
+ &(*decoded_options)[*decoded_options_count - 1]);
+ }
+ }
}
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 79fc506..374034e 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -399,10 +399,27 @@ extern GTY(()) int darwin_ms_struct;
%:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \
%{fgnu-tm: -lcrttms.o}"
-/* Default Darwin ASM_SPEC, very simple. */
+#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION
+/* Emit macosx version (but only major). */
+#define ASM_MMACOSX_VERSION_MIN_SPEC \
+ " %{asm_macosx_version_min=*: -mmacosx-version-min=%*} %<asm_macosx_version_min=*"
+#else
+#define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=*"
+#endif
+
+/* When we detect that we're cctools or llvm as, we need to insert the right
+ additional options. */
+#if HAVE_GNU_AS
+#define ASM_OPTIONS ""
+#else
+#define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
+#endif
+
+/* Default Darwin ASM_SPEC, very simple. */
#define ASM_SPEC "-arch %(darwin_arch) \
+ " ASM_OPTIONS " \
%{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
- %{static}"
+ %{static}" ASM_MMACOSX_VERSION_MIN_SPEC
/* Default ASM_DEBUG_SPEC. Darwin's as cannot currently produce dwarf
debugging data. */
diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt
index 7f2e394..25459e0 100644
--- a/gcc/config/darwin.opt
+++ b/gcc/config/darwin.opt
@@ -37,6 +37,9 @@ Driver RejectNegative Separate
arch_errors_fatal
Driver Alias(Zarch_errors_fatal)
+asm_macosx_version_min=
+Driver RejectNegative Joined
+
bind_at_load
Driver Alias(Zbind_at_load)
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index c10ceff..705fdf2 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -112,8 +112,9 @@ extern int darwin_emit_branch_islands;
DARWIN_CC1_SPEC
#undef ASM_SPEC
-#define ASM_SPEC "-arch %(darwin_arch) -force_cpusubtype_ALL \
- %{static}"
+#define ASM_SPEC "-arch %(darwin_arch) \
+ " ASM_OPTIONS " -force_cpusubtype_ALL \
+ %{static}" ASM_MMACOSX_VERSION_MIN_SPEC
#define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC