This is an automated email from the ASF dual-hosted git repository. granthenke pushed a commit to branch apple-m1 in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 9e2ab0c6cda726405810e6ceb8bb272f17379133 Author: Grant Henke <[email protected]> AuthorDate: Wed Nov 18 14:10:36 2020 -0600 [thirdparty] Upgrade to LLVM 11 and IWYU 0.15 This patch upgrades LLVM to version 11 and IWYU to version 0.15. Change-Id: Id9c32abe256978158617a4fe3a3c34e9bfd00fb2 --- src/kudu/codegen/code_generator.cc | 6 +- src/kudu/codegen/module_builder.cc | 4 +- thirdparty/build-definitions.sh | 7 +- thirdparty/download-thirdparty.sh | 7 +- thirdparty/package-llvm.sh | 11 +- thirdparty/patches/llvm-iwyu-include-picker.patch | 10 -- .../patches/llvm-iwyu-sized-deallocation.patch | 116 --------------------- thirdparty/vars.sh | 4 +- 8 files changed, 20 insertions(+), 145 deletions(-) diff --git a/src/kudu/codegen/code_generator.cc b/src/kudu/codegen/code_generator.cc index 7e419ab..642b841 100644 --- a/src/kudu/codegen/code_generator.cc +++ b/src/kudu/codegen/code_generator.cc @@ -158,14 +158,14 @@ int DumpAsm(FuncPtr fptr, const TargetMachine& tm, std::ostream* out, int max_in MCInst inst; uint64_t size; MCDisassembler::DecodeStatus stat = - disas->getInstruction(inst, size, mem_obj.slice(addr), addr, llvm::nulls(), llvm::nulls()); + disas->getInstruction(inst, size, mem_obj.slice(addr), addr, llvm::nulls()); if (stat != MCDisassembler::Success) { *out << "<ERROR at 0x" << std::hex << addr << " (absolute 0x" << (addr + base_addr) << ")" << ", skipping instruction>\n" << std::dec; } else { string annotations; - printer->printInst(&inst, os, annotations, subtarget_info); + printer->printInst(&inst, addr, annotations, subtarget_info, os); os << " " << annotations << "\n"; // We need to check the opcode name for "RET" instead of comparing // the opcode to llvm::ReturnInst::getOpcode() because the native @@ -178,7 +178,7 @@ int DumpAsm(FuncPtr fptr, const TargetMachine& tm, std::ostream* out, int max_in // LLVM RTTI, since subclassing an LLVM interface would require // identical RTTI settings between LLVM and Kudu (see: // http://llvm.org/docs/Packaging.html#c-features). - string opname = printer->getOpcodeName(inst.getOpcode()); + string opname = printer->getOpcodeName(inst.getOpcode()).str(); std::transform(opname.begin(), opname.end(), opname.begin(), ::toupper); if (opname.find("RET") != string::npos) return i + 1; } diff --git a/src/kudu/codegen/module_builder.cc b/src/kudu/codegen/module_builder.cc index e0818de..eb7e931 100644 --- a/src/kudu/codegen/module_builder.cc +++ b/src/kudu/codegen/module_builder.cc @@ -125,7 +125,7 @@ string ToString(const Module& m) { // This method is needed for the implicit conversion from // llvm::StringRef to std::string string ToString(const Function* f) { - return f->getName(); + return f->getName().str(); } bool ModuleContains(const Module& m, const Function* fptr) { @@ -379,7 +379,7 @@ TargetMachine* ModuleBuilder::GetTargetMachine() const { unordered_set<string> ModuleBuilder::GetFunctionNames() const { unordered_set<string> ret; for (const JITFuture& fut : futures_) { - ret.insert(CHECK_NOTNULL(fut.llvm_f_)->getName()); + ret.insert(CHECK_NOTNULL(fut.llvm_f_)->getName().str()); } return ret; } diff --git a/thirdparty/build-definitions.sh b/thirdparty/build-definitions.sh index fced6d4..7df9aca 100644 --- a/thirdparty/build-definitions.sh +++ b/thirdparty/build-definitions.sh @@ -194,7 +194,6 @@ build_llvm() { TOOLS_ARGS="$TOOLS_ARGS -DLLVM_TOOL_LIBCXX_BUILD=OFF" TOOLS_ARGS="$TOOLS_ARGS -DLLVM_TOOL_LIBCXXABI_BUILD=OFF" - # Disable some builds we don't care about. for arg in \ CLANG_ENABLE_ARCMT \ @@ -291,6 +290,11 @@ build_llvm() { # See https://github.com/llvm-mirror/compiler-rt/blob/749af53928a31afa3111f27cc41fd15849d86667/lib/CMakeLists.txt#L11-L14 TOOLS_ARGS="$TOOLS_ARGS -DCOMPILER_RT_BUILD_SANITIZERS=OFF" TOOLS_ARGS="$TOOLS_ARGS -DCOMPILER_RT_BUILD_XRAY=OFF" + + # Disable Apple platforms the we do not support. + TOOLS_ARGS="$TOOLS_ARGS -DCOMPILER_RT_ENABLE_IOS=OFF" + TOOLS_ARGS="$TOOLS_ARGS -DCOMPILER_RT_ENABLE_WATCHOS=OFF" + TOOLS_ARGS="$TOOLS_ARGS -DCOMPILER_RT_ENABLE_TVOS=OFF" fi # Depend on zlib from the thirdparty tree. It's an optional dependency for @@ -345,7 +349,6 @@ build_llvm() { -DLLVM_INCLUDE_UTILS=OFF \ -DLLVM_TARGETS_TO_BUILD="X86;AArch64" \ -DLLVM_ENABLE_RTTI=ON \ - -DCMAKE_OSX_ARCHITECTURES="x86_64" \ -DCMAKE_CXX_FLAGS="$CLANG_CXXFLAGS" \ -DCMAKE_EXE_LINKER_FLAGS="$CLANG_LDFLAGS" \ -DCMAKE_MODULE_LINKER_FLAGS="$CLANG_LDFLAGS" \ diff --git a/thirdparty/download-thirdparty.sh b/thirdparty/download-thirdparty.sh index 86be27d..2edb494 100755 --- a/thirdparty/download-thirdparty.sh +++ b/thirdparty/download-thirdparty.sh @@ -319,15 +319,12 @@ fetch_and_patch \ $PYTHON_SOURCE \ $PYTHON_PATCHLEVEL -LLVM_PATCHLEVEL=4 +LLVM_PATCHLEVEL=1 fetch_and_patch \ llvm-${LLVM_VERSION}-iwyu-${IWYU_VERSION}.src.tar.gz \ $LLVM_SOURCE \ $LLVM_PATCHLEVEL \ - "patch -p1 < $TP_DIR/patches/llvm-add-iwyu.patch" \ - "patch -p1 < $TP_DIR/patches/llvm-iwyu-include-picker.patch" \ - "patch -p0 < $TP_DIR/patches/llvm-iwyu-sized-deallocation.patch" \ - "patch -d projects -p1 < $TP_DIR/patches/llvm-947f9692440836dcb8d88b74b69dd379d85974ce.patch" + "patch -p1 < $TP_DIR/patches/llvm-add-iwyu.patch" LZ4_PATCHLEVEL=0 fetch_and_patch \ diff --git a/thirdparty/package-llvm.sh b/thirdparty/package-llvm.sh index ec25174..3a71072 100755 --- a/thirdparty/package-llvm.sh +++ b/thirdparty/package-llvm.sh @@ -36,22 +36,23 @@ # 10. Create new tarball from the resulting source tree # # Usage: -# $ env VERSION=6.0.0 IWYU_VERSION=0.9 thirdparty/package-llvm.sh +# $ env VERSION=11.0.0 IWYU_VERSION=0.15 thirdparty/package-llvm.sh set -eux -for ARTIFACT in llvm cfe compiler-rt libcxx libcxxabi lld clang-tools-extra; do - wget https://releases.llvm.org/$VERSION/$ARTIFACT-$VERSION.src.tar.xz +for ARTIFACT in llvm clang compiler-rt libcxx libcxxabi lld clang-tools-extra; do + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$VERSION/$ARTIFACT-$VERSION.src.tar.xz tar xf $ARTIFACT-$VERSION.src.tar.xz rm $ARTIFACT-$VERSION.src.tar.xz done IWYU_TAR=include-what-you-use-${IWYU_VERSION}.src.tar.gz wget https://include-what-you-use.org/downloads/$IWYU_TAR -tar xf $IWYU_TAR +mkdir include-what-you-use +tar xf $IWYU_TAR -C include-what-you-use rm $IWYU_TAR -mv cfe-$VERSION.src llvm-$VERSION.src/tools/clang +mv clang-$VERSION.src llvm-$VERSION.src/tools/clang mv clang-tools-extra-$VERSION.src llvm-$VERSION.src/tools/clang/tools/extra mv lld-$VERSION.src llvm-$VERSION.src/tools/lld mv compiler-rt-$VERSION.src llvm-$VERSION.src/projects/compiler-rt diff --git a/thirdparty/patches/llvm-iwyu-include-picker.patch b/thirdparty/patches/llvm-iwyu-include-picker.patch deleted file mode 100644 index 5c42d15..0000000 --- a/thirdparty/patches/llvm-iwyu-include-picker.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/tools/clang/tools/include-what-you-use/iwyu_include_picker.cc 2017-08-07 16:41:03.193267222 -0700 -+++ b/tools/clang/tools/include-what-you-use/iwyu_include_picker.cc 2017-08-07 16:41:12.603327180 -0700 -@@ -288,6 +295,7 @@ const IncludeMapEntry libc_include_map[] = { - { "<bits/param.h>", kPrivate, "<sys/param.h>", kPublic }, - { "<bits/poll.h>", kPrivate, "<sys/poll.h>", kPrivate }, - { "<bits/poll2.h>", kPrivate, "<sys/poll.h>", kPrivate }, -+ { "<bits/local_lim.h>", kPrivate, "<limits.h>", kPublic }, - { "<bits/posix1_lim.h>", kPrivate, "<limits.h>", kPublic }, - { "<bits/posix2_lim.h>", kPrivate, "<limits.h>", kPublic }, - { "<bits/posix_opt.h>", kPrivate, "<unistd.h>", kPublic }, diff --git a/thirdparty/patches/llvm-iwyu-sized-deallocation.patch b/thirdparty/patches/llvm-iwyu-sized-deallocation.patch deleted file mode 100644 index 5af6398..0000000 --- a/thirdparty/patches/llvm-iwyu-sized-deallocation.patch +++ /dev/null @@ -1,116 +0,0 @@ ---- tools/clang/tools/include-what-you-use/iwyu_ast_util.cc.orig 2020-03-23 14:03:01.060932783 -0700 -+++ tools/clang/tools/include-what-you-use/iwyu_ast_util.cc 2020-03-23 14:04:37.056235116 -0700 -@@ -47,6 +47,7 @@ - class FileEntry; - } // namespace clang - -+using clang::ASTContext; - using clang::BlockPointerType; - using clang::CXXConstructExpr; - using clang::CXXConstructorDecl; -@@ -78,6 +79,7 @@ - using clang::FullSourceLoc; - using clang::FunctionDecl; - using clang::FunctionType; -+using clang::IdentifierInfo; - using clang::ImplicitCastExpr; - using clang::InjectedClassNameType; - using clang::LValueReferenceType; -@@ -929,13 +931,81 @@ - !StartsWith(decl_name, "operator delete")) - return false; - -- // Placement-new/delete has 2 args, second is void*. The only other -- // 2-arg overloads of new/delete in <new> take a const nothrow_t&. -- if (decl->getNumParams() == 2 && -- !decl->getParamDecl(1)->getType().isConstQualified()) -- return false; -- -- return true; -+ // The following variants of operator new[1] are implicitly defined in every -+ // translation unit and should not require including <new>. -+ // -+ // void* operator new ( std::size_t count ); -+ // void* operator new[]( std::size_t count ); -+ // void* operator new ( std::size_t count, std::align_val_t al ); (since C++17) -+ // void* operator new[]( std::size_t count, std::align_val_t al ); (since C++17) -+ // -+ // Likewise, the following variants of operator delete[2] are implicitly -+ // defined in every translation unit and should not require including <new>. -+ // -+ // void operator delete ( void* ptr ) throw(); (until C++11) -+ // void operator delete ( void* ptr ) noexcept; (since C++11) -+ // void operator delete[]( void* ptr ) throw(); (until C++11) -+ // void operator delete[]( void* ptr ) noexcept; (since C++11) -+ // void operator delete ( void* ptr, std::align_val_t al ) noexcept; (since C++17) -+ // void operator delete[]( void* ptr, std::align_val_t al ) noexcept; (since C++17) -+ // void operator delete ( void* ptr, std::size_t sz ) noexcept; (since C++14) -+ // void operator delete[]( void* ptr, std::size_t sz ) noexcept; (since C++14) -+ // void operator delete ( void* ptr, std::size_t sz, -+ // std::align_val_t al ) noexcept; (since C++17) -+ // void operator delete[]( void* ptr, std::size_t sz, -+ // std::align_val_t al ) noexcept; (since C++17) -+ // void operator delete ( void* ptr, const std::nothrow_t& tag ) throw(); (until C++11) -+ // void operator delete ( void* ptr, const std::nothrow_t& tag ) noexcept; (since C++11) -+ // void operator delete[]( void* ptr, const std::nothrow_t& tag ) throw(); (until C++11) -+ // void operator delete[]( void* ptr, const std::nothrow_t& tag ) noexcept; (since C++11) -+ // -+ // The below code attempts to return true for these variants while returning -+ // false for all others. FunctionDecl::isReplaceableGlobalAllocationFunction -+ // comes very very close, but returns true for nothrow new, which is not -+ // implicitly defined. -+ // -+ // 1. https://en.cppreference.com/w/cpp/memory/new/operator_new -+ // 2. https://en.cppreference.com/w/cpp/memory/new/operator_delete -+ switch (decl->getNumParams()) { -+ case 1: -+ // All 1-arg variants are implicitly declared. -+ return true; -+ case 2: { -+ // Amongst 2-arg variants, aligned (C++17) new/delete, sized delete (C++14), and -+ // nothrow delete are implicitly declared. -+ ASTContext& ctx = decl->getASTContext(); -+ QualType t = decl->getParamDecl(1)->getType(); -+ if (t->isAlignValT() || // aligned new/delete -+ ctx.hasSameType(t, ctx.getSizeType())) // sized delete -+ return true; -+ // We have to work a bit harder to figure out if it's a nothrow delete. -+ // -+ // This cribs from FunctionDecl::isReplaceableGlobalAllocationFunction. -+ if (StartsWith(decl_name, "operator delete") && t->isReferenceType()) { -+ t = t->getPointeeType(); -+ if (t.isConstQualified()) { -+ const CXXRecordDecl* recordDecl = t->getAsCXXRecordDecl(); -+ if (recordDecl) { -+ const IdentifierInfo* iInfo = recordDecl->getIdentifier(); -+ if (iInfo && iInfo->isStr("nothrow_t") && recordDecl->isInStdNamespace()) -+ return true; -+ } -+ } -+ } -+ return false; -+ } -+ case 3: { -+ // Amongst 3-arg variants, only sized aligned delete (C++17) is implicitly -+ // declared. -+ ASTContext& ctx = decl->getASTContext(); -+ QualType t = decl->getParamDecl(1)->getType(); -+ return ctx.hasSameType(t, ctx.getSizeType()) && -+ decl->getParamDecl(2)->getType()->isAlignValT(); -+ } -+ default: -+ return false; -+ return true; -+ } - } - - bool IsFriendDecl(const Decl* decl) { -@@ -1082,7 +1152,7 @@ - - bool IsBuiltinFunction(const clang::NamedDecl* decl, - const std::string& symbol_name) { -- if (const clang::IdentifierInfo* iden = decl->getIdentifier()) { -+ if (const IdentifierInfo* iden = decl->getIdentifier()) { - return iden->getBuiltinID() != 0 && - !clang::Builtin::Context::isBuiltinFunc(symbol_name.c_str()); - } diff --git a/thirdparty/vars.sh b/thirdparty/vars.sh index 04fa883..25abe6a 100644 --- a/thirdparty/vars.sh +++ b/thirdparty/vars.sh @@ -142,12 +142,12 @@ LIBUNWIND_NAME=libunwind-$LIBUNWIND_VERSION LIBUNWIND_SOURCE=$TP_SOURCE_DIR/$LIBUNWIND_NAME # See package-llvm.sh for details on the LLVM tarball. -LLVM_VERSION=9.0.0 +LLVM_VERSION=11.0.0 LLVM_NAME=llvm-$LLVM_VERSION.src LLVM_SOURCE=$TP_SOURCE_DIR/$LLVM_NAME # The include-what-you-use is built along with LLVM in its source tree. -IWYU_VERSION=0.13 +IWYU_VERSION=0.15 # Python is required to build LLVM 3.6+ because it uses # llvm/utils/llvm-build/llvmbuild script. It is only built and installed if
