git: 7375f3899ae9 - main - lang/gcc11-devel: Fix Address sanitizer

From: Lorenzo Salvadore <salvadore_at_FreeBSD.org>
Date: Sat, 26 Nov 2022 15:04:37 UTC
The branch main has been updated by salvadore:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7375f3899ae994888d48e099476d4a6aabf310b2

commit 7375f3899ae994888d48e099476d4a6aabf310b2
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2022-11-23 22:35:46 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2022-11-26 15:01:55 +0000

    lang/gcc11-devel: Fix Address sanitizer
    
    Software compiled with -fsanitize=address fails to run with the error
    message "ASan runtime does not come first in initial library list; you
    should either link runtime to your application or manually preload it
    with LD_PRELOAD".
    
    This commit fixes the issue by ignoring the [vdso] loaded shared library
    instead of linux-vdso.so.
    
    PR:             267751
    Reported by:    yuri
---
 lang/gcc11-devel/Makefile                              |  1 +
 .../files/patch-libsanitizer_asan_asan__linux.cpp      | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/lang/gcc11-devel/Makefile b/lang/gcc11-devel/Makefile
index 3592ae4d1962..cde3eccb4a71 100644
--- a/lang/gcc11-devel/Makefile
+++ b/lang/gcc11-devel/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	gcc
 PORTVERSION=	11.3.1.s20221118
+PORTREVISION=	1
 CATEGORIES=	lang
 MASTER_SITES=	GCC/snapshots/${DIST_VERSION}
 PKGNAMESUFFIX=	${SUFFIX}-devel
diff --git a/lang/gcc11-devel/files/patch-libsanitizer_asan_asan__linux.cpp b/lang/gcc11-devel/files/patch-libsanitizer_asan_asan__linux.cpp
new file mode 100644
index 000000000000..22630767b114
--- /dev/null
+++ b/lang/gcc11-devel/files/patch-libsanitizer_asan_asan__linux.cpp
@@ -0,0 +1,18 @@
+Since the vDSO shared librares on Linux and FreeBSD are called
+differently, the initialization order check fails on FreeBSD.
+This patch fixes it by ignoring [vdso] instead of linux-vdso.so.
+
+GCC gets the original file from the LLVM Project, so this patch should
+probably be upstreamed directly to the LLVM Project rather than to GCC.
+
+--- libsanitizer/asan/asan_linux.cpp.orig	2022-11-23 10:52:45 UTC
++++ libsanitizer/asan/asan_linux.cpp
+@@ -135,7 +135,7 @@ static int FindFirstDSOCallback(struct dl_phdr_info *i
+     return 0;
+ 
+   // Ignore vDSO
+-  if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
++  if (internal_strncmp(info->dlpi_name, "[vdso]", sizeof("[vdso]") - 1) == 0)
+     return 0;
+ 
+ #if SANITIZER_FREEBSD || SANITIZER_NETBSD