1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:54:45 -07:00

ld: Fixes issue 1899 ("cannot create 8.out.exe")

http://code.google.com/p/go/issues/detail?id=1899

R=rsc, alex.brainman, bsiegert, hectorchu, bradfitz
CC=golang-dev
https://golang.org/cl/4978047
This commit is contained in:
Jaroslavas Počepko 2011-10-14 20:37:07 +01:00 committed by Hector Chu
parent b3812bf6db
commit ff866c4ca3
2 changed files with 13 additions and 3 deletions

View File

@ -42,9 +42,13 @@ for i in \
$GC $i $GC $i
done done
# Write to temporary file to avoid mingw bash bug.
TMPFILE="/tmp/gotest3"
function testit { function testit {
$LD $1.$O $LD $1.$O
x=$(echo $(./$O.out $2 2>&1)) # extra echo canonicalizes ./$O.out $2 2>&1 >"$TMPFILE" || true
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
if [ "$x" != "$3" ] if [ "$x" != "$3" ]
then then
echo $1 failed: '"'$x'"' is not '"'$3'"' echo $1 failed: '"'$x'"' is not '"'$3'"'
@ -53,7 +57,8 @@ function testit {
function testitpipe { function testitpipe {
$LD $1.$O $LD $1.$O
x=$(echo $(./$O.out | $2 2>&1)) # extra echo canonicalizes ./$O.out | $2 2>&1 >"$TMPFILE" || true
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
if [ "$x" != "$3" ] if [ "$x" != "$3" ]
then then
echo $1 failed: '"'$x'"' is not '"'$3'"' echo $1 failed: '"'$x'"' is not '"'$3'"'
@ -88,4 +93,4 @@ testit server1 "" ""
testit eff_bytesize "" "1.00YB 9.09TB" testit eff_bytesize "" "1.00YB 9.09TB"
testit eff_sequence "" "[-1 2 6 16 44]" testit eff_sequence "" "[-1 2 6 16 44]"
rm -f $O.out *.$O rm -f $O.out $O.out.exe *.$O "$TMPFILE"

View File

@ -70,7 +70,12 @@ libinit(void)
// add goroot to the end of the libdir list. // add goroot to the end of the libdir list.
libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch); libdir[nlibdir++] = smprint("%s/pkg/%s_%s", goroot, goos, goarch);
// Unix doesn't like it when we write to a running (or, sometimes,
// recently run) binary, so remove the output file before writing it.
// On Windows 7, remove() can force the following create() to fail.
#ifndef _WIN32
remove(outfile); remove(outfile);
#endif
cout = create(outfile, 1, 0775); cout = create(outfile, 1, 0775);
if(cout < 0) { if(cout < 0) {
diag("cannot create %s", outfile); diag("cannot create %s", outfile);