From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id A1B6A3959C95; Wed, 16 Nov 2022 11:49:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1B6A3959C95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668599376; bh=QJtCAQDgDTTXHWLLPNh4woxyhRchVvsjE22CKinje5I=; h=From:To:Subject:Date:From; b=K3Uv4Gm4kUgETPV8FHqnsRbxNnJCWJJWjEG70lafRJB/CjkzXjMs/tINy7UoWIxR6 mPtZ/bDupsZu1BUmCfotCMTq2wPaI0z/xTW/QIvGPwZ6NJuM+yYI9h+m61ny2hXqPM PVzmPFI3Y5HSy8qfqyfbScpQc1mr/xNG5Cd3ah9s= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] dwarf2out.c: Don't emit DW_LANG_Rust_old X-Act-Checkin: gcc X-Git-Author: Mark Wielaard X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 2d1c287af3a074d40e84234be9feca904af627d5 X-Git-Newrev: cdcfe27cfba23402f91200c64c1ef8e0bf3528a0 Message-Id: <20221116114936.A1B6A3959C95@sourceware.org> Date: Wed, 16 Nov 2022 11:49:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cdcfe27cfba23402f91200c64c1ef8e0bf3528a0 commit cdcfe27cfba23402f91200c64c1ef8e0bf3528a0 Author: Mark Wielaard Date: Sun Oct 30 16:03:16 2022 +0100 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. Diff: --- 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" } } */ }