-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/dist: make.bash throws undefined error when building from source #45673
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
Comments
If you
That's expected, you can't set GOROOT_BOOTSTRAP to the tip cloned repository you're building. |
@ALTree Hey, In file But |
Try to set |
@WangLeonard Hey, I already showed this on the issue but: $ GOROOT="/Users/furkan.turkal/src/public/go" ./make.bash # SAME ERROR Following attempt does solve either: $ GOROOT="/usr/local/Cellar/go/1.16.3/libexec" go env -w GOROOT="/Users/furkan.turkal/src/public/go"
$ ./make.bash # SAME ERROR Set everything to default: $ unset GOROOT # which is already unset'ed
$ GOROOT="/usr/local/Cellar/go/1.16.3/libexec" go env -w GOROOT="/usr/local/Cellar/go/1.16.3/libexec"
$ ./make.bash # SAME ERROR |
You should download a compiled version (for example https://golang.org/dl/go1.16.3.darwin-amd64.tar.gz from https://golang.org/dl/) and unzip it to a folder, and set it to |
This is the official tutorial : https://golang.org/doc/install/source |
Closing because this doesn't look like a bug. For help building Go, please use a forum. See https://golang.org/wiki/Questions. Thanks. |
I've looked into this a little bit and I believe the reason you're getting that error on diff --git a/src/go/constant/value.go b/src/go/constant/value.go
index 78cb3f896f..4a4af7426b 100644
--- a/src/go/constant/value.go
+++ b/src/go/constant/value.go
@@ -1000,6 +1000,10 @@ func UnaryOp(op token.Token, y Value, prec uint) Value {
case boolVal:
return !y
}
+
+ case token.TEST:
+ goto Error
+
}
Error:
diff --git a/src/go/token/token.go b/src/go/token/token.go
index 96a1079ec3..bc16352e5a 100644
--- a/src/go/token/token.go
+++ b/src/go/token/token.go
@@ -124,6 +124,7 @@ const (
SWITCH
TYPE
VAR
+ TEST
keyword_end
) The problem is that
This means that |
And yet the same patch I posted above doesn't cause early boostrapping errors when applied to go1.16. Did something change in the bootstrapping code that caused a regression? |
Thanks @WangLeonard, I tried that instruction (installed from .pkg) and it seems still does not work: $ GOROOT="/Users/furkan.turkal/src/public/go" GOROOT_BOOTSTRAP="/usr/local/go" ./make.bash # SAME ERROR Thanks, @ALTree. I applied your patch before did this.
What were your
I don't quite understand this statement, on which commit did you able to compile? |
I've bisected using this procedure:
diff --git a/src/go/constant/value.go b/src/go/constant/value.go
index 46414423f2..13be429771 100644
--- a/src/go/constant/value.go
+++ b/src/go/constant/value.go
@@ -974,6 +974,10 @@ func UnaryOp(op token.Token, y Value, prec uint) Value {
case boolVal:
return !y
}
+
+ case token.TEST:
+ goto Error
+
}
Error:
diff --git a/src/go/token/token.go b/src/go/token/token.go
index 96a1079ec3..b7a3c26dbb 100644
--- a/src/go/token/token.go
+++ b/src/go/token/token.go
@@ -124,6 +124,7 @@ const (
SWITCH
TYPE
VAR
+ TEST
keyword_end
)
@@ -225,6 +226,7 @@ var tokens = [...]string{
SWITCH: "switch",
TYPE: "type",
VAR: "var",
+ TEST: "ZZZZZZZZZZZZZZZZZZZZZZZZZZZ",
}
// String returns the string corresponding to the token tok.
This worked in go1.16, and it worked on tip up to the parent of commit 742c05e. At commit 742c05e,
The question is, is this an expected side effect of that commit? Unfortunately I can't tell... cc @mdempsky |
If you are applying patches like that you probably need to add "go/token" to |
Tried that too, but unfortunately:
|
Add "go/parser" also. |
Adding
and adding
Clearly I'm missing something. Still, I can reproduce the behaviour in the OP (patch working on 1.16 breaks bootstrapping on tip), so it wasn't just them having troubles with building tip. Of course maybe it's just that their patch has some missing pieces. |
I can get past that problem, but I have to admit that I ran into what seems to be an unsurmountable problem: I eventually need to add the "time" package to Supporting this kind of change while bootstrapping may require waiting for #44505. |
I see, thanks. Feel free to re-close this if you think there's nothing else to be done. |
I agree that it's a bit awkward that we've locked ourselves into a place where it's hard to add a new parsing token that is referenced by go/constant, but that seems to be where we are. Everything does work, even if you can't make certain kinds of changes. And I think that #44505 does give us a path to fix it, fairly soon. So I don't think there is anything to do here. |
Some packages support build tags for building simplified variants during bootstrap. E.g., math/big has But I think like @ianlancetaylor points out, waiting for #44505 seems like the simplest/surest solution. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It does not related to the version.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
$ git clone https://go.googlesource.com/go
$ cd go/src
$ ./make.bash # OK
Play with the source code (i.e. define a new constant variable, and just use it somewhere)
Run the
./make.bash
againWhat did you expect to see?
It should be built successfully? 🤔
What did you see instead?
undefined: token.TEST
: But it's already defined in the cloned repo. Bootstrap throws this error because it was not defined in/usr/local/Cellar/go/1.16.3/libexec/src/go/token/token.go
file, and$GOROOT_BOOTSTRAP
lookup that directory.But I could not figure out how to make the
GOROOT_BOOTSTRAP
env to look at the source directory when compiling. It uses my/usr/local
path which I've installed with Brew.If I run the following command in
./src
:$ GOROOT_BOOTSTRAP="/Users/furkan.turkal/src/public/go" ./make.bash
It's failing:
I have followed the exact same steps when I was working with Go 1.16. Is this because Go 1.17 has some kind of behavioral change? Or am I missing something important here?
The text was updated successfully, but these errors were encountered: