[llvm-commits] [127823] Set __APPLE_CC__ value to base gcc build number
dpatel at apple.com
dpatel at apple.com
Wed May 30 11:12:11 PDT 2007
Revision: 127823
Author: dpatel
Date: 2007-05-30 11:12:10 -0700 (Wed, 30 May 2007)
Log Message:
-----------
Set __APPLE_CC__ value to base gcc build number
instead of llvm build number.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/c-cppbuiltin.c
apple-local/branches/llvm/gcc/version.c
Modified: apple-local/branches/llvm/gcc/c-cppbuiltin.c
===================================================================
--- apple-local/branches/llvm/gcc/c-cppbuiltin.c 2007-05-30 15:40:29 UTC (rev 127822)
+++ apple-local/branches/llvm/gcc/c-cppbuiltin.c 2007-05-30 18:12:10 UTC (rev 127823)
@@ -329,24 +329,37 @@
/* APPLE LOCAL begin LLVM version number */
#else
#ifdef CONFIG_DARWIN_H
+ /* This chunk of code defines __APPLE_CC__ from the version
+ string. It expects to see a substring of the version string of
+ the form "build NNNN)", where each N is a digit, and the first
+ N is nonzero (there can be 4 or 5 digits). It will abort() if
+ these conditions are not met, since that usually means that
+ someone's broken the version string. */
+
/* LLVM builds multiple different ways. For example, for official releases,
the version number is something like "1.8". We don't want to disable
__APPLE_CC__ entirely, as this breaks system headers. If the build number
- is not a 4-digit code, just define __APPLE_CC__ to 1.
+ is not a 4-digit code, just define __APPLE_CC__ to 1 instead of abort()ing
+ as per above comment.
*/
{
- char Version[] = LLVM_VERSION_INFO;
- if (! ISDIGIT (Version[0])
- || ! ISDIGIT (Version[1])
- || ! ISDIGIT (Version[2])
- || ! ISDIGIT (Version[3])
- || Version[4] != 0) {
- Version[0] = '1';
- Version[1] = '\0';
- builtin_define_with_value_n ("__APPLE_CC__", Version, 1);
- } else {
- builtin_define_with_value_n ("__APPLE_CC__", Version, 4);
- }
+ const char *vt;
+
+ vt = strstr (version_string, "build ");
+ if (vt == NULL)
+ builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+
+ vt += strlen ("build ");
+ if (! ISDIGIT (*vt))
+ builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+ for (q = vt; *q != 0 && ISDIGIT (*q); q++)
+ ;
+ if (q == vt || *q != ')')
+ builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+
+ if ((q - vt != 4 && q - vt != 5) || *vt == '0')
+ builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+ builtin_define_with_value_n ("__APPLE_CC__", vt, q - vt);
}
#endif /*CONFIG_DARWIN_H*/
#endif /*LLVM_VERSION_INFO*/
Modified: apple-local/branches/llvm/gcc/version.c
===================================================================
--- apple-local/branches/llvm/gcc/version.c 2007-05-30 15:40:29 UTC (rev 127822)
+++ apple-local/branches/llvm/gcc/version.c 2007-05-30 18:12:10 UTC (rev 127823)
@@ -16,17 +16,15 @@
to get version number string. Do not use new line.
*/
-const char version_string[] = "4.0.1 "
+const char version_string[] = "4.0.1 (Apple Computer, Inc. build 5449)"
#ifdef ENABLE_LLVM
- "LLVM "
-#endif
- "(Apple Computer, Inc. build "
+ "(LLVM build "
#ifdef LLVM_VERSION_INFO
LLVM_VERSION_INFO
-#else
- "5449"
#endif
- ")";
+ ")"
+#endif
+ ;
/* APPLE LOCAL end Apple version */
/* This is the location of the online document giving instructions for
More information about the llvm-commits
mailing list