+++ /dev/null
-From: Stephane Glondu <steph@glondu.net>
-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.
-
-Forwarded: not-needed
-Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900
-Signed-off-by: Stephane Glondu <steph@glondu.net>
----
- bytecomp/bytelink.ml | 33 ++++++++++++++++++++++++++++-----
- 1 files changed, 28 insertions(+), 5 deletions(-)
-
-diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
-index 4a6426d..e74a67d 100644
---- a/bytecomp/bytelink.ml
-+++ b/bytecomp/bytelink.ml
-@@ -402,7 +402,7 @@ let output_cds_file outfile =
-
- (* Output a bytecode executable as a C file *)
-
--let link_bytecode_as_c tolink outfile =
-+let link_bytecode_as_c tolink outfile with_main =
- let outchan = open_out outfile in
- begin try
- (* The bytecode *)
-@@ -444,17 +444,30 @@ CAMLextern void caml_startup_code(\n\
- (* The table of primitives *)
- Symtable.output_primitive_table outchan;
- (* The entry point *)
-- output_string outchan "\n\
-+ if with_main then begin
-+ output_string outchan "\n\
-+int main(int argc, char **argv)\n\
-+{\n\
-+ caml_startup_code(caml_code, sizeof(caml_code),\n\
-+ caml_data, sizeof(caml_data),\n\
-+ caml_sections, sizeof(caml_sections),\n\
-+ argv);\n\
-+ return 0; /* not reached */\n\
-+}\n"
-+ end else begin
-+ output_string outchan "\n\
- void caml_startup(char ** argv)\n\
- {\n\
- caml_startup_code(caml_code, sizeof(caml_code),\n\
- caml_data, sizeof(caml_data),\n\
- caml_sections, sizeof(caml_sections),\n\
- argv);\n\
--}\n\
-+}\n"
-+ end;
-+ output_string outchan "\
- #ifdef __cplusplus\n\
- }\n\
--#endif\n";
-+#endif\n"
- close_out outchan
- with x ->
- close_out outchan;
-@@ -501,6 +514,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
-+ let c_file = Filename.temp_file "camlobj" ".c" in
-+ try
-+ link_bytecode_as_c tolink c_file true;
-+ let exec_name = fix_exec_name output_name in
-+ if not (build_custom_runtime c_file exec_name)
-+ then raise(Error Custom_runtime);
-+ with x ->
-+ remove_file c_file;
-+ raise x
- 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
-@@ -539,7 +562,7 @@ let link objfiles output_name =
- if Sys.file_exists c_file then raise(Error(File_exists c_file));
- let temps = ref [] in
- try
-- link_bytecode_as_c tolink c_file;
-+ link_bytecode_as_c tolink c_file false;
- if not (Filename.check_suffix output_name ".c") then begin
- temps := c_file :: !temps;
- if Ccomp.compile_file c_file <> 0 then raise(Error Custom_runtime);
---
--- /dev/null
+From: Stephane Glondu <steph@glondu.net>
+Date: Sat, 16 Apr 2011 23:41:23 +0200
+Subject: Natdynlink works on powerpc and hurd-i386
+
+Rationale: ssreflect used to work with natdynlink on powerpc and hurd
+with ocaml 3.11.2 / coq 8.2...
+
+Note: there is no native compiler for powerpc64! This must be a
+typo...
+
+Signed-off-by: Stephane Glondu <steph@glondu.net>
+---
+ configure | 3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/configure b/configure
+index 7a34621..32e8d2e 100755
+--- a/configure
++++ b/configure
+@@ -619,13 +619,14 @@ if test $withsharedlibs = "yes"; then
+ case "$host" in
+ *-*-cygwin*) natdynlink=true;;
+ i[3456]86-*-linux*) natdynlink=true;;
++ i[3456]86-*-gnu*) natdynlink=true;;
+ x86_64-*-linux*) natdynlink=true;;
+ i[3456]86-*-darwin10.*)
+ if test $arch64 == true; then
+ natdynlink=true
+ fi;;
+ i[3456]86-*-darwin[89]*) natdynlink=true;;
+- powerpc64-*-linux*) natdynlink=true;;
++ powerpc-*-linux*) natdynlink=true;;
+ sparc-*-linux*) natdynlink=true;;
+ i686-*-kfreebsd*) natdynlink=true;;
+ x86_64-*-kfreebsd*) natdynlink=true;;
+--
--- /dev/null
+From: Stephane Glondu <steph@glondu.net>
+Date: Thu, 21 Apr 2011 18:39:57 +0200
+Subject: Declare primitive name table as const char *
+
+This avoids lots of warnings when compiling with g++...
+
+Signed-off-by: Stephane Glondu <steph@glondu.net>
+---
+ bytecomp/symtable.ml | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/bytecomp/symtable.ml b/bytecomp/symtable.ml
+index d6ecc94..37def29 100644
+--- a/bytecomp/symtable.ml
++++ b/bytecomp/symtable.ml
+@@ -123,7 +123,7 @@ let output_primitive_table outchan =
+ fprintf outchan " %s,\n" prim.(i)
+ done;
+ fprintf outchan " (primitive) 0 };\n";
+- fprintf outchan "char * caml_names_of_builtin_cprim[] = {\n";
++ fprintf outchan "const char * caml_names_of_builtin_cprim[] = {\n";
+ for i = 0 to Array.length prim - 1 do
+ fprintf outchan " \"%s\",\n" prim.(i)
+ done;
+--
+++ /dev/null
-From: Stephane Glondu <steph@glondu.net>
-Date: Sat, 16 Apr 2011 23:41:23 +0200
-Subject: Natdynlink works on powerpc and hurd-i386
-
-Rationale: ssreflect used to work with natdynlink on powerpc and hurd
-with ocaml 3.11.2 / coq 8.2...
-
-Note: there is no native compiler for powerpc64! This must be a
-typo...
-
-Signed-off-by: Stephane Glondu <steph@glondu.net>
----
- configure | 3 ++-
- 1 files changed, 2 insertions(+), 1 deletions(-)
-
-diff --git a/configure b/configure
-index 7a34621..32e8d2e 100755
---- a/configure
-+++ b/configure
-@@ -619,13 +619,14 @@ if test $withsharedlibs = "yes"; then
- case "$host" in
- *-*-cygwin*) natdynlink=true;;
- i[3456]86-*-linux*) natdynlink=true;;
-+ i[3456]86-*-gnu*) natdynlink=true;;
- x86_64-*-linux*) natdynlink=true;;
- i[3456]86-*-darwin10.*)
- if test $arch64 == true; then
- natdynlink=true
- fi;;
- i[3456]86-*-darwin[89]*) natdynlink=true;;
-- powerpc64-*-linux*) natdynlink=true;;
-+ powerpc-*-linux*) natdynlink=true;;
- sparc-*-linux*) natdynlink=true;;
- i686-*-kfreebsd*) natdynlink=true;;
- x86_64-*-kfreebsd*) natdynlink=true;;
---
--- /dev/null
+From: Stephane Glondu <steph@glondu.net>
+Date: Thu, 21 Apr 2011 18:39:31 +0200
+Subject: Avoid multiple declarations in generated .c files in -output-obj
+
+In -output-obj mode, <caml/mlvalues.h> (which contains some
+primitives) is included in the generated .c file, leading to errors
+when compiling with g++ (multiple declarations).
+
+There are probably better implementations (in particular, in this one,
+care must be taken when changing the list of primitives available in
+mlvalues.h), but this is a small and (not too) intrusive patch.
+
+Signed-off-by: Stephane Glondu <steph@glondu.net>
+---
+ bytecomp/bytelink.ml | 17 +++++++++++++++--
+ bytecomp/symtable.ml | 8 +++++---
+ bytecomp/symtable.mli | 2 +-
+ 3 files changed, 21 insertions(+), 6 deletions(-)
+
+diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
+index 4a6426d..47903c4 100644
+--- a/bytecomp/bytelink.ml
++++ b/bytecomp/bytelink.ml
+@@ -400,6 +400,19 @@ let output_cds_file outfile =
+ remove_file outfile;
+ raise x
+
++(* List of primitives declared in caml/mlvalues.h, to avoid duplicate
++ declarations in generated .c files *)
++
++let mlvalues_primitives = [
++ "caml_get_public_method";
++ "caml_hash_variant";
++ "caml_string_length";
++ "caml_Double_val";
++ "caml_Store_double_val";
++ "caml_Int64_val";
++ "caml_atom_table";
++]
++
+ (* Output a bytecode executable as a C file *)
+
+ let link_bytecode_as_c tolink outfile =
+@@ -442,7 +455,7 @@ CAMLextern void caml_startup_code(\n\
+ (Marshal.to_string sections []);
+ output_string outchan "\n};\n\n";
+ (* The table of primitives *)
+- Symtable.output_primitive_table outchan;
++ Symtable.output_primitive_table outchan mlvalues_primitives;
+ (* The entry point *)
+ output_string outchan "\n\
+ void caml_startup(char ** argv)\n\
+@@ -516,7 +529,7 @@ let link objfiles output_name =
+ #else\n\
+ typedef long value;\n\
+ #endif\n";
+- Symtable.output_primitive_table poc;
++ Symtable.output_primitive_table poc [];
+ output_string poc "\
+ #ifdef __cplusplus\n\
+ }\n\
+diff --git a/bytecomp/symtable.ml b/bytecomp/symtable.ml
+index 37def29..70958ee 100644
+--- a/bytecomp/symtable.ml
++++ b/bytecomp/symtable.ml
+@@ -112,15 +112,17 @@ let output_primitive_names outchan =
+
+ open Printf
+
+-let output_primitive_table outchan =
++let output_primitive_table outchan blacklist =
+ let prim = all_primitives() in
+ for i = 0 to Array.length prim - 1 do
+- fprintf outchan "extern value %s();\n" prim.(i)
++ let p = prim.(i) in
++ if not (List.mem p blacklist) then
++ fprintf outchan "extern value %s();\n" p
+ done;
+ fprintf outchan "typedef value (*primitive)();\n";
+ fprintf outchan "primitive caml_builtin_cprim[] = {\n";
+ for i = 0 to Array.length prim - 1 do
+- fprintf outchan " %s,\n" prim.(i)
++ fprintf outchan " (primitive)%s,\n" prim.(i)
+ done;
+ fprintf outchan " (primitive) 0 };\n";
+ fprintf outchan "const char * caml_names_of_builtin_cprim[] = {\n";
+diff --git a/bytecomp/symtable.mli b/bytecomp/symtable.mli
+index 2b1583f..316381e 100644
+--- a/bytecomp/symtable.mli
++++ b/bytecomp/symtable.mli
+@@ -24,7 +24,7 @@ val require_primitive: string -> unit
+ val initial_global_table: unit -> Obj.t array
+ val output_global_map: out_channel -> unit
+ val output_primitive_names: out_channel -> unit
+-val output_primitive_table: out_channel -> unit
++val output_primitive_table: out_channel -> string list -> unit
+ val data_global_map: unit -> Obj.t
+ val data_primitive_names: unit -> string
+
+--
+++ /dev/null
-From: Stephane Glondu <steph@glondu.net>
-Date: Thu, 21 Apr 2011 18:39:57 +0200
-Subject: Declare primitive name table as const char *
-
-This avoids lots of warnings when compiling with g++...
-
-Signed-off-by: Stephane Glondu <steph@glondu.net>
----
- bytecomp/symtable.ml | 2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/bytecomp/symtable.ml b/bytecomp/symtable.ml
-index d6ecc94..37def29 100644
---- a/bytecomp/symtable.ml
-+++ b/bytecomp/symtable.ml
-@@ -123,7 +123,7 @@ let output_primitive_table outchan =
- fprintf outchan " %s,\n" prim.(i)
- done;
- fprintf outchan " (primitive) 0 };\n";
-- fprintf outchan "char * caml_names_of_builtin_cprim[] = {\n";
-+ fprintf outchan "const char * caml_names_of_builtin_cprim[] = {\n";
- for i = 0 to Array.length prim - 1 do
- fprintf outchan " \"%s\",\n" prim.(i)
- done;
---
+++ /dev/null
-From: Stephane Glondu <steph@glondu.net>
-Date: Thu, 21 Apr 2011 18:39:31 +0200
-Subject: Avoid multiple declarations in generated .c files in -output-obj
-
-In -output-obj mode, <caml/mlvalues.h> (which contains some
-primitives) is included in the generated .c file, leading to errors
-when compiling with g++ (multiple declarations).
-
-There are probably better implementations (in particular, in this one,
-care must be taken when changing the list of primitives available in
-mlvalues.h), but this is a small and (not too) intrusive patch.
-
-Signed-off-by: Stephane Glondu <steph@glondu.net>
----
- bytecomp/bytelink.ml | 17 +++++++++++++++--
- bytecomp/symtable.ml | 8 +++++---
- bytecomp/symtable.mli | 2 +-
- 3 files changed, 21 insertions(+), 6 deletions(-)
-
-diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
-index e74a67d..09689be 100644
---- a/bytecomp/bytelink.ml
-+++ b/bytecomp/bytelink.ml
-@@ -400,6 +400,19 @@ let output_cds_file outfile =
- remove_file outfile;
- raise x
-
-+(* List of primitives declared in caml/mlvalues.h, to avoid duplicate
-+ declarations in generated .c files *)
-+
-+let mlvalues_primitives = [
-+ "caml_get_public_method";
-+ "caml_hash_variant";
-+ "caml_string_length";
-+ "caml_Double_val";
-+ "caml_Store_double_val";
-+ "caml_Int64_val";
-+ "caml_atom_table";
-+]
-+
- (* Output a bytecode executable as a C file *)
-
- let link_bytecode_as_c tolink outfile with_main =
-@@ -442,7 +455,7 @@ CAMLextern void caml_startup_code(\n\
- (Marshal.to_string sections []);
- output_string outchan "\n};\n\n";
- (* The table of primitives *)
-- Symtable.output_primitive_table outchan;
-+ Symtable.output_primitive_table outchan mlvalues_primitives;
- (* The entry point *)
- if with_main then begin
- output_string outchan "\n\
-@@ -539,7 +552,7 @@ let link objfiles output_name =
- #else\n\
- typedef long value;\n\
- #endif\n";
-- Symtable.output_primitive_table poc;
-+ Symtable.output_primitive_table poc [];
- output_string poc "\
- #ifdef __cplusplus\n\
- }\n\
-diff --git a/bytecomp/symtable.ml b/bytecomp/symtable.ml
-index 37def29..70958ee 100644
---- a/bytecomp/symtable.ml
-+++ b/bytecomp/symtable.ml
-@@ -112,15 +112,17 @@ let output_primitive_names outchan =
-
- open Printf
-
--let output_primitive_table outchan =
-+let output_primitive_table outchan blacklist =
- let prim = all_primitives() in
- for i = 0 to Array.length prim - 1 do
-- fprintf outchan "extern value %s();\n" prim.(i)
-+ let p = prim.(i) in
-+ if not (List.mem p blacklist) then
-+ fprintf outchan "extern value %s();\n" p
- done;
- fprintf outchan "typedef value (*primitive)();\n";
- fprintf outchan "primitive caml_builtin_cprim[] = {\n";
- for i = 0 to Array.length prim - 1 do
-- fprintf outchan " %s,\n" prim.(i)
-+ fprintf outchan " (primitive)%s,\n" prim.(i)
- done;
- fprintf outchan " (primitive) 0 };\n";
- fprintf outchan "const char * caml_names_of_builtin_cprim[] = {\n";
-diff --git a/bytecomp/symtable.mli b/bytecomp/symtable.mli
-index 2b1583f..316381e 100644
---- a/bytecomp/symtable.mli
-+++ b/bytecomp/symtable.mli
-@@ -24,7 +24,7 @@ val require_primitive: string -> unit
- val initial_global_table: unit -> Obj.t array
- val output_global_map: out_channel -> unit
- val output_primitive_names: out_channel -> unit
--val output_primitive_table: out_channel -> unit
-+val output_primitive_table: out_channel -> string list -> unit
- val data_global_map: unit -> Obj.t
- val data_primitive_names: unit -> string
-
---
--- /dev/null
+From: Stephane Glondu <steph@glondu.net>
+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.
+
+Forwarded: not-needed
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900
+Signed-off-by: Stephane Glondu <steph@glondu.net>
+---
+ bytecomp/bytelink.ml | 33 ++++++++++++++++++++++++++++-----
+ 1 files changed, 28 insertions(+), 5 deletions(-)
+
+diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
+index 47903c4..09689be 100644
+--- a/bytecomp/bytelink.ml
++++ b/bytecomp/bytelink.ml
+@@ -415,7 +415,7 @@ let mlvalues_primitives = [
+
+ (* Output a bytecode executable as a C file *)
+
+-let link_bytecode_as_c tolink outfile =
++let link_bytecode_as_c tolink outfile with_main =
+ let outchan = open_out outfile in
+ begin try
+ (* The bytecode *)
+@@ -457,17 +457,30 @@ CAMLextern void caml_startup_code(\n\
+ (* The table of primitives *)
+ Symtable.output_primitive_table outchan mlvalues_primitives;
+ (* The entry point *)
+- output_string outchan "\n\
++ if with_main then begin
++ output_string outchan "\n\
++int main(int argc, char **argv)\n\
++{\n\
++ caml_startup_code(caml_code, sizeof(caml_code),\n\
++ caml_data, sizeof(caml_data),\n\
++ caml_sections, sizeof(caml_sections),\n\
++ argv);\n\
++ return 0; /* not reached */\n\
++}\n"
++ end else begin
++ output_string outchan "\n\
+ void caml_startup(char ** argv)\n\
+ {\n\
+ caml_startup_code(caml_code, sizeof(caml_code),\n\
+ caml_data, sizeof(caml_data),\n\
+ caml_sections, sizeof(caml_sections),\n\
+ argv);\n\
+-}\n\
++}\n"
++ end;
++ output_string outchan "\
+ #ifdef __cplusplus\n\
+ }\n\
+-#endif\n";
++#endif\n"
+ close_out outchan
+ with x ->
+ close_out outchan;
+@@ -514,6 +527,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
++ let c_file = Filename.temp_file "camlobj" ".c" in
++ try
++ link_bytecode_as_c tolink c_file true;
++ let exec_name = fix_exec_name output_name in
++ if not (build_custom_runtime c_file exec_name)
++ then raise(Error Custom_runtime);
++ with x ->
++ remove_file c_file;
++ raise x
+ 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 =
+ if Sys.file_exists c_file then raise(Error(File_exists c_file));
+ let temps = ref [] in
+ try
+- link_bytecode_as_c tolink c_file;
++ link_bytecode_as_c tolink c_file false;
+ if not (Filename.check_suffix output_name ".c") then begin
+ temps := c_file :: !temps;
+ if Ccomp.compile_file c_file <> 0 then raise(Error Custom_runtime);
+--
0005-Patch-config.sh-for-installation.patch
0006-Install-ocamlbuild-as-a-link-on-either-.native-or-.b.patch
0007-Fix-ocamlopt-w.r.t.-binutils-2.21.patch
-0008-Embed-bytecode-in-C-object-when-using-custom.patch
-0009-Natdynlink-works-on-powerpc-and-hurd-i386.patch
-0010-Declare-primitive-name-table-as-const-char.patch
-0011-Avoid-multiple-declarations-in-generated-.c-files-in.patch
+0008-Natdynlink-works-on-powerpc-and-hurd-i386.patch
+0009-Declare-primitive-name-table-as-const-char.patch
+0010-Avoid-multiple-declarations-in-generated-.c-files-in.patch
+0011-Embed-bytecode-in-C-object-when-using-custom.patch