Commit 45c3fea9 by Iain Sandoe Committed by Iain Sandoe

Darwin - Tidy mmacosx-version-min code and specs.

gcc/

	* config/darwin-driver.c (darwin_default_min_version): Refactor code.
	(darwin_driver_init): Note a version-min when provided on the c/l.
	* config/darwin.h (%darwin_minversion): Remove.
	* config/i386/darwin.h: Likewise.
	* config/rs6000/darwin.h: Likewise.
	* config/darwin.opt (mmacosx-version-min=): Use the configured default, rather than
	an arbitrary constant.

From-SVN: r228944
parent efd40fc4
2015-10-18 Iain Sandoe <iain@codesourcery.com> 2015-10-18 Iain Sandoe <iain@codesourcery.com>
* config/darwin-driver.c (darwin_default_min_version): Refactor code.
(darwin_driver_init): Note a version-min when provided on the c/l.
* config/darwin.h (%darwin_minversion): Remove.
* config/i386/darwin.h: Likewise.
* config/rs6000/darwin.h: Likewise.
* config/darwin.opt (mmacosx-version-min=): Use the configured default,
rather than an arbitrary constant.
2015-10-18 Iain Sandoe <iain@codesourcery.com>
* config/darwin-driver.c (darwin_driver_init): Handle '-arch' for * config/darwin-driver.c (darwin_driver_init): Handle '-arch' for
PPC, detect conflicts between -arch and multilib settings. Detect PPC, detect conflicts between -arch and multilib settings. Detect
and warn about conflicts between multiple -arch definitions. and warn about conflicts between multiple -arch definitions.
...@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#include "config.h" #include "config.h"
#include "libiberty.h"
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "tm.h" #include "tm.h"
...@@ -96,73 +97,36 @@ darwin_find_version_from_kernel (void) ...@@ -96,73 +97,36 @@ darwin_find_version_from_kernel (void)
included in tm.h). This may be overidden by setting the flag explicitly included in tm.h). This may be overidden by setting the flag explicitly
(or by the MACOSX_DEPLOYMENT_TARGET environment). */ (or by the MACOSX_DEPLOYMENT_TARGET environment). */
static void static const char *
darwin_default_min_version (unsigned int *decoded_options_count, darwin_default_min_version (void)
struct cl_decoded_option **decoded_options)
{ {
const unsigned int argc = *decoded_options_count; /* Try to retrieve the deployment target from the environment. */
struct cl_decoded_option *const argv = *decoded_options; const char *new_flag = getenv ("MACOSX_DEPLOYMENT_TARGET");
unsigned int i;
const char *new_flag;
/* If the command-line is empty, just return. */
if (argc <= 1)
return;
/* Don't do this if the user specified -mmacosx-version-min= or
-mno-macosx-version-min. */
for (i = 1; i < argc; i++)
if (argv[i].opt_index == OPT_mmacosx_version_min_)
return;
/* Retrieve the deployment target from the environment and insert
it as a flag. */
{
const char * macosx_deployment_target;
macosx_deployment_target = getenv ("MACOSX_DEPLOYMENT_TARGET");
if (macosx_deployment_target
/* Apparently, an empty string for MACOSX_DEPLOYMENT_TARGET means
"use the default". Or, possibly "use 10.1". We choose
to ignore the environment variable, as if it was never set. */
&& macosx_deployment_target[0])
{
++*decoded_options_count;
*decoded_options = XNEWVEC (struct cl_decoded_option,
*decoded_options_count);
(*decoded_options)[0] = argv[0];
generate_option (OPT_mmacosx_version_min_, macosx_deployment_target,
1, CL_DRIVER, &(*decoded_options)[1]);
memcpy (*decoded_options + 2, argv + 1,
(argc - 1) * sizeof (struct cl_decoded_option));
return;
}
}
/* Apparently, an empty string for MACOSX_DEPLOYMENT_TARGET means
"use the default". Or, possibly "use 10.1". We choose
to ignore the environment variable, as if it was never set. */
if (new_flag == NULL || new_flag[0] == 0)
#ifndef CROSS_DIRECTORY_STRUCTURE #ifndef CROSS_DIRECTORY_STRUCTURE
/* Try to find the version from the kernel, if we fail - we print a
/* Try to find the version from the kernel, if we fail - we print a message message and give up. */
and give up. */ new_flag = darwin_find_version_from_kernel ();
new_flag = darwin_find_version_from_kernel ();
if (!new_flag)
return;
#else #else
/* For cross-compilers, default to a minimum version determined by
/* For cross-compilers, default to the target OS version. */ the configuration. */
new_flag = DEF_MIN_OSX_VERSION; new_flag = DEF_MIN_OSX_VERSION;
#endif /* CROSS_DIRECTORY_STRUCTURE */ #endif /* CROSS_DIRECTORY_STRUCTURE */
/* Add the new flag. */ if (new_flag != NULL)
++*decoded_options_count; {
*decoded_options = XNEWVEC (struct cl_decoded_option, size_t len = strlen (new_flag);
*decoded_options_count); if (len > 128) { /* Arbitrary limit, number should be like xx.yy.zz */
(*decoded_options)[0] = argv[0]; warning (0, "couldn%'t understand version %s\n", new_flag);
generate_option (OPT_mmacosx_version_min_, new_flag, return NULL;
1, CL_DRIVER, &(*decoded_options)[1]); }
memcpy (*decoded_options + 2, argv + 1, new_flag = xstrndup (new_flag, len);
(argc - 1) * sizeof (struct cl_decoded_option)); }
return; return new_flag;
} }
/* Translate -filelist and -framework options in *DECODED_OPTIONS /* Translate -filelist and -framework options in *DECODED_OPTIONS
...@@ -187,6 +151,8 @@ darwin_driver_init (unsigned int *decoded_options_count, ...@@ -187,6 +151,8 @@ darwin_driver_init (unsigned int *decoded_options_count,
bool seenM64 = false; bool seenM64 = false;
bool appendM32 = false; bool appendM32 = false;
bool appendM64 = false; bool appendM64 = false;
const char *vers_string = NULL;
bool seen_version_min = false;
for (i = 1; i < *decoded_options_count; i++) for (i = 1; i < *decoded_options_count; i++)
{ {
...@@ -246,12 +212,15 @@ darwin_driver_init (unsigned int *decoded_options_count, ...@@ -246,12 +212,15 @@ darwin_driver_init (unsigned int *decoded_options_count,
CL_DRIVER, &(*decoded_options)[i]); CL_DRIVER, &(*decoded_options)[i]);
break; break;
case OPT_mmacosx_version_min_:
seen_version_min = true;
vers_string = xstrndup ((*decoded_options)[i].arg, 32);
default: default:
break; break;
} }
} }
darwin_default_min_version (decoded_options_count, decoded_options);
/* Turn -arch xxxx into the appropriate -m32/-m64 flag. /* Turn -arch xxxx into the appropriate -m32/-m64 flag.
If the User tried to specify multiple arch flags (which is possible with If the User tried to specify multiple arch flags (which is possible with
some Darwin compilers) warn that this mode is not supported by this some Darwin compilers) warn that this mode is not supported by this
...@@ -308,4 +277,21 @@ darwin_driver_init (unsigned int *decoded_options_count, ...@@ -308,4 +277,21 @@ darwin_driver_init (unsigned int *decoded_options_count,
&(*decoded_options)[*decoded_options_count - 1]); &(*decoded_options)[*decoded_options_count - 1]);
} }
/* We will need to know the OS X version we're trying to build for here
so that we can figure out the mechanism and source for the sysroot to
be used. */
if (! seen_version_min && *decoded_options_count > 1)
{
/* Not set by the User, try to figure it out. */
vers_string = darwin_default_min_version ();
if (vers_string != NULL)
{
++*decoded_options_count;
*decoded_options = XRESIZEVEC (struct cl_decoded_option,
*decoded_options,
*decoded_options_count);
generate_option (OPT_mmacosx_version_min_, vers_string, 1, CL_DRIVER,
&(*decoded_options)[*decoded_options_count - 1]);
}
}
} }
...@@ -271,7 +271,6 @@ extern GTY(()) int darwin_ms_struct; ...@@ -271,7 +271,6 @@ extern GTY(()) int darwin_ms_struct;
%{headerpad_max_install_names} \ %{headerpad_max_install_names} \
%{Zimage_base*:-image_base %*} \ %{Zimage_base*:-image_base %*} \
%{Zinit*:-init %*} \ %{Zinit*:-init %*} \
%{!mmacosx-version-min=*:-macosx_version_min %(darwin_minversion)} \
%{mmacosx-version-min=*:-macosx_version_min %*} \ %{mmacosx-version-min=*:-macosx_version_min %*} \
%{nomultidefs} \ %{nomultidefs} \
%{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \ %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \
...@@ -370,8 +369,7 @@ extern GTY(()) int darwin_ms_struct; ...@@ -370,8 +369,7 @@ extern GTY(()) int darwin_ms_struct;
#define DARWIN_EXTRA_SPECS \ #define DARWIN_EXTRA_SPECS \
{ "darwin_crt1", DARWIN_CRT1_SPEC }, \ { "darwin_crt1", DARWIN_CRT1_SPEC }, \
{ "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \ { "darwin_dylib1", DARWIN_DYLIB1_SPEC },
{ "darwin_minversion", DARWIN_MINVERSION_SPEC },
#define DARWIN_DYLIB1_SPEC \ #define DARWIN_DYLIB1_SPEC \
"%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \ "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o) \
...@@ -916,7 +914,9 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); ...@@ -916,7 +914,9 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
#define SUPPORTS_INIT_PRIORITY 0 #define SUPPORTS_INIT_PRIORITY 0
/* When building cross-compilers (and native crosses) we shall default to /* When building cross-compilers (and native crosses) we shall default to
providing an osx-version-min of this unless overridden by the User. */ providing an osx-version-min of this unless overridden by the User.
#define DEF_MIN_OSX_VERSION "10.4" 10.5 is the only version that fully supports all our archs so that's the
fall-back default. */
#define DEF_MIN_OSX_VERSION "10.5"
#endif /* CONFIG_DARWIN_H */ #endif /* CONFIG_DARWIN_H */
...@@ -226,10 +226,9 @@ Generate code suitable for fast turn around debugging ...@@ -226,10 +226,9 @@ Generate code suitable for fast turn around debugging
; The Init here is for the convenience of GCC developers, so that cc1 ; 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 ; 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 ; driver will always pass a -mmacosx-version-min, so in normal use the
; Init is never used. Useful for setting the OS on which people ; Init is never used.
; usually debug.
mmacosx-version-min= mmacosx-version-min=
Target Joined Report Var(darwin_macosx_version_min) Init("10.6") Target Joined Report Var(darwin_macosx_version_min) Init(DEF_MIN_OSX_VERSION)
The earliest MacOS X version on which this program will run The earliest MacOS X version on which this program will run
mone-byte-bool mone-byte-bool
......
...@@ -25,3 +25,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -25,3 +25,6 @@ along with GCC; see the file COPYING3. If not see
%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
%{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L" %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L"
#undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.8"
...@@ -108,7 +108,6 @@ extern int darwin_emit_branch_islands; ...@@ -108,7 +108,6 @@ extern int darwin_emit_branch_islands;
#undef CC1_SPEC #undef CC1_SPEC
#define CC1_SPEC "%(cc1_cpu) \ #define CC1_SPEC "%(cc1_cpu) \
%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \ %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
%{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \
%{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} " \ %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} " \
DARWIN_CC1_SPEC DARWIN_CC1_SPEC
...@@ -119,15 +118,6 @@ extern int darwin_emit_branch_islands; ...@@ -119,15 +118,6 @@ extern int darwin_emit_branch_islands;
#define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}" #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
/* Determine a minimum version based on compiler options. */
#define DARWIN_MINVERSION_SPEC \
"%{!m64|fgnu-runtime:10.4; \
,objective-c|,objc-cpp-output:10.5; \
,objective-c-header:10.5; \
,objective-c++|,objective-c++-cpp-output:10.5; \
,objective-c++-header|,objc++-cpp-output:10.5; \
:10.4}"
#undef ENDFILE_SPEC #undef ENDFILE_SPEC
#define ENDFILE_SPEC \ #define ENDFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
......
...@@ -93,7 +93,6 @@ extern int darwin_emit_branch_islands; ...@@ -93,7 +93,6 @@ extern int darwin_emit_branch_islands;
%(cc1_cpu) \ %(cc1_cpu) \
%{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} \ %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} \
%{static: %{Zdynamic: %e conflicting code gen style switches are used}}\ %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
%{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \
%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \ %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
%{faltivec:-maltivec -include altivec.h} %{fno-altivec:-mno-altivec} \ %{faltivec:-maltivec -include altivec.h} %{fno-altivec:-mno-altivec} \
%<faltivec %<fno-altivec " \ %<faltivec %<fno-altivec " \
...@@ -124,17 +123,6 @@ extern int darwin_emit_branch_islands; ...@@ -124,17 +123,6 @@ extern int darwin_emit_branch_islands;
#define DARWIN_CRT2_SPEC \ #define DARWIN_CRT2_SPEC \
"%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}" "%{!m64:%:version-compare(!> 10.4 mmacosx-version-min= crt2.o%s)}"
/* Determine a minimum version based on compiler options. */
#define DARWIN_MINVERSION_SPEC \
"%{m64:%{fgnu-runtime:10.4; \
,objective-c|,objc-cpp-output:10.5; \
,objective-c-header:10.5; \
,objective-c++|,objective-c++-cpp-output:10.5; \
,objective-c++-header|,objc++-cpp-output:10.5; \
:10.4}; \
shared-libgcc:10.3; \
:10.1}"
#undef SUBTARGET_EXTRA_SPECS #undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \ #define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \ DARWIN_EXTRA_SPECS \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment