Skip to content

cmd/compile: type..eq function not generated #24747

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

Closed
dotaheor opened this issue Apr 7, 2018 · 10 comments
Closed

cmd/compile: type..eq function not generated #24747

dotaheor opened this issue Apr 7, 2018 · 10 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dotaheor
Copy link

dotaheor commented Apr 7, 2018

What version of Go are you using (go version)?

go version go1.10.1 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

package main

func main() {
	type T struct {
		a interface{}
		b int
	}
	
	var t T
	var z = [3]T{1: t}
	_ = z == z
}

What did you expect to see?

no errors

What did you see instead?

weird outputs, not like normal error messages.

type..eq.[3]main.T·1: call to external function
main.main: relocation target type..eq.[3]main.T·1 not defined
main.main: undefined: "type..eq.[3]main.T·1"

btw, gccgo is ok to compile this program.

@dotaheor
Copy link
Author

dotaheor commented Apr 7, 2018

More observations.

The following code compiles ok:

package main

func main() {
	type T struct {
		a interface{}
	}

	var z = [3]T{}
	_ = z
}

but the following one not

package main

func main() {
	type T struct {
		a interface{}
	}
	var z = [3]T{}
	_ = z == z
}

@dotaheor
Copy link
Author

dotaheor commented Apr 7, 2018

1.7 and 1.8 are ok. Not ok since 1.9.0.

@ALTree
Copy link
Member

ALTree commented Apr 7, 2018

Since it's not clear from the report: to trigger the error, go run has to be used on the reproducer. The error is not printed when building, or when directly running a binary produced by go build.

Anyway, I've bisected this to 87065a3 (cmd/go: don't generate DWARF in the compiler if the linker will discard it).

cc @josharian

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 7, 2018
@ALTree ALTree added this to the Go1.11 milestone Apr 7, 2018
@ALTree ALTree changed the title cmd/compile: weird output cmd/compile: relocation target not defined error at runtime Apr 7, 2018
@josharian
Copy link
Contributor

Sounds very similar to #22444. cc also @mdempsky

@dotaheor
Copy link
Author

dotaheor commented Apr 7, 2018

This problem also exists for go build.

package main

func f() {
	var a = []int{5: 0}

	a[0], a[1], a[2] = 0, 1, 2
}

So I think it should be fixed in 1.10.2.
And as soon as possible.

@dotaheor
Copy link
Author

dotaheor commented Apr 7, 2018

Sorry, I miss-typed main as f.
So the problem is gone if there is a main function.
Which makes it not so serious.

But this problem is really not go run specific.

@josharian
Copy link
Contributor

@dotaheor the error message for package main with no func main is entirely unrelated to this issue. I thought there was already a (very old) issue suggesting a better error message when this happens, but I can't find it.

@josharian
Copy link
Contributor

I believe that this is a duplicate of #23546.

@josharian josharian changed the title cmd/compile: relocation target not defined error at runtime cmd/compile: type..eq function not generated Apr 7, 2018
@mvdan
Copy link
Member

mvdan commented Apr 7, 2018

I was about to point out this being a duplicate too. The errors and programs are too similar for this to be a coincidence.

@ALTree
Copy link
Member

ALTree commented Apr 8, 2018

Closing as a dup of #23546.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants