From: Chandler Carruth Date: Mon, 24 Jun 2013 09:38:45 +0000 (+0000) Subject: The profile library must come before the C library so that it can use X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80a393ead5632b8f3343c0348e8c50157cd7e922;p=clang The profile library must come before the C library so that it can use atexit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184708 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 050db6c0b1..794d3124f5 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -6206,6 +6206,9 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, if (Sanitize.needsLsanRt()) addLsanRTLinux(getToolChain(), Args, CmdArgs); + // The profile runtime also needs access to system libraries. + addProfileRTLinux(getToolChain(), Args, CmdArgs); + if (D.CCCIsCXX && !Args.hasArg(options::OPT_nostdlib) && !Args.hasArg(options::OPT_nodefaultlibs)) { @@ -6262,8 +6265,6 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, } } - addProfileRTLinux(getToolChain(), Args, CmdArgs); - C.addCommand(new Command(JA, *this, ToolChain.Linker.c_str(), CmdArgs)); } diff --git a/test/Driver/coverage-ld.c b/test/Driver/coverage-ld.c index 2ec0486c32..c8910c5c0f 100644 --- a/test/Driver/coverage-ld.c +++ b/test/Driver/coverage-ld.c @@ -7,7 +7,7 @@ // RUN: | FileCheck --check-prefix=CHECK-LINUX-I386 %s // // CHECK-LINUX-I386: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-LINUX-I386: "{{.*}}/Inputs/resource_dir/lib/linux/libclang_rt.profile-i386.a" +// CHECK-LINUX-I386: "{{.*}}/Inputs/resource_dir/lib/linux/libclang_rt.profile-i386.a" {{.*}} "-lc" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux --coverage \ @@ -16,4 +16,4 @@ // RUN: | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s // // CHECK-LINUX-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-LINUX-X86-64: "{{.*}}/Inputs/resource_dir/lib/linux/libclang_rt.profile-x86_64.a" +// CHECK-LINUX-X86-64: "{{.*}}/Inputs/resource_dir/lib/linux/libclang_rt.profile-x86_64.a" {{.*}} "-lc"