Skip to content

Commit

Permalink
[Darwin] Fix PR87030 and tidy config fragments.
Browse files Browse the repository at this point in the history
We now have a situation with Darwin target permutations for 32b and
64bit cases, with sub-permutations of bi-arch or single-arch only support.

The current scheme of target headers and tmake fragments has become messy
as things have evolved and needs adjustment to fix the PR.

So here we fix the PR and rationalise the headers and tmake fragments
accordingly.

More tidy-ups to follow.

gcc/
	* config.gcc (*-*-darwin*): Don't include CPU t-darwin here.
	(i[34567]86-*-darwin*): Adjust to use biarch files.  Produce
	an error message if i686-darwin configuration is attempted for
	Darwin >= 18.
	(x86_64-*-darwin*): Switch to single multilib for Darwin >= 18.
	(powerpc-*-darwin*): Use biarch files where needed.
	(powerpc64-*-darwin*): Likewise.
	* config/i386/darwin.h (REAL_LIBGCC_SPEC): Revise workaround for
	pr80556 to default to prepending libSystem > Darwin10.
	(DARWIN_ARCH_SPEC, DARWIN_SUBARCH_SPEC): Revise for default single
	arch case.
	* config/i386/darwin32-biarch.h: New.
	* config/i386/darwin64.h: Rename.
	* gcc/config/i386/darwin64-biarch.h: To this.
	* config/i386/t-darwin: Rename.
	* gcc/config/i386/t-darwin32-biarch: To this.
	* config/i386/t-darwin64: Rename.
	* gcc/config/i386/t-darwin64-biarch: To this.
	* config/rs6000/darwin32-biarch.h: New.
	* config/rs6000/darwin64.h: Rename.
	* config/rs6000/darwin64-biarch.h: To this.
	* config/rs6000/darwin7.h (LIB_SPEC): Delete.
	* config/rs6000/darwin8.h: Likewise.
	* config/rs6000/darwin.h (LIB_SPEC): New.
	(DARWIN_ARCH_SPEC, DARWIN_SUBARCH_SPEC): Revise for default single
	arch case.
	* config/rs6000/t-darwin8: Rename.
	* config/rs6000/t-darwin32-biarch: To this.
	* config/rs6000/t-darwin64 Rename.
	* config/rs6000/t-darwin64-biarch: To this.
  • Loading branch information
iains committed Apr 1, 2019
1 parent f43e323 commit 85d8544
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 47 deletions.
38 changes: 27 additions & 11 deletions gcc/config.gcc
Expand Up @@ -647,7 +647,7 @@ x86_cpus="generic intel"
# Common parts for widely ported systems.
case ${target} in
*-*-darwin*)
tmake_file="t-darwin ${cpu_type}/t-darwin"
tmake_file="t-darwin "
tm_file="${tm_file} darwin.h"
case ${target} in
*-*-darwin9*)
Expand Down Expand Up @@ -1479,16 +1479,25 @@ hppa[12]*-*-hpux11*)
dwarf2=no
fi
;;
i[34567]86-*-darwin1[89]*)
echo "Error: 32bit target is not supported after Darwin17" 1>&2
;;
i[34567]86-*-darwin*)
need_64bit_isa=yes
# Baseline choice for a machine that allows m64 support.
with_cpu=${with_cpu:-core2}
tmake_file="${tmake_file} ${cpu_type}/t-darwin32-biarch t-slibgcc"
tm_file="${tm_file} ${cpu_type}/darwin32-biarch.h"
;;
x86_64-*-darwin1[89]* | x86_64-*-darwin2[01]*)
# Only 64b from now
with_cpu=${with_cpu:-core2}
tmake_file="${tmake_file} t-slibgcc"
;;
x86_64-*-darwin*)
with_cpu=${with_cpu:-core2}
tmake_file="${tmake_file} ${cpu_type}/t-darwin64 t-slibgcc"
tm_file="${tm_file} ${cpu_type}/darwin64.h"
tmake_file="${tmake_file} ${cpu_type}/t-darwin64-biarch t-slibgcc"
tm_file="${tm_file} ${cpu_type}/darwin64-biarch.h"
;;
i[34567]86-*-elfiamcu)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/iamcu.h"
Expand Down Expand Up @@ -2386,25 +2395,32 @@ pdp11-*-*)
# extra_headers=
# ;;
powerpc-*-darwin*)
extra_options="${extra_options} rs6000/darwin.opt"
extra_options="${extra_options} ${cpu_type}/darwin.opt"
case ${target} in
*-darwin1[0-9]* | *-darwin[8-9]*)
tmake_file="${tmake_file} rs6000/t-darwin8"
tm_file="${tm_file} rs6000/darwin8.h"
*-darwin1[0-9]* | *-darwin9*)
tmake_file="${tmake_file} ${cpu_type}/t-darwin32-biarch"
tm_file="${tm_file} ${cpu_type}/darwin32-biarch.h"
;;
*-darwin8*)
tmake_file="${tmake_file} ${cpu_type}/t-darwin32-biarch"
tm_file="${tm_file} ${cpu_type}/darwin32-biarch.h"
tm_file="${tm_file} ${cpu_type}/darwin8.h"
;;
*-darwin7*)
tm_file="${tm_file} rs6000/darwin7.h"
tm_file="${tm_file} ${cpu_type}/darwin7.h"
;;
*-darwin[0-6]*)
*-darwin[456]*)
# Earlier - ingle arch, with 32b only
# OS X 10.0, the first edition is Darwin4
;;
esac
tmake_file="${tmake_file} t-slibgcc"
extra_headers=altivec.h
;;
powerpc64-*-darwin*)
extra_options="${extra_options} ${cpu_type}/darwin.opt"
tmake_file="${tmake_file} ${cpu_type}/t-darwin64 t-slibgcc"
tm_file="${tm_file} ${cpu_type}/darwin8.h ${cpu_type}/darwin64.h"
tmake_file="${tmake_file} ${cpu_type}/t-darwin64-biarch t-slibgcc"
tm_file="${tm_file} ${cpu_type}/darwin64-biarch.h"
extra_headers=altivec.h
;;
powerpc*-*-freebsd*)
Expand Down
10 changes: 5 additions & 5 deletions gcc/config/i386/darwin.h
Expand Up @@ -112,22 +112,22 @@ extern int darwin_emit_branch_islands;
" 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

#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
%{mpc80:crtprec80.o%s}" TM_DESTRUCTOR

#define DARWIN_ARCH_SPEC "x86_64"

/* We default to x86_64 for single-arch builds, bi-arch overrides. */
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \
{ "darwin_arch", DARWIN_ARCH_SPEC }, \
{ "darwin_arch", DARWIN_ARCH_SPEC }, \
{ "darwin_crt2", "" }, \
{ "darwin_subarch", DARWIN_SUBARCH_SPEC },
{ "darwin_subarch", DARWIN_ARCH_SPEC },

/* The Darwin assembler mostly follows AT&T syntax. */
#undef ASSEMBLER_DIALECT
Expand Down
32 changes: 32 additions & 0 deletions gcc/config/i386/darwin32-biarch.h
@@ -0,0 +1,32 @@
/* Target definitions for i386 running Darwin.
Copyright (C) 2019 Free Software Foundation, Inc.
Contributed by Apple Computer Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */

#undef DARWIN_ARCH_SPEC
#define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"

#undef DARWIN_SUBARCH_SPEC
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC

#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \
{ "darwin_arch", DARWIN_ARCH_SPEC }, \
{ "darwin_crt2", "" }, \
{ "darwin_subarch", DARWIN_SUBARCH_SPEC },
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 20 additions & 4 deletions gcc/config/rs6000/darwin.h
Expand Up @@ -84,6 +84,23 @@ extern int darwin_emit_branch_islands;

#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128

/* Machine dependent libraries. Include libmx when compiling on
Darwin 7.0 and above, but before libSystem, since the functions are
actually in libSystem but for 7.x compatibility we want them to be
looked for in libmx first---but only do this if 7.x compatibility
is a concern, which it's not in 64-bit mode. Include
libSystemStubs when compiling on (not necessarily for) 8.0 and
above and not 64-bit long double. */

#undef LIB_SPEC
#define LIB_SPEC \
"%{!static: \
%{!mlong-double-64: \
%{pg:%:version-compare(!> 10.5 mmacosx-version-min= -lSystemStubs_profile)} \
%{!pg:%:version-compare(!> 10.5 mmacosx-version-min= -lSystemStubs)}}\
%{!m64:%:version-compare(>< 10.3 10.4 mmacosx-version-min= -lmx)} \
-lSystem \
}"

/* We want -fPIC by default, unless we're using -static to compile for
the kernel or some such. The "-faltivec" option should have been
Expand All @@ -98,11 +115,10 @@ extern int darwin_emit_branch_islands;
%<faltivec %<fno-altivec " \
DARWIN_CC1_SPEC

#define DARWIN_ARCH_SPEC "%{m64:ppc64;:ppc}"
/* Default to PPC for single arch builds. */
#define DARWIN_ARCH_SPEC "ppc"

#define DARWIN_SUBARCH_SPEC " \
%{m64: ppc64} \
%{!m64: \
%{mcpu=601:ppc601; \
mcpu=603:ppc603; \
mcpu=603e:ppc603; \
Expand All @@ -117,7 +133,7 @@ extern int darwin_emit_branch_islands;
mcpu=970:ppc970; \
mcpu=power4:ppc970; \
mcpu=G5:ppc970; \
:ppc}}"
:ppc}"

/* We need to jam the crt to 10.5 for 10.6 (Rosetta) use. */
#undef DARWIN_CRT1_SPEC
Expand Down
49 changes: 49 additions & 0 deletions gcc/config/rs6000/darwin32-biarch.h
@@ -0,0 +1,49 @@
/* Target definitions for PowerPC running Darwin (Mac OS X).
Copyright (C) 2006-2019 Free Software Foundation, Inc.
Contributed by Apple Computer Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */

#undef DARWIN_ARCH_SPEC
#define DARWIN_ARCH_SPEC "%{m64:ppc64;:ppc}"

#undef DARWIN_SUBARCH_SPEC
#define DARWIN_SUBARCH_SPEC " \
%{m64: ppc64} \
%{!m64: \
%{mcpu=601:ppc601; \
mcpu=603:ppc603; \
mcpu=603e:ppc603; \
mcpu=604:ppc604; \
mcpu=604e:ppc604e; \
mcpu=740:ppc750; \
mcpu=750:ppc750; \
mcpu=G3:ppc750; \
mcpu=7400:ppc7400; \
mcpu=G4:ppc7400; \
mcpu=7450:ppc7450; \
mcpu=970:ppc970; \
mcpu=power4:ppc970; \
mcpu=G5:ppc970; \
:ppc}}"

#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \
{ "darwin_arch", DARWIN_ARCH_SPEC }, \
{ "darwin_crt2", DARWIN_CRT2_SPEC }, \
{ "darwin_subarch", DARWIN_SUBARCH_SPEC },
@@ -1,5 +1,5 @@
/* Target definitions for PowerPC running Darwin (Mac OS X).
Copyright (C) 2006-2018 Free Software Foundation, Inc.
/* Target definitions for PowerPC64 running Darwin (Mac OS X).
Copyright (C) 2006-2019 Free Software Foundation, Inc.
Contributed by Apple Computer Inc.
This file is part of GCC.
Expand All @@ -25,8 +25,13 @@
#undef DARWIN_ARCH_SPEC
#define DARWIN_ARCH_SPEC "%{m32:ppc;:ppc64}"

/* Actually, there's really only 970 as an active option. */
#undef DARWIN_SUBARCH_SPEC
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC

#undef DARWIN_CRT2_SPEC
#define DARWIN_CRT2_SPEC ""
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \
{ "darwin_arch", DARWIN_ARCH_SPEC }, \
{ "darwin_crt2", "" }, \
{ "darwin_subarch", DARWIN_SUBARCH_SPEC },
12 changes: 1 addition & 11 deletions gcc/config/rs6000/darwin7.h
Expand Up @@ -17,21 +17,11 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */

/* Machine dependent libraries. Include libmx when compiling for
Darwin 7.0 and above, but before libSystem, since the functions are
actually in libSystem but for 7.x compatibility we want them to be
looked for in libmx first. Include libmx by default because otherwise
libstdc++ isn't usable. */

#undef LIB_SPEC
#define LIB_SPEC "%{!static:\
%:version-compare(!< 10.3 mmacosx-version-min= -lmx)\
-lSystem}"

/* This generation of tools (specifically the archive tool) did not
export weak symbols from the TOC. */
#undef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
#define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 1

/* Default to the last version, with most support for C++. */
#undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.3.9"
14 changes: 2 additions & 12 deletions gcc/config/rs6000/darwin8.h
Expand Up @@ -17,15 +17,5 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */

/* Machine dependent libraries. Include libmx when compiling on
Darwin 7.0 and above, but before libSystem, since the functions are
actually in libSystem but for 7.x compatibility we want them to be
looked for in libmx first---but only do this if 7.x compatibility
is a concern, which it's not in 64-bit mode. Include
libSystemStubs when compiling on (not necessarily for) 8.0 and
above and not 64-bit long double. */

#undef LIB_SPEC
#define LIB_SPEC "%{!static:\
%{!mlong-double-64:%{pg:-lSystemStubs_profile;:-lSystemStubs}} \
%{!m64:%:version-compare(>< 10.3 10.4 mmacosx-version-min= -lmx)} -lSystem}"
#undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.4"
File renamed without changes.
File renamed without changes.

0 comments on commit 85d8544

Please sign in to comment.