[cfe-commits] [PATCH] Bitrig - multiple changes

David Hill dhill at mindcry.org
Wed Oct 17 18:26:57 PDT 2012


Thanks for the partial commit and info regarding the tests.

Attached is a new diff that hopefully with simpler tests.

Is this ok?

On Wed, Oct 17, 2012 at 02:37:59AM -0700, Chandler Carruth wrote:
> Orthogonal cleanups such as -ccc-clang-archs removal should be in a
> separate patch generally speaking. I'll go ahead and apply that part to
> save a round trip.
> 
> The test cases though look much like the original test cases in the patch I
> cleaned up for you. I had to edit those test cases significantly to get
> them to pass on Linux. Could you try to write the assertions in a manner
> more similar to the ones I ended up checking in? Specifically there is no
> reason to check every argument to the linker when you're really trying to
> isolate and test a single feature. The way you've written in the tests are
> simply too brittle.
> 
> 
> On Tue, Oct 16, 2012 at 7:37 PM, David Hill <dhill at mindcry.org> wrote:
> 
> > How is this?
> >
> > On Tue, Oct 16, 2012 at 05:24:59PM -0700, Eli Friedman wrote:
> > > On Mon, Oct 15, 2012 at 9:00 AM, David Hill <dhill at mindcry.org> wrote:
> > > > Ping.  Can someone commit this?
> > >
> > > +    if (Args.hasArg(options::OPT_pthread)) {
> > > +      if (!Args.hasArg(options::OPT_shared) &&
> > > +          Args.hasArg(options::OPT_pg))
> > >
> > > I'd like to see a driver test where the check for -shared matters.
> > >
> > > -Eli
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> >
> >
-------------- next part --------------
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 760fc8b..938f888 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -5160,8 +5160,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 8e9c1db..3e6768b 100644
--- a/test/Driver/bitrig.c
+++ b/test/Driver/bitrig.c
@@ -12,3 +12,13 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-CXX-STDLIB %s
 // CHECK-LD-CXX-STDLIB: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
 // CHECK-LD-CXX-STDLIB: ld{{.*}}" {{.*}} "-lc++" "-lcxxrt" "-lgcc" "-lm" "-lc" "-lclang_rt.amd64"
+
+// RUN: %clang -no-canonical-prefixes -target amd64-pc-bitrig -pg -pthread %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-PTHREAD %s
+// CHECK-PG-PTHREAD: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
+// CHECK-PG-PTHREAD: ld{{.*}}" {{.*}} "{{.*}}crtbegin.o" {{.*}}.o" "-lpthread_p" "-lc_p" "-lclang_rt.amd64" "{{.*}}crtend.o"
+
+// RUN: %clang -no-canonical-prefixes -target amd64-pc-bitrig -shared -pg -pthread %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-PTHREAD-SHARED %s
+// CHECK-PG-PTHREAD-SHARED: clang{{.*}}" "-cc1" "-triple" "amd64-pc-bitrig"
+// CHECK-PG-PTHREAD-SHARED: ld{{.*}}" {{.*}} "{{.*}}crtbeginS.o" {{.*}}.o" "-lpthread" "-lclang_rt.amd64" "{{.*}}crtendS.o"


More information about the cfe-commits mailing list