diff --git a/.gitignore b/.gitignore index 231cd7f..b60ba4b 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,7 @@ /clang-tools-extra-12.0.0rc1.src.tar.xz /clang-tools-extra-12.0.0rc1.src.tar.xz.sig /clang-12.0.0rc1.src.tar.xz.sig +/clang-12.0.0.src.tar.xz +/clang-tools-extra-12.0.0.src.tar.xz +/clang-tools-extra-12.0.0.src.tar.xz.sig +/clang-12.0.0.src.tar.xz.sig diff --git a/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch b/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch deleted file mode 100644 index 05d153d..0000000 --- a/0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch +++ /dev/null @@ -1,133 +0,0 @@ -From 67013ee5feecca0c1e1dd8a149b20779a9b6c12a Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Wed, 23 Sep 2020 12:47:30 +0000 -Subject: [PATCH] Driver: 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. ---- - lib/Driver/ToolChains/Gnu.cpp | 16 ++++++++++++++-- - 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 - test/Driver/linux-ld.c | 12 ++++++++++++ - 6 files changed, 29 insertions(+), 3 deletions(-) - create mode 100644 test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o - create mode 100644 test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o - create mode 100644 test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so - -diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp -index c8a7fce0..f28792b7 100644 ---- a/lib/Driver/ToolChains/Gnu.cpp -+++ b/lib/Driver/ToolChains/Gnu.cpp -@@ -2500,6 +2500,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( - (TargetArch == llvm::Triple::x86 && - TargetTriple.getOS() != llvm::Triple::Solaris)}}; - -+ bool NeedLibgccShared = !Args.hasArg(options::OPT_static_libgcc) && -+ !Args.hasArg(options::OPT_static); - for (auto &Suffix : Suffixes) { - if (!Suffix.Active) - continue; -@@ -2517,8 +2519,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)) -@@ -2532,6 +2543,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( - GCCInstallPath = (LibDir + "/" + LibSuffix + "/" + VersionText).str(); - GCCParentLibPath = (GCCInstallPath + "/../" + Suffix.ReversePath).str(); - IsValid = true; -+ HasLibGccShared = CandidateHasLibGccShared; - } - } - } -diff --git a/lib/Driver/ToolChains/Gnu.h b/lib/Driver/ToolChains/Gnu.h -index 52690ab4..2a4452d9 100644 ---- a/lib/Driver/ToolChains/Gnu.h -+++ b/lib/Driver/ToolChains/Gnu.h -@@ -190,6 +190,7 @@ - /// 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 @@ - 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/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o b/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o -new file mode 100644 -index 00000000..e69de29b -diff --git a/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o b/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/crtbegin.o -new file mode 100644 -index 00000000..e69de29b -diff --git a/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so b/test/Driver/Inputs/fedora_28_tree/usr/lib/gcc/x86_64-redhat-linux/7/libgcc_s.so -new file mode 100644 -index 00000000..e69de29b -diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c -index ec539522..95725d5c 100644 ---- a/test/Driver/linux-ld.c -+++ b/test/Driver/linux-ld.c -@@ -784,6 +784,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.25.2 - diff --git a/0001-Make-funwind-tables-the-default-for-all-archs.patch b/0001-Make-funwind-tables-the-default-for-all-archs.patch deleted file mode 100644 index 0faa229..0000000 --- a/0001-Make-funwind-tables-the-default-for-all-archs.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff -Naur clang-12.0.0rc1.src.orig/lib/Driver/ToolChain.cpp clang-12.0.0rc1.src/lib/Driver/ToolChain.cpp ---- clang-12.0.0rc1.src.orig/lib/Driver/ToolChain.cpp 2021-02-15 21:40:55.000000000 +0100 -+++ clang-12.0.0rc1.src/lib/Driver/ToolChain.cpp 2021-02-16 07:35:01.000000000 +0100 -@@ -257,7 +257,7 @@ - } - - bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const { -- return false; -+ return true; - } - - Tool *ToolChain::getClang() const { -diff -Naur clang-12.0.0rc1.src.orig/lib/Driver/ToolChains/Gnu.cpp clang-12.0.0rc1.src/lib/Driver/ToolChains/Gnu.cpp ---- clang-12.0.0rc1.src.orig/lib/Driver/ToolChains/Gnu.cpp 2021-02-15 21:40:55.000000000 +0100 -+++ clang-12.0.0rc1.src/lib/Driver/ToolChains/Gnu.cpp 2021-02-16 07:35:30.000000000 +0100 -@@ -2713,7 +2713,7 @@ - case llvm::Triple::x86_64: - return true; - default: -- return false; -+ return true; - } - } - diff --git a/0001-PATCH-clang-Reorganize-gtest-integration.patch b/0001-PATCH-clang-Reorganize-gtest-integration.patch new file mode 100644 index 0000000..e854f01 --- /dev/null +++ b/0001-PATCH-clang-Reorganize-gtest-integration.patch @@ -0,0 +1,42 @@ +From c6b921c8d833546946b70a8c2640032fd7c62461 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:04:52 +0100 +Subject: [PATCH 1/6] [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 9e74014..0185276 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -153,12 +153,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + 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 +@@ -537,7 +531,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 +-- +1.8.3.1 + diff --git a/0001-PATCH-clang-tools-extra-Make-clangd-CompletionModel-.patch b/0001-PATCH-clang-tools-extra-Make-clangd-CompletionModel-.patch new file mode 100644 index 0000000..4745e78 --- /dev/null +++ b/0001-PATCH-clang-tools-extra-Make-clangd-CompletionModel-.patch @@ -0,0 +1,31 @@ +From 84e4fe467f290c85b3d7d22c7333d192e1282054 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Wed, 17 Mar 2021 08:32:56 +0100 +Subject: [PATCH] [PATCH][clang-tools-extra] Make clangd CompletionModel usable + even with non-standard (but supported) layout + +llvm supports specifying a non-standard layout where each project lies in its +own place. Do not assume a fixed layout and use the appropriate cmake variable +instead. +--- + clang-tools-extra/clangd/quality/CompletionModel.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/clang-tools-extra/clangd/quality/CompletionModel.cmake b/clang-tools-extra/clangd/quality/CompletionModel.cmake +index 60c6d2a..41bc2ed 100644 +--- a/clang-tools-extra/clangd/quality/CompletionModel.cmake ++++ b/clang-tools-extra/clangd/quality/CompletionModel.cmake +@@ -5,8 +5,8 @@ + # will define a C++ class called ${cpp_class} - which may be a + # namespace-qualified class name. + function(gen_decision_forest model filename cpp_class) +- set(model_compiler ${CMAKE_SOURCE_DIR}/../clang-tools-extra/clangd/quality/CompletionModelCodegen.py) +- ++ set(model_compiler ${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py) ++ + set(output_dir ${CMAKE_CURRENT_BINARY_DIR}) + set(header_file ${output_dir}/${filename}.h) + set(cpp_file ${output_dir}/${filename}.cpp) +-- +1.8.3.1 + diff --git a/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch b/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch deleted file mode 100644 index f4f0fa3..0000000 --- a/0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 09ae3ef5710a89505318ec721c65b6c838147276 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Thu, 7 Feb 2019 21:05:37 -0800 -Subject: [PATCH] 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/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp -index 88a627e..cb99844 100644 ---- a/lib/Driver/ToolChain.cpp -+++ b/lib/Driver/ToolChain.cpp -@@ -767,6 +767,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/test/Driver/netbsd.cpp b/test/Driver/netbsd.cpp -index 4af7d83..ff18c62 100644 ---- a/test/Driver/netbsd.cpp -+++ b/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" --- -1.8.3.1 - diff --git a/0001-clang-Don-t-install-static-libraries.patch b/0001-clang-Don-t-install-static-libraries.patch deleted file mode 100644 index 8c80dd3..0000000 --- a/0001-clang-Don-t-install-static-libraries.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 8097a9d4295dbc39cbd541ccace7bc5884852366 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 704278a0e93..1737b24a2bc 100644 ---- a/clang/cmake/modules/AddClang.cmake -+++ b/clang/cmake/modules/AddClang.cmake -@@ -111,7 +111,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)) - set(export_to_clangtargets) - if(${lib} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR - "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR --- -2.18.1 - diff --git a/0001-clang-Fix-spurious-test-failure.patch b/0001-clang-Fix-spurious-test-failure.patch deleted file mode 100644 index 07c45b6..0000000 --- a/0001-clang-Fix-spurious-test-failure.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5bfce60443b1c3f4066f506e47cbdc7c4263bb10 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Tue, 11 Aug 2020 18:32:08 -0700 -Subject: [PATCH] clang: Fix spurious test failure - ---- - clang/test/Driver/crash-report-modules.m | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/clang/test/Driver/crash-report-modules.m b/clang/test/Driver/crash-report-modules.m -index e6d03353379..9519adf6f4b 100644 ---- a/clang/test/Driver/crash-report-modules.m -+++ b/clang/test/Driver/crash-report-modules.m -@@ -19,7 +19,7 @@ - @import simple; - const int x = MODULE_MACRO; - --// CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script. -+// CHECK: PLEASE submit a bug report to {{.*}}and include the crash backtrace, preprocessed source, and associated run script. - // CHECK: Preprocessed source(s) and associated run script(s) are located at: - // CHECK-NEXT: note: diagnostic msg: {{.*}}.m - // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache --- -2.18.1 - diff --git a/0002-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch b/0002-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch new file mode 100644 index 0000000..0a29dd4 --- /dev/null +++ b/0002-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch @@ -0,0 +1,40 @@ +From 07b062e1f7c3359550aa8c0a7b86f6054971439d Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:09:29 +0100 +Subject: [PATCH 2/6] [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 b2ddef1..715b323 100644 +--- a/clang/lib/Driver/ToolChain.cpp ++++ b/clang/lib/Driver/ToolChain.cpp +@@ -257,7 +257,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 1d8a3cd..5deeb10 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2713,7 +2713,7 @@ bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const { + case llvm::Triple::x86_64: + return true; + default: +- return false; ++ return true; + } + } + +-- +1.8.3.1 + diff --git a/0002-gtest-reorg.patch b/0002-gtest-reorg.patch deleted file mode 100644 index f8edbd3..0000000 --- a/0002-gtest-reorg.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff -Naur clang-12.0.0rc1.src.orig/CMakeLists.txt clang-12.0.0rc1.src/CMakeLists.txt ---- clang-12.0.0rc1.src.orig/CMakeLists.txt 2021-02-14 21:40:31.000000000 +0100 -+++ clang-12.0.0rc1.src/CMakeLists.txt 2021-02-14 21:41:57.000000000 +0100 -@@ -153,12 +153,6 @@ - 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 -@@ -537,7 +531,11 @@ - - - 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 diff --git a/0003-PATCH-clang-Don-t-install-static-libraries.patch b/0003-PATCH-clang-Don-t-install-static-libraries.patch new file mode 100644 index 0000000..82f99a7 --- /dev/null +++ b/0003-PATCH-clang-Don-t-install-static-libraries.patch @@ -0,0 +1,25 @@ +From 2c6cd40d016f492d53e16f1c7424a0d9878ae7ec Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 31 Jan 2020 11:04:57 -0800 +Subject: [PATCH 3/6] [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 704278a..1737b24 100644 +--- a/clang/cmake/modules/AddClang.cmake ++++ b/clang/cmake/modules/AddClang.cmake +@@ -111,7 +111,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)) + set(export_to_clangtargets) + if(${lib} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR + "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR +-- +1.8.3.1 + diff --git a/0004-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch b/0004-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch new file mode 100644 index 0000000..4f2cf39 --- /dev/null +++ b/0004-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch @@ -0,0 +1,132 @@ +From d8af49687765744efaae7ba0f0c4c0fcd58a0e31 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Wed, 23 Sep 2020 12:47:30 +0000 +Subject: [PATCH 4/6] [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 + .../usr/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 5deeb10..5d51517 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2539,6 +2539,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( + (TargetArch == llvm::Triple::x86 && + TargetTriple.getOS() != llvm::Triple::Solaris)}}; + ++ bool NeedLibgccShared = !Args.hasArg(options::OPT_static_libgcc) && ++ !Args.hasArg(options::OPT_static); + for (auto &Suffix : Suffixes) { + if (!Suffix.Active) + continue; +@@ -2556,8 +2558,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)) +@@ -2571,6 +2582,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 90d3baf..9d0cea2 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 0000000..e69de29 +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 0000000..e69de29 +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 0000000..e69de29 +diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c +index 24d3c78..071bb9b 100644 +--- a/clang/test/Driver/linux-ld.c ++++ b/clang/test/Driver/linux-ld.c +@@ -784,6 +784,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="" \ +-- +1.8.3.1 + diff --git a/0005-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch b/0005-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch new file mode 100644 index 0000000..868fe59 --- /dev/null +++ b/0005-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch @@ -0,0 +1,224 @@ +From ea01f898fd74bae23d8be31f1a29b542e886e3a5 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Tue, 9 Feb 2021 13:35:43 -0800 +Subject: [PATCH 5/6] [PATCH][clang] Partially Revert "scan-view: Remove + Reporter.py and associated AppleScript files" + +This reverts some of commit dbb01536f6f49fa428f170e34466072ef439b3e9. + +The Reporter module was still being used by the ScanView.py module and deleting +it caused scan-view to fail. This commit adds back Reporter.py but removes the +code the references the AppleScript files which were removed in +dbb01536f6f49fa428f170e34466072ef439b3e9. + +Differential Revision: https://reviews.llvm.org/D96367 +--- + clang/tools/scan-view/CMakeLists.txt | 1 + + clang/tools/scan-view/share/Reporter.py | 183 ++++++++++++++++++++++++++++++++ + 2 files changed, 184 insertions(+) + create mode 100644 clang/tools/scan-view/share/Reporter.py + +diff --git a/clang/tools/scan-view/CMakeLists.txt b/clang/tools/scan-view/CMakeLists.txt +index dd3d334..eccc6b8 100644 +--- a/clang/tools/scan-view/CMakeLists.txt ++++ b/clang/tools/scan-view/CMakeLists.txt +@@ -5,6 +5,7 @@ set(BinFiles + + set(ShareFiles + ScanView.py ++ Reporter.py + startfile.py + bugcatcher.ico) + +diff --git a/clang/tools/scan-view/share/Reporter.py b/clang/tools/scan-view/share/Reporter.py +new file mode 100644 +index 0000000..31a14fb +--- /dev/null ++++ b/clang/tools/scan-view/share/Reporter.py +@@ -0,0 +1,183 @@ ++#!/usr/bin/env python ++# -*- coding: utf-8 -*- ++ ++"""Methods for reporting bugs.""" ++ ++import subprocess, sys, os ++ ++__all__ = ['ReportFailure', 'BugReport', 'getReporters'] ++ ++# ++ ++class ReportFailure(Exception): ++ """Generic exception for failures in bug reporting.""" ++ def __init__(self, value): ++ self.value = value ++ ++# Collect information about a bug. ++ ++class BugReport(object): ++ def __init__(self, title, description, files): ++ self.title = title ++ self.description = description ++ self.files = files ++ ++# Reporter interfaces. ++ ++import os ++ ++import email, mimetypes, smtplib ++from email import encoders ++from email.message import Message ++from email.mime.base import MIMEBase ++from email.mime.multipart import MIMEMultipart ++from email.mime.text import MIMEText ++ ++#===------------------------------------------------------------------------===# ++# ReporterParameter ++#===------------------------------------------------------------------------===# ++ ++class ReporterParameter(object): ++ def __init__(self, n): ++ self.name = n ++ def getName(self): ++ return self.name ++ def getValue(self,r,bugtype,getConfigOption): ++ return getConfigOption(r.getName(),self.getName()) ++ def saveConfigValue(self): ++ return True ++ ++class TextParameter (ReporterParameter): ++ def getHTML(self,r,bugtype,getConfigOption): ++ return """\ ++ ++%s: ++ ++"""%(self.getName(),r.getName(),self.getName(),self.getValue(r,bugtype,getConfigOption)) ++ ++class SelectionParameter (ReporterParameter): ++ def __init__(self, n, values): ++ ReporterParameter.__init__(self,n) ++ self.values = values ++ ++ def getHTML(self,r,bugtype,getConfigOption): ++ default = self.getValue(r,bugtype,getConfigOption) ++ return """\ ++ ++%s:"""%(self.getName(),r.getName(),self.getName(),'\n'.join(["""\ ++"""%(o[0], ++ o[0] == default and ' selected="selected"' or '', ++ o[1]) for o in self.values])) ++ ++#===------------------------------------------------------------------------===# ++# Reporters ++#===------------------------------------------------------------------------===# ++ ++class EmailReporter(object): ++ def getName(self): ++ return 'Email' ++ ++ def getParameters(self): ++ return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP Port']] ++ ++ # Lifted from python email module examples. ++ def attachFile(self, outer, path): ++ # Guess the content type based on the file's extension. Encoding ++ # will be ignored, although we should check for simple things like ++ # gzip'd or compressed files. ++ ctype, encoding = mimetypes.guess_type(path) ++ if ctype is None or encoding is not None: ++ # No guess could be made, or the file is encoded (compressed), so ++ # use a generic bag-of-bits type. ++ ctype = 'application/octet-stream' ++ maintype, subtype = ctype.split('/', 1) ++ if maintype == 'text': ++ fp = open(path) ++ # Note: we should handle calculating the charset ++ msg = MIMEText(fp.read(), _subtype=subtype) ++ fp.close() ++ else: ++ fp = open(path, 'rb') ++ msg = MIMEBase(maintype, subtype) ++ msg.set_payload(fp.read()) ++ fp.close() ++ # Encode the payload using Base64 ++ encoders.encode_base64(msg) ++ # Set the filename parameter ++ msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(path)) ++ outer.attach(msg) ++ ++ def fileReport(self, report, parameters): ++ mainMsg = """\ ++BUG REPORT ++--- ++Title: %s ++Description: %s ++"""%(report.title, report.description) ++ ++ if not parameters.get('To'): ++ raise ReportFailure('No "To" address specified.') ++ if not parameters.get('From'): ++ raise ReportFailure('No "From" address specified.') ++ ++ msg = MIMEMultipart() ++ msg['Subject'] = 'BUG REPORT: %s'%(report.title) ++ # FIXME: Get config parameters ++ msg['To'] = parameters.get('To') ++ msg['From'] = parameters.get('From') ++ msg.preamble = mainMsg ++ ++ msg.attach(MIMEText(mainMsg, _subtype='text/plain')) ++ for file in report.files: ++ self.attachFile(msg, file) ++ ++ try: ++ s = smtplib.SMTP(host=parameters.get('SMTP Server'), ++ port=parameters.get('SMTP Port')) ++ s.sendmail(msg['From'], msg['To'], msg.as_string()) ++ s.close() ++ except: ++ raise ReportFailure('Unable to send message via SMTP.') ++ ++ return "Message sent!" ++ ++class BugzillaReporter(object): ++ def getName(self): ++ return 'Bugzilla' ++ ++ def getParameters(self): ++ return [TextParameter(x) for x in ['URL','Product']] ++ ++ def fileReport(self, report, parameters): ++ raise NotImplementedError ++ ++ ++class RadarClassificationParameter(SelectionParameter): ++ def __init__(self): ++ SelectionParameter.__init__(self,"Classification", ++ [['1', 'Security'], ['2', 'Crash/Hang/Data Loss'], ++ ['3', 'Performance'], ['4', 'UI/Usability'], ++ ['6', 'Serious Bug'], ['7', 'Other']]) ++ ++ def saveConfigValue(self): ++ return False ++ ++ def getValue(self,r,bugtype,getConfigOption): ++ if bugtype.find("leak") != -1: ++ return '3' ++ elif bugtype.find("dereference") != -1: ++ return '2' ++ elif bugtype.find("missing ivar release") != -1: ++ return '3' ++ else: ++ return '7' ++ ++### ++ ++def getReporters(): ++ reporters = [] ++ reporters.append(EmailReporter()) ++ return reporters ++ +-- +1.8.3.1 + diff --git a/0006-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch b/0006-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch new file mode 100644 index 0000000..91e82b5 --- /dev/null +++ b/0006-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch @@ -0,0 +1,77 @@ +From 1ef1e91142ac48ecb826f33e1e7072c7402d9fe7 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Wed, 3 Mar 2021 09:58:31 +0100 +Subject: [PATCH 6/6] [PATCH][clang] Allow __ieee128 as an alias to __float128 + on ppc + +This matches gcc behavior. + +Differential Revision: https://reviews.llvm.org/D97846 + +(cherry picked from commit 4aa510be78a75a4da82657fe433016f00dad0784) +--- + clang/include/clang/Basic/LangOptions.def | 1 + + clang/lib/Basic/IdentifierTable.cpp | 3 +++ + clang/lib/Basic/Targets/PPC.cpp | 1 + + clang/test/Sema/128bitfloat.cpp | 7 +++++++ + 4 files changed, 12 insertions(+) + +diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def +index c01f0cc..3c22393e 100644 +--- a/clang/include/clang/Basic/LangOptions.def ++++ b/clang/include/clang/Basic/LangOptions.def +@@ -107,6 +107,7 @@ LANGOPT(Bool , 1, 0, "bool, true, and false keywords") + LANGOPT(Half , 1, 0, "half keyword") + LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword") + LANGOPT(Char8 , 1, 0, "char8_t keyword") ++LANGOPT(IEEE128 , 1, 0, "__ieee128 keyword") + LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword") + BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers") + BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode") +diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp +index 51c6e02..cedc94a 100644 +--- a/clang/lib/Basic/IdentifierTable.cpp ++++ b/clang/lib/Basic/IdentifierTable.cpp +@@ -227,6 +227,9 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) { + if (LangOpts.DeclSpecKeyword) + AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this); + ++ if (LangOpts.IEEE128) ++ AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this); ++ + // Add the 'import' contextual keyword. + get("import").setModulesImport(true); + } +diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp +index ff09c0f..38f286c 100644 +--- a/clang/lib/Basic/Targets/PPC.cpp ++++ b/clang/lib/Basic/Targets/PPC.cpp +@@ -551,6 +551,7 @@ void PPCTargetInfo::adjust(LangOptions &Opts) { + LongDoubleFormat = Opts.PPCIEEELongDouble + ? &llvm::APFloat::IEEEquad() + : &llvm::APFloat::PPCDoubleDouble(); ++ Opts.IEEE128 = 1; + } + + ArrayRef PPCTargetInfo::getTargetBuiltins() const { +diff --git a/clang/test/Sema/128bitfloat.cpp b/clang/test/Sema/128bitfloat.cpp +index 4a826b4..6a9ae74 100644 +--- a/clang/test/Sema/128bitfloat.cpp ++++ b/clang/test/Sema/128bitfloat.cpp +@@ -6,6 +6,13 @@ + // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s + + #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) ++ ++#if defined(__ppc__) ++template struct __is_float128 { static constexpr bool value = false; }; ++template <> struct __is_float128<__float128> { static constexpr bool value = true; }; ++static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to __float128"); ++#endif ++ + __float128 f; + template struct __is_floating_point_helper {}; + template<> struct __is_floating_point_helper<__float128> {}; +-- +1.8.3.1 + diff --git a/0007-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch b/0007-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch deleted file mode 100644 index f667694..0000000 --- a/0007-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 7e0b36755d9bcccaddd1c4c1c69b1f12b729cf4e Mon Sep 17 00:00:00 2001 -From: serge-sans-paille -Date: Mon, 15 Mar 2021 09:28:48 +0100 -Subject: [PATCH 7/7] [PATCH][clang] Allow __ieee128 as an alias to __float128 - on ppc - -This matches gcc behavior. - -Backported from https://reviews.llvm.org/D97846 ---- - clang/include/clang/Basic/LangOptions.def | 1 + - clang/lib/Basic/IdentifierTable.cpp | 3 +++ - clang/lib/Basic/Targets/PPC.cpp | 1 + - clang/test/Sema/128bitfloat.cpp | 7 +++++++ - 4 files changed, 12 insertions(+) - -diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def -index c01f0cc..3c22393e 100644 ---- a/clang/include/clang/Basic/LangOptions.def -+++ b/clang/include/clang/Basic/LangOptions.def -@@ -107,6 +107,7 @@ LANGOPT(Bool , 1, 0, "bool, true, and false keywords") - LANGOPT(Half , 1, 0, "half keyword") - LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword") - LANGOPT(Char8 , 1, 0, "char8_t keyword") -+LANGOPT(IEEE128 , 1, 0, "__ieee128 keyword") - LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword") - BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers") - BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode") -diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp -index 51c6e02..cedc94a 100644 ---- a/clang/lib/Basic/IdentifierTable.cpp -+++ b/clang/lib/Basic/IdentifierTable.cpp -@@ -227,6 +227,9 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) { - if (LangOpts.DeclSpecKeyword) - AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this); - -+ if (LangOpts.IEEE128) -+ AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this); -+ - // Add the 'import' contextual keyword. - get("import").setModulesImport(true); - } -diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp -index ff09c0f..38f286c 100644 ---- a/clang/lib/Basic/Targets/PPC.cpp -+++ b/clang/lib/Basic/Targets/PPC.cpp -@@ -551,6 +551,7 @@ void PPCTargetInfo::adjust(LangOptions &Opts) { - LongDoubleFormat = Opts.PPCIEEELongDouble - ? &llvm::APFloat::IEEEquad() - : &llvm::APFloat::PPCDoubleDouble(); -+ Opts.IEEE128 = 1; - } - - ArrayRef PPCTargetInfo::getTargetBuiltins() const { -diff --git a/clang/test/Sema/128bitfloat.cpp b/clang/test/Sema/128bitfloat.cpp -index 4a826b4..6a9ae74 100644 ---- a/clang/test/Sema/128bitfloat.cpp -+++ b/clang/test/Sema/128bitfloat.cpp -@@ -6,6 +6,13 @@ - // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s - - #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) -+ -+#if defined(__ppc__) -+template struct __is_float128 { static constexpr bool value = false; }; -+template <> struct __is_float128<__float128> { static constexpr bool value = true; }; -+static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to __float128"); -+#endif -+ - __float128 f; - template struct __is_floating_point_helper {}; - template<> struct __is_floating_point_helper<__float128> {}; --- -1.8.3.1 - diff --git a/clang-tidy.patch b/clang-tidy.patch deleted file mode 100644 index beb566f..0000000 --- a/clang-tidy.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff -Naur clang-tools-extra-12.0.0rc1.src.orig/unittests/clang-tidy/CMakeLists.txt clang-tools-extra-12.0.0rc1.src/unittests/clang-tidy/CMakeLists.txt ---- clang-tools-extra-12.0.0rc1.src.orig/unittests/clang-tidy/CMakeLists.txt 2021-02-15 11:12:22.000000000 +0100 -+++ clang-tools-extra-12.0.0rc1.src/unittests/clang-tidy/CMakeLists.txt 2021-02-15 17:02:32.000000000 +0100 -@@ -1,9 +1,17 @@ - set(LLVM_LINK_COMPONENTS - FrontendOpenMP - Support -- TestingSupport - ) - -+if(CLANG_BUILT_STANDALONE) -+ # LLVMTestingSupport library is needed for clang-tidy tests. -+ if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support -+ AND NOT TARGET LLVMTestingSupport) -+ add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support -+ lib/Testing/Support) -+ endif() -+endif() -+ - get_filename_component(CLANG_LINT_SOURCE_DIR - ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-tidy REALPATH) - include_directories(${CLANG_LINT_SOURCE_DIR}) -@@ -37,6 +45,7 @@ - clangToolingCore - clangTransformer - ) -+ - target_link_libraries(ClangTidyTests - PRIVATE - clangTidy -@@ -46,4 +55,5 @@ - clangTidyObjCModule - clangTidyReadabilityModule - clangTidyUtils -+ LLVMTestingSupport - ) diff --git a/clang.spec b/clang.spec index 5a33dab..e8128c3 100644 --- a/clang.spec +++ b/clang.spec @@ -1,10 +1,9 @@ -%global compat_build 0 +%bcond_with compat_build %global maj_ver 12 %global min_ver 0 %global patch_ver 0 -%global rc_ver 1 -%global baserelease 3 +#%%global rc_ver 5 %global clang_tools_binaries \ %{_bindir}/clang-apply-replacements \ @@ -36,17 +35,17 @@ %{_bindir}/clang-cl \ %{_bindir}/clang-cpp \ -%if 0%{?compat_build} -%global pkg_name clang%{maj_ver}.%{min_ver} +%if %{with compat_build} +%global pkg_name clang%{maj_ver} # Install clang to same prefix as llvm, so that apps that use llvm-config # will also be able to find clang libs. -%global install_prefix %{_libdir}/llvm%{maj_ver}.%{min_ver} +%global install_prefix %{_libdir}/llvm%{maj_ver} %global install_bindir %{install_prefix}/bin %global install_includedir %{install_prefix}/include %global install_libdir %{install_prefix}/lib %global pkg_bindir %{install_bindir} -%global pkg_includedir %{_includedir}/llvm%{maj_ver}.%{min_ver} +%global pkg_includedir %{install_includedir} %global pkg_libdir %{install_libdir} %else %global pkg_name clang @@ -54,12 +53,6 @@ %global pkg_libdir %{_libdir} %endif -%if 0%{?fedora} || 0%{?rhel} > 7 -%bcond_without python3 -%else -%bcond_with python3 -%endif - %global build_install_prefix %{buildroot}%{install_prefix} %ifarch ppc64le @@ -71,41 +64,40 @@ %global clang_tools_srcdir clang-tools-extra-%{version}%{?rc_ver:rc%{rc_ver}}.src Name: %pkg_name -Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: %{?rc_ver:0.}%{baserelease}%{?rc_ver:.rc%{rc_ver}}%{?dist} +Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}} +Release: 1%{?dist} Summary: A C language family front-end for LLVM License: NCSA URL: http://llvm.org Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_srcdir}.tar.xz Source3: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_srcdir}.tar.xz.sig -%if !0%{?compat_build} +%if %{without compat_build} Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_tools_srcdir}.tar.xz Source2: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}%{?rc_ver:-rc%{rc_ver}}/%{clang_tools_srcdir}.tar.xz.sig %endif Source4: tstellar-gpg-key.asc - -%if !0%{?compat_build} -Patch21: completion-model-cmake.patch -Patch22: clang-tidy.patch +# Patches for clang +Patch0: 0001-PATCH-clang-Reorganize-gtest-integration.patch +Patch1: 0002-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch +Patch2: 0003-PATCH-clang-Don-t-install-static-libraries.patch +Patch3: 0004-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch +Patch4: 0005-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch +Patch5: 0006-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch + +# Patches for clang-tools-extra +%if %{without compat_build} +Patch201: 0001-PATCH-clang-tools-extra-Make-clangd-CompletionModel-.patch %endif -# Not Upstream -Patch4: 0002-gtest-reorg.patch -Patch11: 0001-ToolChain-Add-lgcc_s-to-the-linker-flags-when-using-.patch -Patch13: 0001-Make-funwind-tables-the-default-for-all-archs.patch -Patch15: 0001-clang-Don-t-install-static-libraries.patch -Patch17: 0001-Driver-Prefer-gcc-toolchains-with-libgcc_s.so-when-n.patch -Patch20: 0007-PATCH-clang-Allow-__ieee128-as-an-alias-to-__float12.patch - BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: ninja-build -%if 0%{?compat_build} -BuildRequires: llvm%{maj_ver}.%{min_ver}-devel = %{version} -BuildRequires: llvm%{maj_ver}.%{min_ver}-static = %{version} +%if %{with compat_build} +BuildRequires: llvm%{maj_ver}-devel = %{version} +BuildRequires: llvm%{maj_ver}-static = %{version} %else BuildRequires: llvm-devel = %{version} BuildRequires: llvm-test = %{version} @@ -122,11 +114,8 @@ BuildRequires: ncurses-devel # should BuildRequires: emacs if it packages emacs integration files. BuildRequires: emacs -# These build dependencies are required for the test suite. -%if %with python3 # The testsuite uses /usr/bin/lit which is part of the python3-lit package. BuildRequires: python3-lit -%endif BuildRequires: python3-sphinx BuildRequires: libatomic @@ -134,6 +123,11 @@ BuildRequires: libatomic # We need python3-devel for pathfix.py. BuildRequires: python3-devel +# For reproducible pyc file generation +# See https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_Appendix/#_byte_compilation_reproducibility +BuildRequires: /usr/bin/marshalparser +%global py_reproducible_pyc_path %{buildroot}%{python3_sitelib} + # Needed for %%multilib_fix_c_header BuildRequires: multilib-rpm-config @@ -195,7 +189,7 @@ Runtime library for clang. %package devel Summary: Development header files for clang -%if !0%{?compat_build} +%if %{without compat_build} Requires: %{name}%{?_isa} = %{version}-%{release} # The clang CMake files reference tools from clang-tools-extra. Requires: %{name}-tools-extra%{?_isa} = %{version}-%{release} @@ -212,7 +206,7 @@ Provides: %{name}-resource-filesystem(major) = %{maj_ver} %description resource-filesystem This package owns the clang resouce directory: $libdir/clang/$version/ -%if !0%{?compat_build} +%if %{without compat_build} %package analyzer Summary: A source code analysis framework License: NCSA and MIT @@ -260,32 +254,23 @@ Requires: python3 %prep %{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE3}' --data='%{SOURCE0}' -%if 0%{?compat_build} -%autosetup -n %{clang_srcdir} -p1 +%if %{with compat_build} +%autosetup -n %{clang_srcdir} -p2 %else %{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE2}' --data='%{SOURCE1}' %setup -T -q -b 1 -n %{clang_tools_srcdir} -%patch21 -p1 -b .comp-model -%patch22 -p1 -b .clang-tidy +%autopatch -m200 -p2 # failing test case rm test/clang-tidy/checkers/altera-struct-pack-align.cpp - pathfix.py -i %{__python3} -pn \ clang-tidy/tool/*.py \ clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py %setup -q -n %{clang_srcdir} - -%patch4 -p1 -b .gtest -%patch11 -p1 -b .libcxx-fix -%patch13 -p1 -b .unwind-default -%patch15 -p2 -b .no-install-static -%patch17 -p1 -b .check-gcc_s -%patch20 -p2 -b .ieee128 - +%autopatch -M200 -p2 # failing test case rm test/CodeGen/profile-filter.c @@ -336,8 +321,9 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ %endif -%if 0%{?compat_build} - -DLLVM_CONFIG:FILEPATH=%{_bindir}/llvm-config-%{maj_ver}.%{min_ver}-%{__isa_bits} \ +%if %{with compat_build} + -DCLANG_BUILD_TOOLS:BOOL=OFF \ + -DLLVM_CONFIG:FILEPATH=%{_bindir}/llvm-config-%{maj_ver}-%{__isa_bits} \ -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ -DCLANG_INCLUDE_TESTS:BOOL=OFF \ %else @@ -352,10 +338,10 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py %endif %endif \ -%if !0%{compat_build} - -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen \ +%if %{with compat_build} + -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen-%{maj_ver} \ %else - -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen-%{maj_ver}.%{min_ver} \ + -DLLVM_TABLEGEN_EXE:FILEPATH=%{_bindir}/llvm-tblgen \ %endif -DCLANG_ENABLE_ARCMT:BOOL=ON \ -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \ @@ -371,7 +357,8 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \ -DBUILD_SHARED_LIBS=OFF \ - -DCLANG_REPOSITORY_STRING="%{?fedora:Fedora}%{?rhel:Red Hat} %{version}-%{release}" + -DCLANG_REPOSITORY_STRING="%{?fedora:Fedora}%{?rhel:Red Hat} %{version}-%{release}" \ + -DCLANG_DEFAULT_UNWINDLIB=libgcc %cmake_build @@ -379,7 +366,7 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py %cmake_install -%if 0%{?compat_build} +%if %{with compat_build} # Remove binaries/other files rm -Rf %{buildroot}%{install_bindir} @@ -449,8 +436,11 @@ mkdir -p %{buildroot}%{_libdir}/clang/%{version}/{include,lib,share}/ # Remove clang-tidy headers. We don't ship the libraries for these. rm -Rvf %{buildroot}%{_includedir}/clang-tidy/ +# Add a symlink in /usr/bin to clang-format-diff +ln -s %{_datadir}/clang/clang-format-diff.py %{buildroot}%{_bindir}/clang-format-diff + %check -%if !0%{?compat_build} +%if %{without compat_build} # requires lit.py from LLVM utilities # FIXME: Fix failing ARM tests LD_LIBRARY_PATH=%{buildroot}/%{_libdir} %cmake_build --target check-all || \ @@ -463,7 +453,7 @@ false %endif -%if !0%{?compat_build} +%if %{without compat_build} %files %license LICENSE.TXT %{clang_binaries} @@ -474,7 +464,7 @@ false %endif %files libs -%if !0%{?compat_build} +%if %{without compat_build} %{_libdir}/clang/ %{_libdir}/*.so.* %else @@ -483,7 +473,7 @@ false %endif %files devel -%if !0%{?compat_build} +%if %{without compat_build} %{_libdir}/*.so %{_includedir}/clang/ %{_includedir}/clang-c/ @@ -501,11 +491,11 @@ false %dir %{pkg_libdir}/clang/%{version}/include/ %dir %{pkg_libdir}/clang/%{version}/lib/ %dir %{pkg_libdir}/clang/%{version}/share/ -%if !0%{?compat_build} +%if %{without compat_build} %{pkg_libdir}/clang/%{maj_ver} %endif -%if !0%{?compat_build} +%if %{without compat_build} %files analyzer %{_bindir}/scan-view %{_bindir}/scan-build @@ -520,6 +510,7 @@ false %{_bindir}/c-index-test %{_bindir}/find-all-symbols %{_bindir}/modularize +%{_bindir}/clang-format-diff %{_mandir}/man1/diagtool.1.gz %{_emacs_sitestartdir}/clang-format.el %{_emacs_sitestartdir}/clang-rename.el @@ -541,12 +532,44 @@ false %endif %changelog -* Tue Mar 30 2021 Jonathan Wakely - 12.0.0-0.3.rc1 -- Rebuilt for removed libstdc++ symbol (#1937698) +* Fri Apr 16 2021 Tom Stellard - 12.0.0-1 +- 12.0.0 Release + +* Wed Apr 14 2021 Tom Stellard - 12.0.0-0.12.rc5 +- Add symlink to clang-format-diff in /usr/bin +- rhbz#1939018 + +* Thu Apr 08 2021 sguelton@redhat.com - 12.0.0-0.11.rc5 +- New upstream release candidate + +* Sat Apr 03 2021 sguelton@redhat.com - 12.0.0-0.10.rc4 +- Make pyc files from python3-clang reproducible + +* Fri Apr 02 2021 sguelton@redhat.com - 12.0.0-0.9.rc4 +- New upstream release candidate + +* Wed Mar 31 2021 Jonathan Wakely - 12.0.0-0.8.rc3 +- Rebuilt for removed libstdc++ symbols (#1937698) -* Mon Mar 15 2021 sguelton@redhat.com - 12.0.0-0.2.rc1 +* Mon Mar 15 2021 sguelton@redhat.com - 12.0.0-0.7.rc3 - Apply patch D97846 to fix rhbz#1934065 +* Mon Mar 15 2021 Timm Bäder 12.0.0-0.6.rc3 +- Set CLANG_DEFAULT_UNWIND_LIB instead of using custom patch +- Add toolchains test to the tests.yml + +* Thu Mar 11 2021 sguelton@redhat.com - 12.0.0-0.5.rc3 +- LLVM 12.0.0 rc3 + +* Tue Mar 09 2021 sguelton@redhat.com - 12.0.0-0.4.rc2 +- rebuilt + +* Mon Mar 01 2021 sguelton@redhat.com - 12.0.0-0.3.rc2 +- Reapply some wrongly removed patch + +* Wed Feb 24 2021 sguelton@redhat.com - 12.0.0-0.2.rc2 +- 12.0.0-rc2 release + * Sun Feb 14 2021 sguelton@redhat.com - 12.0.0-0.1.rc1 - 12.0.0-rc1 release diff --git a/completion-model-cmake.patch b/completion-model-cmake.patch deleted file mode 100644 index 925294d..0000000 --- a/completion-model-cmake.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -Naur clang-tools-extra-12.0.0rc1.src.orig/clangd/quality/CompletionModel.cmake clang-tools-extra-12.0.0rc1.src/clangd/quality/CompletionModel.cmake ---- clang-tools-extra-12.0.0rc1.src.orig/clangd/quality/CompletionModel.cmake 2021-02-14 17:03:14.000000000 +0100 -+++ clang-tools-extra-12.0.0rc1.src/clangd/quality/CompletionModel.cmake 2021-02-14 20:57:51.000000000 +0100 -@@ -5,8 +5,8 @@ - # will define a C++ class called ${cpp_class} - which may be a - # namespace-qualified class name. - function(gen_decision_forest model filename cpp_class) -- set(model_compiler ${CMAKE_SOURCE_DIR}/../clang-tools-extra/clangd/quality/CompletionModelCodegen.py) -- -+ set(model_compiler ${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py) -+ - set(output_dir ${CMAKE_CURRENT_BINARY_DIR}) - set(header_file ${output_dir}/${filename}.h) - set(cpp_file ${output_dir}/${filename}.cpp) diff --git a/sources b/sources index 16e84c4..a2663ed 100644 --- a/sources +++ b/sources @@ -1,4 +1,4 @@ -SHA512 (clang-12.0.0rc1.src.tar.xz) = ffde0f500926e3bb40c9565e013ae73f488ecf3ffea28a1a14c366d12fddc9a399d126cb8af1b42565cc8c32fdcc6d8f5056fd31dd6e104dad2b856cda19009e -SHA512 (clang-tools-extra-12.0.0rc1.src.tar.xz) = 5c7dd5a5fc287513f281db66963101452a5463454393c554f4af043f99737b49110f3d0e07932e99a329f904175c236d31063c2c86b1f9f679c75fb55db0fab3 -SHA512 (clang-tools-extra-12.0.0rc1.src.tar.xz.sig) = 7e63da5b1f2df71d2378a7bff02eb8976a40ff4a106cb775a022b305d2847282d0c5865413ca77e41785c63cf90e11a9b9f2838b148febd1f9e0eea048d1102c -SHA512 (clang-12.0.0rc1.src.tar.xz.sig) = 4afb9effe6417a5c1d03189aff9c8cf3af49a317504b0d09c4c3242627f92c9b27a0291346ee547541fe8c00f36075f3b47b3572eaa8a6174854a3d2505348b3 +SHA512 (clang-12.0.0.src.tar.xz) = f5613b9bffc962467d3bedb7f66b4e057e2781eb63c5dadfd3cf0b02453e29eff0a4f844889031292f06a8b4c081d4d41c515b7f719826ce5c4209a09df9f1f6 +SHA512 (clang-tools-extra-12.0.0.src.tar.xz) = e0323a2506da748b5de32a3df53a987f3f74184c2d02d4e7b173e23e54396427e2d9b6600a7962795020bfc2c0dae16b210a69a4b8784086d1470d88f423c330 +SHA512 (clang-tools-extra-12.0.0.src.tar.xz.sig) = 30afa9c2411417c30a47dcdcfe97ebf353ad1de1a98ed82d45bdfb3fafc30dcb335f6fd18ff3b44e2ed34ff5137932e3a4675289242712df01b8b6da8877fcef +SHA512 (clang-12.0.0.src.tar.xz.sig) = 9780c2f68dfd7ea633dd137dda265ffda6425be658b0724e25dadb6abc54d3368e7850687ce38f4c3bf0c7049a2c1bd2fb299cec5f548c38f3bc4ca1f8877437 diff --git a/tests/clang-format-diff/runtest.sh b/tests/clang-format-diff/runtest.sh new file mode 100755 index 0000000..d27ee13 --- /dev/null +++ b/tests/clang-format-diff/runtest.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -ex + +# Check that clang-format-diff is in PATH. +# rhbz#1939018 +clang-format-diff -h diff --git a/tests/fedora-flags/hello.c b/tests/fedora-flags/hello.c new file mode 100644 index 0000000..51b259b --- /dev/null +++ b/tests/fedora-flags/hello.c @@ -0,0 +1,5 @@ +#include + +void hello() { + printf("Hello World\n"); +} diff --git a/tests/fedora-flags/hello.cpp b/tests/fedora-flags/hello.cpp new file mode 100644 index 0000000..400612b --- /dev/null +++ b/tests/fedora-flags/hello.cpp @@ -0,0 +1,5 @@ +#include + +void hello() { + std::cout << "Hello World\n"; +} diff --git a/tests/fedora-flags/main.c b/tests/fedora-flags/main.c new file mode 100644 index 0000000..1a3455d --- /dev/null +++ b/tests/fedora-flags/main.c @@ -0,0 +1,6 @@ +void hello(); + +int main(int argc, char **argv) { + hello(); + return 0; +} diff --git a/tests/fedora-flags/main.cpp b/tests/fedora-flags/main.cpp new file mode 100644 index 0000000..1a3455d --- /dev/null +++ b/tests/fedora-flags/main.cpp @@ -0,0 +1,6 @@ +void hello(); + +int main(int argc, char **argv) { + hello(); + return 0; +} diff --git a/tests/fedora-flags/runtest.sh b/tests/fedora-flags/runtest.sh new file mode 100755 index 0000000..96d1cc8 --- /dev/null +++ b/tests/fedora-flags/runtest.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -ex pipefail + +cflags=`rpm -D '%toolchain clang' -E %{build_cflags}` +cxxflags=`rpm -D '%toolchain clang' -E %{build_cxxflags}` +ldflags=`rpm -D '%toolchain clang' -E %{build_ldflags}` + + +# Test a c program +clang $cflags -c hello.c -o hello.o +clang $cflags -c main.c -o main.o +clang $ldflags -o hello main.o hello.o +./hello | grep "Hello World" + +# Test a cxx program +clang++ $cxxflags -c hello.cpp -o hello-cpp.o +clang++ $cxxflags -c main.cpp -o main-cpp.o +clang++ $ldflags -o hello-cpp main-cpp.o hello-cpp.o +./hello-cpp | grep "Hello World" diff --git a/tests/libomp/openmp-compile-link-test.c b/tests/libomp/openmp-compile-link-test.c new file mode 100644 index 0000000..a2b6004 --- /dev/null +++ b/tests/libomp/openmp-compile-link-test.c @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char **argv) { + int nthreads = omp_get_num_threads(); + printf("Num Threads: %d\n", nthreads); + return 0; +} diff --git a/tests/libomp/runtest.sh b/tests/libomp/runtest.sh new file mode 100755 index 0000000..f07dbbc --- /dev/null +++ b/tests/libomp/runtest.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -exo pipefail + +clang -fopenmp openmp-compile-link-test.c + +./a.out | grep "Num Threads: 1" diff --git a/tests/llvm-toolchain/runtest.sh b/tests/llvm-toolchain/runtest.sh new file mode 100755 index 0000000..eeebda5 --- /dev/null +++ b/tests/llvm-toolchain/runtest.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Tests for using a full LLVM toolchain: clang + compiler-rt + libcxx + lld + +set -ex pipefail + +# Test compile a C program. +cat << EOF | \ + clang -fuse-ld=lld -rtlib=compiler-rt -x c - && \ + ./a.out | grep 'Hello World' + +#include +int main(int argc, char **argv) { + printf("Hello World\n"); + return 0; +} +EOF + +# Test compile a C++ program. +cat << EOF | \ + clang++ -x c++ -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ - && \ + ./a.out | grep 'Hello World' + +#include +int main(int argc, char **argv) { + std::cout << "Hello World\n"; + return 0; +} +EOF diff --git a/tests/rhbz_1647130/runtest.sh b/tests/rhbz_1647130/runtest.sh new file mode 100755 index 0000000..ab515c7 --- /dev/null +++ b/tests/rhbz_1647130/runtest.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +set -x + +tmp_cpp=`mktemp -t XXXXX.cpp` +tmp_dir=`mktemp -d` +echo 'int main(int argc, char*argv[]) { while(argc--) new int(); return 0; }' > $tmp_cpp +scan-build -o $tmp_dir clang++ -c $tmp_cpp -o /dev/null +(scan-view --no-browser $tmp_dir/* & WPID=$! && sleep 10s && kill $WPID) + diff --git a/tests/rhbz_1657544/from_chars.cpp b/tests/rhbz_1657544/from_chars.cpp new file mode 100644 index 0000000..b76be22 --- /dev/null +++ b/tests/rhbz_1657544/from_chars.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +using namespace std; + +int main(int argc, char **argv) +{ + size_t r=0; + const char *begin = argv[1]; + const char *end = begin + strlen(begin); + from_chars(begin, end, r); + cout << r << '\n'; + return 0; +} diff --git a/tests/rhbz_1657544/runtest.sh b/tests/rhbz_1657544/runtest.sh new file mode 100755 index 0000000..758de0b --- /dev/null +++ b/tests/rhbz_1657544/runtest.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +set -x + +clang++ from_chars.cpp +./a.out 100 | grep 100 diff --git a/tests/tests-libomp.yml b/tests/tests-libomp.yml index b43e4be..a9db418 100644 --- a/tests/tests-libomp.yml +++ b/tests/tests-libomp.yml @@ -15,10 +15,7 @@ - role: standard-test-basic tags: - classic - repositories: - - repo: "https://src.fedoraproject.org/tests/clang.git" - dest: "clang" required_packages: - clang tests: - - clang/libomp + - libomp diff --git a/tests/tests.yml b/tests/tests.yml index b00ddb7..c720883 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -17,25 +17,29 @@ - lld - compiler-rt - libcxx-devel + - libcxx-static - glibc-devel + - glibc-static - gcc # Required for fedora-flags: - annobin - redhat-rpm-config + # Required for clang-format-diff + - clang-tools-extra repositories: - - repo: "https://src.fedoraproject.org/tests/llvm-test-suite.git" + - repo: "https://src.fedoraproject.org/rpms/llvm-test-suite.git" dest: "llvm-test-suite" - - repo: "https://src.fedoraproject.org/tests/clang.git" - dest: "clang" tests: - rhbz#482491: dir: ./ run: find /usr -name 'libgcc_s.so*' && echo "int main(){}" | clang -v -x c - - - llvm-test-suite/test-suite + - llvm-test-suite/tests/test-suite # ABI test suite is too greedy on the FS #- llvm-test-suite/abi-test-suite - - clang/rhbz_1657544 - - clang/rhbz_1647130 - - clang/llvm-toolchain - - clang/fedora-flags + - rhbz_1657544 + - rhbz_1647130 + - llvm-toolchain + - fedora-flags + - toolchains + - clang-format-diff diff --git a/tests/testspocl.yml b/tests/testspocl.yml index 01bcd5b..7189eac 100644 --- a/tests/testspocl.yml +++ b/tests/testspocl.yml @@ -17,7 +17,7 @@ tags: - classic repositories: - - repo: "https://src.fedoraproject.org/tests/pocl.git" + - repo: "https://src.fedoraproject.org/rpms/pocl.git" dest: "pocl" required_packages: - ocl-icd-devel @@ -25,4 +25,4 @@ - gcc tests: # rhbz#1582884 - - pocl/simple-opencl-no-clang: + - pocl/tests/simple-opencl-no-clang diff --git a/tests/toolchains/hello.c b/tests/toolchains/hello.c new file mode 100644 index 0000000..f5c80a9 --- /dev/null +++ b/tests/toolchains/hello.c @@ -0,0 +1,5 @@ +#include +int main(int argc, char **argv) { + printf("Hello World\n"); + return 0; +} diff --git a/tests/toolchains/hello.cpp b/tests/toolchains/hello.cpp new file mode 100644 index 0000000..bda4087 --- /dev/null +++ b/tests/toolchains/hello.cpp @@ -0,0 +1,5 @@ +#include +int main(int argc, char **argv) { + std::cout << "Hello World\n"; + return 0; +} diff --git a/tests/toolchains/runtest.sh b/tests/toolchains/runtest.sh new file mode 100755 index 0000000..c928ae4 --- /dev/null +++ b/tests/toolchains/runtest.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +set pipefail + +status=0 + +test_toolchain() { + + toolchain=$@ + args="" + + while [ $# -gt 0 ]; do + case $1 in + clang) + compiler=$1 + src=hello.c + ;; + clang++) + compiler=$1 + src=hello.cpp + ;; + compiler-rt) + args="$args -rtlib=$1" + ;; + libc++) + args="$args -stdlib=$1" + ;; + lld) + args="$args -fuse-ld=$1" + ;; + *) + args="$args $1" + ;; + esac + shift + done + + cmd="$compiler $args $src" + rm -f a.out + echo "* $toolchain" + echo " command: $cmd" + if $cmd && ./a.out | grep -q 'Hello World'; then + echo " PASS" + else + echo " FAIL" + status=1 + fi +} + +clang --version +dnf info installed clang | grep ^Source +echo "" + +for compiler in clang clang++; do + for rtlib in "" compiler-rt; do + for linker in "" lld; do + for cxxlib in "" libc++; do + if [ "$compiler" = "clang" -a -n "$cxxlib" ]; then + continue + fi + for args in "" -static; do + # Skip known failures + # TODO: Fix these + if [[ "$args" = "-static" && "$rtlib" = "compiler-rt" ]]; then + continue + fi + + # Static libc++ needs -pthread + if [[ "$args" = "-static" && "$cxxlib" = "libc++" ]]; then + args="$args -pthread" + fi + + test_toolchain $compiler $rtlib $linker $cxxlib $args + done + done + done + done +done + +exit $status