From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id rssSHyqq12qLaTsAWB0awg (envelope-from ) for ; Tue, 20 Oct 2026 13:51:38 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=IyIPptcl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 63ABF1E06B; Tue, 20 Oct 2026 13:51:38 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1E5A21E04D for ; Tue, 20 Oct 2026 13:51:35 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA2514BAE7C8 for ; Tue, 20 Oct 2026 17:51:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA2514BAE7C8 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=IyIPptcl Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazon11013052.outbound.protection.outlook.com [40.107.159.52]) by sourceware.org (Postfix) with ESMTPS id 651224BA23C1; Tue, 20 Oct 2026 17:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 651224BA23C1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 651224BA23C1 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.159.52 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1792518547; cv=pass; b=mP6JEva1TRdrraVsWahfJd/dSCC00p1J6fCoW6LMlsqj5Y44CW4St4/7X0eIlcnwVgLi5rlCaRi/HY0mpewreuPURfXx8WBh9wShdMp6eDocaTRnErMXUOQa2r1wmzUvWqoZGqzrJ5q8OZUBoMYUEmXDfzmVBHOI66+Q/6jqAjc= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1792518547; c=relaxed/simple; bh=O4bNvW3V1K3q2DowpKmDTB7XB4abQrd1ANbrZRWvBCo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pL4c7UfSkmQ9lEAqQiXvT0sNe/Dhre6409BaC79rWGV0wQ3DSHkrodJbGgmFJChYAV4j7ATFqJh6R3Jc0v73X+pMdqS/+LLLSO8PDaP8i6KSuRWzmhOoonkza+JeODbE1kwegiLdtZD4D/gfvIxpSYJWeGJRifFQWR5oi3H5ELQ= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector2 header.b=IyIPptcl DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 651224BA23C1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LXT0zFnk23O7WUd+AMI0yLejM2U0g5quL9MjhVFvTJChChhJZdQEV4d9gvuy75s8iDCV9vBwNdEhllrqLOrRFqElHCV8yiWvj5dz1tmc2J/BKL86Ln/VMSVkx8A+Yn8GHH682EoChHuSiluFSndOb0QCfdUH3F2pNs/MrMRmjZ9OEQ3USouCTMsPmQqlmZ2kppN45IuP+mhvU3lDcVAYId4OEAeph87nVeduMhwm6yjfNad+JY0goxREhxEDCLMWlFWq9+04LePaShPwHnfwCpJuL69Ja2hLbGL1kb5dBPbBmkqEjfZzlQYD5BcpMfAF23WO4SVVJnngkA06h2BS0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AvfrmFuuCr/KnmfwUcTH8xa2LvOy5MqK7k7eguv2NkE=; b=mGJ4fKvxtGnrs+WiuB3rndITM11IZyeEgpLAKWKEFd2HIWk0p1yAyF/O4vPTxKgJw1EcbSDt2hk5ZfM/stb31QEa5ZvbBKiZtTraEeDe8NBdXT7VrFNYF+dhBh1Z6tLOtwpAUTp/cokRKWxAUM5NZhdqE4C3eLRcntrtvK2u0jFqkRi/QSpT39DxNl/mlbGD1XmUuGIDzmy0YYCphYGNWfmYPrxRWAYMiH3+YwnyRK46sKbenzzO6/2L9wKUAzMvM+HNTLZAXOrlnOWHThWKEKAheEUxygjO33TdpDerNdIC1J+l8K1vVjaYwJvk7XJMTeS4FJrqZukJMb0OzXcjnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 164.130.1.60) smtp.rcpttodomain=sourceware.org smtp.mailfrom=foss.st.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=foss.st.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AvfrmFuuCr/KnmfwUcTH8xa2LvOy5MqK7k7eguv2NkE=; b=IyIPptclNuG6AI+ZOaqy4Kbsv3KAdGZv4aZ+S91ItiauQsg2QuJ2PktI0b+6DhHsfd/3/XLjluDLaYsEN0bEOTkB/QY9TPJiIJlCJjrGNGgltSta7f9pTZiNgJkibx+UK39m8Ut6ptx9GJZ8TwdfgS6wiRmBMvpfc91qs/ospJ6xEcJByAuizRBzfoffBauLDfO1/rgDqFJrGkST03hH7Gv2gS7m8+j+KkrbzUp59bGc+FoTaZnqLC/8IhYwKJGq6RBnaPS4BMDDs8fW7DWfOKHtDC1ogjKDwCDluNBRQkM8WDiQ2WzXc9h/+SdQsxf8uBfoWgONxvlJyf+yTZWIPw== Received: from PA7P264CA0333.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:39a::27) by AS4PR10MB5672.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:4f3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.546.15; Tue, 20 Oct 2026 17:48:58 +0000 Received: from MAD0EPF000008C4.eurprd05.prod.outlook.com (2603:10a6:102:39a:cafe::98) by PA7P264CA0333.outlook.office365.com (2603:10a6:102:39a::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.522.20 via Frontend Transport; Tue, 20 Oct 2026 17:48:58 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=fail (sender IP is 164.130.1.60) smtp.mailfrom=foss.st.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=foss.st.com; Received-SPF: Fail (protection.outlook.com: domain of foss.st.com does not designate 164.130.1.60 as permitted sender) receiver=protection.outlook.com; client-ip=164.130.1.60; helo=smtpO365.st.com; Received: from smtpO365.st.com (164.130.1.60) by MAD0EPF000008C4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.546.15 via Frontend Transport; Tue, 20 Oct 2026 17:48:56 +0000 Received: from STKDAG1NODE2.st.com (10.75.128.133) by smtpO365.st.com (10.250.44.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Tue, 20 Oct 2026 19:49:26 +0200 Received: from jkgcxl0012.jkg.st.com (10.74.22.122) by STKDAG1NODE2.st.com (10.75.128.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Tue, 20 Oct 2026 19:48:55 +0200 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= To: , CC: , =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= Subject: [PATCH v3] configure: Sync zstd detection with GCC Date: Tue, 20 Oct 2026 19:40:58 +0200 Message-ID: <20261020174837.3201244-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <7e7d11d7-8b43-4150-81cb-29864763f4cf@simark.ca> References: <7e7d11d7-8b43-4150-81cb-29864763f4cf@simark.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.74.22.122] X-ClientProxiedBy: ENXCAS1NODE2.st.com (10.75.128.138) To STKDAG1NODE2.st.com (10.75.128.133) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MAD0EPF000008C4:EE_|AS4PR10MB5672:EE_ X-MS-Office365-Filtering-Correlation-Id: d4eec70a-f9ba-4e49-b9b0-08df2ed269fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|42112799006|23010399003|36860700016|82310400026|56012099006|11063799006|261009223027099003|10067099003|22082099003|18002099003|6133799003|13003099007|3023799007; X-Microsoft-Antispam-Message-Info: f4LTOJp90xPqlgDaq/JvSwSvMWMWcWBtBILG/+WPBxm8BjZTwzX4wDr9ydHgnpb+2muQiZc0BFSQV3z6JuD/XxJxQeN8XwagjmAK7tY6bkRU1e+zm7tTD/E9MnThT5FWenttifsX4/Ol5yt/NEUDzpFD+NQm+4jDVEmpef/TzcI4UUlyeJlUQfx5z57/5EVRnb2cUMpM9dYoIQR3E/4E1DiY/jYxbxdDrmZ3V9BmrrY9Jk++aqv/X0hdMWe8nzbbOp/uwTYZnWJxn2uNUwZS24vqc5iw6BTkS7Y5ecAGheJNkC2AD6Amcx4JOvu+nyHA2sr0ZAOFEsb21ffN2dYjwUh8dGNOxc6B5mS3rNqCbqyj3gCUJ41bqmx5F6inDjLiciiiWXpV7hZ243Ukfa9Hevadngd3g2qOLCeBGHzWfEWZgIHb4OfIn0+1UUEJPxOGzQsjvK5mjaeAenfcy+rTVXQSpREl6K8x4l2Ef5d5VNsnON3xg47a1rzefc/JNnK+J9F3by7tf2tCxbVFL0tdx7410n8mVXOP+rjlOOPZLpTD6dFBY6zwR+LeMsY0Il77MG7zHiDqiwl6d36o89rYHIwQj4iTZWDO19Khs9St9aL6ZDNBDEf4fiVXd9aP2AHZNoZdSDkngrDer7AEL7l9whHh5iXweFZkdDKbE66sae8= X-Forefront-Antispam-Report: CIP:164.130.1.60; CTRY:IT; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:smtpO365.st.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(42112799006)(23010399003)(36860700016)(82310400026)(56012099006)(11063799006)(261009223027099003)(10067099003)(22082099003)(18002099003)(6133799003)(13003099007)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fFWJ2WBDzsWfZn0+OXpP6uOoovgMsV8nItBApMCAtGIiMH1wiMPIMoDB/3GRvyWaGkbyRLDUTVyEIMpIQH8SRRvGchqyPUW1hxtpZO0dL3vMIHY6D5spdQYaojqKZQ1rPo6J/UOvg+82Nk+efge2AaNma8xPhNFtkd1FlrITeKvpQikIqycwl3V1d17zEhSOlu3+SoT5fZc1bxQR5o02yaB82Hg8gT3XvkdYOH0/agPRAZH26usV0748xE9jZwLwhBPTg2TWP+WyXyAApwtIuHo5BJ8fWEGe4bET+6NoiKpWJ0xHVZ76iZm50LJAFaf3s3tzLWvB1P3iMpNNGwU8kw4wAhXY2Shqfg+KA3L1QVXh+hOSP4rVSsQQDjzCmKc/azSFXnQZwhT0RO/j1cHlPLF3yoLwGaupkwmvUZT3eZJvKEnkwQrpy7zpM7iVhPs+ X-OriginatorOrg: foss.st.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2026 17:48:56.5198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4eec70a-f9ba-4e49-b9b0-08df2ed269fe X-MS-Exchange-CrossTenant-Id: 75e027c9-20d5-47d5-b82f-77d7cd041e8f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=75e027c9-20d5-47d5-b82f-77d7cd041e8f; Ip=[164.130.1.60]; Helo=[smtpO365.st.com] X-MS-Exchange-CrossTenant-AuthSource: MAD0EPF000008C4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR10MB5672 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi, I've now update the GCC version of zstd.m4 to contain a unified implementation to detect zstd support. Please let me know if there is something I've missed. V1 can be found here: https://sourceware.org/pipermail/binutils/2026-September/151687.html V2 can be found here: https://sourceware.org/pipermail/binutils/2026-September/151690.html Changes since v1: - Added missed changes in binutils/Makefile.am and binutils/Makefile.in - Added support for dynamic version of zstd in path Changes since v2: - Updated the GCC version of config/zstd.m4 and synced back those changes to this tree. - Fixed gold/configure.ac to use $zstd_enabled. Ok for trunk? Kind regards, Torbjörn -- Sync config/zstd.m4 with GCC to support compiler-based detection and configurable zstd search paths. Add ZSTD_LIBS to binutils link commands for tools using zstd through BFD. Base gold's zstd test conditional on the final detection result rather than pkg-config flags. Regenerate the affected configure scripts and binutils Makefile.in. Signed-off-by: Torbjörn SVENSSON --- bfd/configure | 240 +++++++++++++++++++++++++++++++++++++++---- binutils/Makefile.am | 14 +-- binutils/Makefile.in | 16 +-- binutils/configure | 236 +++++++++++++++++++++++++++++++++++++++--- config/zstd.m4 | 134 +++++++++++++++++++++--- gas/configure | 240 +++++++++++++++++++++++++++++++++++++++---- gdb/configure | 236 +++++++++++++++++++++++++++++++++++++++--- gold/configure | 238 ++++++++++++++++++++++++++++++++++++++---- gold/configure.ac | 2 +- ld/configure | 236 +++++++++++++++++++++++++++++++++++++++--- 10 files changed, 1457 insertions(+), 135 deletions(-) diff --git a/bfd/configure b/bfd/configure index a4326160c57..fd8db630cf6 100755 --- a/bfd/configure +++ b/bfd/configure @@ -653,11 +653,11 @@ TDEFINES SHARED_LIBADD SHARED_LDFLAGS LIBM -ZSTD_LIBS -ZSTD_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG +ZSTD_LIBS +ZSTD_CFLAGS zlibinc zlibdir EXEEXT_FOR_BUILD @@ -855,6 +855,8 @@ with_libintl_prefix with_libintl_type with_system_zlib with_zstd +with_zstd_include +with_zstd_lib ' ac_precious_vars='build_alias host_alias @@ -1540,8 +1542,15 @@ Optional Packages: --without-libintl-prefix don't search for libintl in includedir and libdir --with-libintl-type=TYPE type of library to search for (auto/static/shared) --with-system-zlib use installed libz - --with-zstd support zstd compressed debug sections - (default=auto) + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library Some influential environment variables: CC C compiler command @@ -11527,7 +11536,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11530 "configure" +#line 11539 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11633,7 +11642,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11636 "configure" +#line 11645 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15415,15 +15424,47 @@ $as_echo "no" >&6; } fi + + # Check whether --with-zstd was given. if test "${with_zstd+set}" = set; then : - withval=$with_zstd; + withval=$with_zstd; with_zstd=$withval else with_zstd=auto fi -if test "$with_zstd" != no; then : +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 @@ -15507,31 +15548,192 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZSTD_PKG_ERRORS" >&5 - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : else ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS ZSTD_LIBS=$pkg_cv_ZSTD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + zstd_pkg_config=yes -$as_echo "#define HAVE_ZSTD 1" >>confdefs.h +fi +fi +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi diff --git a/binutils/Makefile.am b/binutils/Makefile.am index edcbc67bde4..0582d9fb826 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -251,7 +251,7 @@ dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) -LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) +LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS) size_SOURCES = size.c $(BULIBS) @@ -271,7 +271,7 @@ nm_new_SOURCES = nm.c demanguse.c $(BULIBS) objdump_SOURCES = objdump.c dwarf.c prdbg.c demanguse.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS) EXTRA_objdump_SOURCES = od-elf32_avr.c od-macho.c od-xcoff.c od-pe.c -objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS) $(LIBSFRAME) +objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS) $(DEBUGINFOD_LIBS) $(LIBSFRAME) objdump.@OBJEXT@:objdump.c if am__fastdepCC @@ -290,11 +290,11 @@ cxxfilt_SOURCES = cxxfilt.c $(BULIBS) ar_SOURCES = arparse.y arlex.l not-ranlib.c arsup.c rename.c binemul.c \ emul_$(EMULATION).c $(BULIBS) EXTRA_ar_SOURCES = $(CFILES) -ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS) ranlib_SOURCES = arparse.y arlex.l is-ranlib.c arsup.c rename.c binemul.c \ emul_$(EMULATION).c $(BULIBS) -ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS) addr2line_SOURCES = addr2line.c $(BULIBS) @@ -485,7 +485,7 @@ srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) srconv.@OBJEXT@: sysroff.c dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) -dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS) dlltool.@OBJEXT@: if am__fastdepCC @@ -518,11 +518,11 @@ sysdump.@OBJEXT@: sysroff.c windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \ winduni.c resres.c $(BULIBS) -windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS) windmc_SOURCES = windmc.c mcparse.y mclex.c \ winduni.c $(BULIBS) -windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS) dllwrap_SOURCES = dllwrap.c version.c dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL) diff --git a/binutils/Makefile.in b/binutils/Makefile.in index fff4565e302..69f6a1e128c 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -282,7 +282,7 @@ am__dirstamp = $(am__leading_dot)dirstamp testsuite_gentestdlls_OBJECTS = testsuite/gentestdlls.$(OBJEXT) testsuite_gentestdlls_LDADD = $(LDADD) testsuite_gentestdlls_DEPENDENCIES = $(BFDLIB) $(LIBIBERTY) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_windmc_OBJECTS = windmc.$(OBJEXT) mcparse.$(OBJEXT) mclex.$(OBJEXT) \ winduni.$(OBJEXT) $(am__objects_1) windmc_OBJECTS = $(am_windmc_OBJECTS) @@ -794,7 +794,7 @@ elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) -LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) +LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS) size_SOURCES = size.c $(BULIBS) objcopy_SOURCES = not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) strings_SOURCES = strings.c $(BULIBS) @@ -806,31 +806,31 @@ strip_new_SOURCES = is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) nm_new_SOURCES = nm.c demanguse.c $(BULIBS) objdump_SOURCES = objdump.c dwarf.c prdbg.c demanguse.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS) EXTRA_objdump_SOURCES = od-elf32_avr.c od-macho.c od-xcoff.c od-pe.c -objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS) $(LIBSFRAME) +objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS) $(DEBUGINFOD_LIBS) $(LIBSFRAME) cxxfilt_SOURCES = cxxfilt.c $(BULIBS) ar_SOURCES = arparse.y arlex.l not-ranlib.c arsup.c rename.c binemul.c \ emul_$(EMULATION).c $(BULIBS) EXTRA_ar_SOURCES = $(CFILES) -ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS) ranlib_SOURCES = arparse.y arlex.l is-ranlib.c arsup.c rename.c binemul.c \ emul_$(EMULATION).c $(BULIBS) -ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS) addr2line_SOURCES = addr2line.c $(BULIBS) srconv_SOURCES = srconv.c coffgrok.c $(BULIBS) dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS) -dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) +dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS) coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS) sysdump_SOURCES = sysdump.c $(BULIBS) windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \ winduni.c resres.c $(BULIBS) -windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS) windmc_SOURCES = windmc.c mcparse.y mclex.c \ winduni.c $(BULIBS) -windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) +windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS) dllwrap_SOURCES = dllwrap.c version.c dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL) EXTRA_DIST = arparse.c arparse.h arlex.c sysinfo.c sysinfo.h \ diff --git a/binutils/configure b/binutils/configure index ea19d09749f..853bf8e7fd2 100755 --- a/binutils/configure +++ b/binutils/configure @@ -846,6 +846,8 @@ with_libintl_type enable_maintainer_mode with_system_zlib with_zstd +with_zstd_include +with_zstd_lib with_msgpack ' ac_precious_vars='build_alias @@ -1540,8 +1542,15 @@ Optional Packages: --without-libintl-prefix don't search for libintl in includedir and libdir --with-libintl-type=TYPE type of library to search for (auto/static/shared) --with-system-zlib use installed libz - --with-zstd support zstd compressed debug sections - (default=auto) + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library --with-msgpack Enable msgpack support (auto/yes/no) Some influential environment variables: @@ -11455,7 +11464,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11458 "configure" +#line 11467 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11561,7 +11570,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11564 "configure" +#line 11573 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15865,15 +15874,47 @@ fi + + # Check whether --with-zstd was given. if test "${with_zstd+set}" = set; then : - withval=$with_zstd; + withval=$with_zstd; with_zstd=$withval else with_zstd=auto fi -if test "$with_zstd" != no; then : +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 @@ -15957,31 +15998,192 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZSTD_PKG_ERRORS" >&5 - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : else ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS ZSTD_LIBS=$pkg_cv_ZSTD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + zstd_pkg_config=yes -$as_echo "#define HAVE_ZSTD 1" >>confdefs.h +fi +fi +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi diff --git a/config/zstd.m4 b/config/zstd.m4 index eb34c0f36d7..28788782d3b 100644 --- a/config/zstd.m4 +++ b/config/zstd.m4 @@ -5,19 +5,129 @@ dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. -dnl Enable features using the zstd library. +dnl Set up and check zstd support. AC_DEFUN([AC_ZSTD], [ +AC_SUBST(ZSTD_CFLAGS) +AC_SUBST(ZSTD_LIBS) AC_ARG_WITH(zstd, - [AS_HELP_STRING([--with-zstd], [support zstd compressed debug sections (default=auto)])], - [], [with_zstd=auto]) - -AS_IF([test "$with_zstd" != no], - [PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.4.0], [ - AC_DEFINE(HAVE_ZSTD, 1, [Define to 1 if zstd is enabled.]) - ], [ - if test "$with_zstd" = yes; then - AC_MSG_ERROR([--with-zstd was given, but pkgconfig/libzstd.pc is not found]) + [AS_HELP_STRING([--with-zstd=VALUE], + [VALUE may be 'auto' (try pkg-config, then compiler search; default), + 'yes' (require zstd), 'no' (disable it), or a PATH for the + installation prefix. When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib])], + [with_zstd=$withval], [with_zstd=auto]) +AC_ARG_WITH(zstd-include, + [AS_HELP_STRING([--with-zstd-include=PATH], + [specify directory for installed zstd include files])]) +AC_ARG_WITH(zstd-lib, + [AS_HELP_STRING([--with-zstd-lib=PATH], + [specify directory for the installed zstd library])]) +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then + PKG_CHECK_MODULES([ZSTD], [libzstd >= 1.4.0], [ + zstd_pkg_config=yes + ], [:]) +fi + +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + AC_LANG_PUSH([C]) + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + AC_SEARCH_LIBS([ZSTD_compress], [zstd], + [zstd_lib_usable=yes], + [zstd_lib_usable=no]) + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" fi - ]) - ]) + LIBS="$save_LIBS" + + AC_CACHE_CHECK([for zstd.h], [ac_cv_zstd_h], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + ]], [[]])], + [ac_cv_zstd_h=yes], + [ac_cv_zstd_h=no])]) + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + AC_MSG_NOTICE([pkg-config zstd is unusable; trying compiler search]) + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + AC_LANG_POP([C]) + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + AC_DEFINE(HAVE_ZSTD, 1, [Define if zstd is available.]) + elif test "$with_zstd" != auto; then + AC_MSG_ERROR([Unable to find a usable zstd library and zstd.h. See + config.log for details.]) + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= +fi ]) diff --git a/gas/configure b/gas/configure index 8afaf2729ed..0edbdd4ec04 100755 --- a/gas/configure +++ b/gas/configure @@ -634,11 +634,11 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS -ZSTD_LIBS -ZSTD_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG +ZSTD_LIBS +ZSTD_CFLAGS zlibinc zlibdir LIBM @@ -838,6 +838,8 @@ with_libintl_type enable_maintainer_mode with_system_zlib with_zstd +with_zstd_include +with_zstd_lib ' ac_precious_vars='build_alias host_alias @@ -1531,8 +1533,15 @@ Optional Packages: --without-libintl-prefix don't search for libintl in includedir and libdir --with-libintl-type=TYPE type of library to search for (auto/static/shared) --with-system-zlib use installed libz - --with-zstd support zstd compressed debug sections - (default=auto) + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library Some influential environment variables: CC C compiler command @@ -11152,7 +11161,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11155 "configure" +#line 11164 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11258,7 +11267,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11261 "configure" +#line 11270 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16142,15 +16151,47 @@ $as_echo "no" >&6; } fi + + # Check whether --with-zstd was given. if test "${with_zstd+set}" = set; then : - withval=$with_zstd; + withval=$with_zstd; with_zstd=$withval else with_zstd=auto fi -if test "$with_zstd" != no; then : +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 @@ -16234,31 +16275,192 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZSTD_PKG_ERRORS" >&5 - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : else ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS ZSTD_LIBS=$pkg_cv_ZSTD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + zstd_pkg_config=yes -$as_echo "#define HAVE_ZSTD 1" >>confdefs.h +fi +fi +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi diff --git a/gdb/configure b/gdb/configure index 810e9ed7a37..78b79b7c3b2 100755 --- a/gdb/configure +++ b/gdb/configure @@ -946,6 +946,8 @@ with_pkgversion with_bugurl with_system_zlib with_zstd +with_zstd_include +with_zstd_lib with_iconv_bin with_system_readline with_jit_reader_dir @@ -1721,8 +1723,15 @@ Optional Packages: --with-pkgversion=PKG Use PKG in the version string in place of "GDB" --with-bugurl=URL Direct users to URL to report a bug --with-system-zlib use installed libz - --with-zstd support zstd compressed debug sections - (default=auto) + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library --with-iconv-bin=PATH specify where to find the iconv program --with-system-readline use installed readline library --with-jit-reader-dir=PATH @@ -11877,7 +11886,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11880 "configure" +#line 11889 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11983,7 +11992,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11986 "configure" +#line 11995 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -26715,15 +26724,47 @@ fi + + # Check whether --with-zstd was given. if test "${with_zstd+set}" = set; then : - withval=$with_zstd; + withval=$with_zstd; with_zstd=$withval else with_zstd=auto fi -if test "$with_zstd" != no; then : +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 @@ -26807,31 +26848,192 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZSTD_PKG_ERRORS" >&5 - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : else ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS ZSTD_LIBS=$pkg_cv_ZSTD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + zstd_pkg_config=yes -$as_echo "#define HAVE_ZSTD 1" >>confdefs.h +fi +fi + +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi diff --git a/gold/configure b/gold/configure index a81a04f0531..e159551e389 100755 --- a/gold/configure +++ b/gold/configure @@ -644,11 +644,11 @@ ax_pthread_config SED HAVE_ZSTD_FALSE HAVE_ZSTD_TRUE -ZSTD_LIBS -ZSTD_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG +ZSTD_LIBS +ZSTD_CFLAGS zlibinc zlibdir LIBOBJS @@ -873,6 +873,8 @@ with_gold_ldflags with_gold_ldadd with_system_zlib with_zstd +with_zstd_include +with_zstd_lib enable_threads enable_jansson enable_maintainer_mode @@ -1555,8 +1557,15 @@ Optional Packages: --with-gold-ldflags=FLAGS additional link flags for gold --with-gold-ldadd=LIBS additional libraries for gold --with-system-zlib use installed libz - --with-zstd support zstd compressed debug sections - (default=auto) + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library Some influential environment variables: CC C compiler command @@ -9989,15 +9998,47 @@ $as_echo "no" >&6; } fi + + # Check whether --with-zstd was given. if test "${with_zstd+set}" = set; then : - withval=$with_zstd; + withval=$with_zstd; with_zstd=$withval else with_zstd=auto fi -if test "$with_zstd" != no; then : +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 @@ -10081,34 +10122,195 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZSTD_PKG_ERRORS" >&5 - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : else ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS ZSTD_LIBS=$pkg_cv_ZSTD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + zstd_pkg_config=yes -$as_echo "#define HAVE_ZSTD 1" >>confdefs.h +fi +fi + +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi - if test "$pkg_cv_ZSTD_LIBS" != ""; then + if test "$zstd_enabled" = yes; then HAVE_ZSTD_TRUE= HAVE_ZSTD_FALSE='#' else diff --git a/gold/configure.ac b/gold/configure.ac index fe6ace01693..89348b660be 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -566,7 +566,7 @@ fi # Link in zlib/zstd if we can. This allows us to write compressed sections. AM_ZLIB AC_ZSTD -AM_CONDITIONAL(HAVE_ZSTD, test "$pkg_cv_ZSTD_LIBS" != "") +AM_CONDITIONAL(HAVE_ZSTD, test "$zstd_enabled" = yes) AC_ARG_ENABLE([threads], [[ --enable-threads[=ARG] multi-threaded linking [ARG={auto,yes,no}]]], diff --git a/ld/configure b/ld/configure index 4d755384c41..5f5c8d311dc 100755 --- a/ld/configure +++ b/ld/configure @@ -877,6 +877,8 @@ with_libintl_type with_xxhash with_system_zlib with_zstd +with_zstd_include +with_zstd_lib ' ac_precious_vars='build_alias host_alias @@ -1598,8 +1600,15 @@ Optional Packages: --with-xxhash use inlined libxxhash for hashing (faster) (auto/yes/no) --with-system-zlib use installed libz - --with-zstd support zstd compressed debug sections - (default=auto) + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library Some influential environment variables: CC C compiler command @@ -11894,7 +11903,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11897 "configure" +#line 11906 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12000,7 +12009,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12003 "configure" +#line 12012 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19080,15 +19089,47 @@ fi + + # Check whether --with-zstd was given. if test "${with_zstd+set}" = set; then : - withval=$with_zstd; + withval=$with_zstd; with_zstd=$withval else with_zstd=auto fi -if test "$with_zstd" != no; then : +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 @@ -19172,31 +19213,192 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZSTD_PKG_ERRORS" >&5 - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - - if test "$with_zstd" = yes; then - as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5 - fi - + : else ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS ZSTD_LIBS=$pkg_cv_ZSTD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + zstd_pkg_config=yes -$as_echo "#define HAVE_ZSTD 1" >>confdefs.h +fi +fi +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi -- 2.43.0