]> granicus.if.org Git - clang/commitdiff
ccc/Darwin/clang: Fix a mistranslation for the llvm-backend; llvm-gcc
authorDaniel Dunbar <daniel@zuster.org>
Tue, 27 Jan 2009 20:42:58 +0000 (20:42 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 27 Jan 2009 20:42:58 +0000 (20:42 +0000)
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

tools/ccc/ccclib/Tools.py
tools/ccc/test/ccc/darwin-hello.m [new file with mode: 0644]

index 0dcd52e7266dedc6fe6f31cf67e7af8a0a8bf9e1..62720624cb1c142c93463e3755a20da4a58e857f 100644 (file)
@@ -227,7 +227,7 @@ class Clang_CompileTool(Tool):
                 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 @@ class Clang_CompileTool(Tool):
             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 (file)
index 0000000..73289e9
--- /dev/null
@@ -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;
+}