<!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>[136962] trunk/dports/lang/llvm-gcc42</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/136962">136962</a></dd>
<dt>Author</dt> <dd>larryv@macports.org</dd>
<dt>Date</dt> <dd>2015-05-31 22:14:02 -0700 (Sun, 31 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>llvm-gcc42: Fix build on Yosemite (#45449)

It lives!
- Remove kernel version check to stop the driver from complaining about
  Darwin 14 and later.
- Fix interpretation of OS X and iOS deployment targets by adapting my
  upstream fix,† which I'm relicensing under GPLv2 for this purpose.
- Stub out unrecognized macros in `/usr/include/xpc/base.h`.

† https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&amp;view=rev&amp;rev=223808</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportslangllvmgcc42Portfile">trunk/dports/lang/llvm-gcc42/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdportslangllvmgcc42filesautogenpatch">trunk/dports/lang/llvm-gcc42/files/autogen.patch</a></li>
<li><a href="#trunkdportslangllvmgcc42filesfixincludespatch">trunk/dports/lang/llvm-gcc42/files/fixincludes.patch</a></li>
<li><a href="#trunkdportslangllvmgcc42filesremovekernelversioncheckpatch">trunk/dports/lang/llvm-gcc42/files/remove-kernel-version-check.patch</a></li>
<li><a href="#trunkdportslangllvmgcc42filesversionminpatch">trunk/dports/lang/llvm-gcc42/files/version-min.patch</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportslangllvmgcc42Portfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/lang/llvm-gcc42/Portfile (136961 => 136962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/llvm-gcc42/Portfile        2015-05-31 19:19:27 UTC (rev 136961)
+++ trunk/dports/lang/llvm-gcc42/Portfile        2015-06-01 05:14:02 UTC (rev 136962)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> 
</span><span class="cx"> name                    llvm-gcc42
</span><span class="cx"> version                 2336.11
</span><del>-revision                1
</del><ins>+revision                2
</ins><span class="cx"> set gcc_version         4.2.1
</span><span class="cx"> categories              lang
</span><span class="cx"> platforms               darwin
</span><span class="lines">@@ -56,25 +56,22 @@
</span><span class="cx"> # driverdriver-num_infiles.patch : Fix linking with no input files (ie all static archives passed with -l...)
</span><span class="cx"> # driverdriver-armcheck.patch    : Build fix for the driverdriver when arm support is not available (eg: Tiger)
</span><span class="cx"> # deployment_target.patch        : Build fix to correctly get the OS version
</span><ins>+# remove-kernel-version-check.patch : Don't complain on Yosemite and later
+# version-min.patch              : Interpret OS X and iOS versions correctly
+# autogen.patch                  : Update to work with modern autogen (necessary to create fixincludes.patch)
+# fixincludes.patch              : Stub out unrecognized macros in system headers
</ins><span class="cx"> 
</span><span class="cx"> patchfiles-append \
</span><span class="cx">         werror-local-alloc.patch \
</span><span class="cx">         incpath.patch \
</span><span class="cx">         driverdriver-num_infiles.patch \
</span><span class="cx">         driverdriver-armcheck.patch \
</span><del>-        deployment_target.patch
</del><ins>+        deployment_target.patch \
+        remove-kernel-version-check.patch \
+        version-min.patch \
+        autogen.patch \
+        fixincludes.patch
</ins><span class="cx"> 
</span><del>-platform darwin {
-    if {${os.major} &gt;= 14} {
-        depends_lib
-        depends_run
-        pre-fetch {
-            ui_error &quot;$name is not supported on Yosemite or later.&quot;
-            error &quot;unsupported platform&quot;
-        }
-    }
-}
-
</del><span class="cx"> post-extract {
</span><span class="cx">     xinstall -W ${filespath} build_gcc ${worksrcpath}
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkdportslangllvmgcc42filesautogenpatch"></a>
<div class="addfile"><h4>Added: trunk/dports/lang/llvm-gcc42/files/autogen.patch (0 => 136962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/llvm-gcc42/files/autogen.patch                                (rev 0)
+++ trunk/dports/lang/llvm-gcc42/files/autogen.patch        2015-06-01 05:14:02 UTC (rev 136962)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Index: fixincludes/genfixes
+===================================================================
+--- fixincludes/genfixes.orig
++++ fixincludes/genfixes
+@@ -63,7 +63,7 @@ fi
+ AG=&quot;autogen $AG&quot;
+ set -e

+-if [ -z &quot;`${AG} -v | fgrep 'Ver. 5.'`&quot; ]
++if [ -z &quot;`${AG} -v | fgrep ' 5.'`&quot; ]
+ then
+   echo &quot;AutoGen appears to be out of date or not correctly installed.&quot;
+   echo &quot;Please download and install:&quot;
</ins></span></pre></div>
<a id="trunkdportslangllvmgcc42filesfixincludespatch"></a>
<div class="addfile"><h4>Added: trunk/dports/lang/llvm-gcc42/files/fixincludes.patch (0 => 136962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/llvm-gcc42/files/fixincludes.patch                                (rev 0)
+++ trunk/dports/lang/llvm-gcc42/files/fixincludes.patch        2015-06-01 05:14:02 UTC (rev 136962)
</span><span class="lines">@@ -0,0 +1,234 @@
</span><ins>+The important part of this patch is the change to inclhack.def. The new
+fixincl.x was manually generated using AutoGen.
+
+Index: fixincludes/inclhack.def
+===================================================================
+--- fixincludes/inclhack.def.orig
++++ fixincludes/inclhack.def
+@@ -1221,6 +1221,31 @@ fix = {
+ };


++/*
++ *  GCC 4.2 doesn't recognize __has_extension and __has_feature.
++ */
++
++fix = {
++  hackname  = darwin_has_extension;
++  mach      = &quot;*-*-darwin*&quot;;
++  files     = xpc/base.h;
++  select    = &quot;__has_extension\\([A-Za-z_]*\\)&quot;;
++  c_fix     = format;
++  c_fix_arg = &quot;0&quot;;
++  test_text = &quot;#if __has_extension(attribute_unavailable_with_message)&quot;;
++};
++
++fix = {
++  hackname  = darwin_has_feature;
++  mach      = &quot;*-*-darwin*&quot;;
++  files     = xpc/base.h;
++  select    = &quot;__has_feature\\([A-Za-z_]*\\)&quot;;
++  c_fix     = format;
++  c_fix_arg = &quot;0&quot;;
++  test_text = &quot;#if __has_feature(objc_arc)&quot;;
++};
++
++
+ /* APPLE LOCAL begin for-fsf-4_4 5133297 */
+ /*
+  *  On darwin8 and earlier, mach-o/swap.h isn't properly guarded
+Index: fixincludes/fixincl.x
+===================================================================
+--- fixincludes/fixincl.x.orig
++++ fixincludes/fixincl.x
+@@ -1,12 +1,12 @@
+ /*  -*- buffer-read-only: t -*- vi: set ro:
+- * 
++ *
+  * DO NOT EDIT THIS FILE   (fixincl.x)
+- * 
+- * It has been AutoGen-ed  Friday July 17, 2009 at 11:13:21 AM CEST
++ *
++ * It has been AutoGen-ed
+  * From the definitions    inclhack.def
+  * and the template file   fixincl
+  */
+-/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Jul 17 11:13:21 CEST 2009
++/* DO NOT SVN-MERGE THIS FILE, EITHER Sun May 31 21:20:28 EDT 2015
+  *
+  * You must regenerate it.  Use the ./genfixes script.
+  *
+@@ -15,29 +15,25 @@
+  * certain ANSI-incompatible system header files which are fixed to work
+  * correctly with ANSI C and placed in a directory that GNU C will search.
+  *
+- * This file contains 217 fixup descriptions.
++ * This file contains 219 fixup descriptions.
+  *
+  * See README for more information.
+  *
+  *  inclhack copyright (c) 1998, 1999, 2000, 2001
+  *  The Free Software Foundation, Inc.
+  *
+-  *  inclhack is free software.
+- *  
+- *  You may 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.
+- *  
+- *  inclhack is distributed in the hope that it will be useful,
+- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++  *  inclhack 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 3 of the License, or
++ *  (at your option) any later version.
++ *
++ *  inclhack 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 inclhack.  See the file &quot;COPYING&quot;.  If not,
+- *  write to:  The Free Software Foundation, Inc.,
+- *             59 Temple Place - Suite 330,
+- *             Boston,  MA  02111-1307, USA.
++ *
++ *  You should have received a copy of the GNU General Public License along
++ *  with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
+  */

+ /* * * * * * * * * * * * * * * * * * * * * * * * * *
+@@ -1960,6 +1956,80 @@ static const char* apzDarwin_Gcc4_Breaka

+ /* * * * * * * * * * * * * * * * * * * * * * * * * *
+  *
++ *  Description of Darwin_Has_Extension fix
++ */
++tSCC zDarwin_Has_ExtensionName[] =
++     &quot;darwin_has_extension&quot;;
++
++/*
++ *  File name selection pattern
++ */
++tSCC zDarwin_Has_ExtensionList[] =
++  &quot;xpc/base.h\0&quot;;
++/*
++ *  Machine/OS name selection pattern
++ */
++tSCC* apzDarwin_Has_ExtensionMachs[] = {
++        &quot;*-*-darwin*&quot;,
++        (const char*)NULL };
++
++/*
++ *  content selection pattern - do fix if pattern found
++ */
++tSCC zDarwin_Has_ExtensionSelect0[] =
++       &quot;__has_extension\\([A-Za-z_]*\\)&quot;;
++
++#define    DARWIN_HAS_EXTENSION_TEST_CT  1
++static tTestDesc aDarwin_Has_ExtensionTests[] = {
++  { TT_EGREP,    zDarwin_Has_ExtensionSelect0, (regex_t*)NULL }, };
++
++/*
++ *  Fix Command Arguments for Darwin_Has_Extension
++ */
++static const char* apzDarwin_Has_ExtensionPatch[] = {
++    &quot;format&quot;,
++    &quot;0&quot;,
++    (char*)NULL };
++
++/* * * * * * * * * * * * * * * * * * * * * * * * * *
++ *
++ *  Description of Darwin_Has_Feature fix
++ */
++tSCC zDarwin_Has_FeatureName[] =
++     &quot;darwin_has_feature&quot;;
++
++/*
++ *  File name selection pattern
++ */
++tSCC zDarwin_Has_FeatureList[] =
++  &quot;xpc/base.h\0&quot;;
++/*
++ *  Machine/OS name selection pattern
++ */
++tSCC* apzDarwin_Has_FeatureMachs[] = {
++        &quot;*-*-darwin*&quot;,
++        (const char*)NULL };
++
++/*
++ *  content selection pattern - do fix if pattern found
++ */
++tSCC zDarwin_Has_FeatureSelect0[] =
++       &quot;__has_feature\\([A-Za-z_]*\\)&quot;;
++
++#define    DARWIN_HAS_FEATURE_TEST_CT  1
++static tTestDesc aDarwin_Has_FeatureTests[] = {
++  { TT_EGREP,    zDarwin_Has_FeatureSelect0, (regex_t*)NULL }, };
++
++/*
++ *  Fix Command Arguments for Darwin_Has_Feature
++ */
++static const char* apzDarwin_Has_FeaturePatch[] = {
++    &quot;format&quot;,
++    &quot;0&quot;,
++    (char*)NULL };
++
++/* * * * * * * * * * * * * * * * * * * * * * * * * *
++ *
+  *  Description of Darwin_Macho_Swaph_Externc fix
+  */
+ tSCC zDarwin_Macho_Swaph_ExterncName[] =
+@@ -4652,13 +4722,10 @@ tSCC zMath_ExceptionSelect0[] =
+  */
+ tSCC zMath_ExceptionBypass0[] =
+        &quot;We have a problem when using C\\+\\+|for C\\+\\+, _[a-z0-9A-Z_]+_exception; for C, exception&quot;;
+-tSCC zMath_ExceptionBypass1[] =
+-       &quot;defined __cplusplus&quot;;

+ #define    MATH_EXCEPTION_TEST_CT  2
+ static tTestDesc aMath_ExceptionTests[] = {
+   { TT_NEGREP,   zMath_ExceptionBypass0, (regex_t*)NULL },
+-  { TT_NEGREP,   zMath_ExceptionBypass1, (regex_t*)NULL },
+   { TT_EGREP,    zMath_ExceptionSelect0, (regex_t*)NULL }, };

+ /*
+@@ -8842,9 +8909,9 @@ static const char* apzGlibc_Fdzero_Inlin
+  *
+  *  List of all fixes
+  */
+-#define REGEX_COUNT          262
++#define REGEX_COUNT          264
+ #define MACH_LIST_SIZE_LIMIT 261
+-#define FIX_COUNT            217
++#define FIX_COUNT            219

+ /*
+  *  Enumerate the fixes
+@@ -8894,6 +8961,8 @@ typedef enum {
+     CTRL_QUOTES_USE_FIXIDX,
+     CXX_UNREADY_FIXIDX,
+     DARWIN_GCC4_BREAKAGE_FIXIDX,
++    DARWIN_HAS_EXTENSION_FIXIDX,
++    DARWIN_HAS_FEATURE_FIXIDX,
+     DARWIN_MACHO_SWAPH_EXTERNC_FIXIDX,
+     DARWIN_PRIVATE_EXTERN_FIXIDX,
+     DARWIN_STDINT_GUARDS_INTN_FIXIDX,
+@@ -9290,6 +9359,16 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
+      DARWIN_GCC4_BREAKAGE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+      aDarwin_Gcc4_BreakageTests,   apzDarwin_Gcc4_BreakagePatch, 0 },

++  {  zDarwin_Has_ExtensionName,    zDarwin_Has_ExtensionList,
++     apzDarwin_Has_ExtensionMachs,
++     DARWIN_HAS_EXTENSION_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
++     aDarwin_Has_ExtensionTests,   apzDarwin_Has_ExtensionPatch, 0 },
++
++  {  zDarwin_Has_FeatureName,    zDarwin_Has_FeatureList,
++     apzDarwin_Has_FeatureMachs,
++     DARWIN_HAS_FEATURE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
++     aDarwin_Has_FeatureTests,   apzDarwin_Has_FeaturePatch, 0 },
++
+   {  zDarwin_Macho_Swaph_ExterncName,    zDarwin_Macho_Swaph_ExterncList,
+      apzDarwin_Macho_Swaph_ExterncMachs,
+      DARWIN_MACHO_SWAPH_EXTERNC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
</ins></span></pre></div>
<a id="trunkdportslangllvmgcc42filesremovekernelversioncheckpatchfromrev136929trunkdportslanggcc47filesremovekernelversioncheckpatch"></a>
<div class="copfile"><h4>Copied: trunk/dports/lang/llvm-gcc42/files/remove-kernel-version-check.patch (from rev 136929, trunk/dports/lang/gcc47/files/remove-kernel-version-check.patch) (0 => 136962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/llvm-gcc42/files/remove-kernel-version-check.patch                                (rev 0)
+++ trunk/dports/lang/llvm-gcc42/files/remove-kernel-version-check.patch        2015-06-01 05:14:02 UTC (rev 136962)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+commit 9be4ec7ebf2d759114a98b0f532171f0e9e5768d
+Author: fxcoudert &lt;fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4&gt;
+Date:   Sun Sep 14 08:05:43 2014 +0000
+
+            PR target/61407
+
+            * config/darwin-driver.c (darwin_find_version_from_kernel): Removed
+            kernel version check to avoid incrementing it after every major OS X
+            release.
+---
+Extracted from upstream r215251. No code added.
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61407
+https://gcc.gnu.org/viewcvs/gcc?view=rev&amp;rev=215251
+
+Index: gcc/config/darwin-driver.c
+===================================================================
+--- gcc/config/darwin-driver.c.orig
++++ gcc/config/darwin-driver.c
+@@ -174,8 +174,6 @@ darwin_default_min_version (int * argc_p
+   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, '.');
</ins></span></pre></div>
<a id="trunkdportslangllvmgcc42filesversionminpatchfromrev136961trunkdportslanggcc47filesmacosxversionminpatch"></a>
<div class="copfile"><h4>Copied: trunk/dports/lang/llvm-gcc42/files/version-min.patch (from rev 136961, trunk/dports/lang/gcc47/files/macosx-version-min.patch) (0 => 136962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/lang/llvm-gcc42/files/version-min.patch                                (rev 0)
+++ trunk/dports/lang/llvm-gcc42/files/version-min.patch        2015-06-01 05:14:02 UTC (rev 136962)
</span><span class="lines">@@ -0,0 +1,515 @@
</span><ins>+commit 9b0d3d17b04a59bb591c06273d2d5a975f8c5d58
+Author: Lawrence Velázquez &lt;vq@larryv.me&gt;
+Date:   Fri Nov 14 17:52:32 2014 -0500
+
+    Handle OS X deployment targets correctly
+
+    As described in PR target/63810, this addresses several problems with
+    the validation and encoding of deployment target version strings for the
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro.  There are
+    currently four testcases exercising inputs to -mmacosx-version-min
+    (gcc/testsuite/gcc.dg/darwin-minversion-*), but they provide minimal
+    coverage, and one is incorrect.
+
+    * The tiny number is now respected, if present.  Thus &quot;10.9.4&quot;
+      correctly becomes &quot;1094&quot; instead of &quot;1090&quot;, and &quot;10.10.1&quot; becomes
+      &quot;101001&quot; instead of &quot;101000&quot;.
+    * Zero padding is now ignored.  Thus &quot;10.09&quot; correctly becomes &quot;1090&quot;
+      instead of &quot;100900&quot;, and &quot;10.00010&quot; becomes &quot;101000&quot; instead of being
+      treated as invalid.
+    * Deployment targets that are missing minor and tiny numbers are no
+      longer considered invalid.  Thus &quot;10&quot; is treated as &quot;10.0.0&quot;, which
+      becomes &quot;1000&quot; without causing an error.
+
+    With this change, trunk matches the behavior of Apple LLVM Compiler
+    6.1.0 on 8,451 of 8,464 generated test inputs.  (The discrepancies are
+    due to a bug in Clang.)  I don't notice any testsuite regressions on
+    OS X 10.10 Yosemite x86-64.
+
+    2015-05-15  Lawrence Velázquez  &lt;vq@larryv.me&gt;
+
+            PR target/63810
+            * gcc/config/darwin-c.c (version_components): New global enum.
+            (parse_version, version_as_legacy_macro)
+            (version_as_modern_macro, macosx_version_as_macro): New functions.
+            (version_as_macro): Remove.
+            (darwin_cpp_builtins): Use new function.
+            * gcc/testsuite/gcc.dg/darwin-minversion-3.c: Update testcase.
+            * gcc/testsuite/gcc.dg/darwin-minversion-4.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-5.c: New testcase.
+            * gcc/testsuite/gcc.dg/darwin-minversion-6.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-7.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-8.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-9.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-10.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-11.c: Ditto.
+            * gcc/testsuite/gcc.dg/darwin-minversion-12.c: Ditto.
+---
+Adapted for LLVM-GCC 4.2.1 (2336.11) from my upstream trunk fix.
+Extended to fix handling of iOS deployment targets.
+
+I hereby relicense my upstream contributions under GPLv2 when used by
+the MacPorts Project, as permitted by the terms of the FSF copyright
+assignment.
+
+The text above is from my email to the gcc-patches mailing list; some
+minor details may not apply to the patch below.
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63810
+https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01888.html
+https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&amp;view=rev&amp;rev=223808
+
+Index: gcc/config/darwin-c.c
+===================================================================
+--- gcc/config/darwin-c.c.orig
++++ gcc/config/darwin-c.c
+@@ -816,35 +816,158 @@ 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 1042.
+-   Print a warning if the version number is not known.  */
++/* Given an OS X or iOS version VERSION_STR, return it as a statically-allocated
++   array of three integers.  If VERSION_STR is invalid, return NULL.
++
++   VERSION_STR 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 non-negative decimal integer. Omitted
++   tokens become zeros.  For example:
++
++        &quot;10&quot;              becomes       {10,0,0}
++        &quot;10.10&quot;           becomes       {10,10,0}
++        &quot;10.10.1&quot;         becomes       {10,10,1}
++        &quot;10.000010.1&quot;     becomes       {10,10,1}
++        &quot;10.010.001&quot;      becomes       {10,10,1}
++        &quot;000010.10.00001&quot; becomes       {10,10,1}
++        &quot;.9.1&quot;            is invalid
++        &quot;10..9&quot;           is invalid
++        &quot;10.10.&quot;          is invalid  */
++
++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];
++
++  version_len = strlen (version_str);
++  if (version_len &lt; 1)
++    return NULL;
++
++  /* Version string must consist of digits and periods only.  */
++  if (strspn (version_str, &quot;0123456789.&quot;) != version_len)
++    return NULL;
++
++  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
++    return NULL;
++
++  version_array[MAJOR] = strtoul (version_str, &amp;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, &amp;end, 10);
++  version_str = end + ((*end == '.') ? 1 : 0);
++
++  version_array[TINY] = strtoul (version_str, &amp;end, 10);
++
++  /* Version string must contain no more than three tokens.  */
++  if (*end != '\0')
++    return NULL;
++
++  return version_array;
++}
++
++/* Given VERSION -- a three-component OS X 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 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.  Minor and tiny numbers
++   from 10 through 99 are permitted but are clamped to 9 (for example, {10,9,10}
++   produces &quot;1099&quot;).  If VERSION contains numbers greater than 99, it is
++   rejected.  */
++
++static const char *
++version_as_legacy_macro (const unsigned long *version)
++{
++  unsigned long major, minor, tiny;
++  static char result[5];
++
++  major = version[MAJOR];
++  minor = version[MINOR];
++  tiny = version[TINY];
++
++  if (major &gt; 99 || minor &gt; 99 || tiny &gt; 99)
++    return NULL;
++
++  minor = ((minor &gt; 9) ? 9 : minor);
++  tiny = ((tiny &gt; 9) ? 9 : tiny);
++
++  if (sprintf (result, &quot;%lu%lu%lu&quot;, major, minor, tiny) != 4)
++    return NULL;
++
++  return result;
++}
++
++/* Given VERSION -- a three-component OS X or iOS 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 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, with
++   zero-padding if necessary (for example, {8,1,0} produces &quot;80100&quot;, and
++   {10,10,1} produces &quot;101001&quot;).  If VERSION contains numbers greater than 99,
++   it is rejected.  */
++
++static const char *
++version_as_modern_macro (const unsigned long *version)
++{
++  unsigned long major, minor, tiny;
++  static char result[7];
++
++  major = version[MAJOR];
++  minor = version[MINOR];
++  tiny = version[TINY];
++
++  if (major &gt; 99 || minor &gt; 99 || tiny &gt; 99)
++    return NULL;
++
++  if (sprintf (result, &quot;%lu%02lu%02lu&quot;, major, minor, tiny)
++      != ((major &gt; 9) ? 6 : 5))
++    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,
++   &quot;10.9&quot; produces &quot;1090&quot;, and &quot;10.10.1&quot; produces &quot;101001&quot;.)  If
++   darwin_macosx_version_min is invalid and cannot be coerced into a valid
++   form, print a warning and return &quot;1000&quot;.  */
++
+ static const char *
+-/* APPLE LOCAL ARM 5683689 */
+ macosx_version_as_macro (void)
+ {
+-  static char result[] = &quot;1000&quot;;
++  const unsigned long *version_array;
++  const char *version_macro;

+-  if (strncmp (darwin_macosx_version_min, &quot;10.&quot;, 3) != 0)
++  version_array = parse_version (darwin_macosx_version_min);
++  if (!version_array)
+     goto fail;
+-  if (! ISDIGIT (darwin_macosx_version_min[3]))
++
++  if (version_array[MAJOR] != 10)
+     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];
+-    }
++
++  if (version_array[MINOR] &lt; 10)
++    version_macro = version_as_legacy_macro (version_array);
+   else
+-    result[3] = '0';
++    version_macro = version_as_modern_macro (version_array);

+-  return result;
++  if (!version_macro)
++    goto fail;
++
++  return version_macro;

+  fail:
+   error (&quot;Unknown value %qs of -mmacosx-version-min&quot;,
+@@ -863,62 +986,21 @@ macosx_version_as_macro (void)
+ static const char *
+ iphoneos_version_as_macro (void)
+ {
+-  static char result[sizeof (&quot;99.99.99&quot;) + 1];
+-  const char *src_ptr = darwin_iphoneos_version_min;
+-  char *result_ptr = &amp;result[0];
++  const unsigned long *version_array;
++  const char *version_macro;

+-  if (! darwin_iphoneos_version_min)
++  version_array = parse_version (darwin_iphoneos_version_min);
++  if (!version_array)
+     goto fail;

+-  if (! ISDIGIT (*src_ptr))
++  if (version_array[MAJOR] &gt; 9)
+     goto fail;

+-  /* Copy over the major version number.  */
+-  *result_ptr++ = *src_ptr++;
+-
+-  if (ISDIGIT (*src_ptr))
+-    *result_ptr++ = *src_ptr++;
+-
+-  if (*src_ptr != '.')
++  version_macro = version_as_modern_macro (version_array);
++  if (!version_macro)
+     goto fail;

+-  src_ptr++;
+-
+-  /* Start parsing the minor version number.  */
+-  if (! ISDIGIT (*src_ptr))
+-    goto fail;
+-
+-  /* Zero-pad a single-digit value, or copy a two-digit value.  */
+-  *result_ptr++ = ISDIGIT (*(src_ptr + 1)) ? *src_ptr++ : '0';
+-  *result_ptr++ = *src_ptr++;
+-
+-  /* Parse the third version number (patch level?)  */
+-  if (*src_ptr == '\0')
+-    {
+-      /* Not present -- default to zeroes.  */
+-      *result_ptr++ = '0';
+-      *result_ptr++ = '0';
+-    }
+-  else if (*src_ptr == '.')
+-    {
+-      src_ptr++;
+-
+-      if (! ISDIGIT (*src_ptr))
+-        goto fail;
+-
+-      /* Zero-pad a single-digit value, or copy a two-digit value.  */
+-      *result_ptr++ = ISDIGIT (*(src_ptr + 1)) ? *src_ptr++ : '0';
+-      *result_ptr++ = *src_ptr++;
+-    }
+-  else
+-    goto fail;
+-
+-  /* Verify and copy the terminating NULL.  */
+-  if (*src_ptr != '\0')
+-    goto fail;
+- 
+-  *result_ptr++ = '\0'; 
+-  return result;
++  return version_macro;
+   
+  fail:
+   error (&quot;Unknown value %qs of -miphoneos-version-min&quot;,
+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 an OS X minimum version with zero-padded
++   minor and tiny numbers less than 10 produces the correct
++   four-character macro.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=10.07.02&quot; } */
++/* { 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,16 @@
++/* PR target/63810: Test that an OS X minimum version with outrageous
++   zero-padding and a minor number greater than 9 still produces
++   a six-character macro.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=00010.010.0000098&quot; } */
++/* { 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,16 @@
++/* PR target/63810: Test that an OS X minimum version with outrageous
++   zero-padding and a minor number less than 10 still produces
++   a four-character macro.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=010.008.000031&quot; } */
++/* { 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-3.c
+===================================================================
+--- /dev/null
++++ gcc/testsuite/gcc.dg/darwin-minversion-3.c
+@@ -0,0 +1,12 @@
++/* Test that most minor versions less than 10 work.  */
++/* { dg-options &quot;-mmacosx-version-min=10.4.1&quot; } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#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 greater than 9 produce a six-character macro.  */
++/* { dg-options &quot;-mmacosx-version-min=10.10.1&quot; } */
++/* { 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 an OS X minimum version with minor number
++   less than 10 and tiny number greater than 9 produces a four-character
++   macro with the tiny number clamped to 9.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=10.9.10&quot; } */
++/* { 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 &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=10.10.11&quot; } */
++/* { 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 less than 10 are preserved in
++   four-character macros.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=10.9.1&quot; } */
++/* { 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,16 @@
++/* PR target/63810: Test that an OS X minimum version with minor number
++   greater than 9 and no tiny number produces a six-character macro
++   ending in &quot;00&quot;.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=10.11&quot; } */
++/* { 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 an OS X minimum version with a zero-padded
++   minor number less than 10 produces a four-character macro.  */
++/* Added by Lawrence Velázquez &lt;vq@larryv.me&gt;.  */
++
++/* { dg-options &quot;-mmacosx-version-min=10.08.4&quot; } */
++/* { dg-do compile { target *-*-darwin* } } */
++
++int
++main ()
++{
++#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1084
++  fail me;
++#endif
++  return 0;
++}
</ins></span></pre></div>
<a id="trunkdportslangllvmgcc42filesversionminpatch"></a>
<div class="propset"><h4>Property changes: trunk/dports/lang/llvm-gcc42/files/version-min.patch</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="addfile"><h4>Added: svn:mergeinfo</h4></div>
</div>

</body>
</html>