summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--Makefile.nt1
-rw-r--r--config/Makefile.mingw1
-rw-r--r--config/Makefile.mingw641
-rw-r--r--config/Makefile.msvc1
-rw-r--r--config/Makefile.msvc641
-rwxr-xr-xconfigure9
-rw-r--r--driver/main_args.ml13
-rw-r--r--utils/clflags.ml2
-rw-r--r--utils/config.mli3
-rw-r--r--utils/config.mlp1
11 files changed, 31 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 34a4fd2dbf..f8077975af 100644
--- a/Makefile
+++ b/Makefile
@@ -430,6 +430,7 @@ utils/config.ml: utils/config.mlp config/Makefile
-e 's|%%HOST%%|$(HOST)|' \
-e 's|%%TARGET%%|$(TARGET)|' \
-e 's|%%FLAMBDA%%|$(FLAMBDA)|' \
+ -e 's|%%SAFE_STRING%%|$(SAFE_STRING)|' \
utils/config.mlp > utils/config.ml
partialclean::
diff --git a/Makefile.nt b/Makefile.nt
index da320c0641..d6f6dc06c8 100644
--- a/Makefile.nt
+++ b/Makefile.nt
@@ -404,6 +404,7 @@ utils/config.ml: utils/config.mlp config/Makefile
-e 's|%%HOST%%|$(HOST)|' \
-e 's|%%TARGET%%|$(TARGET)|' \
-e 's|%%FLAMBDA%%|$(FLAMBDA)|' \
+ -e 's|%%SAFE_STRING%%|$(SAFE_STRING)|' \
-e 's|%%FLEXLINK_FLAGS%%|$(FLEXLINK_FLAGS)|' \
utils/config.mlp > utils/config.ml
diff --git a/config/Makefile.mingw b/config/Makefile.mingw
index beac6a4b78..3f321e2d9e 100644
--- a/config/Makefile.mingw
+++ b/config/Makefile.mingw
@@ -86,6 +86,7 @@ ASM_CFI_SUPPORTED=false
UNIXLIB=win32unix
GRAPHLIB=win32graph
FLAMBDA=false
+SAFE_STRING=false
########## Configuration for the bytecode compiler
diff --git a/config/Makefile.mingw64 b/config/Makefile.mingw64
index af9332c8ca..3ec8b432e3 100644
--- a/config/Makefile.mingw64
+++ b/config/Makefile.mingw64
@@ -86,6 +86,7 @@ ASM_CFI_SUPPORTED=false
UNIXLIB=win32unix
GRAPHLIB=win32graph
FLAMBDA=false
+SAFE_STRING=false
########## Configuration for the bytecode compiler
diff --git a/config/Makefile.msvc b/config/Makefile.msvc
index 32fd1a510c..bc84ff721b 100644
--- a/config/Makefile.msvc
+++ b/config/Makefile.msvc
@@ -80,6 +80,7 @@ ASM_CFI_SUPPORTED=false
UNIXLIB=win32unix
GRAPHLIB=win32graph
FLAMBDA=false
+SAFE_STRING=false
########## Configuration for the bytecode compiler
diff --git a/config/Makefile.msvc64 b/config/Makefile.msvc64
index 147d05f28f..bc965b3287 100644
--- a/config/Makefile.msvc64
+++ b/config/Makefile.msvc64
@@ -79,6 +79,7 @@ ASM_CFI_SUPPORTED=false
UNIXLIB=win32unix
GRAPHLIB=win32graph
FLAMBDA=false
+SAFE_STRING=false
########## Configuration for the bytecode compiler
diff --git a/configure b/configure
index cb1362df62..0e6376e5f6 100755
--- a/configure
+++ b/configure
@@ -53,6 +53,7 @@ native_compiler=true
TOOLPREF=""
with_cfi=true
flambda=false
+safe_string=false
max_testsuite_dir_retries=0
with_cplugins=true
with_fpic=false
@@ -173,6 +174,8 @@ while : ; do
with_cplugins=false;;
-fPIC|--fPIC)
with_fpic=true;;
+ -safe-string|--safe-string)
+ safe_string=true;;
*) if echo "$1" | grep -q -e '^--\?[a-zA-Z0-9-]\+='; then
err "configure expects arguments of the form '-prefix /foo/bar'," \
"not '-prefix=/foo/bar' (note the '=')."
@@ -1851,6 +1854,7 @@ if [ "$ostype" = Cygwin ]; then
echo "DIFF=diff -q --strip-trailing-cr" >>Makefile
fi
echo "FLAMBDA=$flambda" >> Makefile
+echo "SAFE_STRING=$safe_string" >> Makefile
echo "MAX_TESTSUITE_DIR_RETRIES=$max_testsuite_dir_retries" >> Makefile
@@ -1935,6 +1939,11 @@ else
else
inf " using flambda middle-end . no"
fi
+ if test "$safe_string" = "true"; then
+ inf " safe strings ............. yes"
+ else
+ inf " safe strings ............. no"
+ fi
fi
if test "$with_debugger" = "ocamldebugger"; then
diff --git a/driver/main_args.ml b/driver/main_args.ml
index 35f91b4358..efefdddc62 100644
--- a/driver/main_args.ml
+++ b/driver/main_args.ml
@@ -423,7 +423,9 @@ let mk_S f =
;;
let mk_safe_string f =
- "-safe-string", Arg.Unit f, " Make strings immutable"
+ "-safe-string", Arg.Unit f,
+ if Config.safe_string then " Make strings immutable (default)"
+ else " Make strings immutable"
;;
let mk_shared f =
@@ -476,7 +478,14 @@ let mk_unsafe f =
;;
let mk_unsafe_string f =
- "-unsafe-string", Arg.Unit f, " Make strings mutable (default)"
+ if Config.safe_string then
+ let err () =
+ raise (Arg.Bad "OCaml has been configured with -safe-string: \
+ -unsafe-string is not available")
+ in
+ "-unsafe-string", Arg.Unit err, " (option not available)"
+ else
+ "-unsafe-string", Arg.Unit f, " Make strings mutable (default)"
;;
let mk_use_runtime f =
diff --git a/utils/clflags.ml b/utils/clflags.ml
index da61d8ed53..b43c52e0da 100644
--- a/utils/clflags.ml
+++ b/utils/clflags.ml
@@ -153,7 +153,7 @@ let runtime_variant = ref "";; (* -runtime-variant *)
let keep_docs = ref false (* -keep-docs *)
let keep_locs = ref false (* -keep-locs *)
-let unsafe_string = ref true;; (* -safe-string / -unsafe-string *)
+let unsafe_string = ref (not Config.safe_string) (* -safe-string / -unsafe-string *)
let classic_inlining = ref false (* -Oclassic *)
let inlining_report = ref false (* -inlining-report *)
diff --git a/utils/config.mli b/utils/config.mli
index c8feca6a39..7a9c0aab46 100644
--- a/utils/config.mli
+++ b/utils/config.mli
@@ -138,3 +138,6 @@ val print_config : out_channel -> unit;;
val flambda : bool
(* Whether the compiler was configured for flambda *)
+
+val safe_string: bool
+ (* Whether the compiler was configured with -safe-string *)
diff --git a/utils/config.mlp b/utils/config.mlp
index 5b91740012..1f918fe221 100644
--- a/utils/config.mlp
+++ b/utils/config.mlp
@@ -68,6 +68,7 @@ let mkdll, mkexe, mkmaindll =
"%%MKDLL%%", "%%MKEXE%%", "%%MKMAINDLL%%"
let flambda = %%FLAMBDA%%
+let safe_string = %%SAFE_STRING%%
let exec_magic_number = "Caml1999X011"
and cmi_magic_number = "Caml1999I020"