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

Building lbforth on arm 64bit Angstrom Linux #97

Open
Phi-Ho opened this issue Jan 20, 2021 · 29 comments
Open

Building lbforth on arm 64bit Angstrom Linux #97

Phi-Ho opened this issue Jan 20, 2021 · 29 comments
Labels

Comments

@Phi-Ho
Copy link

Phi-Ho commented Jan 20, 2021

Greetings,

I am trying to build lbforth on this platform:

root@de10-nano:~ uname -a
Linux de10-nano 4.1.33-ltsi-altera #1 SMP Thu Mar 30 10:37:56 PDT 2017 armv7l GNU/Linux
root@de10-nano:~

and got this error:

$ make TARGET=arm OS=linux
make -ftargets/c/bootstrap.mk
make[1]: Entering directory '/home/hph/lbForth'
make[1]: Circular kernel.c <- b-forth dependency dropped.
gcc -m32 -O2 -fomit-frame-pointer -fno-unit-at-a-time -Itargets/c targets/c/params.c -o params
gcc: error: unrecognized command line option '-m32'
make[1]: *** [targets/c/forth.mk:25: params] Error 1
make[1]: Leaving directory '/home/hph/lbForth'
make: *** [Makefile:27: b-forth] Error 2
de10-nano:~/lbForth$

How can lbforth be built on a 64bit Arm Linux platform?

Regards,

phiho

@larsbrinkhoff
Copy link
Owner

larsbrinkhoff commented Jan 20, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 20, 2021 via email

@larsbrinkhoff
Copy link
Owner

I believe this should work:

make TARGET=arm OS=linux M32=

Note, nothing after M32=. This is to disable the use of -m32 which isn't supported with the ARM gcc.

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 20, 2021 via email

@larsbrinkhoff
Copy link
Owner

Oh, you don't have a working Lisp. I used "apt-get install sbcl".

I build it and here's a tarball.
lbForth-arm.zip

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 20, 2021 via email

@larsbrinkhoff
Copy link
Owner

I have no explanation for why arm-forth and fort dump core. Possibly something about them being ELF files written from Forth itself. They seem to work reliably on my Raspberry Pi, but maybe something in the operating system you use is different.

b-forth is the bootstrap Forth build with the C compiler, so it's an ordinary binary executable.

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 20, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 20, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 20, 2021 via email

@larsbrinkhoff
Copy link
Owner

It's worrying that the error comes and goes randomly.

But the good news is that you have narrowed down to a specific location, so that part isn't random.

Do you have a debugger on the target? If you could run lbForth under the debugger, hopefully it should stop and display the point where it crashes. What is the "illegal instruction" it's trying to execute?

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 21, 2021 via email

@larsbrinkhoff
Copy link
Owner

larsbrinkhoff commented Jan 21, 2021

It should look something like this:

$ gdb arm-forth
GNU gdb [...]
Copyright (C) 2016 Free Software Foundation, Inc.
[...]
(gdb) run
Starting program: /home/lars/src/lbForth/forth
lbForth
Program received signal SIGILL
0x080485e1 in ?? ()
(gdb) disassemble $pc-10, $pc+20
Dump of assembler code from 0x80485d7 to 0x80485f5:

And then the last part would be the machine code around the failure point.

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 21, 2021 via email

@larsbrinkhoff
Copy link
Owner

larsbrinkhoff commented Jan 21, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 21, 2021 via email

@larsbrinkhoff
Copy link
Owner

larsbrinkhoff commented Jan 21, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 21, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 21, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 21, 2021 via email

@larsbrinkhoff
Copy link
Owner

Is there a feature in gdb that shows the instruction before the current PC in the flow?

I don't think so.

I have another question, can this ' unresolved ' [...] be refactored or implemented differently?

You could remove it and replace all instances of unresolved <foo> with [ ' <foo> ] literal , >mark... I think.

Can we implement a debug word

Try something like this in targets/arm/nucleus.fth:

code bkpt
   bkpt,
   next,
end-code

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 22, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 22, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 23, 2021 via email

@larsbrinkhoff
Copy link
Owner

Sorry, it should be 0 # bkpt,. Apparently the BKPT instruction includes an immediate number.

I get this:

lbForth
ok
: foo ." hello" cr ;
 ok
foo
hello
 ok
: bar ." 1" bkpt ." 2" ;
 ok
bar
1Trace/breakpoint trap

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 24, 2021 via email

@larsbrinkhoff
Copy link
Owner

This by itself doesn't tell us much, but it's a start to go a head and see what happens next. Maybe you can single step and see what is going on with the "unresolved" definition and where it goes astray.

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 24, 2021 via email

@Phi-Ho
Copy link
Author

Phi-Ho commented Jan 24, 2021 via email

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

No branches or pull requests

2 participants