Commit e982ecac authored by Russ Cox's avatar Russ Cox

cmd/ld: add tmpdir flag to preserve temp files

R=ken2
CC=golang-dev
https://golang.org/cl/7497044
parent 433824d8
......@@ -123,6 +123,7 @@ main(int argc, char *argv[])
flagstr("r", "dir1:dir2:...: set ELF dynamic linker search path", &rpath);
flagcount("race", "enable race detector", &flag_race);
flagcount("s", "disable symbol table", &debug['s']);
flagstr("tmpdir", "leave temporary files in this directory", &tmpdir);
flagcount("u", "reject unsafe packages", &debug['u']);
flagcount("v", "print link trace", &debug['v']);
flagcount("w", "disable DWARF generation", &debug['w']);
......
......@@ -117,10 +117,11 @@ main(int argc, char *argv[])
flagstr("r", "dir1:dir2:...: set ELF dynamic linker search path", &rpath);
flagcount("race", "enable race detector", &flag_race);
flagcount("s", "disable symbol table", &debug['s']);
flagcount("shared", "generate shared object", &flag_shared);
flagstr("tmpdir", "leave temporary files in this directory", &tmpdir);
flagcount("u", "reject unsafe packages", &debug['u']);
flagcount("v", "print link trace", &debug['v']);
flagcount("w", "disable DWARF generation", &debug['w']);
flagcount("shared", "generate shared object", &flag_shared);
flagparse(&argc, &argv, usage);
......
......@@ -123,6 +123,7 @@ main(int argc, char *argv[])
flagcount("race", "enable race detector", &flag_race);
flagcount("s", "disable symbol table", &debug['s']);
flagcount("n", "dump symbol table", &debug['n']);
flagstr("tmpdir", "leave temporary files in this directory", &tmpdir);
flagcount("u", "reject unsafe packages", &debug['u']);
flagcount("v", "print link trace", &debug['v']);
flagcount("w", "disable DWARF generation", &debug['w']);
......
......@@ -557,8 +557,6 @@ hostobjs(void)
}
}
static char *tmpdir;
static void
rmtemp(void)
{
......@@ -574,10 +572,11 @@ hostlinksetup(void)
return;
// create temporary directory and arrange cleanup
// TODO: Add flag to specify tempdir, which is then not cleaned up.
tmpdir = mktempdir();
atexit(rmtemp);
if(tmpdir == nil) {
tmpdir = mktempdir();
atexit(rmtemp);
}
// change our output to temporary object file
close(cout);
p = smprint("%s/go.o", tmpdir);
......
......@@ -148,6 +148,7 @@ EXTERN int flag_race;
EXTERN int flag_shared;
EXTERN char* tracksym;
EXTERN char* interpreter;
EXTERN char* tmpdir;
enum
{
......@@ -166,8 +167,7 @@ enum
EXTERN Segment segtext;
EXTERN Segment segdata;
EXTERN Segment segsym;
EXTERN Segment segdwarf;
EXTERN Segment segdwarf;
void addlib(char *src, char *obj);
void addlibpath(char *srcref, char *objref, char *file, char *pkg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment