From cc39b69305360d1cbbd27b84199114a1c7652ac1 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Feb 25 2022 16:11:42 +0000 Subject: Separate clang-tools-extra patches --- diff --git a/0001-PATCH-clang-Reorganize-gtest-integration.patch b/0001-PATCH-clang-Reorganize-gtest-integration.patch deleted file mode 100644 index 6af242d..0000000 --- a/0001-PATCH-clang-Reorganize-gtest-integration.patch +++ /dev/null @@ -1,42 +0,0 @@ -From d23af8c946342a9b68f61c6f5b839a7650ac3920 Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Thu, 25 Feb 2021 14:04:52 +0100 -Subject: [PATCH][clang] Reorganize gtest integration - ---- - clang/CMakeLists.txt | 12 +++++------- - 1 file changed, 5 insertions(+), 7 deletions(-) - -diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt -index 49150fa7c561..2e12f4b06f98 100644 ---- a/clang/CMakeLists.txt -+++ b/clang/CMakeLists.txt -@@ -157,12 +157,6 @@ if(CLANG_BUILT_STANDALONE) - set(LLVM_UTILS_PROVIDED ON) - set(CLANG_TEST_DEPS FileCheck count not) - endif() -- set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) -- if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h -- AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} -- AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) -- add_subdirectory(${UNITTEST_DIR} utils/unittest) -- endif() - else() - # Seek installed Lit. - find_program(LLVM_LIT -@@ -549,7 +543,11 @@ endif() - - - if( CLANG_INCLUDE_TESTS ) -- if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) -+ set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) -+ if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h -+ AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} -+ AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) -+ add_subdirectory(${UNITTEST_DIR} utils/unittest) - add_subdirectory(unittests) - list(APPEND CLANG_TEST_DEPS ClangUnitTests) - list(APPEND CLANG_TEST_PARAMS --- -2.34.1 - diff --git a/0001-Reorganize-gtest-integration.patch b/0001-Reorganize-gtest-integration.patch new file mode 100644 index 0000000..0d36adc --- /dev/null +++ b/0001-Reorganize-gtest-integration.patch @@ -0,0 +1,42 @@ +From cb7b3a4d8f15cd5d1546446656a5083f9fc826eb Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:04:52 +0100 +Subject: Reorganize gtest integration + +--- + clang/CMakeLists.txt | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 937a8467df1d..9a304db5a2c6 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -159,12 +159,6 @@ if(CLANG_BUILT_STANDALONE) + set(LLVM_UTILS_PROVIDED ON) + set(CLANG_TEST_DEPS FileCheck count not) + endif() +- set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) +- if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h +- AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} +- AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) +- add_subdirectory(${UNITTEST_DIR} utils/unittest) +- endif() + else() + # Seek installed Lit. + find_program(LLVM_LIT +@@ -563,7 +557,11 @@ endif() + + + if( CLANG_INCLUDE_TESTS ) +- if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) ++ set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) ++ if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h ++ AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} ++ AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) ++ add_subdirectory(${UNITTEST_DIR} utils/unittest) + add_subdirectory(unittests) + list(APPEND CLANG_TEST_DEPS ClangUnitTests) + list(APPEND CLANG_TEST_PARAMS +-- +2.34.1 + diff --git a/0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch b/0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch deleted file mode 100644 index 29a170a..0000000 --- a/0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch +++ /dev/null @@ -1,51 +0,0 @@ -From d370c7b27b828dec5da585f21054786c5e9d34b8 Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Thu, 25 Feb 2021 14:08:28 +0100 -Subject: [PATCH][clang] ToolChain: Add -lgcc_s to the linker flags when using - libc++ - -The libc++ build for Fedora does not include an implementation of -libunwind, so we need to explicitly link against something that -provides this implementation. ---- - clang/lib/Driver/ToolChain.cpp | 1 + - clang/test/Driver/netbsd.cpp | 4 ++-- - 2 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp -index 7551ee4aeb79..82525a9bd882 100644 ---- a/clang/lib/Driver/ToolChain.cpp -+++ b/clang/lib/Driver/ToolChain.cpp -@@ -954,6 +954,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, - switch (Type) { - case ToolChain::CST_Libcxx: - CmdArgs.push_back("-lc++"); -+ CmdArgs.push_back("-lgcc_s"); - break; - - case ToolChain::CST_Libstdcxx: -diff --git a/clang/test/Driver/netbsd.cpp b/clang/test/Driver/netbsd.cpp -index 4af7d8373d67..ff18c627f560 100644 ---- a/clang/test/Driver/netbsd.cpp -+++ b/clang/test/Driver/netbsd.cpp -@@ -131,7 +131,7 @@ - // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" - // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" - // ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" --// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" -+// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" - // ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" - - // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" -@@ -250,7 +250,7 @@ - // S-ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" - // S-ARM-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic" - // S-ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" --// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" -+// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" - // S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" - - // S-AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" --- -2.34.1 - diff --git a/0002-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch b/0002-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch new file mode 100644 index 0000000..ac3c8e5 --- /dev/null +++ b/0002-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch @@ -0,0 +1,50 @@ +From 8360e0e8d1f8c3f28ff21e4e92c81d8dfc749e82 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:08:28 +0100 +Subject: ToolChain: Add -lgcc_s to the linker flags when using libc++ + +The libc++ build for Fedora does not include an implementation of +libunwind, so we need to explicitly link against something that +provides this implementation. +--- + clang/lib/Driver/ToolChain.cpp | 1 + + clang/test/Driver/netbsd.cpp | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp +index d657d21bfcdb..ef95dd8b882d 100644 +--- a/clang/lib/Driver/ToolChain.cpp ++++ b/clang/lib/Driver/ToolChain.cpp +@@ -966,6 +966,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, + switch (Type) { + case ToolChain::CST_Libcxx: + CmdArgs.push_back("-lc++"); ++ CmdArgs.push_back("-lgcc_s"); + break; + + case ToolChain::CST_Libstdcxx: +diff --git a/clang/test/Driver/netbsd.cpp b/clang/test/Driver/netbsd.cpp +index 4af7d8373d67..ff18c627f560 100644 +--- a/clang/test/Driver/netbsd.cpp ++++ b/clang/test/Driver/netbsd.cpp +@@ -131,7 +131,7 @@ + // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" + // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" + // ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" +-// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" ++// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" + // ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" + + // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" +@@ -250,7 +250,7 @@ + // S-ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi" + // S-ARM-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic" + // S-ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o" +-// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc" ++// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc" + // S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o" + + // S-AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd" +-- +2.34.1 + diff --git a/0003-Make-funwind-tables-the-default-on-all-archs.patch b/0003-Make-funwind-tables-the-default-on-all-archs.patch new file mode 100644 index 0000000..830a41f --- /dev/null +++ b/0003-Make-funwind-tables-the-default-on-all-archs.patch @@ -0,0 +1,39 @@ +From 7e235e92397b954cff12660a492f95333fb3d68e Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:09:29 +0100 +Subject: Make -funwind-tables the default on all archs + +--- + clang/lib/Driver/ToolChain.cpp | 2 +- + clang/lib/Driver/ToolChains/Gnu.cpp | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp +index ef95dd8b882d..b83bd6d3ca5d 100644 +--- a/clang/lib/Driver/ToolChain.cpp ++++ b/clang/lib/Driver/ToolChain.cpp +@@ -258,7 +258,7 @@ std::string ToolChain::getInputFilename(const InputInfo &Input) const { + } + + bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const { +- return false; ++ return true; + } + + Tool *ToolChain::getClang() const { +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp +index d0808d061c82..a9ae51289190 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2703,7 +2703,7 @@ bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const { + case llvm::Triple::x86_64: + return true; + default: +- return false; ++ return true; + } + } + +-- +2.34.1 + diff --git a/0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch b/0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch deleted file mode 100644 index a6788b6..0000000 --- a/0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 2de2549adc85dbc769958cc4f1fd470dcc615f9d Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Thu, 25 Feb 2021 14:09:29 +0100 -Subject: [PATCH][clang] Make -funwind-tables the default on all archs - ---- - clang/lib/Driver/ToolChain.cpp | 2 +- - clang/lib/Driver/ToolChains/Gnu.cpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp -index 82525a9bd882..90fe9ff80120 100644 ---- a/clang/lib/Driver/ToolChain.cpp -+++ b/clang/lib/Driver/ToolChain.cpp -@@ -254,7 +254,7 @@ std::string ToolChain::getInputFilename(const InputInfo &Input) const { - } - - bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const { -- return false; -+ return true; - } - - Tool *ToolChain::getClang() const { -diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index fbb1af4dbe22..8323265ec8e8 100644 ---- a/clang/lib/Driver/ToolChains/Gnu.cpp -+++ b/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -2700,7 +2700,7 @@ bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const { - case llvm::Triple::x86_64: - return true; - default: -- return false; -+ return true; - } - } - --- -2.34.1 - diff --git a/0004-Don-t-install-static-libraries.patch b/0004-Don-t-install-static-libraries.patch new file mode 100644 index 0000000..6b83f51 --- /dev/null +++ b/0004-Don-t-install-static-libraries.patch @@ -0,0 +1,25 @@ +From 89f32fece081722e707eb413654d48b5f8b82d9b Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 31 Jan 2020 11:04:57 -0800 +Subject: Don't install static libraries + +--- + clang/cmake/modules/AddClang.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake +index 9bbbfc032b7d..dd611c0cf164 100644 +--- a/clang/cmake/modules/AddClang.cmake ++++ b/clang/cmake/modules/AddClang.cmake +@@ -114,7 +114,7 @@ macro(add_clang_library name) + if(TARGET ${lib}) + target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS}) + +- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN) ++ if (ARG_SHARED AND (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)) + get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries) + install(TARGETS ${lib} + COMPONENT ${lib} +-- +2.34.1 + diff --git a/0004-PATCH-clang-Don-t-install-static-libraries.patch b/0004-PATCH-clang-Don-t-install-static-libraries.patch deleted file mode 100644 index 52c461d..0000000 --- a/0004-PATCH-clang-Don-t-install-static-libraries.patch +++ /dev/null @@ -1,25 +0,0 @@ -From cf23ebf69a9a1827d601bc4dbfe9a4ab2db039ed Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Fri, 31 Jan 2020 11:04:57 -0800 -Subject: [PATCH][clang] Don't install static libraries - ---- - clang/cmake/modules/AddClang.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake -index 9bbbfc032b7d..dd611c0cf164 100644 ---- a/clang/cmake/modules/AddClang.cmake -+++ b/clang/cmake/modules/AddClang.cmake -@@ -114,7 +114,7 @@ macro(add_clang_library name) - if(TARGET ${lib}) - target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS}) - -- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN) -+ if (ARG_SHARED AND (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)) - get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries) - install(TARGETS ${lib} - COMPONENT ${lib} --- -2.34.1 - diff --git a/0005-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch b/0005-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch deleted file mode 100644 index 59c93c1..0000000 --- a/0005-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch +++ /dev/null @@ -1,132 +0,0 @@ -From 5eb0fef781622a69575c29885a430fb8883a5864 Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Wed, 23 Sep 2020 12:47:30 +0000 -Subject: [PATCH][clang] Prefer gcc toolchains with libgcc_s.so when not static - linking libgcc - -Fedora ships cross-compilers on all platforms, so a user could end up -with a gcc x86_64 cross-compiler installed on an x86_64 system. clang -maintains a list of supported triples for each target and when all -else is equal will prefer toolchains with triples that appear earlier -in the list. - -The cross-compiler triple on Fedora is x86_64-linux-gnu and this comes -before the Fedora system compiler's triple: x86_64-redhat-linux in -the triples list, so the cross compiler is always preferred. This -is a problem, because the cross compiler is missing libraries, like -libgcc_s.so, that clang expects to be there so linker invocations -will fail. - -This patch fixes this by checking for the existence of libgcc_s.so -when it is required and taking that into account when selecting a -toolchain. ---- - clang/lib/Driver/ToolChains/Gnu.cpp | 16 ++++++++++++++-- - clang/lib/Driver/ToolChains/Gnu.h | 4 +++- - .../usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o | 0 - .../usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o | 0 - .../lib/gcc/x86_64-redhat-linux/7/libgcc_s.so | 0 - clang/test/Driver/linux-ld.c | 12 ++++++++++++ - 6 files changed, 29 insertions(+), 3 deletions(-) - create mode 100644 clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o - create mode 100644 clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o - create mode 100644 clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so - -diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index 8323265ec8e8..12eed9b9cbf1 100644 ---- a/clang/lib/Driver/ToolChains/Gnu.cpp -+++ b/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -2525,6 +2525,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( - TargetTriple.getVendor() == llvm::Triple::Freescale || - TargetTriple.getVendor() == llvm::Triple::OpenEmbedded}}; - -+ bool NeedLibgccShared = !Args.hasArg(options::OPT_static_libgcc) && -+ !Args.hasArg(options::OPT_static); - for (auto &Suffix : Suffixes) { - if (!Suffix.Active) - continue; -@@ -2542,8 +2544,17 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( - continue; // Saw this path before; no need to look at it again. - if (CandidateVersion.isOlderThan(4, 1, 1)) - continue; -- if (CandidateVersion <= Version) -- continue; -+ -+ bool CandidateHasLibGccShared = false; -+ if (CandidateVersion <= Version) { -+ if (NeedLibgccShared && !HasLibGccShared) { -+ CandidateHasLibGccShared = -+ D.getVFS().exists(LI->path() + "/libgcc_s.so"); -+ -+ } -+ if (HasLibGccShared || !CandidateHasLibGccShared) -+ continue; -+ } - - if (!ScanGCCForMultilibs(TargetTriple, Args, LI->path(), - NeedsBiarchSuffix)) -@@ -2557,6 +2568,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( - GCCInstallPath = (LibDir + "/" + LibSuffix + "/" + VersionText).str(); - GCCParentLibPath = (GCCInstallPath + "/../" + Suffix.ReversePath).str(); - IsValid = true; -+ HasLibGccShared = CandidateHasLibGccShared; - } - } - } -diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h -index 4eb7ab0215ab..d692fb031eb8 100644 ---- a/clang/lib/Driver/ToolChains/Gnu.h -+++ b/clang/lib/Driver/ToolChains/Gnu.h -@@ -190,6 +190,7 @@ public: - /// Driver, and has logic for fuzzing that where appropriate. - class GCCInstallationDetector { - bool IsValid; -+ bool HasLibGccShared; - llvm::Triple GCCTriple; - const Driver &D; - -@@ -216,7 +217,8 @@ public: - const std::string GentooConfigDir = "/etc/env.d/gcc"; - - public: -- explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} -+ explicit GCCInstallationDetector(const Driver &D) -+ : IsValid(false), HasLibGccShared(false), D(D) {} - void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, - ArrayRef ExtraTripleAliases = None); - -diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o -new file mode 100644 -index 000000000000..e69de29bb2d1 -diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o -new file mode 100644 -index 000000000000..e69de29bb2d1 -diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so -new file mode 100644 -index 000000000000..e69de29bb2d1 -diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c -index b70b712c2eb7..c474cf547e86 100644 ---- a/clang/test/Driver/linux-ld.c -+++ b/clang/test/Driver/linux-ld.c -@@ -687,6 +687,18 @@ - // CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|\\\\}}crtend.o" - // CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|\\\\}}crtn.o" - // -+// Check that clang does not select the cross compiler by default on Fedora 28. -+// -+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -+// RUN: --target=x86_64-unknown-linux-gnu \ -+// RUN: --gcc-toolchain="" \ -+// RUN: --sysroot=%S/Inputs/fedora_28_tree \ -+// RUN: | FileCheck --check-prefix=CHECK-FEDORA-28-X86_64 %s -+// -+// CHECK-FEDORA-28-X86_64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" -+// CHECK-FEDORA-28-X86_64: "[[SYSROOT]]/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o" -+// CHECK-FEDORA-28-X86_64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-redhat-linux/7" -+// - // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ - // RUN: --target=arm-unknown-linux-gnueabi -rtlib=platform \ - // RUN: --gcc-toolchain="" \ --- -2.34.1 - diff --git a/0005-Prefer-gcc-toolchains-with-libgcc_s.so-when-not-stat.patch b/0005-Prefer-gcc-toolchains-with-libgcc_s.so-when-not-stat.patch new file mode 100644 index 0000000..4ca6da9 --- /dev/null +++ b/0005-Prefer-gcc-toolchains-with-libgcc_s.so-when-not-stat.patch @@ -0,0 +1,131 @@ +From f70ad66b2a85d2a6cca8a9a9d12fd174e40f00fc Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Wed, 23 Sep 2020 12:47:30 +0000 +Subject: Prefer gcc toolchains with libgcc_s.so when not static linking libgcc + +Fedora ships cross-compilers on all platforms, so a user could end up +with a gcc x86_64 cross-compiler installed on an x86_64 system. clang +maintains a list of supported triples for each target and when all +else is equal will prefer toolchains with triples that appear earlier +in the list. + +The cross-compiler triple on Fedora is x86_64-linux-gnu and this comes +before the Fedora system compiler's triple: x86_64-redhat-linux in +the triples list, so the cross compiler is always preferred. This +is a problem, because the cross compiler is missing libraries, like +libgcc_s.so, that clang expects to be there so linker invocations +will fail. + +This patch fixes this by checking for the existence of libgcc_s.so +when it is required and taking that into account when selecting a +toolchain. +--- + clang/lib/Driver/ToolChains/Gnu.cpp | 16 ++++++++++++++-- + clang/lib/Driver/ToolChains/Gnu.h | 4 +++- + .../usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o | 0 + .../usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o | 0 + .../lib/gcc/x86_64-redhat-linux/7/libgcc_s.so | 0 + clang/test/Driver/linux-ld.c | 12 ++++++++++++ + 6 files changed, 29 insertions(+), 3 deletions(-) + create mode 100644 clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o + create mode 100644 clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o + create mode 100644 clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so + +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp +index a9ae51289190..6915857c424e 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2528,6 +2528,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( + TargetTriple.getVendor() == llvm::Triple::Freescale || + TargetTriple.getVendor() == llvm::Triple::OpenEmbedded}}; + ++ bool NeedLibgccShared = !Args.hasArg(options::OPT_static_libgcc) && ++ !Args.hasArg(options::OPT_static); + for (auto &Suffix : Suffixes) { + if (!Suffix.Active) + continue; +@@ -2545,8 +2547,17 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( + continue; // Saw this path before; no need to look at it again. + if (CandidateVersion.isOlderThan(4, 1, 1)) + continue; +- if (CandidateVersion <= Version) +- continue; ++ ++ bool CandidateHasLibGccShared = false; ++ if (CandidateVersion <= Version) { ++ if (NeedLibgccShared && !HasLibGccShared) { ++ CandidateHasLibGccShared = ++ D.getVFS().exists(LI->path() + "/libgcc_s.so"); ++ ++ } ++ if (HasLibGccShared || !CandidateHasLibGccShared) ++ continue; ++ } + + if (!ScanGCCForMultilibs(TargetTriple, Args, LI->path(), + NeedsBiarchSuffix)) +@@ -2560,6 +2571,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( + GCCInstallPath = (LibDir + "/" + LibSuffix + "/" + VersionText).str(); + GCCParentLibPath = (GCCInstallPath + "/../" + Suffix.ReversePath).str(); + IsValid = true; ++ HasLibGccShared = CandidateHasLibGccShared; + } + } + } +diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h +index 4eb7ab0215ab..d692fb031eb8 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.h ++++ b/clang/lib/Driver/ToolChains/Gnu.h +@@ -190,6 +190,7 @@ public: + /// Driver, and has logic for fuzzing that where appropriate. + class GCCInstallationDetector { + bool IsValid; ++ bool HasLibGccShared; + llvm::Triple GCCTriple; + const Driver &D; + +@@ -216,7 +217,8 @@ public: + const std::string GentooConfigDir = "/etc/env.d/gcc"; + + public: +- explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} ++ explicit GCCInstallationDetector(const Driver &D) ++ : IsValid(false), HasLibGccShared(false), D(D) {} + void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, + ArrayRef ExtraTripleAliases = None); + +diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o +new file mode 100644 +index 000000000000..e69de29bb2d1 +diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o +new file mode 100644 +index 000000000000..e69de29bb2d1 +diff --git a/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so b/clang/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so +new file mode 100644 +index 000000000000..e69de29bb2d1 +diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c +index fc0a40d0cbe6..6884bcdaa54a 100644 +--- a/clang/test/Driver/linux-ld.c ++++ b/clang/test/Driver/linux-ld.c +@@ -687,6 +687,18 @@ + // CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|\\\\}}crtend.o" + // CHECK-FEDORA-31-RISCV64: "{{.*}}/usr/lib/gcc/riscv64-redhat-linux/9{{/|\\\\}}crtn.o" + // ++// Check that clang does not select the cross compiler by default on Fedora 28. ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux-gnu \ ++// RUN: --gcc-toolchain="" \ ++// RUN: --sysroot=%S/Inputs/fedora_28_tree \ ++// RUN: | FileCheck --check-prefix=CHECK-FEDORA-28-X86_64 %s ++// ++// CHECK-FEDORA-28-X86_64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" ++// CHECK-FEDORA-28-X86_64: "[[SYSROOT]]/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o" ++// CHECK-FEDORA-28-X86_64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-redhat-linux/7" ++// + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ + // RUN: --target=arm-unknown-linux-gnueabi -rtlib=platform \ + // RUN: --gcc-toolchain="" \ +-- +2.34.1 + diff --git a/0006-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch b/0006-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch new file mode 100644 index 0000000..fbdf775 --- /dev/null +++ b/0006-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch @@ -0,0 +1,58 @@ +From 453e5af5763a6368dd5e77c87b0a808c092a50d2 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 11 Nov 2021 10:58:14 +0100 +Subject: Driver: Add a gcc equivalent triple to the list of triples to search + +There are some gcc triples, like x86_64-redhat-linux, that provide the +same behavior as a clang triple with a similar name (e.g. +x86_64-redhat-linux-gnu). When searching for a gcc install, also search +for a gcc equivalent triple if one exists. + +https://reviews.llvm.org/D111207 +--- + clang/lib/Driver/ToolChains/Gnu.cpp | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp +index 6915857c424e..035ab5b338d2 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -1876,6 +1876,18 @@ static llvm::StringRef getGCCToolchainDir(const ArgList &Args, + return GCC_INSTALL_PREFIX; + } + ++/// This function takes a 'clang' triple and converts it to an equivalent gcc ++/// triple. ++static const char *ConvertToGccTriple(StringRef CandidateTriple) { ++ return llvm::StringSwitch(CandidateTriple) ++ .Case("aarch64-redhat-linux-gnu", "aarch64-redhat-linux") ++ .Case("i686-redhat-linux-gnu", "i686-redhat-linux") ++ .Case("ppc64le-redhat-linux-gnu", "ppc64le-redhat-linux") ++ .Case("s390x-redhat-linux-gnu", "s390x-redhat-linux") ++ .Case("x86_64-redhat-linux-gnu", "x86_64-redhat-linux") ++ .Default(NULL); ++} ++ + /// Initialize a GCCInstallationDetector from the driver. + /// + /// This performs all of the autodetection and sets up the various paths. +@@ -1896,6 +1908,16 @@ void Generic_GCC::GCCInstallationDetector::init( + // The compatible GCC triples for this particular architecture. + SmallVector CandidateTripleAliases; + SmallVector CandidateBiarchTripleAliases; ++ ++ // In some cases gcc uses a slightly different triple than clang for the ++ // same target. Convert the clang triple to the gcc equivalent and use that ++ // to search for the gcc install. ++ const char *ConvertedTriple = ConvertToGccTriple(TargetTriple.str()); ++ if (ConvertedTriple) { ++ CandidateTripleAliases.push_back(ConvertedTriple); ++ CandidateBiarchTripleAliases.push_back(ConvertedTriple); ++ } ++ + CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs, + CandidateTripleAliases, CandidateBiarchLibDirs, + CandidateBiarchTripleAliases); +-- +2.34.1 + diff --git a/0006-PATCH-Driver-Add-a-gcc-equivalent-triple-to-the-list.patch b/0006-PATCH-Driver-Add-a-gcc-equivalent-triple-to-the-list.patch deleted file mode 100644 index 3fa578e..0000000 --- a/0006-PATCH-Driver-Add-a-gcc-equivalent-triple-to-the-list.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 60f8d80b366186d0ca5a75afb6acff659d4c82c1 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Thu, 11 Nov 2021 10:58:14 +0100 -Subject: [PATCH] Driver: Add a gcc equivalent triple to the list of triples to - search - -There are some gcc triples, like x86_64-redhat-linux, that provide the -same behavior as a clang triple with a similar name (e.g. -x86_64-redhat-linux-gnu). When searching for a gcc install, also search -for a gcc equivalent triple if one exists. - -https://reviews.llvm.org/D111207 ---- - clang/lib/Driver/ToolChains/Gnu.cpp | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - -diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index 6915857c424e..035ab5b338d2 100644 ---- a/clang/lib/Driver/ToolChains/Gnu.cpp -+++ b/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -1876,6 +1876,18 @@ static llvm::StringRef getGCCToolchainDir(const ArgList &Args, - return GCC_INSTALL_PREFIX; - } - -+/// This function takes a 'clang' triple and converts it to an equivalent gcc -+/// triple. -+static const char *ConvertToGccTriple(StringRef CandidateTriple) { -+ return llvm::StringSwitch(CandidateTriple) -+ .Case("aarch64-redhat-linux-gnu", "aarch64-redhat-linux") -+ .Case("i686-redhat-linux-gnu", "i686-redhat-linux") -+ .Case("ppc64le-redhat-linux-gnu", "ppc64le-redhat-linux") -+ .Case("s390x-redhat-linux-gnu", "s390x-redhat-linux") -+ .Case("x86_64-redhat-linux-gnu", "x86_64-redhat-linux") -+ .Default(NULL); -+} -+ - /// Initialize a GCCInstallationDetector from the driver. - /// - /// This performs all of the autodetection and sets up the various paths. -@@ -1896,6 +1908,16 @@ void Generic_GCC::GCCInstallationDetector::init( - // The compatible GCC triples for this particular architecture. - SmallVector CandidateTripleAliases; - SmallVector CandidateBiarchTripleAliases; -+ -+ // In some cases gcc uses a slightly different triple than clang for the -+ // same target. Convert the clang triple to the gcc equivalent and use that -+ // to search for the gcc install. -+ const char *ConvertedTriple = ConvertToGccTriple(TargetTriple.str()); -+ if (ConvertedTriple) { -+ CandidateTripleAliases.push_back(ConvertedTriple); -+ CandidateBiarchTripleAliases.push_back(ConvertedTriple); -+ } -+ - CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs, - CandidateTripleAliases, CandidateBiarchLibDirs, - CandidateBiarchTripleAliases); --- -2.34.1 - diff --git a/0007-PATCH-clang-Work-around-gcc-miscompile.patch b/0007-PATCH-clang-Work-around-gcc-miscompile.patch deleted file mode 100644 index 1ff135f..0000000 --- a/0007-PATCH-clang-Work-around-gcc-miscompile.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 632715433c4afeac161853c799dccc887573e637 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Thu, 3 Feb 2022 10:34:44 +0100 -Subject: [PATCH][clang] Work around gcc miscompile - -This works around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104334, -which miscompiles clang on s390x and ppc64le. The issue is already -fixed on the gcc side, but including this as a temporary workaround -to get a working build. ---- - clang/lib/Sema/DeclSpec.cpp | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp -index d4dc790c008a..77a1e6c32c6f 100644 ---- a/clang/lib/Sema/DeclSpec.cpp -+++ b/clang/lib/Sema/DeclSpec.cpp -@@ -1203,8 +1203,9 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { - } else if (TypeSpecType == TST_double) { - // vector long double and vector long long double are never allowed. - // vector double is OK for Power7 and later, and ZVector. -- if (getTypeSpecWidth() == TypeSpecifierWidth::Long || -- getTypeSpecWidth() == TypeSpecifierWidth::LongLong) -+ TypeSpecifierWidth TypeSpecWidth = getTypeSpecWidth(); -+ if (TypeSpecWidth == TypeSpecifierWidth::Long || -+ TypeSpecWidth == TypeSpecifierWidth::LongLong) - S.Diag(TSWRange.getBegin(), - diag::err_invalid_vector_long_double_decl_spec); - else if (!S.Context.getTargetInfo().hasFeature("vsx") && --- -2.34.1 - diff --git a/0007-Work-around-gcc-miscompile.patch b/0007-Work-around-gcc-miscompile.patch new file mode 100644 index 0000000..efd6389 --- /dev/null +++ b/0007-Work-around-gcc-miscompile.patch @@ -0,0 +1,32 @@ +From 0d58680446685445ab28c908198f6bcff660c6b7 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Thu, 3 Feb 2022 10:34:44 +0100 +Subject: Work around gcc miscompile + +This works around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104334, +which miscompiles clang on s390x and ppc64le. The issue is already +fixed on the gcc side, but including this as a temporary workaround +to get a working build. +--- + clang/lib/Sema/DeclSpec.cpp | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp +index d4dc790c008a..77a1e6c32c6f 100644 +--- a/clang/lib/Sema/DeclSpec.cpp ++++ b/clang/lib/Sema/DeclSpec.cpp +@@ -1203,8 +1203,9 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { + } else if (TypeSpecType == TST_double) { + // vector long double and vector long long double are never allowed. + // vector double is OK for Power7 and later, and ZVector. +- if (getTypeSpecWidth() == TypeSpecifierWidth::Long || +- getTypeSpecWidth() == TypeSpecifierWidth::LongLong) ++ TypeSpecifierWidth TypeSpecWidth = getTypeSpecWidth(); ++ if (TypeSpecWidth == TypeSpecifierWidth::Long || ++ TypeSpecWidth == TypeSpecifierWidth::LongLong) + S.Diag(TSWRange.getBegin(), + diag::err_invalid_vector_long_double_decl_spec); + else if (!S.Context.getTargetInfo().hasFeature("vsx") && +-- +2.34.1 + diff --git a/0008-PATCH-clang-cmake-Allow-shared-libraries-to-customiz.patch b/0008-PATCH-clang-cmake-Allow-shared-libraries-to-customiz.patch deleted file mode 100644 index b739a6b..0000000 --- a/0008-PATCH-clang-cmake-Allow-shared-libraries-to-customiz.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 2af211858807b2696b6f10fd156616838cbd2e58 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Wed, 4 Aug 2021 14:05:38 -0700 -Subject: [PATCH][clang] cmake: Allow shared libraries to customize the soname - using LLVM_ABI_REVISION - -The LLVM_ABI_REVISION variable is intended to be used for release -candidates which introduce an ABI change to a shared library. This -variable can be specified per library, so there is not one global value -for all of LLVM. - -For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library -compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for -library will be incremented by 1. - -In the main branch, LLVM_ABI_REVISION should always be 0, it is only -meant to be used in the release branch. - -Differential Revision: https://reviews.llvm.org/D105594 ---- - clang/tools/clang-shlib/CMakeLists.txt | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt -index 9c1f8ea452b3..4d785924e4bb 100644 ---- a/clang/tools/clang-shlib/CMakeLists.txt -+++ b/clang/tools/clang-shlib/CMakeLists.txt -@@ -1,3 +1,8 @@ -+# In the main branch, LLVM_ABI_REVISION should always be 0. In the release -+# branches, this should be incremented before each release candidate every -+# time the ABI of libclang-cpp.so changes. -+set(LLVM_ABI_REVISION 0) -+ - # Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off - if (NOT LLVM_ENABLE_PIC) - return() --- -2.34.1 - diff --git a/0008-cmake-Allow-shared-libraries-to-customize-the-soname.patch b/0008-cmake-Allow-shared-libraries-to-customize-the-soname.patch new file mode 100644 index 0000000..12708f6 --- /dev/null +++ b/0008-cmake-Allow-shared-libraries-to-customize-the-soname.patch @@ -0,0 +1,39 @@ +From 2dba3213cb907dba978a9c076ae3fb35583abbc0 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Wed, 4 Aug 2021 14:05:38 -0700 +Subject: cmake: Allow shared libraries to customize the soname using + LLVM_ABI_REVISION + +The LLVM_ABI_REVISION variable is intended to be used for release +candidates which introduce an ABI change to a shared library. This +variable can be specified per library, so there is not one global value +for all of LLVM. + +For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library +compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for +library will be incremented by 1. + +In the main branch, LLVM_ABI_REVISION should always be 0, it is only +meant to be used in the release branch. + +Differential Revision: https://reviews.llvm.org/D105594 +--- + clang/tools/clang-shlib/CMakeLists.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt +index 9c1f8ea452b3..4d785924e4bb 100644 +--- a/clang/tools/clang-shlib/CMakeLists.txt ++++ b/clang/tools/clang-shlib/CMakeLists.txt +@@ -1,3 +1,8 @@ ++# In the main branch, LLVM_ABI_REVISION should always be 0. In the release ++# branches, this should be incremented before each release candidate every ++# time the ABI of libclang-cpp.so changes. ++set(LLVM_ABI_REVISION 0) ++ + # Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off + if (NOT LLVM_ENABLE_PIC) + return() +-- +2.34.1 + diff --git a/0009-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch b/0009-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch index e1ffdb6..1623a5f 100644 --- a/0009-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch +++ b/0009-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch @@ -8,62 +8,13 @@ This reverts commit 76cad51ba700233d6e3492eddcbb466b6adbc2eb. We don't install the LLVMHello plugin, so tests should not depend on it. --- - clang-tools-extra/test/CMakeLists.txt | 13 ++----------- - clang-tools-extra/test/lit.site.cfg.py.in | 2 +- - clang/CMakeLists.txt | 9 --------- - clang/lib/Analysis/plugins/CMakeLists.txt | 2 +- - clang/test/CMakeLists.txt | 4 ++-- - clang/test/lit.site.cfg.py.in | 2 +- - clang/tools/driver/CMakeLists.txt | 2 ++ - 7 files changed, 9 insertions(+), 25 deletions(-) + clang/CMakeLists.txt | 9 --------- + clang/lib/Analysis/plugins/CMakeLists.txt | 2 +- + clang/test/CMakeLists.txt | 4 ++-- + clang/test/lit.site.cfg.py.in | 2 +- + clang/tools/driver/CMakeLists.txt | 2 ++ + 5 files changed, 6 insertions(+), 13 deletions(-) -diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt -index 170e5f8bd197..9321457ae1a3 100644 ---- a/clang-tools-extra/test/CMakeLists.txt -+++ b/clang-tools-extra/test/CMakeLists.txt -@@ -17,7 +17,7 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN - - llvm_canonicalize_cmake_booleans( - CLANG_TIDY_ENABLE_STATIC_ANALYZER -- CLANG_PLUGIN_SUPPORT -+ LLVM_ENABLE_PLUGINS - LLVM_INSTALL_TOOLCHAIN_ONLY - ) - -@@ -87,19 +87,10 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - PLUGIN_TOOL clang-tidy - DEPENDS clang-tidy-headers) - -- if(CLANG_BUILT_STANDALONE) -- # LLVMHello library is needed below -- if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello -- AND NOT TARGET LLVMHello) -- add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello -- lib/Transforms/Hello) -- endif() -- endif() -- - if(TARGET CTTestTidyModule) - list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello) - target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}") -- if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) -+ if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) - set(LLVM_LINK_COMPONENTS - Support - ) -diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in -index d30e6664816b..e7db0e2ef2cb 100644 ---- a/clang-tools-extra/test/lit.site.cfg.py.in -+++ b/clang-tools-extra/test/lit.site.cfg.py.in -@@ -12,7 +12,7 @@ config.clang_libs_dir = "@SHLIBDIR@" - config.python_executable = "@Python3_EXECUTABLE@" - config.target_triple = "@TARGET_TRIPLE@" - config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ --config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ -+config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ - - # Support substitution of the tools and libs dirs with user parameters. This is - # used when we can't determine the tool dir at configuration time. diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 9a304db5a2c6..be0d82117aab 100644 --- a/clang/CMakeLists.txt diff --git a/0010-Revert-Reland-enable-plugins-for-clang-tidy.patch b/0010-Revert-Reland-enable-plugins-for-clang-tidy.patch deleted file mode 100644 index 5dd091c..0000000 --- a/0010-Revert-Reland-enable-plugins-for-clang-tidy.patch +++ /dev/null @@ -1,276 +0,0 @@ -From bab5129993a2a03f9924d5a7a8a8e59448522c91 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Wed, 16 Feb 2022 16:32:28 -0800 -Subject: Revert "Reland "enable plugins for clang-tidy"" - -This reverts commit 84f137a590e7de25c4105303e5938c40566c2dfb. - -We don't install the LLVMHello plugin so tests should not depend on it. ---- - .../clang-tidy/tool/CMakeLists.txt | 13 +--- - .../clang-tidy/tool/ClangTidyMain.cpp | 6 -- - .../docs/clang-tidy/Contributing.rst | 20 ------ - clang-tools-extra/docs/clang-tidy/index.rst | 9 --- - clang-tools-extra/test/CMakeLists.txt | 20 ------ - .../test/clang-tidy/CTTestTidyModule.cpp | 66 ------------------- - clang-tools-extra/test/lit.cfg.py | 6 -- - clang-tools-extra/test/lit.site.cfg.py.in | 2 - - 8 files changed, 2 insertions(+), 140 deletions(-) - delete mode 100644 clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp - -diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt -index 3ce552872015..4b8c93801501 100644 ---- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt -+++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt -@@ -29,17 +29,11 @@ clang_target_link_libraries(clangTidyMain - clangToolingCore - ) - --# Support plugins. --if(CLANG_PLUGIN_SUPPORT) -- set(support_plugins SUPPORT_PLUGINS) --endif() -- - add_clang_tool(clang-tidy - ClangTidyToolMain.cpp -- -- DEPENDS -+ ) -+add_dependencies(clang-tidy - clang-resource-headers -- ${support_plugins} - ) - clang_target_link_libraries(clang-tidy - PRIVATE -@@ -56,9 +50,6 @@ target_link_libraries(clang-tidy - ${ALL_CLANG_TIDY_CHECKS} - ) - --if(CLANG_PLUGIN_SUPPORT) -- export_executable_symbols_for_plugins(clang-tidy) --endif() - - install(PROGRAMS clang-tidy-diff.py - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" -diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp -index 1b0010bdd62a..6147d90eb10b 100644 ---- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp -+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp -@@ -20,7 +20,6 @@ - #include "../GlobList.h" - #include "clang/Tooling/CommonOptionsParser.h" - #include "llvm/Support/InitLLVM.h" --#include "llvm/Support/PluginLoader.h" - #include "llvm/Support/Process.h" - #include "llvm/Support/Signals.h" - #include "llvm/Support/TargetSelect.h" -@@ -387,11 +386,6 @@ getVfsFromFile(const std::string &OverlayFile, - - int clangTidyMain(int argc, const char **argv) { - llvm::InitLLVM X(argc, argv); -- -- // Enable help for -load option, if plugins are enabled. -- if (cl::Option *LoadOpt = cl::getRegisteredOptions().lookup("load")) -- LoadOpt->addCategory(ClangTidyCategory); -- - llvm::Expected OptionsParser = - CommonOptionsParser::create(argc, argv, ClangTidyCategory, - cl::ZeroOrMore); -diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst b/clang-tools-extra/docs/clang-tidy/Contributing.rst -index b1771574950a..b9eb0e7627cc 100644 ---- a/clang-tools-extra/docs/clang-tidy/Contributing.rst -+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst -@@ -634,26 +634,6 @@ This keeps the test directory from getting cluttered. - .. _FileCheck: https://llvm.org/docs/CommandGuide/FileCheck.html - .. _test/clang-tidy/google-readability-casting.cpp: https://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp - --Out-of-tree check plugins --------------------------- -- --Developing an out-of-tree check as a plugin largely follows the steps --outlined above. The plugin is a shared library whose code lives outside --the clang-tidy build system. Build and link this shared library against --LLVM as done for other kinds of Clang plugins. -- --The plugin can be loaded by passing `-load` to `clang-tidy` in addition to the --names of the checks to enable. -- --.. code-block:: console -- -- $ clang-tidy --checks=-*,my-explicit-constructor -list-checks -load myplugin.so -- --There is no expectations regarding ABI and API stability, so the plugin must be --compiled against the version of clang-tidy that will be loading the plugin. -- --The plugins can use threads, TLS, or any other facilities available to in-tree --code which is accessible from the external headers. - - Running clang-tidy on LLVM - -------------------------- -diff --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst -index c76259e02f8d..3231b1528efc 100644 ---- a/clang-tools-extra/docs/clang-tidy/index.rst -+++ b/clang-tools-extra/docs/clang-tidy/index.rst -@@ -218,15 +218,6 @@ An overview of all the command-line options: - --list-checks - - List all enabled checks and exit. Use with - -checks=* to list all available checks. -- -load= - -- Load the dynamic object ``plugin``. This -- object should register new static analyzer -- or clang-tidy passes. Once loaded, the -- object will add new command line options -- to run various analyses. To see the new -- complete list of passes, use the -- :option:`--list-checks` and -- :option:`-load` options together. - -p= - Build path - --quiet - - Run clang-tidy in quiet mode. This suppresses -diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt -index 9321457ae1a3..06be00015223 100644 ---- a/clang-tools-extra/test/CMakeLists.txt -+++ b/clang-tools-extra/test/CMakeLists.txt -@@ -17,8 +17,6 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN - - llvm_canonicalize_cmake_booleans( - CLANG_TIDY_ENABLE_STATIC_ANALYZER -- LLVM_ENABLE_PLUGINS -- LLVM_INSTALL_TOOLCHAIN_ONLY - ) - - configure_lit_site_cfg( -@@ -80,24 +78,6 @@ foreach(dep ${LLVM_UTILS_DEPS}) - endif() - endforeach() - --if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) -- llvm_add_library( -- CTTestTidyModule -- MODULE clang-tidy/CTTestTidyModule.cpp -- PLUGIN_TOOL clang-tidy -- DEPENDS clang-tidy-headers) -- -- if(TARGET CTTestTidyModule) -- list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello) -- target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}") -- if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) -- set(LLVM_LINK_COMPONENTS -- Support -- ) -- endif() -- endif() --endif() -- - add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests" - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CLANG_TOOLS_TEST_DEPS} -diff --git a/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp b/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp -deleted file mode 100644 -index c66a94f458cf..000000000000 ---- a/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp -+++ /dev/null -@@ -1,66 +0,0 @@ --// REQUIRES: plugins --// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s --// CHECK-LIST: Enabled checks: --// CHECK-LIST-NEXT: mytest1 --// CHECK-LIST-NEXT: mytest2 --// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s --// CHECK: 3 warnings generated. --// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2] -- --#include "clang-tidy/ClangTidy.h" --#include "clang-tidy/ClangTidyCheck.h" --#include "clang-tidy/ClangTidyModule.h" --#include "clang-tidy/ClangTidyModuleRegistry.h" --#include "clang/AST/ASTContext.h" --#include "clang/ASTMatchers/ASTMatchFinder.h" -- --using namespace clang; --using namespace clang::tidy; --using namespace clang::ast_matchers; -- --namespace { --class MyTestCheck : public ClangTidyCheck { -- --public: -- MyTestCheck(StringRef Name, ClangTidyContext *Context) -- : ClangTidyCheck(Name, Context) {} -- -- void registerMatchers(ast_matchers::MatchFinder *Finder) override { -- Finder->addMatcher(translationUnitDecl().bind("tu"), this); -- } -- -- void check(const ast_matchers::MatchFinder::MatchResult &Result) override { -- auto S = Result.Nodes.getNodeAs("tu"); -- if (S) -- diag("mytest success"); -- } -- --private: --}; -- --class CTTestModule : public ClangTidyModule { --public: -- void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { -- CheckFactories.registerCheck("mytest1"); -- CheckFactories.registerCheck("mytest2"); -- // intentionally collide with an existing test name, overriding it -- CheckFactories.registerCheck("misc-definitions-in-headers"); -- } --}; --} // namespace -- --namespace tidy1 { --// Register the CTTestTidyModule using this statically initialized variable. --static ClangTidyModuleRegistry::Add<::CTTestModule> -- X("mytest-module", "Adds my checks."); --} // namespace tidy1 -- --namespace tidy2 { --// intentionally collide with an existing test group name, merging with it --static ClangTidyModuleRegistry::Add<::CTTestModule> -- X("misc-module", "Adds miscellaneous lint checks."); --} // namespace tidy2 -- --// This anchor is used to force the linker to link in the generated object file --// and thus register the CTTestModule. --volatile int CTTestModuleAnchorSource = 0; -diff --git a/clang-tools-extra/test/lit.cfg.py b/clang-tools-extra/test/lit.cfg.py -index 858e42ace2a8..24cabd823844 100644 ---- a/clang-tools-extra/test/lit.cfg.py -+++ b/clang-tools-extra/test/lit.cfg.py -@@ -149,9 +149,3 @@ clangd_benchmarks_dir = os.path.join(os.path.dirname(config.clang_tools_dir), - "clangd", "benchmarks") - config.substitutions.append(('%clangd-benchmark-dir', - '%s' % (clangd_benchmarks_dir))) --config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir)) --config.substitutions.append(('%pluginext', config.llvm_plugin_ext)) -- --# Plugins (loadable modules) --if config.has_plugins and config.llvm_plugin_ext: -- config.available_features.add('plugins') -diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in -index e7db0e2ef2cb..f8300c1dd39d 100644 ---- a/clang-tools-extra/test/lit.site.cfg.py.in -+++ b/clang-tools-extra/test/lit.site.cfg.py.in -@@ -4,7 +4,6 @@ import sys - - config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" - config.llvm_libs_dir = "@LLVM_LIBS_DIR@" --config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" - config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" - config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@" - config.clang_tools_dir = "@CLANG_TOOLS_DIR@" -@@ -12,7 +11,6 @@ config.clang_libs_dir = "@SHLIBDIR@" - config.python_executable = "@Python3_EXECUTABLE@" - config.target_triple = "@TARGET_TRIPLE@" - config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ --config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ - - # Support substitution of the tools and libs dirs with user parameters. This is - # used when we can't determine the tool dir at configuration time. --- -2.34.1 - diff --git a/0010-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch b/0010-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch new file mode 100644 index 0000000..c1d57f6 --- /dev/null +++ b/0010-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch @@ -0,0 +1,64 @@ +From 6005ae94e5cbd3e320141ba6a81d1c8a9eaa775e Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Wed, 16 Feb 2022 16:31:51 -0800 +Subject: Revert "replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in + tests" + +This reverts commit 76cad51ba700233d6e3492eddcbb466b6adbc2eb. + +We don't install the LLVMHello plugin, so tests should not depend on it. +--- + clang-tools-extra/test/CMakeLists.txt | 13 ++----------- + clang-tools-extra/test/lit.site.cfg.py.in | 2 +- + 2 files changed, 3 insertions(+), 12 deletions(-) + +diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt +index 170e5f8bd197..9321457ae1a3 100644 +--- a/clang-tools-extra/test/CMakeLists.txt ++++ b/clang-tools-extra/test/CMakeLists.txt +@@ -17,7 +17,7 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN + + llvm_canonicalize_cmake_booleans( + CLANG_TIDY_ENABLE_STATIC_ANALYZER +- CLANG_PLUGIN_SUPPORT ++ LLVM_ENABLE_PLUGINS + LLVM_INSTALL_TOOLCHAIN_ONLY + ) + +@@ -87,19 +87,10 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + PLUGIN_TOOL clang-tidy + DEPENDS clang-tidy-headers) + +- if(CLANG_BUILT_STANDALONE) +- # LLVMHello library is needed below +- if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello +- AND NOT TARGET LLVMHello) +- add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello +- lib/Transforms/Hello) +- endif() +- endif() +- + if(TARGET CTTestTidyModule) + list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello) + target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}") +- if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN)) ++ if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) + set(LLVM_LINK_COMPONENTS + Support + ) +diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in +index d30e6664816b..e7db0e2ef2cb 100644 +--- a/clang-tools-extra/test/lit.site.cfg.py.in ++++ b/clang-tools-extra/test/lit.site.cfg.py.in +@@ -12,7 +12,7 @@ config.clang_libs_dir = "@SHLIBDIR@" + config.python_executable = "@Python3_EXECUTABLE@" + config.target_triple = "@TARGET_TRIPLE@" + config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ +-config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ ++config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ + + # Support substitution of the tools and libs dirs with user parameters. This is + # used when we can't determine the tool dir at configuration time. +-- +2.34.1 + diff --git a/0011-Revert-Reland-enable-plugins-for-clang-tidy.patch b/0011-Revert-Reland-enable-plugins-for-clang-tidy.patch new file mode 100644 index 0000000..5dd091c --- /dev/null +++ b/0011-Revert-Reland-enable-plugins-for-clang-tidy.patch @@ -0,0 +1,276 @@ +From bab5129993a2a03f9924d5a7a8a8e59448522c91 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Wed, 16 Feb 2022 16:32:28 -0800 +Subject: Revert "Reland "enable plugins for clang-tidy"" + +This reverts commit 84f137a590e7de25c4105303e5938c40566c2dfb. + +We don't install the LLVMHello plugin so tests should not depend on it. +--- + .../clang-tidy/tool/CMakeLists.txt | 13 +--- + .../clang-tidy/tool/ClangTidyMain.cpp | 6 -- + .../docs/clang-tidy/Contributing.rst | 20 ------ + clang-tools-extra/docs/clang-tidy/index.rst | 9 --- + clang-tools-extra/test/CMakeLists.txt | 20 ------ + .../test/clang-tidy/CTTestTidyModule.cpp | 66 ------------------- + clang-tools-extra/test/lit.cfg.py | 6 -- + clang-tools-extra/test/lit.site.cfg.py.in | 2 - + 8 files changed, 2 insertions(+), 140 deletions(-) + delete mode 100644 clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp + +diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +index 3ce552872015..4b8c93801501 100644 +--- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt ++++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +@@ -29,17 +29,11 @@ clang_target_link_libraries(clangTidyMain + clangToolingCore + ) + +-# Support plugins. +-if(CLANG_PLUGIN_SUPPORT) +- set(support_plugins SUPPORT_PLUGINS) +-endif() +- + add_clang_tool(clang-tidy + ClangTidyToolMain.cpp +- +- DEPENDS ++ ) ++add_dependencies(clang-tidy + clang-resource-headers +- ${support_plugins} + ) + clang_target_link_libraries(clang-tidy + PRIVATE +@@ -56,9 +50,6 @@ target_link_libraries(clang-tidy + ${ALL_CLANG_TIDY_CHECKS} + ) + +-if(CLANG_PLUGIN_SUPPORT) +- export_executable_symbols_for_plugins(clang-tidy) +-endif() + + install(PROGRAMS clang-tidy-diff.py + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" +diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +index 1b0010bdd62a..6147d90eb10b 100644 +--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp ++++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +@@ -20,7 +20,6 @@ + #include "../GlobList.h" + #include "clang/Tooling/CommonOptionsParser.h" + #include "llvm/Support/InitLLVM.h" +-#include "llvm/Support/PluginLoader.h" + #include "llvm/Support/Process.h" + #include "llvm/Support/Signals.h" + #include "llvm/Support/TargetSelect.h" +@@ -387,11 +386,6 @@ getVfsFromFile(const std::string &OverlayFile, + + int clangTidyMain(int argc, const char **argv) { + llvm::InitLLVM X(argc, argv); +- +- // Enable help for -load option, if plugins are enabled. +- if (cl::Option *LoadOpt = cl::getRegisteredOptions().lookup("load")) +- LoadOpt->addCategory(ClangTidyCategory); +- + llvm::Expected OptionsParser = + CommonOptionsParser::create(argc, argv, ClangTidyCategory, + cl::ZeroOrMore); +diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst b/clang-tools-extra/docs/clang-tidy/Contributing.rst +index b1771574950a..b9eb0e7627cc 100644 +--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst ++++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst +@@ -634,26 +634,6 @@ This keeps the test directory from getting cluttered. + .. _FileCheck: https://llvm.org/docs/CommandGuide/FileCheck.html + .. _test/clang-tidy/google-readability-casting.cpp: https://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp + +-Out-of-tree check plugins +-------------------------- +- +-Developing an out-of-tree check as a plugin largely follows the steps +-outlined above. The plugin is a shared library whose code lives outside +-the clang-tidy build system. Build and link this shared library against +-LLVM as done for other kinds of Clang plugins. +- +-The plugin can be loaded by passing `-load` to `clang-tidy` in addition to the +-names of the checks to enable. +- +-.. code-block:: console +- +- $ clang-tidy --checks=-*,my-explicit-constructor -list-checks -load myplugin.so +- +-There is no expectations regarding ABI and API stability, so the plugin must be +-compiled against the version of clang-tidy that will be loading the plugin. +- +-The plugins can use threads, TLS, or any other facilities available to in-tree +-code which is accessible from the external headers. + + Running clang-tidy on LLVM + -------------------------- +diff --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst +index c76259e02f8d..3231b1528efc 100644 +--- a/clang-tools-extra/docs/clang-tidy/index.rst ++++ b/clang-tools-extra/docs/clang-tidy/index.rst +@@ -218,15 +218,6 @@ An overview of all the command-line options: + --list-checks - + List all enabled checks and exit. Use with + -checks=* to list all available checks. +- -load= - +- Load the dynamic object ``plugin``. This +- object should register new static analyzer +- or clang-tidy passes. Once loaded, the +- object will add new command line options +- to run various analyses. To see the new +- complete list of passes, use the +- :option:`--list-checks` and +- :option:`-load` options together. + -p= - Build path + --quiet - + Run clang-tidy in quiet mode. This suppresses +diff --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt +index 9321457ae1a3..06be00015223 100644 +--- a/clang-tools-extra/test/CMakeLists.txt ++++ b/clang-tools-extra/test/CMakeLists.txt +@@ -17,8 +17,6 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN + + llvm_canonicalize_cmake_booleans( + CLANG_TIDY_ENABLE_STATIC_ANALYZER +- LLVM_ENABLE_PLUGINS +- LLVM_INSTALL_TOOLCHAIN_ONLY + ) + + configure_lit_site_cfg( +@@ -80,24 +78,6 @@ foreach(dep ${LLVM_UTILS_DEPS}) + endif() + endforeach() + +-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +- llvm_add_library( +- CTTestTidyModule +- MODULE clang-tidy/CTTestTidyModule.cpp +- PLUGIN_TOOL clang-tidy +- DEPENDS clang-tidy-headers) +- +- if(TARGET CTTestTidyModule) +- list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello) +- target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}") +- if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) +- set(LLVM_LINK_COMPONENTS +- Support +- ) +- endif() +- endif() +-endif() +- + add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CLANG_TOOLS_TEST_DEPS} +diff --git a/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp b/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp +deleted file mode 100644 +index c66a94f458cf..000000000000 +--- a/clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp ++++ /dev/null +@@ -1,66 +0,0 @@ +-// REQUIRES: plugins +-// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s +-// CHECK-LIST: Enabled checks: +-// CHECK-LIST-NEXT: mytest1 +-// CHECK-LIST-NEXT: mytest2 +-// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s +-// CHECK: 3 warnings generated. +-// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2] +- +-#include "clang-tidy/ClangTidy.h" +-#include "clang-tidy/ClangTidyCheck.h" +-#include "clang-tidy/ClangTidyModule.h" +-#include "clang-tidy/ClangTidyModuleRegistry.h" +-#include "clang/AST/ASTContext.h" +-#include "clang/ASTMatchers/ASTMatchFinder.h" +- +-using namespace clang; +-using namespace clang::tidy; +-using namespace clang::ast_matchers; +- +-namespace { +-class MyTestCheck : public ClangTidyCheck { +- +-public: +- MyTestCheck(StringRef Name, ClangTidyContext *Context) +- : ClangTidyCheck(Name, Context) {} +- +- void registerMatchers(ast_matchers::MatchFinder *Finder) override { +- Finder->addMatcher(translationUnitDecl().bind("tu"), this); +- } +- +- void check(const ast_matchers::MatchFinder::MatchResult &Result) override { +- auto S = Result.Nodes.getNodeAs("tu"); +- if (S) +- diag("mytest success"); +- } +- +-private: +-}; +- +-class CTTestModule : public ClangTidyModule { +-public: +- void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { +- CheckFactories.registerCheck("mytest1"); +- CheckFactories.registerCheck("mytest2"); +- // intentionally collide with an existing test name, overriding it +- CheckFactories.registerCheck("misc-definitions-in-headers"); +- } +-}; +-} // namespace +- +-namespace tidy1 { +-// Register the CTTestTidyModule using this statically initialized variable. +-static ClangTidyModuleRegistry::Add<::CTTestModule> +- X("mytest-module", "Adds my checks."); +-} // namespace tidy1 +- +-namespace tidy2 { +-// intentionally collide with an existing test group name, merging with it +-static ClangTidyModuleRegistry::Add<::CTTestModule> +- X("misc-module", "Adds miscellaneous lint checks."); +-} // namespace tidy2 +- +-// This anchor is used to force the linker to link in the generated object file +-// and thus register the CTTestModule. +-volatile int CTTestModuleAnchorSource = 0; +diff --git a/clang-tools-extra/test/lit.cfg.py b/clang-tools-extra/test/lit.cfg.py +index 858e42ace2a8..24cabd823844 100644 +--- a/clang-tools-extra/test/lit.cfg.py ++++ b/clang-tools-extra/test/lit.cfg.py +@@ -149,9 +149,3 @@ clangd_benchmarks_dir = os.path.join(os.path.dirname(config.clang_tools_dir), + "clangd", "benchmarks") + config.substitutions.append(('%clangd-benchmark-dir', + '%s' % (clangd_benchmarks_dir))) +-config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir)) +-config.substitutions.append(('%pluginext', config.llvm_plugin_ext)) +- +-# Plugins (loadable modules) +-if config.has_plugins and config.llvm_plugin_ext: +- config.available_features.add('plugins') +diff --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in +index e7db0e2ef2cb..f8300c1dd39d 100644 +--- a/clang-tools-extra/test/lit.site.cfg.py.in ++++ b/clang-tools-extra/test/lit.site.cfg.py.in +@@ -4,7 +4,6 @@ import sys + + config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" + config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +-config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" + config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" + config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@" + config.clang_tools_dir = "@CLANG_TOOLS_DIR@" +@@ -12,7 +11,6 @@ config.clang_libs_dir = "@SHLIBDIR@" + config.python_executable = "@Python3_EXECUTABLE@" + config.target_triple = "@TARGET_TRIPLE@" + config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ +-config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@ + + # Support substitution of the tools and libs dirs with user parameters. This is + # used when we can't determine the tool dir at configuration time. +-- +2.34.1 + diff --git a/clang.spec b/clang.spec index 27b3878..bb536a8 100644 --- a/clang.spec +++ b/clang.spec @@ -111,17 +111,18 @@ Source5: macros.%{name} %endif # Patches for clang -Patch1: 0001-PATCH-clang-Reorganize-gtest-integration.patch -Patch2: 0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch -Patch3: 0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch -Patch4: 0004-PATCH-clang-Don-t-install-static-libraries.patch -Patch5: 0005-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch -Patch6: 0006-PATCH-Driver-Add-a-gcc-equivalent-triple-to-the-list.patch -# This patch can be dropped once gcc-12.0.1-0.5.fc36 is in the repo. -Patch7: 0007-PATCH-clang-Work-around-gcc-miscompile.patch -Patch8: 0008-PATCH-clang-cmake-Allow-shared-libraries-to-customiz.patch +Patch1: 0001-Reorganize-gtest-integration.patch +Patch2: 0002-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch +Patch3: 0003-Make-funwind-tables-the-default-on-all-archs.patch +Patch4: 0004-Don-t-install-static-libraries.patch +Patch5: 0005-Prefer-gcc-toolchains-with-libgcc_s.so-when-not-stat.patch +Patch6: 0006-Driver-Add-a-gcc-equivalent-triple-to-the-list-of-tr.patch +Patch7: 0007-Work-around-gcc-miscompile.patch +Patch8: 0008-cmake-Allow-shared-libraries-to-customize-the-soname.patch Patch9: 0009-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch -Patch10: 0010-Revert-Reland-enable-plugins-for-clang-tidy.patch +# Patches for clang-tools-extra (MUST NOT BE MIXED WITH CLANG PATCHES!!!!) +Patch10: 0010-Revert-replace-clang-LLVM_ENABLE_PLUGINS-CLANG_PLUGI.patch +Patch11: 0011-Revert-Reland-enable-plugins-for-clang-tidy.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -297,7 +298,7 @@ Requires: python3 %autosetup -n %{clang_srcdir} -p2 %else -%if ! %{with snapshot_build} +%if %{without snapshot_build} %{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE2}' --data='%{SOURCE1}' %endif %setup -T -q -b 1 -n %{clang_tools_srcdir}