From b3ebb2f24f8af804d4eedde62af5b296cd6808d0 Mon Sep 17 00:00:00 2001 From: Stephane Glondu Date: Tue, 26 Jun 2012 07:25:56 +0200 Subject: [PATCH] Make the Debian-specific behaviour of -custom opt-in (Closes: #678577) --- debian/README.Debian | 7 +++-- ...tecode-in-C-object-when-using-custom.patch | 31 ++++++++++++------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/debian/README.Debian b/debian/README.Debian index 872a07a7..7a63ebce 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -6,9 +6,10 @@ be stripped (more precisely, the bytecode, which is not part of the ELF data, is removed by strip). This Debian version is patched (and the patch has been rejected by upstream [1], but is available separately in debian/patches) so that the bytecode is embedded in the -executable and can be stripped. The original behaviour is restored if -the OCAML_COMPAT environment variable contains the letter “c”. +executable and can be stripped. This new behaviour is optional, and +can be enabled by setting the OCAML_CUSTOM_EMBED environment variable +to “y”. [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=49;bug=256900 - -- Stéphane Glondu , Tue, 24 May 2011 12:02:51 +0200 + -- Stéphane Glondu , Tue, 26 Jun 2012 07:27:05 +0200 diff --git a/debian/patches/0011-Embed-bytecode-in-C-object-when-using-custom.patch b/debian/patches/0011-Embed-bytecode-in-C-object-when-using-custom.patch index 3f17f1d5..ccb5635d 100644 --- a/debian/patches/0011-Embed-bytecode-in-C-object-when-using-custom.patch +++ b/debian/patches/0011-Embed-bytecode-in-C-object-when-using-custom.patch @@ -3,19 +3,20 @@ Date: Sun, 17 Aug 2008 17:10:03 +0200 Subject: Embed bytecode in C object when using -custom This patch fixes non-strippability of bytecode executables linked with -custom runtime. Having "c" in OCAML_COMPAT environment variable -restores the original behaviour. +custom runtime. The new behaviour is enabled when OCAML_CUSTOM_EMBED +is set to "y", or when DEB_HOST_ARCH is non-empty. 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 +Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=678577 Signed-off-by: Stephane Glondu --- - bytecomp/bytelink.ml | 36 ++++++++++++++++++++++++++++++++---- - 1 files changed, 32 insertions(+), 4 deletions(-) + bytecomp/bytelink.ml | 42 ++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml -index 9d62fc6..a3aee28 100644 +index 9d62fc6..c6d558f 100644 --- a/bytecomp/bytelink.ml +++ b/bytecomp/bytelink.ml @@ -415,7 +415,7 @@ let mlvalues_primitives = [ @@ -57,23 +58,29 @@ index 9d62fc6..a3aee28 100644 \n#ifdef __cplusplus\ \n}\ \n#endif\n"; -@@ -501,6 +514,11 @@ let fix_exec_name name = +@@ -501,6 +514,17 @@ let fix_exec_name name = if String.contains name '.' then name else name ^ ".exe" | _ -> name -+(* Legacy custom behaviour (Debian-specific) *) ++(* Debian-specific -custom behaviour: ++ - if DEB_HOST_ARCH is non-empty, it is activated by default ++ - can be enabled/disabled by setting OCAML_CUSTOM_EMBED to y/n ++*) + -+let legacy_custom = -+ try String.contains (Sys.getenv "OCAML_COMPAT") 'c' with Not_found -> false ++let custom_embed = ++ try Sys.getenv "OCAML_CUSTOM_EMBED" = "y" ++ with Not_found -> ++ try Sys.getenv "DEB_HOST_ARCH" <> "" ++ 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 = +@@ -514,6 +538,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 legacy_custom && not !Clflags.output_c_object && not !Clflags.make_runtime then ++ else if custom_embed && 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; @@ -86,7 +93,7 @@ index 9d62fc6..a3aee28 100644 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 +580,7 @@ let link objfiles output_name = +@@ -552,7 +586,7 @@ let link objfiles output_name = if Sys.file_exists c_file then raise(Error(File_exists c_file)); let temps = ref [] in try -- 2.30.2