Skip to content

Commit

Permalink
Hotfix to work with modern ocaml/base
Browse files Browse the repository at this point in the history
Base changes have heavily broken things, it seems.  Caml needed to be
renamed to Stdlib, and any reference to Fir.Test needed a bodge to stop
it from being captured by Stdlib.Test.
  • Loading branch information
Matt Windsor committed Oct 29, 2023
1 parent 8939477 commit 65b0cc0
Show file tree
Hide file tree
Showing 55 changed files with 449 additions and 347 deletions.
34 changes: 18 additions & 16 deletions c4f.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,34 @@ opam-version: "2.0"
synopsis: "Metamorphic fuzzer for C litmus tests"
description:
"'c4f' (the 'C Compiler Concurrency Checker' fuzzer) is a toolkit for randomly expanding C litmus tests in a semantics-refining way."
maintainer: ["Matt Windsor <m.windsor@imperial.ac.uk>"]
authors: ["Matt Windsor <m.windsor@imperial.ac.uk>"]
maintainer: ["Matt Windsor <mattwindsor91@gmail.com>"]
authors: ["Matt Windsor <mattwindsor91@gmail.com>"]
license: "MIT"
homepage: "https://github.com/c4-project/c4f"
doc: "https://automagic-compiler-tormentor.readthedocs.io"
bug-reports: "https://github.com/c4-project/c4f/issues"
depends: [
"dune" {>= "3.2"}
"ocaml" {>= "4.14" & < "4.15"}
"accessor" {>= "v0.15" & < "v0.16"}
"accessor_base" {>= "v0.15" & < "v0.16"}
"ppx_accessor" {>= "v0.15" & < "v0.16"}
"expect_test_helpers_core" {>= "v0.15" & < "v0.16"}
"dune" {>= "3.6"}
"ocaml" {>= "5.1" & < "5.2"}
"accessor" {>= "v0.16" & < "v0.17"}
"accessor_base" {>= "v0.16" & < "v0.17"}
"ppx_accessor" {>= "v0.16" & < "v0.17"}
"expect_test_helpers_core" {>= "v0.16" & < "v0.17"}
"ppx_deriving"
"ppx_jane"
"ppx_yojson_conv" {>= "v0.15" & < "v0.16"}
"core" {>= "v0.15" & < "v0.16"}
"core_unix" {>= "v0.15" & < "v0.16"}
"ppx_yojson_conv" {>= "v0.16" & < "v0.17"}
"ppx_yojson_conv_lib" {>= "v0.16" & < "v0.17"}
"base" {>= "v0.16" & < "v0.17"}
"core" {>= "v0.16" & < "v0.17"}
"core_unix" {>= "v0.16" & < "v0.17"}
"fmt" {>= "0.9" & < "0.10"}
"fpath" {>= "0.7.3" & < "0.8"}
"menhir" {>= "20220210"}
"menhir" {>= "20230608"}
"sedlex" {>= "3" & < "4"}
"shell" {>= "v0.15" & < "v0.16"}
"textutils_kernel" {>= "v0.15" & < "v0.16"}
"travesty" {>= "0.7.2" & < "0.8"}
"yojson" {>= "1.7" & < "2"}
"shell" {>= "v0.16" & < "v0.17"}
"textutils_kernel" {>= "v0.16" & < "v0.17"}
"travesty" {>= "0.7.2" & < "0.9"}
"yojson" {>= "2.1" & < "3"}
"odoc" {with-doc}
]
build: [
Expand Down
34 changes: 18 additions & 16 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 3.2)
(lang dune 3.6)
(name c4f)

(implicit_transitive_deps false)
Expand All @@ -7,8 +7,8 @@
(using menhir 2.0)

(license MIT)
(maintainers "Matt Windsor <m.windsor@imperial.ac.uk>")
(authors "Matt Windsor <m.windsor@imperial.ac.uk>")
(maintainers "Matt Windsor <mattwindsor91@gmail.com>")
(authors "Matt Windsor <mattwindsor91@gmail.com>")
(source (github c4-project/c4f))
(documentation "https://automagic-compiler-tormentor.readthedocs.io")

Expand All @@ -17,24 +17,26 @@
(synopsis "Metamorphic fuzzer for C litmus tests")
(description "'c4f' (the 'C Compiler Concurrency Checker' fuzzer) is a toolkit for randomly expanding C litmus tests in a semantics-refining way.")
(depends
(ocaml (and (>= 4.14) (< 4.15)))
(accessor (and (>= v0.15) (< v0.16)))
(accessor_base (and (>= v0.15) (< v0.16)))
(ppx_accessor (and (>= v0.15) (< v0.16)))
(expect_test_helpers_core (and (>= v0.15) (< v0.16)))
(ocaml (and (>= 5.1) (< 5.2)))
(accessor (and (>= v0.16) (< v0.17)))
(accessor_base (and (>= v0.16) (< v0.17)))
(ppx_accessor (and (>= v0.16) (< v0.17)))
(expect_test_helpers_core (and (>= v0.16) (< v0.17)))
ppx_deriving
ppx_jane
(ppx_yojson_conv (and (>= v0.15) (< v0.16)))
(core (and (>= v0.15) (< v0.16)))
(core_unix (and (>= v0.15) (< v0.16)))
(ppx_yojson_conv (and (>= v0.16) (< v0.17)))
(ppx_yojson_conv_lib (and (>= v0.16) (< v0.17)))
(base (and (>= v0.16) (< v0.17)))
(core (and (>= v0.16) (< v0.17)))
(core_unix (and (>= v0.16) (< v0.17)))
(fmt (and (>= 0.9) (< 0.10)))
(fpath (and (>= 0.7.3) (< 0.8)))
(menhir (>= 20220210))
(menhir (>= 20230608))
(sedlex (and (>= 3) (< 4)))
(shell (and (>= v0.15) (< v0.16)))
(textutils_kernel (and (>= v0.15) (< v0.16)))
(travesty (and (>= 0.7.2) (< 0.8)))
(yojson (and (>= 1.7) (< 2)))
(shell (and (>= v0.16) (< v0.17)))
(textutils_kernel (and (>= v0.16) (< v0.17)))
(travesty (and (>= 0.7.2) (< 0.9)))
(yojson (and (>= 2.1) (< 3)))
))

; Local Variables:
Expand Down
2 changes: 1 addition & 1 deletion lib/common/src/c_id.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module M = Validated.Make_bin_io_compare_hash_sexp (struct

let is_badword (s : string) : bool =
(* Not pointfree because of the need to force a lazy value. *)
Set.mem (Lazy.force badwords) s
Base.Set.mem (Lazy.force badwords) s

let validate_badwords : string Validate.check =
Validate.booltest (Fn.non is_badword)
Expand Down
2 changes: 1 addition & 1 deletion lib/common/src/litmus_id.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module M_str = struct
let try_parse_local (s : string) : (int * string) option =
let open Option.Let_syntax in
let%bind thread, rest = String.lsplit2 ~on:':' s in
let%bind tnum = Caml.int_of_string_opt thread in
let%bind tnum = Stdlib.int_of_string_opt thread in
let%map tnum = Option.some_if (Int.is_non_negative tnum) tnum in
(tnum, rest)

Expand Down
2 changes: 1 addition & 1 deletion lib/delitmus/src/aux_maker.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open Import

(** Given the basic shape of a delitmus runner, this functor constructs a
one-function module that produces auxiliary records. *)
module Make (B : Runner_types.Basic) : sig
module Make (_ : Runner_types.Basic) : sig
val make_aux : Fir.Litmus.Test.t -> Aux.t Or_error.t
(** [make_aux test] tries to extract an auxiliary record for [test]. This
record details the various function and variable mappings that should
Expand Down
1 change: 1 addition & 0 deletions lib/delitmus/src/function_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
project root for more information. *)

open Base
open Ppx_yojson_conv_lib.Yojson_conv.Primitives
open Import

module Record = struct
Expand Down
2 changes: 1 addition & 1 deletion lib/delitmus/src/runner.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
(** Makes a delitmus driver given a function rewriter, information about how
global and local variables are mapped, and various other configuration
tidbits. *)
module Make (Basic : Runner_types.Basic) : Runner_types.S
module Make (_ : Runner_types.Basic) : Runner_types.S
2 changes: 1 addition & 1 deletion lib/delitmus/src/stub.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let try_parse_program_id (id : Common.C_id.t) : int Or_error.t =
let strid = Common.C_id.to_string id in
Or_error.(
tag ~tag:"Thread function does not have a well-formed name"
(try_with (fun () -> Caml.Scanf.sscanf strid "P%d" Fn.id)))
(try_with (fun () -> Stdlib.Scanf.sscanf strid "P%d" Fn.id)))

let to_param_opt (lit_id : Common.Litmus_id.t) (rc : Var_map.Record.t) :
(int * (Common.Litmus_id.t * Fir.Type.t)) option =
Expand Down
1 change: 1 addition & 0 deletions lib/delitmus/src/var_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
project root for more information. *)

open Base
open Ppx_yojson_conv_lib.Yojson_conv.Primitives
open Import

module Mapping = struct
Expand Down
15 changes: 9 additions & 6 deletions lib/fir/src/address.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(https://github.com/herd/herdtools7) : see the LICENSE.herd file in the
project root for more information. *)

(* Needed because Base shadows it: *)
module Ty = Type

open Base
open Import

Expand Down Expand Up @@ -84,8 +87,8 @@ let as_variable (addr : t) : Common.C_id.t Or_error.t =
module Type_check (E : Env_types.S) = struct
module L = Lvalue.Type_check (E)

let type_of : t -> Type.t Or_error.t =
reduce ~lvalue:L.type_of ~ref:(Or_error.bind ~f:Type.ref)
let type_of : t -> Ty.t Or_error.t =
reduce ~lvalue:L.type_of ~ref:(Or_error.bind ~f:Ty.ref)
end

let anonymise = function Lvalue v -> `A v | Ref d -> `B d
Expand Down Expand Up @@ -125,11 +128,11 @@ module Quickcheck_main = Quickcheck_generic (Lvalue)

include (Quickcheck_main : module type of Quickcheck_main with type t := t)

let on_address_of_typed_id (tid : Type.t Common.C_named.t) : t =
let on_address_of_typed_id (tid : Ty.t Common.C_named.t) : t =
let id = tid.@(Common.C_named.name) in
let ty = tid.@(Common.C_named.value) in
let lv = Accessor.construct variable id in
if Type.is_pointer ty then lv else Ref lv
if Ty.is_pointer ty then lv else Ref lv

let of_id_in_env (env : Env.t) ~(id : Common.C_id.t) : t Or_error.t =
Or_error.Let_syntax.(
Expand All @@ -150,9 +153,9 @@ let check_address_var (addr : t) ~(env : Env.t) :
let id = addr.@(variable_of) in
let%bind v_type = Env.type_of_known_value env ~id in
let%bind a_type = A_check.type_of addr in
let%map (_ : Type.t) =
let%map (_ : Ty.t) =
Or_error.tag_arg
(Type.check v_type a_type)
(Ty.check v_type a_type)
"Checking address var type" addr sexp_of_t
in
id)
Expand Down
7 changes: 5 additions & 2 deletions lib/fir/src/address.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

(** FIR: addresses (a lvalue, or reference thereto). *)

(* Needed because Base shadows it: *)
module Ty = Type

open Base
open Import

Expand Down Expand Up @@ -45,7 +48,7 @@ val deref : t -> t
normalised form of [addr] is an lvalue, it returns the result of directly
dereferencing from that lvalue instead. *)

val on_address_of_typed_id : Type.t Common.C_named.t -> t
val on_address_of_typed_id : Ty.t Common.C_named.t -> t

val of_id_in_env : Env.t -> id:Common.C_id.t -> t Or_error.t

Expand Down Expand Up @@ -107,7 +110,7 @@ include Types.S_type_checkable with type t := t

(** Generates random addresses, parametrised on a given lvalue generator. *)
module Quickcheck_generic
(Lv : C4f_utils.My_quickcheck.S_with_sexp with type t := Lvalue.t) :
(_ : C4f_utils.My_quickcheck.S_with_sexp with type t := Lvalue.t) :
C4f_utils.My_quickcheck.S_with_sexp with type t = t

val eval_on_env : t -> env:Env.t -> Constant.t Or_error.t
Expand Down
8 changes: 4 additions & 4 deletions lib/fir/src/assign.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ module Source : sig

(** Lifts an integer expression generator to a source generator. *)
module Quickcheck_int
(Expr : Utils.My_quickcheck.S_with_sexp with type t := Expression.t) :
(_ : Utils.My_quickcheck.S_with_sexp with type t := Expression.t) :
Utils.My_quickcheck.S_with_sexp with type t = t

(** Lifts a Boolean expression generator to a source generator. *)
module Quickcheck_bool
(Expr : Utils.My_quickcheck.S_with_sexp with type t := Expression.t) :
(_ : Utils.My_quickcheck.S_with_sexp with type t := Expression.t) :
Utils.My_quickcheck.S_with_sexp with type t = t
end

Expand Down Expand Up @@ -84,6 +84,6 @@ val quickcheck_observer : t Q.Observer.t

(** Low-level building block for quickcheck generators on assigns. *)
module Quickcheck_generic
(Src : Utils.My_quickcheck.S_with_sexp with type t := Source.t)
(Dst : Utils.My_quickcheck.S_with_sexp with type t := Lvalue.t) :
(_ : Utils.My_quickcheck.S_with_sexp with type t := Source.t)
(_ : Utils.My_quickcheck.S_with_sexp with type t := Lvalue.t) :
Utils.My_quickcheck.S_with_sexp with type t = t
21 changes: 12 additions & 9 deletions lib/fir/src/atomic_cmpxchg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(https://github.com/herd/herdtools7) : see the LICENSE.herd file in the
project root for more information. *)

(* Needed because Base shadows it: *)
module Ty = Type

open Base
open Import

Expand Down Expand Up @@ -76,23 +79,23 @@ Travesty.Traversable.Make1 (struct
end)

module Type_check (Env : Env_types.S) = struct
type nonrec t = Type.t t
type nonrec t = Ty.t t

module Ad = Address.Type_check (Env)

let check_expected_desired ~(expected : Type.t) ~(desired : Type.t) :
Type.t Or_error.t =
let check_expected_desired ~(expected : Ty.t) ~(desired : Ty.t) :
Ty.t Or_error.t =
Or_error.tag
(Type.check_pointer_non ~pointer:expected ~non:desired)
(Ty.check_pointer_non ~pointer:expected ~non:desired)
~tag:"'expected' type must be same as pointer to 'desired' type"

let check_expected_obj ~(expected : Type.t) ~(obj : Type.t) :
Type.t Or_error.t =
let check_expected_obj ~(expected : Ty.t) ~(obj : Ty.t) :
Ty.t Or_error.t =
Or_error.tag
(Type.check_atomic_non ~atomic:expected ~non:obj)
(Ty.check_atomic_non ~atomic:expected ~non:obj)
~tag:"'obj' type must be atomic version of 'expected' type"

let type_of (c : t) : Type.t Or_error.t =
let type_of (c : t) : Ty.t Or_error.t =
Or_error.Let_syntax.(
(* A* *)
let%bind obj = Ad.type_of c.obj in
Expand All @@ -104,5 +107,5 @@ module Type_check (Env : Env_types.S) = struct
let%map _ = check_expected_obj ~expected ~obj in
(* Compare-exchanges return a boolean: whether or not they were
successful. *)
Type.bool ())
Ty.bool ())
end
7 changes: 5 additions & 2 deletions lib/fir/src/atomic_expression.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(https://github.com/herd/herdtools7) : see the LICENSE.herd file in the
project root for more information. *)

(* Needed because Base shadows it: *)
module Ty = Type

open Base

module P = struct
Expand Down Expand Up @@ -55,11 +58,11 @@ Travesty.Traversable.Make1 (struct
end)

module Type_check (E : Env_types.S) :
Types.S_type_checker with type t := Type.t t = struct
Types.S_type_checker with type t := Ty.t t = struct
module Ac = Atomic_cmpxchg.Type_check (E)
module Af = Atomic_fetch.Type_check (E)
module Al = Atomic_load.Type_check (E)

let type_of : Type.t t -> Type.t Or_error.t =
let type_of : Ty.t t -> Ty.t Or_error.t =
reduce ~cmpxchg:Ac.type_of ~fetch:Af.type_of ~load:Al.type_of
end
5 changes: 4 additions & 1 deletion lib/fir/src/atomic_expression.mli
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(https://github.com/herd/herdtools7) : see the LICENSE.herd file in the
project root for more information. *)

(* Needed because Base shadows it: *)
module Ty = Type

open Base

(** Opaque type of atomic expressions. *)
Expand Down Expand Up @@ -57,4 +60,4 @@ module On_expressions : Travesty.Traversable_types.S1 with type 'e t = 'e t

(** We can type check atomic expressions, so long as we already type-checked
any recursive expressions inside them. *)
include Types.S_type_checkable with type t := Type.t t
include Types.S_type_checkable with type t := Ty.t t
17 changes: 10 additions & 7 deletions lib/fir/src/atomic_fetch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(https://github.com/herd/herdtools7) : see the LICENSE.herd file in the
project root for more information. *)

(* Needed because Base shadows it: *)
module Ty = Type

open Base
open Import

Expand Down Expand Up @@ -75,22 +78,22 @@ module Type_check (Env : sig
val env : Env.t
end) =
struct
type nonrec t = Type.t t
type nonrec t = Ty.t t

module Ad = Address.Type_check (Env)

let check_arg_obj ~(arg : Type.t) ~(obj : Type.t) : Type.t Or_error.t =
let check_arg_obj ~(arg : Ty.t) ~(obj : Ty.t) : Ty.t Or_error.t =
Or_error.(
tag_s
(bind (Type.ref arg) ~f:(fun argp ->
Type.check_atomic_non ~atomic:obj ~non:argp ) )
(bind (Ty.ref arg) ~f:(fun argp ->
Ty.check_atomic_non ~atomic:obj ~non:argp ) )
~tag:
[%message
"'obj' type must be atomic version of 'expected' type"
~(arg : Type.t)
~(obj : Type.t)])
~(arg : Ty.t)
~(obj : Ty.t)])

let type_of (c : t) : Type.t Or_error.t =
let type_of (c : t) : Ty.t Or_error.t =
Or_error.Let_syntax.(
(* A* *)
let%bind obj = Ad.type_of c.obj in
Expand Down
Loading

0 comments on commit 65b0cc0

Please sign in to comment.