Hello community, here is the log from the commit of package llvm9 for openSUSE:Leap:15.2 checked in at 2020-05-29 18:49:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/llvm9 (Old) and /work/SRC/openSUSE:Leap:15.2/.llvm9.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "llvm9" Fri May 29 18:49:11 2020 rev:1 rq:774578 version:9.0.1 Changes: -------- New Changes file: --- /dev/null 2020-05-28 02:28:09.919761697 +0200 +++ /work/SRC/openSUSE:Leap:15.2/.llvm9.new.3606/llvm9.changes 2020-05-29 18:49:15.724217295 +0200 @@ -0,0 +1,2091 @@ +------------------------------------------------------------------- +Fri Feb 7 10:29:11 UTC 2020 - Richard Biener <rguenther@suse.com> + +- Add vim-plugin-llvm Conflicts to clang subpackage which now + contains files formerly in llvmN-vim-plugins, conflicting with + packages from older llvm releases. + +------------------------------------------------------------------- +Thu Feb 6 10:58:59 UTC 2020 - Richard Biener <rguenther@suse.com> + +- Add back emacs-llvm Provides and Conflicts to clang subpackage + originally in llvm-emacs-plugins to properly conflict with + llvm-emacs-plugins from older llvm releases. + +------------------------------------------------------------------- +Tue Feb 4 08:41:49 UTC 2020 - Richard Biener <rguenther@suse.com> + +- Add clang5-devel to clang9-doc conflicts. + +------------------------------------------------------------------- +Mon Feb 3 08:53:12 UTC 2020 - Andreas Schwab <schwab@suse.de> + +- Add compiler-rt-sanitizer-ipc-perm.patch: Fix sanitizer-common + build with glibc 2.31. + +------------------------------------------------------------------- +Wed Jan 29 22:33:02 UTC 2020 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Move clang-{format,include-fixer,rename}.{el,py} files from + llvm-*-plugins to clang package. (boo#1161873) +- Drop the now empty llvm-emacs-plugins package. + +------------------------------------------------------------------- +Mon Jan 27 08:03:55 UTC 2020 - Richard Biener <rguenther@suse.com> + +- Add polly and lld build conditionals, remove excessive Requires + to clang from docs. Fix conditional for libc++ use. + [jsc#SLE-7400, jsc#SLE-7614, jsc#SLE-7452, jsc#SLE-8920, jsc#SLE-7390, + jsc#SLE-7587] + +------------------------------------------------------------------- +Wed Jan 15 14:34:50 UTC 2020 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Undo spec-cleaner changes that we don't want. + * Reintroduce blank lines in configuration. + * Use packageand syntax that works for older versions of RPM. + * Don't use %{_bindir} on left-hand side of sed replacements. + +------------------------------------------------------------------- +Sat Jan 11 20:14:12 UTC 2020 - Andreas Schwab <schwab@suse.de> + +- riscv-eh-frame-fixup.patch: Remove changesets that alter the libLLVM ABI + +------------------------------------------------------------------- +Fri Jan 8 15:30:21 UTC 2020 - Jaime Caamaño Ruiz <jcaamano@suse.com> + +- Add upstream patch to export compiler-rt FuzzedDataProvider header, + required by Envoy 1.12.2: + * compiler-rt-move-fdp.patch + +------------------------------------------------------------------- +Mon Jan 6 19:31:23 UTC 2020 - Andreas Schwab <schwab@suse.de> + +- riscv-eh-frame-fixup.patch: Fix handling of .eh_frame on RISC-V +- polly-pthread.patch: Add missing -lpthread + +------------------------------------------------------------------- +Fri Jan 3 15:28:52 UTC 2020 - Andreas Schwab <schwab@suse.de> + +- Enable support for riscv64 +- clang-riscv64-rv64gc.diff, riscv64-suse-linux.patch, + llvm-riscv64-fix-cffi.diff, D60657-riscv-pcrel_lo.diff: Backports from + master + +------------------------------------------------------------------- +Fri Dec 20 21:13:19 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Update to version 9.0.1. + * This release contains bug-fixes for the LLVM 9.0.0 release. + This release is API and ABI compatible with 9.0.0. +- Drop patches that have landed upstream: + * dont-install-example-analyzer-plugins.patch + * fix-module-test.patch + * llvm-add-missing-include.patch +- Drop set-revision.patch, don't provide revision number in clang. + The upstream repository has moved from Subversion to git, so the + revision number is just a hash, which limits its usefulness. +- Rebase llvm-do-not-install-static-libraries.patch. + +------------------------------------------------------------------- +Thu Dec 5 23:49:17 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Modify libcxx-tests-linux-distribution.patch to remove dependency + on python-distro again: we don't have expected failures. + +------------------------------------------------------------------- +Thu Dec 5 08:31:30 UTC 2019 - Martin Liška <mliska@suse.cz> + +- Add llvm-add-missing-include.patch in order to fix + boo#1158367. + +------------------------------------------------------------------- +Tue Dec 3 23:52:49 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Add gwp-asan-lto.patch: Make sure there are no LLVM IR files in + static libraries that we package. +- Add libcxx-tests-linux-distribution.patch (boo#1158293): + Replace platform.linux_distribution by distro.linux_distribution. +- Make documentation packages noarch. + +------------------------------------------------------------------- +Mon Nov 4 02:34:19 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Add openmp-export-fini.patch: Export termination function for + libomp.so, solves boo#1155108. +- Remove flaky test case in libcxx. + +------------------------------------------------------------------- +Wed Oct 30 08:44:49 UTC 2019 - Fabian Vogt <fvogt@suse.com> + +- Fix typo, BOLL -> BOOL + +------------------------------------------------------------------- +Sat Oct 19 11:12:03 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Let new {llvm,clang}*-doc packages "Conflict" with older devel + packages, which they were split from. +- Let doc packages conflict with older versions of themselves. + +------------------------------------------------------------------- +Mon Oct 14 14:16:20 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de> + +- (Build)Require only python3-base instead of full python3 package, + the additional modules are not required. Helps shortening the + build dependency chain. +- Remove python3-* requires from lldb9 subpackage, and add it to + the bindings/pretty-printer subpackage (python3-lldb9). +- Add python3-base Requires to python3-clang subpackage + +------------------------------------------------------------------- +Sat Sep 28 13:28:45 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Add dont-install-example-analyzer-plugins.patch: Remove example + analyzer plugins from install targets instead of deleting them. +- Add fix-module-test.patch: fix test instead of deleting it. +- Don't build static libc++ (with ThinLTO that's not useful anyway). +- Don't build libc++experimental. +- Don't package libc++abi.so with libc++-devel, it's already contained + in the (required) libc++abi-devel. +- Be more specific about files in libc++-devel. + +------------------------------------------------------------------- +Sun Sep 22 19:42:25 UTC 2019 - Aaron Puchert <aaronpuchert@alice-dsl.net> + +- Update to version 9.0.0. + * For details, see the release notes: + - https://releases.llvm.org/9.0.0/docs/ReleaseNotes.html + - https://releases.llvm.org/9.0.0/tools/clang/docs/ReleaseNotes.html + - https://releases.llvm.org/9.0.0/tools/clang/tools/extra/docs/ReleaseNotes.ht... + - https://releases.llvm.org/9.0.0/projects/libcxx/docs/ReleaseNotes.html + - https://releases.llvm.org/9.0.0/tools/lld/docs/ReleaseNotes.html +- Change License to "Apache-2.0 WITH LLVM-exception OR NCSA". + (https://llvm.org/foundation/relicensing/) +- Allow building with ThinLTO and enable it on some architectures. +- Disable LTO cache in lto-disable-cache.patch. +- Unset MALLOC_CHECK_ for compilation to mitigate lock contention. +- No debug info for ppc like for the other 32-bit targets. +- Clean up _constraints: same constraints for 32-bit targets. +- Don't use BUILD_SHARED_LIBS for Clang anymore, since the newly + available libclang-cpp.so should expose the full C++ API. +- Link tools with libclang-cpp.so by using CLANG_LINK_CLANG_DYLIB, + similar to LLVM_BUILD_LLVM_DYLIB for libLLVM.so. +- Remove obsolete n_clang_allow_BUILD_SHARED_LIBRARY.patch. +- Add link-clang-shared.patch to link more clang targets with + libclang-cpp.so, especially libclang.so. +- Add link-clang-tools-extra-shared.patch, link-lldb-shared.patch: + link targets in clang-tools-extra and lldb with libclang-cpp.so. +- Simplify llvm-do-not-install-static-libraries.patch, also handle + Clang, for which we now get static libraries. +- Package documentation for llvm and clang separately, recommend + them for the main package: they are not required for development, + but actually useful for working with the non-devel packages. +- Recommend editor plugins not just for llvm-devel. +- Recommend libstdc++ for Clang again. +- Move diagtool from llvm to clang subpackage. +- Properly distinguish between %{_relver} and %{version}. +- Drop aarch64-disable-memorytest.patch and reactivate test. +- Rebase clang-resourcedirs.patch. +- Rebase llvm-normally-versioned-libllvm.patch. +- Rebase llvm-remove-clang-only-flags.patch. +- Rebase llvm_build_tablegen_component_as_shared_library.patch. +- Rebase set-revision.patch. +- Increase disk space for build. + +------------------------------------------------------------------- +Sun Sep 22 11:13:10 UTC 2019 - Lubos Lunak <l.lunak@centrum.cz> + ++++ 1894 more lines (skipped) ++++ between /dev/null ++++ and /work/SRC/openSUSE:Leap:15.2/.llvm9.new.3606/llvm9.changes New: ---- D60657-riscv-pcrel_lo.diff _constraints assume-opensuse.patch baselibs.conf clang-9.0.1.src.tar.xz clang-docs-9.0.1.src.tar.xz clang-fix-powerpc-triplet.patch clang-ignore-stack-clash-protector.patch clang-resourcedirs.patch clang-riscv64-rv64gc.diff clang-tools-extra-9.0.1.src.tar.xz compiler-rt-9.0.1.src.tar.xz compiler-rt-move-fdp.patch compiler-rt-sanitizer-ipc-perm.patch default-to-i586.patch gwp-asan-lto.patch libcxx-9.0.1.src.tar.xz libcxx-tests-linux-distribution.patch libcxxabi-9.0.1.src.tar.xz link-clang-shared.patch link-clang-tools-extra-shared.patch link-lldb-shared.patch lld-9.0.1.src.tar.xz lldb-9.0.1.src.tar.xz lldb-cmake.patch llvm-9.0.1.src.tar.xz llvm-better-detect-64bit-atomics-support.patch llvm-do-not-install-static-libraries.patch llvm-docs-9.0.1.src.tar.xz llvm-fix-find-gcc5-install.patch llvm-normally-versioned-libllvm.patch llvm-remove-clang-only-flags.patch llvm-riscv64-fix-cffi.diff llvm9-rpmlintrc llvm9.changes llvm9.spec llvm_build_tablegen_component_as_shared_library.patch lto-disable-cache.patch openmp-9.0.1.src.tar.xz openmp-export-fini.patch opt-viewer-Find-style-css-in-usr-share.patch polly-9.0.1.src.tar.xz polly-pthread.patch riscv-eh-frame-fixup.patch riscv64-suse-linux.patch tests-use-python3.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ llvm9.spec ++++++ ++++ 1899 lines (skipped) ++++++ D60657-riscv-pcrel_lo.diff ++++++ commit 41449c58c58e466bcf9cdc4f7415950382bad8d7 Author: Roger Ferrer Ibanez <roger.ferrer@bsc.es> Date: Fri Nov 8 08:26:30 2019 +0000 [RISCV] Fix evaluation of %pcrel_lo The following testcase function: .Lpcrel_label1: auipc a0, %pcrel_hi(other_function) addi a1, a0, %pcrel_lo(.Lpcrel_label1) .p2align 2 # Causes a new fragment to be emitted .type other_function,@function other_function: ret exposes an odd behaviour in which only the %pcrel_hi relocation is evaluated but not the %pcrel_lo. $ llvm-mc -triple riscv64 -filetype obj t.s | llvm-objdump -d -r - <stdin>: file format ELF64-riscv Disassembly of section .text: 0000000000000000 function: 0: 17 05 00 00 auipc a0, 0 4: 93 05 05 00 mv a1, a0 0000000000000004: R_RISCV_PCREL_LO12_I other_function+4 0000000000000008 other_function: 8: 67 80 00 00 ret The reason seems to be that in RISCVAsmBackend::shouldForceRelocation we only consider the fragment but in RISCVMCExpr::evaluatePCRelLo we consider the section. This usually works but there are cases where the section may still be the same but the fragment may be another one. In that case we end forcing a %pcrel_lo relocation without any %pcrel_hi. This patch makes RISCVAsmBackend::shouldForceRelocation use the section, if any, to determine if the relocation must be forced or not. Differential Revision: https://reviews.llvm.org/D60657 Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -57,11 +57,15 @@ bool RISCVAsmBackend::shouldForceRelocat case RISCV::fixup_riscv_tls_gd_hi20: ShouldForce = true; break; - case RISCV::fixup_riscv_pcrel_hi20: - ShouldForce = T->getValue()->findAssociatedFragment() != - Fixup.getValue()->findAssociatedFragment(); + case RISCV::fixup_riscv_pcrel_hi20: { + MCFragment *TFragment = T->getValue()->findAssociatedFragment(); + MCFragment *FixupFragment = Fixup.getValue()->findAssociatedFragment(); + assert(FixupFragment && "We should have a fragment for this fixup"); + ShouldForce = + !TFragment || TFragment->getParent() != FixupFragment->getParent(); break; } + } break; } ++++++ _constraints ++++++ <?xml version="1.0"?> <constraints> <hardware> <disk> <size unit="G">35</size> </disk> <memory> <size unit="M">9000</size> </memory> </hardware> <overwrite> <!-- We have disabled debuginfo on 32 bit architecture because they simply can no address enough memory to link llvm libraries with it. Without debuginfo the disk and memory requirements are much lower. --> <conditions> <arch>armv6l</arch> <arch>armv7l</arch> <arch>i586</arch> <arch>ppc</arch> <arch>s390</arch> </conditions> <hardware> <disk> <size unit="G">10</size> </disk> <memory> <size unit="M">4096</size> </memory> </hardware> </overwrite> <overwrite> <conditions> <arch>aarch64</arch> </conditions> <hardware> <memory> <size unit="M">4096</size> </memory> </hardware> <sandbox>kvm</sandbox> </overwrite> <overwrite> <conditions> <arch>ppc64</arch> <arch>ppc64le</arch> </conditions> <hardware> <memory> <size unit="M">4096</size> </memory> </hardware> </overwrite> <overwrite> <conditions> <arch>riscv64</arch> </conditions> <hardware> <disk> <size unit="G">55</size> </disk> <memory> <size unit="M">14000</size> </memory> </hardware> </overwrite> </constraints> ++++++ assume-opensuse.patch ++++++ Index: cfe-8.0.0rc3.src/lib/Driver/Distro.cpp =================================================================== --- cfe-8.0.0rc3.src.orig/lib/Driver/Distro.cpp +++ cfe-8.0.0rc3.src/lib/Driver/Distro.cpp @@ -19,6 +19,8 @@ using namespace clang::driver; using namespace clang; static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) { + return Distro::OpenSUSE; +/* llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File = VFS.getBufferForFile("/etc/lsb-release"); if (File) { @@ -141,7 +143,7 @@ static Distro::DistroType DetectDistro(l if (VFS.exists("/etc/gentoo-release")) return Distro::Gentoo; - return Distro::UnknownDistro; + return Distro::UnknownDistro;*/ } Distro::Distro(llvm::vfs::FileSystem &VFS) : DistroVal(DetectDistro(VFS)) {} Index: cfe-8.0.0rc3.src/unittests/Driver/CMakeLists.txt =================================================================== --- cfe-8.0.0rc3.src.orig/unittests/Driver/CMakeLists.txt +++ cfe-8.0.0rc3.src/unittests/Driver/CMakeLists.txt @@ -5,7 +5,6 @@ set(LLVM_LINK_COMPONENTS ) add_clang_unittest(ClangDriverTests - DistroTest.cpp ToolChainTest.cpp ModuleCacheTest.cpp MultilibTest.cpp ++++++ baselibs.conf ++++++ libLLVM9 libclang9 libLTO9 llvm9-devel provides "llvm-devel-<targettype> = <version>" conflicts "otherproviders(llvm-devel-<targettype>)" clang9-devel provides "clang-devel-<targettype> = <version>" conflicts "otherproviders(clang-devel-<targettype>)" llvm9-LTO-devel provides "llvm-LTO-devel-<targettype> = <version>" conflicts "otherproviders(llvm-LTO-devel-<targettype>)" ++++++ clang-fix-powerpc-triplet.patch ++++++ [Driver] Fix incorrect GNU triplet for PowerPC on SUSE Linux On SUSE distributions for 32-bit PowerPC, gcc is configured as a 64-bit compiler using the GNU triplet "powerpc64-suse-linux", but invoked with "-m32" by default. Thus, the correct GNU triplet for 32-bit PowerPC SUSE distributions is "powerpc64-suse-linux" and not "powerpc-suse-linux". Differential Revision: https://reviews.llvm.org/D55326 diff -Nru cfe-7.0.0.src.orig/lib/Driver/ToolChains/Gnu.cpp cfe-7.0.0.src/lib/Driver/ToolChains/Gnu.cpp --- cfe-7.0.0.src.orig/lib/Driver/ToolChains/Gnu.cpp 2018-07-31 16:21:46.000000000 +0200 +++ cfe-7.0.0.src/lib/Driver/ToolChains/Gnu.cpp 2018-12-05 15:55:34.106427845 +0100 @@ -1865,7 +1865,7 @@ 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"}; + "powerpc64-suse-linux", "powerpc-montavista-linuxspe"}; static const char *const PPC64LibDirs[] = {"/lib64", "/lib"}; static const char *const PPC64Triples[] = { "powerpc64-linux-gnu", "powerpc64-unknown-linux-gnu", ++++++ clang-ignore-stack-clash-protector.patch ++++++ Index: cfe-6.0.0rc1.src/include/clang/Driver/Options.td =================================================================== --- cfe-6.0.0rc1.src.orig/include/clang/Driver/Options.td +++ cfe-6.0.0rc1.src/include/clang/Driver/Options.td @@ -816,6 +816,7 @@ def fexcess_precision_EQ : Joined<["-"], Group<clang_ignored_gcc_optimization_f_Group>; def : Flag<["-"], "fexpensive-optimizations">, Group<clang_ignored_gcc_optimization_f_Group>; def : Flag<["-"], "fno-expensive-optimizations">, Group<clang_ignored_gcc_optimization_f_Group>; +def : Flag<["-"], "fstack-clash-protection">, Group<clang_ignored_f_Group>; def fextdirs_EQ : Joined<["-"], "fextdirs=">, Group<f_Group>; def : Flag<["-"], "fdefer-pop">, Group<clang_ignored_gcc_optimization_f_Group>; def : Flag<["-"], "fno-defer-pop">, Group<clang_ignored_gcc_optimization_f_Group>; ++++++ clang-resourcedirs.patch ++++++ Index: cfe-6.0.0rc1.src/lib/Driver/Driver.cpp =================================================================== --- cfe-6.0.0rc1.src.orig/lib/Driver/Driver.cpp +++ cfe-6.0.0rc1.src/lib/Driver/Driver.cpp @@ -115,7 +115,7 @@ Driver::Driver(StringRef ClangExecutable // Dir is bin/ or lib/, depending on where BinaryPath is. std::string Dir = llvm::sys::path::parent_path(BinaryPath); - SmallString<128> P(Dir); + SmallString<128> P((Dir != "") ? Dir : "/usr/bin/"); if (CustomResourceDir != "") { llvm::sys::path::append(P, CustomResourceDir); } else { ++++++ clang-riscv64-rv64gc.diff ++++++ commit 93c4d53b0a5 Author: Roger Ferrer Ibanez <rofirrim@gmail.com> Date: Tue Sep 10 08:16:24 2019 +0000 [RISCV] Make -march=rv{32,64}gc the default in RISC-V Linux This is the logical follow-up of D65634. Differential Revision: https://reviews.llvm.org/D66003 llvm-svn: 371496 Index: clang-9.0.1.src/lib/Driver/ToolChains/Arch/RISCV.cpp =================================================================== --- clang-9.0.1.src.orig/lib/Driver/ToolChains/Arch/RISCV.cpp +++ clang-9.0.1.src/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -12,6 +12,7 @@ #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "llvm/Option/ArgList.h" +#include "llvm/ADT/Optional.h" #include "llvm/Support/TargetParser.h" #include "llvm/Support/raw_ostream.h" #include "ToolChains/CommonArgs.h" @@ -189,168 +190,182 @@ static void getExtensionFeatures(const D } } -void riscv::getRISCVTargetFeatures(const Driver &D, const ArgList &Args, - std::vector<StringRef> &Features) { - if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) { - StringRef MArch = A->getValue(); +// Returns false if an error is diagnosed. +static bool getArchFeatures(const Driver &D, StringRef MArch, + std::vector<StringRef> &Features, + const ArgList &Args) { + // RISC-V ISA strings must be lowercase. + if (llvm::any_of(MArch, [](char c) { return isupper(c); })) { + D.Diag(diag::err_drv_invalid_riscv_arch_name) + << MArch << "string must be lowercase"; + return false; + } - // RISC-V ISA strings must be lowercase. - if (llvm::any_of(MArch, [](char c) { return isupper(c); })) { - D.Diag(diag::err_drv_invalid_riscv_arch_name) - << MArch << "string must be lowercase"; - return; - } + // ISA string must begin with rv32 or rv64. + if (!(MArch.startswith("rv32") || MArch.startswith("rv64")) || + (MArch.size() < 5)) { + D.Diag(diag::err_drv_invalid_riscv_arch_name) + << MArch << "string must begin with rv32{i,e,g} or rv64{i,g}"; + return false; + } - // ISA string must begin with rv32 or rv64. - if (!(MArch.startswith("rv32") || MArch.startswith("rv64")) || - (MArch.size() < 5)) { - D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch - << "string must begin with rv32{i,e,g} or rv64{i,g}"; - return; - } + bool HasRV64 = MArch.startswith("rv64"); - bool HasRV64 = MArch.startswith("rv64"); + // The canonical order specified in ISA manual. + // Ref: Table 22.1 in RISC-V User-Level ISA V2.2 + StringRef StdExts = "mafdqlcbjtpvn"; + bool HasF = false, HasD = false; + char Baseline = MArch[4]; + + // First letter should be 'e', 'i' or 'g'. + switch (Baseline) { + default: + D.Diag(diag::err_drv_invalid_riscv_arch_name) + << MArch << "first letter should be 'e', 'i' or 'g'"; + return false; + case 'e': { + StringRef Error; + // Currently LLVM does not support 'e'. + // Extension 'e' is not allowed in rv64. + if (HasRV64) + Error = "standard user-level extension 'e' requires 'rv32'"; + else + Error = "unsupported standard user-level extension 'e'"; + D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch << Error; + return false; + } + case 'i': + break; + case 'g': + // g = imafd + StdExts = StdExts.drop_front(4); + Features.push_back("+m"); + Features.push_back("+a"); + Features.push_back("+f"); + Features.push_back("+d"); + HasF = true; + HasD = true; + break; + } - // The canonical order specified in ISA manual. - // Ref: Table 22.1 in RISC-V User-Level ISA V2.2 - StringRef StdExts = "mafdqlcbjtpvn"; - bool HasF = false, HasD = false; - char Baseline = MArch[4]; + // Skip rvxxx + StringRef Exts = MArch.substr(5); - // First letter should be 'e', 'i' or 'g'. - switch (Baseline) { - default: - D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch - << "first letter should be 'e', 'i' or 'g'"; - return; - case 'e': { + // Remove non-standard extensions and supervisor-level extensions. + // They have 'x', 's', 'sx' prefixes. Parse them at the end. + // Find the very first occurrence of 's' or 'x'. + StringRef OtherExts; + size_t Pos = Exts.find_first_of("sx"); + if (Pos != StringRef::npos) { + OtherExts = Exts.substr(Pos); + Exts = Exts.substr(0, Pos); + } + + std::string Major, Minor; + if (!getExtensionVersion(D, MArch, std::string(1, Baseline), Exts, Major, + Minor)) + return false; + + // TODO: Use version number when setting target features + // and consume the underscore '_' that might follow. + + auto StdExtsItr = StdExts.begin(); + auto StdExtsEnd = StdExts.end(); + + for (auto I = Exts.begin(), E = Exts.end(); I != E; ++I) { + char c = *I; + + // Check ISA extensions are specified in the canonical order. + while (StdExtsItr != StdExtsEnd && *StdExtsItr != c) + ++StdExtsItr; + + if (StdExtsItr == StdExtsEnd) { + // Either c contains a valid extension but it was not given in + // canonical order or it is an invalid extension. StringRef Error; - // Currently LLVM does not support 'e'. - // Extension 'e' is not allowed in rv64. - if (HasRV64) - Error = "standard user-level extension 'e' requires 'rv32'"; + if (StdExts.contains(c)) + Error = "standard user-level extension not given in canonical order"; else - Error = "unsupported standard user-level extension 'e'"; - D.Diag(diag::err_drv_invalid_riscv_arch_name) - << MArch << Error; - return; + Error = "invalid standard user-level extension"; + D.Diag(diag::err_drv_invalid_riscv_ext_arch_name) + << MArch << Error << std::string(1, c); + return false; } - case 'i': - break; - case 'g': - // g = imafd - StdExts = StdExts.drop_front(4); + + // Move to next char to prevent repeated letter. + ++StdExtsItr; + + if (std::next(I) != E) { + // Skip c. + std::string Next = std::string(std::next(I), E); + std::string Major, Minor; + if (!getExtensionVersion(D, MArch, std::string(1, c), Next, Major, Minor)) + return false; + + // TODO: Use version number when setting target features + // and consume the underscore '_' that might follow. + } + + // The order is OK, then push it into features. + switch (c) { + default: + // Currently LLVM supports only "mafdc". + D.Diag(diag::err_drv_invalid_riscv_ext_arch_name) + << MArch << "unsupported standard user-level extension" + << std::string(1, c); + return false; + case 'm': Features.push_back("+m"); + break; + case 'a': Features.push_back("+a"); + break; + case 'f': Features.push_back("+f"); - Features.push_back("+d"); HasF = true; + break; + case 'd': + Features.push_back("+d"); HasD = true; break; + case 'c': + Features.push_back("+c"); + break; } + } - // Skip rvxxx - StringRef Exts = MArch.substr(5); - - // Remove non-standard extensions and supervisor-level extensions. - // They have 'x', 's', 'sx' prefixes. Parse them at the end. - // Find the very first occurrence of 's' or 'x'. - StringRef OtherExts; - size_t Pos = Exts.find_first_of("sx"); - if (Pos != StringRef::npos) { - OtherExts = Exts.substr(Pos); - Exts = Exts.substr(0, Pos); - } - - std::string Major, Minor; - if (!getExtensionVersion(D, MArch, std::string(1, Baseline), - Exts, Major, Minor)) - return; - - // TODO: Use version number when setting target features - // and consume the underscore '_' that might follow. - - auto StdExtsItr = StdExts.begin(); - auto StdExtsEnd = StdExts.end(); - - for (auto I = Exts.begin(), E = Exts.end(); I != E; ++I) { - char c = *I; + // Dependency check. + // It's illegal to specify the 'd' (double-precision floating point) + // extension without also specifying the 'f' (single precision + // floating-point) extension. + if (HasD && !HasF) { + D.Diag(diag::err_drv_invalid_riscv_arch_name) + << MArch << "d requires f extension to also be specified"; + return false; + } - // Check ISA extensions are specified in the canonical order. - while (StdExtsItr != StdExtsEnd && *StdExtsItr != c) - ++StdExtsItr; - - if (StdExtsItr == StdExtsEnd) { - // Either c contains a valid extension but it was not given in - // canonical order or it is an invalid extension. - StringRef Error; - if (StdExts.contains(c)) - Error = "standard user-level extension not given in canonical order"; - else - Error = "invalid standard user-level extension"; - D.Diag(diag::err_drv_invalid_riscv_ext_arch_name) - << MArch << Error << std::string(1, c); - return; - } + // Additional dependency checks. + // TODO: The 'q' extension requires rv64. + // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'. - // Move to next char to prevent repeated letter. - ++StdExtsItr; + // Handle all other types of extensions. + getExtensionFeatures(D, Args, Features, MArch, OtherExts); - if (std::next(I) != E) { - // Skip c. - std::string Next = std::string(std::next(I), E); - std::string Major, Minor; - if (!getExtensionVersion(D, MArch, std::string(1, c), - Next, Major, Minor)) - return; - - // TODO: Use version number when setting target features - // and consume the underscore '_' that might follow. - } - - // The order is OK, then push it into features. - switch (c) { - default: - // Currently LLVM supports only "mafdc". - D.Diag(diag::err_drv_invalid_riscv_ext_arch_name) - << MArch << "unsupported standard user-level extension" - << std::string(1, c); - return; - case 'm': - Features.push_back("+m"); - break; - case 'a': - Features.push_back("+a"); - break; - case 'f': - Features.push_back("+f"); - HasF = true; - break; - case 'd': - Features.push_back("+d"); - HasD = true; - break; - case 'c': - Features.push_back("+c"); - break; - } - } - - // Dependency check. - // It's illegal to specify the 'd' (double-precision floating point) - // extension without also specifying the 'f' (single precision - // floating-point) extension. - if (HasD && !HasF) - D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch - << "d requires f extension to also be specified"; + return true; +} - // Additional dependency checks. - // TODO: The 'q' extension requires rv64. - // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'. +void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, + std::vector<StringRef> &Features) { + llvm::Optional<StringRef> MArch; + if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) + MArch = A->getValue(); + else if (Triple.getOS() == llvm::Triple::Linux) + // RISC-V Linux defaults to rv{32,64}gc. + MArch = Triple.getArch() == llvm::Triple::riscv32 ? "rv32gc" : "rv64gc"; - // Handle all other types of extensions. - getExtensionFeatures(D, Args, Features, MArch, OtherExts); - } + if (MArch.hasValue() && !getArchFeatures(D, *MArch, Features, Args)) + return; // -mrelax is default, unless -mno-relax is specified. if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) @@ -372,8 +387,16 @@ void riscv::getRISCVTargetFeatures(const } StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) { - if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) + assert((Triple.getArch() == llvm::Triple::riscv32 || + Triple.getArch() == llvm::Triple::riscv64) && + "Unexpected triple"); + + if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) return A->getValue(); - return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64"; + // RISC-V Linux defaults to ilp32d/lp64d + if (Triple.getOS() == llvm::Triple::Linux) + return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32d" : "lp64d"; + else + return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64"; } Index: clang-9.0.1.src/lib/Driver/ToolChains/Arch/RISCV.h =================================================================== --- clang-9.0.1.src.orig/lib/Driver/ToolChains/Arch/RISCV.h +++ clang-9.0.1.src/lib/Driver/ToolChains/Arch/RISCV.h @@ -19,7 +19,8 @@ namespace clang { namespace driver { namespace tools { namespace riscv { -void getRISCVTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, +void getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const llvm::opt::ArgList &Args, std::vector<llvm::StringRef> &Features); StringRef getRISCVABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple); Index: clang-9.0.1.src/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang-9.0.1.src.orig/lib/Driver/ToolChains/Clang.cpp +++ clang-9.0.1.src/lib/Driver/ToolChains/Clang.cpp @@ -335,7 +335,7 @@ static void getTargetFeatures(const Tool break; case llvm::Triple::riscv32: case llvm::Triple::riscv64: - riscv::getRISCVTargetFeatures(D, Args, Features); + riscv::getRISCVTargetFeatures(D, Triple, Args, Features); break; case llvm::Triple::systemz: systemz::getSystemZTargetFeatures(Args, Features); @@ -1853,21 +1853,11 @@ void Clang::AddPPCTargetArgs(const ArgLi void Clang::AddRISCVTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { - // FIXME: currently defaults to the soft-float ABIs. Will need to be - // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate. - const char *ABIName = nullptr; const llvm::Triple &Triple = getToolChain().getTriple(); - if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) - ABIName = A->getValue(); - else if (Triple.getArch() == llvm::Triple::riscv32) - ABIName = "ilp32"; - else if (Triple.getArch() == llvm::Triple::riscv64) - ABIName = "lp64"; - else - llvm_unreachable("Unexpected triple!"); + StringRef ABIName = riscv::getRISCVABI(Args, Triple); CmdArgs.push_back("-target-abi"); - CmdArgs.push_back(ABIName); + CmdArgs.push_back(ABIName.data()); } void Clang::AddSparcTargetArgs(const ArgList &Args, Index: clang-9.0.1.src/test/Driver/riscv32-toolchain.c =================================================================== --- clang-9.0.1.src.orig/test/Driver/riscv32-toolchain.c +++ clang-9.0.1.src/test/Driver/riscv32-toolchain.c @@ -68,7 +68,7 @@ // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|\\\\}}crtend.o" // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \ -// RUN: -target riscv32-unknown-linux-gnu \ +// RUN: -target riscv32-unknown-linux-gnu -mabi=ilp32 \ // RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \ // RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32 %s @@ -84,7 +84,7 @@ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32" // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \ -// RUN: -target riscv32-unknown-linux-gnu -march=rv32imafd -mabi=ilp32d \ +// RUN: -target riscv32-unknown-linux-gnu -march=rv32imafd \ // RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \ // RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32D %s Index: clang-9.0.1.src/test/Driver/riscv64-toolchain.c =================================================================== --- clang-9.0.1.src.orig/test/Driver/riscv64-toolchain.c +++ clang-9.0.1.src/test/Driver/riscv64-toolchain.c @@ -68,7 +68,7 @@ // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|\\\\}}crtend.o" // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \ -// RUN: -target riscv64-unknown-linux-gnu \ +// RUN: -target riscv64-unknown-linux-gnu -mabi=lp64 \ // RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \ // RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s @@ -84,7 +84,7 @@ // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64" // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \ -// RUN: -target riscv64-unknown-linux-gnu -march=rv64imafd -mabi=lp64d \ +// RUN: -target riscv64-unknown-linux-gnu -march=rv64imafd \ // RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \ // RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64D %s Index: clang-9.0.1.src/test/Preprocessor/riscv-target-features.c =================================================================== --- clang-9.0.1.src.orig/test/Preprocessor/riscv-target-features.c +++ clang-9.0.1.src/test/Preprocessor/riscv-target-features.c @@ -48,9 +48,9 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s // CHECK-C-EXT: __riscv_compressed 1 -// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -x c -E -dM %s \ +// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s -// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \ +// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64 -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s // CHECK-SOFT: __riscv_float_abi_soft 1 // CHECK-SOFT-NOT: __riscv_float_abi_single @@ -64,9 +64,9 @@ // CHECK-SINGLE-NOT: __riscv_float_abi_soft // CHECK-SINGLE-NOT: __riscv_float_abi_double -// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32d -x c -E -dM %s \ +// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s -// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64d -x c -E -dM %s \ +// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s // CHECK-DOUBLE: __riscv_float_abi_double 1 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft ++++++ compiler-rt-move-fdp.patch ++++++
From f1b0a93e3a777565485e165fba17c4e81ba6c127 Mon Sep 17 00:00:00 2001 From: Max Moroz <mmoroz@chromium.org> Date: Mon, 5 Aug 2019 19:55:52 +0000 Subject: [PATCH] [compiler-rt] Move FDP to include/fuzzer/FuzzedDataProvider.h for easier use.
Summary: FuzzedDataProvider is a helper class for writing fuzz targets that fuzz multple inputs simultaneously. The header is supposed to be used for fuzzing engine agnostic fuzz targets (i.e. the same target can be used with libFuzzer, AFL, honggfuzz, and other engines). The common thing though is that fuzz targets are typically compiled with clang, as it provides all sanitizers as well as different coverage instrumentation modes. Therefore, making this FDP class a part of the compiler-rt installation package would make it easier to develop and distribute fuzz targets across different projects, build systems, etc. Some context also available in https://github.com/google/oss-fuzz/pull/2547. This CL does not delete the header from `lib/fuzzer/utils` directory in order to provide the downstream users some time for a smooth migration to the new header location. Reviewers: kcc, morehouse Reviewed By: morehouse Subscribers: lebedev.ri, kubamracek, dberris, mgorny, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D65661 llvm-svn: 367917 --- compiler-rt/include/CMakeLists.txt | 9 + compiler-rt/include/fuzzer/FuzzedDataProvider.h | 245 +++++++++++++++++++++ compiler-rt/lib/fuzzer/FuzzerExtFunctions.def | 8 +- compiler-rt/lib/fuzzer/tests/CMakeLists.txt | 2 - .../fuzzer/tests/FuzzedDataProviderUnittest.cpp | 2 +- compiler-rt/lib/fuzzer/utils/FuzzedDataProvider.h | 4 +- .../lib/sanitizer_common/scripts/check_lint.sh | 4 +- 7 files changed, 264 insertions(+), 10 deletions(-) create mode 100644 compiler-rt/include/fuzzer/FuzzedDataProvider.h diff --git a/compiler-rt/include/CMakeLists.txt b/compiler-rt/include/CMakeLists.txt index 38bd6e41a91..57ed6c3ade2 100644 --- a/compiler-rt/include/CMakeLists.txt +++ b/compiler-rt/include/CMakeLists.txt @@ -14,6 +14,9 @@ if (COMPILER_RT_BUILD_SANITIZERS) sanitizer/tsan_interface.h sanitizer/tsan_interface_atomic.h ) + set(FUZZER_HEADERS + fuzzer/FuzzedDataProvider.h + ) endif(COMPILER_RT_BUILD_SANITIZERS) if (COMPILER_RT_BUILD_XRAY) @@ -26,6 +29,7 @@ endif(COMPILER_RT_BUILD_XRAY) set(COMPILER_RT_HEADERS ${SANITIZER_HEADERS} + ${FUZZER_HEADERS} ${XRAY_HEADERS}) set(output_dir ${COMPILER_RT_OUTPUT_DIR}/include) @@ -51,6 +55,11 @@ install(FILES ${SANITIZER_HEADERS} COMPONENT compiler-rt-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer) +# Install fuzzer headers. +install(FILES ${FUZZER_HEADERS} + COMPONENT compiler-rt-headers + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer) # Install xray headers. install(FILES ${XRAY_HEADERS} COMPONENT compiler-rt-headers diff --git a/compiler-rt/include/fuzzer/FuzzedDataProvider.h b/compiler-rt/include/fuzzer/FuzzedDataProvider.h new file mode 100644 index 00000000000..e82f441d409 --- /dev/null +++ b/compiler-rt/include/fuzzer/FuzzedDataProvider.h @@ -0,0 +1,245 @@ +//===- FuzzedDataProvider.h - Utility header for fuzz targets ---*- C++ -* ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// A single header library providing an utility class to break up an array of +// bytes. Whenever run on the same input, provides the same output, as long as +// its methods are called in the same order, with the same arguments. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_ +#define LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_ + +#include <limits.h> +#include <stddef.h> +#include <stdint.h> + +#include <algorithm> +#include <cstring> +#include <initializer_list> +#include <string> +#include <type_traits> +#include <utility> +#include <vector> + +class FuzzedDataProvider { + public: + // |data| is an array of length |size| that the FuzzedDataProvider wraps to + // provide more granular access. |data| must outlive the FuzzedDataProvider. + FuzzedDataProvider(const uint8_t *data, size_t size) + : data_ptr_(data), remaining_bytes_(size) {} + ~FuzzedDataProvider() = default; + + // Returns a std::vector containing |num_bytes| of input data. If fewer than + // |num_bytes| of data remain, returns a shorter std::vector containing all + // of the data that's left. Can be used with any byte sized type, such as + // char, unsigned char, uint8_t, etc. + template <typename T> std::vector<T> ConsumeBytes(size_t num_bytes) { + num_bytes = std::min(num_bytes, remaining_bytes_); + return ConsumeBytes<T>(num_bytes, num_bytes); + } + + // Similar to |ConsumeBytes|, but also appends the terminator value at the end + // of the resulting vector. Useful, when a mutable null-terminated C-string is + // needed, for example. But that is a rare case. Better avoid it, if possible, + // and prefer using |ConsumeBytes| or |ConsumeBytesAsString| methods. + template <typename T> + std::vector<T> ConsumeBytesWithTerminator(size_t num_bytes, + T terminator = 0) { + num_bytes = std::min(num_bytes, remaining_bytes_); + std::vector<T> result = ConsumeBytes<T>(num_bytes + 1, num_bytes); + result.back() = terminator; + return result; + } + + // Returns a std::string containing |num_bytes| of input data. Using this and + // |.c_str()| on the resulting string is the best way to get an immutable + // null-terminated C string. If fewer than |num_bytes| of data remain, returns + // a shorter std::string containing all of the data that's left. + std::string ConsumeBytesAsString(size_t num_bytes) { + static_assert(sizeof(std::string::value_type) == sizeof(uint8_t), + "ConsumeBytesAsString cannot convert the data to a string."); + + num_bytes = std::min(num_bytes, remaining_bytes_); + std::string result( + reinterpret_cast<const std::string::value_type *>(data_ptr_), + num_bytes); + Advance(num_bytes); + return result; + } + + // Returns a number in the range [min, max] by consuming bytes from the + // input data. The value might not be uniformly distributed in the given + // range. If there's no input data left, always returns |min|. |min| must + // be less than or equal to |max|. + template <typename T> T ConsumeIntegralInRange(T min, T max) { + static_assert(std::is_integral<T>::value, "An integral type is required."); + static_assert(sizeof(T) <= sizeof(uint64_t), "Unsupported integral type."); + + if (min > max) + abort(); + + // Use the biggest type possible to hold the range and the result. + uint64_t range = static_cast<uint64_t>(max) - min; + uint64_t result = 0; + size_t offset = 0; + + while (offset < sizeof(T) * CHAR_BIT && (range >> offset) > 0 && + remaining_bytes_ != 0) { + // Pull bytes off the end of the seed data. Experimentally, this seems to + // allow the fuzzer to more easily explore the input space. This makes + // sense, since it works by modifying inputs that caused new code to run, + // and this data is often used to encode length of data read by + // |ConsumeBytes|. Separating out read lengths makes it easier modify the + // contents of the data that is actually read. + --remaining_bytes_; + result = (result << CHAR_BIT) | data_ptr_[remaining_bytes_]; + offset += CHAR_BIT; + } + + // Avoid division by 0, in case |range + 1| results in overflow. + if (range != std::numeric_limits<decltype(range)>::max()) + result = result % (range + 1); + + return static_cast<T>(min + result); + } + + // Returns a std::string of length from 0 to |max_length|. When it runs out of + // input data, returns what remains of the input. Designed to be more stable + // with respect to a fuzzer inserting characters than just picking a random + // length and then consuming that many bytes with |ConsumeBytes|. + std::string ConsumeRandomLengthString(size_t max_length) { + // Reads bytes from the start of |data_ptr_|. Maps "\\" to "\", and maps "\" + // followed by anything else to the end of the string. As a result of this + // logic, a fuzzer can insert characters into the string, and the string + // will be lengthened to include those new characters, resulting in a more + // stable fuzzer than picking the length of a string independently from + // picking its contents. + std::string result; + + // Reserve the anticipated capaticity to prevent several reallocations. + result.reserve(std::min(max_length, remaining_bytes_)); + for (size_t i = 0; i < max_length && remaining_bytes_ != 0; ++i) { + char next = ConvertUnsignedToSigned<char>(data_ptr_[0]); + Advance(1); + if (next == '\\' && remaining_bytes_ != 0) { + next = ConvertUnsignedToSigned<char>(data_ptr_[0]); + Advance(1); + if (next != '\\') + break; + } + result += next; + } + + result.shrink_to_fit(); + return result; + } + + // Returns a std::vector containing all remaining bytes of the input data. + template <typename T> std::vector<T> ConsumeRemainingBytes() { + return ConsumeBytes<T>(remaining_bytes_); + } + + // Prefer using |ConsumeRemainingBytes| unless you actually need a std::string + // object. + // Returns a std::vector containing all remaining bytes of the input data. + std::string ConsumeRemainingBytesAsString() { + return ConsumeBytesAsString(remaining_bytes_); + } + + // Returns a number in the range [Type's min, Type's max]. The value might + // not be uniformly distributed in the given range. If there's no input data + // left, always returns |min|. + template <typename T> T ConsumeIntegral() { + return ConsumeIntegralInRange(std::numeric_limits<T>::min(), + std::numeric_limits<T>::max()); + } + + // Reads one byte and returns a bool, or false when no data remains. + bool ConsumeBool() { return 1 & ConsumeIntegral<uint8_t>(); } + + // Returns a copy of a value selected from a fixed-size |array|. + template <typename T, size_t size> + T PickValueInArray(const T (&array)[size]) { + static_assert(size > 0, "The array must be non empty."); + return array[ConsumeIntegralInRange<size_t>(0, size - 1)]; + } + + template <typename T> + T PickValueInArray(std::initializer_list<const T> list) { + // static_assert(list.size() > 0, "The array must be non empty."); + return *(list.begin() + ConsumeIntegralInRange<size_t>(0, list.size() - 1)); + } + + // Return an enum value. The enum must start at 0 and be contiguous. It must + // also contain |kMaxValue| aliased to its largest (inclusive) value. Such as: + // enum class Foo { SomeValue, OtherValue, kMaxValue = OtherValue }; + template <typename T> T ConsumeEnum() { + static_assert(std::is_enum<T>::value, "|T| must be an enum type."); + return static_cast<T>(ConsumeIntegralInRange<uint32_t>( + 0, static_cast<uint32_t>(T::kMaxValue))); + } + + // Reports the remaining bytes available for fuzzed input. + size_t remaining_bytes() { return remaining_bytes_; } + + private: + FuzzedDataProvider(const FuzzedDataProvider &) = delete; + FuzzedDataProvider &operator=(const FuzzedDataProvider &) = delete; + + void Advance(size_t num_bytes) { + if (num_bytes > remaining_bytes_) + abort(); + + data_ptr_ += num_bytes; + remaining_bytes_ -= num_bytes; + } + + template <typename T> + std::vector<T> ConsumeBytes(size_t size, size_t num_bytes_to_consume) { + static_assert(sizeof(T) == sizeof(uint8_t), "Incompatible data type."); + + // The point of using the size-based constructor below is to increase the + // odds of having a vector object with capacity being equal to the length. + // That part is always implementation specific, but at least both libc++ and + // libstdc++ allocate the requested number of bytes in that constructor, + // which seems to be a natural choice for other implementations as well. + // To increase the odds even more, we also call |shrink_to_fit| below. + std::vector<T> result(size); + std::memcpy(result.data(), data_ptr_, num_bytes_to_consume); + Advance(num_bytes_to_consume); + + // Even though |shrink_to_fit| is also implementation specific, we expect it + // to provide an additional assurance in case vector's constructor allocated + // a buffer which is larger than the actual amount of data we put inside it. + result.shrink_to_fit(); + return result; + } + + template <typename TS, typename TU> TS ConvertUnsignedToSigned(TU value) { + static_assert(sizeof(TS) == sizeof(TU), "Incompatible data types."); + static_assert(!std::numeric_limits<TU>::is_signed, + "Source type must be unsigned."); + + // TODO(Dor1s): change to `if constexpr` once C++17 becomes mainstream. + if (std::numeric_limits<TS>::is_modulo) + return static_cast<TS>(value); + + // Avoid using implementation-defined unsigned to signer conversions. + // To learn more, see https://stackoverflow.com/questions/13150449. + if (value <= std::numeric_limits<TS>::max()) + return static_cast<TS>(value); + else { + constexpr auto TS_min = std::numeric_limits<TS>::min(); + return TS_min + static_cast<char>(value - TS_min); + } + } + + const uint8_t *data_ptr_; + size_t remaining_bytes_; +}; + +#endif // LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_ diff --git a/compiler-rt/lib/fuzzer/FuzzerExtFunctions.def b/compiler-rt/lib/fuzzer/FuzzerExtFunctions.def index 87df4ecb812..7b53b085560 100644 --- a/compiler-rt/lib/fuzzer/FuzzerExtFunctions.def +++ b/compiler-rt/lib/fuzzer/FuzzerExtFunctions.def @@ -16,12 +16,12 @@ // Optional user functions EXT_FUNC(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false); EXT_FUNC(LLVMFuzzerCustomMutator, size_t, - (uint8_t * Data, size_t Size, size_t MaxSize, unsigned int Seed), + (uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed), false); EXT_FUNC(LLVMFuzzerCustomCrossOver, size_t, - (const uint8_t * Data1, size_t Size1, - const uint8_t * Data2, size_t Size2, - uint8_t * Out, size_t MaxOutSize, unsigned int Seed), + (const uint8_t *Data1, size_t Size1, + const uint8_t *Data2, size_t Size2, + uint8_t *Out, size_t MaxOutSize, unsigned int Seed), false); // Sanitizer functions diff --git a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt index 6f665107994..69e67ab0d50 100644 --- a/compiler-rt/lib/fuzzer/tests/CMakeLists.txt +++ b/compiler-rt/lib/fuzzer/tests/CMakeLists.txt @@ -75,8 +75,6 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH) set_target_properties(FuzzerUnitTests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - list(APPEND LIBFUZZER_UNITTEST_CFLAGS -I${COMPILER_RT_SOURCE_DIR}/lib/fuzzer/utils) - set(FuzzedDataProviderTestObjects) generate_compiler_rt_tests(FuzzedDataProviderTestObjects FuzzedDataProviderUnitTests "FuzzerUtils-${arch}-Test" ${arch} diff --git a/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp b/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp index e1b272227ff..0989ec9ec7e 100644 --- a/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp +++ b/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp @@ -6,7 +6,7 @@ #include <cstdint> #include <cstdlib> -#include "FuzzedDataProvider.h" +#include <fuzzer/FuzzedDataProvider.h> // The test is intentionally extensive, as behavior of |FuzzedDataProvider| must // not be broken, given than many fuzz targets depend on it. Changing the diff --git a/compiler-rt/lib/fuzzer/utils/FuzzedDataProvider.h b/compiler-rt/lib/fuzzer/utils/FuzzedDataProvider.h index 1b5b4bb0126..e82f441d409 100644 --- a/compiler-rt/lib/fuzzer/utils/FuzzedDataProvider.h +++ b/compiler-rt/lib/fuzzer/utils/FuzzedDataProvider.h @@ -26,7 +26,7 @@ #include <vector> class FuzzedDataProvider { -public: + public: // |data| is an array of length |size| that the FuzzedDataProvider wraps to // provide more granular access. |data| must outlive the FuzzedDataProvider. FuzzedDataProvider(const uint8_t *data, size_t size) @@ -186,7 +186,7 @@ public: // Reports the remaining bytes available for fuzzed input. size_t remaining_bytes() { return remaining_bytes_; } -private: + private: FuzzedDataProvider(const FuzzedDataProvider &) = delete; FuzzedDataProvider &operator=(const FuzzedDataProvider &) = delete; diff --git a/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh b/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh index ed1cf010b6f..d78fb72f36f 100755 --- a/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh +++ b/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh @@ -66,7 +66,9 @@ fi LIT_TESTS=${COMPILER_RT}/test # Headers SANITIZER_INCLUDES=${COMPILER_RT}/include/sanitizer -run_lint ${SANITIZER_INCLUDES_LINT_FILTER} ${SANITIZER_INCLUDES}/*.h & +FUZZER_INCLUDES=${COMPILER_RT}/include/fuzzer +run_lint ${SANITIZER_INCLUDES_LINT_FILTER} ${SANITIZER_INCLUDES}/*.h \ + ${FUZZER_INCLUDES}/*.h & # Sanitizer_common COMMON_RTL=${COMPILER_RT}/lib/sanitizer_common -- 2.16.4 ++++++ compiler-rt-sanitizer-ipc-perm.patch ++++++
From 9c155985f17fd369bbba311b714fb6c01c17d66e Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer <sjoerd.meijer@arm.com> Date: Fri, 18 Oct 2019 11:01:45 +0000 Subject: [PATCH] [Arm][libsanitizer] Fix arm libsanitizer failure with bleeding edge glibc
Glibc has recently introduced changed to the mode field in ipc_perm in commit 2f959dfe849e0646e27403f2e4091536496ac0f0. For Arm this means that the mode field no longer has the same size. This causes an assert failure against libsanitizer's internal copy of ipc_perm. Since this change can't be easily detected I am adding arm to the list of targets that are excluded from this check. Patch by: Tamar Christina Differential Revision: https://reviews.llvm.org/D69104 llvm-svn: 375220
From 947f9692440836dcb8d88b74b69dd379d85974ce Mon Sep 17 00:00:00 2001 From: Evgenii Stepanov <eugenis@google.com> Date: Mon, 25 Nov 2019 13:52:17 -0800 Subject: [PATCH] Fix sanitizer-common build with glibc 2.31
Summary: As mentioned in D69104, glibc changed ABI recently with the [[ https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2f959dfe849e0646e27403f2e4091536496ac0f0| 2f959dfe ]] change. D69104 dealt with just 32-bit ARM, but that is just one of the many affected architectures. E.g. x86_64, i?86, riscv64, sparc 32-bit, s390 31-bit are affected too (and various others). This patch instead of adding a long list of further architectures that wouldn't be checked ever next to arm 32-bit changes the structures to match the 2.31 layout and performs the checking on Linux for ipc_perm mode position/size only on non-Linux or on Linux with glibc 2.31 or later. I think this matches what is done for aarch64 already. If needed, we could list architectures that haven't changed ABI (e.g. powerpc), so that they would be checked even with older glibcs. AFAIK sanitizers don't actually use ipc_perm.mode and so all they care about is the size and alignment of the whole structure. Note, s390 31-bit and arm 32-bit big-endian changed ABI even further, there will now be shmctl with old symbol version and shmctl@@GLIBC_2.31 which will be incompatible. I'm afraid this isn't really solvable unless the sanitizer libraries are symbol versioned and use matching symbol versions to glibc symbols for stuff they intercept, plus use dlvsym. This patch doesn't try to address that. Patch by Jakub Jelinek. Reviewers: kcc, eugenis, dvyukov Reviewed By: eugenis Subscribers: jyknight, kristof.beyls, fedor.sergeev, simoncook, PkmX, s.egerton, steven.zhang, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70662 Index: compiler-rt-9.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cc =================================================================== --- compiler-rt-9.0.1.src.orig/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +++ compiler-rt-9.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -1126,8 +1126,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid); CHECK_SIZE_AND_OFFSET(ipc_perm, gid); CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); -#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21) -/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */ +#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) +/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit + on many architectures. */ CHECK_SIZE_AND_OFFSET(ipc_perm, mode); #endif Index: compiler-rt-9.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.h =================================================================== --- compiler-rt-9.0.1.src.orig/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ compiler-rt-9.0.1.src/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -203,26 +203,13 @@ namespace __sanitizer { u64 __unused1; u64 __unused2; #elif defined(__sparc__) -#if defined(__arch64__) unsigned mode; - unsigned short __pad1; -#else - unsigned short __pad1; - unsigned short mode; unsigned short __pad2; -#endif unsigned short __seq; unsigned long long __unused1; unsigned long long __unused2; -#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__) - unsigned int mode; - unsigned short __seq; - unsigned short __pad1; - unsigned long __unused1; - unsigned long __unused2; #else - unsigned short mode; - unsigned short __pad1; + unsigned int mode; unsigned short __seq; unsigned short __pad2; #if defined(__x86_64__) && !defined(_LP64) ++++++ default-to-i586.patch ++++++ Index: cfe-6.0.0rc1.src/lib/Driver/ToolChains/Arch/X86.cpp =================================================================== --- cfe-6.0.0rc1.src.orig/lib/Driver/ToolChains/Arch/X86.cpp +++ cfe-6.0.0rc1.src/lib/Driver/ToolChains/Arch/X86.cpp @@ -102,8 +102,8 @@ const char *x86::getX86TargetCPU(const A case llvm::Triple::Haiku: return "i586"; default: - // Fallback to p4. - return "pentium4"; + // Fallback to i586. + return "i586"; } } ++++++ gwp-asan-lto.patch ++++++
From 343597789eba1e6482e130b0c1b0818b1432d311 Mon Sep 17 00:00:00 2001 From: Mitch Phillips <31459023+hctim@users.noreply.github.com> Date: Thu, 7 Nov 2019 07:41:08 -0800 Subject: [PATCH] [GWP-ASan] Respect compiler-rt's -fno-lto
https://bugs.llvm.org/show_bug.cgi?id=43722 GWP-ASan didn't include SANITIZER_COMMON_CFLAGS, and thus would produce LLVM bitcode files, when compiler-rt is generally built without LTO. --- compiler-rt/lib/gwp_asan/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/gwp_asan/CMakeLists.txt b/compiler-rt/lib/gwp_asan/CMakeLists.txt index 84839e63f8e..afdd624017a 100644 --- a/compiler-rt/lib/gwp_asan/CMakeLists.txt +++ b/compiler-rt/lib/gwp_asan/CMakeLists.txt @@ -23,7 +23,8 @@ set(GWP_ASAN_HEADERS # Ensure that GWP-ASan meets the delegated requirements of some supporting # allocators. Some supporting allocators (e.g. scudo standalone) cannot use any # parts of the C++ standard library. -set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions -nostdinc++ -pthread) +set(GWP_ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS} -fno-rtti -fno-exceptions + -nostdinc++ -pthread) append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS) append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer GWP_ASAN_CFLAGS) -- 2.23.0 ++++++ libcxx-tests-linux-distribution.patch ++++++ From: Aaron Puchert <aaronpuchert@alice-dsl.net> Date: Wed, 4 Dec 2019 00:41:27 +0100 Subject: [PATCH] Remove call to platform.linux_distribution Summary: Since Python 3.5, platform.linux_distribution is deprecated [1], and in Python 3.8 it has been removed entirely. To avoid adding an additional dependency, we remove the part of code that it depends on, because we don't need XFAIL on (open)SUSE. --- libcxx/utils/libcxx/test/target_info.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py index 6da30e672e1..b52a998e008 100644 --- a/libcxx/utils/libcxx/test/target_info.py +++ b/libcxx/utils/libcxx/test/target_info.py @@ -191,29 +191,8 @@ class LinuxLocalTI(DefaultTargetInfo): def platform(self): return 'linux' - def platform_name(self): - name, _, _ = platform.linux_distribution() - # Some distros have spaces, e.g. 'SUSE Linux Enterprise Server' - # lit features can't have spaces - name = name.lower().strip().replace(' ', '-') - return name # Permitted to be None - - def platform_ver(self): - _, ver, _ = platform.linux_distribution() - ver = ver.lower().strip().replace(' ', '-') - return ver # Permitted to be None. - def add_locale_features(self, features): add_common_locales(features, self.full_config.lit_config) - # Some linux distributions have different locale data than others. - # Insert the distributions name and name-version into the available - # features to allow tests to XFAIL on them. - name = self.platform_name() - ver = self.platform_ver() - if name: - features.add(name) - if name and ver: - features.add('%s-%s' % (name, ver)) def add_cxx_compile_flags(self, flags): flags += ['-D__STDC_FORMAT_MACROS', -- 2.24.0 ++++++ link-clang-shared.patch ++++++ diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt index ceef4b08637..606149ad74f 100644 --- a/clang/tools/c-index-test/CMakeLists.txt +++ b/clang/tools/c-index-test/CMakeLists.txt @@ -18,6 +18,9 @@ if (LLVM_BUILD_STATIC) target_link_libraries(c-index-test PRIVATE libclang_static + ) + clang_target_link_libraries(c-index-test + PRIVATE clangCodeGen clangIndex ) @@ -25,6 +28,9 @@ else() target_link_libraries(c-index-test PRIVATE libclang + ) + clang_target_link_libraries(c-index-test + PRIVATE clangAST clangBasic clangCodeGen diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 613ead1a36b..f86be77b8e7 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -33,7 +33,7 @@ set(SOURCES ../../include/clang-c/Index.h ) -set(LIBS +set(CLANG_LIB_DEPS clangAST clangBasic clangDriver @@ -46,7 +46,7 @@ set(LIBS ) if (CLANG_ENABLE_ARCMT) - list(APPEND LIBS clangARCMigrate) + list(APPEND CLANG_LIB_DEPS clangARCMigrate) endif () if (TARGET clangTidyPlugin) @@ -108,6 +108,11 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCH Support ) +clang_target_link_libraries(libclang + PRIVATE + ${CLANG_LIB_DEPS} + ) + if(ENABLE_SHARED) if(WIN32) set_target_properties(libclang ++++++ link-clang-tools-extra-shared.patch ++++++ ++++ 1257 lines (skipped) ++++++ link-lldb-shared.patch ++++++ diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt index 476e92878e0..3cd16eb22e4 100644 --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -66,7 +66,6 @@ add_lldb_library(lldbCore ValueObjectVariable.cpp LINK_LIBS - clangAST lldbBreakpoint lldbDataFormatters lldbExpression @@ -88,6 +87,10 @@ add_lldb_library(lldbCore Demangle ) +clang_target_link_libraries(lldbCore INTERFACE + clangAST + ) + # Needed to properly resolve references in a debug build. # TODO: Remove once we have better layering set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 4) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt index 99d50c4007f..f848264e273 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt +++ b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt @@ -26,17 +26,6 @@ add_lldb_library(lldbPluginExpressionParserClang PLUGIN ${tablegen_deps} LINK_LIBS - clangAST - clangCodeGen - clangDriver - clangEdit - clangFrontend - clangLex - clangParse - clangRewrite - clangRewriteFrontend - clangSema - clangSerialization lldbCore lldbExpression lldbHost @@ -53,3 +42,17 @@ add_lldb_library(lldbPluginExpressionParserClang PLUGIN MCJIT Support ) + +clang_target_link_libraries(lldbPluginExpressionParserClang INTERFACE + clangAST + clangCodeGen + clangDriver + clangEdit + clangFrontend + clangLex + clangParse + clangRewrite + clangRewriteFrontend + clangSema + clangSerialization + ) diff --git a/lldb/source/Plugins/Language/ObjC/CMakeLists.txt b/lldb/source/Plugins/Language/ObjC/CMakeLists.txt index afb68d4de83..4c78f73c1b3 100644 --- a/lldb/source/Plugins/Language/ObjC/CMakeLists.txt +++ b/lldb/source/Plugins/Language/ObjC/CMakeLists.txt @@ -22,7 +22,6 @@ add_lldb_library(lldbPluginObjCLanguage PLUGIN NSString.cpp LINK_LIBS - clangAST lldbCore lldbDataFormatters lldbExpression @@ -35,3 +34,7 @@ add_lldb_library(lldbPluginObjCLanguage PLUGIN EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS} ) + +clang_target_link_libraries(lldbPluginObjCLanguage INTERFACE + clangAST +) diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt index 29d9ba1f823..6f49d7a16c7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt @@ -9,7 +9,6 @@ add_lldb_library(lldbPluginAppleObjCRuntime PLUGIN AppleObjCTypeEncodingParser.cpp LINK_LIBS - clangAST lldbBreakpoint lldbCore lldbExpression @@ -23,3 +22,7 @@ add_lldb_library(lldbPluginAppleObjCRuntime PLUGIN LINK_COMPONENTS Support ) + +clang_target_link_libraries(lldbPluginAppleObjCRuntime INTERFACE + clangAST + ) diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt index 1a6c4994613..429cd5e0324 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt @@ -13,7 +13,6 @@ add_lldb_library(lldbPluginRenderScriptRuntime PLUGIN ${tablegen_deps} LINK_LIBS - clangBasic lldbBreakpoint lldbCore lldbDataFormatters @@ -28,3 +27,7 @@ add_lldb_library(lldbPluginRenderScriptRuntime PLUGIN Support Target ) + +clang_target_link_libraries(lldbPluginRenderScriptRuntime INTERFACE + clangBasic + ) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt index 1107e531e46..312a87fb01d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt +++ b/lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt @@ -43,8 +43,6 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN UniqueDWARFASTType.cpp LINK_LIBS - clangAST - clangBasic lldbCore lldbExpression lldbHost @@ -63,3 +61,8 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN DebugInfoDWARF Support ) + +clang_target_link_libraries(lldbPluginSymbolFileDWARF INTERFACE + clangAST + clangBasic + ) diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt index 52b431db517..b0719758eae 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt @@ -11,8 +11,6 @@ add_lldb_library(lldbPluginSymbolFileNativePDB PLUGIN UdtRecordCompleter.cpp LINK_LIBS - clangAST - clangLex lldbCore lldbSymbol lldbUtility @@ -21,3 +19,8 @@ add_lldb_library(lldbPluginSymbolFileNativePDB PLUGIN DebugInfoPDB Support ) + +clang_target_link_libraries(lldbPluginSymbolFileNativePDB INTERFACE + clangAST + clangLex + ) diff --git a/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt index 64168d056ce..93502f9a626 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt +++ b/lldb/source/Plugins/SymbolFile/PDB/CMakeLists.txt @@ -4,8 +4,6 @@ add_lldb_library(lldbPluginSymbolFilePDB PLUGIN SymbolFilePDB.cpp LINK_LIBS - clangAST - clangLex lldbCore lldbSymbol lldbUtility @@ -14,3 +12,8 @@ add_lldb_library(lldbPluginSymbolFilePDB PLUGIN DebugInfoPDB Support ) + +clang_target_link_libraries(lldbPluginSymbolFilePDB INTERFACE + clangAST + clangLex + ) diff --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt index 42ae414b3c8..f19d6191289 100644 --- a/lldb/source/Symbol/CMakeLists.txt +++ b/lldb/source/Symbol/CMakeLists.txt @@ -46,9 +46,6 @@ add_lldb_library(lldbSymbol ${PLATFORM_SOURCES} LINK_LIBS - clangAST - clangBasic - clangFrontend lldbCore lldbExpression lldbHost @@ -63,3 +60,9 @@ add_lldb_library(lldbSymbol LINK_COMPONENTS Support ) + +clang_target_link_libraries(lldbSymbol INTERFACE + clangAST + clangBasic + clangFrontend + ) diff --git a/lldb/tools/lldb-instr/CMakeLists.txt b/lldb/tools/lldb-instr/CMakeLists.txt index e3dbeba4006..76d9b5fe382 100644 --- a/lldb/tools/lldb-instr/CMakeLists.txt +++ b/lldb/tools/lldb-instr/CMakeLists.txt @@ -1,7 +1,11 @@ add_lldb_tool(lldb-instr Instrument.cpp - LINK_LIBS + LINK_COMPONENTS + Support + ) + +clang_target_link_libraries(lldb-instr PRIVATE clangAST clangBasic clangCodeGen @@ -10,7 +14,4 @@ add_lldb_tool(lldb-instr clangRewrite clangSerialization clangTooling - - LINK_COMPONENTS - Support ) ++++++ lldb-cmake.patch ++++++ Index: lldb-8.0.0rc3.src/source/lldb.cpp =================================================================== --- lldb-8.0.0rc3.src.orig/source/lldb.cpp +++ lldb-8.0.0rc3.src/source/lldb.cpp @@ -23,11 +23,7 @@ using namespace lldb_private; #endif static const char *GetLLDBRevision() { -#ifdef LLDB_REVISION return LLDB_REVISION; -#else - return NULL; -#endif } static const char *GetLLDBRepository() { Index: lldb-8.0.0rc3.src/source/Core/IOHandler.cpp =================================================================== --- lldb-8.0.0rc3.src.orig/source/Core/IOHandler.cpp +++ lldb-8.0.0rc3.src/source/Core/IOHandler.cpp @@ -10,8 +10,8 @@ #include "lldb/Core/IOHandler.h" #ifndef LLDB_DISABLE_CURSES -#include <curses.h> -#include <panel.h> +#include <ncurses/curses.h> +#include <ncurses/panel.h> #endif #if defined(__APPLE__) Index: lldb-8.0.0rc3.src/source/Host/CMakeLists.txt =================================================================== --- lldb-8.0.0rc3.src.orig/source/Host/CMakeLists.txt +++ lldb-8.0.0rc3.src/source/Host/CMakeLists.txt @@ -143,6 +143,8 @@ endif() set(EXTRA_LIBS) if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") list(APPEND EXTRA_LIBS kvm) +elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") + list(APPEND EXTRA_LIBS dl pthread) endif () if (APPLE) list(APPEND EXTRA_LIBS xml2) ++++++ llvm-better-detect-64bit-atomics-support.patch ++++++ Better detect 64bit atomics support. It appears that on i586 std::atomic<uint64_t>::load is compiled into instruction, but std::atomic<double>::load uses __atomic_load_8. This must be detected so the build system links it to libatomic. Index: llvm-7.0.0.src/cmake/modules/CheckAtomic.cmake =================================================================== --- llvm-7.0.0.src.orig/cmake/modules/CheckAtomic.cmake +++ llvm-7.0.0.src/cmake/modules/CheckAtomic.cmake @@ -26,8 +26,10 @@ function(check_working_cxx_atomics64 var #include <atomic> #include <cstdint> std::atomic<uint64_t> x (0); +std::atomic<double> y (0); int main() { uint64_t i = x.load(std::memory_order_relaxed); + double j = y.load(std::memory_order_relaxed); return 0; } " ${varname}) ++++++ llvm-do-not-install-static-libraries.patch ++++++ This has similar effect as simply deleting the static libraries which we don't want after installation. By not copying them in the first place we reduce the disk usage during installation. Index: llvm-9.0.1.src/clang-9.0.1.src/cmake/modules/AddClang.cmake =================================================================== --- llvm-9.0.1.src.orig/clang-9.0.1.src/cmake/modules/AddClang.cmake +++ llvm-9.0.1.src/clang-9.0.1.src/cmake/modules/AddClang.cmake @@ -106,12 +106,15 @@ macro(add_clang_library name) set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True) endif() - install(TARGETS ${name} - COMPONENT ${name} - ${export_to_clangtargets} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} - RUNTIME DESTINATION bin) + if (ARG_SHARED OR ARG_MODULE) + install(TARGETS ${name} + COMPONENT ${name} + ${export_to_clangtargets} + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} + RUNTIME DESTINATION bin) + set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name}) + endif() if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-${name} @@ -121,7 +124,6 @@ macro(add_clang_library name) set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name}) endif() - set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name}) else() # Add empty "phony" target add_custom_target(${name}) Index: llvm-9.0.1.src/cmake/modules/AddLLVM.cmake =================================================================== --- llvm-9.0.1.src.orig/cmake/modules/AddLLVM.cmake +++ llvm-9.0.1.src/cmake/modules/AddLLVM.cmake @@ -695,11 +695,13 @@ macro(add_llvm_library name) set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True) endif() - install(TARGETS ${name} - ${export_to_llvmexports} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} - RUNTIME DESTINATION bin COMPONENT ${name}) + if(ARG_SHARED OR ARG_MODULE OR NOT LLVM_BUILD_LLVM_DYLIB) + install(TARGETS ${name} + ${export_to_llvmexports} + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} + RUNTIME DESTINATION bin COMPONENT ${name}) + endif() if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-${name} Index: llvm-9.0.1.src/lld-9.0.1.src/cmake/modules/AddLLD.cmake =================================================================== --- llvm-9.0.1.src.orig/lld-9.0.1.src/cmake/modules/AddLLD.cmake +++ llvm-9.0.1.src/lld-9.0.1.src/cmake/modules/AddLLD.cmake @@ -17,13 +17,6 @@ macro(add_lld_library name) set_property(GLOBAL PROPERTY LLD_HAS_EXPORTS True) endif() - install(TARGETS ${name} - COMPONENT ${name} - ${export_to_lldtargets} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} - RUNTIME DESTINATION bin) - if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES) add_llvm_install_targets(install-${name} DEPENDS ${name} Index: llvm-9.0.1.src/polly-9.0.1.src/cmake/polly_macros.cmake =================================================================== --- llvm-9.0.1.src.orig/polly-9.0.1.src/cmake/polly_macros.cmake +++ llvm-9.0.1.src/polly-9.0.1.src/cmake/polly_macros.cmake @@ -42,12 +42,14 @@ macro(add_polly_library name) llvm_config(${name} ${LLVM_LINK_COMPONENTS}) endif( LLVM_LINK_COMPONENTS ) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly") - install(TARGETS ${name} - EXPORT LLVMExports - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + if (MODULE OR SHARED_LIBRARY OR NOT LLVM_BUILD_LLVM_DYLIB) + install(TARGETS ${name} + EXPORT LLVMExports + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) + endif() endif() - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) endmacro(add_polly_library) macro(add_polly_loadable_module name) Index: llvm-9.0.1.src/polly-9.0.1.src/lib/CMakeLists.txt =================================================================== --- llvm-9.0.1.src.orig/polly-9.0.1.src/lib/CMakeLists.txt +++ llvm-9.0.1.src/polly-9.0.1.src/lib/CMakeLists.txt @@ -74,7 +74,7 @@ set_target_properties(PollyCore PROPERTI # LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as # well. add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>) -target_link_libraries(Polly PUBLIC +target_link_libraries(Polly PRIVATE ${ISL_TARGET} ) @@ -143,7 +143,7 @@ else () # hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON # instead which will automatically resolve the additional dependencies by # Polly. - target_link_libraries(LLVMPolly PUBLIC ${ISL_TARGET}) + target_link_libraries(LLVMPolly PRIVATE ${ISL_TARGET}) if (GPU_CODEGEN) target_link_libraries(LLVMPolly PUBLIC PollyPPCG) endif () ++++++ llvm-fix-find-gcc5-install.patch ++++++ Index: cfe-7.0.0rc1.src/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- cfe-7.0.0rc1.src.orig/lib/Driver/ToolChains/Gnu.cpp +++ cfe-7.0.0rc1.src/lib/Driver/ToolChains/Gnu.cpp @@ -1596,7 +1596,8 @@ Generic_GCC::GCCVersion Generic_GCC::GCC MinorStr = MinorStr.slice(0, EndNumber); } } - if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0) + if (!MinorStr.str().empty() && + (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)) return BadVersion; GoodVersion.MinorStr = MinorStr.str(); ++++++ llvm-normally-versioned-libllvm.patch ++++++ Before llvm4, both major and minor version updates of llvm were regularly breaking API. Because of that, the libLLVM library was named in following format: libLLVM-${major}-${minor}.so (https://bugs.llvm.org/show_bug.cgi?id=25059) (https://reviews.llvm.org/D13841) The package containing this library was called libLLVM${major}_${minor} which follows our guidelines. Since llvm4, llvm decided to follow semantic versioning and only break API if the major version was increased. In addition they do not intend to ever have minor version other than 0. (http://blog.llvm.org/2016/12/llvms-new-versioning-scheme.html) The package was renamed to libLLVM${major}, which no longer follows the naming guidelines, but since the package contained multiple libraries, it was not detected. Since bnc#1049703 the libLLVM${major} package contains only the libLLVM-${major}-${minor}.so library and no others. This triggers the shlib-policy-name-error check in our packaging system. Because the reasons for using the libLLVM-${major}-${minor}.so format are no longer valid, lets revert back to libLLVM.so.${major}.${minor}.${version} format. That way the package name matches our guidelines. Index: llvm-8.0.0rc3.src/tools/llvm-config/llvm-config.cpp =================================================================== --- llvm-8.0.0rc3.src.orig/tools/llvm-config/llvm-config.cpp +++ llvm-8.0.0rc3.src/tools/llvm-config/llvm-config.cpp @@ -380,7 +380,6 @@ int main(int argc, char **argv) { } else { // default to the unix values: SharedExt = "so"; - SharedVersionedExt = LLVM_DYLIB_VERSION ".so"; StaticExt = "a"; StaticDir = SharedDir = ActiveLibDir; StaticPrefix = SharedPrefix = "lib"; @@ -393,7 +392,7 @@ int main(int argc, char **argv) { bool DyLibExists = false; const std::string DyLibName = - (SharedPrefix + "LLVM-" + SharedVersionedExt).str(); + (SharedPrefix + "LLVM." + SharedExt).str(); // If LLVM_LINK_DYLIB is ON, the single shared library will be returned // for "--libs", etc, if they exist. This behaviour can be overridden with Index: llvm-8.0.0rc3.src/tools/llvm-shlib/CMakeLists.txt =================================================================== --- llvm-8.0.0rc3.src.orig/tools/llvm-shlib/CMakeLists.txt +++ llvm-8.0.0rc3.src/tools/llvm-shlib/CMakeLists.txt @@ -42,7 +42,7 @@ if(LLVM_BUILD_LLVM_DYLIB) if (LLVM_LINK_LLVM_DYLIB) set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN) endif() - add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES}) + add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB ${INSTALL_WITH_TOOLCHAIN} ${SOURCES}) list(REMOVE_DUPLICATES LIB_NAMES) if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) ++++++ llvm-remove-clang-only-flags.patch ++++++ Index: llvm-8.0.0rc3.src/cmake/modules/HandleLLVMOptions.cmake =================================================================== --- llvm-8.0.0rc3.src.orig/cmake/modules/HandleLLVMOptions.cmake +++ llvm-8.0.0rc3.src/cmake/modules/HandleLLVMOptions.cmake @@ -413,8 +413,6 @@ if( MSVC ) elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS) - add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME) - add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW) check_cxx_compiler_flag("-std=${LLVM_CXX_STD}" CXX_SUPPORTS_CXX_STD) if (CXX_SUPPORTS_CXX_STD) if (CYGWIN OR MINGW) @@ -586,7 +584,6 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPI endif() add_flag_if_supported("-Wimplicit-fallthrough" IMPLICIT_FALLTHROUGH_FLAG) - add_flag_if_supported("-Wcovered-switch-default" COVERED_SWITCH_DEFAULT_FLAG) append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS) append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS) ++++++ llvm-riscv64-fix-cffi.diff ++++++ commit c6b09bff5671600f8e764d3847023d0996f328d9 Author: Luís Marques <luismarques@lowrisc.org> Date: Thu Nov 14 18:27:42 2019 +0000 [RISCV] Fix wrong CFI directives Summary: Removes CFI CFA directives that could incorrectly propagate beyond the basic block they were inteded for. Specifically it removes the epilogue CFI directives. See the branch_and_tail_call test for an example of the issue. Should fix the stack unwinding issues caused by the incorrect directives. Reviewers: asb, lenary, shiva0217 Reviewed By: lenary Tags: #llvm Differential Revision: https://reviews.llvm.org/D69723 Index: llvm-9.0.1.src/lib/Target/RISCV/RISCVFrameLowering.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/RISCVFrameLowering.cpp +++ llvm-9.0.1.src/lib/Target/RISCV/RISCVFrameLowering.cpp @@ -205,7 +205,6 @@ void RISCVFrameLowering::emitEpilogue(Ma MachineFrameInfo &MFI = MF.getFrameInfo(); auto *RVFI = MF.getInfo<RISCVMachineFunctionInfo>(); DebugLoc DL = MBBI->getDebugLoc(); - const RISCVInstrInfo *TII = STI.getInstrInfo(); unsigned FPReg = getFPReg(STI); unsigned SPReg = getSPReg(STI); @@ -226,47 +225,8 @@ void RISCVFrameLowering::emitEpilogue(Ma MachineInstr::FrameDestroy); } - if (hasFP(MF)) { - // To find the instruction restoring FP from stack. - for (auto &I = LastFrameDestroy; I != MBBI; ++I) { - if (I->mayLoad() && I->getOperand(0).isReg()) { - unsigned DestReg = I->getOperand(0).getReg(); - if (DestReg == FPReg) { - // If there is frame pointer, after restoring $fp registers, we - // need adjust CFA to ($sp - FPOffset). - // Emit ".cfi_def_cfa $sp, -FPOffset" - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( - nullptr, RI->getDwarfRegNum(SPReg, true), -FPOffset)); - BuildMI(MBB, std::next(I), DL, - TII->get(TargetOpcode::CFI_INSTRUCTION)) - .addCFIIndex(CFIIndex); - break; - } - } - } - } - - // Add CFI directives for callee-saved registers. - const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo(); - // Iterate over list of callee-saved registers and emit .cfi_restore - // directives. - for (const auto &Entry : CSI) { - unsigned Reg = Entry.getReg(); - unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createRestore( - nullptr, RI->getDwarfRegNum(Reg, true))); - BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) - .addCFIIndex(CFIIndex); - } - // Deallocate stack adjustReg(MBB, MBBI, DL, SPReg, SPReg, StackSize, MachineInstr::FrameDestroy); - - // After restoring $sp, we need to adjust CFA to $(sp + 0) - // Emit ".cfi_def_cfa_offset 0" - unsigned CFIIndex = - MF.addFrameInst(MCCFIInstruction::createDefCfaOffset(nullptr, 0)); - BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) - .addCFIIndex(CFIIndex); } int RISCVFrameLowering::getFrameIndexReference(const MachineFunction &MF, Index: llvm-9.0.1.src/test/CodeGen/RISCV/exception-pointer-register.ll =================================================================== --- llvm-9.0.1.src.orig/test/CodeGen/RISCV/exception-pointer-register.ll +++ llvm-9.0.1.src/test/CodeGen/RISCV/exception-pointer-register.ll @@ -40,11 +40,7 @@ define void @caller(i1* %p) personality ; RV32I-NEXT: lw s1, 4(sp) ; RV32I-NEXT: lw s0, 8(sp) ; RV32I-NEXT: lw ra, 12(sp) -; RV32I-NEXT: .cfi_restore ra -; RV32I-NEXT: .cfi_restore s0 -; RV32I-NEXT: .cfi_restore s1 ; RV32I-NEXT: addi sp, sp, 16 -; RV32I-NEXT: .cfi_def_cfa_offset 0 ; RV32I-NEXT: ret ; RV32I-NEXT: .LBB0_4: # %lpad ; RV32I-NEXT: .Ltmp4: @@ -81,11 +77,7 @@ define void @caller(i1* %p) personality ; RV64I-NEXT: ld s1, 8(sp) ; RV64I-NEXT: ld s0, 16(sp) ; RV64I-NEXT: ld ra, 24(sp) -; RV64I-NEXT: .cfi_restore ra -; RV64I-NEXT: .cfi_restore s0 -; RV64I-NEXT: .cfi_restore s1 ; RV64I-NEXT: addi sp, sp, 32 -; RV64I-NEXT: .cfi_def_cfa_offset 0 ; RV64I-NEXT: ret ; RV64I-NEXT: .LBB0_4: # %lpad ; RV64I-NEXT: .Ltmp4: @@ -119,12 +111,10 @@ end2: define internal void @callee(i1* %p) { ; RV32I-LABEL: callee: ; RV32I: # %bb.0: -; RV32I-NEXT: .cfi_def_cfa_offset 0 ; RV32I-NEXT: ret ; ; RV64I-LABEL: callee: ; RV64I: # %bb.0: -; RV64I-NEXT: .cfi_def_cfa_offset 0 ; RV64I-NEXT: ret ret void } Index: llvm-9.0.1.src/test/CodeGen/RISCV/frame-info.ll =================================================================== --- llvm-9.0.1.src.orig/test/CodeGen/RISCV/frame-info.ll +++ llvm-9.0.1.src/test/CodeGen/RISCV/frame-info.ll @@ -20,12 +20,8 @@ define void @foo(i32 signext %size) { ; RV32-NEXT: call bar ; RV32-NEXT: addi sp, s0, -16 ; RV32-NEXT: lw s0, 8(sp) -; RV32-NEXT: .cfi_def_cfa sp, 16 ; RV32-NEXT: lw ra, 12(sp) -; RV32-NEXT: .cfi_restore ra -; RV32-NEXT: .cfi_restore s0 ; RV32-NEXT: addi sp, sp, 16 -; RV32-NEXT: .cfi_def_cfa_offset 0 ; RV32-NEXT: ret ; ; RV64-LABEL: foo: @@ -50,12 +46,8 @@ define void @foo(i32 signext %size) { ; RV64-NEXT: call bar ; RV64-NEXT: addi sp, s0, -16 ; RV64-NEXT: ld s0, 0(sp) -; RV64-NEXT: .cfi_def_cfa sp, 16 ; RV64-NEXT: ld ra, 8(sp) -; RV64-NEXT: .cfi_restore ra -; RV64-NEXT: .cfi_restore s0 ; RV64-NEXT: addi sp, sp, 16 -; RV64-NEXT: .cfi_def_cfa_offset 0 ; RV64-NEXT: ret entry: %0 = alloca i8, i32 %size, align 16 Index: llvm-9.0.1.src/test/CodeGen/RISCV/split-offsets.ll =================================================================== --- llvm-9.0.1.src.orig/test/CodeGen/RISCV/split-offsets.ll +++ llvm-9.0.1.src/test/CodeGen/RISCV/split-offsets.ll @@ -22,7 +22,6 @@ define void @test1([65536 x i32]** %sp, ; RV32I-NEXT: add a0, a1, a2 ; RV32I-NEXT: sw a4, 4(a0) ; RV32I-NEXT: sw a3, 0(a0) -; RV32I-NEXT: .cfi_def_cfa_offset 0 ; RV32I-NEXT: ret ; ; RV64I-LABEL: test1: @@ -38,7 +37,6 @@ define void @test1([65536 x i32]** %sp, ; RV64I-NEXT: add a0, a1, a2 ; RV64I-NEXT: sw a4, 4(a0) ; RV64I-NEXT: sw a3, 0(a0) -; RV64I-NEXT: .cfi_def_cfa_offset 0 ; RV64I-NEXT: ret entry: %s = load [65536 x i32]*, [65536 x i32]** %sp @@ -74,7 +72,6 @@ define void @test2([65536 x i32]** %sp, ; RV32I-NEXT: mv a3, a4 ; RV32I-NEXT: blt a3, a2, .LBB1_1 ; RV32I-NEXT: .LBB1_2: # %while_end -; RV32I-NEXT: .cfi_def_cfa_offset 0 ; RV32I-NEXT: ret ; ; RV64I-LABEL: test2: @@ -99,7 +96,6 @@ define void @test2([65536 x i32]** %sp, ; RV64I-NEXT: sext.w a4, a3 ; RV64I-NEXT: blt a4, a2, .LBB1_1 ; RV64I-NEXT: .LBB1_2: # %while_end -; RV64I-NEXT: .cfi_def_cfa_offset 0 ; RV64I-NEXT: ret entry: %s = load [65536 x i32]*, [65536 x i32]** %sp ++++++ llvm9-rpmlintrc ++++++ # This line is mandatory to access the configuration functions from Config import * addFilter("devel-file-in-non-devel-package .*/clang/.*/include/.*") addFilter("devel-file-in-non-devel-package .*/clang/.*/lib/.*") addFilter("devel-file-in-non-devel-package .*/usr/include/.*") addFilter("devel-file-in-non-devel-package .*/lib.*/*.a") addFilter("devel-file-in-non-devel-package .*/lib.*/*.so") ++++++ llvm_build_tablegen_component_as_shared_library.patch ++++++ The LLVMTableGen component is a special case that is excluded from libLLVM and normally is only built as static library and linked into llvm-tblgen. We need to have it as a shared library to be available for other projects such as ldc. This patch makes it even more special and forces it to be build and installed as separate shared library. Index: llvm-8.0.0rc3.src/cmake/modules/AddLLVM.cmake =================================================================== --- llvm-8.0.0rc3.src.orig/cmake/modules/AddLLVM.cmake +++ llvm-8.0.0rc3.src/cmake/modules/AddLLVM.cmake @@ -541,7 +541,7 @@ function(llvm_add_library name) if(ARG_MODULE AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS AND ARG_PLUGIN_TOOL AND (WIN32 OR CYGWIN)) # On DLL platforms symbols are imported from the tool by linking against it. set(llvm_libs ${ARG_PLUGIN_TOOL}) - elseif (DEFINED LLVM_LINK_COMPONENTS OR DEFINED ARG_LINK_COMPONENTS) + elseif (DEFINED LLVM_LINK_COMPONENTS OR DEFINED ARG_LINK_COMPONENTS OR (${name} STREQUAL "LLVMTableGen" AND LLVM_BUILD_LLVM_DYLIB)) if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB) set(llvm_libs LLVM) else() Index: llvm-8.0.0rc3.src/cmake/modules/TableGen.cmake =================================================================== --- llvm-8.0.0rc3.src.orig/cmake/modules/TableGen.cmake +++ llvm-8.0.0rc3.src/cmake/modules/TableGen.cmake @@ -115,7 +115,8 @@ macro(add_tablegen target project) set(LLVM_ENABLE_OBJLIB ON) endif() - add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) + add_llvm_executable(${target} ${ARGN}) + target_link_libraries(${target} PRIVATE LLVMTableGen) set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) set(${project}_TABLEGEN "${target}" CACHE Index: llvm-8.0.0rc3.src/lib/TableGen/CMakeLists.txt =================================================================== --- llvm-8.0.0rc3.src.orig/lib/TableGen/CMakeLists.txt +++ llvm-8.0.0rc3.src/lib/TableGen/CMakeLists.txt @@ -1,3 +1,7 @@ +if (LLVM_BUILD_LLVM_DYLIB) + set(MAYBE_SHARED SHARED) +endif() + add_llvm_library(LLVMTableGen Error.cpp JSONBackend.cpp @@ -9,6 +13,8 @@ add_llvm_library(LLVMTableGen TGLexer.cpp TGParser.cpp + ${MAYBE_SHARED} + ADDITIONAL_HEADER_DIRS ${LLVM_MAIN_INCLUDE_DIR}/llvm/TableGen ) ++++++ lto-disable-cache.patch ++++++ diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 5e57a3b8234..23f9ed5fb56 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -885,20 +885,6 @@ if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") if(NOT LINKER_IS_LLD_LINK) append("-flto=thin" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) endif() - # If the linker supports it, enable the lto cache. This improves initial build - # time a little since we re-link a lot of the same objects, and significantly - # improves incremental build time. - # FIXME: We should move all this logic into the clang driver. - if(APPLE) - append("-Wl,-cache_path_lto,${PROJECT_BINARY_DIR}/lto.cache" - CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) - elseif(UNIX AND LLVM_USE_LINKER STREQUAL "lld") - append("-Wl,--thinlto-cache-dir=${PROJECT_BINARY_DIR}/lto.cache" - CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) - elseif(LLVM_USE_LINKER STREQUAL "gold") - append("-Wl,--plugin-opt,cache-dir=${PROJECT_BINARY_DIR}/lto.cache" - CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) - endif() elseif(uppercase_LLVM_ENABLE_LTO STREQUAL "FULL") append("-flto=full" CMAKE_CXX_FLAGS CMAKE_C_FLAGS) if(NOT LINKER_IS_LLD_LINK) ++++++ openmp-export-fini.patch ++++++ diff --git a/openmp/runtime/src/exports_so.txt b/openmp/runtime/src/exports_so.txt index f7de5fd6474..6ba2b5c725e 100644 --- a/openmp/runtime/src/exports_so.txt +++ b/openmp/runtime/src/exports_so.txt @@ -54,6 +54,11 @@ VERSION { ___kmp_free; __kmp_thread_pool; + # + # Internal function used as termination function. + # + __kmp_internal_end_fini; + __kmp_reset_stats; #if USE_ITT_BUILD ++++++ opt-viewer-Find-style-css-in-usr-share.patch ++++++ Index: llvm-7.0.0.src/tools/opt-viewer/opt-viewer.py =================================================================== --- llvm-7.0.0.src.orig/tools/opt-viewer/opt-viewer.py +++ llvm-7.0.0.src/tools/opt-viewer/opt-viewer.py @@ -252,8 +252,7 @@ def generate_report(all_remarks, sorted_remarks = sorted(optrecord.itervalues(all_remarks), key=lambda r: (r.File, r.Line, r.Column, r.PassWithDiffPrefix, r.yaml_tag, r.Function)) IndexRenderer(output_dir, should_display_hotness, max_hottest_remarks_on_index).render(sorted_remarks) - shutil.copy(os.path.join(os.path.dirname(os.path.realpath(__file__)), - "style.css"), output_dir) + shutil.copy("/usr/share/opt-viewer/style.css", output_dir) _render_file_bound = functools.partial(_render_file, source_dir, output_dir, context, no_highlight) if should_print_progress: ++++++ polly-pthread.patch ++++++ Since libPolly uses std::call_once it needs to be linked against libpthread. Due to our use of --as-needed we need to make sure it is linked after libPolly. Index: llvm-9.0.1.src/polly-9.0.1.src/lib/CMakeLists.txt =================================================================== --- llvm-9.0.1.src.orig/polly-9.0.1.src/lib/CMakeLists.txt +++ llvm-9.0.1.src/polly-9.0.1.src/lib/CMakeLists.txt @@ -79,6 +79,7 @@ set_target_properties(PollyCore PROPERTI add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>) target_link_libraries(Polly PRIVATE ${ISL_TARGET} + ${LLVM_PTHREAD_LIB} ) # Additional dependencies for Polly-ACC. ++++++ riscv-eh-frame-fixup.patch ++++++ commit 7cb3cd34e8d Author: Alex Bradbury <asb@lowrisc.org> Date: Tue Aug 20 12:32:31 2019 +0000 [RISCV] Implement getExprForFDESymbol to ensure RISCV_32_PCREL is used for the FDE location Follow binutils in using RISCV_32_PCREL for the FDE initial location. As explained in the relevant binutils commit <https://github.com/riscv/riscv-binutils-gdb/commit/a6cbf936e3dce68114d28cdf60d510a3f78a6d40>, the ADD/SUB pair of relocations is problematic in the presence of linker relaxation. This patch has the same end goal as D64715 but includes test changes and avoids adding a new global VariantKind to MCExpr.h (preferring RISCVMCExpr VKs like the rest of the RISC-V backend). Differential Revision: https://reviews.llvm.org/D66419 llvm-svn: 369375 commit 1c1f8f215d8 Author: Alex Bradbury <asb@lowrisc.org> Date: Mon Aug 19 13:23:02 2019 +0000 [RISCV] Don't force absolute FK_Data_X fixups to relocs The current behavior of shouldForceRelocation forces relocations for the majority of fixups when relaxation is enabled. This makes sense for fixups which incorporate symbols but is unnecessary for simple data fixups where the fixup target is already resolved to an absolute value. Differential Revision: https://reviews.llvm.org/D63404 Patch by Edward Jones. llvm-svn: 369257 commit 49a99788393 Author: Hsiangkai Wang <hsiangkai@gmail.com> Date: Fri Jul 19 06:10:36 2019 +0000 [DebugInfo] Some fields do not need relocations even relax is enabled. In debug frame information, some fields, e.g., Length in CIE/FDE and Offset in FDE are attributes to describe the structure of CIE/FDE. They are not related to the relaxed code. However, these attributes are symbol differences. So, in current design, these attributes will be filled as zero and LLVM generates relocations for them. We only need to generate relocations for symbols in executable sections. So, if the symbols are not located in executable sections, we still evaluate their values under relaxation. Differential Revision: https://reviews.llvm.org/D61584 llvm-svn: 366531 Index: llvm-9.0.1.src/lib/MC/MCExpr.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/MC/MCExpr.cpp +++ llvm-9.0.1.src/lib/MC/MCExpr.cpp @@ -577,6 +577,24 @@ static void AttemptToFoldSymbolOffsetDif A = B = nullptr; } +static bool canFold(const MCAssembler *Asm, const MCSymbolRefExpr *A, + const MCSymbolRefExpr *B, bool InSet) { + if (InSet) + return true; + + if (!Asm->getBackend().requiresDiffExpressionRelocations()) + return true; + + const MCSymbol &CheckSym = A ? A->getSymbol() : B->getSymbol(); + if (!CheckSym.isInSection()) + return true; + + if (!CheckSym.getSection().hasInstructions()) + return true; + + return false; +} + /// Evaluate the result of an add between (conceptually) two MCValues. /// /// This routine conceptually attempts to construct an MCValue: @@ -617,8 +635,7 @@ EvaluateSymbolicAdd(const MCAssembler *A // the backend requires this to be emitted as individual relocations, unless // the InSet flag is set to get the current difference anyway (used for // example to calculate symbol sizes). - if (Asm && - (InSet || !Asm->getBackend().requiresDiffExpressionRelocations())) { + if (Asm && canFold(Asm, LHS_A, LHS_B, InSet)) { // First, fold out any differences which are fully resolved. By // reassociating terms in // Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst). Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -33,6 +33,13 @@ bool RISCVAsmBackend::shouldForceRelocat switch ((unsigned)Fixup.getKind()) { default: break; + case FK_Data_1: + case FK_Data_2: + case FK_Data_4: + case FK_Data_8: + if (Target.isAbsolute()) + return false; + break; case RISCV::fixup_riscv_got_hi20: case RISCV::fixup_riscv_tls_got_hi20: case RISCV::fixup_riscv_tls_gd_hi20: Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "MCTargetDesc/RISCVFixupKinds.h" +#include "MCTargetDesc/RISCVMCExpr.h" #include "MCTargetDesc/RISCVMCTargetDesc.h" #include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCFixup.h" @@ -47,6 +48,7 @@ unsigned RISCVELFObjectWriter::getRelocT const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const { + const MCExpr *Expr = Fixup.getValue(); // Determine the type of the relocation unsigned Kind = Fixup.getKind(); if (IsPCRel) { @@ -87,6 +89,9 @@ unsigned RISCVELFObjectWriter::getRelocT default: llvm_unreachable("invalid fixup kind!"); case FK_Data_4: + if (Expr->getKind() == MCExpr::Target && + cast<RISCVMCExpr>(Expr)->getKind() == RISCVMCExpr::VK_RISCV_32_PCREL) + return ELF::R_RISCV_32_PCREL; return ELF::R_RISCV_32; case FK_Data_8: return ELF::R_RISCV_64; Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp @@ -11,7 +11,10 @@ //===----------------------------------------------------------------------===// #include "RISCVMCAsmInfo.h" +#include "MCTargetDesc/RISCVMCExpr.h" #include "llvm/ADT/Triple.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/MC/MCStreamer.h" using namespace llvm; void RISCVMCAsmInfo::anchor() {} @@ -25,3 +28,20 @@ RISCVMCAsmInfo::RISCVMCAsmInfo(const Tri Data16bitsDirective = "\t.half\t"; Data32bitsDirective = "\t.word\t"; } + +const MCExpr *RISCVMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, + unsigned Encoding, + MCStreamer &Streamer) const { + if (!(Encoding & dwarf::DW_EH_PE_pcrel)) + return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer); + + // The default symbol subtraction results in an ADD/SUB relocation pair. + // Processing this relocation pair is problematic when linker relaxation is + // enabled, so we follow binutils in using the R_RISCV_32_PCREL relocation + // for the FDE initial location. + MCContext &Ctx = Streamer.getContext(); + const MCExpr *ME = + MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, Ctx); + assert(Encoding & dwarf::DW_EH_PE_sdata4 && "Unexpected encoding"); + return RISCVMCExpr::create(ME, RISCVMCExpr::VK_RISCV_32_PCREL, Ctx); +} Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h @@ -23,6 +23,9 @@ class RISCVMCAsmInfo : public MCAsmInfoE public: explicit RISCVMCAsmInfo(const Triple &TargetTriple); + + const MCExpr *getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, + MCStreamer &Streamer) const override; }; } // namespace llvm Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp @@ -266,6 +266,7 @@ unsigned RISCVMCCodeEmitter::getImmOpVal switch (RVExpr->getKind()) { case RISCVMCExpr::VK_RISCV_None: case RISCVMCExpr::VK_RISCV_Invalid: + case RISCVMCExpr::VK_RISCV_32_PCREL: llvm_unreachable("Unhandled fixup kind!"); case RISCVMCExpr::VK_RISCV_TPREL_ADD: // tprel_add is only used to indicate that a relocation should be emitted Index: llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h =================================================================== --- llvm-9.0.1.src.orig/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h +++ llvm-9.0.1.src/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h @@ -36,6 +36,7 @@ public: VK_RISCV_TLS_GD_HI, VK_RISCV_CALL, VK_RISCV_CALL_PLT, + VK_RISCV_32_PCREL, VK_RISCV_Invalid }; Index: llvm-9.0.1.src/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll =================================================================== --- llvm-9.0.1.src.orig/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll +++ llvm-9.0.1.src/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll @@ -6,14 +6,14 @@ ; Check that we actually have relocations, otherwise this is kind of pointless. ; READOBJ-RELOCS: Section (8) .rela.debug_info { -; READOBJ-RELOCS-NEXT: 0x0 R_RISCV_ADD32 - 0x0 -; READOBJ-RELOCS-NEXT: 0x0 R_RISCV_SUB32 - 0x0 -; READOBJ-RELOCS: Section (11) .rela.debug_addr { -; READOBJ-RELOCS-NEXT: 0x0 R_RISCV_ADD32 - 0x0 -; READOBJ-RELOCS-NEXT: 0x0 R_RISCV_SUB32 - 0x0 +; READOBJ-RELOCS: 0x1B R_RISCV_ADD32 - 0x0 +; READOBJ-RELOCS-NEXT: 0x1B R_RISCV_SUB32 - 0x0 +; READOBJ-RELOCS: Section (15) .rela.debug_frame { +; READOBJ-RELOCS: 0x20 R_RISCV_ADD32 - 0x0 +; READOBJ-RELOCS-NEXT: 0x20 R_RISCV_SUB32 - 0x0 ; READOBJ-RELOCS: Section (17) .rela.debug_line { -; READOBJ-RELOCS-NEXT: 0x0 R_RISCV_ADD32 - 0xFFFFFFFC -; READOBJ-RELOCS-NEXT: 0x0 R_RISCV_SUB32 .Lline_table_start0 0x0 +; READOBJ-RELOCS: 0x5A R_RISCV_ADD16 - 0x0 +; READOBJ-RELOCS-NEXT: 0x5A R_RISCV_SUB16 - 0x0 ; Check that we can print the source, even with relocations. ; OBJDUMP-SOURCE: Disassembly of section .text: Index: llvm-9.0.1.src/test/MC/RISCV/fde-reloc.s =================================================================== --- llvm-9.0.1.src.orig/test/MC/RISCV/fde-reloc.s +++ llvm-9.0.1.src/test/MC/RISCV/fde-reloc.s @@ -8,20 +8,8 @@ func: ret .cfi_endproc -# TODO: Should produce R_RISCV_32_PCREL for the FDE pc relocation. Many of the -# ADD32/SUB32 relocations also can be safely resolved even with linker -# relaxation enabled. This test is written to capture current behaviour, in -# preparation for follow-on patches to fix it. - # RELAX-RELOC: Section (4) .rela.eh_frame { -# RELAX-RELOC-NEXT: 0x0 R_RISCV_ADD32 - 0xFFFFFFFC -# RELAX-RELOC-NEXT: 0x0 R_RISCV_SUB32 - 0x0 -# RELAX-RELOC-NEXT: 0x14 R_RISCV_ADD32 - 0x0 -# RELAX-RELOC-NEXT: 0x14 R_RISCV_SUB32 - 0x0 -# RELAX-RELOC-NEXT: 0x18 R_RISCV_ADD32 - 0x0 -# RELAX-RELOC-NEXT: 0x18 R_RISCV_SUB32 - 0x0 -# RELAX-RELOC-NEXT: 0x1C R_RISCV_ADD32 - 0x0 -# RELAX-RELOC-NEXT: 0x1C R_RISCV_SUB32 - 0x0 +# RELAX-RELOC-NEXT: 0x1C R_RISCV_32_PCREL - 0x0 # RELAX-RELOC-NEXT: 0x20 R_RISCV_ADD32 - 0x0 # RELAX-RELOC-NEXT: 0x20 R_RISCV_SUB32 - 0x0 # RELAX-RELOC-NEXT: } Index: llvm-9.0.1.src/test/MC/RISCV/linker-relaxation.s =================================================================== --- llvm-9.0.1.src.orig/test/MC/RISCV/linker-relaxation.s +++ llvm-9.0.1.src/test/MC/RISCV/linker-relaxation.s @@ -136,3 +136,24 @@ sb t1, %pcrel_lo(2b)(a2) # RELAX-RELOC: R_RISCV_RELAX - 0x0 # RELAX-FIXUP: fixup A - offset: 0, value: %pcrel_lo(.Ltmp1), kind: fixup_riscv_pcrel_lo12_s # RELAX-FIXUP: fixup B - offset: 0, value: 0, kind: fixup_riscv_relax + +# Check that a relocation is not emitted for a symbol difference which has +# been folded to a fixup with an absolute value. This can happen when a +# difference expression refers to two symbols, at least one of which is +# not defined at the point it is referenced. Then during *assembler* +# relaxation when both symbols have become defined the difference may be folded +# down to a fixup simply containing the absolute value. We want to ensure that +# we don't force a relocation to be emitted for this absolute value even +# when linker relaxation is enabled. The reason for this is that one instance +# where this pattern appears in in the .eh_frame section (the CIE 'length' +# field), and the .eh_frame section cannot be parsed by the linker unless the +# fixup has been resolved to a concrete value instead of a relocation. + .data +lo: + .word hi-lo + .quad hi-lo +# NORELAX-RELOC-NOT: R_RISCV_32 +# NORELAX-RELOC-NOT: R_RISCV_64 +# RELAX-RELOC-NOT: R_RISCV_32 +# RELAX-RELOC-NOT: R_RISCV_64 +hi: ++++++ riscv64-suse-linux.patch ++++++ commit 1fc2a47f0b6 Author: Sam Elliott <selliott@lowrisc.org> Date: Thu Aug 1 14:23:56 2019 +0000 Add support for openSUSE RISC-V triple Reviewers: asb Reviewed By: asb Subscribers: lenary, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lebedev.ri, kito-cheng, shiva0217, rogfer01, dexonsmith, rkruppe, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63497 Patch by Andreas Schwab (schwab) llvm-svn: 367565 Index: clang-9.0.1.src/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang-9.0.1.src.orig/lib/Driver/ToolChains/Gnu.cpp +++ clang-9.0.1.src/lib/Driver/ToolChains/Gnu.cpp @@ -2018,7 +2018,8 @@ void Generic_GCC::GCCInstallationDetecto static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", "riscv64-linux-gnu", - "riscv64-unknown-elf"}; + "riscv64-unknown-elf", + "riscv64-suse-linux"}; static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", ++++++ tests-use-python3.patch ++++++ Index: llvm-8.0.0rc3.src/test/BugPoint/compile-custom.ll.py =================================================================== --- llvm-8.0.0rc3.src.orig/test/BugPoint/compile-custom.ll.py +++ llvm-8.0.0rc3.src/test/BugPoint/compile-custom.ll.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 from __future__ import print_function Index: llvm-8.0.0rc3.src/test/Other/opt-bisect-helper.py =================================================================== --- llvm-8.0.0rc3.src.orig/test/Other/opt-bisect-helper.py +++ llvm-8.0.0rc3.src/test/Other/opt-bisect-helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 from __future__ import print_function Index: llvm-8.0.0rc3.src/test/TableGen/JSON-check.py =================================================================== --- llvm-8.0.0rc3.src.orig/test/TableGen/JSON-check.py +++ llvm-8.0.0rc3.src/test/TableGen/JSON-check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 import sys import subprocess Index: llvm-8.0.0rc3.src/test/tools/llvm-readobj/Inputs/relocs.py =================================================================== --- llvm-8.0.0rc3.src.orig/test/tools/llvm-readobj/Inputs/relocs.py +++ llvm-8.0.0rc3.src/test/tools/llvm-readobj/Inputs/relocs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 from __future__ import print_function