This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

version bounds for Darwin


This largish patch adds a new flag for Darwin which lets users specify
which version of Darwin they're targetting, and appropriate support.

I intentionally didn't document the default very clearly, it's really
"whatever seems to make most stuff work".

In the Apple compiler, this is actually an environment variable,
MACOSX_DEPLOYMENT_TARGET, and the linker also knows about it.  I plan
to change the linker so that it can also take a flag.

Bootstrapped and tested on powerpc-darwin8.  I also tested a
cross-built to powerpc-darwin7.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-darwin-minversion-1.patch=============
Index: ChangeLog
2005-07-07  Geoffrey Keating  <geoffk@apple.com>

	* config.gcc (*-*-darwin*): Only one target-specific header file
	for generic darwin.
	(powerpc-*-darwin*): Add version-specific header files.
	* configure.in (gcc_AC_CHECK_DECLS): Add strverscmp.
	* config.in: Regenerate.
	* configure: Regenerate.
	* gcc.c: Include xregex.h.
	(version_compare_spec_function): New.
	(spec_function): Add version-compare.
	(replace_outfile_spec_function): Reformat comment.
	(compare_version_strings): New.
	* config/darwin-c.c (version_as_macro): New.
	(builtin_define): New.
	(darwin_cpp_builtins): New.
	* config/darwin-protos.h (darwin_cpp_builtins): New.
	* config/darwin.h (CPP_SPEC): Don't define APPLE_CC here.
	(LIB_SPEC): Make unconditional, update comment.
	(TARGET_C99_FUNCTIONS): Define.
	* config/darwin.opt: Sort.
	(mmacosx-version-min=): New.
	* config/darwin7.h: Delete.
	* config/darwin8.h: Delete.
	* config/i386/darwin.h (): Call darwin_cpp_builtins.
	* config/rs6000/darwin.h (): Call darwin_cpp_builtins.
	(TARGET_C99_FUNCTIONS): Define.
	* config/rs6000/darwin7.h: New.
	* config/rs6000/darwin8.h: New.
	* doc/invoke.texi (Darwin Options): Add -mmacosx-version-min=
	(-mmacosx-version-min): Document.

Index: testsuite/ChangeLog
2005-07-07  Geoffrey Keating  <geoffk@apple.com>

	* gcc.dg/darwin-version-1.c: New.
	* gcc.dg/builtins-18.c: On Darwin, needs -mmacosx-version-min=10.3.
	* gcc.dg/builtins-20.c: Likewise.
	* gcc.dg/builtins-53.c: Likewise.
	* gcc.dg/torture/builtins-convert-1.c: Likewise.
	* gcc.dg/torture/builtins-convert-2.c: Likewise.
	* gcc.dg/torture/builtins-convert-3.c: Likewise.
	* gcc.dg/torture/builtins-power-1.c: Likewise.
	* gcc.dg/builtins-config.h: Complain if macosx-version-min not set
	on Darwin.

Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.551
diff -u -p -u -p -r1.551 config.gcc
--- config.gcc	27 Jun 2005 17:17:11 -0000	1.551
+++ config.gcc	8 Jul 2005 05:37:28 -0000
@@ -355,12 +355,6 @@ esac
 # Common parts for widely ported systems.
 case ${target} in
 *-*-darwin*)
-  case ${target} in
-    *-darwin1[0-9]*) tm_file="${tm_file} darwin8.h" ;;
-    *-darwin[0-6]*) ;;
-    *-darwin7*) tm_file="${tm_file} darwin7.h" ;;
-    *) tm_file="${tm_file} darwin8.h" ;;
-  esac
   tm_file="${tm_file} darwin.h"
   tm_p_file="${tm_p_file} darwin-protos.h"
   tmake_file="t-darwin t-slibgcc-darwin"
@@ -1608,9 +1602,15 @@ powerpc-*-darwin*)
 	tmake_file="${tmake_file} rs6000/t-darwin"
 	extra_options="${extra_options} rs6000/darwin.opt"
 	case ${target} in
-	  *-darwin1[0-9]*) tmake_file="${tmake_file} rs6000/t-darwin8" ;;
-	  *-darwin[0-7]*) ;;
-	  *-darwin[8-9]*) tmake_file="${tmake_file} rs6000/t-darwin8" ;;
+	  *-darwin1[0-9]* | *-darwin[8-9]*)
+	    tmake_file="${tmake_file} rs6000/t-darwin8" 
+	    tm_file="${tm_file} rs6000/darwin8.h"
+	    ;;
+	  *-darwin7*)
+	    tm_file="${tm_file} rs6000/darwin7.h"
+	    ;;
+	  *-darwin[0-6]*)
+	    ;;
 	esac
 	extra_headers=altivec.h
 	;;
Index: config.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.in,v
retrieving revision 1.217
diff -u -p -u -p -r1.217 config.in
--- config.in	2 Jul 2005 08:51:54 -0000	1.217
+++ config.in	8 Jul 2005 05:37:28 -0000
@@ -577,6 +577,13 @@
 #endif
 
 
+/* Define to 1 if we found a declaration for 'strverscmp', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_DECL_STRVERSCMP
+#endif
+
+
 /* Define to 1 if we found a declaration for 'times', otherwise define to 0.
    */
 #ifndef USED_FOR_TARGET
Index: configure
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure,v
retrieving revision 1.914
diff -u -p -u -p -r1.914 configure
--- configure	6 Jul 2005 20:12:53 -0000	1.914
+++ configure	8 Jul 2005 05:37:28 -0000
@@ -11212,8 +11212,10 @@ CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/
 
 
 
-for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd strsignal \
-	strstr errno snprintf vsnprintf vasprintf malloc realloc calloc \
+
+for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd \
+	strsignal strstr strverscmp \
+	errno snprintf vsnprintf vasprintf malloc realloc calloc \
 	free basename getopt clock getpagesize clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked   putchar_unlocked putc_unlocked
 do
   ac_tr_decl=`echo "HAVE_DECL_$ac_func" | $as_tr_cpp`
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.ac,v
retrieving revision 2.121
diff -u -p -u -p -r2.121 configure.ac
--- configure.ac	6 Jul 2005 02:18:18 -0000	2.121
+++ configure.ac	8 Jul 2005 05:37:29 -0000
@@ -1049,8 +1049,9 @@ AM_LANGINFO_CODESET
 # We will need to find libiberty.h and ansidecl.h
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
-gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd strsignal \
-	strstr errno snprintf vsnprintf vasprintf malloc realloc calloc \
+gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd \
+	strsignal strstr strverscmp \
+	errno snprintf vsnprintf vasprintf malloc realloc calloc \
 	free basename getopt clock getpagesize gcc_UNLOCKED_FUNCS, , ,[
 #include "ansidecl.h"
 #include "system.h"])
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.463
diff -u -p -u -p -r1.463 gcc.c
--- gcc.c	3 Jul 2005 21:07:56 -0000	1.463
+++ gcc.c	8 Jul 2005 05:37:29 -0000
@@ -80,6 +80,7 @@ compilation is specified by a string cal
 #if ! defined( SIGCHLD ) && defined( SIGCLD )
 #  define SIGCHLD SIGCLD
 #endif
+#include "xregex.h"
 #include "obstack.h"
 #include "intl.h"
 #include "prefix.h"
@@ -349,6 +350,7 @@ static const char *convert_filename (con
 static const char *if_exists_spec_function (int, const char **);
 static const char *if_exists_else_spec_function (int, const char **);
 static const char *replace_outfile_spec_function (int, const char **);
+static const char *version_compare_spec_function (int, const char **);
 
 /* The Specs Language
 
@@ -1577,6 +1579,7 @@ static const struct spec_function static
   { "if-exists",		if_exists_spec_function },
   { "if-exists-else",		if_exists_else_spec_function },
   { "replace-outfile",		replace_outfile_spec_function },
+  { "version-compare",		version_compare_spec_function },
   { 0, 0 }
 };
 
@@ -7573,8 +7576,9 @@ if_exists_else_spec_function (int argc, 
 }
 
 /* replace-outfile built-in spec function.
-   This looks for the first argument in the outfiles array's name and replaces it
-   with the second argument.  */
+
+   This looks for the first argument in the outfiles array's name and
+   replaces it with the second argument.  */
 
 static const char *
 replace_outfile_spec_function (int argc, const char **argv)
@@ -7592,3 +7596,120 @@ replace_outfile_spec_function (int argc,
   return NULL;
 }
 
+/* Given two version numbers, compares the two numbers.  
+   A version number must match the regular expression
+   ([1-9][0-9]*|0)(\.([1-9][0-9]*|0))*
+*/
+static int
+compare_version_strings (const char *v1, const char *v2)
+{
+  int rresult;
+  regex_t r;
+  
+  if (regcomp (&r, "^([1-9][0-9]*|0)(\\.([1-9][0-9]*|0))*$",
+	       REG_EXTENDED | REG_NOSUB) != 0)
+    abort ();
+  rresult = regexec (&r, v1, 0, NULL, 0);
+  if (rresult == REG_NOMATCH)
+    fatal ("invalid version number `%s'", v1);
+  else if (rresult != 0)
+    abort ();
+  rresult = regexec (&r, v2, 0, NULL, 0);
+  if (rresult == REG_NOMATCH)
+    fatal ("invalid version number `%s'", v2);
+  else if (rresult != 0)
+    abort ();
+
+  return strverscmp (v1, v2);
+}
+
+
+/* version_compare built-in spec function.
+
+   This takes an argument of the following form:
+
+   <comparison-op> <arg1> [<arg2>] <switch> <result>
+
+   and produces "result" if the comparison evaluates to true,
+   and nothing if it doesn't.
+
+   The supported <comparison-op> values are:
+   
+   >=  true if switch is a later (or same) version than arg1
+   !>  opposite of >=
+   <   true if switch is an earlier version than arg1
+   !<  opposite of <
+   ><  true if switch is arg1 or later, and earlier than arg2
+   <>  true if switch is earlier than arg1 or is arg2 or later
+
+   If the switch is not present, the condition is false unless
+   the first character of the <comparison-op> is '!'.
+
+   For example,
+   %:version-compare(>= 10.3 mmacosx-version-min= -lmx)
+   adds -lmx if -mmacosx-version-min=10.3.9 was passed.  */
+
+static const char *
+version_compare_spec_function (int argc, const char **argv)
+{
+  int comp1, comp2;
+  size_t switch_len;
+  const char *switch_value = NULL;
+  int nargs = 1, i;
+  bool result;
+
+  if (argc < 3)
+    abort ();
+  if (argv[0][0] == '\0')
+    abort ();
+  if ((argv[0][1] == '<' || argv[0][1] == '>') && argv[0][0] != '!')
+    nargs = 2;
+  if (argc != nargs + 3)
+    abort ();
+
+  switch_len = strlen (argv[nargs + 1]);
+  for (i = 0; i < n_switches; i++)
+    if (!strncmp (switches[i].part1, argv[nargs + 1], switch_len)
+	&& check_live_switch (i, switch_len))
+      switch_value = switches[i].part1 + switch_len;
+
+  if (switch_value == NULL)
+    comp1 = comp2 = -1;
+  else
+    {
+      comp1 = compare_version_strings (switch_value, argv[1]);
+      if (nargs == 2)
+	comp2 = compare_version_strings (switch_value, argv[2]);
+      else
+	comp2 = -1;  /* This value unused.  */
+    }
+
+  switch (argv[0][0] << 8 | argv[0][1])
+    {
+    case '>' << 8 | '=':
+      result = comp1 >= 0;
+      break;
+    case '!' << 8 | '<':
+      result = comp1 >= 0 || switch_value == NULL;
+      break;
+    case '<' << 8:
+      result = comp1 < 0;
+      break;
+    case '!' << 8 | '>':
+      result = comp1 < 0 || switch_value == NULL;
+      break;
+    case '>' << 8 | '<':
+      result = comp1 >= 0 && comp2 < 0;
+      break;
+    case '<' << 8 | '>':
+      result = comp1 < 0 || comp2 >= 0;
+      break;
+      
+    default:
+      abort ();
+    }
+  if (! result)
+    return NULL;
+
+  return argv[nargs + 2];
+}
Index: config/darwin-c.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin-c.c,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 darwin-c.c
--- config/darwin-c.c	29 Jun 2005 03:01:27 -0000	1.22
+++ config/darwin-c.c	8 Jul 2005 05:37:29 -0000
@@ -542,3 +542,57 @@ find_subframework_header (cpp_reader *pf
 
   return 0;
 }
+
+/* Return the value of darwin_macosx_version_min suitable for the
+   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
+   so '10.4.2' becomes 1042.  
+   Print a warning if the version number is not known.  */
+static const char *
+version_as_macro (void)
+{
+  static char result[] = "1000";
+  
+  if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
+    goto fail;
+  if (! ISDIGIT (darwin_macosx_version_min[3]))
+    goto fail;
+  result[2] = darwin_macosx_version_min[3];
+  if (darwin_macosx_version_min[4] != '\0')
+    {
+      if (darwin_macosx_version_min[4] != '.')
+	goto fail;
+      if (! ISDIGIT (darwin_macosx_version_min[5]))
+	goto fail;
+      if (darwin_macosx_version_min[6] != '\0')
+	goto fail;
+      result[3] = darwin_macosx_version_min[5];
+    }
+  else
+    result[3] = '0';
+  
+  return result;
+  
+ fail:
+  error ("Unknown value %qs of -mmacosx-version-min",
+	 darwin_macosx_version_min);
+  return "1000";
+}
+
+/* Define additional CPP flags for Darwin.   */
+
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+
+void
+darwin_cpp_builtins (cpp_reader *pfile)
+{
+  builtin_define ("__MACH__");
+  builtin_define ("__APPLE__");
+
+  /* __APPLE_CC__ is defined as some old Apple include files expect it
+     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);
+}
Index: config/darwin-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin-protos.h,v
retrieving revision 1.42
diff -u -p -u -p -r1.42 darwin-protos.h
--- config/darwin-protos.h	25 Jun 2005 01:20:43 -0000	1.42
+++ config/darwin-protos.h	8 Jul 2005 05:37:29 -0000
@@ -1,5 +1,5 @@
 /* Prototypes.
-   Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -135,3 +135,4 @@ extern void darwin_assemble_visibility (
 extern void darwin_asm_output_dwarf_delta (FILE *, int, const char *,
 					   const char *);
 extern bool darwin_binds_local_p (tree);
+extern void darwin_cpp_builtins (struct cpp_reader *);
Index: config/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.122
diff -u -p -u -p -r1.122 darwin.h
--- config/darwin.h	25 Jun 2005 01:20:44 -0000	1.122
+++ config/darwin.h	8 Jul 2005 05:37:29 -0000
@@ -185,13 +185,11 @@ Boston, MA 02110-1301, USA.  */
    !strcmp (STR, "dylinker_install_name") ? 1 : \
    0)
 
-/* Machine dependent cpp options.  __APPLE_CC__ is defined as the
-   Apple include files expect it to be defined and won't work if it
-   isn't.  */
+/* Machine dependent cpp options.  Don't add more options here, add
+   them to darwin_cpp_builtins in darwin-c.c.  */
 
 #undef	CPP_SPEC
-#define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}\
-    -D__APPLE_CC__=1"
+#define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}"
 
 /* This is mostly a clone of the standard LINK_COMMAND_SPEC, plus
    precomp, libtool, and fat build additions.  Also we
@@ -291,12 +289,9 @@ Boston, MA 02110-1301, USA.  */
    %{dylinker} %{Mach} "
 
 
-/* Machine dependent libraries but do not redefine it if we already on 7.0 and
-   above as it needs to link with libmx also.  */
+/* Machine dependent libraries.  */
 
-#ifndef	LIB_SPEC
 #define LIB_SPEC "%{!static:-lSystem}"
-#endif
 
 /* -dynamiclib implies -shared-libgcc just like -shared would on linux.  */
 #define REAL_LIBGCC_SPEC \
@@ -1033,10 +1028,8 @@ void add_framework_path (char *);
 
 #define TARGET_HAS_F_SETLKW
 
-/* Darwin before 7.0 does not have C99 functions.   */
-#ifndef TARGET_C99_FUNCTIONS
-#define TARGET_C99_FUNCTIONS 0
-#endif
+/* All new versions of Darwin have C99 functions.  */
+#define TARGET_C99_FUNCTIONS
 
 #define WINT_TYPE "int"
 
Index: config/darwin.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.opt,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 darwin.opt
--- config/darwin.opt	25 Jun 2005 01:20:44 -0000	1.2
+++ config/darwin.opt	8 Jul 2005 05:37:29 -0000
@@ -19,10 +19,14 @@
 ; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 ; 02110-1301, USA.
 
-mone-byte-bool
-Target RejectNegative Report Var(darwin_one_byte_bool)
-Set sizeof(bool) to 1
-
 mfix-and-continue
 Target Report Var(darwin_fix_and_continue)
 Generate code suitable for fast turn around debugging
+
+mmacosx-version-min=
+Target Joined Report Var(darwin_macosx_version_min)
+The earliest MacOS X version on which this program will run
+
+mone-byte-bool
+Target RejectNegative Report Var(darwin_one_byte_bool)
+Set sizeof(bool) to 1
Index: config/darwin7.h
===================================================================
RCS file: config/darwin7.h
diff -N config/darwin7.h
--- config/darwin7.h	25 Jun 2005 01:20:44 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-/* Target definitions for Darwin 7.x (Mac OS X) systems.
-   Copyright (C) 2004, 2005
-   Free Software Foundation, 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 2, 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 COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-/* Darwin 7.0 and above have C99 functions.   */
-#define TARGET_C99_FUNCTIONS 1
-
-/* Machine dependent libraries, include libmx when compiling on Darwin 7.0
-   and above.  */
-
-#undef	LIB_SPEC
-#define LIB_SPEC "%{!static:-lSystem -lmx}"
Index: config/darwin8.h
===================================================================
RCS file: config/darwin8.h
diff -N config/darwin8.h
--- config/darwin8.h	25 Jun 2005 01:20:44 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-/* Target definitions for Darwin 8.0 and above (Mac OS X) systems.
-   Copyright (C) 2004, 2005
-   Free Software Foundation, 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 2, 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 COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-/* Darwin 7.0 and above have C99 functions.   */
-#define TARGET_C99_FUNCTIONS 1
-
-/* 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.  Include libSystemStubs when compiling
-   on 8.0 and above and not 64-bit long double.  */
-
-#undef	LIB_SPEC
-#define LIB_SPEC "%{!static:\
-  %{!mlong-double-64:%{pg:-lSystemStubs_profile;:-lSystemStubs}} \
-  -lmx -lSystem}"
Index: config/i386/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/darwin.h,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 darwin.h
--- config/i386/darwin.h	25 Jun 2005 01:21:07 -0000	1.26
+++ config/i386/darwin.h	8 Jul 2005 05:37:29 -0000
@@ -33,8 +33,7 @@ Boston, MA 02110-1301, USA.  */
     {                                           \
       builtin_define ("__i386__");              \
       builtin_define ("__LITTLE_ENDIAN__");     \
-      builtin_define ("__MACH__");              \
-      builtin_define ("__APPLE__");             \
+      darwin_cpp_builtins (pfile);		\
     }                                           \
   while (0)
 
Index: config/rs6000/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/darwin.h,v
retrieving revision 1.89
diff -u -p -u -p -r1.89 darwin.h
--- config/rs6000/darwin.h	6 Jul 2005 09:16:47 -0000	1.89
+++ config/rs6000/darwin.h	8 Jul 2005 05:37:30 -0000
@@ -54,8 +54,7 @@
       if (TARGET_64BIT) builtin_define ("__ppc64__");  \
       builtin_define ("__POWERPC__");           \
       builtin_define ("__NATURAL_ALIGNMENT__"); \
-      builtin_define ("__MACH__");              \
-      builtin_define ("__APPLE__");             \
+      darwin_cpp_builtins (pfile);		\
     }                                           \
   while (0)
 
@@ -415,3 +414,10 @@ do {									\
 
 /* This is the reserved ivar address Objective-C.  */
 #define OFFS_ASSIGNIVAR_FAST		0xFFFEFEC0
+
+/* Old versions of Mac OS/Darwin don't have C99 functions available.  */
+#undef TARGET_C99_FUNCTIONS
+#define TARGET_C99_FUNCTIONS					\
+  (TARGET_64BIT							\
+   || (darwin_macosx_version_min				\
+       && strverscmp (darwin_macosx_version_min, "10.3") >= 0))
Index: config/rs6000/darwin7.h
===================================================================
RCS file: config/rs6000/darwin7.h
diff -N config/rs6000/darwin7.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/rs6000/darwin7.h	8 Jul 2005 05:37:30 -0000
@@ -0,0 +1,31 @@
+/* Target definitions for Darwin 7.x (Mac OS X) systems.
+   Copyright (C) 2004, 2005
+   Free Software Foundation, 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 2, 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 COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+/* 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}"
Index: config/rs6000/darwin8.h
===================================================================
RCS file: config/rs6000/darwin8.h
diff -N config/rs6000/darwin8.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/rs6000/darwin8.h	8 Jul 2005 05:37:30 -0000
@@ -0,0 +1,33 @@
+/* Target definitions for Darwin 8.0 and above (Mac OS X) systems.
+   Copyright (C) 2004, 2005
+   Free Software Foundation, 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 2, 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 COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+/* 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}"
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.643
diff -u -p -u -p -r1.643 invoke.texi
--- doc/invoke.texi	7 Jul 2005 10:25:32 -0000	1.643
+++ doc/invoke.texi	8 Jul 2005 05:37:32 -0000
@@ -451,7 +451,8 @@ Objective-C and Objective-C++ Dialects}.
 -single_module  -static  -sub_library  -sub_umbrella @gol
 -twolevel_namespace  -umbrella  -undefined @gol
 -unexported_symbols_list  -weak_reference_mismatches @gol
--whatsloaded -F -gused -gfull -mone-byte-bool}
+-whatsloaded -F -gused -gfull -mmacosx-min-version=@var{version} @gol
+-mone-byte-bool}
 
 @emph{DEC Alpha Options}
 @gccoptlist{-mno-fp-regs  -msoft-float  -malpha-as  -mgas @gol
@@ -7668,6 +7669,14 @@ This is by default ON@.
 @opindex -gfull
 Emit debugging information for all symbols and types.
 
+@item -mmacosx-version-min=@var{version}
+The earliest version of MacOS X that this executable will run on
+is @var{version}.  Typical values of @var{version} include @code{10.1},
+@code{10.2}, and @code{10.3.9}.
+
+The default for this option is to make choices that seem to be most
+useful.  
+
 @item -mone-byte-bool
 @opindex -mone-byte-bool
 Override the defaults for @samp{bool} so that @samp{sizeof(bool)==1}.
Index: testsuite/gcc.dg/builtins-18.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/builtins-18.c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 builtins-18.c
--- testsuite/gcc.dg/builtins-18.c	24 Dec 2003 06:52:27 -0000	1.3
+++ testsuite/gcc.dg/builtins-18.c	8 Jul 2005 05:38:24 -0000
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "builtins-config.h"
 
Index: testsuite/gcc.dg/builtins-20.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/builtins-20.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 builtins-20.c
--- testsuite/gcc.dg/builtins-20.c	3 Aug 2004 08:22:21 -0000	1.4
+++ testsuite/gcc.dg/builtins-20.c	8 Jul 2005 05:38:24 -0000
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "builtins-config.h"
 
Index: testsuite/gcc.dg/builtins-53.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/builtins-53.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 builtins-53.c
--- testsuite/gcc.dg/builtins-53.c	15 Apr 2005 05:43:56 -0000	1.4
+++ testsuite/gcc.dg/builtins-53.c	8 Jul 2005 05:38:24 -0000
@@ -10,6 +10,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-O2 -ffast-math" } */
+/* { dg-options "-O2 -ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "builtins-config.h"
 
Index: testsuite/gcc.dg/builtins-config.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/builtins-config.h,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 builtins-config.h
--- testsuite/gcc.dg/builtins-config.h	6 Dec 2004 11:00:49 -0000	1.7
+++ testsuite/gcc.dg/builtins-config.h	8 Jul 2005 05:38:24 -0000
@@ -19,6 +19,15 @@
 /* FreeBSD before version 5 doesn't have the entire C99 runtime. */
 #elif defined(__netware__)
 /* NetWare doesn't have the entire C99 runtime.  */
+#elif (defined(__APPLE__) \
+       && ! defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__))
+/* MacOS versions before 10.3 don't have many C99 functions.  
+   But, if you're including this file, you probably want to test the
+   newer behaviour, so: */
+#error forgot to set -mmacosx-version-min.
+#elif (defined(__APPLE__) \
+       && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1030)
+/* MacOS versions before 10.3 don't have many C99 functions.  */
 #else
 /* Newlib has the "f" variants of the math functions, but not the "l"
    variants.  TARGET_C99_FUNCTIONS is only defined if all C99
Index: testsuite/gcc.dg/darwin-version-1.c
===================================================================
RCS file: testsuite/gcc.dg/darwin-version-1.c
diff -N testsuite/gcc.dg/darwin-version-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/darwin-version-1.c	8 Jul 2005 05:38:25 -0000
@@ -0,0 +1,10 @@
+/* Basic test of the -mmacosx-version-min option.  */
+
+/* { dg-options "-mmacosx-version-min=10.1" } */
+/* { dg-do link { target *-*-darwin* } } */
+
+int main()
+{
+  return 0;
+}
+
Index: testsuite/gcc.dg/torture/builtin-convert-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 builtin-convert-1.c
--- testsuite/gcc.dg/torture/builtin-convert-1.c	19 Mar 2004 03:21:47 -0000	1.2
+++ testsuite/gcc.dg/torture/builtin-convert-1.c	8 Jul 2005 05:38:29 -0000
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-ffast-math" } */
+/* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "../builtins-config.h"
 
Index: testsuite/gcc.dg/torture/builtin-convert-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/torture/builtin-convert-2.c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 builtin-convert-2.c
--- testsuite/gcc.dg/torture/builtin-convert-2.c	29 Apr 2004 01:19:40 -0000	1.2
+++ testsuite/gcc.dg/torture/builtin-convert-2.c	8 Jul 2005 05:38:29 -0000
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-ffast-math" } */
+/* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "../builtins-config.h"
 
Index: testsuite/gcc.dg/torture/builtin-convert-3.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/torture/builtin-convert-3.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 builtin-convert-3.c
--- testsuite/gcc.dg/torture/builtin-convert-3.c	2 May 2004 02:53:05 -0000	1.1
+++ testsuite/gcc.dg/torture/builtin-convert-3.c	8 Jul 2005 05:38:29 -0000
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-ffast-math" } */
+/* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "../builtins-config.h"
 
Index: testsuite/gcc.dg/torture/builtin-power-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/torture/builtin-power-1.c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 builtin-power-1.c
--- testsuite/gcc.dg/torture/builtin-power-1.c	9 Mar 2005 20:11:48 -0000	1.3
+++ testsuite/gcc.dg/torture/builtin-power-1.c	8 Jul 2005 05:38:29 -0000
@@ -7,6 +7,7 @@
 
 /* { dg-do link } */
 /* { dg-options "-ffast-math" } */
+/* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
 
 #include "../builtins-config.h"
 
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]