On 9/16/22 07:52, Jason Merrill wrote:
On 6/24/22 01:23, Alexandre Oliva via Gcc-patches wrote:
On Jun 23, 2022, Alexandre Oliva <ol...@adacore.com> wrote:

Here's the patch.  Regstrapped on x86_64-linux-gnu, also tested with a
cross to aarch64-rtems6.  Ok to install?

Introduce -nostdlib++ option

Uhh, I went ahead and installed this.  The earlier patch was approved if
nobody objected, and so, having overcome the objection to the option
spelling, it ended up in my "approved" patchset.

In case there are objections to it, please let me know, and I'll revert
it promptly, but I guess it makes little sense to revert it on the odd
change that someone does.  Thanks for your understanding.

I'm getting failures from pure-virtual1.C with

xg++: error: unrecognized command-line option '-nostdlib++'

I guess that's because it isn't handled by the specs in the way nostdlib and nodefautlibs are.  Maybe the solution is to set SKIPOPT in the driver?

Are you not seeing this problem?

I started seeing this again and decided to track it down more. It seems to be dependent on specs, as explained in this commit message:

From 0e74112cf494c93f170739b87ecc89b2d5d97f92 Mon Sep 17 00:00:00 2001
From: Jason Merrill <ja...@redhat.com>
Date: Sun, 27 Nov 2022 14:30:14 -0500
Subject: [PATCH] driver: fix validate_switches logic
To: gcc-patches@gcc.gnu.org

Under the old logic for validate_switches, once suffix or starred got set,
they stayed set for all later switches found in the spec.  So for e.g.

%{g*:%{%:debug-level-gt(0):

Once we see g*, starred is set.  Then we see %:, and it sees that as a
zero-length switch, which because starred is still set, matches any and all
command-line options.  So targets that use such a spec accept all options in
the driver, while ones that don't reject some, such as the recent
-nostdlib++.

This patch fixes the inconsistency, so all targets reject -nostdlib++.

gcc/ChangeLog:

	* gcc.cc (validate_switches): Reset suffix/starred on loop.
---
 gcc/gcc.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index ca1c9e27a94..2278e2b6bb1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -9299,12 +9299,15 @@ validate_switches (const char *start, bool user_spec, bool braced)
   const char *atom;
   size_t len;
   int i;
-  bool suffix = false;
-  bool starred = false;
+  bool suffix;
+  bool starred;
 
 #define SKIP_WHITE() do { while (*p == ' ' || *p == '\t') p++; } while (0)
 
 next_member:
+  suffix = false;
+  starred = false;
+
   SKIP_WHITE ();
 
   if (*p == '!')
-- 
2.31.1

Reply via email to