ccc/Darwin/clang: Fix a mistranslation for the llvm-backend; llvm-gcc
doesn't set the relocation model when -mdynamic-no-pic is present.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63129 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py
index 0dcd52e..6272062 100644
--- a/tools/ccc/ccclib/Tools.py
+++ b/tools/ccc/ccclib/Tools.py
@@ -227,7 +227,7 @@
                 cmd_args.extend(arglist.renderAsInput(arg))
         else:
             # Perform argument translation for LLVM backend. This
-            # performs some care in reconciling with llvm-gcc. The
+            # takes some care in reconciling with llvm-gcc. The
             # issue is that llvm-gcc translates these options based on
             # the values in cc1, whereas we are processing based on
             # the driver arguments.
@@ -251,7 +251,7 @@
             if (archName == 'x86_64' or 
                 picEnabled):
                 cmd_args.append('--relocation-model=pic')
-            else:
+            elif not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption):
                 cmd_args.append('--relocation-model=static')
 
             if arglist.getLastArg(arglist.parser.f_timeReportOption):
diff --git a/tools/ccc/test/ccc/darwin-hello.m b/tools/ccc/test/ccc/darwin-hello.m
new file mode 100644
index 0000000..73289e9
--- /dev/null
+++ b/tools/ccc/test/ccc/darwin-hello.m
@@ -0,0 +1,17 @@
+// Check that object files compiled with -mdynamic-no-pic can be
+// linked.
+// 
+// RUN: xcc -ccc-clang -m32 -mdynamic-no-pic %s -c -o %t.o &&
+// RUN: xcc -ccc-clang -m32 %t.o -o %t &&
+// RUN: %t | grep "Hello, World" &&
+// RUN: xcc -ccc-clang -m64 -mdynamic-no-pic %s -c -o %t.o &&
+// RUN: xcc -ccc-clang -m64 %t.o -o %t &&
+// RUN: %t | grep "Hello, World" &&
+// RUN: true
+
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+  fprintf(stdout, "Hello, World");
+  return 0;
+}