From patchwork Tue Mar 28 13:21:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 67016 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 D8B463858C5F for ; Tue, 28 Mar 2023 13:22:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id D74EB3858D39; Tue, 28 Mar 2023 13:21:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D74EB3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=none smtp.mailfrom=cebitec.uni-bielefeld.de Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id EC977C62E0; Tue, 28 Mar 2023 15:21:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3BOkB31e_liP; Tue, 28 Mar 2023 15:21:53 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p508558f9.dip0.t-ipconnect.de [80.133.88.249]) (Authenticated sender: ro) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 2A2D3C65B7; Tue, 28 Mar 2023 15:21:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=CeBiTec.Uni-Bielefeld.DE; s=20200306; t=1680009713; bh=DjDMZ3VBTtgtzHv0KNQ3+ALC53ix0f2oUm5bN2DHnKY=; h=From:To:Cc:Subject:Date:From; b=i39NyYoEJ0gQtkGpl0bWBkA9B55/3SUHFDx+UesZJTlX2Lo5aTfFxkmtvS3LJ2wpg i62wq1DkFOUOCGkL1fhnJWvUFgamB8S7h+CzDJny2vPG95tfRsB5Etx6qByqXx959+ 1NFoMGFGNrb2TpdQdvcJBASbJOC+tLPNEMfgLfpZyKN00Sk9nbeKYlM6foQi0A8cuW GPvuOeBI2Qf7fC4Vu9OOQLQ8VAhSVeBkwb6GJl9q22X3IZNK5Iah0yBqvgWcxs+UQ4 QRwMqselh953z+6HdpdHSo7Mubu86c+zopowNOkiAUB5XBlXXp9zLYq/Rrhoa0m8BO LBBhybnFuBIQw== From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Alexandre Oliva Subject: [PATCH] build: Check that -lzstd can be linked Date: Tue, 28 Mar 2023 15:21:52 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.90 (usg-unix-v) MIME-Version: 1.0 X-Spam-Status: No, score=-3794.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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 Sender: "Gcc-patches" Recent Solaris 11.4 SRUs bundle zstd, but only the 64-bit libraries (no idea why). Because of this, in 32-bit builds cc1 etc. fail to link with undefined references to various ZSTD_* functions from lto-compress.o. This happens because currently only the presence of is necessary to enable zstd support in lto-compress.cc etc. This patch checks for libzstd first and disables zstd support if missing. Tested on sparc-sun-solaris2.11 with the system installation of zstd (64-bit only) and a locally-compiled one (specified with --with-zstd). Ok for trunk? * Setting the cache variable first might be considered a hack: alternatively, one could use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE, adjusting the test program accordingly. * All the code withing if test "x$with_zstd" != xno; then lacks indentation, which makes it harder to read. I've left that out of this patch, though. Rainer diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1494,6 +1494,14 @@ fi CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS" LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS" +# LTO can use zstd compression algorithm +save_LIBS="$LIBS" +LIBS= +AC_SEARCH_LIBS(ZSTD_compress, zstd,, gcc_cv_header_zstd_h=no) +ZSTD_LIB="$LIBS" +LIBS="$save_LIBS" +AC_SUBST(ZSTD_LIB) + AC_MSG_CHECKING(for zstd.h) AC_CACHE_VAL(gcc_cv_header_zstd_h, # We require version 1.3.0 or later. This is the first version that has @@ -1512,14 +1520,6 @@ if test $gcc_cv_header_zstd_h = yes; the elif test "x$with_zstd" != x; then as_fn_error $? "Unable to find zstd.h. See config.log for details." "$LINENO" 5 fi - -# LTO can use zstd compression algorithm -save_LIBS="$LIBS" -LIBS= -AC_SEARCH_LIBS(ZSTD_compress, zstd) -ZSTD_LIB="$LIBS" -LIBS="$save_LIBS" -AC_SUBST(ZSTD_LIB) fi dnl Disabled until we have a complete test for buggy enum bitfields.