From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id B83773858016 for ; Wed, 28 Sep 2022 19:22:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B83773858016 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x629.google.com with SMTP id hy2so29157834ejc.8 for ; Wed, 28 Sep 2022 12:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=uMsEAyUa0c/j5o3qGkzJ1Mo5DVL9t3SGJQ8NBw78WQg=; b=NWP0fNuMhlGU4W3dqyhDjUECt/Y2QGCK/e4ND650/EQQ+7uFMaIOMJEL9kmw2sbAWZ dFTFln7uMSWuw6uvoujb3pBUy70XxnJgkF4tOm1bQ0roeJjUTolrWFr65ondGz6UGMa5 Ax5B329fUb4hCigxQK4CctyZKH1JPObFAnURHu3ET9xN+UDNrZKZmEQPR7OK3QJdF60E BGP7L8l0FkanCniT6iuurjcFChSDSZ/7ZI38f6ajvO0w6Ayx+y8s7r4UTQ4N53MG0n/x oeSDC7JIfDV9pR1wzBgZk8e+sJaS5hBOJbVZ3ipArOZ4G2i4LyqINEERJ0vqgc9QFwUp PH6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=uMsEAyUa0c/j5o3qGkzJ1Mo5DVL9t3SGJQ8NBw78WQg=; b=NMu70S/Hp3gUGVSHPLqxP07rGwS+jLFbUXnjiojOL+8C+KrHTMDiVoajpweaWlTeoM Xdzt7Ww2pKirvpXAcgFAUKBbYHs8nT7TPEgA39inRjCd1uM25bw+UBz8v2iWFpu2ldyd j1U9LgDocm9QTbqVYZsBlWzV4HMgbqM9wz7rWy1FOS9ccqJ2JkC8yOUmL1+l9VqFoTQy why4roZ7sRbPvgGQOZvNeDcvdOrOveHuymNYve+6X/oSo/6gmxJ4y0C13F2nLYtIr+D6 1z5Ubh5LjotzpuRFNTwv6oGqB1+BjpC4MC9cRZBxTOLrm/fx0XDeJrIDv5dmMh5jRXUa 5InA== X-Gm-Message-State: ACrzQf3E3csu8RKMvjbVHhg9fkiMM8LPb/ir2t2Hpr/n0OTwXf6xERIz 8TjWE2fV/yac7gG1d7uXA3H9w+snxt8KSFaCaKqIv2B+ X-Google-Smtp-Source: AMsMyM4Izd3IQ9eldnPAoZNWlI3rdo5TPeJIW5wVpqhybM0kw7QPnTlQ2GtlGEpai6j1pkNRo/mBT/rYuxSa1KgRG0s= X-Received: by 2002:a17:907:7632:b0:76f:f6e7:36cf with SMTP id jy18-20020a170907763200b0076ff6e736cfmr29452329ejc.442.1664392925314; Wed, 28 Sep 2022 12:22:05 -0700 (PDT) MIME-Version: 1.0 References: <19677278-9d77-d0ab-1257-225f2d33e6cd@suse.cz> <371a05eb-ea48-9626-8375-ce100706c617@suse.cz> In-Reply-To: <371a05eb-ea48-9626-8375-ce100706c617@suse.cz> From: Richard Biener Date: Wed, 28 Sep 2022 21:21:52 +0200 Message-ID: Subject: Re: [PATCH] support -gz=zstd for both linker and assembler To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.0 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,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 List-Id: On Tue, Sep 27, 2022 at 3:54 PM Martin Li=C5=A1ka wrote: > > PING^1 OK Thanks, Richard. > On 9/22/22 14:51, Martin Li=C5=A1ka wrote: > > Hi. > > > > Tested with Fangrui's patch set sent to binutils ML and mold linker. > > > > $ gcc -g -gz=3Dzstd a.c --save-temps --verbose 2>&1 | grep debug-sectio= ns > > /home/marxin/Programming/binutils/objdir/gas/as-new -v --gdwarf-5 --co= mpress-debug-sections=3Dzstd --64 -o a.o a.s > > /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/collect2 -= plugin /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/liblto_p= lugin.so -plugin-opt=3D/home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu= /13.0.0/lto-wrapper -plugin-opt=3D-fresolution=3Da.res -plugin-opt=3D-pass-= through=3D-lgcc -plugin-opt=3D-pass-through=3D-lgcc_s -plugin-opt=3D-pass-t= hrough=3D-lc -plugin-opt=3D-pass-through=3D-lgcc -plugin-opt=3D-pass-throug= h=3D-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x8= 6-64.so.2 --compress-debug-sections=3Dzstd /lib/../lib64/crt1.o /lib/../lib= 64/crti.o /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtbegi= n.o -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0 -L/home/mar= xin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../lib64 -L/lib/.= ./lib64 -L/usr/lib/../lib64 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linu= x-gnu/13.0.0/../../.. a.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgc= c --as-needed -lgcc_s --no-as-needed /home/marxin/bin/gcc/lib64/gcc/x86_64-= pc-linux-gnu/13.0.0/crtend.o /lib/../lib64/crtn.o > > > > $ gdb a.out > > ... > > BFD: /home/marxin/Programming/testcases/a.out: unable to initialize dec= ompress status for section .debug_abbrev > > BFD: /home/marxin/Programming/testcases/a.out: unable to initialize dec= ompress status for section .debug_abbrev > > "/home/marxin/Programming/testcases/a.out": not in executable format: f= ile format not recognized > > > > So it's really compressed with zstd. I'm going to write ChangeLog entry= for zlib-gnu once this gets merged as well. > > > > Ready to be installed? > > Thanks, > > Martin > > > > PR driver/106897 > > > > gcc/ChangeLog: > > > > * common.opt: Add -gz=3Dzstd value. > > * configure.ac: Detect --compress-debug-sections=3Dzstd > > for both linker and assembler. > > * configure: Regenerate. > > * gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Handle -gz=3Dzstd. > > (ASM_COMPRESS_DEBUG_SPEC): Likewise. > > --- > > gcc/common.opt | 5 ++++- > > gcc/configure | 11 +++++++++-- > > gcc/configure.ac | 11 +++++++++-- > > gcc/gcc.cc | 15 +++++++++++++++ > > 4 files changed, 37 insertions(+), 5 deletions(-) > > > > diff --git a/gcc/common.opt b/gcc/common.opt > > index 06ef768ab78..68370db816b 100644 > > --- a/gcc/common.opt > > +++ b/gcc/common.opt > > @@ -3419,7 +3419,10 @@ EnumValue > > Enum(compressed_debug_sections) String(zlib) Value(1) > > > > EnumValue > > -Enum(compressed_debug_sections) String(zlib-gnu) Value(2) > > +Enum(compressed_debug_sections) String(zstd) Value(2) > > + > > +EnumValue > > +Enum(compressed_debug_sections) String(zlib-gnu) Value(3) > > > > gz > > Common Driver > > diff --git a/gcc/configure b/gcc/configure > > index 70a013e9a30..ce4e1859e1f 100755 > > --- a/gcc/configure > > +++ b/gcc/configure > > @@ -29727,13 +29727,16 @@ else > > if $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>= &1 | grep -i warning > /dev/null > > then > > gcc_cv_as_compress_debug=3D0 > > - # Since binutils 2.26, gas supports --compress-debug-sections=3Dzli= b, > > - # defaulting to the ELF gABI format. > > elif $gcc_cv_as --compress-debug-sections=3Dzlib -o conftest.o conf= test.s > /dev/null 2>&1 > > then > > gcc_cv_as_compress_debug=3D1 > > gcc_cv_as_compress_debug_option=3D"--compress-debug-sections" > > gcc_cv_as_no_compress_debug_option=3D"--nocompress-debug-sections= " > > + # Since binutils 2.40, gas supports --compress-debug-sections=3Dz= std. > > + if $gcc_cv_as --compress-debug-sections=3Dzstd -o conftest.o conf= test.s > /dev/null 2>&1 > > + then > > + gcc_cv_as_compress_debug=3D2 > > + fi > > else > > gcc_cv_as_compress_debug=3D0 > > fi > > @@ -30251,6 +30254,10 @@ $as_echo_n "checking linker for compressed deb= ug sections... " >&6; } > > if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\' > /dev/null; then > > gcc_cv_ld_compress_debug=3D1 > > gcc_cv_ld_compress_debug_option=3D"--compress-debug-sections" > > + # Detect zstd debug section compression support > > + if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<= zstd\>' > /dev/null; then > > + gcc_cv_ld_compress_debug=3D2 > > + fi > > else > > case "${target}" in > > *-*-solaris2*) > > diff --git a/gcc/configure.ac b/gcc/configure.ac > > index 96e10d7c194..b6bafa8b7d6 100644 > > --- a/gcc/configure.ac > > +++ b/gcc/configure.ac > > @@ -5732,13 +5732,16 @@ gcc_GAS_CHECK_FEATURE([compressed debug section= s], > > if $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>= &1 | grep -i warning > /dev/null > > then > > gcc_cv_as_compress_debug=3D0 > > - # Since binutils 2.26, gas supports --compress-debug-sections=3Dzli= b, > > - # defaulting to the ELF gABI format. > > elif $gcc_cv_as --compress-debug-sections=3Dzlib -o conftest.o conf= test.s > /dev/null 2>&1 > > then > > gcc_cv_as_compress_debug=3D1 > > gcc_cv_as_compress_debug_option=3D"--compress-debug-sections" > > gcc_cv_as_no_compress_debug_option=3D"--nocompress-debug-sections= " > > + # Since binutils 2.40, gas supports --compress-debug-sections=3Dz= std. > > + if $gcc_cv_as --compress-debug-sections=3Dzstd -o conftest.o conf= test.s > /dev/null 2>&1 > > + then > > + gcc_cv_as_compress_debug=3D2 > > + fi > > else > > gcc_cv_as_compress_debug=3D0 > > fi]) > > @@ -6127,6 +6130,10 @@ AC_MSG_CHECKING(linker for compressed debug sect= ions) > > if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\' > /dev/null; then > > gcc_cv_ld_compress_debug=3D1 > > gcc_cv_ld_compress_debug_option=3D"--compress-debug-sections" > > + # Detect zstd debug section compression support > > + if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<= zstd\>' > /dev/null; then > > + gcc_cv_ld_compress_debug=3D2 > > + fi > > else > > changequote(,)dnl > > case "${target}" in > > diff --git a/gcc/gcc.cc b/gcc/gcc.cc > > index 7578988efa9..2ffbbc0bf2a 100644 > > --- a/gcc/gcc.cc > > +++ b/gcc/gcc.cc > > @@ -835,6 +835,14 @@ proper position among the other output files. */ > > #define LINK_COMPRESS_DEBUG_SPEC \ > > " %{gz|gz=3Dzlib:" LD_COMPRESS_DEBUG_OPTION "=3Dzlib}" \ > > " %{gz=3Dnone:" LD_COMPRESS_DEBUG_OPTION "=3Dnone}" \ > > + " %{gz*:%e-gz=3Dzstd is not supported in this configuration} " \ > > + " %{gz=3Dzlib-gnu:}" /* Ignore silently zlib-gnu option value. *= / > > +#elif HAVE_LD_COMPRESS_DEBUG =3D=3D 2 > > +/* ELF gABI style and ZSTD. */ > > +#define LINK_COMPRESS_DEBUG_SPEC \ > > + " %{gz|gz=3Dzlib:" LD_COMPRESS_DEBUG_OPTION "=3Dzlib}" \ > > + " %{gz=3Dnone:" LD_COMPRESS_DEBUG_OPTION "=3Dnone}" \ > > + " %{gz=3Dzstd:" LD_COMPRESS_DEBUG_OPTION "=3Dzstd}" \ > > " %{gz=3Dzlib-gnu:}" /* Ignore silently zlib-gnu option value. *= / > > #else > > #error Unknown value for HAVE_LD_COMPRESS_DEBUG. > > @@ -890,6 +898,13 @@ proper position among the other output files. */ > > " %{gz|gz=3Dzlib:" AS_COMPRESS_DEBUG_OPTION "=3Dzlib}" \ > > " %{gz=3Dnone:" AS_COMPRESS_DEBUG_OPTION "=3Dnone}" \ > > " %{gz=3Dzlib-gnu:}" /* Ignore silently zlib-gnu option value. *= / > > +#elif HAVE_AS_COMPRESS_DEBUG =3D=3D 2 > > +/* ELF gABI style and ZSTD. */ > > +#define ASM_COMPRESS_DEBUG_SPEC \ > > + " %{gz|gz=3Dzlib:" AS_COMPRESS_DEBUG_OPTION "=3Dzlib}" \ > > + " %{gz=3Dnone:" AS_COMPRESS_DEBUG_OPTION "=3Dnone}" \ > > + " %{gz=3Dzstd:" AS_COMPRESS_DEBUG_OPTION "=3Dzstd}" \ > > + " %{gz=3Dzlib-gnu:}" /* Ignore silently zlib-gnu option value. *= / > > #else > > #error Unknown value for HAVE_AS_COMPRESS_DEBUG. > > #endif >