public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "James K. Lowden" <jklowden@schemamania.org>
To: gcc@gcc.gnu.org
Subject: Re: passing command-line arguments, still
Date: Sat, 19 Mar 2022 13:10:29 -0400	[thread overview]
Message-ID: <20220319131029.49490fb71bf0bbaae4c598bf@schemamania.org> (raw)
In-Reply-To: <CAH6eHdSsh8DdeJK_SJ7sn1gZxu8J0Wt1udRrdHELhkjrWUGwrQ@mail.gmail.com>

I'm collecting my remarks in one reply here, hopefully for easier
reading.  I want to offer my thanks, and also my assessment of the
situation as I understand it.  My critique is intended as purely
constructive. 

I understand vaguely what's going on.  I'll use the -findicator-column=
form because it works, and because that's today's convention. 

I assert: 

1.  I did define my option to take an argument.
2.  The documentation is incomplete and incorrect.
3.  The naming convention is inconsistent. 

Joseph Myers answered my question directly: 

> The .opt files control how options are parsed, both in the driver and
> in the compiler programs such as cc1.  Passing of options from the
> driver to those compiler programs is based on specs in the driver; -f
> options are passed down because of the use of %{f*} in cc1_options
> (and the use of %(cc1_options) in the specs for most languages).

IIUC, it's not lang.opt, but lang-specs.h:

$ nl lang-specs.h 
     1  /* gcc-src/gcc/config/lang-specs.h */
     2      {".cob", "@cobol", 0, 1, 0},
     3      {".COB", "@cobol", 0, 1, 0},
     4      {".cbl", "@cobol", 0, 1, 0},
     5      {".CBL", "@cobol", 0, 1, 0},
     6      {"@cobol", "cobol1 %i %(cc1_options) %{!fsyntax-only:%
(invoke_as)}", 0, 1, 0},

The contents of that file are unspecified.  gccint.info says only: 

> 'lang-specs.h'
>      This file provides entries for 'default_compilers' in 'gcc.c'
> which override the default of giving an error that a compiler for that
>      language is not installed.

I implemented the above by cargo-cult coding.   Until today I had no
idea what line 6 does.  Now I have only some idea. 

I don't understand where the %{} syntax is processed.  I'm guessing
autoconf, which on this project is above my pay grade.   

On Thu, 17 Mar 2022 17:39:00 +0000
Jonathan Wakely <jwakely.gcc@gmail.com> wrote:

> You didn't define your option to take an argument in the
> .opt file.

Of course I did: 

  indicator-column
  Cobol Joined Separate UInteger Var(indicator_column) Init(0)
      IntegerRange(0, 8) 
  Column after which Region B begins

That says it takes an argument -- either Joined or Separate -- as an
unsigned integer initialized to 0 in the range [0,8].  Not only that,
the option is accepted by gcobol; it's just not passed to the
compiler.  

The documentation does not say an option taking an argument must
end in "=" and does not recommend it begin with "f".  

Marek Polacek <polacek@redhat.com> wrote:
> > 2.  GCC accepts a  -fno- alternative, automatically
> 
> Right, unless it's RejectNegative.

Yes, and RejectNegative is an instrument of accidental complexity. If
-f options automatically accept a -fno- option, then a -f option that
does not want a -fno- alternative should use another name.  There are
25 other lowercase letters available.

> > 3.  The "f" stands for "flag", meaning on/off.  
> 
> It does stand for "flag", and it looks like at some point in ancient
> history if was on/off, but then came options like -falign-loops=N.

IME, someone made a mistake in the past, and that mistake is now
becoming mistaken for a standard.  I don't mind living with some cruft
-- it's not as though gcc is unique in that regard -- but at the same
time I see no reason to vernerate it or perpetuate it. 

In plain words, if we recognize that -f indicates an on/off switch,
let's use it that way, deprecate those that don't, and not add new -f
options that take arguments. 

One last, final minor point, 

> >      By default, all options beginning with "f", "W" or "m" are
> >      implicitly assumed to take a "no-" form.  

> > More accurate would be
> > to say a "fno-" form is automatically accepted or generated.
> 
> TBH, I don't see how that would be any more accurate that what we
> have now.

Words matter. No one is assuming anything, a fact hidden by the passive
"are implicitly assumed".  I don't know whether -fno- is "accepted" or
"generated", or by what.  I'm suggesting the agent be stated and the
verb not hide what's happening.  I would say: 

	"Options beginning with "f", "W" or "m" also 
	<accept/produce/create>
	a "no-" form generated by <technology>.  

I wouldn't say "by default", because it's not by default.  It's by
design, and the alternative is contained in the next sentence. 

I've said my peace.  I have my option, and I'll use it.   If any of my
assertions is incorrect, I'd be happy to be corrected.  I hope my
observations, if correct, contribute to better option names and
documentation.

My thanks for your help.  I'm sure we've spent more time on
this corner of configuration than we expected to.  

--jkl

  reply	other threads:[~2022-03-19 17:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 18:34 James K. Lowden
2022-03-16 18:45 ` Marek Polacek
2022-03-17 16:21   ` James K. Lowden
2022-03-17 17:39     ` Jonathan Wakely
2022-03-19 17:10       ` James K. Lowden [this message]
2022-03-19 17:53         ` David Edelsohn
2022-03-21 10:19           ` Jonathan Wakely
2022-03-21 10:21         ` Jonathan Wakely
2022-03-17 18:37     ` Joseph Myers
2022-03-17 19:16     ` Marek Polacek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220319131029.49490fb71bf0bbaae4c598bf@schemamania.org \
    --to=jklowden@schemamania.org \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).