Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: cannot be used to bootstrap go 1.5 #10092

Closed
h4ck3rm1k3 opened this issue Mar 6, 2015 · 19 comments
Closed

gccgo: cannot be used to bootstrap go 1.5 #10092

h4ck3rm1k3 opened this issue Mar 6, 2015 · 19 comments

Comments

@h4ck3rm1k3
Copy link

There is a strange bug when you run the go command from this source tree compiled with gccgo 4.9

Using gccgo-5
gccgo-5 (Debian 5-20150226-1) 5.0.0 20150226 (experimental) [trunk revision 220999]

compile like this

gccgo-5  -g -o go6 cmd/go/main.go cmd/go/build.go cmd/go/clean.go cmd/go/context.go cmd/go/discovery.go cmd/go/doc.go cmd/go/env.go cmd/go/fix.go cmd/go/fmt.go cmd/go/generate.go cmd/go/get.go cmd/go/go11.go cmd/go/help.go cmd/go/http.go cmd/go/list.go cmd/go/pkg.go cmd/go/run.go cmd/go/signal.go cmd/go/signal_unix.go cmd/go/testflag.go cmd/go/test.go cmd/go/testgo.go cmd/go/tool.go cmd/go/vcs.go cmd/go/version.go cmd/go/vet.go cmd/go/cc.go

ln -s ~/experiments/go/src/go6 ~/go1.4/bin/go

run then like this

export GOROOT=~/experiments/go/
export GOPATH=~/experiments/go/
./all.bash 

errors out with

import cycle not allowed
package cmd/dist
    imports bytes
    imports errors
    imports runtime
    imports unsafe
    imports runtime
@mikioh mikioh changed the title gccgo cannot be used to bootstrap go 1.5 gccgo: cannot be used to bootstrap go 1.5 Mar 6, 2015
@mikioh mikioh added the gccgo label Mar 6, 2015
@h4ck3rm1k3
Copy link
Author

When I link then the source code to the ~/go1.4/src we get a different error

ln -s ~/experiments/go/ . ~/go1.4/

and then
build the dist outside the system.
cp dist.6 cmd/dist/dist

mdupont@mdupont-Aspire-7750G:~/go1.4/src$ bash ./all.bash 
##### Building Go bootstrap tool.
cmd/dist
WORK=/tmp/go-build179595840

##### Building Go toolchain using /mnt/data/home/mdupont/go1.4.
bootstrap/internal/obj
bootstrap/asm/internal/flags
bootstrap/internal/gc
bootstrap/internal/obj/arm
bootstrap/internal/ld
bootstrap/internal/obj/x86
bootstrap/internal/obj/ppc64
bootstrap/asm/internal/lex
bootstrap/internal/asm
# bootstrap/asm/internal/lex
../../../../go1.4/pkg/bootstrap/src/bootstrap/asm/internal/lex/tokenizer.go:43:3: error: reference to undefined field or method 'IsIdentRune'
  s.IsIdentRune = isIdentRune
   ^
bootstrap/old5a
bootstrap/old9a
# bootstrap/internal/gc
../../../../go1.4/pkg/bootstrap/src/bootstrap/internal/gc/reg.go:224:2: error: missing statement after label
  memcase:
  ^
bootstrap/asm/internal/arch
bootstrap/old6a
bootstrap/old8a
bootstrap/5l
bootstrap/6l
bootstrap/8l
bootstrap/9l
go tool dist: FAILED: /mnt/data/home/mdupont/go1.4/bin/go install -v bootstrap/...

So you turn off the deleting of the dist tool and build it manually.

@h4ck3rm1k3
Copy link
Author

see my branch here with the make file
h4ck3rm1k3/google-go@cc2b942

cpu info did not build, skipped it
h4ck3rm1k3/google-go@c282bd6#diff-08b793eecf5656817d57c70701b1c45cL490

turn off the build of dist
h4ck3rm1k3/google-go@c282bd6#diff-0bd01a098860e0bfe2917d0ee12e7575L120

@paranoiacblack
Copy link
Contributor

/cc @ianlancetaylor

@ianlancetaylor
Copy link
Contributor

I think the "import cycle not allowed" problem happens when gccgo sees packages that have the same name as packages in GOROOT. Because gccgo has no GOROOT, it gets confused and thinks those packages are the ones in GOROOT. That is, if GOPATH has a time package, gccgo thinks that is the package it is supposed to use for import "time", even though really it will use the standard time package. This doesn't happen with the gc compiler because it sees the GOROOT time package and knows that one will be used first. Since gccgo has no GOROOT, this does not happen.

The way that the go tool handles GOROOT needs to change when using gccgo.

@h4ck3rm1k3
Copy link
Author

Yes, that is right. The problem with the cycle was resolved when I
symlinked in the code into the goroot

On Fri, Mar 13, 2015 at 5:25 PM, Ian Lance Taylor [email protected]
wrote:

I think the "import cycle not allowed" problem happens when gccgo sees
packages that have the same name as packages in GOROOT. Because gccgo has
no GOROOT, it gets confused and thinks those packages are the ones in
GOROOT. That is, if GOPATH has a time package, gccgo thinks that is the
package it is supposed to use for import "time", even though really it will
use the standard time package. This doesn't happen with the gc compiler
because it sees the GOROOT time package and knows that one will be used
first. Since gccgo has no GOROOT, this does not happen.

The way that the go tool handles GOROOT needs to change when using gccgo.

Reply to this email directly or view it on GitHub
#10092 (comment).

James Michael DuPont
Member of Free Libre Open Source Software Kosova http://www.flossk.org
Saving Wikipedia(tm) articles from deletion http://SpeedyDeletion.wikia.com

@davecheney davecheney added this to the Go1.5 milestone Mar 19, 2015
@davecheney davecheney self-assigned this Mar 19, 2015
@davecheney davecheney modified the milestones: Go1.5Maybe, Go1.5 Mar 19, 2015
mwhudson added a commit to mwhudson/go that referenced this issue Apr 13, 2015
fixes golang#10092

Change-Id: I7307753896962d37f087e581854b06f4945db5ef
@mwhudson
Copy link
Contributor

I'm not sure what is going on with this bug, but if I use the go-5 binary that comes with the gccgo-5 package on vivid (as in "mkdir -p ~/gccgo_for_bootstrap/bin; ln -s /usr/bin/go-5 /gccgo_for_bootstrap/bin/go; GOROOT_BOOTSTRAP=/gccgo_for_bootstrap ./make.bash") then the only issues that prevent it working are the assembly files in the cmd/dist directory.

@mwhudson
Copy link
Contributor

See linked branch for a fix for that; with this applied, the bootstrap completes for me.

@h4ck3rm1k3
Copy link
Author

Great news, will check it out.

@davecheney
Copy link
Contributor

https://go-review.googlesource.com/8809

Please test

@minux
Copy link
Member

minux commented Apr 13, 2015 via email

@h4ck3rm1k3
Copy link
Author

I have been able to do this now.

setting these environmental variables
export GOTOOLDIR=${HOME}/install/bin
export GCCGO=${HOME}/install/bin/gccgo
export LD_LIBRARY_PATH=${HOME}/install/lib64
export PATH=${PATH}:${HOME}/install/bin
export GOROOT_BOOTSTRAP=${HOME}/go

can run ./make.bash to produce a go binary.

thanks for your help, I learned a lot in this long process.

mike

@davecheney
Copy link
Contributor

You don't need anything but GOROOT_BOOTSTRAP and LD_LIBRARY_PATH.

On Wed, 15 Apr 2015 02:24 James Michael DuPont [email protected]
wrote:

I have been able to do this now.

setting these environmental variables
export GOTOOLDIR=${HOME}/install/bin
export GCCGO=${HOME}/install/bin/gccgo
export LD_LIBRARY_PATH=${HOME}/install/lib64
export PATH=${PATH}:${HOME}/install/bin
export GOROOT_BOOTSTRAP=${HOME}/go

can run ./make.bash to produce a go binary.

thanks for your help, I learned a lot in this long process.

mike


Reply to this email directly or view it on GitHub
#10092 (comment).

@h4ck3rm1k3
Copy link
Author

The go cmd does not find my compiler. I do not have root and it is not installed. Without the PATH I get this :

builddist.sh: line 4: gccgo: command not found

Without setting the GCCGO, I get

run: /home/h4ck3rm1k3/go/pkg/bootstrap /home/h4ck3rm1k3/go/bin/go install bootstrap/...
go build bootstrap/internal/gc/big: : fork/exec : no such file or directory

I added a -n build to the dist too and that show this :

cd /home/h4ck3rm1k3/go/pkg/bootstrap/src/bootstrap/old9a
"" -I $WORK -I /home/h4ck3rm1k3/go/pkg/bootstrap/pkg/gccgo_linux_ppc64le -c -g -fgo-relative-import-path=_/home/h4ck3rm1k3/go\
/pkg/bootstrap/src/bootstrap/old9a -o $WORK/bootstrap/old9a/_obj/_go_.o ./lex.go ./y.go
ar cru $WORK/bootstrap/libold9a.a $WORK/bootstrap/old9a/_obj/_go_.o

It does not find the compiler.

So the flags that I absolutly need for my building of gccgo from source and installing it in my homedir are :

export GCCGO=${HOME}/install/bin/gccgo
export LD_LIBRARY_PATH=${HOME}/install/lib64
export PATH=${PATH}:${HOME}/go/bin:${HOME}/install/bin
export GOROOT_BOOTSTRAP=${HOME}/go

BTW, If I run the compilation again with the new go, I get :

go tool: no such tool "9g"

@davecheney
Copy link
Contributor

What is builddist.sh, is it part of Go.

I think the issue you are having is unrelated to this bug.

On Wed, 15 Apr 2015 14:09 James Michael DuPont [email protected]
wrote:

The go cmd does not find my compiler. I do not have root and it is not
installed. Without the PATH I get this :

builddist.sh: line 4: gccgo: command not found

Without setting the GCCGO, I get

run: /home/h4ck3rm1k3/go/pkg/bootstrap /home/h4ck3rm1k3/go/bin/go install bootstrap/...
go build bootstrap/internal/gc/big: : fork/exec : no such file or directory

I added a -n build to the dist too and that show this :

cd /home/h4ck3rm1k3/go/pkg/bootstrap/src/bootstrap/old9a
"" -I $WORK -I /home/h4ck3rm1k3/go/pkg/bootstrap/pkg/gccgo_linux_ppc64le -c -g -fgo-relative-import-path=_/home/h4ck3rm1k3/go
/pkg/bootstrap/src/bootstrap/old9a -o $WORK/bootstrap/old9a/_obj/go.o ./lex.go ./y.go
ar cru $WORK/bootstrap/libold9a.a $WORK/bootstrap/old9a/_obj/go.o

It does not find the compiler.

So the flags that I absolutly need for my building of gccgo from source
and installing it in my homedir are :

export GCCGO=${HOME}/install/bin/gccgo
export LD_LIBRARY_PATH=${HOME}/

install/lib64
export PATH=${PATH}:${HOME}/go/bin:${HOME}/install/bin
export GOROOT_BOOTSTRAP=${HOME}/go

BTW, If I run the compilation again with the new go, I get :

go tool: no such tool "9g"


Reply to this email directly or view it on GitHub
#10092 (comment).

@h4ck3rm1k3
Copy link
Author

The builddist.sh is my script, oh i see. Let me checkout the master branch again.
On origin/master 47515e0

export LD_LIBRARY_PATH=${HOME}/install/lib64
export PATH=${PATH}:${HOME}/go/bin:${HOME}/install/bin
export GOROOT_BOOTSTRAP=${HOME}/go

bash make.bash

##### Building Go bootstrap tool.
cmd/dist
# cmd/dist
fork/exec /usr/local/bin/gcc: no such file or directory

The compiler is not installed in usr/local/bin that is why i needed to compile dist with my script

my builddist script is just the output from the go build command cleaned up.
https://github.com/h4ck3rm1k3/go/blob/bootstrap-v2/src/builddist.sh

@davecheney
Copy link
Contributor

Your GOROOT_BOOTSTRAP is wrong, it should point to the same value as your passed to gcc's ./configure --prefix

On 15 Apr 2015, at 14:34, James Michael DuPont [email protected] wrote:

The builddist.sh is my script, oh i see. Let me checkout the master branch again.
On origin/master 47515e0

export LD_LIBRARY_PATH=${HOME}/install/lib64
export PATH=${PATH}:${HOME}/go/bin:${HOME}/install/bin
export GOROOT_BOOTSTRAP=${HOME}/go
bash make.bash

Building Go bootstrap tool.

cmd/dist

cmd/dist

fork/exec /usr/local/bin/gcc: no such file or directory
The compiler is not installed in usr/local/bin that is why i needed to compile dist with my script

my builddist script is just the output from the go build command cleaned up.
https://github.com/h4ck3rm1k3/go/blob/bootstrap-v2/src/builddist.sh


Reply to this email directly or view it on GitHub.

@h4ck3rm1k3
Copy link
Author

I have the same problem there.

+ export GOROOT=/home/h4ck3rm1k3/go
+ GOROOT=/home/h4ck3rm1k3/go
+ GOROOT_BOOTSTRAP=/home/h4ck3rm1k3/install
+ '[' '!' -x /home/h4ck3rm1k3/install/bin/go ']'
+ rm -f cmd/dist/dist
+ GOROOT=/home/h4ck3rm1k3/install
+ GOOS=
+ GOARCH=
+ /home/h4ck3rm1k3/install/bin/go build -o cmd/dist/dist ./cmd/dist
# _/home/h4ck3rm1k3/go/src/cmd/dist
fork/exec /usr/local/bin/gcc: no such file or directory

I am going to try and rebuild the compiler cleanly again.

@minux
Copy link
Member

minux commented Apr 15, 2015 via email

@h4ck3rm1k3
Copy link
Author

It was a problem with the prefix, yes, I thought I fixed it but did not clean the previous build correctly.

cd build
../configure --prefix=/home/h4ck3rm1k3/install/ --enable-languages=go

and then the bootstrap build works out of the box.

this works! thank you everyone for your patience in helping me learn this amazing new system.

mike

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants