Fix for rhbz#1674031

This commit is contained in:
sergesanspaille 2019-05-22 11:27:00 +00:00
parent fe4c5544fa
commit fbb26fda6e
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,99 @@
From ccfe04576c13497b9c422ceef0b6efe99077a392 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar@redhat.com>
Date: Thu, 16 May 2019 00:07:53 +0000
Subject: [PATCH] Merging r360674:
------------------------------------------------------------------------
r360674 | russell_gallop | 2019-05-14 07:01:40 -0700 (Tue, 14 May 2019) | 7 lines
[Driver][Windows] Add dependent lib argument for profile instr generate
This is needed so lld-link can find clang_rt.profile when self hosting
on Windows with PGO. Using clang-cl as a linker knows to add the library
but self hosting, using -DCMAKE_LINKER=<...>/lld-link.exe doesn't.
Differential Revision: https://reviews.llvm.org/D61742
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_80@360828 91177308-0d34-0410-b5e6-96231b3b80d8
---
lib/Driver/ToolChains/Clang.cpp | 12 +++++++++---
test/Driver/cl-options.c | 2 +-
test/Driver/instrprof-ld.c | 14 ++++++++++++++
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp
index 589f53b119..78ee7a7817 100644
--- a/lib/Driver/ToolChains/Clang.cpp
+++ b/lib/Driver/ToolChains/Clang.cpp
@@ -718,8 +718,9 @@ static void appendUserToPath(SmallVectorImpl<char> &Result) {
Result.append(UID.begin(), UID.end());
}
-static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
- const InputInfo &Output, const ArgList &Args,
+static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
+ const Driver &D, const InputInfo &Output,
+ const ArgList &Args,
ArgStringList &CmdArgs) {
auto *PGOGenerateArg = Args.getLastArg(options::OPT_fprofile_generate,
@@ -759,6 +760,11 @@ static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
ProfileGenerateArg->getValue()));
// The default is to use Clang Instrumentation.
CmdArgs.push_back("-fprofile-instrument=clang");
+ if (TC.getTriple().isWindowsMSVCEnvironment()) {
+ // Add dependent lib for clang_rt.profile
+ CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
+ TC.getCompilerRT(Args, "profile")));
+ }
}
if (PGOGenerateArg) {
@@ -4118,7 +4124,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// sampling, overhead of call arc collection is way too high and there's no
// way to collect the output.
if (!Triple.isNVPTX())
- addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
+ addPGOAndCoverageFlags(TC, C, D, Output, Args, CmdArgs);
if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
ABICompatArg->render(Args, CmdArgs);
diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c
index 909e391cec..5048fd25c4 100644
--- a/test/Driver/cl-options.c
+++ b/test/Driver/cl-options.c
@@ -66,7 +66,7 @@
// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
// RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
// RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
// CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
// CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
diff --git a/test/Driver/instrprof-ld.c b/test/Driver/instrprof-ld.c
index ea20105699..1ac3f9650f 100644
--- a/test/Driver/instrprof-ld.c
+++ b/test/Driver/instrprof-ld.c
@@ -121,3 +121,17 @@
//
// CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
// CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
+
+// Test instrumented profiling dependent-lib flags
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-pc-win32 \
+// RUN: -fprofile-instr-generate 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-WINDOWS-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-WINDOWS-X86-64-DEPENDENT-LIB: "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-mingw32 \
+// RUN: -fprofile-instr-generate 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MINGW-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-MINGW-X86-64-DEPENDENT-LIB-NOT: "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.a"
--
2.20.1

View File

@ -61,7 +61,7 @@
Name: %pkg_name
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
Release: 2%{?rc_ver:.rc%{rc_ver}}%{?dist}
Release: 3%{?rc_ver:.rc%{rc_ver}}%{?dist}
Summary: A C language family front-end for LLVM
License: NCSA
@ -74,6 +74,7 @@ Source1: http://%{?rc_ver:pre}releases.llvm.org/%{version}/%{?rc_ver:rc%{rc_ver}
Patch4: 0002-gtest-reorg.patch
Patch9: 0001-Fix-uninitialized-value-in-ABIArgInfo.patch
Patch11: 0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch
Patch12: 0001-Merging-r360674.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -216,6 +217,7 @@ pathfix.py -i %{__python3} -pn \
%patch4 -p1 -b .gtest
%patch9 -p1 -b .abi-arginfo
%patch11 -p1 -b .libcxx-fix
%patch12 -p1 -b .double-promotion
mv ../%{clang_tools_srcdir} tools/extra
@ -418,6 +420,9 @@ false
%endif
%changelog
* Thu May 16 2019 sguelton@redhat.com - 8.0.0-3
- Fix for rhbz#1674031
* Fri Apr 12 2019 sguelton@redhat.com - 8.0.0-2
- Remove useless patch thanks to GCC upgrade