mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Handle -march properly
Signed-off-by: Kakadu <Kakadu@pm.me>
This commit is contained in:
parent
55d595600d
commit
3f7f51b2f0
10 changed files with 51 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
RUNTIME=runtime32.a
|
RUNTIME=runtime.a
|
||||||
|
|
||||||
.DEFAULT := $(RUNTIME)
|
.DEFAULT := $(RUNTIME)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
(rule
|
(rule
|
||||||
(target runtime32.a)
|
(target runtime.a)
|
||||||
(mode
|
(mode
|
||||||
(promote (until-clean)))
|
(promote (until-clean)))
|
||||||
(deps Makefile gc_runtime.s runtime.c runtime.h)
|
(deps Makefile gc_runtime.s runtime.c runtime.h)
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ let[@ocaml.warning "-32"] main =
|
||||||
try
|
try
|
||||||
let r = read_int () in
|
let r = read_int () in
|
||||||
Printf.printf "> ";
|
Printf.printf "> ";
|
||||||
read (acc @ [ r ])
|
read (r :: acc)
|
||||||
with End_of_file -> acc
|
with End_of_file -> List.rev acc
|
||||||
in
|
in
|
||||||
let input = read [] in
|
let input = read [] in
|
||||||
let output =
|
let output =
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class options args =
|
||||||
raise
|
raise
|
||||||
(Commandline_error "Path expected after '-I' specifier")
|
(Commandline_error "Path expected after '-I' specifier")
|
||||||
| Some path -> self#add_include_path path)
|
| Some path -> self#add_include_path path)
|
||||||
| "-march=amd64" -> march := `AMD64
|
| "-march=x86_64" | "-march=amd64" -> march := `AMD64
|
||||||
| "-march=x86" -> march := `X86_32
|
| "-march=x86" -> march := `X86_32
|
||||||
| "-s" -> self#set_mode `SM
|
| "-s" -> self#set_mode `SM
|
||||||
| "-b" -> self#set_mode `BC
|
| "-b" -> self#set_mode `BC
|
||||||
|
|
|
||||||
|
|
@ -841,8 +841,7 @@ let build cmd prog =
|
||||||
let objs = find_objects (fst @@ fst prog) cmd#get_include_paths in
|
let objs = find_objects (fst @@ fst prog) cmd#get_include_paths in
|
||||||
let buf = Buffer.create 255 in
|
let buf = Buffer.create 255 in
|
||||||
List.iter (fun o -> Buffer.add_string buf o; Buffer.add_string buf " ") objs;
|
List.iter (fun o -> Buffer.add_string buf o; Buffer.add_string buf " ") objs;
|
||||||
let gcc_cmdline = Printf.sprintf "gcc %s -m32 %s %s.s %s %s/runtime32.a" cmd#get_debug cmd#get_output_option cmd#basename (Buffer.contents buf) inc in
|
let gcc_cmdline = Printf.sprintf "gcc %s -m32 %s %s.s %s %s/runtime.a" cmd#get_debug cmd#get_output_option cmd#basename (Buffer.contents buf) inc in
|
||||||
Printf.printf " > %s\n%!" gcc_cmdline;
|
|
||||||
Sys.command gcc_cmdline
|
Sys.command gcc_cmdline
|
||||||
| `Compile ->
|
| `Compile ->
|
||||||
Sys.command (Printf.sprintf "gcc %s -m32 -c %s.s" cmd#get_debug cmd#basename)
|
Sys.command (Printf.sprintf "gcc %s -m32 -c %s.s" cmd#get_debug cmd#basename)
|
||||||
|
|
|
||||||
|
|
@ -1464,7 +1464,13 @@ let build cmd prog =
|
||||||
cmd#dump_file "s" (genasm cmd prog);
|
cmd#dump_file "s" (genasm cmd prog);
|
||||||
cmd#dump_file "i" (Interface.gen prog);
|
cmd#dump_file "i" (Interface.gen prog);
|
||||||
let compiler =
|
let compiler =
|
||||||
match cmd#target_os with Darwin -> "clang" | Linux -> "gcc"
|
match (cmd#target_os, cmd#march) with
|
||||||
|
| Darwin, `AMD64 -> "clang"
|
||||||
|
| Darwin, `X86_32 ->
|
||||||
|
Printf.eprintf "X86_32 on darwin is not supported\n";
|
||||||
|
exit 1
|
||||||
|
| Linux, `AMD64 -> "gcc"
|
||||||
|
| Linux, `X86_32 -> "gcc -m32"
|
||||||
in
|
in
|
||||||
let compiler_flags, linker_flags =
|
let compiler_flags, linker_flags =
|
||||||
match cmd#target_os with
|
match cmd#target_os with
|
||||||
|
|
@ -1489,7 +1495,9 @@ let build cmd prog =
|
||||||
in
|
in
|
||||||
Sys.command gcc_cmdline
|
Sys.command gcc_cmdline
|
||||||
| `Compile ->
|
| `Compile ->
|
||||||
Sys.command
|
let cmd =
|
||||||
(Printf.sprintf "%s %s %s -c -g %s.s" compiler compiler_flags
|
Printf.sprintf "%s %s %s -c -g %s.s" compiler compiler_flags debug_flags
|
||||||
debug_flags cmd#basename)
|
cmd#basename
|
||||||
|
in
|
||||||
|
Sys.command cmd
|
||||||
| _ -> invalid_arg "must not happen"
|
| _ -> invalid_arg "must not happen"
|
||||||
|
|
|
||||||
4
stdlib/.gitignore
vendored
4
stdlib/.gitignore
vendored
|
|
@ -3,3 +3,7 @@
|
||||||
/*.log
|
/*.log
|
||||||
*.i
|
*.i
|
||||||
*.s
|
*.s
|
||||||
|
*.exe
|
||||||
|
*.x32.exe
|
||||||
|
*.x64.exe
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
SRCDIR ?= .
|
SRCDIR ?= .
|
||||||
|
$(info SRCDIR = $(SRCDIR))
|
||||||
FILES ?= $(wildcard $(SRCDIR)/*.lama)
|
FILES ?= $(wildcard $(SRCDIR)/*.lama)
|
||||||
|
$(info FILES = $(FILES))
|
||||||
OFILES = $(FILES:$(SRCDIR)/%=%)
|
OFILES = $(FILES:$(SRCDIR)/%=%)
|
||||||
OFILES := $(OFILES:.lama=.o)
|
OFILES := $(OFILES:.lama=.o)
|
||||||
$(info OFILES = $(OFILES))
|
$(info OFILES = $(OFILES))
|
||||||
|
|
@ -11,7 +13,7 @@ LAMAC ?= ../src/lamac
|
||||||
BDIR ?= .
|
BDIR ?= .
|
||||||
|
|
||||||
all: $(addprefix $(BDIR)/,$(ALL))
|
all: $(addprefix $(BDIR)/,$(ALL))
|
||||||
$(info ALL = $(ALL))
|
$(info ALL = $(ALL), SRCDIR = $(SRCDIR))
|
||||||
$(BDIR)/Fun.o: $(BDIR)/Ref.o
|
$(BDIR)/Fun.o: $(BDIR)/Ref.o
|
||||||
|
|
||||||
$(BDIR)/Data.o: $(BDIR)/Ref.o $(BDIR)/Collection.o
|
$(BDIR)/Data.o: $(BDIR)/Ref.o $(BDIR)/Collection.o
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,19 @@
|
||||||
../Makefile
|
../Makefile
|
||||||
../../runtime/Std.i
|
../../runtime/Std.i
|
||||||
../List.lama
|
../List.lama
|
||||||
|
../Array.lama
|
||||||
|
../Buffer.lama
|
||||||
|
../Collection.lama
|
||||||
|
../Data.lama
|
||||||
|
../Fun.lama
|
||||||
|
../Lazy.lama
|
||||||
|
../List.lama
|
||||||
|
../Matcher.lama
|
||||||
|
../Ostap.lama
|
||||||
|
../Random.lama
|
||||||
|
../Ref.lama
|
||||||
|
../STM.lama
|
||||||
|
../Timer.lama
|
||||||
%{project_root}/src/Driver.exe)
|
%{project_root}/src/Driver.exe)
|
||||||
(targets
|
(targets
|
||||||
List.i
|
List.i
|
||||||
|
|
@ -48,5 +61,3 @@
|
||||||
LAMAC
|
LAMAC
|
||||||
"../../src/Driver.exe -march=x86 -I ../runtime32"
|
"../../src/Driver.exe -march=x86 -I ../runtime32"
|
||||||
(run make -j2 -f ../Makefile all)))))))
|
(run make -j2 -f ../Makefile all)))))))
|
||||||
|
|
||||||
;)
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,19 @@
|
||||||
../Makefile
|
../Makefile
|
||||||
../../runtime/Std.i
|
../../runtime/Std.i
|
||||||
../List.lama
|
../List.lama
|
||||||
|
../Array.lama
|
||||||
|
../Buffer.lama
|
||||||
|
../Collection.lama
|
||||||
|
../Data.lama
|
||||||
|
../Fun.lama
|
||||||
|
../Lazy.lama
|
||||||
|
../List.lama
|
||||||
|
../Matcher.lama
|
||||||
|
../Ostap.lama
|
||||||
|
../Random.lama
|
||||||
|
../Ref.lama
|
||||||
|
../STM.lama
|
||||||
|
../Timer.lama
|
||||||
%{project_root}/src/Driver.exe)
|
%{project_root}/src/Driver.exe)
|
||||||
(targets
|
(targets
|
||||||
List.i
|
List.i
|
||||||
Loading…
Add table
Add a link
Reference in a new issue