chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

fails to work on 9front

Open bakul opened this issue 3 years ago • 9 comments

Compiles but doesn't work on 9front

% mk install
% cd 
% chibi-scheme
ERROR: couldn't find include: "srfi/69/hash.no-such-file"
  called from <anonymous> on line 211 of file /sys/lib/chibi-scheme/meta-7.scm
  called from <anonymous> on line 1213 of file /sys/lib/chibi-scheme/init-7.scm
  called from <anonymous> on line 280 of file /sys/lib/chibi-scheme/init-7.scm
  called from error on line 100 of file /sys/lib/chibi-scheme/init-7.scm

Looks like this is related to shared libraries as I see

#define sexp_so_extension ".no-such-file"

in include/chibi/install.h

bakul avatar May 15 '21 01:05 bakul

chibi-scheme -q should work.

SRFI 69 should be compiled statically in the 9front build, not sure what broke there.

ashinn avatar May 15 '21 06:05 ashinn

Thanks. Yes, chibi-scheme -q works but still, things are broken. For instance mk test fails. Another example: (expt 2 32) returns 0. This is with $objtype = amd64.

[edit: not filing a separate PR yet as the root cause may be the same for all this]

bakul avatar May 15 '21 14:05 bakul

I've never tried to build Chibi on 9front and don't have an installation available. I don't have any plans to address this port myself, but patches are welcome.

The original Plan9 work was all done on 9vx. I haven't touched this in ages, but nothing fundamental has changed.

ashinn avatar May 16 '21 11:05 ashinn

What I'm seeing is when gen-static is called during the 2nd phase of the build, it gets in some kind of allocation loop and eventually runs out of memory.

I'm willing to dig deeper if you have tips, but I'm not sure what to do about it.

mars2klb avatar Nov 08 '22 17:11 mars2klb

I believe this is a problem recognizing eof-object: linux:

$ chibi-scheme                                                                                                                                                                                                                                                                                                  
> (define eof-object (read-char (open-input-string "")))
> (eof-object? eof-object)
#t
> eof-object
#<eof>
>

9front:

% ./6.out -q
> (define eof-object (read-char (open-input-string "")))
> (eof-object? eof-object)
#f
> eof-object
#\xffffff
> 

It just keeps reading until it runs out of memory since it never sees the eof.

#define EOF (-1) in stdio.h just like linux

mars2klb avatar Dec 08 '22 00:12 mars2klb

So EOF is somehow becoming positive on 9front?

ashinn avatar Dec 08 '22 21:12 ashinn

I think it must be an architecture thing (sizes) because if I change https://github.com/ashinn/chibi-scheme/blob/master/vm.c#L2206 from

 if (i == EOF) {

to

 if ((int)i == EOF) {

it works.

The build still fails for other reasons, but this seems to address one bit of brokenness.

mars2klb avatar Dec 08 '22 22:12 mars2klb

i is sexp_sint_t which may indeed be larger than int, so without the cast you'd expect it to promote EOF to the larger size. This should work properly, so it seems like a bug in the 9front compiler?

At the same time, the cast should be safe on all platforms, I can add that.

ashinn avatar Dec 11 '22 03:12 ashinn

I think plan9 promotion rules are older K&R C rules while Ansi C made a "quiet change" in 1990. But this was a long time ago and I don't recall the details. Just a vague memory.

bakul avatar Dec 11 '22 03:12 bakul