Subject: Embed bytecode in C object when using -custom
This patch fixes non-strippability of bytecode executables linked with
-custom runtime.
+custom runtime. Having "c" in OCAML_COMPAT environment variable
+restores the original behaviour.
Forwarded: not-needed
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=627761
Signed-off-by: Stephane Glondu <steph@glondu.net>
---
- bytecomp/bytelink.ml | 31 +++++++++++++++++++++++++++----
- 1 files changed, 27 insertions(+), 4 deletions(-)
+ bytecomp/bytelink.ml | 36 ++++++++++++++++++++++++++++++++----
+ 1 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
-index 47903c4..184079c 100644
+index 47903c4..e63dd3b 100644
--- a/bytecomp/bytelink.ml
+++ b/bytecomp/bytelink.ml
@@ -415,7 +415,7 @@ let mlvalues_primitives = [
#ifdef __cplusplus\n\
}\n\
#endif\n";
-@@ -514,6 +527,16 @@ let link objfiles output_name =
+@@ -501,6 +514,11 @@ let fix_exec_name name =
+ if String.contains name '.' then name else name ^ ".exe"
+ | _ -> name
+
++(* Legacy custom behaviour (Debian-specific) *)
++
++let legacy_custom =
++ try String.contains (Sys.getenv "OCAML_COMPAT") 'c' with Not_found -> false
++
+ (* Main entry point (build a custom runtime if needed) *)
+
+ let link objfiles output_name =
+@@ -514,6 +532,16 @@ let link objfiles output_name =
Clflags.dllibs := !lib_dllibs @ !Clflags.dllibs; (* put user's DLLs first *)
if not !Clflags.custom_runtime then
link_bytecode tolink output_name true
-+ else if not !Clflags.output_c_object && not !Clflags.make_runtime then
++ else if not legacy_custom && not !Clflags.output_c_object && not !Clflags.make_runtime then
+ let c_file = Filename.temp_file "camlobj" ".c" in
+ try
+ link_bytecode_as_c tolink c_file true;
else if not !Clflags.output_c_object then begin
let bytecode_name = Filename.temp_file "camlcode" "" in
let prim_name = Filename.temp_file "camlprim" ".c" in
-@@ -552,7 +575,7 @@ let link objfiles output_name =
+@@ -552,7 +580,7 @@ let link objfiles output_name =
if Sys.file_exists c_file then raise(Error(File_exists c_file));
let temps = ref [] in
try