Skip to content

Commit

Permalink
Remove -allow-illegal-crossing (#3516)
Browse files Browse the repository at this point in the history
Now that we have [@@unsafe_allow_any_mode_crossing], which is a more precise way
of unsafely mode crossing types, we can remove the -allow-illegal-crossing flag,
which was always intended to be temporary, and all its usages.

---------

Co-authored-by: Richard Eisenberg <[email protected]>
  • Loading branch information
glittershark and goldfirere authored Jan 28, 2025
1 parent 321fc34 commit b3ce767
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 1,079 deletions.
11 changes: 0 additions & 11 deletions driver/main_args.ml
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,6 @@ in
\ allows a set of extensions, and every successive universe includes \n\
\ the previous one."

let mk_allow_illegal_crossing f =
"-allow-illegal-crossing", Arg.Unit f,
"Type declarations will not be checked along the portability or contention axes"

let mk_dump_dir f =
"-dump-dir", Arg.String f,
"redirects any file(s) that would be outputted as a result of other flags\n\
Expand Down Expand Up @@ -960,7 +956,6 @@ module type Common_options = sig
val _extension : string -> unit
val _no_extension : string -> unit
val _extension_universe : string -> unit
val _allow_illegal_crossing : unit -> unit
val _noassert : unit -> unit
val _nolabels : unit -> unit
val _nostdlib : unit -> unit
Expand Down Expand Up @@ -1249,7 +1244,6 @@ struct
mk_extension F._extension;
mk_no_extension F._no_extension;
mk_extension_universe F._extension_universe;
mk_allow_illegal_crossing F._allow_illegal_crossing;
mk_for_pack_byt F._for_pack;
mk_g_byt F._g;
mk_no_g F._no_g;
Expand Down Expand Up @@ -1381,7 +1375,6 @@ struct
mk_extension F._extension;
mk_no_extension F._no_extension;
mk_extension_universe F._extension_universe;
mk_allow_illegal_crossing F._allow_illegal_crossing;
mk_noassert F._noassert;
mk_noinit F._noinit;
mk_nolabels F._nolabels;
Expand Down Expand Up @@ -1476,7 +1469,6 @@ struct
mk_extension F._extension;
mk_no_extension F._no_extension;
mk_extension_universe F._extension_universe;
mk_allow_illegal_crossing F._allow_illegal_crossing;
mk_for_pack_opt F._for_pack;
mk_g_opt F._g;
mk_no_g F._no_g;
Expand Down Expand Up @@ -1669,7 +1661,6 @@ module Make_opttop_options (F : Opttop_options) = struct
mk_extension F._extension;
mk_no_extension F._no_extension;
mk_extension_universe F._extension_universe;
mk_allow_illegal_crossing F._allow_illegal_crossing;
mk_no_float_const_prop F._no_float_const_prop;
mk_noassert F._noassert;
mk_noinit F._noinit;
Expand Down Expand Up @@ -1778,7 +1769,6 @@ struct
mk_extension F._extension;
mk_no_extension F._no_extension;
mk_extension_universe F._extension_universe;
mk_allow_illegal_crossing F._allow_illegal_crossing;
mk_noassert F._noassert;
mk_nolabels F._nolabels;
mk_nostdlib F._nostdlib;
Expand Down Expand Up @@ -1890,7 +1880,6 @@ module Default = struct
let _no_extension s = Language_extension.(disable_of_string_exn s)
let _extension_universe s =
Language_extension.(set_universe_and_enable_all_of_string_exn s)
let _allow_illegal_crossing = set Clflags.allow_illegal_crossing
let _noassert = set noassert
let _nolabels = set classic
let _nostdlib = set no_std_include
Expand Down
1 change: 0 additions & 1 deletion driver/main_args.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module type Common_options = sig
val _extension : string -> unit
val _no_extension : string -> unit
val _extension_universe : string -> unit
val _allow_illegal_crossing : unit -> unit
val _noassert : unit -> unit
val _nolabels : unit -> unit
val _nostdlib : unit -> unit
Expand Down
10 changes: 8 additions & 2 deletions otherlibs/stdlib_alpha/capsule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,12 @@ module Mutex = struct
; mutex : M.t
; mutable poisoned : bool
}
[@@unsafe_allow_any_mode_crossing]

(* CR: illegal mode crossing on the current version of the compiler,
but should be legal. *)
type packed : value mod portable uncontended = P : 'k t -> packed
[@@unsafe_allow_any_mode_crossing
"CR layouts v2.8: illegal mode crossing on the current version of the compiler, but \
should be legal."]

let[@inline] name t = t.name

Expand Down Expand Up @@ -357,8 +359,12 @@ module Rwlock = struct
; rwlock : Rw.t
; mutable poisoned : bool
}
[@@unsafe_allow_any_mode_crossing]

type packed : value mod portable uncontended = P : 'k t -> packed
[@@unsafe_allow_any_mode_crossing
"CR layouts v2.8: This can go away once we have proper mode crossing \
inference for GADT constructors "]

exception Poisoned

Expand Down
6 changes: 6 additions & 0 deletions otherlibs/stdlib_alpha/capsule.mli
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ module Mutex : sig
the capsule ['k] using {!create_with_mutex}. *)

type packed : value mod portable uncontended = P : 'k t -> packed
[@@unsafe_allow_any_mode_crossing
"CR layouts v2.8: This can go away once we have proper mode crossing \
inference for GADT constructors "]
(** [packed] is the type of a mutex for some unknown capsule.
Unpacking one provides a ['k Mutex.t] together with a fresh
existential type brand for ['k]. *)
Expand Down Expand Up @@ -219,6 +222,9 @@ module Rwlock : sig
the capsule ['k] using {!create_with_rwlock} *)

type packed : value mod portable uncontended = P : 'k t -> packed
[@@unsafe_allow_any_mode_crossing
"CR layouts v2.8: This can go away once we have proper mode crossing \
inference for GADT constructors "]
(** [packed] is the type of a reader-writer lock for some unknown capsule.
Unpacking one provides a ['k Rwlock.t] together with a fresh existential type
brand for ['k]. *)
Expand Down
4 changes: 1 addition & 3 deletions otherlibs/stdlib_alpha/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
-safe-string
-strict-formats
-extension-universe
alpha
;; Capsule API can't be defined legally.
-allow-illegal-crossing))
alpha))
(ocamlopt_flags
(:include %{project_root}/ocamlopt_flags.sexp))
(foreign_stubs
Expand Down
8 changes: 5 additions & 3 deletions testsuite/tests/capsule-api/rwlock_capsule.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST
include stdlib_alpha;
flags = "-extension-universe alpha -allow-illegal-crossing";
flags = "-extension-universe alpha";
runtime5;
{ bytecode; }
{ native; }
Expand All @@ -19,10 +19,12 @@ type ('a, 'k) _data : value mod portable uncontended = ('a, 'k) Capsule.Data.t
type _packed : value mod portable uncontended = Capsule.Rwlock.packed

(* CR: without [with] syntax and mode crossing inference, we need to depend on
[allow-illegal-crossing] to determine that 'a myref crosses portabilility.
This only holds when 'a also crosses portability *)
[@@unsafe_allow_any_mode_crossing] to determine that 'a myref crosses portabilility.
This only holds when 'a also crosses portability *)

type 'a myref : value mod portable = { mutable v : 'a}
[@@unsafe_allow_any_mode_crossing
"CR layouts v2.8: This can go away once we have with-kinds"]


module RwCell = struct
Expand Down
Loading

0 comments on commit b3ce767

Please sign in to comment.