scheme-containers / monorepo

Generators, website, issues
https://containers.scheme.org
MIT License
7 stars 1 forks source link

Added stalin #23

Closed Retropikzel closed 2 months ago

Retropikzel commented 2 months ago

This ones a total cheat. :D

Since stalin is in Debian packages this container just installs it. It's definitely not ideal but it could be usefull to someone on windows for example.

Feel free to reject this for any reason. Also I put stalin under curiosities and I'm not 100% if thats correct.

lassik commented 2 months ago

We used to cheat on a few schemes by installing the Debian package. We might still have or two of those around.

This is good to get started with, but we prefer to build from the original source archives since it's a good verification that we know a set of build steps that still work.

tracker.debian.org tells us that @rlbdv maintains their stalin package. He's known from Guile and for making Lokke. If we're lucky, he can help.

The original stalin sources have been preserved for posterity at https://files.scheme.org/stalin-0.11.tgz. This is a stable URL that a Dockerfile can use.

lassik commented 2 months ago

Whether we use the Debian package or build from source, we should still include a C compiler in the container so that its users can build and run Scheme programs. E.g. the Chicken and Gambit containers currently do this.

lassik commented 2 months ago

Also I put stalin under curiosities and I'm not 100% if thats correct.

Yes. Most schemers would definitely consider it a curiosity at the moment. It only supports R4RS, and we don't know anybody besides its original author who comprehends it.

Retropikzel commented 2 months ago

I now tried to build it but this Dockerfile: `# -- mode: dockerfile; coding: utf-8 -- FROM debian:bookworm-slim AS build RUN apt-get update && apt-get -y --no-install-recommends install \ stalin build-essential git ca-certificates libx11-dev libgc-dev libgc1 \ && rm -rf /var/lib/apt/lists/* WORKDIR /build RUN git clone https://github.com/barak/stalin.git --depth=1 WORKDIR /build/stalin RUN sed -i 's@./stalin@stalin@' makefile RUN ./build RUN make install

FROM debian:bookworm-slim COPY --from=build /usr/local/ /usr/local/ COPY scheme-banner /usr/local/bin/ COPY scheme-r7rs /usr/local/bin/ RUN ldconfig CMD ["scheme-banner"] `

Leads to segmentation fault at RUN ./build phase. :/ Better to use the Debian package for now.

lassik commented 2 months ago

Good to know. Thanks for trying it anyway. Maybe we can build it in the future. I'm trying to persuade people to consolidate that kind of maintenance work under https://conservatory.scheme.org/, but it's slow going.

@barak has packaged several old Scheme implementations for Debian, but tends to be quite busy.

lassik commented 2 months ago

Did you manage to compile and run a hello world using the stalin package from debian?

What does stalin -On do?

build-essential is quite a large package which installs a lot of stuff we don't need. In the interest of slimming down the container, would gcc libc-dev be adequate for its needs? That's what we use for the other compile-to-C schemes.

lassik commented 2 months ago

(We use build-essential in the build containers since their size doesn't matter, but we try to keep down the size of the run containers that users actually download. Modern Linux doesn't make that easy, but there are still ways to trim tens and in some cases even hundreds of megabytes.)

Retropikzel commented 2 months ago

Did you manage to compile and run a hello world using the stalin package from debian?

What does stalin -On do?

Yes I managed to compile test code. Just simple (display "hello"). When stalin is started it says:

 For now, you must specify -On because safe fixnum arithmetic is not (yet) implemented

So I added it to the scheme-banner and scheme-r7rs, it says the same when you run bash inside the container and compile stuff.

build-essential is quite a large package which installs a lot of stuff we don't need. In the interest of slimming down the container, would gcc libc-dev be adequate for its needs? That's what we use for the other compile-to-C schemes.

Switched to just gcc package.

lassik commented 2 months ago

We're going to need libc-dev as well. It has the standard C headers, and also pulls in the libc binary package.

lassik commented 2 months ago

If you run bash in the built container (e.g. docker run --rm -it schemers/stalin:0 bash)

and type echo '(display "hello world") (newline)' >hello.scm

are you able to compile that hello.scm using stalin and run the resulting executable?

Retropikzel commented 2 months ago

If you run bash in the built container (e.g. docker run --rm -it schemers/stalin:0 bash)

and type echo '(display "hello world") (newline)' >hello.scm

are you able to compile that hello.scm using stalin and run the resulting executable?

Yes.

lassik commented 2 months ago

Great!

Sorry, I missed your earlier comment saying you managed to build a test program. It works on my end as well.

I was wrong about the need to manually specify libc-dev. The gcc package pulls it in, even with --no-install-recommends. I think this wasn't the case in prior versions of Debian since we've specified it explicitly, but it could have been an oversight on my part.

lassik commented 2 months ago

I'd like to suggest a few more changes:

Retropikzel commented 2 months ago

I'd like to suggest a few more changes:

* Change the container tag from `head` to `0`. What Debian is offering is the release version 0.11 with [minimal patches](https://sources.debian.org/src/stalin/0.11-7/debian/patches/). The major version is extremely unlikely to ever climb to 1.

* Drop the `scheme-r7rs` command since R7RS isn't supported.

* Perhaps `scheme-banner` should simply `echo Stalin 0.11`. The idea is that it introduces the implementation and drops into a REPL. Stalin is the only well-known implementation that does not have a REPL. This presents a bit of a dilemma about what to do.

Should the banner say maybe that there is no repl? Something like: echo Stalin 0.11 (Stalin has no repl)

lassik commented 2 months ago

Should the banner say maybe that there is no repl? Something like: echo Stalin 0.11 (Stalin has no repl)

That's a good idea.

lassik commented 2 months ago

Sorry, don't have as much time today so I finished the PR myself.

I dropped the head tag since it was based on the same Debian package as the 0 tag.

The scheme-banner command should not run stalin (well, apart from stalin -version) since it cannot do anything useful. To compile something, the user must give an entirely custom command line to start the container with. That command line may either be stalin with the right options, or simply bash. Users will probably want to volume-mount complex projects into the container.

lassik commented 2 months ago

(We use CMD instead of ENTRYPOINT so one cannot give arguments to scheme-banner by appending them to the docker run command. For the sake of consistency, we do this for all containers. This also enables the user to easily drop into bash.)

lassik commented 2 months ago

Just discovered these by accident:

Retropikzel commented 2 months ago

Thank you!

lassik commented 2 months ago

Updated https://github.com/schemedoc/usage while at it.