[128373] trunk/dports/lang/gcc47
larryv at macports.org
larryv at macports.org
Wed Nov 19 21:21:41 PST 2014
Revision: 128373
https://trac.macports.org/changeset/128373
Author: larryv at macports.org
Date: 2014-11-19 21:21:41 -0800 (Wed, 19 Nov 2014)
Log Message:
-----------
gcc47: Fix handling of OS X deployment targets
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63810, and also
comment:9:ticket:45449, comment:61:ticket:43978, and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61407#c49.
Modified Paths:
--------------
trunk/dports/lang/gcc47/Portfile
Added Paths:
-----------
trunk/dports/lang/gcc47/files/macosx-version-min.patch
Removed Paths:
-------------
trunk/dports/lang/gcc47/files/yosemite-version-check.patch
Modified: trunk/dports/lang/gcc47/Portfile
===================================================================
--- trunk/dports/lang/gcc47/Portfile 2014-11-20 05:18:39 UTC (rev 128372)
+++ trunk/dports/lang/gcc47/Portfile 2014-11-20 05:21:41 UTC (rev 128373)
@@ -10,7 +10,7 @@
# Whenever this port is bumped for version/revision, please revbump dragonegg-*-gcc-4.7
version 4.7.4
-revision 2
+revision 3
platforms darwin
categories lang
maintainers mww openmaintainer
@@ -54,9 +54,12 @@
depends_skip_archcheck-append gcc_select ld64 cctools
license_noconflict gmp mpfr ppl libmpc
-patchfiles ppc_fde_encoding.diff \
- yosemite-version-check.patch
+patchfiles ppc_fde_encoding.diff
+# Handle OS X deployment targets correctly (GCC PR target/63810
+# <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63810>).
+patchfiles-append macosx-version-min.patch
+
# Don't link with "-flat_namespace -undefined suppress" on Yosemite and
# later (#45483).
patchfiles-append yosemite-libtool.patch
Copied: trunk/dports/lang/gcc47/files/macosx-version-min.patch (from rev 128370, trunk/dports/lang/gcc48/files/macosx-version-min.patch)
===================================================================
--- trunk/dports/lang/gcc47/files/macosx-version-min.patch (rev 0)
+++ trunk/dports/lang/gcc47/files/macosx-version-min.patch 2014-11-20 05:21:41 UTC (rev 128373)
@@ -0,0 +1,538 @@
+Index: gcc/config/darwin-c.c
+===================================================================
+--- gcc/config/darwin-c.c.orig
++++ gcc/config/darwin-c.c
+@@ -570,29 +570,180 @@ 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 1040. The lowest digit is always zero.
+- Print a warning if the version number can't be understood. */
++/* Given a version string, return the version as a statically-allocated
++ array of three non-negative integers. If the version string is
++ invalid, return null.
++
++ Version strings must consist of one, two, or three tokens, each
++ separated by a single period. Each token must contain only the
++ characters '0' through '9' and is converted to an equivalent
++ integer. Omitted tokens are treated as zeros. For example:
++
++ "10" becomes {10,0,0}
++ "10.10" becomes {10,10,0}
++ "10.10.1" becomes {10,10,1}
++ "10.000010.1" becomes {10,10,1}
++ "10.010.001" becomes {10,10,1}
++ "000010.10.00001" becomes {10,10,1} */
++
++enum version_components { MAJOR, MINOR, TINY };
++
++static const unsigned long *
++parse_version (const char *version_str)
++{
++ size_t version_len;
++ char *end;
++ static unsigned long version_array[3];
++
++ if (! version_str)
++ return NULL;
++
++ version_len = strlen (version_str);
++ if (version_len < 1)
++ return NULL;
++
++ /* Version string must consist of digits and periods only. */
++ if (strspn (version_str, "0123456789.") != version_len)
++ return NULL;
++
++ if (! ISDIGIT (version_str[0]) || ! ISDIGIT (version_str[version_len - 1]))
++ return NULL;
++
++ version_array[MAJOR] = strtoul (version_str, &end, 10);
++ version_str = end + ((*end == '.') ? 1 : 0);
++
++ /* Version string must not contain adjacent periods. */
++ if (*version_str == '.')
++ return NULL;
++
++ version_array[MINOR] = strtoul (version_str, &end, 10);
++ version_str = end + ((*end == '.') ? 1 : 0);
++
++ version_array[TINY] = strtoul (version_str, &end, 10);
++
++ /* Version string must contain no more than three tokens. */
++ if (*end != '\0')
++ return NULL;
++
++ return version_array;
++}
++
++/* Given a three-component version represented as an array of
++ non-negative integers, return a statically-allocated string suitable
++ for the legacy __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro.
++ If the version is invalid and cannot be coerced into a valid form,
++ return null.
++
++ The legacy format is a four-character string -- two chars for the
++ major number and one each for the minor and tiny numbers. Major
++ numbers are zero-padded if necessary. Minor and tiny numbers from
++ 10 through 99 are permitted but are clamped to 9 (for example,
++ {10,9,10} produces "1099"). Versions containing numbers greater
++ than 99 are rejected. */
++
+ static const char *
+-version_as_macro (void)
++version_as_legacy_macro (const unsigned long *version)
+ {
+- static char result[] = "1000";
++ unsigned long major, minor, tiny;
++ static char result[sizeof "9999"];
++
++ if (! version)
++ return NULL;
++
++ major = version[MAJOR];
++ minor = version[MINOR];
++ tiny = version[TINY];
++
++ if (major > 99 || minor > 99 || tiny > 99)
++ return NULL;
++
++ minor = ((minor > 9) ? 9 : minor);
++ tiny = ((tiny > 9) ? 9 : tiny);
++
++ /* NOTE: Cast result of sizeof so that result of sprintf is not
++ converted to an unsigned type. */
++ if (sprintf (result, "%02lu%lu%lu", major, minor, tiny)
++ != (int) sizeof "9999" - 1)
++ return NULL;
+
+- if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
++ return result;
++}
++
++/* Given a three-component version represented as an array of
++ non-negative integers, return a statically-allocated string suitable
++ for the modern __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro
++ or the __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ macro. If the
++ version is invalid, return null.
++
++ The modern format is a five- or six-character string -- one or two
++ chars for the major number and two each for the minor and tiny
++ numbers, which are zero-padded if necessary (for example, {8,1,0}
++ produces "80100", and {10,10,1} produces "101001"). Versions
++ containing numbers greater than 99 are rejected. */
++
++static const char *
++version_as_modern_macro (const unsigned long *version)
++{
++ unsigned long major, minor, tiny;
++ static char result[sizeof "999999"];
++
++ if (! version)
++ return NULL;
++
++ major = version[MAJOR];
++ minor = version[MINOR];
++ tiny = version[TINY];
++
++ if (major > 99 || minor > 99 || tiny > 99)
++ return NULL;
++
++ /* NOTE: 'sizeof ((x > y) ? "foo" : "bar")' returns size of char
++ pointer instead of char array, so use
++ '(x > y) ? sizeof "foo" : sizeof "bar"' instead. */
++ /* NOTE: Cast result of sizeof so that result of sprintf is not
++ converted to an unsigned type. */
++ if (sprintf (result, "%lu%02lu%02lu", major, minor, tiny)
++ != (int) ((major > 9) ? sizeof "999999" : sizeof "99999") - 1)
++ return NULL;
++
++ return result;
++}
++
++/* Return the value of darwin_macosx_version_min, suitably formatted
++ for the __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro. Values
++ representing OS X 10.9 and earlier are encoded using the legacy
++ four-character format, while 10.10 and later use a modern
++ six-character format. (For example, "10.9" produces "1090", and
++ "10.10.1" produces "101001".) If the value is invalid and cannot be
++ coerced into a valid form, print a warning and return "1000". */
++
++static const char *
++macosx_version_as_macro (void)
++{
++ const unsigned long *version_array;
++ const char *version_macro;
++
++ version_array = parse_version (darwin_macosx_version_min);
++ if (! version_array)
+ goto fail;
+- if (! ISDIGIT (darwin_macosx_version_min[3]))
++
++ /* Do not assume that the major number will always be exactly 10. */
++ if (version_array[MAJOR] < 10 || version_array[MAJOR] > 10)
+ goto fail;
+- result[2] = darwin_macosx_version_min[3];
+- if (darwin_macosx_version_min[4] != '\0'
+- && darwin_macosx_version_min[4] != '.')
++
++ if (version_array[MAJOR] == 10 && version_array[MINOR] < 10)
++ version_macro = version_as_legacy_macro (version_array);
++ else
++ version_macro = version_as_modern_macro (version_array);
++
++ if (! version_macro)
+ goto fail;
+
+- return result;
++ return version_macro;
+
+ fail:
+ error ("unknown value %qs of -mmacosx-version-min",
+- darwin_macosx_version_min);
++ darwin_macosx_version_min);
+ return "1000";
+ }
+
+@@ -614,7 +765,7 @@ darwin_cpp_builtins (cpp_reader *pfile)
+ builtin_define ("__CONSTANT_CFSTRINGS__");
+
+ builtin_define_with_value ("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__",
+- version_as_macro(), false);
++ macosx_version_as_macro(), false);
+
+ /* Since we do not (at 4.6) support ObjC gc for the NeXT runtime, the
+ following will cause a syntax error if one tries to compile gc attributed
+Index: gcc/config/darwin-driver.c
+===================================================================
+--- gcc/config/darwin-driver.c.orig
++++ gcc/config/darwin-driver.c
+@@ -29,8 +29,8 @@ along with GCC; see the file COPYING3.
+ #include <sys/sysctl.h>
+ #include "xregex.h"
+
+-static bool
+-darwin_find_version_from_kernel (char *new_flag)
++static char *
++darwin_find_version_from_kernel (void)
+ {
+ char osversion[32];
+ size_t osversion_len = sizeof (osversion) - 1;
+@@ -39,6 +39,7 @@ darwin_find_version_from_kernel (char *n
+ char minor_vers[6];
+ char * version_p;
+ char * version_pend;
++ char * new_flag;
+
+ /* Determine the version of the running OS. If we can't, warn user,
+ and do nothing. */
+@@ -46,7 +47,7 @@ darwin_find_version_from_kernel (char *n
+ &osversion_len, NULL, 0) == -1)
+ {
+ warning (0, "sysctl for kern.osversion failed: %m");
+- return false;
++ return NULL;
+ }
+
+ /* Try to parse the first two parts of the OS version number. Warn
+@@ -57,8 +58,6 @@ darwin_find_version_from_kernel (char *n
+ version_p = osversion + 1;
+ if (ISDIGIT (*version_p))
+ major_vers = major_vers * 10 + (*version_p++ - '0');
+- if (major_vers > 4 + 9)
+- goto parse_failed;
+ if (*version_p++ != '.')
+ goto parse_failed;
+ version_pend = strchr(version_p, '.');
+@@ -74,17 +73,16 @@ darwin_find_version_from_kernel (char *n
+ if (major_vers - 4 <= 4)
+ /* On 10.4 and earlier, the old linker is used which does not
+ support three-component system versions. */
+- sprintf (new_flag, "10.%d", major_vers - 4);
++ asprintf (&new_flag, "10.%d", major_vers - 4);
+ else
+- sprintf (new_flag, "10.%d.%s", major_vers - 4,
+- minor_vers);
++ asprintf (&new_flag, "10.%d.%s", major_vers - 4, minor_vers);
+
+- return true;
++ return new_flag;
+
+ parse_failed:
+ warning (0, "couldn%'t understand kern.osversion %q.*s",
+ (int) osversion_len, osversion);
+- return false;
++ return NULL;
+ }
+
+ #endif
+@@ -105,7 +103,7 @@ darwin_default_min_version (unsigned int
+ const unsigned int argc = *decoded_options_count;
+ struct cl_decoded_option *const argv = *decoded_options;
+ unsigned int i;
+- static char new_flag[sizeof ("10.0.0") + 6];
++ const char *new_flag;
+
+ /* If the command-line is empty, just return. */
+ if (argc <= 1)
+@@ -142,16 +140,16 @@ darwin_default_min_version (unsigned int
+
+ #ifndef CROSS_DIRECTORY_STRUCTURE
+
+- /* Try to find the version from the kernel, if we fail - we print a message
+- and give up. */
+- if (!darwin_find_version_from_kernel (new_flag))
+- return;
++ /* Try to find the version from the kernel, if we fail - we print a message
++ and give up. */
++ new_flag = darwin_find_version_from_kernel ();
++ if (!new_flag)
++ return;
+
+ #else
+
+- /* For cross-compilers, default to the target OS version. */
+-
+- strncpy (new_flag, DEF_MIN_OSX_VERSION, sizeof (new_flag));
++ /* For cross-compilers, default to the target OS version. */
++ new_flag = DEF_MIN_OSX_VERSION;
+
+ #endif /* CROSS_DIRECTORY_STRUCTURE */
+
+@@ -165,7 +163,6 @@ darwin_default_min_version (unsigned int
+ memcpy (*decoded_options + 2, argv + 1,
+ (argc - 1) * sizeof (struct cl_decoded_option));
+ return;
+-
+ }
+
+ /* Translate -filelist and -framework options in *DECODED_OPTIONS
+Index: gcc/testsuite/gcc.dg/darwin-minversion-1.c
+===================================================================
+--- gcc/testsuite/gcc.dg/darwin-minversion-1.c.orig
++++ gcc/testsuite/gcc.dg/darwin-minversion-1.c
+@@ -2,7 +2,8 @@
+ /* { dg-options "-mmacosx-version-min=10.1" } */
+ /* { dg-do run { target *-*-darwin* } } */
+
+-int main(void)
++int
++main ()
+ {
+ #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
+ fail me;
+Index: gcc/testsuite/gcc.dg/darwin-minversion-10.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-10.c
+@@ -0,0 +1,16 @@
++/* PR target/63810: Test that a version with a zero-padded minor
++ number < 10 and a zero-padded tiny number < 10 produces the correct
++ four-character macro. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=10.07.02" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1072
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-11.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-11.c
+@@ -0,0 +1,15 @@
++/* PR target/63810: Test that a version with outrageous zero-padding and
++ a minor number > 9 still produces a six-character macro. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=00010.010.0000098" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101098
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-12.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-12.c
+@@ -0,0 +1,15 @@
++/* PR target/63810: Test that a version with outrageous zero-padding and
++ a minor number < 10 still produces a four-character macro. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=010.008.000031" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1089
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-2.c
+===================================================================
+--- gcc/testsuite/gcc.dg/darwin-minversion-2.c.orig
++++ gcc/testsuite/gcc.dg/darwin-minversion-2.c
+@@ -2,7 +2,8 @@
+ /* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */
+ /* { dg-do run { target *-*-darwin* } } */
+
+-int main(void)
++int
++main ()
+ {
+ #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030
+ fail me;
+Index: gcc/testsuite/gcc.dg/darwin-minversion-3.c
+===================================================================
+--- gcc/testsuite/gcc.dg/darwin-minversion-3.c.orig
++++ gcc/testsuite/gcc.dg/darwin-minversion-3.c
+@@ -1,10 +1,11 @@
+-/* Test that most-minor versions greater than 9 work. */
+-/* { dg-options "-mmacosx-version-min=10.4.10" } */
++/* Test that most minor versions < 10 work. */
++/* { dg-options "-mmacosx-version-min=10.4.1" } */
+ /* { dg-do compile { target *-*-darwin* } } */
+
+-int main(void)
++int
++main ()
+ {
+-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1040
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1041
+ fail me;
+ #endif
+ return 0;
+Index: gcc/testsuite/gcc.dg/darwin-minversion-4.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-4.c
+@@ -0,0 +1,12 @@
++/* Test that minor versions > 9 produce a six-character macro. */
++/* { dg-options "-mmacosx-version-min=10.10.1" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101001
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-5.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-5.c
+@@ -0,0 +1,16 @@
++/* PR target/63810: Test that a version with minor number < 10 and tiny
++ number > 9 produces a four-character macro with the tiny number
++ clamped to 9. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=10.9.10" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1099
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-6.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-6.c
+@@ -0,0 +1,15 @@
++/* PR target/63810: Test that tiny numbers are preserved in
++ six-character macros. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=10.10.11" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101011
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-7.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-7.c
+@@ -0,0 +1,15 @@
++/* PR target/63810: Test that tiny numbers < 10 are preserved in
++ four-character macros. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=10.9.1" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1091
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-8.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-8.c
+@@ -0,0 +1,15 @@
++/* PR target/63810: Test that a version with minor number > 9 and no
++ tiny number produces a six-character macro ending in "00". */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=10.11" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101100
++ fail me;
++#endif
++ return 0;
++}
+Index: gcc/testsuite/gcc.dg/darwin-minversion-9.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-9.c
+@@ -0,0 +1,15 @@
++/* PR target/63810: Test that a version with a zero-padded minor
++ number < 10 produces a four-character macro. */
++/* Added by Lawrence Velázquez <larryv at macports.org>. */
++
++/* { dg-options "-mmacosx-version-min=10.08.4" } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1084
++ fail me;
++#endif
++ return 0;
++}
Deleted: trunk/dports/lang/gcc47/files/yosemite-version-check.patch
===================================================================
--- trunk/dports/lang/gcc47/files/yosemite-version-check.patch 2014-11-20 05:18:39 UTC (rev 128372)
+++ trunk/dports/lang/gcc47/files/yosemite-version-check.patch 2014-11-20 05:21:41 UTC (rev 128373)
@@ -1,241 +0,0 @@
-From 33cd1c2bb44e20e4eecd6ee04c02619ed95aa783 Mon Sep 17 00:00:00 2001
-From: fxcoudert <fxcoudert at 138bc75d-0d04-0410-961f-82ee72b054a4>
-Date: Mon, 29 Sep 2014 18:40:57 +0000
-Subject: [PATCH] PR target/61407
-
- * config/darwin-c.c (version_as_macro): Added extra 0 for OS X 10.10
- and above.
- * config/darwin-driver.c (darwin_find_version_from_kernel): Removed
- kernel version check to avoid incrementing it after every major OS X
- release.
- (darwin_default_min_version): Avoid static memory buffer.
-
- * gcc.dg/darwin-minversion-1.c: Fixed formatting
- * gcc.dg/darwin-minversion-2.c: Fixed formatting
- * gcc.dg/darwin-minversion-3.c: Fixed formatting
- * gcc.dg/darwin-minversion-4.c: Added test for OS X 10.10
-
-
-git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@215690 138bc75d-0d04-0410-961f-82ee72b054a4
----
- gcc/config/darwin-c.c | 25 ++++++++++++++++-----
- gcc/config/darwin-driver.c | 35 ++++++++++++++----------------
- gcc/testsuite/gcc.dg/darwin-minversion-1.c | 3 ++-
- gcc/testsuite/gcc.dg/darwin-minversion-2.c | 3 ++-
- gcc/testsuite/gcc.dg/darwin-minversion-3.c | 3 ++-
- gcc/testsuite/gcc.dg/darwin-minversion-4.c | 12 ++++++++++
- 8 files changed, 72 insertions(+), 28 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-4.c
-
-diff --git gcc/config/darwin-c.c gcc/config/darwin-c.c
-index 892ba35..7fe4b1f 100644
---- gcc/config/darwin-c.c
-+++ gcc/config/darwin-c.c
-@@ -571,21 +571,34 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
- }
-
- /* Return the value of darwin_macosx_version_min suitable for the
-- __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
-- so '10.4.2' becomes 1040. The lowest digit is always zero.
-+ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, so '10.4.2'
-+ becomes 1040 and '10.10.0' becomes 101000. The lowest digit is
-+ always zero, as is the second lowest for '10.10.x' and above.
- Print a warning if the version number can't be understood. */
- static const char *
- version_as_macro (void)
- {
-- static char result[] = "1000";
-+ static char result[7] = "1000";
-+ int minorDigitIdx;
-
- 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'
-- && darwin_macosx_version_min[4] != '.')
-+
-+ minorDigitIdx = 3;
-+ result[2] = darwin_macosx_version_min[minorDigitIdx++];
-+ if (ISDIGIT (darwin_macosx_version_min[minorDigitIdx]))
-+ {
-+ /* Starting with OS X 10.10, the macro ends '00' rather than '0',
-+ i.e. 10.10.x becomes 101000 rather than 10100. */
-+ result[3] = darwin_macosx_version_min[minorDigitIdx++];
-+ result[4] = '0';
-+ result[5] = '0';
-+ result[6] = '\0';
-+ }
-+ if (darwin_macosx_version_min[minorDigitIdx] != '\0'
-+ && darwin_macosx_version_min[minorDigitIdx] != '.')
- goto fail;
-
- return result;
-diff --git gcc/config/darwin-driver.c gcc/config/darwin-driver.c
-index 8b6ae93..541e10b 100644
---- gcc/config/darwin-driver.c
-+++ gcc/config/darwin-driver.c
-@@ -29,8 +29,8 @@ along with GCC; see the file COPYING3. If not see
- #include <sys/sysctl.h>
- #include "xregex.h"
-
--static bool
--darwin_find_version_from_kernel (char *new_flag)
-+static char *
-+darwin_find_version_from_kernel (void)
- {
- char osversion[32];
- size_t osversion_len = sizeof (osversion) - 1;
-@@ -39,6 +39,7 @@ darwin_find_version_from_kernel (char *new_flag)
- char minor_vers[6];
- char * version_p;
- char * version_pend;
-+ char * new_flag;
-
- /* Determine the version of the running OS. If we can't, warn user,
- and do nothing. */
-@@ -46,7 +47,7 @@ darwin_find_version_from_kernel (char *new_flag)
- &osversion_len, NULL, 0) == -1)
- {
- warning (0, "sysctl for kern.osversion failed: %m");
-- return false;
-+ return NULL;
- }
-
- /* Try to parse the first two parts of the OS version number. Warn
-@@ -57,8 +58,6 @@ darwin_find_version_from_kernel (char *new_flag)
- version_p = osversion + 1;
- if (ISDIGIT (*version_p))
- major_vers = major_vers * 10 + (*version_p++ - '0');
-- if (major_vers > 4 + 9)
-- goto parse_failed;
- if (*version_p++ != '.')
- goto parse_failed;
- version_pend = strchr(version_p, '.');
-@@ -74,17 +73,16 @@ darwin_find_version_from_kernel (char *new_flag)
- if (major_vers - 4 <= 4)
- /* On 10.4 and earlier, the old linker is used which does not
- support three-component system versions. */
-- sprintf (new_flag, "10.%d", major_vers - 4);
-+ asprintf (&new_flag, "10.%d", major_vers - 4);
- else
-- sprintf (new_flag, "10.%d.%s", major_vers - 4,
-- minor_vers);
-+ asprintf (&new_flag, "10.%d.%s", major_vers - 4, minor_vers);
-
-- return true;
-+ return new_flag;
-
- parse_failed:
- warning (0, "couldn%'t understand kern.osversion %q.*s",
- (int) osversion_len, osversion);
-- return false;
-+ return NULL;
- }
-
- #endif
-@@ -105,7 +103,7 @@ darwin_default_min_version (unsigned int *decoded_options_count,
- const unsigned int argc = *decoded_options_count;
- struct cl_decoded_option *const argv = *decoded_options;
- unsigned int i;
-- static char new_flag[sizeof ("10.0.0") + 6];
-+ const char *new_flag;
-
- /* If the command-line is empty, just return. */
- if (argc <= 1)
-@@ -142,16 +140,16 @@ darwin_default_min_version (unsigned int *decoded_options_count,
-
- #ifndef CROSS_DIRECTORY_STRUCTURE
-
-- /* Try to find the version from the kernel, if we fail - we print a message
-- and give up. */
-- if (!darwin_find_version_from_kernel (new_flag))
-- return;
-+ /* Try to find the version from the kernel, if we fail - we print a message
-+ and give up. */
-+ new_flag = darwin_find_version_from_kernel ();
-+ if (!new_flag)
-+ return;
-
- #else
-
-- /* For cross-compilers, default to the target OS version. */
--
-- strncpy (new_flag, DEF_MIN_OSX_VERSION, sizeof (new_flag));
-+ /* For cross-compilers, default to the target OS version. */
-+ new_flag = DEF_MIN_OSX_VERSION;
-
- #endif /* CROSS_DIRECTORY_STRUCTURE */
-
-@@ -165,7 +163,6 @@ darwin_default_min_version (unsigned int *decoded_options_count,
- memcpy (*decoded_options + 2, argv + 1,
- (argc - 1) * sizeof (struct cl_decoded_option));
- return;
--
- }
-
- /* Translate -filelist and -framework options in *DECODED_OPTIONS
-diff --git gcc/testsuite/gcc.dg/darwin-minversion-1.c gcc/testsuite/gcc.dg/darwin-minversion-1.c
-index d8a3243..6221d61 100644
---- gcc/testsuite/gcc.dg/darwin-minversion-1.c
-+++ gcc/testsuite/gcc.dg/darwin-minversion-1.c
-@@ -2,7 +2,8 @@
- /* { dg-options "-mmacosx-version-min=10.1" } */
- /* { dg-do run { target *-*-darwin* } } */
-
--int main(void)
-+int
-+main ()
- {
- #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
- fail me;
-diff --git gcc/testsuite/gcc.dg/darwin-minversion-2.c gcc/testsuite/gcc.dg/darwin-minversion-2.c
-index fd4975a..8e18d52 100644
---- gcc/testsuite/gcc.dg/darwin-minversion-2.c
-+++ gcc/testsuite/gcc.dg/darwin-minversion-2.c
-@@ -2,7 +2,8 @@
- /* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */
- /* { dg-do run { target *-*-darwin* } } */
-
--int main(void)
-+int
-+main ()
- {
- #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030
- fail me;
-diff --git gcc/testsuite/gcc.dg/darwin-minversion-3.c gcc/testsuite/gcc.dg/darwin-minversion-3.c
-index d0c5934..4fcb969 100644
---- gcc/testsuite/gcc.dg/darwin-minversion-3.c
-+++ gcc/testsuite/gcc.dg/darwin-minversion-3.c
-@@ -2,7 +2,8 @@
- /* { dg-options "-mmacosx-version-min=10.4.10" } */
- /* { dg-do compile { target *-*-darwin* } } */
-
--int main(void)
-+int
-+main ()
- {
- #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1040
- fail me;
-diff --git gcc/testsuite/gcc.dg/darwin-minversion-4.c gcc/testsuite/gcc.dg/darwin-minversion-4.c
-new file mode 100644
-index 0000000..1cb42eb
---- /dev/null
-+++ gcc/testsuite/gcc.dg/darwin-minversion-4.c
-@@ -0,0 +1,12 @@
-+/* Test that major versions greater than 9 work and have the additional 0. */
-+/* { dg-options "-mmacosx-version-min=10.10.0" } */
-+/* { dg-do compile { target *-*-darwin* } } */
-+
-+int
-+main ()
-+{
-+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101000
-+ fail me;
-+#endif
-+ return 0;
-+}
---
-2.1.2
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20141119/cc87aa67/attachment-0001.html>
More information about the macports-changes
mailing list