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

build: redeclaration errors after switching branches #9231

Open
bradfitz opened this issue Dec 10, 2014 · 17 comments
Open

build: redeclaration errors after switching branches #9231

bradfitz opened this issue Dec 10, 2014 · 17 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

I had to revert to go1.4 yesterday because cross-compiling was (or is) broken, and now master won't build, revealing that we might be .gitignoring too many files.

git status shows I have a clean tree at tip, but the build suggests otherwise:

mac:go bradfitz$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
mac:go bradfitz$ git rev-parse HEAD
2937d88af591920d72d1ddd480df4c2c31532d2d
mac:go bradfitz$ cd src/
mac:src bradfitz$ ./make.bash
# Building C bootstrap tool.
cmd/dist

# Building compilers and Go bootstrap tool for host, darwin/amd64.
lib9
libbio
liblink
cmd/gc
cmd/6l
cmd/6a
cmd/6g
runtime
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:7: _Gidle redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:18
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:8: _Grunnable redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:19
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:9: _Grunning redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:20
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:10: _Gsyscall redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:21
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:11: _Gwaiting redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:22
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:12: _Gmoribund_unused redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:23
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:13: _Gdead redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:24
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:14: _Genqueue redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:25
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:15: _Gcopystack redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:26
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:16: _Gscan redeclared in this block
    previous declaration at /Users/bradfitz/go/src/runtime/runtime2.go:28
/Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go:16: too many errors
go tool dist: FAILED: /Users/bradfitz/go/pkg/tool/darwin_amd64/6g -pack -o $WORK/_go_.a -p runtime -+ -asmhdr $WORK/go_asm.h /Users/bradfitz/go/src/runtime/alg.go /Users/bradfitz/go/src/runtime/arch1_amd64.go /Users/bradfitz/go/src/runtime/arch_amd64.go /Users/bradfitz/go/src/runtime/atomic_amd64x.go /Users/bradfitz/go/src/runtime/cgo.go /Users/bradfitz/go/src/runtime/cgocall.go /Users/bradfitz/go/src/runtime/cgocallback.go /Users/bradfitz/go/src/runtime/chan.go /Users/bradfitz/go/src/runtime/chan1.go /Users/bradfitz/go/src/runtime/compiler.go /Users/bradfitz/go/src/runtime/complex.go /Users/bradfitz/go/src/runtime/cpuprof.go /Users/bradfitz/go/src/runtime/cputicks.go /Users/bradfitz/go/src/runtime/debug.go /Users/bradfitz/go/src/runtime/defs_darwin_amd64.go /Users/bradfitz/go/src/runtime/env_posix.go /Users/bradfitz/go/src/runtime/error.go /Users/bradfitz/go/src/runtime/extern.go /Users/bradfitz/go/src/runtime/hashmap.go /Users/bradfitz/go/src/runtime/hashmap_fast.go /Users/bradfitz/go/src/runtime/heapdump.go /Users/bradfitz/go/src/runtime/iface.go /Users/bradfitz/go/src/runtime/lfstack.go /Users/bradfitz/go/src/runtime/lfstack_amd64.go /Users/bradfitz/go/src/runtime/lock_sema.go /Users/bradfitz/go/src/runtime/malloc.go /Users/bradfitz/go/src/runtime/malloc1.go /Users/bradfitz/go/src/runtime/malloc2.go /Users/bradfitz/go/src/runtime/mcache.go /Users/bradfitz/go/src/runtime/mcentral.go /Users/bradfitz/go/src/runtime/mem.go /Users/bradfitz/go/src/runtime/mem_darwin.go /Users/bradfitz/go/src/runtime/mfixalloc.go /Users/bradfitz/go/src/runtime/mgc.go /Users/bradfitz/go/src/runtime/mgc0.go /Users/bradfitz/go/src/runtime/mgc1.go /Users/bradfitz/go/src/runtime/mheap.go /Users/bradfitz/go/src/runtime/mprof.go /Users/bradfitz/go/src/runtime/msize.go /Users/bradfitz/go/src/runtime/netpoll.go /Users/bradfitz/go/src/runtime/netpoll_kqueue.go /Users/bradfitz/go/src/runtime/os1_darwin.go /Users/bradfitz/go/src/runtime/os2_darwin.go /Users/bradfitz/go/src/runtime/os_darwin.go /Users/bradfitz/go/src/runtime/panic.go /Users/bradfitz/go/src/runtime/panic1.go /Users/bradfitz/go/src/runtime/parfor.go /Users/bradfitz/go/src/runtime/print1.go /Users/bradfitz/go/src/runtime/proc.go /Users/bradfitz/go/src/runtime/proc1.go /Users/bradfitz/go/src/runtime/race0.go /Users/bradfitz/go/src/runtime/rdebug.go /Users/bradfitz/go/src/runtime/rune.go /Users/bradfitz/go/src/runtime/runtime.go /Users/bradfitz/go/src/runtime/runtime1.go /Users/bradfitz/go/src/runtime/runtime2.go /Users/bradfitz/go/src/runtime/select.go /Users/bradfitz/go/src/runtime/sema.go /Users/bradfitz/go/src/runtime/signal1_unix.go /Users/bradfitz/go/src/runtime/signal_amd64x.go /Users/bradfitz/go/src/runtime/signal_darwin.go /Users/bradfitz/go/src/runtime/signal_darwin_amd64.go /Users/bradfitz/go/src/runtime/signal_unix.go /Users/bradfitz/go/src/runtime/sigpanic_unix.go /Users/bradfitz/go/src/runtime/sigqueue.go /Users/bradfitz/go/src/runtime/slice.go /Users/bradfitz/go/src/runtime/softfloat64.go /Users/bradfitz/go/src/runtime/sqrt.go /Users/bradfitz/go/src/runtime/stack1.go /Users/bradfitz/go/src/runtime/stack2.go /Users/bradfitz/go/src/runtime/string.go /Users/bradfitz/go/src/runtime/string1.go /Users/bradfitz/go/src/runtime/stubs.go /Users/bradfitz/go/src/runtime/stubs2.go /Users/bradfitz/go/src/runtime/symtab.go /Users/bradfitz/go/src/runtime/sys_x86.go /Users/bradfitz/go/src/runtime/time.go /Users/bradfitz/go/src/runtime/traceback.go /Users/bradfitz/go/src/runtime/type.go /Users/bradfitz/go/src/runtime/typekind.go /Users/bradfitz/go/src/runtime/typekind1.go /Users/bradfitz/go/src/runtime/vdso_none.go /Users/bradfitz/go/src/runtime/wbfat.go /Users/bradfitz/go/src/runtime/zgoarch_amd64.go /Users/bradfitz/go/src/runtime/zgoos_darwin.go /Users/bradfitz/go/src/runtime/zruntime_defs_darwin_amd64.go /Users/bradfitz/go/src/runtime/zversion.go
mac:src bradfitz$

Is it this line of .gitignore that's too ignore-y?

src/runtime/z*

?

@bradfitz
Copy link
Contributor Author

Also, after the failed make.bash, git status shows dirty files:

mac:src bradfitz$ git st
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    cmd/dist/dist

nothing added to commit but untracked files present (use "git add" to track)

@bradfitz
Copy link
Contributor Author

Yes, running rm src/runtime/z* followed by git reset --hard origin/master and rm src/cmd/dist/dist made my make.bash work again.

@randall77
Copy link
Contributor

We gitignore all the runtime/z_.go files. Some of them are still around,
but at least zruntime__.go are no longer valid, but still ignored by our
.gitignore, but alas still picked up by the build. So yes, you have to
blow them away when syncing from an older client.

On Tue, Dec 9, 2014 at 4:32 PM, Brad Fitzpatrick notifications@github.com
wrote:

Yes, running rm src/runtime/z* followed by git reset --hard origin/master
and rm src/cmd/dist/dist made my make.bash work again.


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

@bradfitz
Copy link
Contributor Author

The .gitignore should be accurate so other git tools like reset and status and clean work as expected.

What's the more specific pattern we should ignore?

@rsc
Copy link
Contributor

rsc commented Dec 10, 2014

We used to remove z* in cmd/dist but now there are go generate-generated z
files so we only remove a few specific other z files in cmd/dist. It would
be fine to remove zruntime_defs* in cmd/dist.

@bradfitz
Copy link
Contributor Author

Looks like just:

    src/runtime/zaexperiment.h
    src/runtime/zversion.go

?

@rsc
Copy link
Contributor

rsc commented Dec 10, 2014

Yes, that is the correct list.

@bradfitz
Copy link
Contributor Author

@minux
Copy link
Member

minux commented Dec 10, 2014

I also hit this issue several times and all of the trouble is caused by zruntime_defs_darwin_amd64.go.
Could we make cmd/dist remove zruntime_defs_darwin_amd64.go? Or, better, remove all of src/runtime/z*_GOOS_GOARCH.*, cmd/dist already knows how to readdir(), so this shouldn't need any platform-specific changes, but will simplify the lives of people who switches branches from release branch to master a lot.

@bradfitz
Copy link
Contributor Author

Can we have cmd/dist not do any deleting at all, and just build the right files instead of building whatever it finds on disk?

(Sorry, I forget how this all works.)

@minux
Copy link
Member

minux commented Dec 10, 2014

@bradfitz, because cmd/go also need to be able to build runtime, we will also
need to change cmd/go for that.

If you are concerned about deleting files, what about make cmd/dist warn if it
finds z*_GOOS_GOARCH.* in runtime?
It's certainly better than the current build error which might confuse a user.

@bradfitz
Copy link
Contributor Author

I defer to Russ.

@bradfitz bradfitz reopened this Dec 10, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@mattetti
Copy link
Contributor

just run into this issue today, Brad's steps fixed my issue but it would have been nice to know what's going on/clean up the files for me, instead of googling the error :)

@c4milo
Copy link
Member

c4milo commented Oct 25, 2016

I'm running into this one when trying to upgrade from Go 1.7.1 to 1.7.3 via go1.4-bootstrap-20161024

@bradfitz
Copy link
Contributor Author

@c4milo, um, what are you doing? Are you mixing the Go 1.4 sources atop the Go 1.7 sources? I think you're using the bootstrap code incorrectly.

@c4milo
Copy link
Member

c4milo commented Oct 25, 2016

@bradfitz, you are right, I didn't remember quite well how the bootstrap process worked. I was able to upgrade to 1.7.3 successfully using go1.4-bootstrap-20161024. Thanks!

@Goodwine
Copy link

Goodwine commented Jul 8, 2018

I ran into this by makeing go1.4, cancelling mid way, checking out to a newer branch (1.11beta1) and building again.
I fixed it with git clean -fd as suggested by Brad, but it was totally not obvious.

git clone $GO_REPO go
cd go
git checkout go1.4 # I meant to do 1.11beta1
cd src
./make.bash # already have GOROOT_BOOTSTRAP, so it's k
^C
git checkout  go1.11beta1
./make.bash # fails because the repo is dirty

@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants