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

asm: "unexpected EOF" error of assembly file #43689

Closed
erifan opened this issue Jan 14, 2021 · 5 comments
Closed

asm: "unexpected EOF" error of assembly file #43689

erifan opened this issue Jan 14, 2021 · 5 comments

Comments

@erifan
Copy link

erifan commented Jan 14, 2021

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

$ go version
Tip

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
Linux/amd64

What did you do?

https://play.golang.org/p/84SFhv1JUs6
Create a test file for the above code and run the test.

What did you expect to see?

Pass

What did you see instead?

--- FAIL: TestEOF (0.01s)
eof_test.go:36: exit status 1
/tmp/foo654446592/f.s:4: unexpected EOF
asm: assembly of /tmp/foo654446592/f.s failed
FAIL
exit status 1

If we replace
s := `TEXT ·f(SB), 4, $0-16
MOVQ R8, r1+0(FP)
MOVQ R9, r1+0(FP)
RET`
as
s := `TEXT ·f(SB), 4, $0-16
MOVQ R8, r1+0(FP)
MOVQ R9, r1+0(FP)
RET
`
The test passes.
The assembler parser seems to prohibit a line of instruction followed by EOF, but should we allow the last line to do so ?

@cherrymui
Copy link
Member

I think it is reasonable to require the file ended with a newline.

@erifan
Copy link
Author

erifan commented Jan 15, 2021

I think it is reasonable to require the file ended with a newline.

Is this a requirement for assembly files? But I did not find the corresponding documentation. In addition, I see that there is no such limitation for generating Go files in this way.

@cherrymui
Copy link
Member

Let's step back a bit. Why do you think it is useful to support non-newline-terminated file? As far as I can tell, most popular editors leave file newline-terminated. And for program-generated files, it is trivial to make it newline-terminated.

We could consider supporting it if it is useful. But I'm not sure why.

@erifan
Copy link
Author

erifan commented Jan 16, 2021

For normative. Since we can generate source file that does not end with a newline character, then we should give a qualitative view of this behavior. We can either tell the user through the document that the source file needs to end with a terminator, just like c and java (I have roughly read the standard document of Go and did not see the corresponding description, but I did not read it carefully. If it does have such description please correct me). Either allow this behavior instead of reporting an inexplicable error. It is really simple to add a newline character at the end of the generated source file, but I didn't think of adding a newline character at first, because I think it is more compact if it is not added. I think there are other users like me.
And I think it is weird that the .go file allows such behavior while the .s file does not.

@randall77
Copy link
Contributor

I think the "unexpected EOF" error reported at the last line of the file is pretty clear.

@golang golang locked and limited conversation to collaborators Jan 16, 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

4 participants