[cfe-commits] [PATCH] Correction for Driver Tools support for OpenBSD

Brad Smith brad at comstyle.com
Mon Sep 10 19:29:31 PDT 2012


On Tue, Sep 04, 2012 at 11:01:48PM -0700, Eric Christopher wrote:
> 
> On Sep 4, 2012, at 4:57 PM, Brad Smith <brad at comstyle.com> wrote:
> 
> > On Mon, Aug 27, 2012 at 05:08:37PM -0400, Brad Smith wrote:
> >> The attached diff corrects the Driver Tools support for OpenBSD
> >> to properly link libpthread_p when using profiling.
> > 
> > Anyone?
> 
> Looks fine, a test case wouldn't go amiss.

How about the following?

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- next part --------------
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 163480)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -4960,14 +4960,21 @@
     // 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: test/Driver/openbsd.c
===================================================================
--- test/Driver/openbsd.c	(revision 163480)
+++ test/Driver/openbsd.c	(working copy)
@@ -3,3 +3,8 @@
 
 // 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> %t.log
+// RUN: FileCheck -input-file %t.log %s
+// 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" "-lpthread_p" "-lc_p" "-lgcc" "{{.*}}crtend.o"


More information about the cfe-commits mailing list