https://gcc.gnu.org/g:fbc94ff6e7615c7e5aeff8f3e0a2f894889e1b4f
commit r15-7129-gfbc94ff6e7615c7e5aeff8f3e0a2f894889e1b4f Author: Arsen Arsenović <ar...@aarsen.me> Date: Mon Sep 2 21:29:53 2024 +0200 d,ada/spec: only sub nostd{inc,lib} rather than nostd{inc,lib}* This prevents the gcc driver erroneously accepting -nostdlib++ when it should not when Ada was enabled. Also, similarly, -nostdinc* (where * is nonempty) is unhandled by either the Ada or D compiler, so the spec should not substitute those either (thanks for pointing that out, Jakub). Brought to my attention by Michał Górny <mgo...@gentoo.org>. gcc/ada/ChangeLog: * gcc-interface/lang-specs.h: Replace %{nostdinc*} %{nostdlib*} with %{nostdinc} %{nostdlib}. gcc/d/ChangeLog: * lang-specs.h: Replace %{nostdinc*} with %{nostdinc}. gcc/testsuite/ChangeLog: * gcc.dg/driver-nostdlibstar.c: New test. Diff: --- gcc/ada/gcc-interface/lang-specs.h | 6 +++--- gcc/d/lang-specs.h | 2 +- gcc/testsuite/gcc.dg/driver-nostdlibstar.c | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/ada/gcc-interface/lang-specs.h b/gcc/ada/gcc-interface/lang-specs.h index 2ba0f1d20a74..bfa41afe621b 100644 --- a/gcc/ada/gcc-interface/lang-specs.h +++ b/gcc/ada/gcc-interface/lang-specs.h @@ -37,7 +37,7 @@ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ %{!S:%{!c:%e-c or -S required for Ada}}\ gnat1 %{I*} %{k8:-gnatk8} %{!Q:-quiet}\ - %{nostdinc*} %{nostdlib*}\ + %{nostdinc} %{nostdlib}\ %{fcompare-debug-second:-gnatd_A} \ %{O*} %{W*} %{w} %{p} %{pg:-p} " ADA_DUMPS_OPTIONS " \ %{coverage:-fprofile-arcs -ftest-coverage} " @@ -55,7 +55,7 @@ "\ %{!c:%e-c required for gnat2why}\ gnat1why %{I*} %{k8:-gnatk8} %{!Q:-quiet}\ - %{nostdinc*} %{nostdlib*}\ + %{nostdinc} %{nostdlib}\ %{a} " ADA_DUMPS_OPTIONS " \ %{gnatea:-gnatez} %{g*&m*&f*} \ %1 %{o*:%w%*-gnatO} \ @@ -66,7 +66,7 @@ "\ %{!c:%e-c required for gnat2scil}\ gnat1scil %{I*} %{k8:-gnatk8} %{!Q:-quiet}\ - %{nostdinc*} %{nostdlib*}\ + %{nostdinc} %{nostdlib}\ %{a} " ADA_DUMPS_OPTIONS " \ %{gnatea:-gnatez} %{g*&m*&f*} \ %1 %{o*:%w%*-gnatO} \ diff --git a/gcc/d/lang-specs.h b/gcc/d/lang-specs.h index 2292e7eac9fa..64e7a5f25988 100644 --- a/gcc/d/lang-specs.h +++ b/gcc/d/lang-specs.h @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see {".dd", "@d", 0, 1, 0 }, {".di", "@d", 0, 1, 0 }, {"@d", - "%{!E:d21 %i %(cc1_options) %I %{nostdinc*} %{i*} %{I*} %{J*} \ + "%{!E:d21 %i %(cc1_options) %I %{nostdinc} %{i*} %{I*} %{J*} \ %{H} %{Hd*} %{Hf*} %{MD:-MD %b.deps} %{MMD:-MMD %b.deps} \ %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} \ %{X:-Xf %b.json} %{Xf*} \ diff --git a/gcc/testsuite/gcc.dg/driver-nostdlibstar.c b/gcc/testsuite/gcc.dg/driver-nostdlibstar.c new file mode 100644 index 000000000000..b3b208248abe --- /dev/null +++ b/gcc/testsuite/gcc.dg/driver-nostdlibstar.c @@ -0,0 +1,4 @@ +// Test that the GCC driver (which has no concept of libstdc++) rejects -nostdlib++ +// { dg-additional-options "-nostdlib++" } +// { dg-prune-output "compilation terminated" } +// { dg-error "unrecognized command-line option '-nostdlib\\+\\+'" "" { target *-*-* } 0 }