rename the configure-time safe-string options for clarity
-(un)safe-string becomes -(no-)force-safe-string -(un)safe-string-default becomes -default-unsafe-string Config.safe_string (and Clflags.unsafe_string) keep their name for backward-compatibility, as well as the C define CAML_SAFE_STRING (which corresponds to -force-safe-string).master
parent
6550a30719
commit
a202aa032b
19
Changes
19
Changes
|
@ -89,13 +89,18 @@ Release branch for 4.06:
|
|||
- GPR#1386: provide configure-time options to fine-tune the safe-string
|
||||
options and default settings changed by GPR#1525.
|
||||
|
||||
At configure-time, -safe-string forces all module to use immutable
|
||||
strings (this disables the per-module, compile-time -unsafe-string
|
||||
option). The new (un)safe-string-default options let you set the
|
||||
default choice for the per-module compile-time option. (The new
|
||||
GPR#1252 behavior corresponds to having -safe-string-default, while
|
||||
4.05 and older had -unsafe-string-default).
|
||||
(Gabriel Scherer, review by Jacques-Pascal Deplaix)
|
||||
The previous configure option -safe-string is now
|
||||
renamed -force-safe-string.
|
||||
|
||||
At configure-time, -force-safe-string forces all module to use
|
||||
immutable strings (this disables the per-file, compile-time
|
||||
-unsafe-string option). The new default-(un)safe-string options
|
||||
let you set the default choice for the per-file compile-time
|
||||
option. (The new GPR#1252 behavior corresponds to having
|
||||
-default-safe-string, while 4.05 and older had
|
||||
-default-unsafe-string).
|
||||
|
||||
(Gabriel Scherer, review by Jacques-Pascal Deplaix and Damien Doligez)
|
||||
|
||||
### Code generation and optimizations:
|
||||
|
||||
|
|
4
Makefile
4
Makefile
|
@ -343,8 +343,8 @@ utils/config.ml: utils/config.mlp config/Makefile
|
|||
-e 's|%%PROFILING%%|$(PROFILING)|' \
|
||||
-e 's|%%PROFINFO_WIDTH%%|$(PROFINFO_WIDTH)|' \
|
||||
-e 's|%%RANLIBCMD%%|$(RANLIBCMD)|' \
|
||||
-e 's|%%SAFE_STRING%%|$(SAFE_STRING)|' \
|
||||
-e 's|%%SAFE_STRING_DEFAULT%%|$(SAFE_STRING_DEFAULT)|' \
|
||||
-e 's|%%FORCE_SAFE_STRING%%|$(FORCE_SAFE_STRING)|' \
|
||||
-e 's|%%DEFAULT_SAFE_STRING%%|$(DEFAULT_SAFE_STRING)|' \
|
||||
-e 's|%%WINDOWS_UNICODE%%|$(WINDOWS_UNICODE)|' \
|
||||
-e 's|%%SYSTEM%%|$(SYSTEM)|' \
|
||||
-e 's|%%SYSTHREAD_SUPPORT%%|$(SYSTHREAD_SUPPORT)|' \
|
||||
|
|
|
@ -102,8 +102,8 @@ WITH_PROFINFO=false
|
|||
LIBUNWIND_AVAILABLE=false
|
||||
LIBUNWIND_LINK_FLAGS=
|
||||
PROFINFO_WIDTH=26
|
||||
SAFE_STRING=false
|
||||
SAFE_STRING_DEFAULT=true
|
||||
FORCE_SAFE_STRING=false
|
||||
DEFAULT_SAFE_STRING=true
|
||||
WINDOWS_UNICODE=1
|
||||
AFL_INSTRUMENT=false
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ WITH_SPACETIME_CALL_COUNTS=false
|
|||
LIBUNWIND_AVAILABLE=false
|
||||
LIBUNWIND_LINK_FLAGS=
|
||||
PROFINFO_WIDTH=26
|
||||
SAFE_STRING=false
|
||||
SAFE_STRING_DEFAULT=true
|
||||
FORCE_SAFE_STRING=false
|
||||
DEFAULT_SAFE_STRING=true
|
||||
WINDOWS_UNICODE=1
|
||||
AFL_INSTRUMENT=false
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ WITH_SPACETIME_CALL_COUNTS=false
|
|||
LIBUNWIND_AVAILABLE=false
|
||||
LIBUNWIND_LINK_FLAGS=
|
||||
PROFINFO_WIDTH=26
|
||||
SAFE_STRING=false
|
||||
SAFE_STRING_DEFAULT=true
|
||||
FORCE_SAFE_STRING=false
|
||||
DEFAULT_SAFE_STRING=true
|
||||
WINDOWS_UNICODE=1
|
||||
AFL_INSTRUMENT=false
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ WITH_SPACETIME_CALL_COUNTS=false
|
|||
LIBUNWIND_AVAILABLE=false
|
||||
LIBUNWIND_LINK_FLAGS=
|
||||
PROFINFO_WIDTH=26
|
||||
SAFE_STRING=false
|
||||
SAFE_STRING_DEFAULT=true
|
||||
FORCE_SAFE_STRING=false
|
||||
DEFAULT_SAFE_STRING=true
|
||||
WINDOWS_UNICODE=1
|
||||
AFL_INSTRUMENT=false
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ native_compiler=true
|
|||
TOOLPREF=""
|
||||
with_cfi=true
|
||||
flambda=false
|
||||
safe_string=false
|
||||
safe_string_default=true
|
||||
force_safe_string=false
|
||||
default_safe_string=true
|
||||
afl_instrument=false
|
||||
max_testsuite_dir_retries=0
|
||||
with_cplugins=false
|
||||
|
@ -215,36 +215,36 @@ while : ; do
|
|||
;; # Ignored for backward compatibility
|
||||
-fPIC|--fPIC)
|
||||
with_fpic=true;;
|
||||
# There are two configure-time string safety option,
|
||||
# (un)safe-string and (un)safe-string-default that interact
|
||||
# with a compile-time (un)safe-string option.
|
||||
|
||||
# There are two configure-time string safety options,
|
||||
# -(no-)force-safe-string and -default-(un)safe-string that
|
||||
# interact with a compile-time (un)safe-string option.
|
||||
#
|
||||
# If -safe-string is set at configure time, then the compiler will
|
||||
# always enforce that string and bytes are distinct: the
|
||||
# If -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 -safe-string is not set at configure-time (if its
|
||||
# negation -unsafe-string is used), the compiler will use the
|
||||
# compile-time (un)safe-string setting to decide whether string
|
||||
# and bytes are compatible on a per-module basis. The
|
||||
# configure-time options (un)safe-string-default decide which
|
||||
# setting will be chosen by default, if no compile-time option
|
||||
# is explicitly passed.
|
||||
# If -no-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
|
||||
# configure-time options default-(un)safe-string decide 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 -unsafe-string -unsafe-string-default.
|
||||
# then). OCaml 4.06 uses -unsafe-string -safe-string-default. We
|
||||
# expect -safe-string to become the default in the future.
|
||||
-safe-string|--safe-string)
|
||||
safe_string=true;;
|
||||
-unsafe-string|--unsafe-string)
|
||||
safe_string=false;;
|
||||
-safe-string-default|--safe-string-default)
|
||||
safe_string_default=true;;
|
||||
-unsafe-string-default|--unsafe-string-default)
|
||||
safe_string_default=false;;
|
||||
# The configure-time behavior of OCaml 4.05 and older was equivalent
|
||||
# to -no-force-safe-string -default-unsafe-string. OCaml 4.06
|
||||
# uses -no-force-safe-string -default-safe-string. We
|
||||
# expect -force-safe-string to become the default in the future.
|
||||
-force-safe-string|--force-safe-string)
|
||||
force_safe_string=true;;
|
||||
-no-force-safe-string|--no-force-safe-string)
|
||||
force_safe_string=false;;
|
||||
-default-safe-string|--default-safe-string)
|
||||
default_safe_string=true;;
|
||||
-default-unsafe-string|--default-unsafe-string)
|
||||
default_safe_string=false;;
|
||||
-flat-float-array|--flat-float-array)
|
||||
flat_float_array=true;;
|
||||
-no-flat-float-array|--no-flat-float-array)
|
||||
|
@ -2035,7 +2035,7 @@ if $with_fpic; then
|
|||
echo "#define CAML_WITH_FPIC" >> m.h
|
||||
fi
|
||||
|
||||
if $safe_string; then
|
||||
if $force_safe_string; then
|
||||
echo "#define CAML_SAFE_STRING" >> m.h
|
||||
fi
|
||||
|
||||
|
@ -2129,8 +2129,8 @@ if [ "$ostype" = Cygwin ]; then
|
|||
config DIFF "diff -q --strip-trailing-cr"
|
||||
fi
|
||||
config FLAMBDA "$flambda"
|
||||
config SAFE_STRING "$safe_string"
|
||||
config SAFE_STRING_DEFAULT "$safe_string_default"
|
||||
config FORCE_SAFE_STRING "$force_safe_string"
|
||||
config DEFAULT_SAFE_STRING "$default_safe_string"
|
||||
config WINDOWS_UNICODE "0"
|
||||
config AFL_INSTRUMENT "$afl_instrument"
|
||||
config MAX_TESTSUITE_DIR_RETRIES "$max_testsuite_dir_retries"
|
||||
|
@ -2251,15 +2251,15 @@ else
|
|||
else
|
||||
inf " using flambda middle-end . no"
|
||||
fi
|
||||
if $safe_string; then
|
||||
inf " safe strings ............. yes"
|
||||
if $force_safe_string; then
|
||||
inf " force safe strings ............. yes"
|
||||
else
|
||||
inf " safe strings ............. no"
|
||||
if $safe_string_default; then
|
||||
inf " (-safe-string is the default per-module option)"
|
||||
else
|
||||
inf " (-unsafe-string is the default per-module option)"
|
||||
fi
|
||||
inf " force safe strings ............. no"
|
||||
if $default_safe_string; then
|
||||
inf " (-safe-string is the default per-file option)"
|
||||
else
|
||||
inf " (-unsafe-string is the default per-file option)"
|
||||
fi
|
||||
fi
|
||||
if $flat_float_array; then
|
||||
inf " flat float arrays ........ yes"
|
||||
|
|
|
@ -429,7 +429,7 @@ let mk_S f =
|
|||
let mk_safe_string f =
|
||||
"-safe-string", Arg.Unit f,
|
||||
if Config.safe_string then " (was set when configuring the compiler)"
|
||||
else if Config.safe_string_default then " Make strings immutable (default)"
|
||||
else if Config.default_safe_string then " Make strings immutable (default)"
|
||||
else " Make strings immutable"
|
||||
;;
|
||||
|
||||
|
@ -499,11 +499,11 @@ let mk_unsafe f =
|
|||
let mk_unsafe_string f =
|
||||
if Config.safe_string then
|
||||
let err () =
|
||||
raise (Arg.Bad "OCaml has been configured with -safe-string: \
|
||||
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.safe_string_default then
|
||||
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)"
|
||||
|
|
|
@ -704,8 +704,8 @@ $\hbox{"string_length"}(v)-1$.
|
|||
or byte sequence \var{v}, with type "unsigned char". Bytes are
|
||||
numbered from 0 to $\hbox{"string_length"}(v)-1$.
|
||||
\item "String_val("\var{v}")" returns a pointer to the first byte of the string
|
||||
\var{v}, with type "char *" or, when OCaml is configured with "-safe-string",
|
||||
with type "const char *".
|
||||
\var{v}, with type "char *" or, when OCaml is configured with
|
||||
"-force-safe-string", with type "const char *".
|
||||
This pointer is a valid C string: there is a null byte after the last
|
||||
byte in the string. However, OCaml strings can contain embedded null bytes,
|
||||
which will confuse the usual C functions over strings.
|
||||
|
|
|
@ -158,7 +158,7 @@ ocamltest_config.ml: ocamltest_config.ml.in
|
|||
-e 's|@@OCAMLOPTDEFAULTFLAGS@@|$(ocamloptdefaultflags)|' \
|
||||
-e 's|@@OCAMLSRCDIR@@|$(ocamlsrcdir)|' \
|
||||
-e 's|@@FLAMBDA@@|$(FLAMBDA)|' \
|
||||
-e 's|@@SAFE_STRING@@|$(SAFE_STRING)|' \
|
||||
-e 's|@@FORCE_SAFE_STRING@@|$(FORCE_SAFE_STRING)|' \
|
||||
$< > $@
|
||||
|
||||
.PHONY: clean
|
||||
|
|
|
@ -26,4 +26,4 @@ let flambda = @@FLAMBDA@@
|
|||
let ocamlc_default_flags = "@@OCAMLCDEFAULTFLAGS@@"
|
||||
let ocamlopt_default_flags = "@@OCAMLOPTDEFAULTFLAGS@@"
|
||||
|
||||
let safe_string = @@SAFE_STRING@@
|
||||
let safe_string = @@FORCE_SAFE_STRING@@
|
||||
|
|
|
@ -2346,7 +2346,7 @@ let report_error ppf = function
|
|||
fprintf ppf
|
||||
"@[<hov>Unit %s imports from %s, compiled with -unsafe-string.@ %s@]"
|
||||
export import "This compiler has been configured in strict \
|
||||
-safe-string mode"
|
||||
safe-string mode (-force-safe-string)"
|
||||
| Missing_module(_, path1, path2) ->
|
||||
fprintf ppf "@[@[<hov>";
|
||||
if Path.same path1 path2 then
|
||||
|
|
|
@ -160,7 +160,7 @@ 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.safe_string_default)
|
||||
else ref (not Config.default_safe_string)
|
||||
(* -safe-string / -unsafe-string *)
|
||||
|
||||
let classic_inlining = ref false (* -Oclassic *)
|
||||
|
|
|
@ -166,11 +166,15 @@ val libunwind_link_flags : string
|
|||
(* Linker flags to use libunwind *)
|
||||
|
||||
val safe_string: bool
|
||||
(* Whether the compiler was configured with -safe-string;
|
||||
in that case, the -unsafe-string compile-time option is unavailable *)
|
||||
val safe_string_default: 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. *)
|
||||
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 *)
|
||||
|
|
|
@ -63,8 +63,8 @@ let mkdll, mkexe, mkmaindll =
|
|||
|
||||
let profiling = %%PROFILING%%
|
||||
let flambda = %%FLAMBDA%%
|
||||
let safe_string = %%SAFE_STRING%%
|
||||
let safe_string_default = %%SAFE_STRING_DEFAULT%%
|
||||
let safe_string = %%FORCE_SAFE_STRING%%
|
||||
let default_safe_string = %%DEFAULT_SAFE_STRING%%
|
||||
let windows_unicode = %%WINDOWS_UNICODE%% != 0
|
||||
|
||||
let flat_float_array = %%FLAT_FLOAT_ARRAY%%
|
||||
|
@ -176,7 +176,7 @@ let print_config oc =
|
|||
p_bool "flambda" flambda;
|
||||
p_bool "spacetime" spacetime;
|
||||
p_bool "safe_string" safe_string;
|
||||
p_bool "safe_string_default" safe_string_default;
|
||||
p_bool "default_safe_string" default_safe_string;
|
||||
p_bool "flat_float_array" flat_float_array;
|
||||
p_bool "windows_unicode" windows_unicode;
|
||||
|
||||
|
|
Loading…
Reference in New Issue