Bug 39293 - -save-temps does not follow the -o option and instead puts the temp file in the current directory
Summary: -save-temps does not follow the -o option and instead puts the temp file in t...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 17:47 UTC by Michael Meissner
Modified: 2009-04-29 12:08 UTC (History)
3 users (show)

See Also:
Host: x86_64-gnu-linux
Target: powerpc64-linux
Build: x86_64-gnu-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
This patch fixes -save-temps so that it puts the temp file in the output directory rather than the current directory (2.26 KB, patch)
2009-02-28 01:01 UTC, Michael Meissner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meissner 2009-02-24 17:47:17 UTC
I was building Spec 2006 with a powerpc64-linux cross compiler using the -save-temps option so that I could do some analysis on the generated code.  Unfortunately, if I use -j4 in the make for the spec build, the test cactusADM does not build.  I traced this down to there were several Startup.c files in different directories, and the spec make uses -o to put the resulting objects in different directories:

<gcc>/gcc <flags> -o PUGH/Startup.o PUGH/Startup.c
<gcc>/gcc <flags> -o IOUtil/Startup.o IOUtil/Startup.c
<gcc>/gcc <flags> -o BenchADMsrc/Startup.o BenchADMsrc/Startup.c
<gcc>/gcc <flags> -o CartGrid3D/Startup.o CartGrid3D/Startup.c
...

As luck would have it, make decided to compile several of of the Startup.c's at the same time, and since they wrote the files in the current directory, they overwrote each other, and the assembler complained about illegal input.
Comment 1 Andrew Pinski 2009-02-24 18:10:18 UTC
Here at Sony we added -save-temps-o option which does this.
Comment 2 jsm-csl@polyomino.org.uk 2009-02-24 19:07:59 UTC
Subject: Re:   New: -save-temps does not follow the -o
 option and instead puts the temp file in the current directory

I've also found this to be a pain when working on glibc, where compilation 
commands are run from subdirectories of the source directory so using 
-save-temps causes the temporary files to be put in the source directory, 
after which the glibc build system can end up using them for future builds 
in preference to the actual source files.

Comment 3 Michael Meissner 2009-02-28 01:01:35 UTC
Created attachment 17374 [details]
This patch fixes -save-temps so that it puts the temp file in the output directory rather than the current directory
Comment 4 Michael Meissner 2009-04-02 20:45:40 UTC
Subject: Bug 39293

Author: meissner
Date: Thu Apr  2 20:45:26 2009
New Revision: 145470

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145470
Log:
[PATCH, committed] Add -save-temps=obj, PR 39293

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/invoke.texi
    trunk/gcc/gcc.c

Comment 5 Ben Elliston 2009-04-29 12:08:27 UTC
Fixed for 4.5.