Command line argument of the distributing application

12 views
Skip to first unread message

ID

unread,
Oct 3, 2025, 2:24:58 PMOct 3
to chez-scheme
Hello folks, I'm currently following section 2.8 of the user manual to try build a distributable application. And everything works, until I try to pass some command line arguments to the application.

The problem is that, some of the command line arguments are consumed by the scheme interpreter itself (e. g. `--version`, `--help`, etc.) AFAIK the interpreter itself first consumes the command line arguments, does the necessary things with the command line flags it knows, then executes the application boot files, right?

Does that mean if I want to use, for example, `--version` flag, in my application, I'll have to use `./myapp -- --version` instead of just `./myapp --version`? Is there any workaround besides writing a wrapper shell script?

Thanks in advance.

---
Best,
ID

Amirouche Boubekki

unread,
Oct 3, 2025, 5:24:15 PMOct 3
to ID, chez-scheme
Try binink:

> git clone https://codeberg.org/amirouche/binink
> cd binink
> ./venv
> make chezscheme # cloned from github.com/cisco/chezscheme in ./local/src/
> make binink
> mv a.out local/bin/binink
> make check
...
> binink

Usage:

binink check [--fail-fast] [DIRECTORY ...] LIBRARY.SCM ...
binink compile [DIRECTORY ...] LIBRARY.SCM PROCEDURE
binink exec [DIRECTORY ...] LIBRARY.SCM PROCEDURE [-- ARGUMENT ...]
binink repl
binink root available
binink root create DISTRIBUTION VERSION MACHINE DIRECTORY
binink root exec DIRECTORY TARGET-DIRECTORY -- COMMAND ...

The following flags are available:

--dev Generate allocation, and instruction counts, debug on
exception, and dump profile information.

--optimize-level=0-3 Configure optimization level, higher is less
safe, harder to debug, but faster

(scheme "Chez Scheme Version 10.3.0-pre-release-4")
(tag "main-22509ee-dirty")
(homepage "https://codeberg.org/amirouche/binink")

Mind the fact that program.scm is not supported. Instead you need a
r6rs library with an exported procedure:

> cd tmp # preferable to avoid warnings
> cat myproject.scm
(library (myproject)

(export main)

(import (chezscheme))


(define main
(lambda args
(display (apply + (map string->number args)))
(newline))))

You can compile it into a a.out binary with the following command:

> binink compile myproject.scm main
compiling /tmp/binink/compile-kFaDKf/program.scm with output to
/tmp/binink/compile-kFaDKf/program.so
Produced: ./a.out
> /usr/bin/time ./a.out 123 321 456
900
real 0m 0.03s
user 0m 0.02s
sys 0m 0.01s

That binary has not dependency except musl:

> ldd a.out
/lib/ld-musl-x86_64.so.1 (0x7f41cab73000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f41cab73000)

For cross compiling to other distro, there is binink root subcommands
that rely on bubblewrap (bwrap), here is quick cli dance to
demonstrate it:

> mkdir /tmp/rootfs/trixie -p
> binink root create debian trixie amd64 /tmp/rootfs/trixie
...
> sudo binink root exec /tmp/rootfs/trixie/ /root -- /bin/bash
$ apt install build-essential uuid-dev liblz4-dev zlib1g-dev git
...
$ git clone https://codeberg.org/amirouche/binink
$ cd binink
$ make chezscheme
$ make binink
$ ./a.out
Usage:

binink check [--fail-fast] [DIRECTORY ...] LIBRARY.SCM ...
...
$ ldd a.out
linux-vdso.so.1 (0x00007f0cd45cf000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0cd3f2c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0cd3d36000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0cd45d1000)

With https://en.wikipedia.org/wiki/Binfmt_misc around you can cross
compile to another hardware architecture
> --
> You received this message because you are subscribed to the Google Groups "chez-scheme" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chez-scheme...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/chez-scheme/fffe7c82-2f6d-418c-a5d8-064ef80f2884n%40googlegroups.com.
base.scm

ID CTo

unread,
Oct 4, 2025, 3:13:49 AMOct 4
to Amirouche Boubekki, chez-scheme
Wow, this is a much more sophisticated solution than I'm expecting.
I'll look into this, thank you!
--
Best,
ID
Reply all
Reply to author
Forward
0 new messages