From patchwork Wed Jul 2 23:34:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 115486 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 E218A3852FDB for ; Wed, 2 Jul 2025 23:35:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E218A3852FDB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=DvkTSMY7 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by sourceware.org (Postfix) with ESMTPS id 6AB93385782C for ; Wed, 2 Jul 2025 23:34:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AB93385782C 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 6AB93385782C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751499292; cv=none; b=gbCnBwct7NWWW+dnsPjbxZ1ccBjz9C+Do6/i/VPVmYK1vVFsY/JGpckeREe519pYkVoYwN+i6bgnZL/Ry1NOAr9p593JqkISid473WtpBvnElrCy+JuswrdlQAW3D5ikdinDSQMs0y8KBogAtaLlQVMAW7q60yCkal40eu0QnA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751499292; c=relaxed/simple; bh=CqvvfRO5F6F6P18w5LIEr2+yHy8YgKzVW+X0YoqmW1A=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=PUQGpmM6y4g4KpEUxhiu97MkKqXOPf2xc9aliwls/tfoSnRH4f6FjqgDrnpmhVZNvS8ygVl/c4A58ikaXtUhjvbokXhic6fTw4Gv0NgcfW2/1QUia/F6f6spDkHBCR2fY+adu+rEMLZNFo0z+a0Kr1+DsEi6K5L/kp9vZDOJ4og= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AB93385782C Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-714066c7bbbso84243907b3.3 for ; Wed, 02 Jul 2025 16:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751499292; x=1752104092; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=QXt0yHCjqgPw5sJze19MUxQO9QRwwoSq5ECBS5ccZ5Q=; b=DvkTSMY7RiuJD1oEk8TfT/j28icB+bKFMcDg+AhVTYbncKIX9K7AHax9UhzmsUWn21 3zkcjNEcfKmd2jJ4fqZ0XE1s5eKtXFT5EtlzmvV4C9yvWDhSa+X8DBDgY/HygLGXM7Qo FV0YaZvtQ5CmSUs5kNW4EUe76lThL2UenNb0LEyyrNmnz4Kw/mk+dyK/V0nBIZSf4xL7 T7svVV+HIBz+L5zseIZUOPtphxsqEKOzcIe1uss1hnDCv0NAcj79eYzSYfliRpa6sQH8 z5KVdLrOS1w+TWlpSfQzXQYv+9sE9CTov/t+QmGlPvk3OY8sIIfxhumFEgmZwW6qKN9Z 2hMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751499292; x=1752104092; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=QXt0yHCjqgPw5sJze19MUxQO9QRwwoSq5ECBS5ccZ5Q=; b=tbsC7IUAp0gJza9YaSURjkuqVPLlCSVo6YoYXT3Dxe3m8pT4FYh8pEcd4osY76Ljxe H4ZRpIUqgEtAO8X8obPB+UgfutVOcqH6FL08VlrCb6YqI7NxquDPeE+og904ic/rfd9A iV6DI6IL1mZiL5zhSKBQbaW51WhPLGeZ2H7mQtUUgzO+eIj1sYQmtLjMZwu9BFBnTjxq CF9MX00fek0KmQMrv2Y1gAirGzWR4HBG9iCviO5ZbpGExOT8n2McCGsA1nTyDYX6FK9N CC8ITmcmY8iG8FK7T3ZlHJFNkLF3Tsi+EGy27nlCK9XikgodSL6WiSIKg0VK2nwNkGXe tWgA== X-Gm-Message-State: AOJu0YzAOC3wlae/TCJpFC4VlJk4kefzo7dloECKIQ9/XYad/h9nm6Yi Gjp5nEjQ755UeijLcWfVUpcNrYQDwtKki+wlZJBnbKT/Gu77wcdFgzV5miziA0EUnSDZRGbzzic eKoni0HEj2ZCdIBzMoDlBmntmoRccxrS+Taz0kx3w9Q== X-Gm-Gg: ASbGncuB5CIY23aalSG6z7JxtM0eRbpb4mh9WfWuheBN7g+mGex0Dj9as2utN6OuFZI GOn55oJJRxvq3vYXTp2WnXQ6R7bzvKQJrUsFLt+FrpBssLLAwNCYNgIQAPs7EZYR3KkDgE/xX4/ XBcMzZTVWCT6AZ99XjBZPOMBFZ/3C/gVUhkWtFwDH5RA== X-Google-Smtp-Source: AGHT+IF/DmQUQuVnjnBRaCmodCFcxpEPCETVuMsPXUYhF0k7n+uwMIhYWdxbpeTowwCB8MsrbDByqGUTbPsdDTWJ22s= X-Received: by 2002:a05:690c:c8b:b0:70d:f237:6a60 with SMTP id 00721157ae682-71658fbc905mr22335917b3.7.1751499291587; Wed, 02 Jul 2025 16:34:51 -0700 (PDT) MIME-Version: 1.0 From: "H.J. Lu" Date: Thu, 3 Jul 2025 07:34:15 +0800 X-Gm-Features: Ac12FXzKy_LsFCPTQ3VlB76RJs8CKpF7brxcUiu0V0tLcMx_nHPDqanFvEsSgts Message-ID: Subject: [PATCH] x86-64: Compile gmon tests with -mfentry [BZ #33121] To: GNU C Library , Florian Weimer , Sam James X-Spam-Status: No, score=-3014.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org When glibc was configured with --enable-stack-protector=all and built with GCC 16, I got: FAIL: gmon/tst-gmon-gprof FAIL: gmon/tst-gmon-pie-gprof FAIL: gmon/tst-gmon-static-gprof FAIL: gmon/tst-gmon-static-pie-gprof [hjl@gnu-tgl-3 build-x86_64-linux]$ cat gmon/tst-gmon-gprof.out FAIL [hjl@gnu-tgl-3 build-x86_64-linux]$ This is because -pg doesn't work with separate shrink wrapping in GCC 16: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881 Compile gmon tests with -mfentry to call __fentry__ before the prologue. This fixes BZ #33121. OK for master? From 23230494a5df01aa36c7da91dcf8710406726f7b Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 3 Jul 2025 05:56:16 +0800 Subject: [PATCH] x86-64: Compile gmon tests with -mfentry [BZ #33121] When glibc was configured with --enable-stack-protector=all and built with GCC 16, I got: FAIL: gmon/tst-gmon-gprof FAIL: gmon/tst-gmon-pie-gprof FAIL: gmon/tst-gmon-static-gprof FAIL: gmon/tst-gmon-static-pie-gprof [hjl@gnu-tgl-3 build-x86_64-linux]$ cat gmon/tst-gmon-gprof.out --- expected +++ actual @@ -1,3 +1,2 @@ f1 2000 f2 1000 -f3 1 FAIL [hjl@gnu-tgl-3 build-x86_64-linux]$ This is because -pg doesn't work with separate shrink wrapping in GCC 16: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881 Compile gmon tests with -mfentry to call __fentry__ before the prologue. This fixes BZ #33121. Signed-off-by: H.J. Lu --- sysdeps/x86_64/Makefile | 8 ++++++++ sysdeps/x86_64/configure | 34 ++++++++++++++++++++++++++++++++++ sysdeps/x86_64/configure.ac | 9 +++++++++ 3 files changed, 51 insertions(+) diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index be64eb2ee4..2e061cb224 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -19,6 +19,14 @@ sysdep_routines += _mcount # recursive calls when ENTRY is used. Just copy the normal static # object. sysdep_noprof += _mcount + +# -pg doesn't work with separate shrink wrapping in GCC 16: +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881 +# Add -mfentry to call __fentry__ before the prologue. +CFLAGS-tst-gmon.c += $(test-cc-cflags-mfentry) +CFLAGS-tst-gmon-static.c += $(test-cc-cflags-mfentry) +CFLAGS-tst-gmon-pie.c += $(test-cc-cflags-mfentry) +CFLAGS-tst-gmon-static-pie.c += $(test-cc-cflags-mfentry) endif ifeq ($(subdir),string) diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure index bbf520bfc9..45255c7ddb 100644 --- a/sysdeps/x86_64/configure +++ b/sysdeps/x86_64/configure @@ -256,6 +256,40 @@ rm -f conftest* config_vars="$config_vars have-mamx-tile = $libc_cv_test_x86_have_amx_tile" + + +saved_CC="$CC" +CC="$TEST_CC" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -mfentry works in testing" >&5 +printf %s "checking if -mfentry works in testing... " >&6; } +if test ${libc_cv_test_cc_cflags_mfentry+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} -c -Werror -mfentry -xc /dev/null -S -o /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + libc_cv_test_cc_cflags_mfentry=-mfentry +else case e in #( + e) libc_cv_test_cc_cflags_mfentry= + ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_cflags_mfentry" >&5 +printf "%s\n" "$libc_cv_test_cc_cflags_mfentry" >&6; } + +CC="$saved_CC" + + +config_vars="$config_vars +test-cc-cflags-mfentry = $libc_cv_test_cc_cflags_mfentry" + # Check if -mapxf is enabled. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mapxf is enabled" >&5 printf %s "checking whether -mapxf is enabled... " >&6; } diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac index 4a3f7f4541..851cf0fb8b 100644 --- a/sysdeps/x86_64/configure.ac +++ b/sysdeps/x86_64/configure.ac @@ -86,6 +86,15 @@ fi [libc_cv_test_x86_have_amx_tile=no]) LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_test_x86_have_amx_tile]) +dnl Check if TEST_CC supports -mfentry +LIBC_TRY_TEST_CC_OPTION([if -mfentry works], + [-c -Werror -mfentry], + libc_cv_test_cc_cflags_mfentry, + [libc_cv_test_cc_cflags_mfentry=-mfentry], + [libc_cv_test_cc_cflags_mfentry=] +) +LIBC_CONFIG_VAR(test-cc-cflags-mfentry, $libc_cv_test_cc_cflags_mfentry) + # Check if -mapxf is enabled. AC_CACHE_CHECK(whether -mapxf is enabled, libc_cv_x86_have_apx, [dnl -- 2.50.0