On Thu, 1 Dec 2022 17:14:31 +0000 (UTC)
Michael Matz <m...@suse.de> wrote:

> > 3.  Correct the entries in the default_compilers array.  Currently I
> > have in cobol/lang-specs.h:
> > 
> >     {".cob", "@cobol", 0, 0, 0},
> >     {".COB", "@cobol", 0, 0, 0},
> >     {".cbl", "@cobol", 0, 0, 0},
> >     {".CBL", "@cobol", 0, 0, 0},
> >     {"@cobol", 
> >     "cobol1 %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}", 
> >     0, 0, 0}, 
> 
> It misses %(cpp_unique_options) which was the reason why your -I
> arguments weren't passed to cobol1.  

If I understood you correctly, I don't need to modify gcc.cc.  I only
need to modify cobol/lang-specs.h, which I've done.  But that's
evidently not all I need to do, because it doesn't seem to work.  

The last element in the fragment in cobol/lang-specs.h is now: 

    {"@cobol",
        "cobol1 %i %(cc1_options) %{!fsyntax-only:%(invoke_as)} "
        "%(cpp_unique_options) ",
        0, 0, 0},

(using string constant concatenation).  That's the only change I made,
so far, because everything we said (AIUI) boiled down to, "just add
cpp_unique_options to your spec string".  

> You would just your new %(cobol_options), or simply '%{v} %{I*}'
> directly in addition to cc1_options.

I didn't do that.  IIUC, the 2nd element in the struct can be a string
constant or the address of a char* variable.  So, I chose a string
constant. 

Getting wiser with age, I used -### to dump the cobol1 command
line.  It appears to be consistent with observed behavior: when I run
under gdb and stop at the cobol1::main function, argc is 14, and argv
does not include the -I option. 

The -### output reports the cobol1 command line (as 14 strings,
exactly) on line 10.  In additon to what was supplied (by me, invoking
gcobol), it shows:

        -quiet
        -dumpdir o- -dumpbase csytst10.cbl 
        -dumpbase-ext .cbl
        "-main=gcc/cobol/prim/samples/CUBES/cobol/csytst10.cbl"
        "-mtune=generic" 
        "-march=x86-64" 
        -o /tmp/ccLYrc6D.s

The -main I can explain later if it matters.  The others are magic I
don't understand and don't think matter, but I show them so you know.  

Note that I'm invoking gcobol from the build tree, using -B (among
others) to make it DTRT.  

I see the -B and -I options, and others, with their arguments, contained
in COLLECT_GCC_OPTIONS on lines 9 and 11.  I guess that represents an
environment string?  Or, anyway, a string that holds the options that
will be passed to collect2?  

The contents of COLLECT_GCC_OPTIONS appear to be a superset of the
options supplied on the cobol1 command line. 

It would seem the single change I made is less than the minimum
required, but I confess I've lost track of why anything more is
needed.  

--jkl

Reply via email to