On Thu, 26 Dec 2019, Alexandre Oliva wrote: > On Dec 25, 2019, Alexandre Oliva <ol...@adacore.com> wrote: > > > 3. do not take the executable name into account when it shares the > > basename with an input file; combine executable basename with input name > > otherwise. this makes gcc -o foo[.exe] -g -gsplit-dwarf foo.c output > > foo.dwo rather than foo-foo.dwo, which is nice, but then dwo files > > compiled for use with foo won't all match foo-*.dwo; it seems more > > desirable that they all do > > > 4. same as above, but only when there is only one input file, so that > > after adding bar.c to the command above, you'd get foo-foo.dwo and > > foo-bar.dwo > > > Me, I'm leaning towards 5. > > And yet I ended up implementing 4 after some more thinking, because the > point was to reduce gratuitous and unnecessary changes. > > > Here's my first cut at documenting all of the various complex > interactions between -o, -dumpbase, -dumpbase-ext, -dumpdir, and > save-temps=* > > Is this too cryptic, to the point of requiring lots of examples to make > it understandable, or is this usable enough?
It's understandable and indeed also very helpful. So I agree to go forward with this (variant 4). Did I miss the actual (non-documentation) patch? Thanks, Richard. > > @@ -1561,6 +1563,89 @@ assembler file in @file{@var{source}.s}, a precompiled > header file in > @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on > standard output. > > + > +@item -dumpbase @var{dumpbase} > +@opindex dumpbase > +This option sets the base name for auxiliary and dump output files. It > +does not affect the name of the main output file, implied or specified > +with @option{-o}. It may affect intermediate outputs, however: > + > +@smallexample > +gcc -save-temps -S foo.c& > +@end smallexample > + > +saves the (no longer) temporary preprocessed file in @file{foo.i}, and > +then compiles to the (implied) output file @file{foo.s}, whereas: > + > +@smallexample > +gcc -save-temps -dumpbase save-foo -c foo.c& > +@end smallexample > + > +preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now > +an intermediate, thus auxiliary output), and then assembles to the > +(implied) output file @file{foo.o}. > + > +If absent, dump and aux files their names from the input file, or from > +the (non-linker) output file, if one is explicitly specified: dump > +output files (e.g. those requested by -fdump-* options) with the input > +name suffix, and aux output files (those requested by other non-dump > +options, e.g. @code{-save-temps}, @code{-gsplit-dwarf}, > +@code{-fcallgraph-info}) without it. > + > +Similar suffix differentiation of dump and aux outputs can be attained > +for explicitly-given @option{-dumpbase basename.suf} by also specifying > +@option{-dumpbase-ext .suf}. > + > +If @var{dumpbase} is explicitly specified with any directory component, > +@option{-dumpdir} and other @var{dumppfx}-setting @option{-save-temps=*} > +options are ignored, and instead of appending to it, @var{dumpbase} > +fully overrides it. > + > +When @option{-dumpbase} is specified in a command that compiles multiple > +inputs, or that compiles and then links, it may be combined with > +@var{dumppfx}, as specified under @option{-dumpdir}, and each input file > +is then compiled using the combined @var{dumppfx}, and default values > +for @var{dumpbase} and @var{auxdropsuf} computed for each input file. > + > + > +@item -dumpbase-ext @var{auxdropsuf} > +@opindex dumpbase-ext > +When forming the name of an auxiliary (but not a dump) output file, drop > +trailing @var{auxdropsuf} from @var{dumpbase} before appending any > +suffixes. If not specified, this option defaults to the suffix of the > +input file, including the period. > + > + > +@item -dumpdir @var{dumppfx} > +@opindex dumpdir > +When forming the name of an auxiliary or dump output file, use > +@var{dumppfx} as a prefix. If it is to be used as a directory name, it > +must end with a directory separator. > + > +It defaults to the location of the output file; options > +@option{-save-temps=cwd} and @option{-save-temps=obj} override this > +default, just like an explicit @option{-dumpdir} option. In case > +multiple such options are given, the last one prevails. > + > +When compiling from multiple input files, if @option{-dumpbase} is > +specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash > +are appended to (or override, if containing any directory components) an > +explicit or defaulted @var{dumppfx}, so that each of the multiple > +compilations gets differently-named aux and dump outputs. > + > +When compiling and then linking from multiple input files, a defaulted > +or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- > +transformation above. If neither @option{-dumpdir} nor > +@option{-dumpbase} are given, the linker output base name, minus the > +executable suffix, plus a dash is appended to the default @var{dumppfx} > +instead. > + > +When compiling and then linking from a single input file, the linker > +output base name will only be appended to the default @var{dumppfx} as > +above if it does not share the base name with the single input file > +name. > + > + > @item -v > @opindex v > Print (on standard error output) the commands executed to run the stages > > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)