Skip to content

Commit

Permalink
Delete machine groups from 0install entirely
Browse files Browse the repository at this point in the history
Signed-off-by: Ambre Austen Suhamy <ambre@tarides.com>
  • Loading branch information
ElectreAAS committed Oct 23, 2024
1 parent 8d734b2 commit b14c0f4
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 104 deletions.
35 changes: 0 additions & 35 deletions src/0install-solver/src/solver/diagnostics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ struct
[ `Model_rejection of Model.rejection
| `FailsRestriction of Model.restriction
| `DepFailsRestriction of Model.dependency * Model.restriction
| `MachineGroupConflict of Model.Role.t * Model.impl
| `ClassConflict of Model.Role.t * Model.conflict_class
| `ConflictsRole of Model.Role.t
| `DiagnosticsFailure of string
Expand Down Expand Up @@ -211,14 +210,6 @@ struct
format_role
dep_info.Model.dep_role
(format_restrictions [ restriction ])
| `MachineGroupConflict (other_role, other_impl) ->
pf
f
"Can't use %s with selection of %a (%s)"
(Model.format_machine impl)
format_role
other_role
(Model.format_machine other_impl)
| `ClassConflict (other_role, cl) ->
pf f "In same conflict class (%s) as %a" (cl :> string) format_role other_role
| `ConflictsRole other_role -> pf f "Conflicts with %a" format_role other_role
Expand Down Expand Up @@ -373,31 +364,6 @@ struct
Component.apply_user_restriction component restriction))
;;

(** Find an implementation which requires a machine group. Use this to
explain the rejection of all implementations requiring other groups. *)
exception Found of (Model.Role.t * Model.impl * Model.machine_group)

let check_machine_groups report =
let check role compoment =
match Component.selected_impl compoment with
| None -> ()
| Some impl ->
(match Model.machine_group impl with
| None -> ()
| Some group -> raise (Found (role, impl, group)))
in
try RoleMap.iter check report with
| Found (example_role, example_impl, example_group) ->
let filter _key component =
Component.filter_impls component (fun impl ->
match Model.machine_group impl with
| Some group when group <> example_group ->
Some (`MachineGroupConflict (example_role, example_impl))
| _ -> None)
in
RoleMap.iter filter report
;;

module Classes = Map.Make (struct
type t = Model.conflict_class

Expand Down Expand Up @@ -452,7 +418,6 @@ struct
>>| RoleMap.of_seq
in
examine_extra_restrictions report;
check_machine_groups report;
check_conflict_classes report;
RoleMap.iter (examine_selection report) report;
RoleMap.iter (fun _ c -> Component.finalise c) report;
Expand Down
8 changes: 0 additions & 8 deletions src/0install-solver/src/solver/s.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ module type SOLVER_INPUT = sig
(** A restriction limits which implementations can fill a role. *)
type restriction

(** The solver will avoid selections with mixed machine groups.
This is useful if e.g. the CPU supports 32-bit and 64-bit programs,
but we can't mix them in a single process. The string simply has
to be unique for each group (e.g. "32" and "64"). *)
type machine_group = private string

val pp_impl : Format.formatter -> impl -> unit

(** The list of candidates to fill a role. *)
Expand All @@ -104,7 +98,6 @@ module type SOLVER_INPUT = sig
val restrictions : dependency -> restriction list

val meets_restriction : impl -> restriction -> bool
val machine_group : impl -> machine_group option

(** There can be only one implementation in each conflict class. *)
type conflict_class = private string
Expand Down Expand Up @@ -134,7 +127,6 @@ module type SOLVER_INPUT = sig
number and part of the hash. *)
val pp_impl_long : Format.formatter -> impl -> unit

val format_machine : impl -> string
val string_of_restriction : restriction -> string
val describe_problem : impl -> rejection -> string

Expand Down
51 changes: 0 additions & 51 deletions src/0install-solver/src/solver/solver_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ struct
type t =
(* If the SAT variable is True then we selected this... *)
| ImplElem of Model.impl
| MachineGroup of string
| Role of Model.Role.t

let pp f = function
| ImplElem impl -> Model.pp_impl f impl
| MachineGroup name -> Format.pp_print_string f name
| Role role -> Model.Role.pp f role
;;
end
Expand Down Expand Up @@ -225,52 +223,6 @@ struct
S.at_most_one sat (our_vars @ replacements) |> ignore))
;;

(** On multi-arch systems, we can select 32-bit or 64-bit implementations,
but not both in the same set of selections. *)
module Machine_group = struct
module Map = Map.Make (struct
type t = Model.machine_group

let compare = compare
end)

type t =
{ sat : S.t
; mutable groups : S.lit Map.t
}

let create sat = { sat; groups = Map.empty }

let var t name =
match Map.find_opt name t.groups with
| Some v -> v
| None ->
let v =
S.add_variable t.sat @@ SolverData.MachineGroup ("m." ^ (name :> string))
in
t.groups <- Map.add name v t.groups;
v
;;

(* If [impl] requires a particular machine group, add a constraint to the problem. *)
let process t impl_var impl =
Model.machine_group impl
|> Option.iter (fun group ->
S.implies t.sat ~reason:"machine group" impl_var [ var t group ])
;;

(* Call this at the end to add the final clause with all discovered groups.
[t] must not be used after this. *)
let seal t =
let xs = Map.bindings t.groups in
if List.length xs > 1
then
(* If we get to the end of the solve without deciding then nothing we selected cares about the
type of CPU. The solver will set them all to false at the end. *)
S.at_most_one t.sat (List.map snd xs) |> ignore
;;
end

module Conflict_classes = struct
module Map = Map.Make (struct
type t = Model.conflict_class
Expand Down Expand Up @@ -375,7 +327,6 @@ struct
let build_problem root_req sat ~dummy_impl =
(* For each (iface, source) we have a list of implementations. *)
let impl_cache = ImplCache.create () in
let machine_groups = Machine_group.create sat in
let conflict_classes = Conflict_classes.create sat in
(* Handle <replaced-by> conflicts after building the problem. *)
let replacements = ref [] in
Expand All @@ -385,7 +336,6 @@ struct
, fun () ->
impls
|> Monad.List.iter (fun (impl_var, impl) ->
Machine_group.process machine_groups impl_var impl;
Conflict_classes.process conflict_classes impl_var impl;
let deps = Model.requires role impl in
process_deps impl_var deps) )
Expand All @@ -403,7 +353,6 @@ struct
(* All impl_candidates have now been added, so snapshot the cache. *)
let impl_clauses = ImplCache.snapshot impl_cache in
add_replaced_by_conflicts sat impl_clauses !replacements;
Machine_group.seal machine_groups;
Conflict_classes.seal conflict_classes;
impl_clauses
;;
Expand Down
2 changes: 0 additions & 2 deletions src/0install-solver/src/solver/zeroinstall_solver.mli
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ module Diagnostics
(** e.g. version too old for another component. *)
| `DepFailsRestriction of Result.Input.dependency * Result.Input.restriction
(** Couldn't satisfy its dependencies. *)
| `MachineGroupConflict of Result.Role.t * Result.Input.impl
(** A selected impl has a different machine type. *)
| `ClassConflict of Result.Role.t * Result.Input.conflict_class
(** A selected impl has the same conflict class. *)
| `ConflictsRole of Result.Role.t
Expand Down
8 changes: 0 additions & 8 deletions src/opam-0install/lib/model.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,6 @@ struct
; impls : impl list
}

type machine_group =
private
string (* We don't use machine groups because opam is source-only. *)

let machine_group _impl = None

type conflict_class = string

let conflict_class = function
Expand Down Expand Up @@ -268,8 +262,6 @@ struct
| Some f -> Some { kind = `Ensure; expr = OpamFormula.Atom f })
;;

let format_machine _impl = "(src)"

let string_of_op = function
| `Eq -> "="
| `Geq -> ">="
Expand Down

0 comments on commit b14c0f4

Please sign in to comment.