Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

ARM Support #8

Open
jcelliott opened this issue Apr 24, 2014 · 9 comments
Open

ARM Support #8

jcelliott opened this issue Apr 24, 2014 · 9 comments

Comments

@jcelliott
Copy link

I know goluago does not advertise ARM support yet, but how much work would it be to add it?

Currently, compiling a go program that imports goluago on ARM gives the following output:

# command-line-arguments
_dtoa: illegal combination CMPD C_LFCON C_REG C_NONE, 9 1
(7051)  CMPD    $0.000000e+00,R0,
pow: illegal combination CMPD C_LFCON C_REG C_NONE, 9 1
(4450)  CMPD    $0.000000e+00,R2,
_dtoa: illegal combination CMPD C_LFCON C_REG C_NONE, 9 1
(7051)  CMPD    $0.000000e+00,R0,
pow: illegal combination CMPD C_LFCON C_REG C_NONE, 9 1
(4450)  CMPD    $0.000000e+00,R2,
@akavel
Copy link
Owner

akavel commented Apr 24, 2014

Hi Joshua!
The fact is, I have no idea. I don't have easy access to an ARM environment to be able to test, debug, etc. I even requested access to GCC Compile Farm aiming for that, but after being granted, I found out their ARM machines seem to be defunct unfortunately. On the other hand, I do have a Raspberry Pi, but I don't have it set up well, so it would require somewhat substantial effort on my side to have it configured enough - and the bits of free time I have I try to spend on pushing the x86/amd64 ports towards completeness first... If you had possibility to provide me with some (longish term) access to an ARM via Internet, it would be easier for me to try to make it work (although I cannot promise how quickly).

That said, what you quoted here looks strange and quite surprising to me; I think it qualifies quite well for a question that could be asked on golang-nuts if you cared. I think it has some chance of being result of some bug in Go's internal C compiler. On the other hand, it could maybe be related somehow to matters of hardware/software floating point on ARM (?). Regardless, I would also advise you to try to checkout locally an earlier version of the github.com/akavel/gostdc project (specifically, revision akavel/gostdc@c33937a). There's very high chance the above issue would disappear then (although something else might surface as broken).

Finally, it would be somewhat helpful (especially if you plan to ask on golang-nuts) if you could provide information about: Go version you're using, the exact ARM you're using, result of go env, and minimal code for reproducing the quoted error about "illegal combination".

By the way, thanks for reaching out to me! I'm actually quite interested in making the project run on ARM sooner or later, and the error you quoted surprises me and piques my curiosity! Please let me know if you post the question on golang-nuts, I'd be very interested to read any answers, and to be sure I don't overlook this thread.

@jcelliott
Copy link
Author

Glad to hear you're interested in getting this working on ARM! Here's the test program I'm trying to build, which runs fine on x86:

package main

import (
    "fmt"
    lua "github.com/akavel/goluago/internal"
)

func main() {
    l := lua.Open()
    l.Pushcclosure(lua.Open_base, 0)
    l.Call(0, 0)
    program := `print("hello from lua")`
    l.Loadbuffer([]byte(program), "chunk 1")
    l.Call(0, 0)
    fmt.Println("done")
}

I also tried checking out the version of akavel/gostdc you linked to above, but got the same results.

I am testing on a Raspberry Pi, and here is the output of go env:

GOARCH="arm"
GOBIN=""
GOCHAR="5"
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/me"
GORACE=""
GOROOT="/home/me/go"
GOTOOLDIR="/home/me/go/pkg/tool/linux_arm"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -marm -pthread"
CXX="g++"
CGO_ENABLED="1"

Any ideas where to start looking for the problem? If not, I'll probably ask this on golang-nuts like you suggested. I might also be able to get an ARM board set up for testing, I'll get back to you on that.

@akavel
Copy link
Owner

akavel commented Apr 25, 2014

You still didn't provide "go version" output, which would be also important information I suppose; but that said, my most important immediate follow up is, that I originally supposed that the # command-line-arguments string comes from somewhere in your program; but given that apparently not, and now I seem to understand that it is actually compilation that fails, not even running the program (yes?), then this has me completely lost now, and asking a question on golang-nuts would be what I'd to at this moment, as this may be obvious to the boatload of gurus there, or at the very least ring some bells to someone and provide some additional clues. Um, and, certainly, trying to google fragments of the error message would be good idea too, but I suppose you might have already tried that?

@akavel
Copy link
Owner

akavel commented Apr 25, 2014

Hm, from quick googling, the error seems to originate from the 5l command, in current release (Go 1.2.1) this is located in src/cmd/5l/span.c line 652. However, for Go 1.3 the span.c file seems to have disappeared from src/cmd/5l/, which may be connected with the major refactorings and redesigns in Go compilers & linkers. Given that, it might be also worthwhile to try and build the current Go 1.3 beta from source, and then try to compile the goluago app again with it. But there's also notable probability that the problematic linker code might just have moved around to somewhere else. By the way, goluago seems to somewhat stress-test Go's C compiler/linker infrastructure, as it has already found one bug there and one "peculiarity" (namely, a pre-ANSI-C behavior).

@jcelliott
Copy link
Author

Sorry, for some reason I thought the version was in the go env output. I'm using Go 1.2.1. I like the idea of trying with the 1.3 beta, so I'll give that a shot today and let you know what happens.

@jcelliott
Copy link
Author

I tried building with Go 1.3, and got some different errors. Running go build on my test program with the current master of akavel/gostdc I get:

# github.com/akavel/gostdc
00296 (/home/pi/src/github.com/akavel/gostdc/dtoa.c:140)        CMPD    $0,R0,
00296 (/home/pi/src/github.com/akavel/gostdc/dtoa.c:140)        CMPD    $0,R0,
00296 (/home/pi/src/github.com/akavel/gostdc/dtoa.c:140)        CMPD    $0,R0,
warning: ../src/github.com/akavel/gostdc/dtoa.c:40 used and not set: ilim1 ilim mlo spec_case
<unknown line number> illegal combination 00296 (/home/pi/src/github.com/akavel/gostdc/dtoa.c:140)      CMPD     $0,R0,; 15 1 0, 9 1
<unknown line number> from 9 1 to 1 1

<unknown line number> illegal combination 00296 (/home/pi/src/github.com/akavel/gostdc/dtoa.c:140)      CMPD     $0,R0,; 15 1 0, 9 1
<unknown line number> from 9 1 to 1 1

<unknown line number> illegal combination 00296 (/home/pi/src/github.com/akavel/gostdc/dtoa.c:140)      CMPD     $0,R0,; 15 1 0, 9 1
<unknown line number> from 9 1 to 1 1

Trying again with revision c33937a of akavel/gostdc gives 763 lines of output, almost all of which look like this:

warning: ../src/github.com/akavel/goluago/internal/lobject.c:168 result of operation not used

And then I get these two lines near the end:

../src/github.com/akavel/goluago/internal/loslib.c:126 unknown vlong LIST
../src/github.com/akavel/goluago/internal/loslib.c:126 unknown vlong COND

I found an old issue here (also here [plan9]) that suggests the problem is with 5c not being able to handle ternary conditionals.

@beatgammit
Copy link

I got the same result as @jcelliott with his test code on Go 1.2.1. I'm building Go 1.3 beta right now and I'll let you know the results when it's done.

I'm interested in in porting luna (a prettier interface to golua) to goluago.

@beatgammit
Copy link

Alright, I have the same results as @jcelliott. If I get time, I'll try converting the ternaries to if/else statements and make a PR if that fixes it.

I'll look into getting it up on a public address so you can take a crack at it.

@akavel
Copy link
Owner

akavel commented Apr 27, 2014

  • The warnings are expected, and according to Roberto Ierusalimshy "mostly rubbish" - at least those in goluago, didn't investigate those in gostdc yet.
  • Nice, that the previous commit of gostdc seems to workaround the issue in Go 1.3, at least on first sight. That said, I suppose you're aware, that given the error with ternary operator, fixing it may still result in exposing some other ones. Also, I feel obliged to warn you that this "earlier" gostdc may be less complete, although on the other hand with much easier license (BSD/MIT) instead of current weird Lucent license. Personally, I'd much prefer to go the way of the "earlier" gostdc in the end, the Lucent one ("current") just helped me debug & resolve certain problem quicker.
  • Hello @beatgammit! Thanks for your interest and offers. I'd be very happy if you would port luna to be able to use goluago. I was thinking to use some prettier interface from the beginning. That's in part why I put all the stuff in the weird "package internal" actually (although also to have more freedom to experiment, without feeling pressure of an accidentally frozen API). Although I'm starting to think that maybe I should just move the stuff to some "package lua51" already and don't care so much... still haven't decided on that, though. Anyway, in case of further discussion about this, please contact me via email (czapkofan@gmail.com), it'd be totally off topic in this issue.
  • Finally, as to remote access to an ARM for me, thanks to you both for the offers, I'd be sure interested.

Thanks for your interest in goluago!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants