Date: Thursday, May 27, 2021 @ 03:07:42 Author: foutrelis Revision: 416504
upgpkg: clang 12.0.0-1: new upstream release Build with -fno-semantic-interposition and -Bsymbolic-function for improved performance (FS#70697). Added: clang/trunk/clang-link-with-Bsymbolic-functions.patch clang/trunk/clangd-CompletionModel-cmake.patch clang/trunk/opencl-respect-calling-convention-for-builtin.patch clang/trunk/partially-revert-scan-view-remove-Reporter.py.patch Modified: clang/trunk/PKGBUILD clang/trunk/enable-SSP-and-PIE-by-default.patch -----------------------------------------------------+ PKGBUILD | 29 +- clang-link-with-Bsymbolic-functions.patch | 63 +++++ clangd-CompletionModel-cmake.patch | 66 +++++ enable-SSP-and-PIE-by-default.patch | 126 ++++++---- opencl-respect-calling-convention-for-builtin.patch | 107 ++++++++ partially-revert-scan-view-remove-Reporter.py.patch | 225 ++++++++++++++++++ 6 files changed, 561 insertions(+), 55 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-05-27 02:27:51 UTC (rev 416503) +++ PKGBUILD 2021-05-27 03:07:42 UTC (rev 416504) @@ -2,7 +2,7 @@ # Contributor: Jan "heftig" Steffens <[email protected]> pkgname=clang -pkgver=11.1.0 +pkgver=12.0.0 pkgrel=1 pkgdesc="C language family frontend for LLVM" arch=('x86_64') @@ -20,14 +20,22 @@ source=($_source_base/$pkgname-$pkgver.src.tar.xz{,.sig} $_source_base/clang-tools-extra-$pkgver.src.tar.xz{,.sig} $_source_base/llvm-$pkgver.src.tar.xz{,.sig} + partially-revert-scan-view-remove-Reporter.py.patch + opencl-respect-calling-convention-for-builtin.patch + clangd-CompletionModel-cmake.patch + clang-link-with-Bsymbolic-functions.patch enable-SSP-and-PIE-by-default.patch) -sha256sums=('0a8288f065d1f57cb6d96da4d2965cbea32edc572aa972e466e954d17148558b' +sha256sums=('e26e452e91d4542da3ebbf404f024d3e1cbf103f4cd110c26bf0a19621cca9ed' 'SKIP' - '76707c249de7a9cde3456b960c9a36ed9bbde8e3642c01f0ef61a43d61e0c1a2' + 'ad41e0b527a65ade95c1ba690a5434cefaab4a2daa1be307caaa1e8541fe6d5c' 'SKIP' - 'ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5' + '49dc47c8697a1a0abd4ee51629a696d7bfe803662f2a7252a3b16fc75f3a8b50' 'SKIP' - '248a0e8609b00689e82ce5e05e1de58b7c8ae09a35bbb9625e9069e1f13d2fec') + '68be2fb78e62f76702a156d4c1759b4c6f0d805e1b492e9c6f490ce40862138d' + '859d34dac43999edfc4c33e1cbb6e7458921fa9f16a93514701c1a9706665d24' + '6739abedc8870879618414c5358fda4fcfd4a3ac7a22030ac7c409779b68f669' + '5bc0b47c70990bb8dd0cf4138a8ab9e15cf6b008b7c0cf2c7aac3736b559e0e6' + 'a877fa5cf1c1cca3bd55f9a36cf8c1bdd061ff398aeace90fe3cbd9e82550da3') validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <[email protected]> validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <[email protected]> @@ -58,6 +66,16 @@ mkdir build mv "$srcdir/clang-tools-extra-$pkgver.src" tools/extra patch -Np2 -i ../enable-SSP-and-PIE-by-default.patch + + # Some fixes from the release/12.x branch + patch -Np2 -i ../partially-revert-scan-view-remove-Reporter.py.patch + patch -Np2 -i ../opencl-respect-calling-convention-for-builtin.patch + + # https://bugs.llvm.org/show_bug.cgi?id=49990 + patch -Np2 -d tools/extra <../clangd-CompletionModel-cmake.patch + + # https://bugs.archlinux.org/task/70697 + patch -Np2 -i ../clang-link-with-Bsymbolic-functions.patch } build() { @@ -67,7 +85,6 @@ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr - -DPYTHON_EXECUTABLE=/usr/bin/python -DLLVM_LINK_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON -DLLVM_ENABLE_RTTI=ON Added: clang-link-with-Bsymbolic-functions.patch =================================================================== --- clang-link-with-Bsymbolic-functions.patch (rev 0) +++ clang-link-with-Bsymbolic-functions.patch 2021-05-27 03:07:42 UTC (rev 416504) @@ -0,0 +1,63 @@ +From 4f05f4c8e66bc76b1d94f5283494404382e3bacd Mon Sep 17 00:00:00 2001 +From: Fangrui Song <[email protected]> +Date: Thu, 13 May 2021 13:44:57 -0700 +Subject: [PATCH] [CMake][ELF] Link libLLVM.so and libclang-cpp.so with + -Bsymbolic-functions + +llvm-dev message: https://lists.llvm.org/pipermail/llvm-dev/2021-May/150465.html + +In an ELF shared object, a default visibility defined symbol is preemptible by +default. This creates some missed optimization opportunities. +-Bsymbolic-functions is more aggressive than our current -fvisibility-inlines-hidden +(present since 2012) as it applies to all function definitions. It can + +* avoid PLT for cross-TU function calls && reduce dynamic symbol lookup +* reduce dynamic symbol lookup for taking function addresses and optimize out GOT/TOC on x86-64/ppc64 + +In a -DLLVM_TARGETS_TO_BUILD=X86 build, the number of JUMP_SLOT decreases from 12716 to 1628, and the number of GLOB_DAT decreases from 1918 to 1313 +The built clang with `-DLLVM_LINK_LLVM_DYLIB=on -DCLANG_LINK_CLANG_DYLIB=on` is significantly faster. +See the Linux kernel build result https://bugs.archlinux.org/task/70697 + +Note: the performance of -fno-semantic-interposition -Bsymbolic-functions +libLLVM.so and libclang-cpp.so is close to a PIE binary linking against +`libLLVM*.a` and `libclang*.a`. When the host compiler is Clang, +-Bsymbolic-functions is the major contributor. On x86-64 (with GOTPCRELX) and +ppc64 ELFv2, the GOT/TOC relocations can be optimized. + +Some implication: + +Interposing a subset of functions is no longer supported. +(This is fragile on ELF and unsupported on Mach-O at all. For Mach-O we don't +use `ld -interpose` or `-flat_namespace`) + +Compiling a program which takes the address of any LLVM function with +`{gcc,clang} -fno-pic` and expects the address to equal to the address taken +from libLLVM.so or libclang-cpp.so is unsupported. I am fairly confident that +llvm-project shouldn't have different behaviors depending on such pointer +equality (as we've been using -fvisibility-inlines-hidden which applies to +inline functions for a long time), but if we accidentally do, users should be +aware that they should not make assumption on pointer equality in `-fno-pic` +mode. + +See more on https://maskray.me/blog/2021-05-09-fno-semantic-interposition + +Reviewed By: phosek + +Differential Revision: https://reviews.llvm.org/D102090 +--- + clang/tools/clang-shlib/CMakeLists.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt +index 5949223fc8e3..d08cf8938328 100644 +--- a/clang/tools/clang-shlib/CMakeLists.txt ++++ b/clang/tools/clang-shlib/CMakeLists.txt +@@ -48,3 +48,8 @@ add_clang_library(clang-cpp + ${_OBJECTS} + LINK_LIBS + ${_DEPS}) ++# Optimize function calls for default visibility definitions to avoid PLT and ++# reduce dynamic relocations. ++if (NOT APPLE) ++ target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions) ++endif() Added: clangd-CompletionModel-cmake.patch =================================================================== --- clangd-CompletionModel-cmake.patch (rev 0) +++ clangd-CompletionModel-cmake.patch 2021-05-27 03:07:42 UTC (rev 416504) @@ -0,0 +1,66 @@ +From f51ab1871655a9a96134c2636c37dcb5a6b01ac3 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille <[email protected]> +Date: Mon, 22 Mar 2021 10:05:25 +0100 +Subject: [PATCH] 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. + +Differential Revision: https://reviews.llvm.org/D96787 +--- + 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 60c6d2aa8433..41bc2ed1890b 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) + +From 7907c46fe6195728fafd843b8c0fb19a3e68e9ad Mon Sep 17 00:00:00 2001 +From: Harald van Dijk <[email protected]> +Date: Wed, 5 May 2021 19:25:34 +0100 +Subject: [PATCH] Make clangd CompletionModel not depend on directory layout. + +The current code accounts for two possible layouts, but there is at +least a third supported layout: clang-tools-extra may also be checked +out as clang/tools/extra with the releases, which was not yet handled. +Rather than treating that as a special case, use the location of +CompletionModel.cmake to handle all three cases. This should address the +problems that prompted D96787 and the problems that prompted the +proposed revert D100625. + +Reviewed By: usaxena95 + +Differential Revision: https://reviews.llvm.org/D101851 +--- + clang-tools-extra/clangd/quality/CompletionModel.cmake | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/clang-tools-extra/clangd/quality/CompletionModel.cmake b/clang-tools-extra/clangd/quality/CompletionModel.cmake +index 41bc2ed1890b..dc0c0cde4dab 100644 +--- a/clang-tools-extra/clangd/quality/CompletionModel.cmake ++++ b/clang-tools-extra/clangd/quality/CompletionModel.cmake +@@ -4,8 +4,9 @@ + # ${CMAKE_CURRENT_BINARY_DIR}. The generated header + # will define a C++ class called ${cpp_class} - which may be a + # namespace-qualified class name. ++set(CLANGD_COMPLETION_MODEL_COMPILER ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py) + function(gen_decision_forest model filename cpp_class) +- set(model_compiler ${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py) ++ set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER}) + + set(output_dir ${CMAKE_CURRENT_BINARY_DIR}) + set(header_file ${output_dir}/${filename}.h) Modified: enable-SSP-and-PIE-by-default.patch =================================================================== --- enable-SSP-and-PIE-by-default.patch 2021-05-27 02:27:51 UTC (rev 416503) +++ enable-SSP-and-PIE-by-default.patch 2021-05-27 03:07:42 UTC (rev 416504) @@ -1,6 +1,6 @@ -From bb7bdc61f8a80db9aa16370d9c9fd0ae7be825cc Mon Sep 17 00:00:00 2001 +From 6878f5376dec0a3d75674d5a2076d4af911f7c7c Mon Sep 17 00:00:00 2001 From: Evangelos Foutras <[email protected]> -Date: Mon, 12 Oct 2020 16:40:41 +0300 +Date: Wed, 12 May 2021 08:55:14 +0300 Subject: [PATCH] Enable SSP and PIE by default This is a minimal set of changes needed to make clang use SSP and PIE by @@ -17,26 +17,27 @@ Hopefully these changes will be obsoleted by the introduction upstream of a compile-time option (https://bugs.llvm.org/show_bug.cgi?id=13410) --- - clang/lib/Driver/ToolChains/Linux.cpp | 14 ++++++++++++-- - clang/lib/Driver/ToolChains/Linux.h | 1 + + clang/lib/Driver/ToolChains/Linux.cpp | 10 ++++++++-- + clang/lib/Driver/ToolChains/Linux.h | 5 +++++ clang/test/Driver/cross-linux.c | 16 ++++++++-------- clang/test/Driver/env.c | 2 +- clang/test/Driver/fsanitize.c | 14 +++++++------- clang/test/Driver/gcc-toolchain.cpp | 2 +- clang/test/Driver/hexagon-toolchain-elf.c | 2 +- + clang/test/Driver/hip-fpie-option.hip | 4 ++-- clang/test/Driver/linux-as.c | 4 ++-- clang/test/Driver/linux-ld.c | 2 ++ - clang/test/Driver/ppc-abi.c | 16 +++++++++------- + clang/test/Driver/ppc-abi.c | 18 +++++++++++------- clang/test/Driver/riscv32-toolchain.c | 4 ++-- clang/test/Driver/riscv64-toolchain.c | 4 ++-- clang/test/Driver/stack-protector.c | 4 ++-- - 13 files changed, 50 insertions(+), 35 deletions(-) + 14 files changed, 54 insertions(+), 37 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp -index 180350476c3..119f32ceec6 100644 +index 9663a7390ada..2f8d01092557 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp -@@ -819,8 +819,18 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs, +@@ -832,8 +832,14 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs, } bool Linux::isPIEDefault() const { @@ -50,27 +51,34 @@ + getTriple().isMusl() || getSanitizerArgs().requiresPIE(); + + return true; -+} -+ -+unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { -+ return 2; } bool Linux::isNoExecStackDefault() const { diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h -index 6b16b0e6499..d0024110aef 100644 +index 6b16b0e64990..04c4d176ca71 100644 --- a/clang/lib/Driver/ToolChains/Linux.h +++ b/clang/lib/Driver/ToolChains/Linux.h -@@ -39,6 +39,7 @@ public: +@@ -10,6 +10,7 @@ + #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LINUX_H + + #include "Gnu.h" ++#include "clang/Basic/LangOptions.h" + #include "clang/Driver/ToolChain.h" + + namespace clang { +@@ -39,6 +40,10 @@ public: bool isPIEDefault() const override; bool isNoExecStackDefault() const override; bool IsMathErrnoDefault() const override; -+ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override; ++ LangOptions::StackProtectorMode ++ GetDefaultStackProtectorLevel(bool KernelOrKext) const override { ++ return LangOptions::SSPStrong; ++ } SanitizerMask getSupportedSanitizers() const override; void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; diff --git a/clang/test/Driver/cross-linux.c b/clang/test/Driver/cross-linux.c -index 6c2dab26069..c28c5653e34 100644 +index 6c2dab260695..c28c5653e348 100644 --- a/clang/test/Driver/cross-linux.c +++ b/clang/test/Driver/cross-linux.c @@ -42,8 +42,8 @@ @@ -118,7 +126,7 @@ // CHECK-MULTI64-X86-64: "-L[[gcc_install]]/../../../../x86_64-unknown-linux/lib" // CHECK-MULTI64-X86-64: "-L[[sysroot]]/lib" diff --git a/clang/test/Driver/env.c b/clang/test/Driver/env.c -index 0371bc91c4a..ea89f525121 100644 +index 0371bc91c4a3..ea89f5251217 100644 --- a/clang/test/Driver/env.c +++ b/clang/test/Driver/env.c @@ -20,7 +20,7 @@ @@ -131,10 +139,10 @@ // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c -index 7340bfb35e4..681bb90b50e 100644 +index 8926d55a0cf4..40f628ccae45 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c -@@ -329,15 +329,15 @@ +@@ -330,15 +330,15 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1 // OK @@ -154,7 +162,7 @@ // CHECK-NO-PIE-NOT: "-pie" // CHECK-NO-PIE: "-mrelocation-model" "static" -@@ -662,12 +662,12 @@ +@@ -667,12 +667,12 @@ // RUN: %clang -fno-sanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NOSP // NOSP-NOT: "-fsanitize=safe-stack" @@ -171,7 +179,7 @@ // NO-SP-NOT: stack-protector // NO-SP: "-fsanitize=safe-stack" diff --git a/clang/test/Driver/gcc-toolchain.cpp b/clang/test/Driver/gcc-toolchain.cpp -index 6c872f4255c..f5006d1dd9a 100644 +index 6c872f4255c3..f5006d1dd9ab 100644 --- a/clang/test/Driver/gcc-toolchain.cpp +++ b/clang/test/Driver/gcc-toolchain.cpp @@ -26,6 +26,6 @@ @@ -183,7 +191,7 @@ // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5" // CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.." diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c -index cc11f9fcba9..1fe8b5db587 100644 +index cc11f9fcba9e..1fe8b5db587b 100644 --- a/clang/test/Driver/hexagon-toolchain-elf.c +++ b/clang/test/Driver/hexagon-toolchain-elf.c @@ -487,7 +487,7 @@ @@ -195,8 +203,26 @@ // CHECK042: "-mllvm" "-hexagon-small-data-threshold=8" // CHECK042-NEXT: llvm-mc // CHECK042: "-gpsize=8" +diff --git a/clang/test/Driver/hip-fpie-option.hip b/clang/test/Driver/hip-fpie-option.hip +index 2e296a099dea..86915f1c8c25 100644 +--- a/clang/test/Driver/hip-fpie-option.hip ++++ b/clang/test/Driver/hip-fpie-option.hip +@@ -5,11 +5,11 @@ + + // RUN: %clang -### -target x86_64-unknown-linux-gnu \ + // RUN: --offload-arch=gfx906 %s -nogpulib -nogpuinc \ +-// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s ++// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s + + // RUN: %clang -### -target x86_64-unknown-linux-gnu \ + // RUN: -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \ +-// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s ++// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s + + // RUN: %clang -### -target x86_64-unknown-linux-gnu \ + // RUN: --offload-arch=gfx906 %s -nogpulib -nogpuinc \ diff --git a/clang/test/Driver/linux-as.c b/clang/test/Driver/linux-as.c -index 0959bd7ba0a..4056a672b6f 100644 +index 0959bd7ba0a1..4056a672b6f9 100644 --- a/clang/test/Driver/linux-as.c +++ b/clang/test/Driver/linux-as.c @@ -164,7 +164,7 @@ @@ -218,7 +244,7 @@ // CHECK-SPARCV9PIC: as // CHECK-SPARCV9PIC: -64 diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c -index ec539522c25..caf96020a15 100644 +index 24d3c78643f8..9ea22e6e0f64 100644 --- a/clang/test/Driver/linux-ld.c +++ b/clang/test/Driver/linux-ld.c @@ -1,3 +1,5 @@ @@ -228,10 +254,10 @@ // sysroot to make these tests independent of the host system. // diff --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c -index aef8d8576ad..ec595f4cd96 100644 +index a74a19953ca2..0452661ba5a7 100644 --- a/clang/test/Driver/ppc-abi.c +++ b/clang/test/Driver/ppc-abi.c -@@ -1,9 +1,9 @@ +@@ -1,20 +1,20 @@ // Check passing PowerPC ABI options to the backend. // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ @@ -241,22 +267,25 @@ -// RUN: -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1 %s +// RUN: -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIE %s // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ - // RUN: -mabi=elfv1-qpx | FileCheck -check-prefix=CHECK-ELFv1-QPX %s - // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ -@@ -11,9 +11,9 @@ - // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ - // RUN: -mcpu=a2 -mqpx | FileCheck -check-prefix=CHECK-ELFv1-QPX %s - // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ --// RUN: -mcpu=a2q -mno-qpx | FileCheck -check-prefix=CHECK-ELFv1 %s -+// RUN: -mcpu=a2q -mno-qpx | FileCheck -check-prefix=CHECK-ELFv1-PIE %s - // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ -// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-BE %s +// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-BE-PIE %s // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \ - // RUN: | FileCheck -check-prefix=CHECK-ELFv2 %s -@@ -33,11 +33,13 @@ +-// RUN: | FileCheck -check-prefix=CHECK-ELFv2 %s ++// RUN: | FileCheck -check-prefix=CHECK-ELFv2-PIE %s + // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \ + // RUN: -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-LE %s + // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \ +-// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s ++// RUN: -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIE %s + // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \ +-// RUN: -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s ++// RUN: -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2-PIE %s + // RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s + // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s +@@ -26,10 +26,14 @@ + // CHECK-ELFv1: "-mrelocation-model" "static" // CHECK-ELFv1: "-target-abi" "elfv1" -// CHECK-ELFv1-LE: "-mrelocation-model" "static" @@ -264,19 +293,18 @@ +// CHECK-ELFv1-PIE: "-target-abi" "elfv1" +// CHECK-ELFv1-LE: "-mrelocation-model" "pic" "-pic-level" "2" // CHECK-ELFv1-LE: "-target-abi" "elfv1" --// CHECK-ELFv1-QPX: "-mrelocation-model" "static" -+// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2" - // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx" --// CHECK-ELFv2: "-mrelocation-model" "static" -+// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2" + // CHECK-ELFv2: "-mrelocation-model" "static" // CHECK-ELFv2: "-target-abi" "elfv2" ++// CHECK-ELFv2-PIE: "-mrelocation-model" "pic" "-pic-level" "2" ++// CHECK-ELFv2-PIE: "-target-abi" "elfv2" // CHECK-ELFv2-BE: "-mrelocation-model" "static" // CHECK-ELFv2-BE: "-target-abi" "elfv2" + // CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" diff --git a/clang/test/Driver/riscv32-toolchain.c b/clang/test/Driver/riscv32-toolchain.c -index b83c9aafcbf..15b6f6496b2 100644 +index a5852f5f3997..233d9ef003cf 100644 --- a/clang/test/Driver/riscv32-toolchain.c +++ b/clang/test/Driver/riscv32-toolchain.c -@@ -81,7 +81,7 @@ +@@ -84,7 +84,7 @@ // C-RV32-LINUX-MULTI-ILP32: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot" // C-RV32-LINUX-MULTI-ILP32: "-m" "elf32lriscv" // C-RV32-LINUX-MULTI-ILP32: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32.so.1" @@ -285,7 +313,7 @@ // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib32/ilp32" // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32" // C-RV32-LINUX-MULTI-ILP32: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32" -@@ -96,7 +96,7 @@ +@@ -99,7 +99,7 @@ // C-RV32-LINUX-MULTI-ILP32D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot" // C-RV32-LINUX-MULTI-ILP32D: "-m" "elf32lriscv" // C-RV32-LINUX-MULTI-ILP32D: "-dynamic-linker" "/lib/ld-linux-riscv32-ilp32d.so.1" @@ -295,10 +323,10 @@ // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32d" // C-RV32-LINUX-MULTI-ILP32D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32d" diff --git a/clang/test/Driver/riscv64-toolchain.c b/clang/test/Driver/riscv64-toolchain.c -index 5df069eb9fd..2617551ec35 100644 +index e727f20bb601..a801e5eee462 100644 --- a/clang/test/Driver/riscv64-toolchain.c +++ b/clang/test/Driver/riscv64-toolchain.c -@@ -81,7 +81,7 @@ +@@ -84,7 +84,7 @@ // C-RV64-LINUX-MULTI-LP64: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot" // C-RV64-LINUX-MULTI-LP64: "-m" "elf64lriscv" // C-RV64-LINUX-MULTI-LP64: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64.so.1" @@ -307,7 +335,7 @@ // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/lib64/lp64" // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64" // C-RV64-LINUX-MULTI-LP64: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64" -@@ -96,7 +96,7 @@ +@@ -99,7 +99,7 @@ // C-RV64-LINUX-MULTI-LP64D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot" // C-RV64-LINUX-MULTI-LP64D: "-m" "elf64lriscv" // C-RV64-LINUX-MULTI-LP64D: "-dynamic-linker" "/lib/ld-linux-riscv64-lp64d.so.1" @@ -317,7 +345,7 @@ // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64d" // C-RV64-LINUX-MULTI-LP64D: "-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d" diff --git a/clang/test/Driver/stack-protector.c b/clang/test/Driver/stack-protector.c -index a3e40b50eed..dfffe0d6cf8 100644 +index a3e40b50eed8..dfffe0d6cf85 100644 --- a/clang/test/Driver/stack-protector.c +++ b/clang/test/Driver/stack-protector.c @@ -3,11 +3,11 @@ Added: opencl-respect-calling-convention-for-builtin.patch =================================================================== --- opencl-respect-calling-convention-for-builtin.patch (rev 0) +++ opencl-respect-calling-convention-for-builtin.patch 2021-05-27 03:07:42 UTC (rev 416504) @@ -0,0 +1,107 @@ +From e0fe1c58acfa0bde36afde8354cb31fc1e0b75e2 Mon Sep 17 00:00:00 2001 +From: Luke Drummond <[email protected]> +Date: Wed, 10 Mar 2021 18:14:42 +0000 +Subject: [PATCH] [OpenCL] Respect calling convention for builtin + +`__translate_sampler_initializer` has a calling convention of +`spir_func`, but clang generated calls to it using the default CC. + +Instruction Combining was lowering these mismatching calling conventions +to `store i1* undef` which itself was subsequently lowered to a trap +instruction by simplifyCFG resulting in runtime `SIGILL` + +There are arguably two bugs here: but whether there's any wisdom in +converting an obviously invalid call into a runtime crash over aborting +with a sensible error message will require further discussion. So for +now it's enough to set the right calling convention on the runtime +helper. + +Reviewed By: svenh, bader + +Differential Revision: https://reviews.llvm.org/D98411 + +(cherry picked from commit fcfd3fda71905d7c48f75a531c2265ad3b9876ea) +--- + clang/lib/CodeGen/CodeGenModule.cpp | 12 +++++++----- + clang/test/CodeGenOpenCL/sampler.cl | 12 ++++++------ + 2 files changed, 13 insertions(+), 11 deletions(-) + +diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp +index 31afbc6b4262..9c9bd4e374af 100644 +--- a/clang/lib/CodeGen/CodeGenModule.cpp ++++ b/clang/lib/CodeGen/CodeGenModule.cpp +@@ -6215,15 +6215,17 @@ llvm::SanitizerStatReport &CodeGenModule::getSanStats() { + + return *SanStats; + } ++ + llvm::Value * + CodeGenModule::createOpenCLIntToSamplerConversion(const Expr *E, + CodeGenFunction &CGF) { + llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType()); +- auto SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr()); +- auto FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false); +- return CGF.Builder.CreateCall(CreateRuntimeFunction(FTy, +- "__translate_sampler_initializer"), +- {C}); ++ auto *SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr()); ++ auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false); ++ auto *Call = CGF.Builder.CreateCall( ++ CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C}); ++ Call->setCallingConv(Call->getCalledFunction()->getCallingConv()); ++ return Call; + } + + CharUnits CodeGenModule::getNaturalPointeeTypeAlignment( +diff --git a/clang/test/CodeGenOpenCL/sampler.cl b/clang/test/CodeGenOpenCL/sampler.cl +index e6bda49f51c8..5ad8d0dbbf37 100644 +--- a/clang/test/CodeGenOpenCL/sampler.cl ++++ b/clang/test/CodeGenOpenCL/sampler.cl +@@ -39,7 +39,7 @@ kernel void foo(sampler_t smp_par) { + // Case 2b + sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; + // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %opencl.sampler_t addrspace(2)* +- // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) ++ // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) + // CHECK: store %opencl.sampler_t addrspace(2)* [[SAMP]], %opencl.sampler_t addrspace(2)** [[smp_ptr]] + + // Case 1b +@@ -56,12 +56,12 @@ kernel void foo(sampler_t smp_par) { + + // Case 1a/2a + fnc4smp(glb_smp); +- // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) ++ // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* [[SAMP]]) + + // Case 1a/2c + fnc4smp(glb_smp_const); +- // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) ++ // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* [[SAMP]]) + + // Case 1c +@@ -70,12 +70,12 @@ kernel void foo(sampler_t smp_par) { + // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* [[SAMP]]) + + fnc4smp(5); +- // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5) ++ // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5) + // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* [[SAMP]]) + + const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; + fnc4smp(const_smp); +- // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) ++ // CHECK: [[CONST_SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], %opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]] + fnc4smp(const_smp); + // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]] +@@ -83,7 +83,7 @@ kernel void foo(sampler_t smp_par) { + + constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; + fnc4smp(constant_smp); +- // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) ++ // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* [[SAMP]]) + + // TODO: enable sampler initialization with non-constant integer. Added: partially-revert-scan-view-remove-Reporter.py.patch =================================================================== --- partially-revert-scan-view-remove-Reporter.py.patch (rev 0) +++ partially-revert-scan-view-remove-Reporter.py.patch 2021-05-27 03:07:42 UTC (rev 416504) @@ -0,0 +1,225 @@ +From 3263c81589eca689341ab5084723bdb7fe4a1286 Mon Sep 17 00:00:00 2001 +From: Tom Stellard <[email protected]> +Date: Thu, 11 Feb 2021 22:28:19 +0000 +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. + +Reviewed By: NoQ + +Differential Revision: https://reviews.llvm.org/D96367 + +(cherry picked from commit e3cd3a3c91524c957e06bb0170343548f02b6842) +--- + 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 """\ ++<tr> ++<td class="form_clabel">%s:</td> ++<td class="form_value"><input type="text" name="%s_%s" value="%s"></td> ++</tr>"""%(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 """\ ++<tr> ++<td class="form_clabel">%s:</td><td class="form_value"><select name="%s_%s"> ++%s ++</select></td>"""%(self.getName(),r.getName(),self.getName(),'\n'.join(["""\ ++<option value="%s"%s>%s</option>"""%(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 ++
