diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2023-03-21 14:19:28 -0600 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2023-04-27 19:47:13 -0700 |
commit | 810d0b07547c0c5d2795c72cca576edea7ba7000 (patch) | |
tree | 0de6b704f589132e6880b600f74fdec96a7ebf59 /recipes-devtools | |
parent | 45281f52c1de86b6728423107dbce454ac680d3c (diff) | |
download | meta-clang-810d0b07547c0c5d2795c72cca576edea7ba7000.tar.gz |
clang: fix reproducibily issue
Clang gives a name to the constructors of anonymous structures in
debug info that's based on the filename of the structure's definition.
It didn't respect the debug-prefix-map setting, causimg QA warnings
in several recipes, notably libcxx.
Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Diffstat (limited to 'recipes-devtools')
-rw-r--r-- | recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch | 70 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 71 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch b/recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch new file mode 100644 index 0000000..8670afe --- /dev/null +++ b/recipes-devtools/clang/clang/0037-clang-Call-printName-to-get-name-of-Decl.patch | |||
@@ -0,0 +1,70 @@ | |||
1 | From d33d6a8c4f43907cb53130730a2bc48624a34b74 Mon Sep 17 00:00:00 2001 | ||
2 | From: Dan McGregor <dan.mcgregor@usask.ca> | ||
3 | Date: Tue, 21 Mar 2023 13:04:51 -0600 | ||
4 | Subject: [PATCH] [clang] Call printName to get name of Decl | ||
5 | |||
6 | Rather than sending a name directly to the stream, use printName | ||
7 | to preserve any PrintingPolicy. This ensures that names are properly | ||
8 | affected by path remapping. | ||
9 | |||
10 | Differential Revision: https://reviews.llvm.org/D149272 | ||
11 | |||
12 | Upstream-Status: pending | ||
13 | --- | ||
14 | clang/lib/AST/Decl.cpp | 4 ++-- | ||
15 | clang/lib/AST/DeclarationName.cpp | 4 ++-- | ||
16 | clang/test/CodeGen/debug-prefix-map.cpp | 11 +++++++++++ | ||
17 | 3 files changed, 15 insertions(+), 4 deletions(-) | ||
18 | create mode 100644 clang/test/CodeGen/debug-prefix-map.cpp | ||
19 | |||
20 | diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp | ||
21 | index e60cc28f6e0f..24de6156c0f5 100644 | ||
22 | --- a/clang/lib/AST/Decl.cpp | ||
23 | +++ b/clang/lib/AST/Decl.cpp | ||
24 | @@ -1626,8 +1626,8 @@ Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const { | ||
25 | llvm_unreachable("unknown module kind"); | ||
26 | } | ||
27 | |||
28 | -void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy&) const { | ||
29 | - OS << Name; | ||
30 | +void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const { | ||
31 | + Name.print(OS, Policy); | ||
32 | } | ||
33 | |||
34 | void NamedDecl::printName(raw_ostream &OS) const { | ||
35 | diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp | ||
36 | index c1219041a466..da8b3886c340 100644 | ||
37 | --- a/clang/lib/AST/DeclarationName.cpp | ||
38 | +++ b/clang/lib/AST/DeclarationName.cpp | ||
39 | @@ -117,12 +117,12 @@ static void printCXXConstructorDestructorName(QualType ClassType, | ||
40 | Policy.adjustForCPlusPlus(); | ||
41 | |||
42 | if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) { | ||
43 | - OS << *ClassRec->getDecl(); | ||
44 | + ClassRec->getDecl()->printName(OS, Policy); | ||
45 | return; | ||
46 | } | ||
47 | if (Policy.SuppressTemplateArgsInCXXConstructors) { | ||
48 | if (auto *InjTy = ClassType->getAs<InjectedClassNameType>()) { | ||
49 | - OS << *InjTy->getDecl(); | ||
50 | + InjTy->getDecl()->printName(OS, Policy); | ||
51 | return; | ||
52 | } | ||
53 | } | ||
54 | diff --git a/clang/test/CodeGen/debug-prefix-map.cpp b/clang/test/CodeGen/debug-prefix-map.cpp | ||
55 | new file mode 100644 | ||
56 | index 000000000000..7ddaee531282 | ||
57 | --- /dev/null | ||
58 | +++ b/clang/test/CodeGen/debug-prefix-map.cpp | ||
59 | @@ -0,0 +1,11 @@ | ||
60 | +// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S %s -emit-llvm -o - | FileCheck %s | ||
61 | + | ||
62 | +struct alignas(64) an { | ||
63 | + struct { | ||
64 | + unsigned char x{0}; | ||
65 | + } arr[64]; | ||
66 | +}; | ||
67 | + | ||
68 | +struct an *pan = new an; | ||
69 | + | ||
70 | +// CHECK: !DISubprogram(name: "(unnamed struct at ./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}", | ||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index 6b85edf..c539bb3 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
@@ -46,6 +46,7 @@ SRC_URI = "\ | |||
46 | file://0034-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ | 46 | file://0034-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ |
47 | file://0035-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \ | 47 | file://0035-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \ |
48 | file://0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ | 48 | file://0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \ |
49 | file://0037-clang-Call-printName-to-get-name-of-Decl.patch \ | ||
49 | " | 50 | " |
50 | # Fallback to no-PIE if not set | 51 | # Fallback to no-PIE if not set |
51 | GCCPIE ??= "" | 52 | GCCPIE ??= "" |