[cfe-commits] [PATCH] Bitrig - support -lpthread_p when -pg is used.

David Hill dhill at mindcry.org
Mon Oct 8 18:38:11 PDT 2012


Hello -

Attached is a diff to support linking against -lpthread_p when -pg is
used.

Please review and commit.

Thanks,
David Hill
-------------- next part --------------
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 71c7ca2..c7c4bc5 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -5141,8 +5141,14 @@ void bitrig::Link::ConstructJob(Compilation &C, const JobAction &JA,
         CmdArgs.push_back("-lm");
     }
 
-    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))
         CmdArgs.push_back("-lc_p");
diff --git a/test/Driver/bitrig.c b/test/Driver/bitrig.c
index 6359bb4..99e58f0 100644
--- a/test/Driver/bitrig.c
+++ b/test/Driver/bitrig.c
@@ -3,6 +3,11 @@
 // CHECK-LD-C: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
 // CHECK-LD-C: ld{{.*}}" {{.*}} "-lc" "-lclang_rt.amd64"
 
+// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target amd64-pc-bitrig -pg -pthread %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG %s
+// CHECK-PG: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
+// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lpthread_p" "-lc_p" "-lclang_rt.amd64"
+
 // RUN: %clangxx -no-canonical-prefixes -ccc-clang-archs "" -target amd64-pc-bitrig %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-CXX %s
 // CHECK-LD-CXX: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig" 


More information about the cfe-commits mailing list