<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[127365] trunk/dports/lang/gcc47</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/127365">127365</a></dd>
<dt>Author</dt> <dd>larryv@macports.org</dd>
<dt>Date</dt> <dd>2014-10-25 20:04:58 -0700 (Sat, 25 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>gcc47: Fix OS version check for Yosemite and later (#43978)

Backported from upstream
(https://gcc.gnu.org/viewcvs/gcc?view=revision&amp;revision=215690).</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportslanggcc47Portfile">trunk/dports/lang/gcc47/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdportslanggcc47filesyosemiteversioncheckpatch">trunk/dports/lang/gcc47/files/yosemite-version-check.patch</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportslanggcc47Portfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/lang/gcc47/Portfile (127364 => 127365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/gcc47/Portfile        2014-10-26 02:15:15 UTC (rev 127364)
+++ trunk/dports/lang/gcc47/Portfile        2014-10-26 03:04:58 UTC (rev 127365)
</span><span class="lines">@@ -54,7 +54,8 @@
</span><span class="cx"> depends_skip_archcheck-append gcc_select ld64 cctools
</span><span class="cx"> license_noconflict  gmp mpfr ppl libmpc
</span><span class="cx"> 
</span><del>-patchfiles          ppc_fde_encoding.diff
</del><ins>+patchfiles          ppc_fde_encoding.diff \
+                    yosemite-version-check.patch
</ins><span class="cx"> 
</span><span class="cx"> set major           4.7
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkdportslanggcc47filesyosemiteversioncheckpatch"></a>
<div class="addfile"><h4>Added: trunk/dports/lang/gcc47/files/yosemite-version-check.patch (0 => 127365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/gcc47/files/yosemite-version-check.patch                                (rev 0)
+++ trunk/dports/lang/gcc47/files/yosemite-version-check.patch        2014-10-26 03:04:58 UTC (rev 127365)
</span><span class="lines">@@ -0,0 +1,241 @@
</span><ins>+From 33cd1c2bb44e20e4eecd6ee04c02619ed95aa783 Mon Sep 17 00:00:00 2001
+From: fxcoudert &lt;fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4&gt;
+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[] = &quot;1000&quot;;
++  static char result[7] = &quot;1000&quot;;
++  int minorDigitIdx;

+   if (strncmp (darwin_macosx_version_min, &quot;10.&quot;, 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'
+-      &amp;&amp; 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'
++      &amp;&amp; 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 &lt;sys/sysctl.h&gt;
+ #include &quot;xregex.h&quot;

+-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)
+               &amp;osversion_len, NULL, 0) == -1)
+     {
+       warning (0, &quot;sysctl for kern.osversion failed: %m&quot;);
+-      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 &gt; 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 &lt;= 4)
+     /* On 10.4 and earlier, the old linker is used which does not
+        support three-component system versions.  */
+-    sprintf (new_flag, &quot;10.%d&quot;, major_vers - 4);
++    asprintf (&amp;new_flag, &quot;10.%d&quot;, major_vers - 4);
+   else
+-    sprintf (new_flag, &quot;10.%d.%s&quot;, major_vers - 4,
+-             minor_vers);
++    asprintf (&amp;new_flag, &quot;10.%d.%s&quot;, major_vers - 4, minor_vers);

+-  return true;
++  return new_flag;

+  parse_failed:
+   warning (0, &quot;couldn%'t understand kern.osversion %q.*s&quot;,
+            (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 (&quot;10.0.0&quot;) + 6];
++  const char *new_flag;

+   /* If the command-line is empty, just return.  */
+   if (argc &lt;= 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 &quot;-mmacosx-version-min=10.1&quot; } */
+ /* { 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 &quot;-mmacosx-version-min=10.1 -mmacosx-version-min=10.3&quot; } */
+ /* { 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 &quot;-mmacosx-version-min=10.4.10&quot; } */
+ /* { 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 &quot;-mmacosx-version-min=10.10.0&quot; } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101000
++  fail me;
++#endif
++  return 0;
++}
+-- 
+2.1.2
+
</ins></span></pre>
</div>
</div>

</body>
</html>