[arch-commits] Commit in clang/trunk (2 files)

Evangelos Foutras foutrelis at gemini.archlinux.org
Thu Feb 24 09:48:53 UTC 2022


    Date: Thursday, February 24, 2022 @ 09:48:53
  Author: foutrelis
Revision: 438061

upgpkg: clang 13.0.1-2: fix CFI in C++17 mode

Fixes Chromium 99 which enabled -std=c++17 (https://crbug.com/1273966).

Added:
  clang/trunk/strip-exception-specifications-in-CFI-type-names.patch
Modified:
  clang/trunk/PKGBUILD

--------------------------------------------------------+
 PKGBUILD                                               |    5 +
 strip-exception-specifications-in-CFI-type-names.patch |   59 +++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2022-02-24 09:32:18 UTC (rev 438060)
+++ PKGBUILD	2022-02-24 09:48:53 UTC (rev 438061)
@@ -3,7 +3,7 @@
 
 pkgname=clang
 pkgver=13.0.1
-pkgrel=1
+pkgrel=2
 pkgdesc="C language family frontend for LLVM"
 arch=('x86_64')
 url="https://clang.llvm.org/"
@@ -21,6 +21,7 @@
         $_source_base/clang-tools-extra-$pkgver.src.tar.xz{,.sig}
         $_source_base/llvm-$pkgver.src.tar.xz{,.sig}
         fix-scan-build-py-executable-lookup-path.patch
+        strip-exception-specifications-in-CFI-type-names.patch
         enable-SSP-and-PIE-by-default.patch)
 sha256sums=('787a9e2d99f5c8720aa1773e4be009461cd30d3bd40fdd24591e473467c917c9'
             'SKIP'
@@ -29,6 +30,7 @@
             'ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
             'SKIP'
             '578b960121c42b8db80566dcb51558409d04455b618cdd608e41b35ded36c13e'
+            '3f4a2784a4c2b2df13e03beb0b66d5805c520f2b9f16ff76e0557daeb284c8fa'
             '67706047fc93a2e79185d344bdac48219ce042c55ddb9b9397bc98db2153ba58')
 validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans at chromium.org>
 validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar at redhat.com>
@@ -62,6 +64,7 @@
   patch -Np2 -i ../enable-SSP-and-PIE-by-default.patch
 
   patch -Np2 -i ../fix-scan-build-py-executable-lookup-path.patch
+  patch -Np2 -i ../strip-exception-specifications-in-CFI-type-names.patch
 
   # Attempt to convert script to Python 3
   2to3 -wn --no-diffs \

Added: strip-exception-specifications-in-CFI-type-names.patch
===================================================================
--- strip-exception-specifications-in-CFI-type-names.patch	                        (rev 0)
+++ strip-exception-specifications-in-CFI-type-names.patch	2022-02-24 09:48:53 UTC (rev 438061)
@@ -0,0 +1,59 @@
+From 0a14674f276b598d23353290635fc62f93e9ab30 Mon Sep 17 00:00:00 2001
+From: Peter Collingbourne <peter at pcc.me.uk>
+Date: Fri, 3 Dec 2021 14:48:57 -0500
+Subject: [PATCH] CodeGen: Strip exception specifications from function types
+ in CFI type names.
+
+With C++17 the exception specification has been made part of the
+function type, and therefore part of mangled type names.
+
+However, it's valid to convert function pointers with an exception
+specification to function pointers with the same argument and return
+types but without an exception specification, which means that e.g. a
+function of type "void () noexcept" can be called through a pointer
+of type "void ()". We must therefore consider the two types to be
+compatible for CFI purposes.
+
+We can do this by stripping the exception specification before mangling
+the type name, which is what this patch does.
+
+Differential Revision: https://reviews.llvm.org/D115015
+---
+ clang/lib/CodeGen/CodeGenModule.cpp          |  5 +++++
+ clang/test/CodeGenCXX/cfi-icall-noexcept.cpp | 11 +++++++++++
+ 2 files changed, 16 insertions(+)
+ create mode 100644 clang/test/CodeGenCXX/cfi-icall-noexcept.cpp
+
+diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
+index 9ba1a5c25e81a..39044617d6774 100644
+--- a/clang/lib/CodeGen/CodeGenModule.cpp
++++ b/clang/lib/CodeGen/CodeGenModule.cpp
+@@ -6398,6 +6398,11 @@ void CodeGenModule::EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
+ llvm::Metadata *
+ CodeGenModule::CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,
+                                             StringRef Suffix) {
++  if (auto *FnType = T->getAs<FunctionProtoType>())
++    T = getContext().getFunctionType(
++        FnType->getReturnType(), FnType->getParamTypes(),
++        FnType->getExtProtoInfo().withExceptionSpec(EST_None));
++
+   llvm::Metadata *&InternalId = Map[T.getCanonicalType()];
+   if (InternalId)
+     return InternalId;
+diff --git a/clang/test/CodeGenCXX/cfi-icall-noexcept.cpp b/clang/test/CodeGenCXX/cfi-icall-noexcept.cpp
+new file mode 100644
+index 0000000000000..eabc4862b4c52
+--- /dev/null
++++ b/clang/test/CodeGenCXX/cfi-icall-noexcept.cpp
+@@ -0,0 +1,11 @@
++// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -emit-llvm -std=c++17 -o - %s | FileCheck %s
++
++// Tests that exception specifiers are stripped when forming the
++// mangled CFI type name.
++
++void f() noexcept {}
++
++// CHECK: define{{.*}} void @_Z1fv({{.*}} !type [[TS1:![0-9]+]] !type [[TS2:![0-9]+]]
++
++// CHECK: [[TS1]] = !{i64 0, !"_ZTSFvvE"}
++// CHECK: [[TS2]] = !{i64 0, !"_ZTSFvvE.generalized"}



More information about the arch-commits mailing list