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

cmd/compile: compile failure building kubernetes #15071

Closed
davecheney opened this issue Apr 2, 2016 · 8 comments
Closed

cmd/compile: compile failure building kubernetes #15071

davecheney opened this issue Apr 2, 2016 · 8 comments
Milestone

Comments

@davecheney
Copy link
Contributor

% bash benchkube.bash                                      
go version devel +75a22d0 Sat Apr 2 00:06:30 2016 +0000 linux/amd64
# k8s.io/kubernetes/pkg/volume/util
src/k8s.io/kubernetes/pkg/volume/util/fs_linux.go:27: undefined: XFALL
# k8s.io/kubernetes/pkg/api
src/k8s.io/kubernetes/pkg/api/conversion.go:20: undefined: XFALL

I haven't bisected yet, this is a recent (within the last month) failure.

/cc @josharian @mdempsky

@davecheney davecheney added this to the Go1.7 milestone Apr 2, 2016
@davecheney
Copy link
Contributor Author

bisect blames e41f527, paging @tzneal to the OR, stat!

@bradfitz bradfitz assigned tzneal and unassigned mdempsky Apr 2, 2016
@bradfitz
Copy link
Contributor

bradfitz commented Apr 2, 2016

It's now trying to inline switches (the point of the offending CL), but it doesn't know how to inline the fallthrough in k8s.io/kubernetes/pkg/api/resource/quantity.go:

// Neg sets q to the negative value of y.
// It updates the format of q to match y.
func (q *Quantity) Neg(y Quantity) error {
        switch {
        case y.Amount == nil:
                *q = y
        case q.Amount == nil:
                q.Amount = &inf.Dec{}
                fallthrough
        default:
                q.Amount.Neg(y.Amount)  
                q.Format = y.Format             
        }
        return nil
}

Removing the fallthrough makes it compile.

Marking fallthrough as hairy fixes it, but means that switch can no longer be inlined:

diff --git a/src/cmd/compile/internal/gc/inl.go b/src/cmd/compile/internal/gc/inl.go
index c21af77..230eb43 100644
--- a/src/cmd/compile/internal/gc/inl.go
+++ b/src/cmd/compile/internal/gc/inl.go
@@ -215,6 +215,7 @@ func ishairy(n *Node, budget *int) bool {
                OFOR,
                OSELECT,
                OTYPESW,
+               OXFALL,
                OPROC,
                ODEFER,
                ODCLTYPE, // can't print yet

@bradfitz
Copy link
Contributor

bradfitz commented Apr 2, 2016

I will leave to @tzneal or @dr2chase to fix.

@griesemer
Copy link
Contributor

Please notify me of the fix so I can update the corresponding binary exporter as well. Or leave fallthrough as "hairy" and wait until we switch over to binary format (soon-ish, code is working but needs to be reviewed and checked in.)

@davecheney
Copy link
Contributor Author

@griesemer @bradfitz thanks for the fix, I've verified it works and gets k8s building at tip again. I think it's a reasonable fix. I'll send a CL unless someone beats me to it this afternoon.

@tzneal
Copy link
Member

tzneal commented Apr 2, 2016

I've got a fix and unit test, but I'm in the middle of moving houses and my primary machine is still packed up. It's taking forever to run tests on this Macbook...

diff --git a/src/cmd/compile/internal/gc/fmt.go b/src/cmd/compile/internal/gc/fmt.go
index 7ed0851..72e1bc3 100644
--- a/src/cmd/compile/internal/gc/fmt.go
+++ b/src/cmd/compile/internal/gc/fmt.go
@@ -189,6 +189,7 @@ var goopnames = []string{
        OSUB:      "-",
        OSWITCH:   "switch",
        OXOR:      "^",
+       OXFALL:    "fallthrough",
 }

@griesemer
Copy link
Contributor

@tzneal Thanks.

@gopherbot
Copy link

CL https://golang.org/cl/21452 mentions this issue.

@golang golang locked and limited conversation to collaborators Apr 2, 2017
@rsc rsc unassigned tzneal Jun 23, 2022
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

6 participants