On Fri, Oct 21, 2011 at 5:27 PM, Eric Christopher <[email protected]> wrote:
>
> On Oct 21, 2011, at 3:22 PM, James Molloy wrote:
>
> Eric, I agree that this is only a stopgap until a "new and improved" driver
> mechanism is in place, but it does look to be a good addition?
>
> Yeah, should be fine. I was mostly coming up with doomsday scenarios of bug
> reports due to people not knowing that /a/b/clang only supports arm while
> /d/e/clang only supports x86, but thought better about it :)

Eric, could you please commit the configure --target patches?
I have attached an updated version of the patches on top of
today's trunk.

Thanks,
Sebastian
--
Qualcomm Innovation Center, Inc is a member of Code Aurora Forum
From f862fa81e016f752e9df9de2902c8d6bb819a235 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <[email protected]>
Date: Tue, 11 Oct 2011 12:04:55 -0500
Subject: [PATCH] add getDefaultTargetTriple

---
 autoconf/configure.ac                   |    2 ++
 configure                               |    5 +++++
 include/llvm/Config/config.h.cmake      |    3 +++
 include/llvm/Config/config.h.in         |    3 +++
 include/llvm/Config/llvm-config.h.cmake |    3 +++
 include/llvm/Config/llvm-config.h.in    |    3 +++
 include/llvm/Support/Host.h             |    9 +++++++++
 lib/Support/Unix/Host.inc               |   19 +++++++++++++------
 lib/Support/Windows/Host.inc            |    5 +++++
 9 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 89f8467..f23c3e7 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -1459,6 +1459,8 @@ AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
                    [Time at which LLVM was configured])
 AC_DEFINE_UNQUOTED(LLVM_HOSTTRIPLE, "$host",
                    [Host triple we were built on])
+AC_DEFINE_UNQUOTED(LLVM_DEFAULT_TARGET_TRIPLE, "$target",
+                   [Default target triple to build for])
 
 # Determine which bindings to build.
 if test "$BINDINGS_TO_BUILD" = auto ; then
diff --git a/configure b/configure
index a82cccb..e1f60b7 100755
--- a/configure
+++ b/configure
@@ -20874,6 +20874,11 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+cat >>confdefs.h <<_ACEOF
+#define LLVM_DEFAULT_TARGET_TRIPLE "$target"
+_ACEOF
+
+
 # Determine which bindings to build.
 if test "$BINDINGS_TO_BUILD" = auto ; then
   BINDINGS_TO_BUILD=""
diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake
index e44d429..9c56c99 100644
--- a/include/llvm/Config/config.h.cmake
+++ b/include/llvm/Config/config.h.cmake
@@ -557,6 +557,9 @@
 /* Host triple we were built on */
 #cmakedefine LLVM_HOSTTRIPLE "${LLVM_HOSTTRIPLE}"
 
+/* Default target triple to build for */
+#cmakedefine LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}"
+
 /* Installation directory for include files */
 #cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"
 
diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in
index 3670de5..b767e46 100644
--- a/include/llvm/Config/config.h.in
+++ b/include/llvm/Config/config.h.in
@@ -543,6 +543,9 @@
 /* Installation directory for data files */
 #undef LLVM_DATADIR
 
+/* Default target triple to build for */
+#undef LLVM_DEFAULT_TARGET_TRIPLE
+
 /* Installation directory for documentation */
 #undef LLVM_DOCSDIR
 
diff --git a/include/llvm/Config/llvm-config.h.cmake b/include/llvm/Config/llvm-config.h.cmake
index 4147fd1..ff3ab74 100644
--- a/include/llvm/Config/llvm-config.h.cmake
+++ b/include/llvm/Config/llvm-config.h.cmake
@@ -37,6 +37,9 @@
 /* Host triple we were built on */
 #cmakedefine LLVM_HOSTTRIPLE "${LLVM_HOSTTRIPLE}"
 
+/* Default target triple to build for */
+#cmakedefine LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}"
+
 /* Installation directory for include files */
 #cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"
 
diff --git a/include/llvm/Config/llvm-config.h.in b/include/llvm/Config/llvm-config.h.in
index b2257f3..49288fd 100644
--- a/include/llvm/Config/llvm-config.h.in
+++ b/include/llvm/Config/llvm-config.h.in
@@ -37,6 +37,9 @@
 /* Host triple we were built on */
 #undef LLVM_HOSTTRIPLE
 
+/* Default target triple to build for */
+#undef LLVM_DEFAULT_TARGET_TRIPLE
+
 /* Installation directory for include files */
 #undef LLVM_INCLUDEDIR
 
diff --git a/include/llvm/Support/Host.h b/include/llvm/Support/Host.h
index f77d4c1..ec17a4d 100644
--- a/include/llvm/Support/Host.h
+++ b/include/llvm/Support/Host.h
@@ -33,6 +33,15 @@ namespace sys {
     return !isLittleEndianHost();
   }
 
+  /// getDefaultTargetTriple() - Return the triple of the default
+  /// target system.
+  ///
+  /// The target triple is a string in the format of:
+  ///   CPU_TYPE-VENDOR-OPERATING_SYSTEM
+  /// or
+  ///   CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
+  std::string getDefaultTargetTriple();
+
   /// getHostTriple() - Return the target triple of the running
   /// system.
   ///
diff --git a/lib/Support/Unix/Host.inc b/lib/Support/Unix/Host.inc
index dda3ce2..f76ed2a 100644
--- a/lib/Support/Unix/Host.inc
+++ b/lib/Support/Unix/Host.inc
@@ -35,12 +35,9 @@ static std::string getOSVersion() {
   return info.release;
 }
 
-std::string sys::getHostTriple() {
-  // FIXME: Derive directly instead of relying on the autoconf generated
-  // variable.
-
-  StringRef HostTripleString(LLVM_HOSTTRIPLE);
-  std::pair<StringRef, StringRef> ArchSplit = HostTripleString.split('-');
+static std::string getTriple(const char *name) {
+  StringRef TripleString(name);
+  std::pair<StringRef, StringRef> ArchSplit = TripleString.split('-');
 
   // Normalize the arch, since the host triple may not actually match the host.
   std::string Arch = ArchSplit.first;
@@ -64,3 +61,13 @@ std::string sys::getHostTriple() {
 
   return Triple;
 }
+
+std::string sys::getDefaultTargetTriple() {
+  return getTriple(LLVM_DEFAULT_TARGET_TRIPLE);
+}
+
+std::string sys::getHostTriple() {
+  // FIXME: Derive directly instead of relying on the autoconf generated
+  // variable.
+  return getTriple(LLVM_HOSTTRIPLE);
+}
diff --git a/lib/Support/Windows/Host.inc b/lib/Support/Windows/Host.inc
index 733830e..278550a 100644
--- a/lib/Support/Windows/Host.inc
+++ b/lib/Support/Windows/Host.inc
@@ -21,3 +21,8 @@ std::string sys::getHostTriple() {
   // FIXME: Adapt to running version.
   return LLVM_HOSTTRIPLE;
 }
+
+std::string sys::getDefaultTargetTriple() {
+  // FIXME: Adapt to running version.
+  return LLVM_DEFAULT_TARGET_TRIPLE;
+}
-- 
1.7.4.1

From 1817fe39718b6b35b4992570f7330a531229ffad Mon Sep 17 00:00:00 2001
From: Sebastian Pop <[email protected]>
Date: Tue, 11 Oct 2011 12:07:51 -0500
Subject: [PATCH] use getDefaultTargetTriple instead of getHostTriple

---
 examples/clang-interpreter/main.cpp              |    2 +-
 lib/Frontend/CompilerInvocation.cpp              |    4 ++--
 lib/Frontend/CreateInvocationFromCommandLine.cpp |    2 +-
 tools/driver/cc1as_main.cpp                      |    4 ++--
 tools/driver/driver.cpp                          |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/clang-interpreter/main.cpp b/examples/clang-interpreter/main.cpp
index c9734e5..4192c09 100644
--- a/examples/clang-interpreter/main.cpp
+++ b/examples/clang-interpreter/main.cpp
@@ -76,7 +76,7 @@ int main(int argc, const char **argv, char * const *envp) {
 
   llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
   DiagnosticsEngine Diags(DiagID, DiagClient);
-  Driver TheDriver(Path.str(), llvm::sys::getHostTriple(),
+  Driver TheDriver(Path.str(), llvm::sys::getDefaultTargetTriple(),
                    "a.out", /*IsProduction=*/false, Diags);
   TheDriver.setTitle("clang interpreter");
 
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index f1d98b9..ab61fbe 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -1912,9 +1912,9 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
   Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
 
-  // Use the host triple if unspecified.
+  // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
-    Opts.Triple = llvm::sys::getHostTriple();
+    Opts.Triple = llvm::sys::getDefaultTargetTriple();
 }
 
 //
diff --git a/lib/Frontend/CreateInvocationFromCommandLine.cpp b/lib/Frontend/CreateInvocationFromCommandLine.cpp
index fc15081..e94b944 100644
--- a/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -48,7 +48,7 @@ clang::createInvocationFromCommandLine(ArrayRef<const char *> ArgList,
   Args.push_back("-fsyntax-only");
 
   // FIXME: We shouldn't have to pass in the path info.
-  driver::Driver TheDriver("clang", llvm::sys::getHostTriple(),
+  driver::Driver TheDriver("clang", llvm::sys::getDefaultTargetTriple(),
                            "a.out", false, *Diags);
 
   // Don't check that inputs exist, they may have been remapped.
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index 4215a32..5a17512 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/tools/driver/cc1as_main.cpp
@@ -151,8 +151,8 @@ void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
 
   // Target Options
   Opts.Triple = Triple::normalize(Args->getLastArgValue(OPT_triple));
-  if (Opts.Triple.empty()) // Use the host triple if unspecified.
-    Opts.Triple = sys::getHostTriple();
+  if (Opts.Triple.empty()) // Use the default target triple if unspecified.
+    Opts.Triple = sys::getDefaultTargetTriple();
 
   // Language Options
   Opts.IncludePaths = Args->getAllArgValues(OPT_I);
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index bd1d2a2..4f5d3fe 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -382,7 +382,7 @@ int main(int argc_, const char **argv_) {
 #else
   const bool IsProduction = false;
 #endif
-  Driver TheDriver(Path.str(), llvm::sys::getHostTriple(),
+  Driver TheDriver(Path.str(), llvm::sys::getDefaultTargetTriple(),
                    "a.out", IsProduction, Diags);
 
   // Attempt to find the original path used to invoke the driver, to determine
-- 
1.7.4.1

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to