mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-20 21:58:44 +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
|
|
@ -22,8 +22,8 @@ let[@ocaml.warning "-32"] main =
|
|||
try
|
||||
let r = read_int () in
|
||||
Printf.printf "> ";
|
||||
read (acc @ [ r ])
|
||||
with End_of_file -> acc
|
||||
read (r :: acc)
|
||||
with End_of_file -> List.rev acc
|
||||
in
|
||||
let input = read [] in
|
||||
let output =
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class options args =
|
|||
raise
|
||||
(Commandline_error "Path expected after '-I' specifier")
|
||||
| Some path -> self#add_include_path path)
|
||||
| "-march=amd64" -> march := `AMD64
|
||||
| "-march=x86_64" | "-march=amd64" -> march := `AMD64
|
||||
| "-march=x86" -> march := `X86_32
|
||||
| "-s" -> self#set_mode `SM
|
||||
| "-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 buf = Buffer.create 255 in
|
||||
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
|
||||
Printf.printf " > %s\n%!" gcc_cmdline;
|
||||
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
|
||||
Sys.command gcc_cmdline
|
||||
| `Compile ->
|
||||
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 "i" (Interface.gen prog);
|
||||
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
|
||||
let compiler_flags, linker_flags =
|
||||
match cmd#target_os with
|
||||
|
|
@ -1489,7 +1495,9 @@ let build cmd prog =
|
|||
in
|
||||
Sys.command gcc_cmdline
|
||||
| `Compile ->
|
||||
Sys.command
|
||||
(Printf.sprintf "%s %s %s -c -g %s.s" compiler compiler_flags
|
||||
debug_flags cmd#basename)
|
||||
let cmd =
|
||||
Printf.sprintf "%s %s %s -c -g %s.s" compiler compiler_flags debug_flags
|
||||
cmd#basename
|
||||
in
|
||||
Sys.command cmd
|
||||
| _ -> invalid_arg "must not happen"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue