Date: Saturday, November 19, 2022 @ 23:16:48
Author: foutrelis
Revision: 462189
upgpkg: clang 14.0.6-4: backport fix for Chromium 108
Also enable minimal debug info.
Added:
clang/trunk/enforce-instantiation-of-constexpr-template-functions.patch
Modified:
clang/trunk/PKGBUILD
-------------------------------------------------------------+
PKGBUILD | 12 +
enforce-instantiation-of-constexpr-template-functions.patch | 89 ++++++++++
2 files changed, 100 insertions(+), 1 deletion(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2022-11-19 22:31:52 UTC (rev 462188)
+++ PKGBUILD 2022-11-19 23:16:48 UTC (rev 462189)
@@ -3,7 +3,7 @@
pkgname=clang
pkgver=14.0.6
-pkgrel=3
+pkgrel=4
pkgdesc="C language family frontend for LLVM"
arch=('x86_64')
url="https://clang.llvm.org/"
@@ -16,10 +16,12 @@
provides=("clang-analyzer=$pkgver" "clang-tools-extra=$pkgver")
conflicts=('clang-analyzer' 'clang-tools-extra')
replaces=('clang-analyzer' 'clang-tools-extra')
+options=('debug')
_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
source=($_source_base/clang-$pkgver.src.tar.xz{,.sig}
$_source_base/clang-tools-extra-$pkgver.src.tar.xz{,.sig}
$_source_base/llvm-$pkgver.src.tar.xz{,.sig}
+ enforce-instantiation-of-constexpr-template-functions.patch
clang-coroutines-ubsan.patch
clang-tidy-fix-standalone-build.patch
enable-fstack-protector-strong-by-default.patch)
@@ -29,6 +31,7 @@
'SKIP'
'050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
'SKIP'
+ 'eb2916131ae63b3bd1689f6a27dc0c2fadad73a5c5f2c828062c8a2c547e4a0d'
'2c25ddf0ba6be01949842873fef4d285456321aaccd4ba95db61b69a4c580106'
'081a7ebc1ae524b13fc6be3dc73feb2c9eb7cf4b99f7f13d9ed37a688311f58a'
'7a9ce949579a3b02d4b91b6835c4fb45adc5f743007572fb0e28e6433e48f3a5')
@@ -62,6 +65,9 @@
mv "$srcdir/clang-tools-extra-$pkgver.src" tools/extra
patch -Np2 -i ../enable-fstack-protector-strong-by-default.patch
+ # https://github.com/llvm/llvm-project/issues/55560
+ patch -Np2 -i ../enforce-instantiation-of-constexpr-template-functions.patch
+
# https://github.com/llvm/llvm-project/issues/49689
patch -Np2 -i ../clang-coroutines-ubsan.patch
@@ -76,6 +82,10 @@
build() {
cd clang-$pkgver.src/build
+ # Build only minimal debug info to reduce size
+ CFLAGS=${CFLAGS/-g /-g1 }
+ CXXFLAGS=${CXXFLAGS/-g /-g1 }
+
local cmake_args=(
-G Ninja
-DCMAKE_BUILD_TYPE=Release
Added: enforce-instantiation-of-constexpr-template-functions.patch
===================================================================
--- enforce-instantiation-of-constexpr-template-functions.patch
(rev 0)
+++ enforce-instantiation-of-constexpr-template-functions.patch 2022-11-19
23:16:48 UTC (rev 462189)
@@ -0,0 +1,89 @@
+From 2ba4e83e61617daee70f98fcdd76cb8bc3d6ac38 Mon Sep 17 00:00:00 2001
+From: serge-sans-paille <[email protected]>
+Date: Sat, 18 Jun 2022 13:48:41 +0200
+Subject: [PATCH] [clang] Enforce instantiation of constexpr template functions
+ during non-constexpr evaluation
+
+Otherwise these functions are not instantiated and we end up with an undefined
+symbol.
+
+Fix #55560
+
+Differential Revision: https://reviews.llvm.org/D128119
+
+(cherry picked from commit da6a14b91ad999327b41a9040577273591e4ad1d)
+---
+ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 +++--
+ .../CodeGenCXX/constexpr-late-instantiation.cpp | 17 +++++++++++++++++
+ .../SemaCXX/constexpr-late-instantiation.cpp | 15 +++++++++++++++
+ 3 files changed, 35 insertions(+), 2 deletions(-)
+ create mode 100644 clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
+ create mode 100644 clang/test/SemaCXX/constexpr-late-instantiation.cpp
+
+diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+index 467372c71496..293782822e83 100644
+--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
++++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+@@ -4826,7 +4826,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation
PointOfInstantiation,
+ /*Complain*/DefinitionRequired)) {
+ if (DefinitionRequired)
+ Function->setInvalidDecl();
+- else if (TSK == TSK_ExplicitInstantiationDefinition) {
++ else if (TSK == TSK_ExplicitInstantiationDefinition ||
++ (Function->isConstexpr() && !Recursive)) {
+ // Try again at the end of the translation unit (at which point a
+ // definition will be required).
+ assert(!Recursive);
+@@ -4841,7 +4842,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation
PointOfInstantiation,
+ Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
+ if (getLangOpts().CPlusPlus11)
+ Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
+- << Function;
++ << Function;
+ }
+ }
+
+diff --git a/clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
b/clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
+new file mode 100644
+index 000000000000..1c8eef73f2dd
+--- /dev/null
++++ b/clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
+@@ -0,0 +1,17 @@
++// Make sure foo is instantiated and we don't get a link error
++// RUN: %clang_cc1 -S -emit-llvm -triple %itanium_abi_triple %s -o- |
FileCheck %s
++
++template <typename T>
++constexpr T foo(T a);
++
++// CHECK-LABEL: define {{.*}} @main
++int main() {
++ // CHECK: call {{.*}} @_Z3fooIiET_S0_
++ int k = foo<int>(5);
++}
++// CHECK: }
++
++template <typename T>
++constexpr T foo(T a) {
++ return a;
++}
+diff --git a/clang/test/SemaCXX/constexpr-late-instantiation.cpp
b/clang/test/SemaCXX/constexpr-late-instantiation.cpp
+new file mode 100644
+index 000000000000..ec8e071217c1
+--- /dev/null
++++ b/clang/test/SemaCXX/constexpr-late-instantiation.cpp
+@@ -0,0 +1,15 @@
++// RUN: %clang_cc1 %s -fsyntax-only -verify
++
++template <typename T>
++constexpr T foo(T a); // expected-note {{declared here}}
++
++int main() {
++ int k = foo<int>(5); // Ok
++ constexpr int j = // expected-error {{constexpr variable 'j' must be
initialized by a constant expression}}
++ foo<int>(5); // expected-note {{undefined function 'foo<int>'
cannot be used in a constant expression}}
++}
++
++template <typename T>
++constexpr T foo(T a) {
++ return a;
++}