git: c3ff309608cf - main - devel/google-perftools: Add LD_32_PRELOAD to the valgrind detection code

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Sun, 21 Nov 2021 18:29:18 UTC
The branch main has been updated by yuri:

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

commit c3ff309608cf29a11b0985a6e50e7924ff280c0c
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2021-11-21 18:25:53 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2021-11-21 18:29:16 +0000

    devel/google-perftools: Add LD_32_PRELOAD to the valgrind detection code
    
    Suggested by:   Paul Floyd <pjfloyd@wanadoo.fr>
---
 devel/google-perftools/Makefile                                    | 2 +-
 devel/google-perftools/files/patch-src_base_dynamic__annotations.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/devel/google-perftools/Makefile b/devel/google-perftools/Makefile
index f8b0d79c6900..303c5d6cc575 100644
--- a/devel/google-perftools/Makefile
+++ b/devel/google-perftools/Makefile
@@ -3,7 +3,7 @@
 PORTNAME=	google-perftools
 DISTVERSIONPREFIX=	gperftools-
 DISTVERSION=	2.9.1
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	devel
 MASTER_SITES=	https://github.com/gperftools/gperftools/releases/download/gperftools-${PORTVERSION}/
 DISTNAME=	gperftools-${PORTVERSION}
diff --git a/devel/google-perftools/files/patch-src_base_dynamic__annotations.c b/devel/google-perftools/files/patch-src_base_dynamic__annotations.c
index e02b1a5f5afe..3850e05461a5 100644
--- a/devel/google-perftools/files/patch-src_base_dynamic__annotations.c
+++ b/devel/google-perftools/files/patch-src_base_dynamic__annotations.c
@@ -3,13 +3,15 @@
 
 --- src/base/dynamic_annotations.c.orig	2021-02-15 06:44:21 UTC
 +++ src/base/dynamic_annotations.c
-@@ -43,6 +43,19 @@
+@@ -43,6 +43,21 @@
  #include "base/dynamic_annotations.h"
  #include "getenv_safe.h" // for TCMallocGetenvSafe
  
 +static int running_on_valgrind_preload = -1;
 +void __attribute__ ((constructor)) premain() {
 +  char *LD_PRELOAD = getenv("LD_PRELOAD");
++  if (LD_PRELOAD == NULL)
++    LD_PRELOAD = getenv("LD_32_PRELOAD");
 +  running_on_valgrind_preload = LD_PRELOAD != NULL &&
 +    (
 +      strstr(LD_PRELOAD, "/valgrind/") != NULL
@@ -23,7 +25,7 @@
  static int GetRunningOnValgrind(void) {
  #ifdef RUNNING_ON_VALGRIND
    if (RUNNING_ON_VALGRIND) return 1;
-@@ -51,6 +64,11 @@ static int GetRunningOnValgrind(void) {
+@@ -51,6 +66,11 @@ static int GetRunningOnValgrind(void) {
    if (running_on_valgrind_str) {
      return strcmp(running_on_valgrind_str, "0") != 0;
    }