Skip to content

Commit

Permalink
Merge branch 'e2e4b6b7-1.30' into 1.30
Browse files Browse the repository at this point in the history
  • Loading branch information
dboulytchev committed Aug 28, 2024
2 parents f51d063 + 84cf5fa commit c8a56b7
Show file tree
Hide file tree
Showing 64 changed files with 6,218 additions and 3,960 deletions.
36 changes: 16 additions & 20 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
name: Build
name: Main workflow

on:
pull_request:
push:
paths-ignore:
- 'README.md'
branches:
- '1.10'

permissions: read-all

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
#- macos-latest
- ubuntu-20.04
#- windows-latest
ocaml-version:
#- 4.11.0
- 4.10.1
#- 4.09.1
#- 4.08.1
- ubuntu-latest
- macos-latest
ocaml-compiler:
- 4.13.1

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
- name: Checkout tree
uses: actions/checkout@v3

- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-version: ${{ matrix.ocaml-version }}
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- run: opam pin add Lama.dev . --no-action
- run: opam depext Lama.dev --yes --with-test
- run: opam install . --deps-only --with-test
- run: opam exec -- make #dune build
- run: opam exec -- make regression # dune runtest
- run: eval $(opam env)
- run: opam exec -- make
- run: opam exec -- make regression
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.o
.merlin

.vscode
27 changes: 14 additions & 13 deletions Lama.opam
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
opam-version: "2.0"
version: "1.10"
version: "1.30"

synopsis: "Lama programming system"
synopsis: "Lama programming language"
maintainer: "[email protected]"
authors: "[email protected]"
homepage: "https://github.com/JetBrains-Research/Lama"
bug-reports: "https://github.com/JetBrains-Research/Lama/issues"
authors: [
"Dmitry Boulytchev <[email protected]>"
"Daniil Berezun <[email protected]>"
"Egor Sheremetov <[email protected]>"
]
homepage: "https://github.com/PLTools/Lama"
bug-reports: "https://github.com/PLTools/Lama/issues"

depends: [
"ocaml" { >= "4.07.1" }
"ocaml" { >= "4.13.1" }
"ocamlfind" { build }
"camlp5" { >= "8.00.05" }
"ostap" { >= "0.5"}
"GT" { >= "0.5.0" }
"GT" { >= "0.5.1" }
"posix-uname" { = "2.0.2" }
]

build: [
Expand All @@ -21,11 +26,7 @@ build: [
]
install: [make "install"]

depexts: [
["gcc-multilib"] {os-family = "debian"}
]

dev-repo: "git+https://github.com/JetBrains-Research/Lama.git"
dev-repo: "git+https://github.com/PLTools/Lama.git"
url {
src: "git+https://github.com/JetBrains-Research/Lama.git#1.10+ocaml4.10"
src: "git+https://github.com/PLTools/Lama.git#1.30"
}
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
EXECUTABLE = src/lamac
INSTALL ?= install -v
MKDIR ?= mkdir
BUILDDIR = build

.PHONY: all regression

all:
$(MAKE) -C src
$(MAKE) -C runtime
$(MAKE) -C byterun
$(MAKE) -C stdlib

STD_FILES=$(shell ls stdlib/*.[oi] stdlib/*.lama runtime/runtime.a runtime/Std.i)

build: all
mkdir -p $(BUILDDIR)
cp -r runtime/Std.i runtime/runtime.a stdlib/* src/lamac $(BUILDDIR)

install: all
$(INSTALL) $(EXECUTABLE) `opam var bin`
$(MKDIR) -p `opam var share`/Lama
Expand All @@ -21,13 +25,24 @@ uninstall:
$(RM) -r `opam var share`/Lama
$(RM) `opam var bin`/$(EXECUTABLE)

regression-all: regression regression-expressions

regression:
$(MAKE) clean check -C regression
$(MAKE) clean check -C stdlib/regression
$(MAKE) clean check -j8 -C regression
$(MAKE) clean check -j8 -C stdlib/regression

regression-expressions:
$(MAKE) clean check -j8 -C regression/expressions
$(MAKE) clean check -j8 -C regression/deep-expressions

negative_scenarios_tests:
$(MAKE) -C runtime negative_tests

clean:
$(MAKE) clean -C src
$(MAKE) clean -C runtime
$(MAKE) clean -C stdlib
$(MAKE) clean -C regression
$(MAKE) clean -C byterun
$(MAKE) clean -C bench
rm -rf $(BUILDDIR)
76 changes: 40 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
| Lama 1.10 | Lama-devel 1.10 |
| -------------------- | -------------------------- |
| [![Lama 1.10][1]][2] | [![Lama-devel 1.10][3]][4] |
| Lama 1.3 |
|---------------------|
| [![Lama 1.3][1]][2] |

[1]: https://github.com/JetBrains-Research/Lama/workflows/Build/badge.svg?branch=1.10
[2]: https://github.com/JetBrains-Research/Lama/actions
[3]: https://github.com/JetBrains-Research/Lama-devel/workflows/Build/badge.svg?branch=1.10
[4]: https://github.com/JetBrains-Research/Lama-devel/actions
[1]: https://github.com/PLTools/Lama/Lama/workflows/Build/badge.svg?branch=1.30
[2]: https://github.com/PLTools/Lama/Lama/actions

# Lama

Expand All @@ -26,13 +24,12 @@ The name ![lama](lama.svg) is an acronym for *Lambda-Algol* since the language h

The main purpose of ![lama](lama.svg) is to present a repertoire of constructs with certain runtime behavior and relevant implementation techniques.
The lack of a type system (a vital feature for a real-world language
for software engineering) is an intensional decision that allows showing the unchained diversity of runtime behaviors, including those that a typical type system is called to prevent.
for software engineering) is an intensional decision that allows showing the unchained diversity of runtime behaviors, including those that a typical type system is called to prevent.
On the other hand the language can be used in the future as a raw substrate to apply various ways of software verification (including type systems).

The current implementation contains a native code compiler for **x86-32**, written in **OCaml**, a runtime library with garbage-collection support, written in **C**, and a small standard library, written in ![lama](lama.svg) itself.
The native code compiler uses **gcc** as a toolchain.
The current implementation contains a native code compiler for **x86-64**, written in **OCaml**, a runtime library with garbage-collection support, written in **C**, and a small standard library, written in ![lama](lama.svg) itself.

In addition, a source-level reference interpreter is implemented as well as a compiler to a small stack machine.
In addition, a source-level reference interpreter is implemented as well as a compiler to a small stack machine.
The stack machine code can in turn be either interpreted on a stack machine interpreter, or used as an intermediate representation by the native code compiler.

## Language Specification
Expand All @@ -41,27 +38,24 @@ The language specification can be found [here](lama-spec.pdf).

## Installation

Supported target: GNU/Linux x86_32 (x86_64 by running 32-bit mode)

***Mac*** users should use either a virtual machine or docker with a Linux distributive inside.
Supported target: GNU/Linux x86_64, MacOS x86_64 (arm using Rosetta).

***Windows*** users should get Windows Subsystem for Linux a.k.a WSL (recommended) or cygwin.
Ubuntu-based variant of WSL is recommended.

* System-wide prerequisites:

- `gcc-multilib`
For example, (for Debian-based GNU/Linux):
```bash
$ sudo apt install gcc-multilib
- Linux: `gcc`

For example, (for Debian-based Linux):
```bash
sudo apt install gcc
```

On some versions, you need to install the additional package `lib32gcc-9-dev` in case of errors like
```
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a when searching for -lgcc
```
- MacOS: `clang`

Should be automatically installed with developer tools.

- [opam](http://opam.ocaml.org) (>= 2.0.4)
- [OCaml](http://ocaml.org) (>= 4.10.1). *Optional* because it can be easily installed through opam.
Compiler variant with `flambda` switch is recommended.
Expand All @@ -73,22 +67,18 @@ Ubuntu-based variant of WSL is recommended.
1. Install the right [switch](https://opam.ocaml.org/doc/Manual.html#Switches) for the OCaml compiler

```bash
# for fresh opam
$ opam switch create lama --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda
# for old opam
$ opam switch create lama ocaml-variants.4.10.1+flambda
opam switch create lama --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda
```

* In the above command:

- `opam switch create` is a subcommand to create a new switch
- `ocaml-variants.4.10.1+flambda` is the name of a standard template for the switch
- `ocaml-variants.4.14.0+options` is the name of a standard template for the switch
- `lama` is an alias for the switch being created; on success a directory `$(HOME)/.opam/lama` should be created

2. Update PATH variable for the fresh switch. (You can add these commands to your `~/.bashrc` for convenience but they should be added by `opam`)
```bash
$ export OPAMSWITCH=lama
$ eval $(opam env)
eval $(opam env --switch=lama --set-switch)
```

* Check that the OCaml compiler is now available in PATH by running `which ocamlc`; it should answer with `/home/user/.opam/lama/bin/ocamlc` (or similar) and `ocamlc -v` should answer with
Expand All @@ -100,16 +90,15 @@ Ubuntu-based variant of WSL is recommended.
3. Pin Lama package using `opam` and right URL (remember of "#" being a comment character in various shells)

```bash
$ opam pin add Lama https://github.com/JetBrains-Research/Lama.git\#1.10 --no-action
opam pin add Lama https://github.com/PLTools/Lama.git\#1.30 --no-action
```

The extra '#' sign is added because in various Shells it is the start of a comment

4. Install *dep*endencies on system-wide *ext*ernal packages and `lama` itself after that.
4. Install dependencies on system-wide external packages and `lama` itself after that.

```bash
$ opam depext Lama --yes
$ opam install Lama --yes
opam install Lama --yes
```

5. Check that `lamac` executable was installed: `which lamac` should answer with
Expand All @@ -120,5 +109,20 @@ Ubuntu-based variant of WSL is recommended.

### Smoke-testing (optional)

Clone the repository and run `make -C tutorial`.
Clone the repository and run `make -C tutorial`.
It should build a local compiler `src/lamac` and a few tutorial executables in `tutorial/`.

### Useful links

* [Plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=mrartemsav.lama-lsp)

### Changes in Lama 1.3

* Migrated from x86-32 to x86-64 architecture.
* Added `let ... in ...` construct.
* Added `-g` mode
* Changed regex syntax ...

### Changes in Lama 1.2

* New garbage collector: single-threaded stop-the-world `LISP2` (see GC Handbook for details: [1st edition](https://www.cs.kent.ac.uk/people/staff/rej/gcbook/), [2nd edition](http://gchandbook.org/)) [mark-compact](https://www.memorymanagement.org/glossary/m.html#term-mark-compact).
8 changes: 5 additions & 3 deletions byterun/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FLAGS=-g -fstack-protector-all

all: byterun.o
$(CC) -m32 -g -o byterun byterun.o ../runtime/runtime.a
$(CC) $(FLAGS) -o byterun byterun.o ../runtime/runtime.a

byterun.o: byterun.c
$(CC) -g -fstack-protector-all -m32 -c byterun.c
$(CC) $(FLAGS) -g -c byterun.c

clean:
$(RM) *.a *.o *~
$(RM) *.a *.o *~ byterun
3 changes: 3 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 3.3)

(cram enable)
Binary file modified lama-spec.pdf
Binary file not shown.
20 changes: 13 additions & 7 deletions regression/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
TESTS=$(sort $(basename $(wildcard test*.lama)))
DEBUG_FILES=stack-dump-before data-dump-before extra-roots-dump-before heap-dump-before stack-dump-after data-dump-after extra-roots-dump-after heap-dump-after
TESTS=$(sort $(filter-out test111, $(basename $(wildcard test*.lama))))

LAMAC=../src/lamac

.PHONY: check $(TESTS)

check: $(TESTS)

check: $(TESTS) ctest111

$(TESTS): %: %.lama
@echo $@
cat $@.input | LAMA=../runtime $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
cat $@.input | LAMA=../runtime $(LAMAC) -ds -s $< > $@.log && diff $@.log orig/$@.log
LAMA=../runtime $(LAMAC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
@echo "regression/$@"
@cat $@.input | LAMA=../runtime $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../runtime $(LAMAC) -ds -s $< > $@.log && diff $@.log orig/$@.log
@LAMA=../runtime $(LAMAC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log

ctest111:
@echo "regression/test111"
@LAMA=../runtime $(LAMAC) test111.lama && cat test111.input | $(ARCH) ./test111 > test111.log && diff test111.log orig/test111.log

clean:
$(RM) test*.log *.s *~ $(TESTS) *.i
$(RM) test*.log *.s *.sm *~ $(TESTS) *.i $(DEBUG_FILES) test111
$(MAKE) clean -C expressions
$(MAKE) clean -C deep-expressions
6 changes: 3 additions & 3 deletions regression/deep-expressions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LAMAC = ../../src/lamac
check: $(TESTS)

$(TESTS): %: %.lama
@echo $@
@echo "regression/deep-expressions/$@"
@LAMA=../../runtime $(LAMAC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(LAMAC) -s $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(LAMAC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(LAMAC) -s $< > $@.log && diff $@.log orig/$@.log

clean:
rm -f *.log *.s *~
Expand Down
6 changes: 3 additions & 3 deletions regression/expressions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ RC = ../../src/lamac
check: $(TESTS)

$(TESTS): %: %.lama
@echo $@
@echo "regression/expressions/$@"
@LAMA=../../runtime $(RC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(RC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | $(RC) -s $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(RC) -i $< > $@.log && diff $@.log orig/$@.log
@cat $@.input | LAMA=../../runtime $(RC) -s $< > $@.log && diff $@.log orig/$@.log

clean:
rm -f *.log *.s *~
Expand Down
Empty file added regression/new_test001.input
Empty file.
10 changes: 10 additions & 0 deletions regression/new_test001.lama
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fun f (a, b, c, d, e) {
var i = d / b;
write (a);
write (b);
write (c);
write (d);
write (e)
}

f (1, 2, 3, 4, 5)
Empty file added regression/new_test002.input
Empty file.
Loading

0 comments on commit c8a56b7

Please sign in to comment.