diff options
42 files changed, 81 insertions, 240 deletions
@@ -898,7 +898,6 @@ typing/parmatch.cmo : \ typing/ident.cmi \ typing/env.cmi \ typing/ctype.cmi \ - utils/config.cmi \ typing/btype.cmi \ parsing/asttypes.cmi \ parsing/ast_helper.cmi \ @@ -921,7 +920,6 @@ typing/parmatch.cmx : \ typing/ident.cmx \ typing/env.cmx \ typing/ctype.cmx \ - utils/config.cmx \ typing/btype.cmx \ parsing/asttypes.cmi \ parsing/ast_helper.cmx \ @@ -974,7 +972,6 @@ typing/persistent_env.cmo : \ utils/load_path.cmi \ utils/lazy_backtrack.cmi \ utils/consistbl.cmi \ - utils/config.cmi \ file_formats/cmi_format.cmi \ utils/clflags.cmi \ typing/persistent_env.cmi @@ -985,7 +982,6 @@ typing/persistent_env.cmx : \ utils/load_path.cmx \ utils/lazy_backtrack.cmx \ utils/consistbl.cmx \ - utils/config.cmx \ file_formats/cmi_format.cmx \ utils/clflags.cmx \ typing/persistent_env.cmi @@ -3954,7 +3950,6 @@ middle_end/closure/closure.cmo : \ typing/env.cmi \ lambda/debuginfo.cmi \ middle_end/convert_primitives.cmi \ - utils/config.cmi \ middle_end/compilenv.cmi \ utils/clflags.cmi \ middle_end/clambda_primitives.cmi \ @@ -3977,7 +3972,6 @@ middle_end/closure/closure.cmx : \ typing/env.cmx \ lambda/debuginfo.cmx \ middle_end/convert_primitives.cmx \ - utils/config.cmx \ middle_end/compilenv.cmx \ utils/clflags.cmx \ middle_end/clambda_primitives.cmx \ @@ -4167,7 +4161,6 @@ middle_end/flambda/closure_conversion.cmo : \ middle_end/flambda/flambda.cmi \ lambda/debuginfo.cmi \ middle_end/convert_primitives.cmi \ - utils/config.cmi \ middle_end/compilation_unit.cmi \ middle_end/flambda/base_types/closure_origin.cmi \ middle_end/flambda/base_types/closure_id.cmi \ @@ -4196,7 +4189,6 @@ middle_end/flambda/closure_conversion.cmx : \ middle_end/flambda/flambda.cmx \ lambda/debuginfo.cmx \ middle_end/convert_primitives.cmx \ - utils/config.cmx \ middle_end/compilation_unit.cmx \ middle_end/flambda/base_types/closure_origin.cmx \ middle_end/flambda/base_types/closure_id.cmx \ @@ -87,6 +87,11 @@ Working version ### Build system: +* #10893: Remove configuration options --disable-force-safe-string and + DEFAULT_STRING=unsafe as well as --enable-force-safe-string and + DEFAULT_STRING=safe which are now the default unconditionally. + (Kate Deplaix, review by Gabriel Scherer and David Allsopp) + ### Bug fixes: OCaml 4.14.0 diff --git a/Makefile.config.in b/Makefile.config.in index e4e22de4dd..6ee1453d88 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -244,8 +244,8 @@ FLAMBDA=@flambda@ WITH_FLAMBDA_INVARIANTS=@flambda_invariants@ FORCE_INSTRUMENTED_RUNTIME=@force_instrumented_runtime@ WITH_CMM_INVARIANTS=@cmm_invariants@ -FORCE_SAFE_STRING=@force_safe_string@ -DEFAULT_SAFE_STRING=@default_safe_string@ +FORCE_SAFE_STRING=true +DEFAULT_SAFE_STRING=true WINDOWS_UNICODE=@windows_unicode@ AFL_INSTRUMENT=@afl@ FLAT_FLOAT_ARRAY=@flat_float_array@ @@ -754,8 +754,6 @@ stdlib_manpages PACKLD flexlink_flags flexdll_chain -default_safe_string -force_safe_string afl function_sections flat_float_array @@ -1598,8 +1596,6 @@ Optional Features: --disable-stdlib-manpages do not build or install the library man pages --enable-warn-error treat C compiler warnings as errors - --disable-force-safe-string - do not force strings to be safe --disable-flat-float-array do not use flat float arrays --disable-function-sections @@ -1636,7 +1632,7 @@ Some influential environment variables: WINDOWS_UNICODE_MODE how to handle Unicode under Windows: ansi, compatible DEFAULT_STRING - whether strings should be safe (default) or unsafe + CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a @@ -2956,8 +2952,6 @@ OCAML_VERSION_SHORT=5.00 - - ## Generated files ac_config_files="$ac_config_files Makefile.build_config" @@ -3346,38 +3340,18 @@ fi -# There are two configure-time string safety options, -# --(enable|disable)-force-safe-string and -# DEFAULT_STRING=safe|unsafe that -# interact with a compile-time (un)safe-string option. -# -# If --enable-force-safe-string is set at configure time, then the compiler -# will always enforce that string and bytes are distinct: the -# compile-time -unsafe-string option is disabled. This lets us -# assume pervasive string immutability, for code optimizations and -# in the C layer. -# -# If --disable-force-safe-string is set at configure-time, the compiler -# will use the compile-time (un)safe-string option to decide whether -# string and bytes are compatible on a per-file basis. The -# configuration variable DEFAULT_STRING=safe|unsafe decides which -# setting will be chosen by default, if no compile-time option is -# explicitly passed. -# -# The configure-time behavior of OCaml 4.05 and older was equivalent -# to --disable-force-safe-string DEFAULT_STRING=unsafe. With OCaml 4.06 -# and older was equivalent to --disable-force-safe-string DEFAULT_STRING=safe. -# With OCaml 4.10 and later use --enable-force-safe-string DEFAULT_STRING=safe. -# We expect the --disable-force-safe-string and DEFAULT_STRING=unsafe options -# to be removed in the future. - # Check whether --enable-force-safe-string was given. if test "${enable_force_safe_string+set}" = set; then : - enableval=$enable_force_safe_string; + enableval=$enable_force_safe_string; if test "x$enableval" = 'xno'; then : + as_fn_error $? "Support for mutable strings was removed in OCaml 5.00." "$LINENO" 5 +fi fi +if test x"$DEFAULT_STRING" = "xunsafe"; then : + as_fn_error $? "Support for mutable strings was removed in OCaml 5.00." "$LINENO" 5 +fi # Check whether --enable-flat-float-array was given. if test "${enable_flat_float_array+set}" = set; then : @@ -17760,20 +17734,6 @@ else afl=false fi -if test x"$enable_force_safe_string" = "xno"; then : - force_safe_string=false -else - $as_echo "#define CAML_SAFE_STRING 1" >>confdefs.h - - force_safe_string=true -fi - -if test x"$DEFAULT_STRING" = "xunsafe"; then : - default_safe_string=false -else - default_safe_string=true -fi - oc_cflags="$common_cflags $internal_cflags" oc_cppflags="$common_cppflags $internal_cppflags" ocamlc_cflags="$common_cflags $sharedlib_cflags \$(CFLAGS)" diff --git a/configure.ac b/configure.ac index 67831f74b9..2a7ef8637c 100644 --- a/configure.ac +++ b/configure.ac @@ -162,8 +162,6 @@ AC_SUBST([windows_unicode]) AC_SUBST([flat_float_array]) AC_SUBST([function_sections]) AC_SUBST([afl]) -AC_SUBST([force_safe_string]) -AC_SUBST([default_safe_string]) AC_SUBST([flexdll_chain]) AC_SUBST([flexlink_flags]) AC_SUBST([PACKLD]) @@ -372,37 +370,14 @@ AC_ARG_ENABLE([warn-error], AC_ARG_VAR([WINDOWS_UNICODE_MODE], [how to handle Unicode under Windows: ansi, compatible]) -# There are two configure-time string safety options, -# --(enable|disable)-force-safe-string and -# DEFAULT_STRING=safe|unsafe that -# interact with a compile-time (un)safe-string option. -# -# If --enable-force-safe-string is set at configure time, then the compiler -# will always enforce that string and bytes are distinct: the -# compile-time -unsafe-string option is disabled. This lets us -# assume pervasive string immutability, for code optimizations and -# in the C layer. -# -# If --disable-force-safe-string is set at configure-time, the compiler -# will use the compile-time (un)safe-string option to decide whether -# string and bytes are compatible on a per-file basis. The -# configuration variable DEFAULT_STRING=safe|unsafe decides which -# setting will be chosen by default, if no compile-time option is -# explicitly passed. -# -# The configure-time behavior of OCaml 4.05 and older was equivalent -# to --disable-force-safe-string DEFAULT_STRING=unsafe. With OCaml 4.06 -# and older was equivalent to --disable-force-safe-string DEFAULT_STRING=safe. -# With OCaml 4.10 and later use --enable-force-safe-string DEFAULT_STRING=safe. -# We expect the --disable-force-safe-string and DEFAULT_STRING=unsafe options -# to be removed in the future. - -AC_ARG_ENABLE([force-safe-string], - [AS_HELP_STRING([--disable-force-safe-string], - [do not force strings to be safe])]) - -AC_ARG_VAR([DEFAULT_STRING], - [whether strings should be safe (default) or unsafe]) +AC_ARG_ENABLE([force-safe-string], [], + [AS_IF([test "x$enableval" = 'xno'], + [AC_MSG_ERROR([Support for mutable strings was removed in OCaml 5.00.])])], + []) + +AC_ARG_VAR([DEFAULT_STRING], []) +AS_IF([test x"$DEFAULT_STRING" = "xunsafe"], + [AC_MSG_ERROR([Support for mutable strings was removed in OCaml 5.00.])]) AC_ARG_ENABLE([flat-float-array], [AS_HELP_STRING([--disable-flat-float-array], @@ -1947,15 +1922,6 @@ AS_IF([test x"$with_afl" = "xyes"], [afl=true], [afl=false]) -AS_IF([test x"$enable_force_safe_string" = "xno"], - [force_safe_string=false], - [AC_DEFINE([CAML_SAFE_STRING]) - force_safe_string=true]) - -AS_IF([test x"$DEFAULT_STRING" = "xunsafe"], - [default_safe_string=false], - [default_safe_string=true]) - oc_cflags="$common_cflags $internal_cflags" oc_cppflags="$common_cppflags $internal_cppflags" ocamlc_cflags="$common_cflags $sharedlib_cflags \$(CFLAGS)" diff --git a/driver/compenv.ml b/driver/compenv.ml index 8b1c4e5559..a19854e066 100644 --- a/driver/compenv.ml +++ b/driver/compenv.ml @@ -227,6 +227,16 @@ let parse_warnings error v = let read_one_param ppf position name v = let set name options s = setter ppf (fun b -> b) name options s in let clear name options s = setter ppf (fun b -> not b) name options s in + let compat name s = + let error_if_unset = function + | true -> true + | false -> + Printf.ksprintf (print_error ppf) + "Unsetting %s is not supported anymore" name; + true + in + setter ppf error_if_unset name [ ref true ] s + in match name with | "g" -> set "g" [ Clflags.debug ] v | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v @@ -243,7 +253,7 @@ let read_one_param ppf position name v = | "nolabels" -> set "nolabels" [ classic ] v | "principal" -> set "principal" [ principal ] v | "rectypes" -> set "rectypes" [ recursive_types ] v - | "safe-string" -> clear "safe-string" [ unsafe_string ] v + | "safe-string" -> compat "safe-string" v (* kept for compatibility *) | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v | "strict-formats" -> set "strict-formats" [ strict_formats ] v | "thread" -> set "thread" [ use_threads ] v diff --git a/driver/compmisc.ml b/driver/compmisc.ml index bc2d151b12..d4f2af32ff 100644 --- a/driver/compmisc.ml +++ b/driver/compmisc.ml @@ -50,7 +50,6 @@ let initial_env () = in Typemod.initial_env ~loc:(Location.in_file "command line") - ~safe_string:(Config.safe_string || not !Clflags.unsafe_string) ~initially_opened_module ~open_implicit_modules:(List.rev !Clflags.open_modules) diff --git a/driver/main_args.ml b/driver/main_args.ml index 8203454660..61259afaeb 100644 --- a/driver/main_args.ml +++ b/driver/main_args.ml @@ -504,11 +504,9 @@ let mk_S f = "-S", Arg.Unit f, " Keep intermediate assembly file" ;; -let mk_safe_string f = - "-safe-string", Arg.Unit f, - if Config.safe_string then " (was set when configuring the compiler)" - else if Config.default_safe_string then " Make strings immutable (default)" - else " Make strings immutable" +let mk_safe_string = + "-safe-string", Arg.Unit (fun () -> ()), + " (default unconditionally since 5.00)" ;; let mk_shared f = @@ -578,17 +576,11 @@ let mk_unsafe f = " Do not compile bounds checking on array and string access" ;; -let mk_unsafe_string f = - if Config.safe_string then - let err () = - raise (Arg.Bad "OCaml has been configured with -force-safe-string: \ - -unsafe-string is not available") - in - "-unsafe-string", Arg.Unit err, " (option not available)" - else if Config.default_safe_string then - "-unsafe-string", Arg.Unit f, " Make strings mutable" - else - "-unsafe-string", Arg.Unit f, " Make strings mutable (default)" +let mk_unsafe_string = + let err () = + raise (Arg.Bad "-unsafe-string is not available since OCaml 5.00") + in + "-unsafe-string", Arg.Unit err, " (option not available)" ;; let mk_use_runtime f = @@ -929,7 +921,6 @@ module type Common_options = sig val _no_principal : unit -> unit val _rectypes : unit -> unit val _no_rectypes : unit -> unit - val _safe_string : unit -> unit val _short_paths : unit -> unit val _strict_sequence : unit -> unit val _no_strict_sequence : unit -> unit @@ -938,7 +929,6 @@ module type Common_options = sig val _force_tmc : unit -> unit val _unboxed_types : unit -> unit val _no_unboxed_types : unit -> unit - val _unsafe_string : unit -> unit val _version : unit -> unit val _vnum : unit -> unit val _w : string -> unit @@ -1004,7 +994,6 @@ module type Compiler_options = sig val _runtime_variant : string -> unit val _with_runtime : unit -> unit val _without_runtime : unit -> unit - val _safe_string : unit -> unit val _short_paths : unit -> unit val _thread : unit -> unit val _v : unit -> unit @@ -1225,7 +1214,7 @@ struct mk_runtime_variant F._runtime_variant; mk_with_runtime F._with_runtime; mk_without_runtime F._without_runtime; - mk_safe_string F._safe_string; + mk_safe_string; mk_short_paths F._short_paths; mk_strict_sequence F._strict_sequence; mk_no_strict_sequence F._no_strict_sequence; @@ -1236,7 +1225,7 @@ struct mk_unboxed_types F._unboxed_types; mk_no_unboxed_types F._no_unboxed_types; mk_unsafe F._unsafe; - mk_unsafe_string F._unsafe_string; + mk_unsafe_string; mk_use_runtime F._use_runtime; mk_use_runtime_2 F._use_runtime; mk_v F._v; @@ -1300,7 +1289,7 @@ struct mk_no_principal F._no_principal; mk_rectypes F._rectypes; mk_no_rectypes F._no_rectypes; - mk_safe_string F._safe_string; + mk_safe_string; mk_short_paths F._short_paths; mk_stdin F._stdin; mk_strict_sequence F._strict_sequence; @@ -1310,7 +1299,7 @@ struct mk_unboxed_types F._unboxed_types; mk_no_unboxed_types F._no_unboxed_types; mk_unsafe F._unsafe; - mk_unsafe_string F._unsafe_string; + mk_unsafe_string; mk_version F._version; mk__version F._version; mk_no_version F._no_version; @@ -1427,7 +1416,7 @@ struct mk_with_runtime F._with_runtime; mk_without_runtime F._without_runtime; mk_S F._S; - mk_safe_string F._safe_string; + mk_safe_string; mk_shared F._shared; mk_short_paths F._short_paths; mk_strict_sequence F._strict_sequence; @@ -1442,7 +1431,7 @@ struct mk_unboxed_types F._unboxed_types; mk_no_unboxed_types F._no_unboxed_types; mk_unsafe F._unsafe; - mk_unsafe_string F._unsafe_string; + mk_unsafe_string; mk_v F._v; mk_verbose F._verbose; mk_version F._version; @@ -1546,7 +1535,7 @@ module Make_opttop_options (F : Opttop_options) = struct mk_no_rectypes F._no_rectypes; mk_remove_unused_arguments F._remove_unused_arguments; mk_S F._S; - mk_safe_string F._safe_string; + mk_safe_string; mk_short_paths F._short_paths; mk_stdin F._stdin; mk_strict_sequence F._strict_sequence; @@ -1558,7 +1547,7 @@ module Make_opttop_options (F : Opttop_options) = struct mk_unboxed_types F._unboxed_types; mk_no_unboxed_types F._no_unboxed_types; mk_unsafe F._unsafe; - mk_unsafe_string F._unsafe_string; + mk_unsafe_string; mk_verbose F._verbose; mk_version F._version; mk__version F._version; @@ -1628,7 +1617,7 @@ struct mk_no_principal F._no_principal; mk_rectypes F._rectypes; mk_no_rectypes F._no_rectypes; - mk_safe_string F._safe_string; + mk_safe_string; mk_short_paths F._short_paths; mk_strict_sequence F._strict_sequence; mk_no_strict_sequence F._no_strict_sequence; @@ -1638,7 +1627,7 @@ struct mk_force_tmc F._force_tmc; mk_unboxed_types F._unboxed_types; mk_no_unboxed_types F._no_unboxed_types; - mk_unsafe_string F._unsafe_string; + mk_unsafe_string; mk_v F._v; mk_verbose F._verbose; mk_version F._version; @@ -1719,12 +1708,10 @@ module Default = struct let _open s = open_modules := (s :: (!open_modules)) let _principal = set principal let _rectypes = set recursive_types - let _safe_string = clear unsafe_string let _short_paths = clear real_paths let _strict_formats = set strict_formats let _strict_sequence = set strict_sequence let _unboxed_types = set unboxed_types - let _unsafe_string = set unsafe_string let _w s = Warnings.parse_options false s |> Option.iter Location.(prerr_alert none) diff --git a/driver/main_args.mli b/driver/main_args.mli index 2b963ef18c..b8f79b34a1 100644 --- a/driver/main_args.mli +++ b/driver/main_args.mli @@ -34,7 +34,6 @@ module type Common_options = sig val _no_principal : unit -> unit val _rectypes : unit -> unit val _no_rectypes : unit -> unit - val _safe_string : unit -> unit val _short_paths : unit -> unit val _strict_sequence : unit -> unit val _no_strict_sequence : unit -> unit @@ -43,7 +42,6 @@ module type Common_options = sig val _force_tmc : unit -> unit val _unboxed_types : unit -> unit val _no_unboxed_types : unit -> unit - val _unsafe_string : unit -> unit val _version : unit -> unit val _vnum : unit -> unit val _w : string -> unit @@ -108,7 +106,6 @@ module type Compiler_options = sig val _runtime_variant : string -> unit val _with_runtime : unit -> unit val _without_runtime : unit -> unit - val _safe_string : unit -> unit val _short_paths : unit -> unit val _thread : unit -> unit val _v : unit -> unit diff --git a/file_formats/cmi_format.ml b/file_formats/cmi_format.ml index eadf676e08..bd82cc3761 100644 --- a/file_formats/cmi_format.ml +++ b/file_formats/cmi_format.ml @@ -19,7 +19,6 @@ type pers_flags = | Rectypes | Alerts of alerts | Opaque - | Unsafe_string type error = | Not_an_interface of filepath diff --git a/file_formats/cmi_format.mli b/file_formats/cmi_format.mli index d4d665fdf5..2a63deb3dc 100644 --- a/file_formats/cmi_format.mli +++ b/file_formats/cmi_format.mli @@ -19,7 +19,6 @@ type pers_flags = | Rectypes | Alerts of alerts | Opaque - | Unsafe_string type cmi_infos = { cmi_name : modname; diff --git a/lambda/matching.ml b/lambda/matching.ml index 65fc5e06a5..6a44270f76 100644 --- a/lambda/matching.ml +++ b/lambda/matching.ml @@ -1863,7 +1863,7 @@ let get_mod_field modname field = lazy (let mod_ident = Ident.create_persistent modname in let env = - Env.add_persistent_structure mod_ident Env.initial_safe_string + Env.add_persistent_structure mod_ident Env.initial in match Env.open_pers_signature modname env with | Error `Not_found -> @@ -3442,7 +3442,7 @@ let failure_handler ~scopes loc ~failer () = let sloc = Scoped_location.of_location ~scopes loc in let slot = transl_extension_path sloc - Env.initial_safe_string Predef.path_match_failure + Env.initial Predef.path_match_failure in let fname, line, char = Location.get_pos_info loc.Location.loc_start in diff --git a/lambda/translcore.ml b/lambda/translcore.ml index 1914bf8e09..5562b7c431 100644 --- a/lambda/translcore.ml +++ b/lambda/translcore.ml @@ -189,7 +189,7 @@ let event_function ~scopes exp lam = let assert_failed ~scopes exp = let slot = transl_extension_path Loc_unknown - Env.initial_safe_string Predef.path_assert_failure + Env.initial Predef.path_assert_failure in let loc = exp.exp_loc in let (fname, line, char) = diff --git a/manual/src/cmds/unified-options.etex b/manual/src/cmds/unified-options.etex index ef90a2cf95..0ff860beac 100644 --- a/manual/src/cmds/unified-options.etex +++ b/manual/src/cmds/unified-options.etex @@ -660,7 +660,8 @@ Linux AMD 64, they must contain only position-independent code). \item["-safe-string"] Enforce the separation between types "string" and "bytes", -thereby making strings read-only. This is the default. +thereby making strings read-only. This is the default, and enforced +since OCaml 5.00. \item["-short-paths"] When a type is visible under several module-paths, use the shortest @@ -711,7 +712,8 @@ unspecified result instead of raising a "Division_by_zero" exception. \item["-unsafe-string"] Identify the types "string" and "bytes", thereby making strings writable. This is intended for compatibility with old source code and should not -be used with new software. +be used with new software. This option raises an error unconditionally +since OCaml 5.00. \comp{% \item["-use-runtime" \var{runtime-name}] diff --git a/middle_end/closure/closure.ml b/middle_end/closure/closure.ml index bf73f487c6..6a0cfcfa59 100644 --- a/middle_end/closure/closure.ml +++ b/middle_end/closure/closure.ml @@ -897,9 +897,9 @@ let rec close ({ backend; fenv; cenv ; mutable_vars } as env) lam = close_approx_var env id | Lmutvar id -> (Uvar id, Value_unknown) | Lconst cst -> - let str ?(shared = true) cst = + let str cst = let name = - Compilenv.new_structured_constant cst ~shared + Compilenv.new_structured_constant cst ~shared:true in Uconst_ref (name, Some cst) in @@ -914,13 +914,7 @@ let rec close ({ backend; fenv; cenv ; mutable_vars } as env) lam = | Const_immstring s -> str (Uconst_string s) | Const_base (Const_string (s, _, _)) -> - (* Strings (even literal ones) must be assumed to be mutable... - except when OCaml has been configured with - -safe-string. Passing -safe-string at compilation - time is not enough, since the unit could be linked - with another one compiled without -safe-string, and - that one could modify our string literal. *) - str ~shared:Config.safe_string (Uconst_string s) + str (Uconst_string s) | Const_base(Const_float x) -> str (Uconst_float (float_of_string x)) | Const_base(Const_int32 x) -> str (Uconst_int32 x) | Const_base(Const_int64 x) -> str (Uconst_int64 x) diff --git a/middle_end/flambda/closure_conversion.ml b/middle_end/flambda/closure_conversion.ml index 7b811166af..f5ba6f2599 100644 --- a/middle_end/flambda/closure_conversion.ml +++ b/middle_end/flambda/closure_conversion.ml @@ -118,12 +118,8 @@ let rec declare_const t (const : Lambda.structured_constant) | Const_base (Const_char c) -> (Const (Char c), Names.const_char) | Const_base (Const_string (s, _, _)) -> let const, name = - if Config.safe_string then - (Flambda.Allocated_const (Immutable_string s), - Names.const_immstring) - else - (Flambda.Allocated_const (String s), - Names.const_string) + (Flambda.Allocated_const (Immutable_string s), + Names.const_immstring) in register_const t const name | Const_base (Const_float c) -> diff --git a/ocaml-variants.opam b/ocaml-variants.opam index 96cda316fd..f2d0ec852f 100644 --- a/ocaml-variants.opam +++ b/ocaml-variants.opam @@ -18,8 +18,6 @@ build: [ "--docdir=%{doc}%/ocaml" "--with-afl" {ocaml-option-afl:installed} "--disable-native-compiler" {ocaml-option-bytecode-only:installed} - "--disable-force-safe-string" {ocaml-option-default-unsafe-string:installed} - "DEFAULT_STRING=unsafe" {ocaml-option-default-unsafe-string:installed} "--disable-flat-float-array" {ocaml-option-no-flat-float-array:installed} "--enable-flambda" {ocaml-option-flambda:installed} "--enable-frame-pointers" {ocaml-option-fp:installed} @@ -46,11 +44,11 @@ install: [make "install"] conflicts: [ "ocaml-option-32bit" # Not yet implemented "ocaml-option-nnpchecker" # Fundamentally not possible + "ocaml-option-default-unsafe-string" # Not supported since 5.00 ] depopts: [ "ocaml-option-afl" "ocaml-option-bytecode-only" - "ocaml-option-default-unsafe-string" "ocaml-option-no-flat-float-array" "ocaml-option-flambda" "ocaml-option-fp" diff --git a/ocamldoc/.depend b/ocamldoc/.depend index 3ec61c60c2..67b0e8c4ab 100644 --- a/ocamldoc/.depend +++ b/ocamldoc/.depend @@ -38,7 +38,6 @@ odoc_analyse.cmo : \ ../parsing/location.cmi \ ../parsing/lexer.cmi \ ../typing/env.cmi \ - ../utils/config.cmi \ ../driver/compmisc.cmi \ ../utils/clflags.cmi \ odoc_analyse.cmi @@ -66,7 +65,6 @@ odoc_analyse.cmx : \ ../parsing/location.cmx \ ../parsing/lexer.cmx \ ../typing/env.cmx \ - ../utils/config.cmx \ ../driver/compmisc.cmx \ ../utils/clflags.cmx \ odoc_analyse.cmi diff --git a/ocamldoc/odoc_analyse.ml b/ocamldoc/odoc_analyse.ml index f9ec3cb69c..257e2cbc86 100644 --- a/ocamldoc/odoc_analyse.ml +++ b/ocamldoc/odoc_analyse.ml @@ -42,7 +42,6 @@ let initial_env () = ln @ List.rev !Clflags.open_modules in Typemod.initial_env ~loc:(Location.in_file "ocamldoc command line") - ~safe_string:(Config.safe_string || not !Clflags.unsafe_string) ~open_implicit_modules ~initially_opened_module diff --git a/ocamltest/Makefile b/ocamltest/Makefile index 4d37423512..53ebb005ca 100644 --- a/ocamltest/Makefile +++ b/ocamltest/Makefile @@ -249,7 +249,6 @@ ocamltest_config.ml: ocamltest_config.ml.in Makefile ../Makefile.config $(call SUBST_STRING,CPP) \ $(call SUBST_STRING,ocamlsrcdir) \ $(call SUBST,FLAMBDA) \ - $(call SUBST,FORCE_SAFE_STRING) \ $(call SUBST,FLAT_FLOAT_ARRAY) \ $(call SUBST,WITH_OCAMLDOC) \ $(call SUBST,WITH_OCAMLDEBUG) \ diff --git a/ocamltest/ocamltest_config.ml.in b/ocamltest/ocamltest_config.ml.in index db4dd221ad..2f03f01989 100644 --- a/ocamltest/ocamltest_config.ml.in +++ b/ocamltest/ocamltest_config.ml.in @@ -52,8 +52,6 @@ let flambda = %%FLAMBDA%% let ocamlc_default_flags = "" let ocamlopt_default_flags = "" -let safe_string = %%FORCE_SAFE_STRING%% - let flat_float_array = %%FLAT_FLOAT_ARRAY%% let ocamldoc = %%WITH_OCAMLDOC%% diff --git a/ocamltest/ocamltest_config.mli b/ocamltest/ocamltest_config.mli index 3ce8c9558e..ce9e084bdf 100644 --- a/ocamltest/ocamltest_config.mli +++ b/ocamltest/ocamltest_config.mli @@ -73,9 +73,6 @@ val ocamlsrcdir : string val flambda : bool (** Whether flambda has been enabled at configure time *) -val safe_string : bool -(** Whether the compiler was configured with -safe-string *) - val flat_float_array : bool (* Whether the compiler was configured with -flat-float-array *) diff --git a/parsing/ast_mapper.ml b/parsing/ast_mapper.ml index ee56f3f05d..f6c992ba45 100644 --- a/parsing/ast_mapper.ml +++ b/parsing/ast_mapper.ml @@ -843,7 +843,7 @@ module PpxContext = struct lid "principal", make_bool !Clflags.principal; lid "transparent_modules", make_bool !Clflags.transparent_modules; lid "unboxed_types", make_bool !Clflags.unboxed_types; - lid "unsafe_string", make_bool !Clflags.unsafe_string; + lid "unsafe_string", make_bool false; (* kept for compatibility *) get_cookies () ] in @@ -923,8 +923,6 @@ module PpxContext = struct Clflags.transparent_modules := get_bool payload | "unboxed_types" -> Clflags.unboxed_types := get_bool payload - | "unsafe_string" -> - Clflags.unsafe_string := get_bool payload | "cookies" -> let l = get_list (get_pair get_string (fun x -> x)) payload in cookies := diff --git a/runtime/caml/m.h.in b/runtime/caml/m.h.in index 1c3dee1779..ba0074318d 100644 --- a/runtime/caml/m.h.in +++ b/runtime/caml/m.h.in @@ -90,7 +90,7 @@ #undef CAML_WITH_FPIC -#undef CAML_SAFE_STRING +#define CAML_SAFE_STRING 1 #undef FLAT_FLOAT_ARRAY diff --git a/runtime/caml/mlvalues.h b/runtime/caml/mlvalues.h index 4b8dcbbce6..8d03aed48e 100644 --- a/runtime/caml/mlvalues.h +++ b/runtime/caml/mlvalues.h @@ -315,11 +315,7 @@ CAMLextern value caml_hash_variant(char const * tag); /* Strings. */ #define String_tag 252 -#ifdef CAML_SAFE_STRING #define String_val(x) ((const char *) Bp_val(x)) -#else -#define String_val(x) ((char *) Bp_val(x)) -#endif #define Bytes_val(x) ((unsigned char *) Bp_val(x)) CAMLextern mlsize_t caml_string_length (value); /* size in bytes */ CAMLextern int caml_string_is_c_safe (value); diff --git a/testsuite/tests/asmcomp/staticalloc.ml b/testsuite/tests/asmcomp/staticalloc.ml index 16eae1d48a..8f241847f8 100644 --- a/testsuite/tests/asmcomp/staticalloc.ml +++ b/testsuite/tests/asmcomp/staticalloc.ml @@ -19,8 +19,6 @@ let () = let[@local never] g () = (a, fst b) in assert (g () == ((1,2), (1,2))); assert (fst (pair a a) == (1, 2)); - assert (snd b != ["x"; "y"] || Config.safe_string); (* mutable "constant", - cannot be shared *) let x2 = Gc.allocated_bytes () in assert(x1 -. x0 = x2 -. x1) (* check that we did not allocated anything between x1 and x2 *) diff --git a/testsuite/tests/compiler-libs/test_untypeast.ml b/testsuite/tests/compiler-libs/test_untypeast.ml index c342a0f5b6..97775515fa 100644 --- a/testsuite/tests/compiler-libs/test_untypeast.ml +++ b/testsuite/tests/compiler-libs/test_untypeast.ml @@ -8,7 +8,7 @@ let res = let s = {| match None with Some (Some _) -> () | _ -> () |} in let pe = Parse.expression (Lexing.from_string s) in - let te = Typecore.type_expression (Env.initial_safe_string) pe in + let te = Typecore.type_expression Env.initial pe in let ute = Untypeast.untype_expression te in Format.asprintf "%a" Pprintast.expression ute diff --git a/typing/ctype.ml b/typing/ctype.ml index 5d1fe86aa4..621ea88527 100644 --- a/typing/ctype.ml +++ b/typing/ctype.ml @@ -281,7 +281,7 @@ let in_current_module = function let in_pervasives p = in_current_module p && - try ignore (Env.find_type p Env.initial_safe_string); true + try ignore (Env.find_type p Env.initial); true with Not_found -> false let is_datatype decl= diff --git a/typing/env.ml b/typing/env.ml index a2dee9f77d..0195a8baba 100644 --- a/typing/env.ml +++ b/typing/env.ml @@ -2551,7 +2551,7 @@ let save_signature_with_imports ~alerts sg modname filename imports = ~alerts sg modname filename (* Make the initial environment *) -let (initial_safe_string, initial_unsafe_string) = +let initial = Predef.build_initial_env (add_type ~check:false) (add_extension ~check:false ~rebind:false) @@ -3020,7 +3020,7 @@ let lookup_all_dot_constructors ~errors ~use ~loc usage l s env = | Longident.Lident "*predef*" -> (* Hack to support compilation of default arguments *) lookup_all_ident_constructors - ~errors ~use ~loc usage s initial_safe_string + ~errors ~use ~loc usage s initial | _ -> let (_, comps) = lookup_structure_components ~errors ~use ~loc l env in match NameMap.find s comps.comp_constrs with diff --git a/typing/env.mli b/typing/env.mli index 55ab3a5b6f..ae8e2cf8dc 100644 --- a/typing/env.mli +++ b/typing/env.mli @@ -57,8 +57,7 @@ type address = type t val empty: t -val initial_safe_string: t -val initial_unsafe_string: t +val initial: t val diff: t -> t -> Ident.t list type type_descr_kind = diff --git a/typing/parmatch.ml b/typing/parmatch.ml index 2b48d63d54..0ec2ddada7 100644 --- a/typing/parmatch.ml +++ b/typing/parmatch.ml @@ -2149,7 +2149,7 @@ let inactive ~partial pat = true | Tpat_constant c -> begin match c with - | Const_string _ -> Config.safe_string + | Const_string _ | Const_int _ | Const_char _ | Const_float _ | Const_int32 _ | Const_int64 _ | Const_nativeint _ -> true end diff --git a/typing/persistent_env.ml b/typing/persistent_env.ml index 65f6066376..e29017bb3f 100644 --- a/typing/persistent_env.ml +++ b/typing/persistent_env.ml @@ -27,7 +27,6 @@ type error = | Illegal_renaming of modname * modname * filepath | Inconsistent_import of modname * filepath * filepath | Need_recursive_types of modname - | Depend_on_unsafe_string_unit of modname exception Error of error let error err = raise (Error err) @@ -163,7 +162,6 @@ let save_pers_struct penv crc ps pm = (function | Rectypes -> () | Alerts _ -> () - | Unsafe_string -> () | Opaque -> register_import_as_opaque penv modname) ps.ps_flags; Consistbl.set crc_units modname crc ps.ps_filename; @@ -186,9 +184,6 @@ let acknowledge_pers_struct penv check modname pers_sig pm = | Rectypes -> if not !Clflags.recursive_types then error (Need_recursive_types(ps.ps_name)) - | Unsafe_string -> - if Config.safe_string then - error (Depend_on_unsafe_string_unit(ps.ps_name)); | Alerts _ -> () | Opaque -> register_import_as_opaque penv modname) ps.ps_flags; @@ -252,9 +247,6 @@ let check_pers_struct penv f ~loc name = Format.sprintf "%s uses recursive types" name - | Depend_on_unsafe_string_unit name -> - Printf.sprintf "%s uses -unsafe-string" - name in let warn = Warnings.No_cmi_file(name, Some msg) in Location.prerr_warning loc warn @@ -306,7 +298,6 @@ let make_cmi penv modname sign alerts = List.concat [ if !Clflags.recursive_types then [Cmi_format.Rectypes] else []; if !Clflags.opaque then [Cmi_format.Opaque] else []; - (if !Clflags.unsafe_string then [Cmi_format.Unsafe_string] else []); [Alerts alerts]; ] in @@ -358,11 +349,6 @@ let report_error ppf = fprintf ppf "@[<hov>Invalid import of %s, which uses recursive types.@ %s@]" import "The compilation flag -rectypes is required" - | Depend_on_unsafe_string_unit(import) -> - fprintf ppf - "@[<hov>Invalid import of %s, compiled with -unsafe-string.@ %s@]" - import "This compiler has been configured in strict \ - safe-string mode (-force-safe-string)" let () = Location.register_error_of_exn diff --git a/typing/persistent_env.mli b/typing/persistent_env.mli index b2e139312d..618ea3991e 100644 --- a/typing/persistent_env.mli +++ b/typing/persistent_env.mli @@ -24,7 +24,6 @@ type error = | Illegal_renaming of modname * modname * filepath | Inconsistent_import of modname * filepath * filepath | Need_recursive_types of modname - | Depend_on_unsafe_string_unit of modname exception Error of error diff --git a/typing/predef.ml b/typing/predef.ml index cd2da42285..af932a53fd 100644 --- a/typing/predef.ml +++ b/typing/predef.ml @@ -160,7 +160,7 @@ let mk_add_type add_type type_ident in add_type type_ident decl env -let common_initial_env add_type add_extension empty_env = +let build_initial_env add_type add_extension empty_env = let add_type = mk_add_type add_type and add_type1 type_ident ~variance ~separability ?(kind=fun _ -> Type_abstract) env = @@ -230,6 +230,7 @@ let common_initial_env add_type add_extension empty_env = ~kind:(fun tvar -> variant [cstr ident_none []; cstr ident_some [tvar]]) |> add_type ident_string + |> add_type ident_bytes |> add_type ident_unit ~immediate:Always ~kind:(variant [cstr ident_void []]) @@ -252,13 +253,6 @@ let common_initial_env add_type add_extension empty_env = [newgenty (Ttuple[type_string; type_int; type_int])] |> add_extension ident_unhandled [] -let build_initial_env add_type add_exception empty_env = - let common = common_initial_env add_type add_exception empty_env in - let add_type = mk_add_type add_type in - let safe_string = add_type ident_bytes common in - let unsafe_string = add_type ident_bytes ~manifest:type_string common in - (safe_string, unsafe_string) - let builtin_values = List.map (fun id -> (Ident.name id, id)) all_predef_exns diff --git a/typing/predef.mli b/typing/predef.mli index 962a276a92..4fde9cce6b 100644 --- a/typing/predef.mli +++ b/typing/predef.mli @@ -72,7 +72,7 @@ val ident_some : Ident.t val build_initial_env: (Ident.t -> type_declaration -> 'a -> 'a) -> (Ident.t -> extension_constructor -> 'a -> 'a) -> - 'a -> 'a * 'a + 'a -> 'a (* To initialize linker tables *) diff --git a/typing/typemod.ml b/typing/typemod.ml index 5774460e92..34367e45e2 100644 --- a/typing/typemod.ml +++ b/typing/typemod.ml @@ -113,14 +113,9 @@ let type_open_ ?used_slot ?toplevel ovf env loc lid = ignore (extract_sig_open env lid.loc md.md_type); assert false -let initial_env ~loc ~safe_string ~initially_opened_module +let initial_env ~loc ~initially_opened_module ~open_implicit_modules = - let env = - if safe_string then - Env.initial_safe_string - else - Env.initial_unsafe_string - in + let env = Env.initial in let open_module env m = let open Asttypes in let lexbuf = Lexing.from_string m in @@ -3131,7 +3126,7 @@ let package_units initial_env objfiles cmifile modulename = let modname = String.capitalize_ascii(Filename.basename pref) in let sg = Env.read_signature modname (pref ^ ".cmi") in if Filename.check_suffix f ".cmi" && - not(Mtype.no_code_needed_sig Env.initial_safe_string sg) + not(Mtype.no_code_needed_sig Env.initial sg) then raise(Error(Location.none, Env.empty, Implementation_is_required f)); (modname, Env.read_signature modname (pref ^ ".cmi"))) diff --git a/typing/typemod.mli b/typing/typemod.mli index 30ed1c7174..f0073a8c4c 100644 --- a/typing/typemod.mli +++ b/typing/typemod.mli @@ -68,7 +68,7 @@ val package_units: (* Should be in Envaux, but it breaks the build of the debugger *) val initial_env: - loc:Location.t -> safe_string:bool -> + loc:Location.t -> initially_opened_module:string option -> open_implicit_modules:string list -> Env.t diff --git a/utils/Makefile b/utils/Makefile index 352198ec12..b4273fb59e 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -76,8 +76,6 @@ config.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile $(call SUBST_STRING,RANLIBCMD) \ $(call SUBST_STRING,RPATH) \ $(call SUBST_STRING,MKSHAREDLIBRPATH) \ - $(call SUBST,FORCE_SAFE_STRING) \ - $(call SUBST,DEFAULT_SAFE_STRING) \ $(call SUBST,WINDOWS_UNICODE) \ $(call SUBST,NAKED_POINTERS) \ $(call SUBST,SUPPORTS_SHARED_LIBRARIES) \ diff --git a/utils/clflags.ml b/utils/clflags.ml index af4edc0e6c..520a1da623 100644 --- a/utils/clflags.ml +++ b/utils/clflags.ml @@ -174,10 +174,6 @@ let with_runtime = ref true;; (* -with-runtime *) let keep_docs = ref false (* -keep-docs *) let keep_locs = ref true (* -keep-locs *) -let unsafe_string = - if Config.safe_string then ref false - else ref (not Config.default_safe_string) - (* -safe-string / -unsafe-string *) let classic_inlining = ref false (* -Oclassic *) let inlining_report = ref false (* -inlining-report *) diff --git a/utils/clflags.mli b/utils/clflags.mli index 5d9cb86312..08b2c5f095 100644 --- a/utils/clflags.mli +++ b/utils/clflags.mli @@ -193,7 +193,6 @@ val force_tmc : bool ref val force_slash : bool ref val keep_docs : bool ref val keep_locs : bool ref -val unsafe_string : bool ref val opaque : bool ref val profile_columns : Profile.column list ref val flambda_invariant_checks : bool ref diff --git a/utils/config.mli b/utils/config.mli index 4fc9d495d4..29f482d261 100644 --- a/utils/config.mli +++ b/utils/config.mli @@ -221,18 +221,6 @@ val profinfo_width : int (** How many bits are to be used in values' headers for profiling information *) -val safe_string: bool -(** Whether the compiler was configured with -force-safe-string; - in that case, the -unsafe-string compile-time option is unavailable - - @since 4.05.0 *) - -val default_safe_string: bool -(** Whether the compiler was configured to use the -safe-string - or -unsafe-string compile-time option by default. - - @since 4.06.0 *) - val flat_float_array : bool (** Whether the compiler and runtime automagically flatten float arrays *) diff --git a/utils/config.mlp b/utils/config.mlp index 7f927f1fe6..8deabaf112 100644 --- a/utils/config.mlp +++ b/utils/config.mlp @@ -81,8 +81,8 @@ let mkdll, mkexe, mkmaindll = let flambda = %%FLAMBDA%% let with_flambda_invariants = %%WITH_FLAMBDA_INVARIANTS%% let with_cmm_invariants = %%WITH_CMM_INVARIANTS%% -let safe_string = %%FORCE_SAFE_STRING%% -let default_safe_string = %%DEFAULT_SAFE_STRING%% +let safe_string = true +let default_safe_string = true let windows_unicode = %%WINDOWS_UNICODE%% != 0 let naked_pointers = %%NAKED_POINTERS%% let force_instrumented_runtime = %%FORCE_INSTRUMENTED_RUNTIME%% |