[cfe-commits] [PATCH] Bitrig libpthread profiling linking

David Hill dhill at mindcry.org
Thu Sep 20 06:32:21 PDT 2012


Hello,

Attached is a patch to properly link against libpthread_p when using
profiling on Bitrig.

Please review.

Thanks,
David
-------------- next part --------------
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 960ffde..1e9c464 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -5075,8 +5075,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
new file mode 100644
index 0000000..3abac54
--- /dev/null
+++ b/test/Driver/bitrig.c
@@ -0,0 +1,4 @@
+// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target amd64-pc-bitrig -pg -pthread %s -### 2> %t.log
+// RUN: FileCheck -input-file %t.log %s
+// CHECK: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
+// CHECK: 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" "{{.*}}crtend.o"


More information about the cfe-commits mailing list