Skip to content

Commit

Permalink
remove useless c_processing module, better organisation of src/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
zapashcanon committed Jun 15, 2024
1 parent 373e424 commit 76870f1
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 43 deletions.
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@
xmlm
(hc (>= 0.3))
dune-site)
(sites (share pyc) (share binc) (share libc)))
(sites (share binc) (share libc)))
File renamed without changes.
File renamed without changes.
27 changes: 0 additions & 27 deletions src/c_processing/c_share.ml

This file was deleted.

11 changes: 0 additions & 11 deletions src/c_processing/c_share.mli

This file was deleted.

29 changes: 27 additions & 2 deletions src/cmd/cmd_c.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ type metadata =
; files : Fpath.t list
}

let binc_location = List.map Fpath.v C_share_site.Sites.binc

let libc_location = List.map Fpath.v C_share_site.Sites.libc

let find location file : Fpath.t Result.t =
let* l =
list_map
(fun dir ->
let filename = Fpath.append dir file in
match Bos.OS.File.exists filename with
| Ok true -> Ok (Some filename)
| Ok false -> Ok None
| Error (`Msg msg) -> Error (`Msg msg) )
location
in
let rec loop = function
| [] -> Error (`Msg (Format.asprintf "can't find file %a" Fpath.pp file))
| None :: tl -> loop tl
| Some file :: _tl -> Ok file
in
loop l

let compile ~includes ~opt_lvl (files : Fpath.t list) : Fpath.t Result.t =
let flags =
let stack_size = 8 * 1024 * 1024 |> string_of_int in
Expand All @@ -37,7 +59,10 @@ let compile ~includes ~opt_lvl (files : Fpath.t list) : Fpath.t Result.t =
let* clang_bin = OS.Cmd.resolve @@ Cmd.v "clang" in

let out = Fpath.(v "a.out.wasm") in
let files = Cmd.of_list (List.map Fpath.to_string (C_share.libc :: files)) in

let* libc = find binc_location (Fpath.v "libc.wasm") in

let files = Cmd.of_list (List.map Fpath.to_string (libc :: files)) in
let clang : Bos.Cmd.t = Cmd.(clang_bin %% flags % "-o" % p out %% files) in

let+ () = OS.Cmd.run clang in
Expand Down Expand Up @@ -98,7 +123,7 @@ let cmd debug arch property _testcomp workspace workers opt_lvl includes files
deterministic_result_order concolic solver : unit Result.t =
if debug then Logs.set_level (Some Debug);
let workspace = Fpath.v workspace in
let includes = C_share.lib_location @ includes in
let includes = libc_location @ includes in
let* (_exists : bool) = OS.Dir.create ~path:true workspace in
let* modul = compile ~includes ~opt_lvl files in
let* () = metadata ~workspace arch property files in
Expand Down
1 change: 0 additions & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
binary_parser
binary_to_text
binary_types
c_share
c_share_site
check
choice_intf
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/script/gc.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[23]
$ owi script --no-exhaustion reference/proposals/gc/ref_eq.wast
owi: internal error, uncaught exception:
File "src/typecheck/typecheck.ml", line 478, characters 4-10: Assertion failed
File "src/validate/typecheck.ml", line 478, characters 4-10: Assertion failed

[125]
$ owi script --no-exhaustion reference/proposals/gc/ref_test.wast
Expand Down

0 comments on commit 76870f1

Please sign in to comment.