From patchwork Tue Apr 9 14:24:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 88249 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A360D3844774 for ; Tue, 9 Apr 2024 14:28:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 60CCC3858288 for ; Tue, 9 Apr 2024 14:24:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60CCC3858288 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 60CCC3858288 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672681; cv=none; b=Cpd58GplRp1syr1RZZTsA39HimAxgp8QxNvyfaq22xdVKjoXqAOvvg6LMyWdvz5E6w7/HkJS4kNAqgwYfTRepzqAVYetJnfm5y9g6yerk1NO3R0KPHy6Mp6DaZdaU9cpJxnfM+BUBF0t5/DmsbGZM+ENu0E1lT9roTuJBlboMa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672681; c=relaxed/simple; bh=CgLJ8/LPFpRv3pIWSDWhQ5jC7CJ2Bw6gIy6M8Rhhwqw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UJIsMf89lrqu9Ubi8b4dhIY9W/b86c3fiPAHtF5OgmVuCIeknC7SLOPrrOJoS0C/XQ1seAGk7WnvKyv2BGMnEGMZr7hxX3PldBleSjKv0zqtE+E/65KC2YWQNL59NZ2li6dGftc/TknWZIBzOoDDYS2kiq1VRdrLOCBdImU5U/g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-22fa18566adso358137fac.0 for ; Tue, 09 Apr 2024 07:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712672677; x=1713277477; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j9dh3oUn/QLoYwWhSB7z6iSS0R3yh0KSCEByO2OZaCg=; b=DykdiN3kguuMsfKdIgazD6S7zqt5IxHTcNH/lOrB9LIvBbdKUKwBjhujB9HdPtbZy7 dNYOIa1qafUxOLWy/Ozj/o7uDbvLwAwOoe2XhtuQs9iZ6+O0mbB51EHuwJDdJhoPMJJy T1oNbTfffffXxMqIZcjRQjqqtRcGteca4PxaW+FyfTMxJHs0tO5tDKnzTmJJwZ/6QuYc 2DTMuBkoo9l0ME9D/XVB8bzU1/2CyPzfLLqjZC5dyP8TXegUwf8x3VrqlhneTiiCgStZ Et/Sg4seDUIhVap85vcILWzFPEvTeH2jHIkaXOPJZXieJqvFyFz3jXjyP/H24bZqHfdw PBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712672677; x=1713277477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j9dh3oUn/QLoYwWhSB7z6iSS0R3yh0KSCEByO2OZaCg=; b=X/qW6Fh66jAcstJyFWI3q4/I9rlyTECm9ZZoB7PXkvbOVHQFaffjR7UnOOlgFbdRga jAjqzUnSC+d/FalcM7RshriPH2HeB9wjwZmZOpGieRTIuo4tRABk13PpR9hRDGey9TrG ZKPk8wFYO5B6kRO37HmckrZ/PJpAIZg3RmGIQUvKUdhG+2MWVk/aB6IaMfncaq86ajP8 K+OPnbUtFii4TSNy8h2zzeakcQdr28NhSsmGIdFvc6esHjmNVyZCYCspqTQ5oHdQediP fByZMErm/I7DggZY7IaZT7RYNxxtquEFVRzvnTNP6wmAZBdVen4Am+sS8+pEJ6fT0vAl xoyw== X-Forwarded-Encrypted: i=1; AJvYcCWQWRBw8kMf64NPC8wiibUQCPxghBR4CZykiGAy3mKf6qwZYYlFbSdED+XQbPy0ENBrKXkkmqH9aOO5bBJPVKlxVucGMUnzpw== X-Gm-Message-State: AOJu0Yze+nx5TpyBgdHdpIlOh1nwoZbatCw9k4c6J9LfXDWKZFkQdxEk qkzJ3WDbf2PgbhsGpVaVM318Z8W9RELOMyealp+O4TyffRQPl0aiXoPmXVEf X-Google-Smtp-Source: AGHT+IFdk764qF3nTjrjFVRGwQGp61hpdKmt8IjtRzVdSpu11RU8L565dU4LAv5iLxnln+P4U+v/Ew== X-Received: by 2002:a05:6870:82a2:b0:22e:b354:f5ee with SMTP id q34-20020a05687082a200b0022eb354f5eemr12428248oae.15.1712672677126; Tue, 09 Apr 2024 07:24:37 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.169.48]) by smtp.gmail.com with ESMTPSA id m65-20020a633f44000000b005dc816b2369sm8168014pga.28.2024.04.09.07.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 07:24:36 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 6DD65740751; Tue, 9 Apr 2024 07:24:35 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Cc: amodra@gmail.com, gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] mmap: Avoid the sanitizer configure check failure Date: Tue, 9 Apr 2024 07:24:34 -0700 Message-ID: <20240409142435.1708867-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409142435.1708867-1-hjl.tools@gmail.com> References: <20240409142435.1708867-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3020.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org When -fsanitize=address,undefined is used to build, the mmap configure check failed with ================================================================= ==231796==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d72b in main /home/alan/build/gas-san/all/bfd/conftest.c:239 Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d2e1 in main /home/alan/build/gas-san/all/bfd/conftest.c:190 SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 2 allocation(s). Define GCC_AC_FUNC_MMAP with export ASAN_OPTIONS=detect_leaks=0 to avoid the sanitizer configure check failure. config/ * mmap.m4 (GCC_AC_FUNC_MMAP): New. * no-executables.m4 (AC_FUNC_MMAP): Renamed to GCC_AC_FUNC_MMAP. Change AC_FUNC_MMAP to GCC_AC_FUNC_MMAP. libiberty/ * Makefile.in (aclocal_deps): Add $(srcdir)/../config/mmap.m4. * acinclude.m4: Change AC_FUNC_MMAP to GCC_AC_FUNC_MMAP. * aclocal.m4: Regenerated. * configure: Likewise. zlib/ * acinclude.m4: Include ../config/mmap.m4. * Makefile.in: Regenerated. * configure: Likewise. --- config/mmap.m4 | 12 ++++++++++++ config/no-executables.m4 | 4 ++-- libiberty/Makefile.in | 1 + libiberty/acinclude.m4 | 2 +- libiberty/aclocal.m4 | 1 + libiberty/configure | 5 +++++ zlib/Makefile.in | 2 +- zlib/acinclude.m4 | 1 + zlib/configure | 7 ------- 9 files changed, 24 insertions(+), 11 deletions(-) diff --git a/config/mmap.m4 b/config/mmap.m4 index fba0d9d3657..5ebdb90e4ee 100644 --- a/config/mmap.m4 +++ b/config/mmap.m4 @@ -95,3 +95,15 @@ if test $gcc_cv_func_mmap_anon = yes; then [Define if mmap with MAP_ANON(YMOUS) works.]) fi ]) + +dnl +dnl Avoid the sanitizer run-time memory leak failure in the mmap configure +dnl test. +dnl +AC_DEFUN([GCC_AC_FUNC_MMAP], + save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS + m4_defn([AC_FUNC_MMAP]) + ASAN_OPTIONS="$save_ASAN_OPTIONS" +) diff --git a/config/no-executables.m4 b/config/no-executables.m4 index 6842f84fba3..e8e2537bde5 100644 --- a/config/no-executables.m4 +++ b/config/no-executables.m4 @@ -49,14 +49,14 @@ m4_defn([AC_LINK_IFELSE])) dnl This is a shame. We have to provide a default for some link tests, dnl similar to the default for run tests. -m4_define([AC_FUNC_MMAP], +m4_define([GCC_AC_FUNC_MMAP], if test x$gcc_no_link = xyes; then if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then ac_cv_func_mmap_fixed_mapped=no fi fi if test "x${ac_cv_func_mmap_fixed_mapped}" != xno; then - m4_defn([AC_FUNC_MMAP]) + m4_defn([GCC_AC_FUNC_MMAP]) fi) m4_divert_pop()dnl diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 85c4b6b6ef8..b77a41c781c 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -508,6 +508,7 @@ aclocal_deps = \ $(srcdir)/../config/cet.m4 \ $(srcdir)/../config/enable.m4 \ $(srcdir)/../config/gcc-plugin.m4 \ + $(srcdir)/../config/mmap.m4 \ $(srcdir)/../config/no-executables.m4 \ $(srcdir)/../config/override.m4 \ $(srcdir)/../config/picflag.m4 \ diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4 index 9974dcd4ec5..d08e31bc0b5 100644 --- a/libiberty/acinclude.m4 +++ b/libiberty/acinclude.m4 @@ -19,7 +19,7 @@ dnl On some versions of SunOS4 at least, strncmp reads a word at a time dnl but erroneously reads past the end of strings. This can cause dnl a SEGV in some cases. AC_DEFUN([libiberty_AC_FUNC_STRNCMP], -[AC_REQUIRE([AC_FUNC_MMAP]) +[AC_REQUIRE([GCC_AC_FUNC_MMAP]) AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, [AC_TRY_RUN([ /* Test by Jim Wilson and Kaveh Ghazi. diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4 index 364fb6bc3b4..9678b0acaba 100644 --- a/libiberty/aclocal.m4 +++ b/libiberty/aclocal.m4 @@ -17,6 +17,7 @@ m4_include([../config/cet.m4]) m4_include([../config/enable.m4]) m4_include([../config/gcc-plugin.m4]) m4_include([../config/hwcaps.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/no-executables.m4]) m4_include([../config/override.m4]) m4_include([../config/picflag.m4]) diff --git a/libiberty/configure b/libiberty/configure index 5c69fee56c1..18e98b84bb5 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -7724,6 +7724,9 @@ if test x$gcc_no_link = xyes; then fi fi if test "x${ac_cv_func_mmap_fixed_mapped}" != xno; then + save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -7902,6 +7905,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strncmp" >&5 diff --git a/zlib/Makefile.in b/zlib/Makefile.in index dd8a21deba1..951260ac4c5 100644 --- a/zlib/Makefile.in +++ b/zlib/Makefile.in @@ -98,7 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ - $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/mmap.m4 \ $(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ diff --git a/zlib/acinclude.m4 b/zlib/acinclude.m4 index 9a5f5485716..3b8be00d702 100644 --- a/zlib/acinclude.m4 +++ b/zlib/acinclude.m4 @@ -1,3 +1,4 @@ +sinclude(../config/mmap.m4) sinclude(../config/no-executables.m4) sinclude(../libtool.m4) dnl The lines below arrange for aclocal not to bring libtool.m4 diff --git a/zlib/configure b/zlib/configure index 2d551360683..0e8a28a09a8 100755 --- a/zlib/configure +++ b/zlib/configure @@ -11245,12 +11245,6 @@ if test -n "$with_cross_host"; then # We ignore --with-system-zlib in this case. target_all=libzgcj.la else - if test x$gcc_no_link = xyes; then - if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then - ac_cv_func_mmap_fixed_mapped=no - fi -fi -if test "x${ac_cv_func_mmap_fixed_mapped}" != xno; then @@ -11452,7 +11446,6 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt -fi for ac_func in memcpy strerror do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`