git: 531a51cc368c - main - devel/llvm13: fix building software with -fstack-protector-strong

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Fri, 22 Oct 2021 12:09:16 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=531a51cc368cf2f53fd21923532964ba96965474

commit 531a51cc368cf2f53fd21923532964ba96965474
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2021-10-22 11:42:37 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2021-10-22 11:42:37 +0000

    devel/llvm13: fix building software with -fstack-protector-strong
    
    Apply https://reviews.llvm.org/D109090
    Fixes immediate segfault when executing binaries built by the port's compiler with -fstack-protector-strong.
    
    Submitted by:   adalava
---
 .../files/patch-llvm_lib_CodeGen_TargetLoweringBase.cpp   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/devel/llvm13/files/patch-llvm_lib_CodeGen_TargetLoweringBase.cpp b/devel/llvm13/files/patch-llvm_lib_CodeGen_TargetLoweringBase.cpp
new file mode 100644
index 000000000000..0323f6d7a13b
--- /dev/null
+++ b/devel/llvm13/files/patch-llvm_lib_CodeGen_TargetLoweringBase.cpp
@@ -0,0 +1,15 @@
+--- llvm/lib/CodeGen/TargetLoweringBase.cpp.orig	2021-09-24 16:18:10 UTC
++++ llvm/lib/CodeGen/TargetLoweringBase.cpp
+@@ -1980,8 +1980,11 @@ void TargetLoweringBase::insertSSPDeclarations(Module 
+     auto *GV = new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false,
+                                   GlobalVariable::ExternalLinkage, nullptr,
+                                   "__stack_chk_guard");
++
++    // FreeBSD has "__stack_chk_guard" defined externally on libc.so
+     if (TM.getRelocationModel() == Reloc::Static &&
+-        !TM.getTargetTriple().isWindowsGNUEnvironment())
++        !TM.getTargetTriple().isWindowsGNUEnvironment() &&
++        !TM.getTargetTriple().isOSFreeBSD())
+       GV->setDSOLocal(true);
+   }
+ }