From d803ebb6bc095d9fff709cc3b19fc6742adb8a1b Mon Sep 17 00:00:00 2001 From: sergesanspaille Date: Mar 02 2021 13:40:08 +0000 Subject: Rename, cleanup and normalize patch serie --- 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..da7e6cb --- /dev/null +++ b/0001-PATCH-clang-Reorganize-gtest-integration.patch @@ -0,0 +1,42 @@ +From 7475a5bacb2c9dee974199652740d1555eb36e56 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-Partially-Revert-scan-view-Remove-Reporter.py-and-as.patch b/0001-Partially-Revert-scan-view-Remove-Reporter.py-and-as.patch deleted file mode 100644 index 6079e9f..0000000 --- a/0001-Partially-Revert-scan-view-Remove-Reporter.py-and-as.patch +++ /dev/null @@ -1,224 +0,0 @@ -From 9d68d4554d903353a7d4599d2428bd479651eb40 Mon Sep 17 00:00:00 2001 -From: Tom Stellard -Date: Tue, 9 Feb 2021 13:35:43 -0800 -Subject: [PATCH] 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 dd3d33439299..eccc6b83195b 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 000000000000..31a14fb0cf74 ---- /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 -+ --- -2.27.0 - 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-ToolChain-Add-lgcc_s-to-the-linker-flags.patch b/0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch new file mode 100644 index 0000000..5dd8e88 --- /dev/null +++ b/0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch @@ -0,0 +1,51 @@ +From 27000b14439d22145487f55f8a85eb5f8cc98e30 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:08:28 +0100 +Subject: [PATCH 2/6] [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 b2ddef1..c4c71e1 100644 +--- a/clang/lib/Driver/ToolChain.cpp ++++ b/clang/lib/Driver/ToolChain.cpp +@@ -1014,6 +1014,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 4af7d83..ff18c62 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" +-- +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-Make-funwind-tables-the-default-on-all-a.patch b/0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch new file mode 100644 index 0000000..f9a7bba --- /dev/null +++ b/0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch @@ -0,0 +1,40 @@ +From 1622f30ac9ece9171dccb25db8d596ac45b11eee Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 25 Feb 2021 14:09:29 +0100 +Subject: [PATCH 3/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 c4c71e1..d237cc6 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/0004-PATCH-clang-Don-t-install-static-libraries.patch b/0004-PATCH-clang-Don-t-install-static-libraries.patch new file mode 100644 index 0000000..c0f8c05 --- /dev/null +++ b/0004-PATCH-clang-Don-t-install-static-libraries.patch @@ -0,0 +1,25 @@ +From 4dbe9c671f4f15f5fb6bf80428505690e15b7c83 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 31 Jan 2020 11:04:57 -0800 +Subject: [PATCH 4/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/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 new file mode 100644 index 0000000..020b147 --- /dev/null +++ b/0005-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch @@ -0,0 +1,132 @@ +From 00bae317b3ae890a4baab8338696c3c9b0cdc114 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Wed, 23 Sep 2020 12:47:30 +0000 +Subject: [PATCH 5/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/0006-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch b/0006-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch new file mode 100644 index 0000000..a01bc4e --- /dev/null +++ b/0006-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch @@ -0,0 +1,224 @@ +From 4e7dc19c77a609671b2dea81797d79dad1b688c3 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Tue, 9 Feb 2021 13:35:43 -0800 +Subject: [PATCH 6/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/clang.spec b/clang.spec index 164dc3c..8c47965 100644 --- a/clang.spec +++ b/clang.spec @@ -90,13 +90,12 @@ Source4: tstellar-gpg-key.asc Patch21: completion-model-cmake.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 -Patch19: 0001-Partially-Revert-scan-view-Remove-Reporter.py-and-as.patch +Patch4: 0001-PATCH-clang-Reorganize-gtest-integration.patch +Patch11: 0002-PATCH-clang-ToolChain-Add-lgcc_s-to-the-linker-flags.patch +Patch13: 0003-PATCH-clang-Make-funwind-tables-the-default-on-all-a.patch +Patch15: 0004-PATCH-clang-Don-t-install-static-libraries.patch +Patch17: 0005-PATCH-clang-Prefer-gcc-toolchains-with-libgcc_s.so-w.patch +Patch19: 0006-PATCH-clang-Partially-Revert-scan-view-Remove-Report.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -277,11 +276,11 @@ pathfix.py -i %{__python3} -pn \ %setup -q -n %{clang_srcdir} -%patch4 -p1 -b .gtest -%patch11 -p1 -b .libcxx-fix -%patch13 -p1 -b .unwind-default +%patch4 -p2 -b .gtest +%patch11 -p2 -b .libcxx-fix +%patch13 -p2 -b .unwind-default %patch15 -p2 -b .no-install-static -%patch17 -p1 -b .check-gcc_s +%patch17 -p2 -b .check-gcc_s %patch19 -p2 -b .scan-view-remove-files-fix