larsbrinkhoff / lbForth

Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
GNU General Public License v3.0
418 stars 112 forks source link

overload of EXECUTE in cygwin/clisp causes failure to metacompile #28

Closed vigilancetech-com closed 7 years ago

vigilancetech-com commented 7 years ago

$ make make -ftargets/c/bootstrap.mk make[1]: Entering directory '/home/kevin/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 targets/c/run.sh ./params -lisp > params.lisp cp targets/c/jump.fth jump.fth cp targets/ctc.fth threading.fth cp targets/c/target.fth target.fth echo ": sysdir s\" src/\" ;" >> target.fth ./lisp/lisp.sh '(load "lisp/meta.lisp") (compile-forth "targets/c/nucleus.fth" "src/kernel.fth")' ;; Loading file lisp/meta.lisp ... ;; Loading file params.lisp ... ;; Loaded file params.lisp WARNING: DEFUN/DEFMACRO(EXECUTE): # is locked Ignore the lock and proceed WARNING: DEFUN/DEFMACRO: redefining function EXECUTE in /home/kevin/lbForth/lisp/meta.lisp, was defined in C ;; Loading file lisp/words.lisp ... ;; Loaded file lisp/words.lisp ;; Loaded file lisp/meta.lisp gcc -m32 -O2 -fomit-frame-pointer -fno-unit-at-a-time -Itargets/c -c -o kernel.o kernel.c gcc -m32 kernel.o -o b-forth rm -f kernel.c kernel.o params.lisp jump.fth threading.fth target.fth make[1]: Leaving directory '/home/kevin/lbForth' cp b-forth forth rm -f *-stamp touch x86-windows-stamp cat targets/x86/params.fth targets/x86/windows/params.fth > params.fth cp targets/x86/jump.fth jump.fth cp targets/itc.fth threading.fth cat targets/x86/target.fth targets/x86/windows/target.fth > target.fth echo ": sysdir s\" /usr/local/share/lbForth/\" ;" >> target.fth echo include targets/x86/meta.fth | targets/c/run.sh ./forth | tail -n+3 > x86-forth mv image x86-forth mv: cannot stat 'image': No such file or directory make: [targets/x86/forth.mk:6: x86-forth] Error 1 (ignored) chmod a+x x86-forth rm -f forth.exe cp x86-forth forth 0;~/lbForth

larsbrinkhoff commented 7 years ago

In which package is the symbol EXECUTE defined?

vigilancetech-com commented 7 years ago

I got the error message to go away by changing every incident of "execute" in lisp/meta.lisp to "my-execute" but it still won't metacompile but now without any messages at all other than a missing "image" file:


$ make clean
rm -f params.fth jump.fth threading.fth target.fth
rm -f forth *-forth test-* *-stamp *.exe conf.mk
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ ./configure
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ cat conf.mk
TARGET=x86
OS=windows
IMG=pe
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ make
make -ftargets/c/bootstrap.mk
make[1]: Entering directory '/home/kevin/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
targets/c/run.sh ./params -lisp > params.lisp
cp targets/c/jump.fth jump.fth
cp targets/ctc.fth threading.fth
cp targets/c/target.fth target.fth
echo ": sysdir   s\" src/\" ;" >> target.fth
./lisp/lisp.sh '(load "lisp/meta.lisp") (compile-forth "targets/c/nucleus.fth" "src/kernel.fth")'
;; Loading file lisp/meta.lisp ...
;;  Loading file params.lisp ...
;;  Loaded file params.lisp
;;  Loading file lisp/words.lisp ...
;;  Loaded file lisp/words.lisp
;; Loaded file lisp/meta.lisp
gcc -m32 -O2 -fomit-frame-pointer -fno-unit-at-a-time -Itargets/c  -c -o kernel.o kernel.c
gcc -m32 kernel.o -o b-forth
rm -f kernel.c kernel.o params.lisp jump.fth threading.fth target.fth
make[1]: Leaving directory '/home/kevin/lbForth'
cp b-forth forth
rm -f *-stamp
touch x86-windows-stamp
cat targets/x86/params.fth targets/x86/windows/params.fth > params.fth
cp targets/x86/jump.fth jump.fth
cp targets/itc.fth threading.fth
cat targets/x86/target.fth targets/x86/windows/target.fth > target.fth
echo ": sysdir   s\" /usr/local/share/lbForth/\" ;" >> target.fth
echo include targets/x86/meta.fth | targets/c/run.sh ./forth | tail -n+3 > x86-forth
mv image x86-forth
mv: cannot stat 'image': No such file or directory
make: [targets/x86/forth.mk:6: x86-forth] Error 1 (ignored)
chmod a+x x86-forth
rm -f forth.exe
cp x86-forth forth
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ 
larsbrinkhoff commented 7 years ago

That actually looks like a success. Try running "forth"

The error message about the missing image file is an artifact of the build system, and is ignored.

vigilancetech-com commented 7 years ago
$ make clean 
rm -f params.fth jump.fth threading.fth target.fth
rm -f forth *-forth test-* *-stamp *.exe conf.mk
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ ./configure
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ make
make -ftargets/c/bootstrap.mk
make[1]: Entering directory '/home/kevin/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
targets/c/run.sh ./params -lisp > params.lisp
cp targets/c/jump.fth jump.fth
cp targets/ctc.fth threading.fth
cp targets/c/target.fth target.fth
echo ": sysdir   s\" src/\" ;" >> target.fth
./lisp/lisp.sh '(load "lisp/meta.lisp") (compile-forth "targets/c/nucleus.fth" "src/kernel.fth")'
;; Loading file lisp/meta.lisp ...
;;  Loading file params.lisp ...
;;  Loaded file params.lisp
;;  Loading file lisp/words.lisp ...
;;  Loaded file lisp/words.lisp
;; Loaded file lisp/meta.lisp
gcc -m32 -O2 -fomit-frame-pointer -fno-unit-at-a-time -Itargets/c  -c -o kernel.o kernel.c
gcc -m32 kernel.o -o b-forth
rm -f kernel.c kernel.o params.lisp jump.fth threading.fth target.fth
make[1]: Leaving directory '/home/kevin/lbForth'
cp b-forth forth
rm -f *-stamp
touch x86-windows-stamp
cat targets/x86/params.fth targets/x86/windows/params.fth > params.fth
cp targets/x86/jump.fth jump.fth
cp targets/itc.fth threading.fth
cat targets/x86/target.fth targets/x86/windows/target.fth > target.fth
echo ": sysdir   s\" /usr/local/share/lbForth/\" ;" >> target.fth
echo include targets/x86/meta.fth | targets/c/run.sh ./forth | tail -n+3 > x86-forth
mv image x86-forth
mv: cannot stat 'image': No such file or directory
make: [targets/x86/forth.mk:6: x86-forth] Error 1 (ignored)
chmod a+x x86-forth
rm -f forth.exe
cp x86-forth forth
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ forth
bash: forth: command not found
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ ls
INSTALL    app/           build.md       conf.mk     experiments/      lib/             params.exe*  targets/       x86-forth*
LICENSE    appharbor.sln  build.vcxproj  configure*  forth*            lisp/            params.fth   test/          x86-windows-stamp
Makefile   appveyor.yml   check.mk       contrib/    install-deps.sh*  myforth.c        src/         threading.fth
README.md  b-forth.exe*   circle.yml     doc/        jump.fth          packages.config  target.fth   wercker.yml
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ ./forth
./forth: line 1: Undefined:: command not found
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ cat forth
Undefined: file-source
0;~/lbForth
joyce oliver@joy61 ~/lbForth
$ 
vigilancetech-com commented 7 years ago

could this have something to do with my path having a space in it? Could there be missing quotes around a variable somewhere (e.g. a $ or $@ not being a "$" or "$@" )?

larsbrinkhoff commented 7 years ago

I have now pushed a fix for the EXECUTE problem. The build now works without any complaints using CLISP on my machine.

larsbrinkhoff commented 7 years ago

I think your change from EXECUTE to MY-EXECUTE may have broken the metacompiler. When it sees a Forth word in the course, it depends on finding the corresponding Lisp definition with the same name.

Try the latest version. Don't forget to update the "lisp" submodule too.

larsbrinkhoff commented 7 years ago

Also, you may want to specify something other than the default "c" target, e.g.

make TARGET=x86 OS=linux
vigilancetech-com commented 7 years ago

same result with a fresh clone:

$ ./configure
0;/home/kevin/lbForth
joyce oliver@joy61 /home/kevin/lbForth
$ make
make -ftargets/c/bootstrap.mk
make[1]: Entering directory '/home/kevin/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
targets/c/run.sh ./params -lisp > params.lisp
cp targets/c/jump.fth jump.fth
cp targets/ctc.fth threading.fth
cp targets/c/target.fth target.fth
echo ": sysdir   s\" src/\" ;" >> target.fth
git submodule update --init
Submodule 'lisp' (http://github.com/larsbrinkhoff/forth-metacompiler) registered for path 'lisp'
Cloning into '/home/kevin/lbForth/lisp'...
remote: Counting objects: 143, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 143 (delta 0), reused 0 (delta 0), pack-reused 140
Receiving objects: 100% (143/143), 56.46 KiB | 0 bytes/s, done.
Resolving deltas: 100% (90/90), done.
Checking connectivity... done.
Submodule path 'lisp': checked out '40b99c09628f616d94649009ba9894340088d77c'
./lisp/lisp.sh '(load "lisp/meta.lisp") (compile-forth "targets/c/nucleus.fth" "src/kernel.fth")'
;; Loading file lisp/meta.lisp ...
;;  Loading file params.lisp ...
;;  Loaded file params.lisp
;;  Loading file lisp/words.lisp ...
;;  Loaded file lisp/words.lisp
;; Loaded file lisp/meta.lisp
gcc -m32 -O2 -fomit-frame-pointer -fno-unit-at-a-time -Itargets/c  -c -o kernel.o kernel.c
gcc -m32 kernel.o -o b-forth
rm -f kernel.c kernel.o params.lisp jump.fth threading.fth target.fth
make[1]: Leaving directory '/home/kevin/lbForth'
cp b-forth forth
rm -f *-stamp
touch x86-windows-stamp
cat targets/x86/params.fth targets/x86/windows/params.fth > params.fth
cp targets/x86/jump.fth jump.fth
cp targets/itc.fth threading.fth
cat targets/x86/target.fth targets/x86/windows/target.fth > target.fth
echo ": sysdir   s\" /usr/local/share/lbForth/\" ;" >> target.fth
echo include targets/x86/meta.fth | targets/c/run.sh ./forth | tail -n+3 > x86-forth
mv image x86-forth
mv: cannot stat 'image': No such file or directory
make: [targets/x86/forth.mk:6: x86-forth] Error 1 (ignored)
chmod a+x x86-forth
rm -f forth.exe
cp x86-forth forth
0;/home/kevin/lbForth
joyce oliver@joy61 /home/kevin/lbForth
$ ls -lt|head
total 255K
-rwxr-xr-x  1 joyce oliver None   23 Mar 28 13:34 forth*
-rwxr-xr-x  1 joyce oliver None   23 Mar 28 13:34 x86-forth*
-rw-r--r--  1 joyce oliver None  704 Mar 28 13:33 target.fth
-rw-r--r--  1 joyce oliver None  455 Mar 28 13:33 threading.fth
-rw-r--r--  1 joyce oliver None  208 Mar 28 13:33 jump.fth
-rw-r--r--  1 joyce oliver None  336 Mar 28 13:33 params.fth
-rw-r--r--  1 joyce oliver None    0 Mar 28 13:33 x86-windows-stamp
-rwxr-xr-x  1 joyce oliver None  79K Mar 28 13:33 b-forth.exe*
drwxr-xr-x+ 1 joyce oliver None    0 Mar 28 13:33 lisp/
0;/home/kevin/lbForth
joyce oliver@joy61 /home/kevin/lbForth
$ cat forth
Undefined: file-source
0;/home/kevin/lbForth
joyce oliver@joy61 /home/kevin/lbForth
$ 
vigilancetech-com commented 7 years ago

No change with make TARGET=x86 OS=windows

larsbrinkhoff commented 7 years ago

That's strange. I don't know what's going on.

Apparently, the bootstrap "b-forth" works ok. It tries to run the metacompiler, but it complains that there is no "file-source" definition. But that's located well past half of kernel.fth, so I don't understand why it would break at that point.

Maybe spaces in filenames, as you suggested. Or maybe CRLF line endings?

vigilancetech-com commented 7 years ago

maybe. I'm going to change machines here pretty soon and I'll make sure the username doesn't have a space in it this time and check it again. If that's it, its kind of a nasty bug we should chase down. It's been many years since I had much dealings with make (which is probably where it lies)

larsbrinkhoff commented 7 years ago

I'll have access to a Windows machine on Monday. I can do some tests then.

larsbrinkhoff commented 7 years ago

Hmm, it could be the git client. I have been using the one that comes with Cygwin. Maybe if you check out the source code with some other version of git for Windows, something will be slightly garbled.

vigilancetech-com commented 7 years ago

I tried it without a space in the path. Same problem. I'm using the one that comes with cygwin too. Did the version with cygwin git work for you?

larsbrinkhoff commented 7 years ago

Thanks for testing. Yes, as I recall, the cygwin git worked back when I did the Window port.

I should be able to test this myself tomorrow.

larsbrinkhoff commented 7 years ago

Installing cygwin was slow for some reason, so I wasn't able to complete it today. Will continue tomorrow.

vigilancetech-com commented 7 years ago

BTW, would you consider downgrading your GPL license to LGPL so your forth could be used to build commercial software? I think its really wonderful but I won't be able to use it for anything serious due to that limitation.

larsbrinkhoff commented 7 years ago

I installed cygwin for x86-64, and building works ok. I had to use make M32= but that's expected.

Are you using the 32-bit cygwin? I'll try that too.

larsbrinkhoff commented 7 years ago

Yes, I see the error in cygwin32.

larsbrinkhoff commented 7 years ago

I'll close this, because the EXECUTE error seems to be fixed. I'll open two new issues: one about the current problem, and another about licensing.