Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2785216rwb; Mon, 5 Sep 2022 01:07:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Ni+hq+4xSWOSdcVFpM8wjQ693w2B1RuXm94xPOJHWTU6GINPLo8Zd18GlxuO+Syi28zjL X-Received: by 2002:a17:903:11c9:b0:172:6ea1:b728 with SMTP id q9-20020a17090311c900b001726ea1b728mr47941474plh.95.1662365254905; Mon, 05 Sep 2022 01:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662365254; cv=none; d=google.com; s=arc-20160816; b=qGc356R1uFi8bjzBi7B/v/whg/t8l04UR8nA+er4CojuhvigAGMQ5zkQ6CrdNB9K+G K2O3LSAnmXAskyesR09URS2D0YxFbGs8hfJkn3uslKW/9ElRXfwz2t8foP8UjVmXgndG KYs4KRYSm2j3o6T/tvHPrc6EzQXSL0+eRYVayT4a7E0L8qaMPDufo1PMxsKxZ6PLyy/A dscZLzEr/sACHG/WG9FOQn7VsMHeZOrAYGpNyX0O32rS81fnrLPQgPbSv+3qwKRXkiNj ymYOR6UpvosB80OUfFEtknVUTUXjSmoUHpNaWoeoVUjV8MN4rEst0xVDXJZVoy05q4a3 OQ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=A8H2tIWtmysI6q42/vGdpy/wkxM6S+6qAW0XkzspLV4=; b=wyhFi1mNX3G0o9K65KTu+7ITdgKC9CyHC0nPoj5uU1ND1GlEsv9Vzxl8drBokX7xkr taZ9nFthUDb5mCikr1nfPNKBbDiYSWMeYfPqTgFmZ/C/pmQRKw22SwItooLddBzxj04y rd5RxnhcIy/T7TlyTirKRSjBXZNf+/CNnb14Efs72rTRStjv0h8gE58YqHoRKRtsJQeY /Y8xSSP1f5gWoRih0viRpehbeUc+0rFZN8+KdI75WesrAShRq8Qc5Cn1wptv4rCusjWZ u15U29etq7X1I4xdTPaTHuDUeyp0vmdwA6WG6hxJGHcU+sja0xYrrsRthVtVpd0RmD7d vMtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cgY5u3eT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a170902ce0100b00176a42dc442si3130388plg.325.2022.09.05.01.07.21; Mon, 05 Sep 2022 01:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cgY5u3eT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236173AbiIEHuH (ORCPT + 99 others); Mon, 5 Sep 2022 03:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236488AbiIEHuF (ORCPT ); Mon, 5 Sep 2022 03:50:05 -0400 Received: from conssluserg-02.nifty.com (conssluserg-02.nifty.com [210.131.2.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D000EDFB3; Mon, 5 Sep 2022 00:49:59 -0700 (PDT) Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 2857nkNj029570; Mon, 5 Sep 2022 16:49:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 2857nkNj029570 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1662364187; bh=A8H2tIWtmysI6q42/vGdpy/wkxM6S+6qAW0XkzspLV4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cgY5u3eTZ88UYDSwr2fLxgjDmMYY6/Srnx7DPWM0pHwo/SpIqLi1lpR3F28bLtfQ6 nXkBTHcFl6Asuvu98Ij4laU6ipVtPxPmjycUInjJFG+9U/7nNVRsEUNVBZPH6Wkwxb 6uee0LIknkwdMgujAFnsxmuD6p5EMz4NmK2Hn07f2PCUKAnQfXk7hRHR9PbIqyWwZ5 l4Da+gt0zwzo72RQLYbRsYabAdoGj38TIRftCpKNpHr7pZTU6QboWOrC8DIA2OoFSL sTW5RdvolAgklHeRW02nsq0VqckJHDTUHw7i6R/4zHKtXMZaFiZJTZ1knXnDZHBtqa fZZoUyshCHF4A== X-Nifty-SrcIP: [209.85.160.46] Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-11eab59db71so19626230fac.11; Mon, 05 Sep 2022 00:49:46 -0700 (PDT) X-Gm-Message-State: ACgBeo1ep+SPf+BmDAmlAcbFCvx3LQZ8/gV10ZZYoiEXZnI5ycCLMpZE WtNWpp623JLi5qKQbix7pnrRKIJChYUx1jKGj9k= X-Received: by 2002:a05:6870:c58b:b0:10b:d21d:ad5e with SMTP id ba11-20020a056870c58b00b0010bd21dad5emr8041384oab.287.1662364185752; Mon, 05 Sep 2022 00:49:45 -0700 (PDT) MIME-Version: 1.0 References: <20220831184408.2778264-1-ndesaulniers@google.com> <20220831184408.2778264-5-ndesaulniers@google.com> In-Reply-To: <20220831184408.2778264-5-ndesaulniers@google.com> From: Masahiro Yamada Date: Mon, 5 Sep 2022 16:49:09 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 4/5] Makefile.debug: re-enable debug info for .S files To: Nick Desaulniers Cc: Michal Marek , Nathan Chancellor , Tom Rix , Linux Kbuild mailing list , Linux Kernel Mailing List , clang-built-linux , X86 ML , Dmitrii Bundin , Fangrui Song , Alexey Alexandrov , Bill Wendling , Greg Thelen Content-Type: multipart/mixed; boundary="000000000000c7ca9a05e7e95216" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000c7ca9a05e7e95216 Content-Type: text/plain; charset="UTF-8" On Thu, Sep 1, 2022 at 3:44 AM Nick Desaulniers wrote: > > Alexey reported that the fraction of unknown filename instances in > kallsyms grew from ~0.3% to ~10% recently; Bill and Greg tracked it down > to assembler defined symbols, which regressed as a result of: > > commit b8a9092330da ("Kbuild: do not emit debug info for assembly with LLVM_IAS=1") > > In that commit, I allude to restoring debug info for assembler defined > symbols in a follow up patch, but it seems I forgot to do so in > > commit a66049e2cf0e ("Kbuild: make DWARF version a choice") > > This patch does a few things: > 1. Add -g to KBUILD_AFLAGS. This will instruct the compiler to instruct > the assembler to emit debug info. But this can cause an issue for > folks using a newer compiler but older assembler, because the > implicit default DWARF version changed from v4 to v5 in gcc-11 and > clang-14. What kind of bad things happen for "KBUILD_AFLAGS += -g"? I think 'gcc -g -c -o foo.o foo.S' will invoke 'as --gdwarf-2' as the backend if gcc is configured to work with old binutils. > diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug > index 9f39b0130551..46e88f0ca998 100644 > --- a/scripts/Makefile.debug > +++ b/scripts/Makefile.debug > @@ -4,18 +4,32 @@ ifdef CONFIG_DEBUG_INFO_SPLIT > DEBUG_CFLAGS += -gsplit-dwarf > else > DEBUG_CFLAGS += -g > +KBUILD_AFLAGS += -g > endif > > -ifndef CONFIG_AS_IS_LLVM > -KBUILD_AFLAGS += -Wa,-gdwarf-2 > +ifdef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT > +# gcc-11+, clang-14+ > +ifeq ($(call cc-min-version, 110000, 140000),y) > +dwarf-version-y := 5 > +else > +dwarf-version-y := 4 If you explicitly specify the DWARF version for CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT, what is the point of CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT? When CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y, I believe the right thing to do is to pass only -g, and let the tool do whatever it thinks is appropriate. > endif > - > -ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT > +else # !CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > endif > > +# Binutils 2.35+ (or clang) required for -gdwarf-{4|5}. > +# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=31bf18645d98b4d3d7357353be840e320649a67d > +ifneq ($(call as-option,-Wa$(comma)-gdwarf-$(dwarf-version-y)),) When is this as-option supposed to fail? Binutils <= 2.34 always accepts whatever -gdwarf-* option. Surprisingly or not, it accepts -gdwarf-6, -gdwarf-7, ... No matter what DWARF version you specify, GAS silently downgrades it to DWARF-2. masahiro@zoe:~/tools/binutils-2.34/bin$ ./as --version | head -n 1 GNU assembler (GNU Binutils) 2.34 masahiro@zoe:~/tools/binutils-2.34/bin$ cat /dev/null | ./as -gdwarf-5 -o /dev/null - masahiro@zoe:~/tools/binutils-2.34/bin$ echo $? 0 masahiro@zoe:~/tools/binutils-2.34/bin$ cat /dev/null | ./as -gdwarf-100 -o /dev/null - masahiro@zoe:~/tools/binutils-2.34/bin$ echo $? 0 Overall, I am not convinced with this patch. Please see the attached patch. Is there any problem with writing this more simply? > +KBUILD_AFLAGS += -Wa,-gdwarf-$(dwarf-version-y) > +else > +ifndef CONFIG_AS_IS_LLVM > +KBUILD_AFLAGS += -Wa,-gdwarf-2 > +endif > +endif > + > ifdef CONFIG_DEBUG_INFO_REDUCED > DEBUG_CFLAGS += -fno-var-tracking > ifdef CONFIG_CC_IS_GCC > -- > 2.37.2.672.g94769d06f0-goog > -- Best Regards Masahiro Yamada --000000000000c7ca9a05e7e95216 Content-Type: text/x-patch; charset="US-ASCII"; name="dwarf.diff" Content-Disposition: attachment; filename="dwarf.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l7ogoa5i0 ZGlmZiAtLWdpdCBhL2xpYi9LY29uZmlnLmRlYnVnIGIvbGliL0tjb25maWcuZGVidWcKaW5kZXgg YmNiZTYwZDZjODBjLi4zN2FhMTlmMGY3YjAgMTAwNjQ0Ci0tLSBhL2xpYi9LY29uZmlnLmRlYnVn CisrKyBiL2xpYi9LY29uZmlnLmRlYnVnCkBAIC0yNjQsNiArMjY0LDcgQEAgY29uZmlnIERFQlVH X0lORk9fRFdBUkZfVE9PTENIQUlOX0RFRkFVTFQKIGNvbmZpZyBERUJVR19JTkZPX0RXQVJGNAog CWJvb2wgIkdlbmVyYXRlIERXQVJGIFZlcnNpb24gNCBkZWJ1Z2luZm8iCiAJc2VsZWN0IERFQlVH X0lORk8KKwlkZXBlbmRzIG9uICFDQ19JU19DTEFORyB8fCAoQ0NfSVNfQ0xBTkcgJiYgKEFTX0lT X0xMVk0gfHwgKEFTX0lTX0dOVSAmJiBBU19WRVJTSU9OID49IDIzNTAwKSkpCiAJaGVscAogCSAg R2VuZXJhdGUgRFdBUkYgdjQgZGVidWcgaW5mby4gVGhpcyByZXF1aXJlcyBnY2MgNC41KyBhbmQg Z2RiIDcuMCsuCiAKZGlmZiAtLWdpdC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