Commit 9c250803 by James Clarke Committed by François-Xavier Coudert

re PR target/61407 (Build errors on latest OS X 10.10 Yosemite with Xcode 6 on GCC 4.8.3)

	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

Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

From-SVN: r215251
parent 1a09cece
2014-09-14 James Clarke <jrtc27@jrtc27.com>
Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
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.
2014-09-13 Jan Hubicka <hubicka@ucw.cz> 2014-09-13 Jan Hubicka <hubicka@ucw.cz>
* tree.c (need_assembler_name_p): Store C++ type mangling only * tree.c (need_assembler_name_p): Store C++ type mangling only
...@@ -79,6 +90,7 @@ ...@@ -79,6 +90,7 @@
(pdp11_scalar_mode_supported_p): New function. (pdp11_scalar_mode_supported_p): New function.
* config/rl78/rl78.h (LIBGCC2_HAS_DF_MODE): Remove. * config/rl78/rl78.h (LIBGCC2_HAS_DF_MODE): Remove.
* config/rx/rx.h (LIBGCC2_HAS_DF_MODE): Remove. * config/rx/rx.h (LIBGCC2_HAS_DF_MODE): Remove.
2014-09-12 Richard Biener <rguenther@suse.de> 2014-09-12 Richard Biener <rguenther@suse.de>
PR middle-end/63237 PR middle-end/63237
...@@ -571,21 +571,34 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp) ...@@ -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 /* Return the value of darwin_macosx_version_min suitable for the
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, so '10.4.2'
so '10.4.2' becomes 1040. The lowest digit is always zero. 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. */ Print a warning if the version number can't be understood. */
static const char * static const char *
version_as_macro (void) version_as_macro (void)
{ {
static char result[] = "1000"; static char result[7] = "1000";
int minorDigitIdx;
if (strncmp (darwin_macosx_version_min, "10.", 3) != 0) if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
goto fail; goto fail;
if (! ISDIGIT (darwin_macosx_version_min[3])) if (! ISDIGIT (darwin_macosx_version_min[3]))
goto fail; goto fail;
result[2] = darwin_macosx_version_min[3];
if (darwin_macosx_version_min[4] != '\0' minorDigitIdx = 3;
&& darwin_macosx_version_min[4] != '.') 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; goto fail;
return result; return result;
......
...@@ -29,8 +29,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,8 +29,8 @@ along with GCC; see the file COPYING3. If not see
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include "xregex.h" #include "xregex.h"
static bool static char *
darwin_find_version_from_kernel (char *new_flag) darwin_find_version_from_kernel (void)
{ {
char osversion[32]; char osversion[32];
size_t osversion_len = sizeof (osversion) - 1; size_t osversion_len = sizeof (osversion) - 1;
...@@ -39,6 +39,7 @@ darwin_find_version_from_kernel (char *new_flag) ...@@ -39,6 +39,7 @@ darwin_find_version_from_kernel (char *new_flag)
char minor_vers[6]; char minor_vers[6];
char * version_p; char * version_p;
char * version_pend; char * version_pend;
char * new_flag;
/* Determine the version of the running OS. If we can't, warn user, /* Determine the version of the running OS. If we can't, warn user,
and do nothing. */ and do nothing. */
...@@ -46,7 +47,7 @@ darwin_find_version_from_kernel (char *new_flag) ...@@ -46,7 +47,7 @@ darwin_find_version_from_kernel (char *new_flag)
&osversion_len, NULL, 0) == -1) &osversion_len, NULL, 0) == -1)
{ {
warning (0, "sysctl for kern.osversion failed: %m"); 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 /* 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) ...@@ -57,8 +58,6 @@ darwin_find_version_from_kernel (char *new_flag)
version_p = osversion + 1; version_p = osversion + 1;
if (ISDIGIT (*version_p)) if (ISDIGIT (*version_p))
major_vers = major_vers * 10 + (*version_p++ - '0'); major_vers = major_vers * 10 + (*version_p++ - '0');
if (major_vers > 4 + 9)
goto parse_failed;
if (*version_p++ != '.') if (*version_p++ != '.')
goto parse_failed; goto parse_failed;
version_pend = strchr(version_p, '.'); version_pend = strchr(version_p, '.');
...@@ -74,17 +73,16 @@ darwin_find_version_from_kernel (char *new_flag) ...@@ -74,17 +73,16 @@ darwin_find_version_from_kernel (char *new_flag)
if (major_vers - 4 <= 4) if (major_vers - 4 <= 4)
/* On 10.4 and earlier, the old linker is used which does not /* On 10.4 and earlier, the old linker is used which does not
support three-component system versions. */ support three-component system versions. */
sprintf (new_flag, "10.%d", major_vers - 4); asprintf (&new_flag, "10.%d", major_vers - 4);
else else
sprintf (new_flag, "10.%d.%s", major_vers - 4, asprintf (&new_flag, "10.%d.%s", major_vers - 4, minor_vers);
minor_vers);
return true; return new_flag;
parse_failed: parse_failed:
warning (0, "couldn%'t understand kern.osversion %q.*s", warning (0, "couldn%'t understand kern.osversion %q.*s",
(int) osversion_len, osversion); (int) osversion_len, osversion);
return false; return NULL;
} }
#endif #endif
...@@ -105,7 +103,7 @@ darwin_default_min_version (unsigned int *decoded_options_count, ...@@ -105,7 +103,7 @@ darwin_default_min_version (unsigned int *decoded_options_count,
const unsigned int argc = *decoded_options_count; const unsigned int argc = *decoded_options_count;
struct cl_decoded_option *const argv = *decoded_options; struct cl_decoded_option *const argv = *decoded_options;
unsigned int i; 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 the command-line is empty, just return. */
if (argc <= 1) if (argc <= 1)
...@@ -142,16 +140,16 @@ darwin_default_min_version (unsigned int *decoded_options_count, ...@@ -142,16 +140,16 @@ darwin_default_min_version (unsigned int *decoded_options_count,
#ifndef CROSS_DIRECTORY_STRUCTURE #ifndef CROSS_DIRECTORY_STRUCTURE
/* Try to find the version from the kernel, if we fail - we print a message /* Try to find the version from the kernel, if we fail - we print a message
and give up. */ and give up. */
if (!darwin_find_version_from_kernel (new_flag)) new_flag = darwin_find_version_from_kernel ();
return; if (!new_flag)
return;
#else #else
/* For cross-compilers, default to the target OS version. */ /* For cross-compilers, default to the target OS version. */
new_flag = DEF_MIN_OSX_VERSION;
strncpy (new_flag, DEF_MIN_OSX_VERSION, sizeof (new_flag));
#endif /* CROSS_DIRECTORY_STRUCTURE */ #endif /* CROSS_DIRECTORY_STRUCTURE */
...@@ -165,7 +163,6 @@ darwin_default_min_version (unsigned int *decoded_options_count, ...@@ -165,7 +163,6 @@ darwin_default_min_version (unsigned int *decoded_options_count,
memcpy (*decoded_options + 2, argv + 1, memcpy (*decoded_options + 2, argv + 1,
(argc - 1) * sizeof (struct cl_decoded_option)); (argc - 1) * sizeof (struct cl_decoded_option));
return; return;
} }
/* Translate -filelist and -framework options in *DECODED_OPTIONS /* Translate -filelist and -framework options in *DECODED_OPTIONS
......
2014-09-14 James Clarke <jrtc27@jrtc27.com>
PR target/61407
* 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
2014-09-13 Marek Polacek <polacek@redhat.com> 2014-09-13 Marek Polacek <polacek@redhat.com>
PR c++/60862 PR c++/60862
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
/* { dg-options "-mmacosx-version-min=10.1" } */ /* { dg-options "-mmacosx-version-min=10.1" } */
/* { dg-do run { target *-*-darwin* } } */ /* { dg-do run { target *-*-darwin* } } */
int main(void) int
main ()
{ {
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
fail me; fail me;
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
/* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */ /* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */
/* { dg-do run { target *-*-darwin* } } */ /* { dg-do run { target *-*-darwin* } } */
int main(void) int
main ()
{ {
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030
fail me; fail me;
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
/* { dg-options "-mmacosx-version-min=10.4.10" } */ /* { dg-options "-mmacosx-version-min=10.4.10" } */
/* { dg-do compile { target *-*-darwin* } } */ /* { 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__ != 1040
fail me; fail me;
......
/* 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;
}
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