summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Driver/Options.td4
-rw-r--r--clang/lib/Driver/Driver.cpp12
-rw-r--r--clang/test/Driver/print-effective-triple.c6
-rw-r--r--clang/test/Driver/print-target-triple.c6
4 files changed, 28 insertions, 0 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 601aa874496..18781849bff 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2348,6 +2348,10 @@ def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Flags<[Unsupported]>;
+def print_target_triple : Flag<["-", "--"], "print-target-triple">,
+ HelpText<"Print the normalized target triple">;
+def print_effective_triple : Flag<["-", "--"], "print-effective-triple">,
+ HelpText<"Print the effective target triple">;
def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
HelpText<"Print the full program path of <name>">, MetaVarName<"<name>">;
def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 952a716cb6e..350ee0e39dc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1672,6 +1672,18 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
}
return false;
}
+
+ if (C.getArgs().hasArg(options::OPT_print_target_triple)) {
+ llvm::outs() << TC.getTripleString() << "\n";
+ return false;
+ }
+
+ if (C.getArgs().hasArg(options::OPT_print_effective_triple)) {
+ const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
+ llvm::outs() << Triple.getTriple() << "\n";
+ return false;
+ }
+
return true;
}
diff --git a/clang/test/Driver/print-effective-triple.c b/clang/test/Driver/print-effective-triple.c
new file mode 100644
index 00000000000..65b38748d6a
--- /dev/null
+++ b/clang/test/Driver/print-effective-triple.c
@@ -0,0 +1,6 @@
+// Test that -print-target-triple prints correct triple.
+
+// RUN: %clang -print-effective-triple 2>&1 \
+// RUN: --target=thumb-linux-gnu \
+// RUN: | FileCheck %s
+// CHECK: armv4t-unknown-linux-gnu
diff --git a/clang/test/Driver/print-target-triple.c b/clang/test/Driver/print-target-triple.c
new file mode 100644
index 00000000000..70b2493a6fa
--- /dev/null
+++ b/clang/test/Driver/print-target-triple.c
@@ -0,0 +1,6 @@
+// Test that -print-target-triple prints correct triple.
+
+// RUN: %clang -print-target-triple 2>&1 \
+// RUN: --target=x86_64-linux-gnu \
+// RUN: | FileCheck %s
+// CHECK: x86_64-unknown-linux-gnu
OpenPOWER on IntegriCloud