From dc6cc87ab68091a714526b391e2a1291d84d485e Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 13 Sep 2012 06:32:34 +0000 Subject: [PATCH] Properly link libpthread_p when using profiling on OpenBSD. 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 | 13 ++++++++++--- test/Driver/openbsd.c | 12 ++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index c0ce50437f..c10df6fc63 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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"); } diff --git a/test/Driver/openbsd.c b/test/Driver/openbsd.c index 911c452c6c..93a740420c 100644 --- a/test/Driver/openbsd.c +++ b/test/Driver/openbsd.c @@ -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" -- 2.50.1