View | Details | Return to bug 61407 | Differences between
and this patch

Collapse All | Expand All

(-)gcc-4.8.3-orig/gcc/config/darwin-c.c (-6 / +19 lines)
Lines 571-591 find_subframework_header (cpp_reader *pf Link Here
571
}
571
}
572
572
573
/* Return the value of darwin_macosx_version_min suitable for the
573
/* Return the value of darwin_macosx_version_min suitable for the
574
   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
574
   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, so '10.4.2'
575
   so '10.4.2' becomes 1040.  The lowest digit is always zero.
575
   becomes 1040 and '10.10.0' becomes 101000.  The lowest digit is
576
   always zero, as is the second lowest for '10.10.x' and above.
576
   Print a warning if the version number can't be understood.  */
577
   Print a warning if the version number can't be understood.  */
577
static const char *
578
static const char *
578
version_as_macro (void)
579
version_as_macro (void)
579
{
580
{
580
  static char result[] = "1000";
581
  static char result[7] = "1000";
582
  int minorDigitIdx;
581
583
582
  if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
584
  if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
583
    goto fail;
585
    goto fail;
584
  if (! ISDIGIT (darwin_macosx_version_min[3]))
586
  if (! ISDIGIT (darwin_macosx_version_min[3]))
585
    goto fail;
587
    goto fail;
586
  result[2] = darwin_macosx_version_min[3];
588
587
  if (darwin_macosx_version_min[4] != '\0'
589
  minorDigitIdx = 3;
588
      && darwin_macosx_version_min[4] != '.')
590
  result[2] = darwin_macosx_version_min[minorDigitIdx++];
591
  if (ISDIGIT (darwin_macosx_version_min[minorDigitIdx]))
592
  {
593
    /* Starting with OS X 10.10, the macro ends '00' rather than '0',
594
       i.e. 10.10.x becomes 101000 rather than 10100.  */
595
    result[3] = darwin_macosx_version_min[minorDigitIdx++];
596
    result[4] = '0';
597
    result[5] = '0';
598
    result[6] = '\0';
599
  }
600
  if (darwin_macosx_version_min[minorDigitIdx] != '\0'
601
      && darwin_macosx_version_min[minorDigitIdx] != '.')
589
    goto fail;
602
    goto fail;
590
603
591
  return result;
604
  return result;
(-)gcc-4.8.3-orig/gcc/config/darwin-driver.c (-19 / +16 lines)
Lines 29-36 along with GCC; see the file COPYING3. Link Here
29
#include <sys/sysctl.h>
29
#include <sys/sysctl.h>
30
#include "xregex.h"
30
#include "xregex.h"
31
31
32
static bool
32
static char *
33
darwin_find_version_from_kernel (char *new_flag)
33
darwin_find_version_from_kernel (void)
34
{
34
{
35
  char osversion[32];
35
  char osversion[32];
36
  size_t osversion_len = sizeof (osversion) - 1;
36
  size_t osversion_len = sizeof (osversion) - 1;
Lines 39-44 darwin_find_version_from_kernel (char *n Link Here
39
  char minor_vers[6];
39
  char minor_vers[6];
40
  char * version_p;
40
  char * version_p;
41
  char * version_pend;
41
  char * version_pend;
42
  char * new_flag;
42
43
43
  /* Determine the version of the running OS.  If we can't, warn user,
44
  /* Determine the version of the running OS.  If we can't, warn user,
44
     and do nothing.  */
45
     and do nothing.  */
Lines 46-52 darwin_find_version_from_kernel (char *n Link Here
46
	      &osversion_len, NULL, 0) == -1)
47
	      &osversion_len, NULL, 0) == -1)
47
    {
48
    {
48
      warning (0, "sysctl for kern.osversion failed: %m");
49
      warning (0, "sysctl for kern.osversion failed: %m");
49
      return false;
50
      return NULL;
50
    }
51
    }
51
52
52
  /* Try to parse the first two parts of the OS version number.  Warn
53
  /* Try to parse the first two parts of the OS version number.  Warn
Lines 57-64 darwin_find_version_from_kernel (char *n Link Here
57
  version_p = osversion + 1;
58
  version_p = osversion + 1;
58
  if (ISDIGIT (*version_p))
59
  if (ISDIGIT (*version_p))
59
    major_vers = major_vers * 10 + (*version_p++ - '0');
60
    major_vers = major_vers * 10 + (*version_p++ - '0');
60
  if (major_vers > 4 + 9)
61
    goto parse_failed;
62
  if (*version_p++ != '.')
61
  if (*version_p++ != '.')
63
    goto parse_failed;
62
    goto parse_failed;
64
  version_pend = strchr(version_p, '.');
63
  version_pend = strchr(version_p, '.');
Lines 74-90 darwin_find_version_from_kernel (char *n Link Here
74
  if (major_vers - 4 <= 4)
73
  if (major_vers - 4 <= 4)
75
    /* On 10.4 and earlier, the old linker is used which does not
74
    /* On 10.4 and earlier, the old linker is used which does not
76
       support three-component system versions.  */
75
       support three-component system versions.  */
77
    sprintf (new_flag, "10.%d", major_vers - 4);
76
    asprintf (&new_flag, "10.%d", major_vers - 4);
78
  else
77
  else
79
    sprintf (new_flag, "10.%d.%s", major_vers - 4,
78
    asprintf (&new_flag, "10.%d.%s", major_vers - 4, minor_vers);
80
	     minor_vers);
81
79
82
  return true;
80
  return new_flag;
83
81
84
 parse_failed:
82
 parse_failed:
85
  warning (0, "couldn%'t understand kern.osversion %q.*s",
83
  warning (0, "couldn%'t understand kern.osversion %q.*s",
86
	   (int) osversion_len, osversion);
84
	   (int) osversion_len, osversion);
87
  return false;
85
  return NULL;
88
}
86
}
89
87
90
#endif
88
#endif
Lines 105-111 darwin_default_min_version (unsigned int Link Here
105
  const unsigned int argc = *decoded_options_count;
103
  const unsigned int argc = *decoded_options_count;
106
  struct cl_decoded_option *const argv = *decoded_options;
104
  struct cl_decoded_option *const argv = *decoded_options;
107
  unsigned int i;
105
  unsigned int i;
108
  static char new_flag[sizeof ("10.0.0") + 6];
106
  const char *new_flag;
109
107
110
  /* If the command-line is empty, just return.  */
108
  /* If the command-line is empty, just return.  */
111
  if (argc <= 1)
109
  if (argc <= 1)
Lines 142-157 darwin_default_min_version (unsigned int Link Here
142
140
143
#ifndef CROSS_DIRECTORY_STRUCTURE
141
#ifndef CROSS_DIRECTORY_STRUCTURE
144
142
145
 /* Try to find the version from the kernel, if we fail - we print a message 
143
  /* Try to find the version from the kernel, if we fail - we print a message 
146
    and give up.  */
144
     and give up.  */
147
 if (!darwin_find_version_from_kernel (new_flag))
145
  new_flag = darwin_find_version_from_kernel ();
148
   return;
146
  if (!new_flag)
147
    return;
149
148
150
#else
149
#else
151
150
152
 /* For cross-compilers, default to the target OS version. */
151
  /* For cross-compilers, default to the target OS version. */
153
152
  new_flag = DEF_MIN_OSX_VERSION;
154
 strncpy (new_flag, DEF_MIN_OSX_VERSION, sizeof (new_flag));
155
153
156
#endif /* CROSS_DIRECTORY_STRUCTURE */
154
#endif /* CROSS_DIRECTORY_STRUCTURE */
157
155
Lines 165-171 darwin_default_min_version (unsigned int Link Here
165
  memcpy (*decoded_options + 2, argv + 1,
163
  memcpy (*decoded_options + 2, argv + 1,
166
	  (argc - 1) * sizeof (struct cl_decoded_option));
164
	  (argc - 1) * sizeof (struct cl_decoded_option));
167
  return;
165
  return;
168
  
169
}
166
}
170
167
171
/* Translate -filelist and -framework options in *DECODED_OPTIONS
168
/* Translate -filelist and -framework options in *DECODED_OPTIONS
(-)gcc-4.8.3-orig/gcc/testsuite/gcc.dg/darwin-minversion-1.c (-1 / +2 lines)
Lines 2-8 Link Here
2
/* { dg-options "-mmacosx-version-min=10.1" } */
2
/* { dg-options "-mmacosx-version-min=10.1" } */
3
/* { dg-do run { target *-*-darwin* } } */
3
/* { dg-do run { target *-*-darwin* } } */
4
4
5
int main(void)
5
int
6
main ()
6
{
7
{
7
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
8
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
8
  fail me;
9
  fail me;
(-)gcc-4.8.3-orig/gcc/testsuite/gcc.dg/darwin-minversion-2.c (-1 / +2 lines)
Lines 2-8 Link Here
2
/* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */
2
/* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */
3
/* { dg-do run { target *-*-darwin* } } */
3
/* { dg-do run { target *-*-darwin* } } */
4
4
5
int main(void)
5
int
6
main ()
6
{
7
{
7
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030
8
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030
8
  fail me;
9
  fail me;
(-)gcc-4.8.3-orig/gcc/testsuite/gcc.dg/darwin-minversion-3.c (-1 / +2 lines)
Lines 2-8 Link Here
2
/* { dg-options "-mmacosx-version-min=10.4.10" } */
2
/* { dg-options "-mmacosx-version-min=10.4.10" } */
3
/* { dg-do compile { target *-*-darwin* } } */
3
/* { dg-do compile { target *-*-darwin* } } */
4
4
5
int main(void)
5
int
6
main ()
6
{
7
{
7
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1040
8
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1040
8
  fail me;
9
  fail me;
(-)gcc-4.8.3-orig/gcc/testsuite/gcc.dg/darwin-minversion-4.c (+12 lines)
Line 0 Link Here
1
/* Test that major versions greater than 9 work and have the additional 0.  */
2
/* { dg-options "-mmacosx-version-min=10.10.0" } */
3
/* { dg-do compile { target *-*-darwin* } } */
4
5
int
6
main ()
7
{
8
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101000
9
  fail me;
10
#endif
11
  return 0;
12
}

Return to bug 61407