[llvm-commits] [llvm-gcc-4.2] r56370 - in /llvm-gcc-4.2/trunk/gcc: config/darwin.c config/darwin.h llvm-backend.cpp
Evan Cheng
evan.cheng at apple.com
Fri Sep 19 13:59:22 PDT 2008
Author: evancheng
Date: Fri Sep 19 15:59:22 2008
New Revision: 56370
URL: http://llvm.org/viewvc/llvm-project?rev=56370&view=rev
Log:
Determine the correct target triple string when -mmacosx-version-min is specified. This is Mac OS X only.
Modified:
llvm-gcc-4.2/trunk/gcc/config/darwin.c
llvm-gcc-4.2/trunk/gcc/config/darwin.h
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
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=56370&r1=56369&r2=56370&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin.c Fri Sep 19 15:59:22 2008
@@ -2671,4 +2671,43 @@
return type_node == ccfstring_type_node;
}
/* APPLE LOCAL end radar 4985544 */
+
+/* APPLE LOCAL begin radar 6230142 */
+bool darwin_llvm_override_target_version(const char *triple, char **new_triple) {
+ int len = 0, version = 0;
+
+ if (!darwin_macosx_version_min)
+ return false;
+
+ /* Triple string is expected to look something like 'i386-apple-darwin?'. */
+ len = strlen (triple);
+ if (len < 7)
+ return false;
+ if (strncmp (&triple[len - 7], "darwin", 6) != 0)
+ return (char *)triple;
+
+ /* llvm-gcc doesn't support pre-10.0 systems. */
+ version = strverscmp (darwin_macosx_version_min, "10.0");
+ if (version < 0)
+ return false;
+
+ /* 10.0 is darwin4. */
+ version += 4;
+
+ /* Darwin version number will be 2 digits for 10.6 and up. */
+ if (version >= 10)
+ ++len;
+ *new_triple = ggc_alloc (len+1);
+ strcpy (*new_triple, triple);
+ if (version >= 10)
+ {
+ (*new_triple)[len-2] = '1';
+ version -= 10;
+ }
+ (*new_triple)[len-1] = '0' + version;
+ (*new_triple)[len] = '\0';
+
+ return true;
+}
+/* APPLE LOCAL end radar 6230142 */
#include "gt-darwin.h"
Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin.h?rev=56370&r1=56369&r2=56370&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin.h Fri Sep 19 15:59:22 2008
@@ -1564,4 +1564,10 @@
#undef TARGET_BUILD_SYSROOT_PATH
#define TARGET_BUILD_SYSROOT_PATH(S,P) darwin_build_sysroot_path((S), (P))
/* LLVM LOCAL end sysroot */
+
+/* APPLE LOCAL begin radar 6230142 */
+extern bool darwin_llvm_override_target_version(const char*, char**);
+#define LLVM_OVERRIDE_TARGET_VERSION(T,N) \
+ darwin_llvm_override_target_version(T,N)
+/* APPLE LOCAL end radar 6230142 */
#endif /* CONFIG_DARWIN_H */
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=56370&r1=56369&r2=56370&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Fri Sep 19 15:59:22 2008
@@ -192,6 +192,13 @@
TargetTriple = Arch + TargetTriple.substr(DashPos);
}
#endif
+#ifdef LLVM_OVERRIDE_TARGET_VERSION
+ char *NewTriple;
+ bool OverRidden = LLVM_OVERRIDE_TARGET_VERSION(TargetTriple.c_str(),
+ &NewTriple);
+ if (OverRidden)
+ TargetTriple = std::string(NewTriple);
+#endif
TheModule->setTargetTriple(TargetTriple);
TheTypeConverter = new TypeConverter();
More information about the llvm-commits
mailing list