From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 883B53858D28; Sun, 30 Oct 2022 15:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 883B53858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x15.wildebeest.org [172.31.17.151]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 4411C330CD52; Sun, 30 Oct 2022 16:22:35 +0100 (CET) Received: by reform (Postfix, from userid 1000) id C2A9E2E81682; Sun, 30 Oct 2022 16:22:34 +0100 (CET) Date: Sun, 30 Oct 2022 16:22:34 +0100 From: Mark Wielaard To: Jakub Jelinek Cc: arthur.cohen@embecosm.com, Jason Merrill , Tom Tromey , gcc-patches@gcc.gnu.org, gcc-rust@gcc.gnu.org Subject: Re: [PATCH Rust front-end v3 01/46] Use DW_ATE_UTF for the Rust 'char' type Message-ID: References: <20221026081811.602573-1-arthur.cohen@embecosm.com> <20221026081811.602573-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="f7+O6QkuT6H3Rhi8" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3039.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,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: --f7+O6QkuT6H3Rhi8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Wed, Oct 26, 2022 at 10:39:09AM +0200, Jakub Jelinek wrote: > I must say I don't understand nor like this DW_LANG_Rust_old stuff at all. > Other languages don't do similar dances. > Look for D, or Go. Neither of them has any non-standard lang code as > fallback, they use the DWARF assigned DW_LANG_* code, and DW_LANG_C as > fallback. On most arches, DWARF 5 is the default anyway, or non-strict > DWARF at least. Where neither is enabled because of prehistoric or buggy > DWARF consumers, it is unlikely they'd handle Rust sanely anyway. > Just follow what Go does in the same function. DW_LANG_Rust_old was used by old rustc compilers <= 2016 before DWARF5 assigned an official number. It might be recognized by some debuggers. But I agree that these days it doesn't really make sense to emit it. When producing strict DWARF it is also slightly odd to emit a non-standard language code. So I agree that it makes sense to do what Go does, always emit DW_LANG_Rust unless we emit strict DWARF for versions before 5 (and then just fall back to DW_LANG_C). The attached patch (against "upstream gccrs") does that. I kept the oldlang.rs testcase just to see that the -gstrict-dwarf -gdwarf-3 case does something sane. The only "issue" is that is_rust () depends on the comp_unit_die DW_AT_language being DW_LANG_Rust. But the only usage of is_rust already depends on strict DWARF. https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=no-Rust-old if someone wants to push that, to merge for a v4. Thanks, Mark --f7+O6QkuT6H3Rhi8 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-dwarf2out.c-Don-t-emit-DW_LANG_Rust_old.patch" >From cdcfe27cfba23402f91200c64c1ef8e0bf3528a0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 30 Oct 2022 16:03:16 +0100 Subject: [PATCH] dwarf2out.c: Don't emit DW_LANG_Rust_old DW_LANG_Rust_old is a non-standard DWARF language code used by old rustc compilers before DWARF5 (released in 2017). Just always emit DW_LANG_Rust unless producing strict DWARF for versions before 5. And in that old strict DWARF case just emit DW_LANG_C instead of a non-standard language code. --- gcc/dwarf2out.cc | 14 +++++--------- gcc/testsuite/rust/debug/oldlang.rs | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 7b9d5ae33fc..87c0d103a27 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -5600,14 +5600,15 @@ is_fortran (const_tree decl) return is_fortran (); } -/* Return TRUE if the language is Rust. */ +/* Return TRUE if the language is Rust. + Note, returns FALSE for dwarf_version < 5 && dwarf_strict. */ static inline bool is_rust () { unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); - return lang == DW_LANG_Rust || lang == DW_LANG_Rust_old; + return lang == DW_LANG_Rust; } /* Return TRUE if the language is Ada. */ @@ -25216,13 +25217,6 @@ gen_compile_unit_die (const char *filename) } else if (strcmp (language_string, "GNU F77") == 0) language = DW_LANG_Fortran77; - else if (strcmp (language_string, "GNU Rust") == 0) - { - if (dwarf_version >= 5 || !dwarf_strict) - language = DW_LANG_Rust; - else - language = DW_LANG_Rust_old; - } else if (dwarf_version >= 3 || !dwarf_strict) { if (strcmp (language_string, "GNU Ada") == 0) @@ -25248,6 +25242,8 @@ gen_compile_unit_die (const char *filename) { if (strcmp (language_string, "GNU Go") == 0) language = DW_LANG_Go; + else if (strcmp (language_string, "GNU Rust") == 0) + language = DW_LANG_Rust; } } /* Use a degraded Fortran setting in strict DWARF2 so is_fortran works. */ diff --git a/gcc/testsuite/rust/debug/oldlang.rs b/gcc/testsuite/rust/debug/oldlang.rs index ddacf0e4392..648d6b78f06 100644 --- a/gcc/testsuite/rust/debug/oldlang.rs +++ b/gcc/testsuite/rust/debug/oldlang.rs @@ -1,6 +1,6 @@ fn main () { // { dg-do compile } // { dg-options "-gstrict-dwarf -gdwarf-3 -dA" } -// DW_LANG_Rust_old is 0x9000 -// { dg-final { scan-assembler "0x9000\[ \t]\[^\n\r]* DW_AT_language" } } */ +// Strict DWARF < 5 uses DW_LANG_C = 0x0002 +// { dg-final { scan-assembler "0x2\[ \t]\[^\n\r]* DW_AT_language" } } */ } -- 2.30.2 --f7+O6QkuT6H3Rhi8--