Skip to content

Commit

Permalink
Migrate compiler build from ocamlbuild to dune
Browse files Browse the repository at this point in the history
  • Loading branch information
maximedenes authored and bgregoir committed Mar 22, 2023
1 parent aae1897 commit 3190103
Show file tree
Hide file tree
Showing 22 changed files with 84 additions and 208 deletions.
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ ocaml:
artifacts:
paths:
- compiler/_build/
- compiler/jasminc.native
- compiler/jazz2tex.native
- compiler/jasminc
- compiler/jazz2tex

eclib:
stage: prove
Expand Down Expand Up @@ -143,7 +143,7 @@ opam-compiler:
nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run
'eval $(opam env) &&
make -C compiler -j$NIX_BUILD_CORES &&
(cd compiler && mkdir -p bin && cp _build/entry/jasminc.native bin/jasminc)'
(cd compiler && mkdir -p bin && cp _build/default/jasminc.exe bin/jasminc)'
artifacts:
paths:
- compiler/bin/jasminc
Expand Down Expand Up @@ -182,7 +182,7 @@ check:
- coq-program
- ocaml
script:
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run './compiler/jasminc.native -version'
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run './compiler/jasminc -version'
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -j$NIX_BUILD_CORES -C compiler check-ci $EXTRA_MAKE_ARGUMENTS'

libjade-compile-to-asm:
Expand Down
8 changes: 4 additions & 4 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ compiler/entry/jasminc.ml
compiler/src/LICENSE.puf
compiler/scripts/runtest
compiler/Makefile
compiler/jasmin.mlpack.in
compiler/myocamlbuild.ml
compiler/_tags
compiler/opam
compiler/dune
compiler/dune-project
compiler/src/dune
compiler/jasmin.opam
compiler/CIL/.keep
compiler/config/tests.config

Expand Down
7 changes: 4 additions & 3 deletions compiler/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ README.md

default.nix
Makefile
jasmin.mlpack.in
_tags
myocamlbuild.ml
dune
dune-project
src/dune
.merlin
jasmin.opam

find:CIL:*.ml
find:CIL:*.mli
Expand Down
45 changes: 13 additions & 32 deletions compiler/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# -*- Makefile -*-

# --------------------------------------------------------------------
OCAMLBUILD_JOBS ?= 2
OCAMLBUILD_BIN ?= ocamlbuild
OCAMLBUILD_EXTRA ?=
OCAMLBUILD_OPTS := -use-ocamlfind -j $(OCAMLBUILD_JOBS)

# In Emacs, use classic display to enable error jumping.
ifeq ($(shell echo $$TERM), dumb)
OCAMLBUILD_OPTS += -classic-display
endif
OCAMLBUILD_OPTS += $(OCAMLBUILD_EXTRA)

OCAMLBUILD := $(OCAMLBUILD_BIN) $(OCAMLBUILD_OPTS)

# --------------------------------------------------------------------
JSJOBS ?= 2
CHECKPY ?=
Expand Down Expand Up @@ -45,26 +31,21 @@ OBELISK ?= obelisk
all: build
@true

build: jasmin.mlpack native
build: native

define do-build
$(RM) jasminc jazz2tex
$(OCAMLBUILD) "entry/jasminc.$(1)" "entry/jazz2tex.$(1)"
ln -sf "_build/entry/jasminc.$(1)" jasminc
ln -sf "_build/entry/jazz2tex.$(1)" jazz2tex
dune build jasminc.$(1)
dune build jazz2tex.$(1)
ln -sf "_build/default/jasminc.$(1)" jasminc
ln -sf "_build/default/jazz2tex.$(1)" jazz2tex
endef

byte:
$(call do-build,byte)
$(call do-build,bc)

native:
$(call do-build,native)

jasmin.mlpack: __force__
( echo '# GENERATED - EDIT jasmin.mlpack.in'; \
cat jasmin.mlpack.in; \
echo "$(wildcard CIL/*.ml*)" | tr ' ' '\n' | sed 's/\..*$$//' | sort -u ) \
> jasmin.mlpack
$(call do-build,exe)

CIL:
rm -f CIL/*.ml CIL/*.mli ../proofs/extraction.vo
Expand All @@ -79,14 +60,14 @@ check-ci:
$(CHECK) --report=- $(CHECKCATS)

clean:
$(OCAMLBUILD) -clean -classic-display
dune clean
rm -rf _c_build
rm -f jasminc.native jasminc.byte lib*.a
rm -f jasminc jazz2tex lib*.a

install:
$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 -T jasminc.native $(DESTDIR)$(BINDIR)/jasminc
$(INSTALL) -m 0755 -T jazz2tex.native $(DESTDIR)$(BINDIR)/jazz2tex
$(INSTALL) -m 0755 -T jasminc $(DESTDIR)$(BINDIR)/jasminc
$(INSTALL) -m 0755 -T jazz2tex $(DESTDIR)$(BINDIR)/jazz2tex

uninstall:
$(RM) $(DESTDIR)$(BINDIR)/jasminc
Expand All @@ -111,8 +92,8 @@ lib%.a: _c_build/%.o
_c_build/%.o: _c_build/%.s
gcc -c -o $@ $<

_c_build/%.s: examples/%.jazz _c_build jasminc.native
./jasminc.native $< -o $@
_c_build/%.s: examples/%.jazz _c_build jasminc
./jasminc $< -o $@

# --------------------------------------------------------------------
%.inferred.mli:
Expand Down
29 changes: 0 additions & 29 deletions compiler/_tags

This file was deleted.

4 changes: 2 additions & 2 deletions compiler/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ stdenv.mkDerivation {
name = "jasmin-0";
src = ./.;
buildInputs = [ mpfr ppl ]
++ (with ocamlPackages; [ ocaml findlib ocamlbuild apron batteries camlidl cmdliner menhir menhirLib zarith yojson])
++ (with ocamlPackages; [ ocaml findlib dune_3 apron batteries camlidl cmdliner menhir menhirLib zarith yojson])
;

installPhase = ''
mkdir -p $out/bin
for p in jasminc jazz2tex
do
cp _build/entry/$p.native $out/bin/$p
cp _build/default/$p.exe $out/bin/$p
done
'';
}
31 changes: 31 additions & 0 deletions compiler/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(env
(dev
(flags (:standard -w +Z+Y+28-23+32+33+34-58@8)))
(release
(flags (:standard -w +Z+Y+28-23+32+33+34-58@8))))

(dirs src CIL entry)
(include_subdirs unqualified)

(executable
(public_name jasminc)
(name jasminc)
(modules jasminc)
(flags -rectypes)
(modes byte exe)
(libraries jasmin))

(executable
(public_name jazz2tex)
(name jazz2tex)
(modules jazz2tex)
(flags -rectypes)
(modes byte exe)
(libraries cmdliner jasmin))

(library
(name jasmin)
(public_name jasmin.jasmin)
(modules :standard \ jasminc jazz2tex)
(flags -rectypes)
(libraries batteries zarith menhirLib yojson apron.octMPQ apron.ppl apron.boxMPQ))
5 changes: 5 additions & 0 deletions compiler/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(lang dune 3.2)
(name jasmin)
(license MIT)
(authors "The Jasmin development team")
(using menhir 2.1)
2 changes: 1 addition & 1 deletion compiler/examples/gimli/x86-64/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JASMINC?=../../jasminc.native
JASMINC?=../../jasminc

.SUFFIXES: .s .o .jazz .jinc

Expand Down
2 changes: 1 addition & 1 deletion compiler/examples/siphash/x86-64/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JASMINC?=../../jasminc.native
JASMINC?=../../jasminc

all: run
./run
Expand Down
69 changes: 0 additions & 69 deletions compiler/jasmin.mlpack.in

This file was deleted.

4 changes: 2 additions & 2 deletions compiler/opam → compiler/jasmin.opam
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ build: [
]
install: [
mkdir -p "%{prefix}%/bin"
cp "_build/entry/jasminc.native" "%{prefix}%/bin/jasminc"
cp "_build/entry/jazz2tex.native" "%{prefix}%/bin/jazz2tex"
cp "_build/default/jasminc.exe" "%{prefix}%/bin/jasminc"
cp "_build/default/jazz2tex.exe" "%{prefix}%/bin/jazz2tex"
]
depends: [
"ocaml" { >= "4.10" & build }
Expand Down
50 changes: 0 additions & 50 deletions compiler/myocamlbuild.ml

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/scripts/check-arm-m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ trap "rm -r ${DIR}" EXIT

set -x

$(dirname $0)/../jasminc.native -arch arm-m4 -o ${ASM} "$@"
$(dirname $0)/../jasminc -arch arm-m4 -o ${ASM} "$@"

llvm-mc --triple=armv7m --mcpu=cortex-m4 --filetype=obj -o ${OBJ} ${ASM}
2 changes: 1 addition & 1 deletion compiler/scripts/check-cct
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

exec $(dirname $0)/../jasminc.native -checkCT "$@"
exec $(dirname $0)/../jasminc -checkCT "$@"
2 changes: 1 addition & 1 deletion compiler/scripts/check-safety
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

exec $(dirname $0)/../jasminc.native -checksafety "$@"
exec $(dirname $0)/../jasminc -checksafety "$@"
Loading

0 comments on commit 3190103

Please sign in to comment.