From 7f1f88317a25ac2778435a7328d83fb95f9a4530 Mon Sep 17 00:00:00 2001 From: geoffk Date: Sat, 17 Feb 2007 01:47:38 +0000 Subject: [PATCH] * config/darwin.h (LINK_SPEC): Always pass -macosx_version_min to linker. (DARWIN_EXTRA_SPECS): Add %(darwin_minversion). * config/rs6000/darwin.h (SUBTARGET_OVERRIDE_OPTIONS): Just call darwin_rs6000_override_options. (C_COMMON_OVERRIDE_OPTIONS): Expect darwin_macosx_version_min to be non-NULL always. (TARGET_C99_FUNCTIONS): Likewise. (CC1_SPEC): Always pass -mmacosx-version-min to cc1*. (DARWIN_MINVERSION_SPEC): New. * config/rs6000/rs6000.c (darwin_rs6000_override_options): New. * config/i386/darwin.h (CC1_SPEC): Always pass -mmacosx-version-min to cc1*. (DARWIN_MINVERSION_SPEC): New. * config/darwin.opt (mmacosx-version-min): Initialize to non-NULL value. * config/darwin-c.c (darwin_cpp_builtins): Expect darwin_macosx_version_min to be non-NULL always. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122067 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 19 +++++++++++ gcc/config/darwin-c.c | 5 ++- gcc/config/darwin.h | 6 ++-- gcc/config/darwin.opt | 6 +++- gcc/config/i386/darwin.h | 4 +++ gcc/config/rs6000/darwin.h | 84 +++++++++++----------------------------------- gcc/config/rs6000/rs6000.c | 55 ++++++++++++++++++++++++++++++ 7 files changed, 108 insertions(+), 71 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e454372..404a138 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,24 @@ 2007-02-16 Geoffrey Keating + * config/darwin.h (LINK_SPEC): Always pass -macosx_version_min + to linker. + (DARWIN_EXTRA_SPECS): Add %(darwin_minversion). + * config/rs6000/darwin.h (SUBTARGET_OVERRIDE_OPTIONS): Just call + darwin_rs6000_override_options. + (C_COMMON_OVERRIDE_OPTIONS): Expect + darwin_macosx_version_min to be non-NULL always. + (TARGET_C99_FUNCTIONS): Likewise. + (CC1_SPEC): Always pass -mmacosx-version-min to cc1*. + (DARWIN_MINVERSION_SPEC): New. + * config/rs6000/rs6000.c (darwin_rs6000_override_options): New. + * config/i386/darwin.h (CC1_SPEC): Always pass -mmacosx-version-min + to cc1*. + (DARWIN_MINVERSION_SPEC): New. + * config/darwin.opt (mmacosx-version-min): Initialize to non-NULL + value. + * config/darwin-c.c (darwin_cpp_builtins): Expect + darwin_macosx_version_min to be non-NULL always. + * config/rs6000/rs6000.c: Clean up trailing whitespace. 2007-02-16 Uros Bizjak diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 88ce9ef..eefd5f6 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -616,7 +616,6 @@ darwin_cpp_builtins (cpp_reader *pfile) to be defined and won't work if it isn't. */ builtin_define_with_value ("__APPLE_CC__", "1", false); - if (darwin_macosx_version_min) - builtin_define_with_value ("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", - version_as_macro(), false); + builtin_define_with_value ("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", + version_as_macro(), false); } diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 6d7f5b9..7070072 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -297,8 +297,7 @@ extern GTY(()) int darwin_ms_struct; %{headerpad_max_install_names*} \ %{Zimage_base*:-image_base %*} \ %{Zinit*:-init %*} \ - %{mmacosx-version-min=*:-macosx_version_min %*} \ - %{!mmacosx-version-min=*:%{shared-libgcc:-macosx_version_min 10.3}} \ + -macosx_version_min %(darwin_minversion) \ %{nomultidefs} \ %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \ %{Zmultiply_defined*:-multiply_defined %*} \ @@ -387,7 +386,8 @@ extern GTY(()) int darwin_ms_struct; #define DARWIN_EXTRA_SPECS \ { "darwin_crt1", DARWIN_CRT1_SPEC }, \ - { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, + { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \ + { "darwin_minversion", DARWIN_MINVERSION_SPEC }, #define DARWIN_DYLIB1_SPEC \ "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \ diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt index ef89b78..28dd1c4 100644 --- a/gcc/config/darwin.opt +++ b/gcc/config/darwin.opt @@ -23,8 +23,12 @@ mfix-and-continue Target Report Var(darwin_fix_and_continue) Generate code suitable for fast turn around debugging +; The Init here is for the convenience of GCC developers, so that +; cc1 and cc1plus don't crash if no -mmacosx-version-min is passed. The +; driver will always pass a -mmacosx-version-min, so in normal use +; the Init is never used. mmacosx-version-min= -Target Joined Report Var(darwin_macosx_version_min) +Target Joined Report Var(darwin_macosx_version_min) Init("10.1") The earliest MacOS X version on which this program will run mone-byte-bool diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index 109fe79..c00a791 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -74,6 +74,7 @@ Boston, MA 02110-1301, USA. */ #undef CC1_SPEC #define CC1_SPEC "%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \ + -mmacosx-version-min=%(darwin_minversion) \ %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}" #undef ASM_SPEC @@ -82,6 +83,9 @@ Boston, MA 02110-1301, USA. */ #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}" #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC +/* Determine a minimum version based on compiler options. */ +#define DARWIN_MINVERSION_SPEC "10.4" + #undef SUBTARGET_EXTRA_SPECS #define SUBTARGET_EXTRA_SPECS \ DARWIN_EXTRA_SPECS \ diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 158b1be..9a000c8 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -55,74 +55,23 @@ /* Translate config/rs6000/darwin.opt to config/darwin.h. */ #define TARGET_DYNAMIC_NO_PIC (TARGET_MACHO_DYNAMIC_NO_PIC) -#define TARGET_OS_CPP_BUILTINS() \ - do \ - { \ - if (!TARGET_64BIT) builtin_define ("__ppc__"); \ - if (TARGET_64BIT) builtin_define ("__ppc64__"); \ - builtin_define ("__POWERPC__"); \ - builtin_define ("__NATURAL_ALIGNMENT__"); \ - darwin_cpp_builtins (pfile); \ - } \ +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + if (!TARGET_64BIT) builtin_define ("__ppc__"); \ + if (TARGET_64BIT) builtin_define ("__ppc64__"); \ + builtin_define ("__POWERPC__"); \ + builtin_define ("__NATURAL_ALIGNMENT__"); \ + darwin_cpp_builtins (pfile); \ + } \ while (0) - -#define SUBTARGET_OVERRIDE_OPTIONS \ -do { \ - /* The Darwin ABI always includes AltiVec, can't be (validly) turned \ - off. */ \ - rs6000_altivec_abi = 1; \ - TARGET_ALTIVEC_VRSAVE = 1; \ - if (DEFAULT_ABI == ABI_DARWIN) \ - { \ - if (MACHO_DYNAMIC_NO_PIC_P) \ - { \ - if (flag_pic) \ - warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC"); \ - flag_pic = 0; \ - } \ - else if (flag_pic == 1) \ - { \ - flag_pic = 2; \ - } \ - } \ - if (TARGET_64BIT && ! TARGET_POWERPC64) \ - { \ - target_flags |= MASK_POWERPC64; \ - warning (0, "-m64 requires PowerPC64 architecture, enabling"); \ - } \ - if (flag_mkernel) \ - { \ - rs6000_default_long_calls = 1; \ - target_flags |= MASK_SOFT_FLOAT; \ - } \ - \ - /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes \ - Altivec. */ \ - if (!flag_mkernel && !flag_apple_kext \ - && TARGET_64BIT \ - && ! (target_flags_explicit & MASK_ALTIVEC)) \ - target_flags |= MASK_ALTIVEC; \ - \ - /* Unless the user (not the configurer) has explicitly overridden \ - it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to \ - G4 unless targetting the kernel. */ \ - if (!flag_mkernel \ - && !flag_apple_kext \ - && darwin_macosx_version_min \ - && strverscmp (darwin_macosx_version_min, "10.5") >= 0 \ - && ! (target_flags_explicit & MASK_ALTIVEC) \ - && ! rs6000_select[1].string) \ - { \ - target_flags |= MASK_ALTIVEC; \ - } \ -} while(0) +#define SUBTARGET_OVERRIDE_OPTIONS darwin_rs6000_override_options () #define C_COMMON_OVERRIDE_OPTIONS do { \ /* On powerpc, __cxa_get_exception_ptr is available starting in the \ 10.4.6 libstdc++.dylib. */ \ - if ((! darwin_macosx_version_min \ - || strverscmp (darwin_macosx_version_min, "10.4.6") < 0) \ + if (strverscmp (darwin_macosx_version_min, "10.4.6") < 0 \ && flag_use_cxa_get_exception_ptr == 2) \ flag_use_cxa_get_exception_ptr = 0; \ if (flag_mkernel) \ @@ -144,6 +93,7 @@ do { \ #define CC1_SPEC "\ %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} \ %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\ + -mmacosx-version-min=%(darwin_minversion) \ %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}}" #define DARWIN_ARCH_SPEC "%{m64:ppc64;:ppc}" @@ -171,6 +121,13 @@ do { \ #define DARWIN_CRT2_SPEC \ "%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}" +/* Determine a minimum version based on compiler options. */ +#define DARWIN_MINVERSION_SPEC \ + "%{mmacosx-version-min=*:%*; \ + m64:10.4; \ + shared-libgcc:10.3; \ + :10.1}" + #undef SUBTARGET_EXTRA_SPECS #define SUBTARGET_EXTRA_SPECS \ DARWIN_EXTRA_SPECS \ @@ -473,8 +430,7 @@ do { \ #undef TARGET_C99_FUNCTIONS #define TARGET_C99_FUNCTIONS \ (TARGET_64BIT \ - || (darwin_macosx_version_min \ - && strverscmp (darwin_macosx_version_min, "10.3") >= 0)) + || strverscmp (darwin_macosx_version_min, "10.3") >= 0) /* When generating kernel code or kexts, we don't use Altivec by default, as kernel code doesn't save/restore those registers. */ diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index feecb45..7666909 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1169,6 +1169,61 @@ rs6000_init_hard_regno_mode_ok (void) rs6000_hard_regno_mode_ok_p[m][r] = true; } +#if TARGET_MACHO +/* The Darwin version of SUBTARGET_OVERRIDE_OPTIONS. */ + +static void +darwin_rs6000_override_options (void) +{ + /* The Darwin ABI always includes AltiVec, can't be (validly) turned + off. */ + rs6000_altivec_abi = 1; + TARGET_ALTIVEC_VRSAVE = 1; + if (DEFAULT_ABI == ABI_DARWIN) + { + if (MACHO_DYNAMIC_NO_PIC_P) + { + if (flag_pic) + warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC"); + flag_pic = 0; + } + else if (flag_pic == 1) + { + flag_pic = 2; + } + } + if (TARGET_64BIT && ! TARGET_POWERPC64) + { + target_flags |= MASK_POWERPC64; + warning (0, "-m64 requires PowerPC64 architecture, enabling"); + } + if (flag_mkernel) + { + rs6000_default_long_calls = 1; + target_flags |= MASK_SOFT_FLOAT; + } + + /* Make -m64 imply -maltivec. Darwin's 64-bit ABI includes + Altivec. */ + if (!flag_mkernel && !flag_apple_kext + && TARGET_64BIT + && ! (target_flags_explicit & MASK_ALTIVEC)) + target_flags |= MASK_ALTIVEC; + + /* Unless the user (not the configurer) has explicitly overridden + it with -mcpu=G3 or -mno-altivec, then 10.5+ targets default to + G4 unless targetting the kernel. */ + if (!flag_mkernel + && !flag_apple_kext + && strverscmp (darwin_macosx_version_min, "10.5") >= 0 + && ! (target_flags_explicit & MASK_ALTIVEC) + && ! rs6000_select[1].string) + { + target_flags |= MASK_ALTIVEC; + } +} +#endif + /* If not otherwise specified by a target, make 'long double' equivalent to 'double'. */ -- 2.7.4