Q. What is gnuroot debian?
A. Debian jessie on top of android, in a chroot jail. ( https://play.google.com/store/apps/details?id=com.gnuroot.debian&hl=en )
Q. Why don’t you use Termux instead? ( https://play.google.com/store/apps/details?id=com.termux&hl=en )
A. Even though it’s been reported that golang works with termux, termux requires minimum Android version 5.0 and I have Android 4.2. (And also out of sheer curiosity since gcc works and go is no more low-level than gcc (?))
Q. What did you try?
1)
$ apt-get -t jessie-backports install golang
2)
https://golang.org/doc/install --> “Test your installation”
3)
$ mkdir -p ~/go/src/hello
$ cd ~/go/src/hello
$ emacs hello.go --> Paste sample code from "Test your installation"
$ go build
I get:
go build _/root/go/src/hello: /usr/lib/go-1.7/pkg/tool/linux_arm/compile: signal: segmentation fault
Q. What does yes work on your system?
A.
-
“$ apt-get install build-essential
” and then gcc/g++ on printf("hello world")
program works as expected; and also I succeded to compile various tools/utilities from source using ‘./configure && make install’ in the past.
root@localhost:~/src/hello$ cat hello.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World, 2!\n";
return 0;
}
root@localhost:~/src/hello$ g++ hello.cpp
root@localhost:~/src/hello$ ./a.out
Hello, World, 2!
root@localhost:~/src/hello$
-
python works.
root@localhost:~$ python
Python 2.7.9 (default, Aug 13 2016, 17:56:53)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> reduce(lambda x,y: x+y, map(lambda x: x*x, range(1,11)))
385
>>>
Q. What else did you try?
1)
Tried with/without setting GOARM=5, GOARCH=arm
2)
Tried installing the latest version of go from https://golang.org/doc/install?download=go1.9.1.linux-armv6l.tar.gz , performing same “Test your installation” steps, now got a slightly different but essentially similar message:
$ go build
go build runtime/internal/sys: /usr/local/go/pkg/tool/linux_arm/compile: signal: illegal instruction
>>
Tried with gdb:
$ gdb -batch -ex run -ex quit --args go build
...
[New LWP 19753]
go build runtime/internal/sys: /usr/local/go/pkg/tool/linux_arm/compile: signal: illegal instruction
[LWP 19753 exited]
[Inferior 1 (process 19733) exited with code 01]
>>>
Suprisingly, this does yes work:
$ gdb -batch -ex run -ex quit --args /usr/local/go/pkg/tool/linux_arm/compile hello.go
-->
yields ‘hello.o’ ; yet without gdb:
$ /usr/local/go/pkg/tool/linux_arm/compile hello.go
/usr/local/go/pkg/tool/linux_arm/compile: signal: illegal instruction
3)
Tried installing gccgo (from debian repositories):
root@localhost:~$ apt-get -t jessie-backports install gccgo
root@localhost:~/go/src/hello$ gccgo hello.go
root@localhost:~/go/src/hello$ ls
a.out hello.go
root@localhost:~/go/src/hello$ ./a.out
no debug info in ELF executable errno -1
fatal error: no debug info in ELF executable
runtime stack:
no debug info in ELF executable errno -1
panic during panic
okay, so tried with: -g switch:
root@localhost:~/go/src/hello$ gccgo -g hello.go
root@localhost:~/go/src/hello$ ./a.out
hello, world
root@localhost:~/go/src/hello$
-
voila! A finally working go ‘hello world’ program on my android! But not with latest go. And only with ‘-g’ flag, @#&?
root@localhost:~/go1.4/src$ ./make.bash
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, linux/arm.
lib9
libbio
...
go/doc
go/build
cmd/go
./make.bash: line 161: 8579 Illegal instruction "$GOTOOLDIR"/go_bootstrap clean -i std
root@localhost:~/go1.4/src$
So I guess my next bunch of questions is:
1)
From which exact .c files ‘go_bootstrap’ binary is built? (I could sprinkle-in a few ‘printf("debug.")
’ statements to pinpoint the exact location of the crash…)
2)
How do I compile (make.bash
) with debug info? (is there a command-line switch for that?)
Can anyone please help me out with those?