https://gcc.gnu.org/g:0529fc9fd82f7104309c6338046f49bf9c894233

commit r17-6660-g0529fc9fd82f7104309c6338046f49bf9c894233
Author: Utkarsh Bahuguna <[email protected]>
Date:   Tue Nov 10 21:22:05 2026 +0530

    gccrs: Add a script to regenerate the core diagnostics file
    
    Updating core-1.49.expected meant running the rig and copying its
    output over by hand. This script compiles core with the same flags and
    cleanup as core-diagnostics.exp and writes the file directly, and the
    rig's log now points at it when the output changes.
    
    Assisted-by: Claude Opus (Anthropic)
    
    gcc/testsuite/ChangeLog:
    
            * rust/core/regen-core-expected.sh: New script.
            * rust/core/core-diagnostics.exp: Mention it when the output
            differs.
    
    Signed-off-by: Utkarsh Bahuguna <[email protected]>

Diff:
---
 gcc/testsuite/rust/core/core-diagnostics.exp   |  2 ++
 gcc/testsuite/rust/core/regen-core-expected.sh | 44 ++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/gcc/testsuite/rust/core/core-diagnostics.exp 
b/gcc/testsuite/rust/core/core-diagnostics.exp
index 5e9deee5acc5..eebac9761dc8 100644
--- a/gcc/testsuite/rust/core/core-diagnostics.exp
+++ b/gcc/testsuite/rust/core/core-diagnostics.exp
@@ -57,6 +57,8 @@ proc core-diagnostics { } {
     catch { exec diff -u $expected $actual } diff
     regsub {\nchild process exited abnormally$} $diff "" diff
     send_log "diff -u core-1.49.expected core-diagnostics.out:\n$diff\n"
+    send_log "if the change is expected, update the file with\n"
+    send_log "  $srcdir/$subdir/regen-core-expected.sh <build dir>\n"
     fail "$name: diagnostics differ from core-1.49.expected, see rust.log"
 }
 
diff --git a/gcc/testsuite/rust/core/regen-core-expected.sh 
b/gcc/testsuite/rust/core/regen-core-expected.sh
new file mode 100755
index 000000000000..355536d1bde0
--- /dev/null
+++ b/gcc/testsuite/rust/core/regen-core-expected.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Regenerate the expected output for compiling core 1.49
+#
+# usage: regen-core-expected.sh BUILD_DIR
+#
+# BUILD_DIR is your build directory, the one with gcc/gccrs in it.  Uses
+# the same flags and cleanup as core-diagnostics.exp.
+
+if [ $# -ne 1 ] || [ ! -x "$1/gcc/gccrs" ]; then
+  printf 'usage: %s BUILD_DIR\n' "$0" >&2
+  printf 'BUILD_DIR should point to your GCC build directory\n' >&2
+  exit 1
+fi
+
+bindir=$(cd "$1/gcc" && pwd)
+here=$(cd "$(dirname "$0")" && pwd)
+libdir=$(cd "$here/../../../../libgrust/rustc-lib" && pwd)
+
+flags="-frust-incomplete-and-experimental-compiler-do-not-use
+  -fdiagnostics-plain-output -fno-rust-debug -frust-edition=2018
+  -frust-crate=core -w"
+
+# the testsuite runs in the C locale, so quotes come out as plain '
+set -x
+LC_ALL=C "$bindir/gccrs" -B "$bindir" $flags -S "$libdir/core/src/lib.rs" \
+  -o /dev/null 2>&1 \
+  | sed -e "s|$libdir/||g" -e '/internal compiler error: /q' \
+  > "$here/core-1.49.expected"

Reply via email to