On 12/07/2017 05:10 AM, Nathan Sidwell wrote:
> There's an unfortunate interaction between -save-temps=obj and
> -fdump-tree-<whatever> when subdirectories are in play.
>
> Consider:
> g++ -fdump-tree-all -save-temps=obj -c -o tgt/x.o sub/x.cc
> we end up with a bunch of errors of the form:
> sub/x.cc:1:0: error: could not open dump file
> ‘tgt/tgt/x.046t.profile_estimate’: No such file or directory
>
> you'll see it's added the 'tgt' sub directory twice. The reason is that
> cc1plus is invoked as:
>
> /usr/libexec/gcc/x86_64-redhat-linux/7/cc1plus -E -quiet -v
> -D_GNU_SOURCE sub/x.cc -mtune=generic -march=x86-64 -ansi
> -Woverloaded-virtual -Wall -Wpointer-arith -Wwrite-strings
> -felide-constructors -fdump-tree-all -fpch-preprocess -o tgt/x.ii
>
> to generate the preprocessed output, and then as:
>
> /usr/libexec/gcc/x86_64-redhat-linux/7/cc1plus -fpreprocessed tgt/x.ii
> -quiet -dumpbase tgt/x -mtune=generic -march=x86-64 -auxbase-strip
> tgt/x.o -Woverloaded-virtual -Wall -Wpointer-arith -Wwrite-strings -ansi
> -version -felide-constructors -fdump-tree-all -o tgt/x.s
>
> for the compilation itself. That has '-dumpbase tgt/x' and
> '-auxbase-strip tgt/x.o' passed in.
>
> The options processing checks if dump-base is absolute, and if not
> prefixes dump_dir_name or aux_base_name's directory components.
>
> It seems to me that the absolute path check is incomplete. We should
> check if dump-base has /any/ directory components. If it does, we
> shouldn't touch it. That's what this patch does:
>
> 1) remove the absolute dir check. That's subsumed into ...
> 2) look for any DIR_SEPARATOR in the dump-base. If so, no prefixing
> 3 & 4) existing prefix code
> 5) always set dump_base_name_prefixed, so we don't repeat #2 on a
> subsequent invocation.
>
> With this patch we now get a successful compilation:
>
> nathans@lyta:7>egcs/trunk/obj/x86_64/gcc/xg++ -B
> egcs/trunk/obj/x86_64/gcc/ -fdump-tree-all -save-temps=obj -c -o tgt/x.o
> sub/x.cc
> nathans@lyta:8>ls tgt
> total 100
> 4 x.003t.original 4 x.010t.eh 4 x.020t.ssa 4
> x.049t.release_ssa 4 x.220t.switchlower 4 x.o
> 4 x.004t.gimple 4 x.011t.cfg 4 x.027t.fixup_cfg3
> 4 x.050t.local-fnsummary2 4 x.226t.resx 4 x.s
> 4 x.006t.omplower 4 x.012t.ompexp 4 x.028t.local-fnsummary1 4
> x.087t.fixup_cfg4 4 x.228t.optimized
> 4 x.007t.lower 4 x.013t.printf-return-value1 4
> x.029t.einline 4 x.218t.veclower 0 x.313t.statistics
> 4 x.009t.ehopt 4 x.019t.fixup_cfg1 0
> x.046t.profile_estimate 4 x.219t.cplxlower0 4 x.ii
>
> ok?
>
> nathan
> --
> Nathan Sidwell
>
> pfx.diff
>
>
> 2017-12-06 Nathan Sidwell <nat...@acm.org>
>
> * opts.c (finish_options): Don't prefix dump_base_name if it
> already contains directories.
OK.
jeff