Skip to content

Commit 928d038

Browse files
committed
WIP on more dune
Signed-off-by: Kakadu <[email protected]>
1 parent 8a4ff68 commit 928d038

File tree

12 files changed

+174
-66
lines changed

12 files changed

+174
-66
lines changed

dune-project

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
(lang dune 3.3)
22

33
(cram enable)
4+
5+
(generate_opam_files true)
6+
7+
(package
8+
(name Lama)
9+
(synopsis "TODO")
10+
(depends posix-uname))

runtime/dune

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(rule
2+
(target runtime.a)
3+
(mode
4+
(promote (until-clean)))
5+
(deps Makefile gc.c gc.h runtime_common.h runtime.c runtime.h printf.S)
6+
(action
7+
(run make)))

runtime32/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
RUNTIME=runtime32.a
12

2-
all: gc_runtime.o runtime.o
3-
ar rc runtime.a gc_runtime.o runtime.o
3+
.DEFAULT := $(RUNTIME)
4+
5+
$(RUNTIME): gc_runtime.o runtime.o
6+
ar rc $@ gc_runtime.o runtime.o
47

58
gc_runtime.o: gc_runtime.s
69
$(CC) -g -fstack-protector-all -m32 -c gc_runtime.s

runtime32/dune

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(rule
2+
(target runtime32.a)
3+
(mode
4+
(promote (until-clean)))
5+
(deps Makefile gc_runtime.s runtime.c runtime.h)
6+
(action
7+
(run make)))

src/Driver.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ let[@ocaml.warning "-32"] main =
1212
cmd#dump_AST (snd prog);
1313
cmd#dump_source (snd prog);
1414
match cmd#get_mode with
15-
| `Default | `Compile -> ignore @@ X86_64.build cmd prog
15+
| `Default | `Compile -> (
16+
match cmd#march with
17+
| `X86_32 -> ignore @@ X86_32.build cmd prog
18+
| `AMD64 -> ignore @@ X86_64.build cmd prog)
1619
| `BC -> SM.ByteCode.compile cmd (SM.compile cmd prog)
1720
| _ ->
1821
let rec read acc =

src/Options.ml

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class options args =
4343
val i = ref 1
4444
val infile = ref (None : string option)
4545
val outfile = ref (None : string option)
46+
val march = ref `AMD64
4647
val runtime_path = runtime_path_
4748
val paths = ref [ runtime_path_ ]
4849
val mode = ref (`Default : [ `Default | `Eval | `SM | `Compile | `BC ])
@@ -79,6 +80,8 @@ class options args =
7980
raise
8081
(Commandline_error "Path expected after '-I' specifier")
8182
| Some path -> self#add_include_path path)
83+
| "-march=amd64" -> march := `AMD64
84+
| "-march=x86" -> march := `X86_32
8285
| "-s" -> self#set_mode `SM
8386
| "-b" -> self#set_mode `BC
8487
| "-i" -> self#set_mode `Eval
@@ -139,6 +142,8 @@ class options args =
139142
Some args.(j))
140143
else None
141144

145+
method march : [ `AMD64 | `X86_32 ] = !march
146+
method get_debug = ""
142147
method get_mode = !mode
143148

144149
method get_output_option =

0 commit comments

Comments
 (0)