On Thu, 2024-10-31 at 11:36 -0700, Andrew Pinski wrote: > On Thu, Oct 31, 2024 at 10:02 AM Xi Ruoyao <xry...@xry111.site> > wrote: > > > > On Tue, 2024-10-29 at 19:19 -0400, David Malcolm wrote: > > > +static void > > > +test_output_arg_parsing () > > > +{ > > > + auto_fix_quotes fix_quotes; > > > + auto_fix_progname fix_progname; > > > + > > > + /* Minimal correct example. */ > > > + { > > > + parser_test pt; > > > + auto result = pt.parse ("foo"); > > > + ASSERT_EQ (result->m_format, "foo"); > > > + ASSERT_EQ (result->m_kvs.size (), 0); > > > + ASSERT_FALSE (pt.execution_failed_p ()); > > > + } > > > + > > > + /* Stray trailing colon with no key/value pairs. */ > > > + { > > > + parser_test pt; > > > + auto result = pt.parse ("foo:"); > > > + ASSERT_EQ (result, nullptr); > > > + ASSERT_TRUE (pt.execution_failed_p ()); > > > + ASSERT_STREQ (pt.get_diagnostic_text (), > > > + "PROGNAME: error: `-fOPTION=foo:':" > > > + " expected KEY=VALUE-style parameter for format > > > `foo'" > > > + " after `:';" > > > + " got `'\n"); > > > + } > > > > Hi David, > > > > Unfortunately this test fails with LANG=zh_CN.UTF-8, breaking > > bootstrap: > > > > ../../gcc-upstream/gcc/opts-diagnostic.cc:599: > > test_output_arg_parsing: FAIL: ASSERT_STREQ (pt.get_diagnostic_text > > (), "PROGNAME: error: `-fOPTION=foo:':" " expected KEY=VALUE-style > > parameter for format `foo'" " after `:';" " got `'\n") > > val1="PROGNAME: 错误:`-fOPTION=foo:': expected KEY=VALUE-style > > parameter for format `foo' after `:'; got `' > > " > > val2="PROGNAME: error: `-fOPTION=foo:': expected KEY=VALUE-style > > parameter for format `foo' after `:'; got `' > > " > > > > ("错误" just means "error" in Chinese.) > > > > I'm not sure what the best way is to fix the issue. > > This is recorded as > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117361 already. > I think one idea is to set LANG=C before doing the self-check. But I > will allow David and other think of better ways of fixing it.
Sorry about this. For some reason this isn't reproducing for me. That said, I think setting LANG=C when running selftests is probably the best solution. How does the attached (untested) patch look? Dave
From 250cc6e1b2d4e9f44d77ac353e93bf53ff85570b Mon Sep 17 00:00:00 2001 From: David Malcolm <dmalc...@redhat.com> Date: Thu, 31 Oct 2024 16:50:49 -0400 Subject: [PATCH] Use LANG=C when running selftests [PR117361] gcc/ChangeLog: PR bootstrap/117361 * Makefile.in (GCC_FOR_SELFTESTS): New. gcc/c/ChangeLog: PR bootstrap/117361 * Make-lang.in (s-selftest-c): Use GCC_FOR_SELFTESTS. (selftest-c-gdb): Likewise. (selftest-c-valgrind): Likewise. gcc/cp/ChangeLog: PR bootstrap/117361 * Make-lang.in (s-selftest-c++): Use GCC_FOR_SELFTESTS. (selftest-c++-gdb): Likewise. (selftest-c++-valgrind): Likewise. gcc/rust/ChangeLog: PR bootstrap/117361 * Make-lang.in (s-selftest-rust): Use GCC_FOR_SELFTESTS. (selftest-rust-gdb): Likewise. (selftest-rust-valgrind): Likewise. Signed-off-by: David Malcolm <dmalc...@redhat.com> --- gcc/Makefile.in | 3 +++ gcc/c/Make-lang.in | 6 +++--- gcc/cp/Make-lang.in | 6 +++--- gcc/rust/Make-lang.in | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index b4d34cc0b42e..c6c13f2736c5 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -487,6 +487,9 @@ T_STDINT_GCC_H = $(srcdir)/ginclude/stdint-gcc.h # Don't use this as a dependency--use $(GCC_PASSES). GCC_FOR_TARGET = $(STAGE_CC_WRAPPER) ./xgcc -B./ -B$(build_tooldir)/bin/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include -L$(objdir)/../ld $(TFLAGS) +# The GCC to use when running selftests +GCC_FOR_SELFTESTS = LANG=C $(GCC_FOR_TARGET) + # Set if the compiler was configured with --with-build-sysroot. SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@ diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in index 905ab9e79f74..e7082a935635 100644 --- a/gcc/c/Make-lang.in +++ b/gcc/c/Make-lang.in @@ -150,13 +150,13 @@ C_SELFTEST_DEPS = cc1$(exeext) $(SELFTEST_DEPS) # Run the C selftests: s-selftest-c: $(C_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(C_SELFTEST_FLAGS) + $(GCC_FOR_SELFTESTS) $(C_SELFTEST_FLAGS) $(STAMP) $@ # Convenience methods for running C selftests under gdb: .PHONY: selftest-c-gdb selftest-c-gdb: $(C_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(C_SELFTEST_FLAGS) \ + $(GCC_FOR_SELFTESTS) $(C_SELFTEST_FLAGS) \ -wrapper gdb,--args .PHONY: selftest-gdb @@ -165,7 +165,7 @@ selftest-gdb: selftest-c-gdb # Convenience methods for running C selftests under valgrind: .PHONY: selftest-c-valgrind selftest-c-valgrind: $(C_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(C_SELFTEST_FLAGS) \ + $(GCC_FOR_SELFTESTS) $(C_SELFTEST_FLAGS) \ -wrapper valgrind,--leak-check=full .PHONY: selftest-valgrind diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index e792ea4ddf36..fb7ae59d9d4c 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -252,19 +252,19 @@ CPP_SELFTEST_FLAGS = -xc++ $(SELFTEST_FLAGS) # Run the C++ selftests s-selftest-c++: $(CPP_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) + $(GCC_FOR_SELFTESTS) $(CPP_SELFTEST_FLAGS) $(STAMP) $@ # Convenience method for running C++ selftests under gdb: .PHONY: selftest-c++-gdb selftest-c++-gdb: $(CPP_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \ + $(GCC_FOR_SELFTESTS) $(CPP_SELFTEST_FLAGS) \ -wrapper gdb,--args # Convenience method for running C++ selftests under valgrind: .PHONY: selftest-c++-valgrind selftest-c++-valgrind: $(CPP_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(CPP_SELFTEST_FLAGS) \ + $(GCC_FOR_SELFTESTS) $(CPP_SELFTEST_FLAGS) \ -wrapper valgrind,--leak-check=full # 'make check' in gcc/ looks for check-c++, as do all toplevel C++-related diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index aed9a998c80a..69178557059e 100644 --- a/gcc/rust/Make-lang.in +++ b/gcc/rust/Make-lang.in @@ -338,19 +338,19 @@ RUST_SELFTEST_DEPS = crab1$(exeext) $(SELFTEST_DEPS) # Run the rust selftests s-selftest-rust: $(RUST_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) + $(GCC_FOR_SELFTESTS) $(RUST_SELFTEST_FLAGS) $(STAMP) $@ # Convenience methods for running rust selftests under gdb: .PHONY: selftest-rust-gdb selftest-rust-gdb: $(RUST_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \ + $(GCC_FOR_SELFTESTS) $(RUST_SELFTEST_FLAGS) \ -wrapper gdb,--args # Convenience methods for running rust selftests under valgrind: .PHONY: selftest-rust-valgrind selftest-rust-valgrind: $(RUST_SELFTEST_DEPS) - $(GCC_FOR_TARGET) $(RUST_SELFTEST_FLAGS) \ + $(GCC_FOR_SELFTESTS) $(RUST_SELFTEST_FLAGS) \ -wrapper valgrind,--leak-check=full # Install info documentation for the front end, if it is present in the source directory. This target -- 2.26.3