[llvm-commits] [llvm-gcc-4.2] r129893 - /llvm-gcc-4.2/trunk/gcc/config/darwin.c
Eric Christopher
echristo at apple.com
Wed Apr 20 16:36:53 PDT 2011
Author: echristo
Date: Wed Apr 20 18:36:53 2011
New Revision: 129893
URL: http://llvm.org/viewvc/llvm-project?rev=129893&view=rev
Log:
Rewrite darwin_llvm_override_target_version to use the new triples and
rewrite old triples to be either ios or macosx depending on the target.
Fixes rdar://9145520
Modified:
llvm-gcc-4.2/trunk/gcc/config/darwin.c
Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin.c?rev=129893&r1=129892&r2=129893&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin.c Wed Apr 20 18:36:53 2011
@@ -2789,59 +2789,50 @@
/* LLVM LOCAL begin radar 6230142 */
unsigned darwin_llvm_override_target_version(const char *triple, char **new_triple) {
- int len = 0, pad1 = 0, pad2 = 0, version = 0;
+ int os_len = 0, base_len = 0, version = 0;
+ int isDarwin = 0, isIOS = 0, isOSX = 0;
char *substr;
-
- if (!darwin_macosx_version_min)
- return 0;
-
+
/* Triple string is expected to look something like 'i386-*-darwin?' or
- 'i386-*-darwin9.5.0' */
- substr = strstr(triple, "darwin");
- if (!substr)
+ 'i386-*-darwin9.5.0' or substituting ios or macosx for the darwin. */
+ if ((substr = strstr (triple, "darwin")) != 0)
+ isDarwin = 1;
+ else if ((substr = strstr (triple, "ios")) != 0)
+ isIOS = 1;
+ else if ((substr = strstr (triple, "macosx")) != 0)
+ isOSX = 1;
+ else
return 0;
- len = substr + 6 - triple;
-
- /* llvm-gcc doesn't support pre-10.0 systems. */
+
+ /* llvm-gcc doesn't support pre-10.0 macosx systems. */
version = strverscmp (darwin_macosx_version_min, "10.0");
if (version < 0)
return 0;
- /* 10.0 is darwin4. */
- version += 4;
-
- /* Darwin version number will be 2 digits for 10.6 and up. */
- if (version >= 10)
- pad1 = 1;
-
- /* If darwin_macosx_version_min is something like 10.4.9, we need to append
- the .9 to the new triple. */
- substr = strchr(darwin_macosx_version_min, '.');
- if (!substr)
- return 0;
- substr = strchr(substr+1, '.');
- if (substr)
- pad2 = strlen(substr);
-
- *new_triple = ggc_alloc (len+pad1+pad2+1);
- strncpy (*new_triple, triple, len);
- if (version >= 10)
- {
- (*new_triple)[len] = '1';
- version -= 10;
- ++len;
- }
- (*new_triple)[len] = '0' + version;
- if (substr)
- {
- int i;
- for (i = 0; i < pad2; ++i)
- (*new_triple)[len+1+i] = substr[i];
- len += pad2;
- }
- (*new_triple)[len+1] = '\0';
+ base_len = substr - triple;
+ if ((isIOS || isDarwin) && darwin_iphoneos_version_min) {
+ os_len = strlen(darwin_iphoneos_version_min) + strlen("ios");
+ *new_triple = ggc_alloc(base_len + os_len + 1);
+ strncpy(*new_triple, triple, base_len);
+ strncpy(*new_triple + base_len, "ios", strlen("ios"));
+ strncpy(*new_triple + base_len + strlen ("ios"),
+ darwin_iphoneos_version_min,
+ strlen(darwin_iphoneos_version_min));
+ (*new_triple)[base_len+os_len+1] = '\0';
+ return 1;
+ } else if ((isOSX || isDarwin) && darwin_macosx_version_min) {
+ os_len = strlen(darwin_macosx_version_min) + strlen("macosx");
+ *new_triple = ggc_alloc(base_len + os_len + 1);
+ strncpy(*new_triple, triple, base_len);
+ strncpy(*new_triple + base_len, "macosx", strlen("macosx"));
+ strncpy(*new_triple + base_len + strlen("macosx"),
+ darwin_macosx_version_min,
+ strlen(darwin_macosx_version_min));
+ (*new_triple)[base_len+os_len+1] = '\0';
+ return 1;
+ }
- return 1;
+ return 0;
}
/* LLVM LOCAL end radar 6230142 */
#include "gt-darwin.h"
More information about the llvm-commits
mailing list