]> granicus.if.org Git - clang/commitdiff
Properly link libpthread_p when using profiling on OpenBSD.
authorEric Christopher <echristo@apple.com>
Thu, 13 Sep 2012 06:32:34 +0000 (06:32 +0000)
committerEric Christopher <echristo@apple.com>
Thu, 13 Sep 2012 06:32:34 +0000 (06:32 +0000)
Patch by Brad Smith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163777 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/openbsd.c

index c0ce50437ffcb941d73d262a5efbb156f9ff3236..c10df6fc6344d161341bc85387b84dabaeffa2e2 100644 (file)
@@ -4943,14 +4943,21 @@ void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
     // the default system libraries. Just mimic this for now.
     CmdArgs.push_back("-lgcc");
 
-    if (Args.hasArg(options::OPT_pthread))
-      CmdArgs.push_back("-lpthread");
+    if (Args.hasArg(options::OPT_pthread)) {
+      if (!Args.hasArg(options::OPT_shared) &&
+          Args.hasArg(options::OPT_pg))
+         CmdArgs.push_back("-lpthread_p");
+      else
+         CmdArgs.push_back("-lpthread");
+    }
+
     if (!Args.hasArg(options::OPT_shared)) {
-      if (Args.hasArg(options::OPT_pg)) 
+      if (Args.hasArg(options::OPT_pg))
          CmdArgs.push_back("-lc_p");
       else
          CmdArgs.push_back("-lc");
     }
+
     CmdArgs.push_back("-lgcc");
   }
 
index 911c452c6c18c725a90da30685c6a7f6c85c3b80..93a740420cf4bf4639722a5ab013f836a4813a8f 100644 (file)
@@ -1,5 +1,9 @@
-// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target i686-pc-openbsd %s -### 2> %t.log
-// RUN: FileCheck -input-file %t.log %s
+// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD %s
+// CHECK-LD: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK-LD: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
 
-// CHECK: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
+// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target i686-pc-openbsd -pg -pthread %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG %s
+// CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lpthread_p" "-lc_p" "-lgcc" "{{.*}}crtend.o"