diff --git a/.clang.metadata b/.clang.metadata index 87814fb..77c6957 100644 --- a/.clang.metadata +++ b/.clang.metadata @@ -1,2 +1,2 @@ -e1d7f274c4fd623f19255cc52c6d7b39cf8769ee SOURCES/cfe-8.0.1.src.tar.xz -0174e060781fc01e5f97f2ff9b51a03165d7b37a SOURCES/clang-tools-extra-8.0.1.src.tar.xz +0d72ce018c85c54fc709c7da71d3dd1463af0bfc SOURCES/clang-9.0.1.src.tar.xz +f0571ec2135cb735f22baa149ac84e7334d0ac70 SOURCES/clang-tools-extra-9.0.1.src.tar.xz diff --git a/.gitignore b/.gitignore index 1d9c55c..c3307e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/cfe-8.0.1.src.tar.xz -SOURCES/clang-tools-extra-8.0.1.src.tar.xz +SOURCES/clang-9.0.1.src.tar.xz +SOURCES/clang-tools-extra-9.0.1.src.tar.xz diff --git a/SOURCES/0001-BPF-annotate-DIType-metadata-for-builtin-preseve_arr.patch b/SOURCES/0001-BPF-annotate-DIType-metadata-for-builtin-preseve_arr.patch new file mode 100644 index 0000000..2062f00 --- /dev/null +++ b/SOURCES/0001-BPF-annotate-DIType-metadata-for-builtin-preseve_arr.patch @@ -0,0 +1,204 @@ +From 5eb29c8b23b652b8dd8988621f5c91191b13ffe3 Mon Sep 17 00:00:00 2001 +From: Yonghong Song +Date: Fri, 2 Aug 2019 21:28:28 +0000 +Subject: [PATCH] [BPF] annotate DIType metadata for builtin + preseve_array_access_index() + +Previously, debuginfo types are annotated to +IR builtin preserve_struct_access_index() and +preserve_union_access_index(), but not +preserve_array_access_index(). The debug info +is useful to identify the root type name which +later will be used for type comparison. + +For user access without explicit type conversions, +the previous scheme works as we can ignore intermediate +compiler generated type conversions (e.g., from union types to +union members) and still generate correct access index string. + +The issue comes with user explicit type conversions, e.g., +converting an array to a structure like below: + struct t { int a; char b[40]; }; + struct p { int c; int d; }; + struct t *var = ...; + ... __builtin_preserve_access_index(&(((struct p *)&(var->b[0]))->d)) ... +Although BPF backend can derive the type of &(var->b[0]), +explicit type annotation make checking more consistent +and less error prone. + +Another benefit is for multiple dimension array handling. +For example, + struct p { int c; int d; } g[8][9][10]; + ... __builtin_preserve_access_index(&g[2][3][4].d) ... +It would be possible to calculate the number of "struct p"'s +before accessing its member "d" if array debug info is +available as it contains each dimension range. + +This patch enables to annotate IR builtin preserve_array_access_index() +with proper debuginfo type. The unit test case and language reference +is updated as well. + +Signed-off-by: Yonghong Song + +Differential Revision: https://reviews.llvm.org/D65664 + +llvm-svn: 367724 +(cherry picked from commit d0ea05d5eff475a27a5d3bbe4d9fd389935f9cb2) +--- + clang/lib/CodeGen/CGExpr.cpp | 12 ++++++++--- + .../CodeGen/builtin-preserve-access-index-array.c | 18 +++++++++++++++++ + clang/test/CodeGen/builtin-preserve-access-index.c | 23 +++++++++++----------- + llvm/docs/LangRef.rst | 4 ++++ + llvm/include/llvm/IR/IRBuilder.h | 10 +++++++--- + llvm/test/CodeGen/BPF/CORE/intrinsic-array.ll | 2 +- + 6 files changed, 51 insertions(+), 18 deletions(-) + create mode 100644 clang/test/CodeGen/builtin-preserve-access-index-array.c + +diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp +index b6c2567..21c4103 100644 +--- a/clang/lib/CodeGen/CGExpr.cpp ++++ b/clang/lib/CodeGen/CGExpr.cpp +@@ -3405,6 +3405,7 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr, + ArrayRef indices, + QualType eltType, bool inbounds, + bool signedIndices, SourceLocation loc, ++ QualType *arrayType = nullptr, + const llvm::Twine &name = "arrayidx") { + // All the indices except that last must be zero. + #ifndef NDEBUG +@@ -3433,9 +3434,12 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr, + } else { + // Remember the original array subscript for bpf target + unsigned idx = LastIndex->getZExtValue(); ++ llvm::DIType *DbgInfo = nullptr; ++ if (arrayType) ++ DbgInfo = CGF.getDebugInfo()->getOrCreateStandaloneType(*arrayType, loc); + eltPtr = CGF.Builder.CreatePreserveArrayAccessIndex(addr.getPointer(), + indices.size() - 1, +- idx); ++ idx, DbgInfo); + } + + return Address(eltPtr, eltAlign); +@@ -3572,19 +3576,21 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, + auto *Idx = EmitIdxAfterBase(/*Promote*/true); + + // Propagate the alignment from the array itself to the result. ++ QualType arrayType = Array->getType(); + Addr = emitArraySubscriptGEP( + *this, ArrayLV.getAddress(), {CGM.getSize(CharUnits::Zero()), Idx}, + E->getType(), !getLangOpts().isSignedOverflowDefined(), SignedIndices, +- E->getExprLoc()); ++ E->getExprLoc(), &arrayType); + EltBaseInfo = ArrayLV.getBaseInfo(); + EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType()); + } else { + // The base must be a pointer; emit it with an estimate of its alignment. + Addr = EmitPointerWithAlignment(E->getBase(), &EltBaseInfo, &EltTBAAInfo); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); ++ QualType ptrType = E->getBase()->getType(); + Addr = emitArraySubscriptGEP(*this, Addr, Idx, E->getType(), + !getLangOpts().isSignedOverflowDefined(), +- SignedIndices, E->getExprLoc()); ++ SignedIndices, E->getExprLoc(), &ptrType); + } + + LValue LV = MakeAddrLValue(Addr, E->getType(), EltBaseInfo, EltTBAAInfo); +diff --git a/clang/test/CodeGen/builtin-preserve-access-index-array.c b/clang/test/CodeGen/builtin-preserve-access-index-array.c +new file mode 100644 +index 0000000..a449b28 +--- /dev/null ++++ b/clang/test/CodeGen/builtin-preserve-access-index-array.c +@@ -0,0 +1,18 @@ ++// RUN: %clang -target x86_64 -emit-llvm -S -g %s -o - | FileCheck %s ++ ++#define _(x) (__builtin_preserve_access_index(x)) ++ ++struct s1 { ++ char a; ++ int b[4]; ++}; ++ ++const void *unit1(struct s1 *arg) { ++ return _(&arg->b[2]); ++} ++// CHECK: define dso_local i8* @unit1 ++// CHECK: call [4 x i32]* @llvm.preserve.struct.access.index.p0a4i32.p0s_struct.s1s(%struct.s1* %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S1:[0-9]+]] ++// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0a4i32([4 x i32]* %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[ARRAY:[0-9]+]] ++// ++// CHECK: ![[ARRAY]] = !DICompositeType(tag: DW_TAG_array_type ++// CHECK: ![[STRUCT_S1]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1" +diff --git a/clang/test/CodeGen/builtin-preserve-access-index.c b/clang/test/CodeGen/builtin-preserve-access-index.c +index 954a3b8..1084416 100644 +--- a/clang/test/CodeGen/builtin-preserve-access-index.c ++++ b/clang/test/CodeGen/builtin-preserve-access-index.c +@@ -31,16 +31,16 @@ const void *unit4(const int *arg) { + } + // CHECK: define dso_local i8* @unit4 + // CHECK-NOT: getelementptr +-// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %{{[0-9a-z]+}}, i32 0, i32 1) ++// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %{{[0-9a-z]+}}, i32 0, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[POINTER:[0-9]+]] + + const void *unit5(const int *arg[5]) { + return _(&arg[1][2]); + } + // CHECK: define dso_local i8* @unit5 + // CHECK-NOT: getelementptr +-// CHECK: call i32** @llvm.preserve.array.access.index.p0p0i32.p0p0i32(i32** %{{[0-9a-z]+}}, i32 0, i32 1) ++// CHECK: call i32** @llvm.preserve.array.access.index.p0p0i32.p0p0i32(i32** %{{[0-9a-z]+}}, i32 0, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}} + // CHECK-NOT: getelementptr +-// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %{{[0-9a-z]+}}, i32 0, i32 2) ++// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %{{[0-9a-z]+}}, i32 0, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[POINTER:[0-9]+]] + + struct s1 { + char a; +@@ -141,7 +141,7 @@ const void *unit13(struct s4 *arg) { + // CHECK: define dso_local i8* @unit13 + // CHECK: call %union.u* @llvm.preserve.struct.access.index.p0s_union.us.p0s_struct.s4s(%struct.s4* %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S4:[0-9]+]] + // CHECK: call %union.u* @llvm.preserve.union.access.index.p0s_union.us.p0s_union.us(%union.u* %{{[0-9a-z]+}}, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_I_U:[0-9]+]] +-// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0a4i32([4 x i32]* %{{[0-9a-z]+}}, i32 1, i32 2) ++// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0a4i32([4 x i32]* %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}} + + const void *unit14(union u3 *arg) { + return _(&arg->c.b[2]); +@@ -149,13 +149,13 @@ const void *unit14(union u3 *arg) { + // CHECK: define dso_local i8* @unit14 + // CHECK: call %union.u3* @llvm.preserve.union.access.index.p0s_union.u3s.p0s_union.u3s(%union.u3* %{{[0-9a-z]+}}, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U3:[0-9]+]] + // CHECK: call [4 x i32]* @llvm.preserve.struct.access.index.p0a4i32.p0s_struct.ss(%struct.s* %{{[0-9a-z]+}}, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_I_S:[0-9]+]] +-// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0a4i32([4 x i32]* %{{[0-9a-z]+}}, i32 1, i32 2) ++// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0a4i32([4 x i32]* %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}} + + const void *unit15(struct s4 *arg) { + return _(&arg[2].c.a); + } + // CHECK: define dso_local i8* @unit15 +-// CHECK: call %struct.s4* @llvm.preserve.array.access.index.p0s_struct.s4s.p0s_struct.s4s(%struct.s4* %{{[0-9a-z]+}}, i32 0, i32 2) ++// CHECK: call %struct.s4* @llvm.preserve.array.access.index.p0s_struct.s4s.p0s_struct.s4s(%struct.s4* %{{[0-9a-z]+}}, i32 0, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}} + // CHECK: call %union.u* @llvm.preserve.struct.access.index.p0s_union.us.p0s_struct.s4s(%struct.s4* %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S4]] + // CHECK: call %union.u* @llvm.preserve.union.access.index.p0s_union.us.p0s_union.us(%union.u* %{{[0-9a-z]+}}, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_I_U]] + +@@ -163,15 +163,16 @@ const void *unit16(union u3 *arg) { + return _(&arg[2].a); + } + // CHECK: define dso_local i8* @unit16 +-// CHECK: call %union.u3* @llvm.preserve.array.access.index.p0s_union.u3s.p0s_union.u3s(%union.u3* %{{[0-9a-z]+}}, i32 0, i32 2) ++// CHECK: call %union.u3* @llvm.preserve.array.access.index.p0s_union.u3s.p0s_union.u3s(%union.u3* %{{[0-9a-z]+}}, i32 0, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}} + // CHECK: call %union.u3* @llvm.preserve.union.access.index.p0s_union.u3s.p0s_union.u3s(%union.u3* %{{[0-9a-z]+}}, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U3]] + ++// CHECK: ![[POINTER]] = !DIDerivedType(tag: DW_TAG_pointer_type ++// CHECK: ![[STRUCT_S4]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s4" ++// CHECK: ![[UNION_I_U]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u" ++// CHECK: ![[UNION_U3]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u3" ++// CHECK: ![[STRUCT_I_S]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s" + // CHECK: ![[STRUCT_S1]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1" + // CHECK: ![[STRUCT_S2]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s2" + // CHECK: ![[STRUCT_S3]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s3" + // CHECK: ![[UNION_U1]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1" + // CHECK: ![[UNION_U2]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u2" +-// CHECK: ![[STRUCT_S4]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s4" +-// CHECK: ![[UNION_I_U]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u" +-// CHECK: ![[UNION_U3]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u3" +-// CHECK: ![[STRUCT_I_S]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s" +-- +1.8.3.1 + diff --git a/SOURCES/0001-Driver-Prefer-vendor-supplied-gcc-toolchain.patch b/SOURCES/0001-Driver-Prefer-vendor-supplied-gcc-toolchain.patch deleted file mode 100644 index 66e623e..0000000 --- a/SOURCES/0001-Driver-Prefer-vendor-supplied-gcc-toolchain.patch +++ /dev/null @@ -1,120 +0,0 @@ -From d84a971ba917569829b51fff6057e5fd0d85e402 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Thu, 18 Jan 2018 02:57:51 +0000 -Subject: [PATCH] Driver: Prefer vendor supplied gcc toolchain - -Summary: -This patch fixes an issue on Fedora where if you had the x86_64 cross -compiler installed on your x86_64 system, then clang would use that compiler -as the default toolchain. This was happening because the cross compiler -is installed to /usr/lib/gcc/x86_64-linux-gnu/ and this directory comes before -the default compiler directory (/usr/lib/gcc/x86_64-redhat-linux/) in the search -list. - -This patch re-orders the search list so that vendor supplied gcc toolchains -are selected before toolchains with a generic target, which should prevent -these kind of issues on other OSes too. - -Subscribers: srhines, cfe-commits - -Differential Revision: https://reviews.llvm.org/D42608 ---- - lib/Driver/ToolChains/Gnu.cpp | 47 ++++++++++++++++++++++--------------------- - 1 file changed, 24 insertions(+), 23 deletions(-) - -diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp ---- a/lib/Driver/ToolChains/Gnu.cpp -+++ b/lib/Driver/ToolChains/Gnu.cpp -@@ -1870,8 +1870,8 @@ - // lifetime or initialization issues. - static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; - static const char *const AArch64Triples[] = { -- "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", -- "aarch64-suse-linux", "aarch64-linux-android"}; -+ "aarch64-redhat-linux", "aarch64-suse-linux", "aarch64-linux-android", -+ "aarch64-none-linux-gnu", "aarch64-linux-gnu"}; - static const char *const AArch64beLibDirs[] = {"/lib"}; - static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", - "aarch64_be-linux-gnu"}; -@@ -1879,31 +1879,34 @@ - static const char *const ARMLibDirs[] = {"/lib"}; - static const char *const ARMTriples[] = {"arm-linux-gnueabi", - "arm-linux-androideabi"}; -- static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", -- "armv7hl-redhat-linux-gnueabi", -+ static const char *const ARMHFTriples[] = {"armv7hl-redhat-linux-gnueabi", - "armv6hl-suse-linux-gnueabi", -- "armv7hl-suse-linux-gnueabi"}; -+ "armv7hl-suse-linux-gnueabi", -+ "arm-linux-gnueabihf"}; - static const char *const ARMebLibDirs[] = {"/lib"}; - static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", - "armeb-linux-androideabi"}; - static const char *const ARMebHFTriples[] = { -- "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"}; -+ "armebv7hl-redhat-linux-gnueabi", "armeb-linux-gnueabihf"}; - - static const char *const X86_64LibDirs[] = {"/lib64", "/lib"}; - static const char *const X86_64Triples[] = { -- "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", -- "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E", -+ "x86_64-redhat-linux6E", - "x86_64-redhat-linux", "x86_64-suse-linux", - "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", - "x86_64-slackware-linux", "x86_64-unknown-linux", -- "x86_64-amazon-linux", "x86_64-linux-android"}; -+ "x86_64-amazon-linux", "x86_64-linux-android", -+ "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", -+ "x86_64-pc-linux-gnu" -+ }; - static const char *const X32LibDirs[] = {"/libx32"}; - static const char *const X86LibDirs[] = {"/lib32", "/lib"}; - static const char *const X86Triples[] = { -- "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", -- "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", -+ "i386-redhat-linux6E", "i686-redhat-linux", - "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", -- "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu", -+ "i486-slackware-linux", "i686-montavista-linux", -+ "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", -+ "i386-linux-gnu", "i586-linux-gnu", - "i686-linux-android", "i386-gnu", "i486-gnu", - "i586-gnu", "i686-gnu"}; - -@@ -1940,16 +1943,16 @@ - - static const char *const PPCLibDirs[] = {"/lib32", "/lib"}; - static const char *const PPCTriples[] = { -- "powerpc-linux-gnu", "powerpc-unknown-linux-gnu", "powerpc-linux-gnuspe", -- "powerpc-suse-linux", "powerpc-montavista-linuxspe"}; -+ "powerpc-suse-linux", "powerpc-montavista-linuxspe", -+ "powerpc-linux-gnu", "powerpc-unknown-linux-gnu", "powerpc-linux-gnuspe"}; - static const char *const PPC64LibDirs[] = {"/lib64", "/lib"}; - static const char *const PPC64Triples[] = { -- "powerpc64-linux-gnu", "powerpc64-unknown-linux-gnu", -- "powerpc64-suse-linux", "ppc64-redhat-linux"}; -+ "powerpc64-suse-linux", "ppc64-redhat-linux", -+ "powerpc64-linux-gnu", "powerpc64-unknown-linux-gnu"}; - static const char *const PPC64LELibDirs[] = {"/lib64", "/lib"}; - static const char *const PPC64LETriples[] = { -- "powerpc64le-linux-gnu", "powerpc64le-unknown-linux-gnu", -- "powerpc64le-suse-linux", "ppc64le-redhat-linux"}; -+ "powerpc64le-suse-linux", "ppc64le-redhat-linux", -+ "powerpc64le-linux-gnu", "powerpc64le-unknown-linux-gnu"}; - - static const char *const RISCV32LibDirs[] = {"/lib", "/lib32"}; - static const char *const RISCVTriples[] = {"riscv32-unknown-linux-gnu", -@@ -1965,8 +1968,8 @@ - - static const char *const SystemZLibDirs[] = {"/lib64", "/lib"}; - static const char *const SystemZTriples[] = { -- "s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu", -- "s390x-suse-linux", "s390x-redhat-linux"}; -+ "s390x-ibm-linux-gnu", "s390x-suse-linux", "s390x-redhat-linux", -+ "s390x-linux-gnu", "s390x-unknown-linux-gnu"}; - - - using std::begin; --- -1.8.3.1 - diff --git a/SOURCES/0001-Fix-uninitialized-value-in-ABIArgInfo.patch b/SOURCES/0001-Fix-uninitialized-value-in-ABIArgInfo.patch deleted file mode 100644 index 9755200..0000000 --- a/SOURCES/0001-Fix-uninitialized-value-in-ABIArgInfo.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 565b9633ee68b311c1a954022869d9e99fee7286 Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Fri, 1 Feb 2019 06:39:13 +0000 -Subject: [PATCH] Fix uninitialized value in ABIArgInfo - -GCC-9 takes advantage of this uninitialized values to optimize stuff, -which ends up in failing validation when compiling clang. ---- - include/clang/CodeGen/CGFunctionInfo.h | 11 +++++------ - 1 file changed, 5 insertions(+), 6 deletions(-) - -diff --git a/include/clang/CodeGen/CGFunctionInfo.h b/include/clang/CodeGen/CGFunctionInfo.h -index cf64e9f3ee..131eb38393 100644 ---- a/include/clang/CodeGen/CGFunctionInfo.h -+++ b/include/clang/CodeGen/CGFunctionInfo.h -@@ -112,14 +112,13 @@ private: - } - - ABIArgInfo(Kind K) -- : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) { -- } -+ : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), -+ TheKind(K), PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false), -+ IndirectRealign(false), SRetAfterThis(false), InReg(false), -+ CanBeFlattened(false), SignExt(false), SuppressSRet(false) {} - - public: -- ABIArgInfo() -- : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), -- TheKind(Direct), PaddingInReg(false), InReg(false), -- SuppressSRet(false) {} -+ ABIArgInfo() : ABIArgInfo(Direct) {} - - static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0, - llvm::Type *Padding = nullptr, --- -2.19.2 - diff --git a/SPECS/clang.spec b/SPECS/clang.spec index 5c009b2..86551ac 100644 --- a/SPECS/clang.spec +++ b/SPECS/clang.spec @@ -1,7 +1,10 @@ -%global maj_ver 8 +%global compat_build 0 + +%global maj_ver 9 %global min_ver 0 %global patch_ver 1 -#%%global rc_ver 2 +#%%global rc_ver 3 +%global baserelease 2 #i686 disabled because llvm-test is not built for this target # other targets disables because of failing tests @@ -13,6 +16,7 @@ %{_bindir}/clangd \ %{_bindir}/clang-apply-replacements \ %{_bindir}/clang-change-namespace \ + %{_bindir}/clang-doc \ %{_bindir}/clang-include-fixer \ %{_bindir}/clang-query \ %{_bindir}/clang-refactor \ @@ -32,11 +36,26 @@ %{_bindir}/clang-format \ %{_bindir}/clang-import-test \ %{_bindir}/clang-offload-bundler \ + %{_bindir}/clang-scan-deps \ %{_bindir}/diagtool \ %{_bindir}/hmaptool +%if 0%{?compat_build} +%global pkg_name clang%{maj_ver}.%{min_ver} +# Install clang to same prefix as llvm, so that apps that use llvm-config +# will also be able to find clang libs. +%global install_prefix %{_libdir}/llvm%{maj_ver}.%{min_ver} +%global install_bindir %{install_prefix}/bin +%global install_includedir %{install_prefix}/include +%global install_libdir %{install_prefix}/lib + +%global pkg_bindir %{install_bindir} +%global pkg_includedir %{_includedir}/llvm%{maj_ver}.%{min_ver} +%global pkg_libdir %{install_libdir} +%else %global pkg_name clang %global install_prefix /usr +%endif %if 0%{?fedora} || 0%{?rhel} > 7 %bcond_without python3 @@ -45,44 +64,50 @@ %endif %global build_install_prefix %{buildroot}%{install_prefix} + %ifarch ppc64le # Too many threads on 32 core ppc64 systems causes OOM errors. %global _smp_mflags -j8 %endif -%global clang_srcdir cfe-%{version}%{?rc_ver:rc%{rc_ver}}.src +%global clang_srcdir clang-%{version}%{?rc_ver:rc%{rc_ver}}.src %global clang_tools_srcdir clang-tools-extra-%{version}%{?rc_ver:rc%{rc_ver}}.src Name: %pkg_name Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 1%{?rc_ver:.rc%{rc_ver}}%{?dist} +Release: %{baserelease}%{?rc_ver:.rc%{rc_ver}}%{?dist} Summary: A C language family front-end for LLVM License: NCSA URL: http://llvm.org -Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-%{rc_ver}}/%{clang_srcdir}.tar.xz +Source0: http://%{?rc_ver:pre}releases.llvm.org/%{version}/%{?rc_ver:rc%{rc_ver}}/%{clang_srcdir}.tar.xz %if !0%{?compat_build} -Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-%{rc_ver}}/%{clang_tools_srcdir}.tar.xz +Source1: http://%{?rc_ver:pre}releases.llvm.org/%{version}/%{?rc_ver:rc%{rc_ver}}/%{clang_tools_srcdir}.tar.xz %endif -Patch3: 0001-Driver-Prefer-vendor-supplied-gcc-toolchain.patch 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 +# Fix crash with kernel bpf self-tests +Patch14: 0001-BPF-annotate-DIType-metadata-for-builtin-preseve_arr.patch BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: ninja-build +%if 0%{?compat_build} +BuildRequires: llvm%{maj_ver}.%{min_ver}-devel = %{version} +BuildRequires: llvm%{maj_ver}.%{min_ver}-static = %{version} +%else BuildRequires: llvm-devel = %{version} -# llvm-static is required, because clang-tablegen needs libLLVMTableGen, which -# is not included in libLLVM.so. -BuildRequires: llvm-static = %{version} -# Required for make check %if 0%{?enable_test_pkg} BuildRequires: llvm-test = %{version} BuildRequires: llvm-googletest = %{version} %endif +# llvm-static is required, because clang-tablegen needs libLLVMTableGen, which +# is not included in libLLVM.so. +BuildRequires: llvm-static = %{version} +%endif + BuildRequires: libxml2-devel BuildRequires: perl-generators BuildRequires: ncurses-devel @@ -138,13 +163,17 @@ Runtime library for clang. %package devel Summary: Development header files for clang +%if !0%{?compat_build} Requires: %{name}%{?_isa} = %{version}-%{release} # The clang CMake files reference tools from clang-tools-extra. Requires: %{name}-tools-extra%{?_isa} = %{version}-%{release} +%endif +Requires: %{name}-libs = %{version}-%{release} %description devel Development header files for clang. +%if !0%{?compat_build} %package analyzer Summary: A source code analysis framework License: NCSA and MIT @@ -186,55 +215,70 @@ Requires: python3 %{summary}. +%endif %prep -%setup -T -q -b 1 -n clang-tools-extra-%{version}%{?rc_ver:rc%{rc_ver}}.src +%if 0%{?compat_build} +%autosetup -n %{clang_srcdir} -p1 +%else +%setup -T -q -b 1 -n %{clang_tools_srcdir} + pathfix.py -i %{__python3} -pn \ clang-tidy/tool/*.py \ - include-fixer/find-all-symbols/tool/run-find-all-symbols.py + clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py -%setup -q -n cfe-%{version}%{?rc_ver:rc%{rc_ver}}.src +%setup -q -n %{clang_srcdir} -%patch3 -p1 -b .rhel %patch4 -p1 -b .gtest -%patch9 -p1 -b .abi-arginfo %patch11 -p1 -b .libcxx-fix +%patch14 -p2 -b .bpf-fix mv ../%{clang_tools_srcdir} tools/extra -%if 0%{?__isa_bits} == 64 -sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/64/g' test/lit.cfg.py -%else -sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py -%endif - pathfix.py -i %{__python3} -pn \ tools/clang-format/*.py \ tools/clang-format/git-clang-format \ utils/hmaptool/hmaptool \ tools/scan-view/bin/scan-view - - +%endif %build +%if 0%{?__isa_bits} == 64 +sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/64/g' test/lit.cfg.py +%else +sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py +%endif + mkdir -p _build cd _build -%ifarch s390 s390x %{arm} %ix86 +%ifarch s390 s390x %{arm} %ix86 ppc64le # Decrease debuginfo verbosity to reduce memory consumption during final library linking %global optflags %(echo %{optflags} | sed 's/-g /-g1 /') %endif +# -DCMAKE_INSTALL_RPATH=";" is a workaround for llvm manually setting the +# rpath of libraries and binaries. llvm will skip the manual setting +# if CAMKE_INSTALL_RPATH is set to a value, but cmake interprets this value +# as nothing, so it sets the rpath to "" when installing. %cmake .. -G Ninja \ -DLLVM_PARALLEL_LINK_JOBS=1 \ -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DPYTHON_EXECUTABLE=%{__python3} \ - -DCMAKE_SKIP_RPATH:BOOL=ON \ - -DCMAKE_INSTALL_RPATH:BOOL=OFF \ + -DCMAKE_INSTALL_RPATH:BOOL=";" \ +%ifarch s390 s390x %{arm} %ix86 ppc64le + -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ +%endif +%if 0%{?compat_build} + -DLLVM_CONFIG:FILEPATH=%{_bindir}/llvm-config-%{maj_ver}.%{min_ver}-%{__isa_bits} \ + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ + -DCLANG_INCLUDE_TESTS:BOOL=OFF \ +%else -DCLANG_INCLUDE_TESTS:BOOL=ON \ -DLLVM_EXTERNAL_LIT=%{_bindir}/lit \ -DLLVM_MAIN_SRC_DIR=%{_datadir}/llvm/src \ @@ -243,8 +287,13 @@ cd _build %else -DLLVM_LIBDIR_SUFFIX= \ %endif +%endif \ +%if !0%{compat_build} -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen \ +%else + -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen-%{maj_ver}.%{min_ver} \ +%endif -DCLANG_ENABLE_ARCMT:BOOL=ON \ -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \ -DCLANG_INCLUDE_DOCS:BOOL=ON \ @@ -254,16 +303,30 @@ cd _build -DLLVM_ENABLE_RTTI=ON \ -DLLVM_BUILD_DOCS=ON \ -DLLVM_ENABLE_SPHINX=ON \ + -DCLANG_LINK_CLANG_DYLIB=OFF \ -DSPHINX_WARNINGS_AS_ERRORS=OFF \ \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \ -DCLANG_REPOSITORY_STRING="%{?fedora:Fedora}%{?rhel:Red Hat} %{version}-%{release}" -ninja -v -j2 +%ninja_build -l 8 %install -DESTDIR=%{buildroot} ninja install -C _build +%ninja_install -C _build +%if 0%{?compat_build} + +# Remove binaries/other files +rm -Rf %{buildroot}%{install_bindir} +rm -Rf %{buildroot}%{install_prefix}/share +rm -Rf %{buildroot}%{install_prefix}/libexec + +# Move include files +mkdir -p %{buildroot}%{pkg_includedir} +mv %{buildroot}/%{install_includedir}/clang %{buildroot}/%{pkg_includedir}/ +mv %{buildroot}/%{install_includedir}/clang-c %{buildroot}/%{pkg_includedir}/ + +%else # install clang python bindings mkdir -p %{buildroot}%{python3_sitelib}/clang/ @@ -294,23 +357,33 @@ ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang++.1.gz ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang-%{maj_ver}.1.gz ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang++-%{maj_ver}.1.gz -# Add clang++-{version} sylink +# Add clang++-{version} symlink ln -s clang++ %{buildroot}%{_bindir}/clang++-%{maj_ver} # Fix permission chmod u-x %{buildroot}%{_mandir}/man1/scan-build.1* +%endif %check +%if !0%{?compat_build} # requires lit.py from LLVM utilities - +# FIXME: Fix failing ARM tests, s390x i686 and ppc64le tests +# FIXME: Ignore test failures until rhbz#1715016 is fixed. %if 0%{?enable_test_pkg} -LD_LIBRARY_PATH=%{buildroot}%{_libdir} ninja check-all -j2 -C _build +LD_LIBRARY_PATH=%{buildroot}%{_libdir} ninja check-all -C _build || \ +%endif +%ifarch s390x i686 ppc64le %{arm} +: +%else +: %endif +%endif +%if !0%{?compat_build} %files %{clang_binaries} %{_bindir}/c-index-test @@ -322,18 +395,32 @@ LD_LIBRARY_PATH=%{buildroot}%{_libdir} ninja check-all -j2 -C _build %{_emacs_sitestartdir}/clang-format.el %{_datadir}/clang/clang-format.py* %{_datadir}/clang/clang-format-diff.py* +%endif %files libs +%if !0%{?compat_build} %{_libdir}/clang/ %{_libdir}/*.so.* +%else +%{pkg_libdir}/*.so.* +%{pkg_libdir}/clang/%{version} +%endif %files devel +%if !0%{?compat_build} %{_libdir}/*.so %{_includedir}/clang/ %{_includedir}/clang-c/ %{_libdir}/cmake/* %dir %{_datadir}/clang/ +%else +%{pkg_libdir}/*.so +%{pkg_includedir}/clang/ +%{pkg_includedir}/clang-c/ +%{pkg_libdir}/cmake/ +%endif +%if !0%{?compat_build} %files analyzer %{_bindir}/scan-view %{_bindir}/scan-build @@ -361,8 +448,29 @@ LD_LIBRARY_PATH=%{buildroot}%{_libdir} ninja check-all -j2 -C _build %files -n python3-clang %{python3_sitelib}/clang/ - +%endif %changelog +* Fri Jan 10 2020 Tom Stellard - 9.0.1-2 +- Fix crash with kernel bpf self-tests + +* Thu Dec 19 2019 Tom Stellard - 9.0.1-1 +- 9.0.1 Release + +* Fri Nov 15 2019 Tom Stellard - 9.0.0-5 +- Fix typo from previous patch: move clang-libs dep to correct sub-package + +* Thu Nov 14 2019 Tom Stellard - 9.0.0-4 +- Add explicit requires for clang-libs to fix rpmdiff errors + +* Wed Oct 02 2019 Tom Stellard - 9.0.0-3 +- Limit build to 8 threads to avoid OOM on x86_64 + +* Wed Oct 02 2019 Tom Stellard - 9.0.0-2 +- Disable CLANG_LINK_CLANG_DYLIB + +* Fri Sep 27 2019 Tom Stellard - 9.0.0-1 +- 9.0.0 Release + * Thu Aug 1 2019 sguelton@redhat.com - 8.0.1-1 - 8.0.1 Release