cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.99k stars 987 forks source link

How to run Chez Scheme on the bare metal? #480

Open guenchi opened 4 years ago

guenchi commented 4 years ago

I'm trying to build a Lisp Machine base on Chez Scheme.

Please give some advice...

thanks very much!

burgerrg commented 4 years ago

What do you have in mind? Would you like to write code that emits machine code for a Lisp machine?

steven741 commented 4 years ago

I was also interested in getting chez to run on bare metal. Chez won't build for bare metal targets so, it requires workarounds. Probably the best way of getting it to build would be to use newlib and make the appropriate patches from there. It's a considered effort.

I think Dr. Burger's hint to write a compiler for your target instead of directly using chez would be better to look into. The problem is complicated and the solution may require it's own lisp and vm. Although, that doesn't answer the question of how to run chez on bare metal targets.

guenchi commented 4 years ago

Here are my thoughts: (and implementations in progress).

  1. Write a preliminary system in assembly and C.
  2. Use C to implement the system functions needed by Chez. (This is exactly what I want to know here, like which functions...)
  3. Use existing machines to cross-compile Chez into the target code.
  4. Use Scheme to implement the remaining system functions.
  5. Optimize specific scheme basic functions. like car, cdr ... etc.
burgerrg commented 4 years ago

One option is to create a new machine type in Chez Scheme. You will need to have a C compiler and run-time libraries for the C side of Chez Scheme. You'll need to write the assembler for your architecture in Scheme (see arm32.ss, ppc32.ss, x86.ss, and x86_64.ss). It's a significant undertaking.

guenchi commented 4 years ago

One option is to create a new machine type in Chez Scheme. You will need to have a C compiler and run-time libraries for the C side of Chez Scheme. You'll need to write the assembler for your architecture in Scheme (see arm32.ss, ppc32.ss, x86.ss, and x86_64.ss). It's a significant undertaking.

thanks :)

I think if the new system is compatible with Unix, maybe there is no need to change the Chez Scheme?

burgerrg commented 4 years ago

It would certainly minimize the porting effort if the system is Posix-like and uses one of the already supported CPUs.

gwatt commented 4 years ago

I'm not trying to discourage anyone from using Chez Scheme, but if you truly want a scheme for bare-metal you should check out Loko (Bare Metal). It's designed to be entirely self hosting and has no dependencies on C libraries. It's also only amd64, so other targets will require significant work.

guenchi commented 4 years ago

It would certainly minimize the porting effort if the system is Posix-like and uses one of the already supported CPUs.

Ya, that was the plan.

guenchi commented 4 years ago

I'm not trying to discourage anyone from using Chez Scheme, but if you truly want a scheme for bare-metal you should check out Loko (Bare Metal). It's designed to be entirely self hosting and has no dependencies on C libraries. It's also only amd64, so other targets will require significant work.

It’s quite useful, thanks!

jasonhemann commented 4 years ago

Let me suggest also Samuel and Marc's experience report. Their paper and video should be up soon.

soegaard commented 4 years ago

Back in the day Flatt has MzScheme on “bare metal” using OSKit. Maybe OSKit is an option today too?

https://www.cs.utah.edu/flux/oskit/

fre. 6. dec. 2019 kl. 22.54 skrev guenchi notifications@github.com:

I'm trying to build a Lisp Machine base on Chez Scheme.

Please give some advice...

thanks very much!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/480?email_source=notifications&email_token=AADQXRNN4JXCTZLNTU7UERDQXLC2TA5CNFSM4JXCC652YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H6YMXBQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQXROXFYRBCQ4RAI6DB23QXLC2TANCNFSM4JXCC65Q .

-- -- Jens Axel Søgaard

guenchi commented 4 years ago

Let me suggest also Samuel and Marc's experience report. Their paper and video should be up soon.

that's very cool...