On Thu, Mar 25, 2010 at 11:33:17PM +0900, Tadashi Koike wrote:
> Hi Richard
> (* I am weak in English, so pleas forgive my English mistake.)
>
> Thank you for your reply, and I'm sorry to be late a reply.
>
> > On Sat, Mar 20, 2010 at 5:40 PM, Tadashi Koike <[email protected]> wrote:
> >> [ summary ]
> >> compiling is failed when more than two source file are
> >> specified with both -save-temps=obj and -o options.
> :
> >> [[ operations being error ]]
> >> % gcc -save-temps=obj -o hellow main.c func.c
> >> % gcc -save-temps=obj -o obj_dir/hellow main.c func.c
>
> 2010/3/21 Richard Guenther <[email protected]>:
> >
> > It should be an error to use -save-temps=obj with multiple
> > input files. Mike, can you look at this?
> >
> > Thanks,
> > Richard.
> >
>
> After I received your reply, I confirm an information about "-save-temps=obj".
I tend to agree with Richard, that if there are multiple source inputs, it
should be an error to use -save-temps=obj without the -c/-S option.
Though it might be friendlier to allow:
gcc -o dir/exe a.c b.c c.c
and put the temp files in:
dir/a.{s,i}
dir/b.{s,i}
dir/c.{s,i}
But it would fail for doing:
gcc -o exe dir1/a.c dir2/a.c
where the names overlap. Let me look at it.
> In this URL(http://gcc.gnu.org/gcc-4.5/changes.html), "-save-temps=obj"
> option are introduced as follow:
>
> | The -save-temps=obj switch will write files into the directory specified
> | with the -o option, and the intermediate filenames are based on the
> | output file.
>
> If above is a specification of "-save-temps=obj" option, found behaviors
> in my report about "-save-temps=obj" are true behaviors (but cannot
> deal in case of multiple input files).
>
> I considered. And I read a purpose of this option in above URL :
>
> | This will allow the user to get the compiler intermediate files when
> | doing parallel builds without two builds of the same filename located in
> | different directories from interfering with each other.
>
> My recognition is below:
> - True purpose is a failure of compiling under parallel builds. In detail,
> problem is a compiling failure under parallel builds caused by
> interfering
> intermediate file each other. To solve this problem, developer thought
> that the intermediate files have to be created in different directory.
> So a directory specified with the -o option are choose as these purpose.
>
> (I named this problem as "Compiling failure by interfering" for following
> discussion.)
Yes, the motivation was for doing large builds (notably spec 2006) where
several of the files have the same base name but are in different
subdirectories. In particular, I could not build 436.cactusADM with -j8
without getting conflicts (bugzilla 39293). Even if I built it with -j1 so
they wouldn't interfere, I would lose the asm files for some of the builds,
which would mean my static analysis programs would miss some objects.
I have also seen conflicts with -save-temps if you use have -j numbers when
doing a compiler bootstrap.
> - If two builds of the same file name located in different directories are
> done as serial, each build is successful fine, but intermediate file is
> overwritten by a latest compiling.
> (I named this problem as "Overwritten by interfering" for following
> discussion.)
Yes.
> - A purpose of "-save-temps=obj" option is to solve the "Compiling
> failure by interfering", not to solve the "Overwritten by interfering".
Well the real purpose is to allow me to better debug stuff when doing large
builds, so that I can go back without having to do the build by hand. Just
like when I added the original -save-temps option around 1988 or so.
> From my consideration, I reached some understanding as follow:
> - True solution for "Compiling failure by interferng" is using a
> true independent file name which is assured by System (such as
> filename returned by tmpnam() function in stdio.h) for each
> intermediate file. After compiling are successful, filename of
> intermediate files need to change as true filenames based on
> source/object files.
Well if this is a big problem for you, when 4.6 opens up, feel free to add a
new varient of -save-temps=<xxx>. The current implementation of
-save-temps=obj meets the needs that I had in doing large builds.
> - "-save-temps=obj" option is useful to solve some "Overwritten
> by interfering" problems. Trouble will decrease caused this
> problem. (so I hope/want this option very much)
>
> - I hope that the filename of intermediate file by "-save-temps=obj"
> is also based on source files.
>
> I hope to hear someone's opinion else.
--
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
[email protected]