Index: ChangeLog
authorGeoffrey Keating <geoffk@apple.com>
Fri, 8 Jul 2005 05:51:06 +0000 (05:51 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Fri, 8 Jul 2005 05:51:06 +0000 (05:51 +0000)
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.

From-SVN: r101753

27 files changed:
gcc/ChangeLog
gcc/config.gcc
gcc/config.in
gcc/config/darwin-c.c
gcc/config/darwin-protos.h
gcc/config/darwin.h
gcc/config/darwin.opt
gcc/config/darwin7.h [deleted file]
gcc/config/darwin8.h [deleted file]
gcc/config/i386/darwin.h
gcc/config/rs6000/darwin.h
gcc/config/rs6000/darwin7.h [new file with mode: 0644]
gcc/config/rs6000/darwin8.h [new file with mode: 0644]
gcc/configure
gcc/configure.ac
gcc/doc/invoke.texi
gcc/gcc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-18.c
gcc/testsuite/gcc.dg/builtins-20.c
gcc/testsuite/gcc.dg/builtins-53.c
gcc/testsuite/gcc.dg/builtins-config.h
gcc/testsuite/gcc.dg/darwin-version-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/builtin-convert-1.c
gcc/testsuite/gcc.dg/torture/builtin-convert-2.c
gcc/testsuite/gcc.dg/torture/builtin-convert-3.c
gcc/testsuite/gcc.dg/torture/builtin-power-1.c

index b61d62d0bd60171dade8bee65e78723e0cf4a7b1..1c2d6b9e79cbd5973fe3b97506de3396d1ca1be4 100644 (file)
@@ -1,3 +1,35 @@
+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.
+
 2005-07-07  Ian Lance Taylor  <ian@airs.com>
 
        * config/mips/mips.md (abs<mode>2) [GPR]: Remove.
index 66cced208cac40889fd51c22f3fe1163609618a9..4119abbdbde1b43361d98666d95789b1c83a0aa2 100644 (file)
@@ -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 192b46194655ed006aab2edcb51b0b3e4f72062d..3fc2f58a64f96fafa2a5e60d2fa69347d9247770 100644 (file)
 #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 9102ea2e67da606fa71b62e3aa2bbedd99c3ff2e..738f07c81a730c9821348b534e6dd03bfc277c2c 100644 (file)
@@ -542,3 +542,57 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
 
   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 c3a03e27f9a19e78b07df21c6cc3561250389823..dfada767b0104a15a8c83af8bbf21f65af119cd2 100644 (file)
@@ -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 (tree, int);
 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 022e3a05b9440ffd9e92c218aadb81771c6b29e2..9802fe4cf46a260edc5fae542daa71d1c5966956 100644 (file)
@@ -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 84f4149340177a566a9065849b856d2d1b798864..90a094b84407fd4e4427a0b68ff37230858a4bea 100644 (file)
 ; 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
diff --git a/gcc/config/darwin7.h b/gcc/config/darwin7.h
deleted file mode 100644 (file)
index 1932881..0000000
+++ /dev/null
@@ -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}"
diff --git a/gcc/config/darwin8.h b/gcc/config/darwin8.h
deleted file mode 100644 (file)
index f4e0d82..0000000
+++ /dev/null
@@ -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 348c42b17d099c393da55759237f989a98f14c29..7e8b2dcc0d220393c269d15a55ac4f35d1596587 100644 (file)
@@ -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 72ec64b853106a7790b088b3f1195e0aedf6ab7c..6086445c62d3e98674aced5fa076fb36dc364d16 100644 (file)
@@ -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))
diff --git a/gcc/config/rs6000/darwin7.h b/gcc/config/rs6000/darwin7.h
new file mode 100644 (file)
index 0000000..4c1cda3
--- /dev/null
@@ -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}"
diff --git a/gcc/config/rs6000/darwin8.h b/gcc/config/rs6000/darwin8.h
new file mode 100644 (file)
index 0000000..ee583a2
--- /dev/null
@@ -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 55015f6466a5d3d8a110d7a8fce90c09265990ec..fd89fc80f8dbabf16afe8ade2b9dffa8da5e4bae 100755 (executable)
@@ -11212,8 +11212,10 @@ CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
 
 
 
-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 f2d631b4c7c177a88f8259352a13da87b60c7fec..00a531f1241f9158fc86e58777c0c58e4092d3b0 100644 (file)
@@ -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 a36f17945b0c762557a8c3949887f4b485614035..8acfd0f011bff446ea70072c203b9a90cfbe06ad 100644 (file)
@@ -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 1530fc0c16f87c6cff5d795580acc09f4e9a4a82..c137ad4f9ce33ccb3d718a90043ddfcf76d7f696 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -80,6 +80,7 @@ compilation is specified by a string called a "spec".  */
 #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 (const char *, int, int);
 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 **);
 \f
 /* The Specs Language
 
@@ -1577,6 +1579,7 @@ static const struct spec_function static_spec_functions[] =
   { "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, const char **argv)
 }
 
 /* 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, const char **argv)
   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 394b84667a287a27b5776a79302bb757c8f13f00..67c70d4c17e6cde81bb14987a1e1a1ee04bedd3f 100644 (file)
@@ -1,3 +1,16 @@
+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.
+
 2005-07-07  Jeff Law  <law@redhat.com>
 
        * gcc.dg/tree-ssa/vrp17.c: Simplify.  Remove dependency on
index a47de8b609eedee82beac0c9dc0047e6f83d3c4a..d04fe712f9a1b8968ffab40c983e594efa5f58ef 100644 (file)
@@ -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 fb7dd95c84b970167fc05d6b73f2c901c13b7bda..dbcf96c3c07b6440a6068a0bbe4e1bac6669c057 100644 (file)
@@ -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 e01908c26a7d87648acfec740f5bc27a422824bb..2b4b2f978b4c8a2c3b4dd6629dc0c3fcf3c02cdf 100644 (file)
@@ -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 05afc5ee567fc24ab35331d94f1c505265ba7ed3..74915bce16d9cf26b4e782699430fff3aa8ef77a 100644 (file)
 /* 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
diff --git a/gcc/testsuite/gcc.dg/darwin-version-1.c b/gcc/testsuite/gcc.dg/darwin-version-1.c
new file mode 100644 (file)
index 0000000..11cfcef
--- /dev/null
@@ -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 ac671590d2043256e7a292f29d56d0763a443630..d9fa77b853896dbbfdfa7e8680cc4fc0451277ac 100644 (file)
@@ -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 68fc071eb7dd8b8720584e4ace191da20f557fc8..5c4c4a6740350ab529c7825ab83fd8a5114b4a28 100644 (file)
@@ -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 9901ceccf819eebb8723a456371ee1b910a7bebb..4efabd559ba5facf5f8b611bddd9532efabd9149 100644 (file)
@@ -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 7b890bb0816833ea9c7c9884190752ccfb84a27e..bbee0674a32e3ce7007f6f552a632c504577911e 100644 (file)
@@ -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"