diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/cmd/6c/swt.c | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/cmd/6c/swt.c')
-rw-r--r-- | src/cmd/6c/swt.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/cmd/6c/swt.c b/src/cmd/6c/swt.c index f16d0f78a..58d6d5129 100644 --- a/src/cmd/6c/swt.c +++ b/src/cmd/6c/swt.c @@ -247,18 +247,12 @@ outcode(void) Binit(&b, f, OWRITE); Bprint(&b, "go object %s %s %s\n", getgoos(), thestring, getgoversion()); - if(ndynimp > 0 || ndynexp > 0) { - int i; - + if(pragcgobuf.to > pragcgobuf.start) { Bprint(&b, "\n"); Bprint(&b, "$$ // exports\n\n"); Bprint(&b, "$$ // local types\n\n"); - Bprint(&b, "$$ // dynimport\n"); - for(i=0; i<ndynimp; i++) - Bprint(&b, "dynimport %s %s %s\n", dynimp[i].local, dynimp[i].remote, dynimp[i].path); - Bprint(&b, "\n$$ // dynexport\n"); - for(i=0; i<ndynexp; i++) - Bprint(&b, "dynexport %s %s\n", dynexp[i].local, dynexp[i].remote); + Bprint(&b, "$$ // cgo\n"); + Bprint(&b, "%s", fmtstrflush(&pragcgobuf)); Bprint(&b, "\n$$\n\n"); } Bprint(&b, "!\n"); @@ -339,12 +333,38 @@ outhist(Biobuf *b) char *p, *q, *op, c; Prog pg; int n; + char *tofree; + static int first = 1; + static char *goroot, *goroot_final; + + if(first) { + // Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL. + first = 0; + goroot = getenv("GOROOT"); + goroot_final = getenv("GOROOT_FINAL"); + if(goroot == nil) + goroot = ""; + if(goroot_final == nil) + goroot_final = goroot; + if(strcmp(goroot, goroot_final) == 0) { + goroot = nil; + goroot_final = nil; + } + } + tofree = nil; pg = zprog; pg.as = AHISTORY; c = pathchar(); for(h = hist; h != H; h = h->link) { p = h->name; + if(p != nil && goroot != nil) { + n = strlen(goroot); + if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') { + tofree = smprint("%s%s", goroot_final, p+n); + p = tofree; + } + } op = 0; if(systemtype(Windows) && p && p[1] == ':'){ c = p[2]; @@ -400,6 +420,11 @@ outhist(Biobuf *b) Bputc(b, pg.lineno>>24); zaddr(b, &pg.from, 0); zaddr(b, &pg.to, 0); + + if(tofree) { + free(tofree); + tofree = nil; + } } } @@ -591,8 +616,8 @@ align(int32 i, Type *t, int op, int32 *maxalign) int32 maxround(int32 max, int32 v) { - v += SZ_VLONG-1; + v = xround(v, SZ_VLONG); if(v > max) - max = xround(v, SZ_VLONG); + return v; return max; } |