diff --git a/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch b/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch new file mode 100644 index 0000000..166e69a --- /dev/null +++ b/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch @@ -0,0 +1,192 @@ +From 2912ed4fde14e34b58c482cb81fb88676ab3ffc2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= +Date: Wed, 27 Apr 2022 14:46:47 +0200 +Subject: [PATCH 01/24] Do not trigger warning when calling virtual methods + introduced by constraining "self" (#11204) + +(cherry picked from commit 1e7af3f6261502bb384dc9e23a74ad0990bfd854) +--- + Changes | 11 ++++++- + testsuite/tests/typing-objects/Tests.ml | 15 ++++++++++ + typing/typeclass.ml | 40 ++++++++++--------------- + 3 files changed, 40 insertions(+), 26 deletions(-) + +diff --git a/Changes b/Changes +index a8ce94bdc6..931a74b8d1 100644 +--- a/Changes ++++ b/Changes +@@ -1,3 +1,13 @@ ++OCaml 4.14 maintenance branch ++----------------------------- ++ ++### Bug fixes: ++ ++- #11204: Fix regression introduced in 4.14.0 that would trigger Warning 17 when ++ calling virtual methods introduced by constraining the self type from within ++ the class definition. ++ (Nicolás Ojeda Bär, review by Leo White) ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +@@ -62,7 +72,6 @@ OCaml 4.14.0 (28 March 2022) + definition-aware operations. + (Ulysse Gérard, Thomas Refis and Leo White, review by Florian Angeletti) + +- + ### Language features: + + - #10462: Add attribute to produce a compiler error for polls. +diff --git a/testsuite/tests/typing-objects/Tests.ml b/testsuite/tests/typing-objects/Tests.ml +index f617bcf1b9..3dcd87c43c 100644 +--- a/testsuite/tests/typing-objects/Tests.ml ++++ b/testsuite/tests/typing-objects/Tests.ml +@@ -955,6 +955,21 @@ Warning 17 [undeclared-virtual-method]: the virtual method m is not declared. + class c : object method m : int method n : int end + |}];; + ++class virtual c = object (self : 'c) ++ constraint 'c = < f : int; .. > ++end ++[%%expect {| ++class virtual c : object method virtual f : int end ++|}];; ++ ++class virtual c = object (self : 'c) ++ constraint 'c = < f : int; .. > ++ method g = self # f ++end ++[%%expect {| ++class virtual c : object method virtual f : int method g : int end ++|}];; ++ + class [ 'a ] c = object (_ : 'a) end;; + let o = object + method m = 1 +diff --git a/typing/typeclass.ml b/typing/typeclass.ml +index 048ee998b0..fedbc0e025 100644 +--- a/typing/typeclass.ml ++++ b/typing/typeclass.ml +@@ -552,12 +552,11 @@ type first_pass_accummulater = + concrete_vals : VarSet.t; + local_meths : MethSet.t; + local_vals : VarSet.t; +- vars : Ident.t Vars.t; +- meths : Ident.t Meths.t; } ++ vars : Ident.t Vars.t; } + + let rec class_field_first_pass self_loc cl_num sign self_scope acc cf = + let { rev_fields; val_env; par_env; concrete_meths; concrete_vals; +- local_meths; local_vals; vars; meths } = acc ++ local_meths; local_vals; vars } = acc + in + let loc = cf.pcf_loc in + let attributes = cf.pcf_attributes in +@@ -612,13 +611,6 @@ let rec class_field_first_pass self_loc cl_num sign self_scope acc cf = + (val_env, par_env, inherited_vars, vars)) + parent_sign.csig_vars (val_env, par_env, [], vars) + in +- let meths = +- Meths.fold +- (fun label _ meths -> +- if Meths.mem label meths then meths +- else Meths.add label (Ident.create_local label) meths) +- parent_sign.csig_meths meths +- in + (* Methods available through super *) + let super_meths = + MethSet.fold +@@ -641,7 +633,7 @@ let rec class_field_first_pass self_loc cl_num sign self_scope acc cf = + in + let rev_fields = field :: rev_fields in + { acc with rev_fields; val_env; par_env; +- concrete_meths; concrete_vals; vars; meths }) ++ concrete_meths; concrete_vals; vars }) + | Pcf_val (label, mut, Cfk_virtual styp) -> + with_attrs + (fun () -> +@@ -723,15 +715,11 @@ let rec class_field_first_pass self_loc cl_num sign self_scope acc cf = + let cty = transl_simple_type val_env false sty in + let ty = cty.ctyp_type in + add_method loc val_env label.txt priv Virtual ty sign; +- let meths = +- if Meths.mem label.txt meths then meths +- else Meths.add label.txt (Ident.create_local label.txt) meths +- in + let field = + Virtual_method { label; priv; cty; loc; attributes } + in + let rev_fields = field :: rev_fields in +- { acc with rev_fields; meths }) ++ { acc with rev_fields }) + + | Pcf_method (label, priv, Cfk_concrete (override, expr)) -> + with_attrs +@@ -785,10 +773,6 @@ let rec class_field_first_pass self_loc cl_num sign self_scope acc cf = + raise(Error(loc, val_env, + Field_type_mismatch ("method", label.txt, err))) + end; +- let meths = +- if Meths.mem label.txt meths then meths +- else Meths.add label.txt (Ident.create_local label.txt) meths +- in + let sdefinition = make_method self_loc cl_num expr in + let warning_state = Warnings.backup () in + let field = +@@ -799,7 +783,7 @@ let rec class_field_first_pass self_loc cl_num sign self_scope acc cf = + let rev_fields = field :: rev_fields in + let concrete_meths = MethSet.add label.txt concrete_meths in + let local_meths = MethSet.add label.txt local_meths in +- { acc with rev_fields; concrete_meths; local_meths; meths }) ++ { acc with rev_fields; concrete_meths; local_meths }) + + | Pcf_constraint (sty1, sty2) -> + with_attrs +@@ -837,11 +821,10 @@ and class_fields_first_pass self_loc cl_num sign self_scope + let local_meths = MethSet.empty in + let local_vals = VarSet.empty in + let vars = Vars.empty in +- let meths = Meths.empty in + let init_acc = + { rev_fields; val_env; par_env; + concrete_meths; concrete_vals; +- local_meths; local_vals; vars; meths } ++ local_meths; local_vals; vars } + in + let acc = + Builtin_attributes.warning_scope [] +@@ -850,7 +833,7 @@ and class_fields_first_pass self_loc cl_num sign self_scope + (class_field_first_pass self_loc cl_num sign self_scope) + init_acc cfs) + in +- List.rev acc.rev_fields, acc.vars, acc.meths ++ List.rev acc.rev_fields, acc.vars + + and class_field_second_pass cl_num sign met_env field = + let mkcf desc loc attrs = +@@ -1003,7 +986,7 @@ and class_structure cl_num virt self_scope final val_env met_env loc + end; + + (* Typing of class fields *) +- let (fields, vars, meths) = ++ let (fields, vars) = + class_fields_first_pass self_loc cl_num sign self_scope + val_env par_env str + in +@@ -1016,6 +999,13 @@ and class_structure cl_num virt self_scope final val_env met_env loc + update_class_signature loc val_env + ~warn_implicit_public:false virt kind sign; + ++ let meths = ++ Meths.fold ++ (fun label _ meths -> ++ Meths.add label (Ident.create_local label) meths) ++ sign.csig_meths Meths.empty ++ in ++ + (* Close the signature if it is final *) + begin match final with + | Not_final -> () +-- +2.37.0.rc2 + diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch deleted file mode 100644 index 6bf857a..0000000 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 04e523e937625bf30d775681c11e00f6dc6fc00a Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/2] Don't add rpaths to libraries. - ---- - configure.ac | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 3754ad8a39..fb60c7c14c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1422,8 +1422,6 @@ AS_IF([test x"$enable_shared" != "xno"], - [[*-*-openbsd7.[3-9]|*-*-openbsd[89].*]], - [mkdll_flags="${mkdll_flags} -Wl,--no-execute-only"]) - oc_ldflags="$oc_ldflags -Wl,-E" -- rpath="-Wl,-rpath," -- mksharedlibrpath="-Wl,-rpath," - natdynlinkopts="-Wl,-E" - supports_shared_libraries=true], - [mkdll='shared-libs-not-available']) --- -2.52.0 - diff --git a/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch b/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch new file mode 100644 index 0000000..9c75989 --- /dev/null +++ b/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch @@ -0,0 +1,43 @@ +From 623258a6517c8ec1d9e5f41cbdc05205a0e6ee1d Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Thu, 5 May 2022 20:01:44 +0100 +Subject: [PATCH 02/24] Merge pull request #11236 from Nymphium/missing-since2 + +Add missing @since annotation to Gc.eventlog_pause + +(cherry picked from commit 77fee6035c25d8a31084dc556ee634e46bb39164) +--- + stdlib/gc.mli | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/stdlib/gc.mli b/stdlib/gc.mli +index b211197fd4..8031eeb8df 100644 +--- a/stdlib/gc.mli ++++ b/stdlib/gc.mli +@@ -442,7 +442,10 @@ external eventlog_pause : unit -> unit = "caml_eventlog_pause" + Traces are collected if the program is linked to the instrumented runtime + and started with the environment variable OCAML_EVENTLOG_ENABLED. + Events are flushed to disk after pausing, and no new events will be +- recorded until [eventlog_resume] is called. *) ++ recorded until [eventlog_resume] is called. ++ ++ @since 4.11 ++ *) + + external eventlog_resume : unit -> unit = "caml_eventlog_resume" + (** [eventlog_resume ()] will resume the collection of traces in the +@@ -451,7 +454,10 @@ external eventlog_resume : unit -> unit = "caml_eventlog_resume" + and started with the environment variable OCAML_EVENTLOG_ENABLED. + This call can be used after calling [eventlog_pause], or if the program + was started with OCAML_EVENTLOG_ENABLED=p. (which pauses the collection of +- traces before the first event.) *) ++ traces before the first event.) ++ ++ @since 4.11 ++ *) + + + (** [Memprof] is a sampling engine for allocated memory words. Every +-- +2.37.0.rc2 + diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch deleted file mode 100644 index 74de99b..0000000 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ /dev/null @@ -1,25 +0,0 @@ -From ef549c9a97838331877b139f407269db2a0fc691 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/2] configure: Allow user defined C compiler flags. - ---- - configure.ac | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index fb60c7c14c..f6a493ccf5 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -3243,7 +3243,7 @@ AC_CONFIG_COMMANDS_PRE([ - [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) - mkdll_ldflags="" - AS_IF([test -n "${LDFLAGS}"], -- [for flag in ${LDFLAGS}; do -+ [for flag in "${LDFLAGS}"; do - mkdll_ldflags="${mkdll_ldflags} ${mkexe_ldflags_prefix}${flag}" - done - mkdll_ldflags_exp="$mkdll_ldflags"]) --- -2.52.0 - diff --git a/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch b/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch new file mode 100644 index 0000000..3854e05 --- /dev/null +++ b/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch @@ -0,0 +1,26 @@ +From d497565758b5c80d8a7bf4cad02e5a4558ae6b00 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= +Date: Tue, 17 May 2022 10:21:34 +0200 +Subject: [PATCH 03/24] misc.h: fix preprocessor conditional on _MSC_VER + +(cherry picked from commit 253d605e10865371aed45967a94caed0642b7583) +--- + runtime/caml/misc.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/runtime/caml/misc.h b/runtime/caml/misc.h +index 5915c30a7b..494d45e8f8 100644 +--- a/runtime/caml/misc.h ++++ b/runtime/caml/misc.h +@@ -35,7 +35,7 @@ + /* Supported since at least GCC 3.1 */ + #define CAMLdeprecated_typedef(name, type) \ + typedef type name __attribute ((deprecated)) +-#elif _MSC_VER >= 1310 ++#elif defined(_MSC_VER) && _MSC_VER >= 1310 + /* NB deprecated("message") only supported from _MSC_VER >= 1400 */ + #define CAMLdeprecated_typedef(name, type) \ + typedef __declspec(deprecated) type name +-- +2.37.0.rc2 + diff --git a/0004-Changes.patch b/0004-Changes.patch new file mode 100644 index 0000000..214e89e --- /dev/null +++ b/0004-Changes.patch @@ -0,0 +1,28 @@ +From d2b9da6f7aff410e8a1499637ae88aaf0a135c2f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= +Date: Tue, 17 May 2022 14:45:26 +0200 +Subject: [PATCH 04/24] Changes + +(cherry picked from commit 9a157026f115364635f8fe0ae5805e15ef071de0) +--- + Changes | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/Changes b/Changes +index 931a74b8d1..fdfffd78bb 100644 +--- a/Changes ++++ b/Changes +@@ -8,6 +8,10 @@ OCaml 4.14 maintenance branch + the class definition. + (Nicolás Ojeda Bär, review by Leo White) + ++- #11263: caml/misc.h: check whether `_MSC_VER` is defined before using it. This ++ could break the build of the compiler on non-gcc non-clang Unix builds. ++ (Nicolás Ojeda Bär, review by Sebastien Hinderer) ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +-- +2.37.0.rc2 + diff --git a/0005-Guard-more-instances-of-undefined-_MSC_VER.patch b/0005-Guard-more-instances-of-undefined-_MSC_VER.patch new file mode 100644 index 0000000..d9f81d7 --- /dev/null +++ b/0005-Guard-more-instances-of-undefined-_MSC_VER.patch @@ -0,0 +1,93 @@ +From 513164232d897c39c4e571a7a8f167dee5c146b3 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Wed, 18 May 2022 12:48:33 +0100 +Subject: [PATCH 05/24] Guard more instances of undefined _MSC_VER + +--- + Changes | 8 +++++--- + runtime/caml/memory.h | 2 +- + runtime/caml/misc.h | 12 +++++++----- + 3 files changed, 13 insertions(+), 9 deletions(-) + +diff --git a/Changes b/Changes +index fdfffd78bb..590268262d 100644 +--- a/Changes ++++ b/Changes +@@ -8,9 +8,11 @@ OCaml 4.14 maintenance branch + the class definition. + (Nicolás Ojeda Bär, review by Leo White) + +-- #11263: caml/misc.h: check whether `_MSC_VER` is defined before using it. This +- could break the build of the compiler on non-gcc non-clang Unix builds. +- (Nicolás Ojeda Bär, review by Sebastien Hinderer) ++- #11263, #11267: caml/{memory,misc}.h: check whether `_MSC_VER` is defined ++ before using it to ensure that the headers can always be used in code which ++ turns on -Wundef (or equivalent). ++ (David Allsopp and Nicolás Ojeda Bär, review by Nicolás Ojeda Bär and ++ Sebastien Hinderer) + + OCaml 4.14.0 (28 March 2022) + ---------------------------- +diff --git a/runtime/caml/memory.h b/runtime/caml/memory.h +index 1e9cdf6d9b..d9e58bc2d0 100644 +--- a/runtime/caml/memory.h ++++ b/runtime/caml/memory.h +@@ -329,7 +329,7 @@ struct caml__roots_block { + #define CAMLunused_start __attribute__ ((unused)) + #define CAMLunused_end + #define CAMLunused __attribute__ ((unused)) +-#elif _MSC_VER >= 1500 ++#elif defined(_MSC_VER) && _MSC_VER >= 1500 + #define CAMLunused_start __pragma( warning (push) ) \ + __pragma( warning (disable:4189 ) ) + #define CAMLunused_end __pragma( warning (pop)) +diff --git a/runtime/caml/misc.h b/runtime/caml/misc.h +index 494d45e8f8..c605f8711e 100644 +--- a/runtime/caml/misc.h ++++ b/runtime/caml/misc.h +@@ -43,7 +43,8 @@ + #define CAMLdeprecated_typedef(name, type) typedef type name + #endif + +-#if defined(__GNUC__) && __STDC_VERSION__ >= 199901L || _MSC_VER >= 1925 ++#if defined(__GNUC__) && __STDC_VERSION__ >= 199901L \ ++ || defined(_MSC_VER) && _MSC_VER >= 1925 + + #define CAML_STRINGIFY(x) #x + #ifdef _MSC_VER +@@ -90,7 +91,7 @@ CAMLdeprecated_typedef(addr, char *); + #define CAMLnoreturn_start + #define CAMLnoreturn_end __attribute__ ((noreturn)) + #define Noreturn __attribute__ ((noreturn)) +-#elif _MSC_VER >= 1500 ++#elif defined(_MSC_VER) && _MSC_VER >= 1500 + #define CAMLnoreturn_start __declspec(noreturn) + #define CAMLnoreturn_end + #define Noreturn +@@ -138,11 +139,12 @@ CAMLdeprecated_typedef(addr, char *); + /* we need to be able to compute the exact offset of each member. */ + #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define CAMLalign(n) _Alignas(n) +-#elif defined(__cplusplus) && (__cplusplus >= 201103L || _MSC_VER >= 1900) ++#elif defined(__cplusplus) \ ++ && (__cplusplus >= 201103L || defined(_MSC_VER) && _MSC_VER >= 1900) + #define CAMLalign(n) alignas(n) + #elif defined(SUPPORTS_ALIGNED_ATTRIBUTE) + #define CAMLalign(n) __attribute__((aligned(n))) +-#elif _MSC_VER >= 1500 ++#elif defined(_MSC_VER) && _MSC_VER >= 1500 + #define CAMLalign(n) __declspec(align(n)) + #else + #error "How do I align values on this platform?" +@@ -170,7 +172,7 @@ CAMLdeprecated_typedef(addr, char *); + #define CAMLunused_start __attribute__ ((unused)) + #define CAMLunused_end + #define CAMLunused __attribute__ ((unused)) +-#elif _MSC_VER >= 1500 ++#elif defined(_MSC_VER) && _MSC_VER >= 1500 + #define CAMLunused_start __pragma( warning (push) ) \ + __pragma( warning (disable:4189 ) ) + #define CAMLunused_end __pragma( warning (pop)) +-- +2.37.0.rc2 + diff --git a/0006-Better-documentation-for-string_of_float-.-11353.patch b/0006-Better-documentation-for-string_of_float-.-11353.patch new file mode 100644 index 0000000..935a992 --- /dev/null +++ b/0006-Better-documentation-for-string_of_float-.-11353.patch @@ -0,0 +1,95 @@ +From fa904a7d3c89c2ad18a426017aeda5bb0d7dd8bd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fran=C3=A7ois=20Pottier?= + +Date: Fri, 24 Jun 2022 16:37:13 +0200 +Subject: [PATCH 06/24] Better documentation for [string_of_float]. (#11353) + +Better documentation for [string_of_float] (and [Float.to_string]) +with similar warnings for [print_float] and [prerr_float] in a similar way. + +(cherry picked from commit 40113fbc73930b41a7a2df468de18c94feeefdf5) +--- + stdlib/float.mli | 7 ++++++- + stdlib/stdlib.mli | 15 ++++++++++++--- + stdlib/templates/float.template.mli | 7 ++++++- + 3 files changed, 24 insertions(+), 5 deletions(-) + +diff --git a/stdlib/float.mli b/stdlib/float.mli +index ba84d9b0e2..93d2f3016d 100644 +--- a/stdlib/float.mli ++++ b/stdlib/float.mli +@@ -178,7 +178,12 @@ val of_string_opt: string -> float option + (** Same as [of_string], but returns [None] instead of raising. *) + + val to_string : float -> string +-(** Return the string representation of a floating-point number. *) ++(** Return a string representation of a floating-point number. ++ ++ This conversion can involve a loss of precision. For greater control over ++ the manner in which the number is printed, see {!Printf}. ++ ++ This function is an alias for {!Stdlib.string_of_float}. *) + + type fpclass = Stdlib.fpclass = + FP_normal (** Normal number, none of the below *) +diff --git a/stdlib/stdlib.mli b/stdlib/stdlib.mli +index 237adfbdd8..0eaee2716e 100644 +--- a/stdlib/stdlib.mli ++++ b/stdlib/stdlib.mli +@@ -776,7 +776,10 @@ external int_of_string : string -> int = "caml_int_of_string" + [Failure "int_of_string"] instead of returning [None]. *) + + val string_of_float : float -> string +-(** Return the string representation of a floating-point number. *) ++(** Return a string representation of a floating-point number. ++ ++ This conversion can involve a loss of precision. For greater control over ++ the manner in which the number is printed, see {!Printf}. *) + + val float_of_string_opt: string -> float option + (** Convert the given string to a float. The string is read in decimal +@@ -861,7 +864,10 @@ val print_int : int -> unit + (** Print an integer, in decimal, on standard output. *) + + val print_float : float -> unit +-(** Print a floating-point number, in decimal, on standard output. *) ++(** Print a floating-point number, in decimal, on standard output. ++ ++ The conversion of the number to a string uses {!string_of_float} and ++ can involve a loss of precision. *) + + val print_endline : string -> unit + (** Print a string, followed by a newline character, on +@@ -889,7 +895,10 @@ val prerr_int : int -> unit + (** Print an integer, in decimal, on standard error. *) + + val prerr_float : float -> unit +-(** Print a floating-point number, in decimal, on standard error. *) ++(** Print a floating-point number, in decimal, on standard error. ++ ++ The conversion of the number to a string uses {!string_of_float} and ++ can involve a loss of precision. *) + + val prerr_endline : string -> unit + (** Print a string, followed by a newline character on standard +diff --git a/stdlib/templates/float.template.mli b/stdlib/templates/float.template.mli +index e35c01809f..e2f7411a02 100644 +--- a/stdlib/templates/float.template.mli ++++ b/stdlib/templates/float.template.mli +@@ -178,7 +178,12 @@ val of_string_opt: string -> float option + (** Same as [of_string], but returns [None] instead of raising. *) + + val to_string : float -> string +-(** Return the string representation of a floating-point number. *) ++(** Return a string representation of a floating-point number. ++ ++ This conversion can involve a loss of precision. For greater control over ++ the manner in which the number is printed, see {!Printf}. ++ ++ This function is an alias for {!Stdlib.string_of_float}. *) + + type fpclass = Stdlib.fpclass = + FP_normal (** Normal number, none of the below *) +-- +2.37.0.rc2 + diff --git a/0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch b/0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch new file mode 100644 index 0000000..b57c6ba --- /dev/null +++ b/0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch @@ -0,0 +1,30 @@ +From 05874f93adc60f16ccd5cbeef1e2ff010cef12c1 Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Fri, 1 Jul 2022 14:41:25 +0200 +Subject: [PATCH 07/24] Merge pull request #11380 from + damiendoligez/fix-fortran-test-on-macos + +fix gfortran test on Macos + +(cherry picked from commit d7a2e0fa7f2df9bd178109ba9725bb074affbd5c) +--- + testsuite/tests/lib-bigarray-2/has-gfortran.sh | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/testsuite/tests/lib-bigarray-2/has-gfortran.sh b/testsuite/tests/lib-bigarray-2/has-gfortran.sh +index 82f7ae8aee..051122113a 100644 +--- a/testsuite/tests/lib-bigarray-2/has-gfortran.sh ++++ b/testsuite/tests/lib-bigarray-2/has-gfortran.sh +@@ -5,6 +5,9 @@ if ! which gfortran > /dev/null 2>&1; then + elif ! grep -q '^CC=gcc' ${ocamlsrcdir}/Makefile.config; then + echo "OCaml was not compiled with gcc" > ${ocamltest_response} + test_result=${TEST_SKIP} ++elif gcc --version 2>&1 | grep 'Apple clang version'; then ++ echo "OCaml was not compiled with gcc" > ${ocamltest_response} ++ test_result=${TEST_SKIP} + else + test_result=${TEST_PASS} + fi +-- +2.37.0.rc2 + diff --git a/0008-Refactor-the-initialization-of-bytecode-threading-11.patch b/0008-Refactor-the-initialization-of-bytecode-threading-11.patch new file mode 100644 index 0000000..d6b3510 --- /dev/null +++ b/0008-Refactor-the-initialization-of-bytecode-threading-11.patch @@ -0,0 +1,101 @@ +From b9afeb8b8dc8c32f9f1c74c8402de9e6265e9d5f Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Fri, 1 Jul 2022 17:14:44 +0200 +Subject: [PATCH 08/24] Refactor the initialization of bytecode threading + (#11378) + +Refactor the initialization of bytecode threading + +Use a function `caml_init_thread_code` instead of exposing global variables +`caml_instr_table` and `caml_instr_base`. + +This should silence the GCC 12 "dangling-pointer" warning. + +Fixes: #11358 +--- + Changes | 5 +++++ + runtime/caml/fix_code.h | 3 +-- + runtime/fix_code.c | 10 ++++++++-- + runtime/interp.c | 7 +++---- + 4 files changed, 17 insertions(+), 8 deletions(-) + +diff --git a/Changes b/Changes +index 590268262d..7ea4475b8d 100644 +--- a/Changes ++++ b/Changes +@@ -14,6 +14,11 @@ OCaml 4.14 maintenance branch + (David Allsopp and Nicolás Ojeda Bär, review by Nicolás Ojeda Bär and + Sebastien Hinderer) + ++- #11358, #11378: Refactor the initialization of bytecode threading. ++ This avoids a "dangling pointer" warning of GCC 12.1. ++ (Xavier Leroy, report by Armaël Guéneau, review by Gabriel Scherer) ++ ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +diff --git a/runtime/caml/fix_code.h b/runtime/caml/fix_code.h +index 83c393a17d..2eafaa814b 100644 +--- a/runtime/caml/fix_code.h ++++ b/runtime/caml/fix_code.h +@@ -34,8 +34,7 @@ void caml_set_instruction (code_t pos, opcode_t instr); + int caml_is_instruction (opcode_t instr1, opcode_t instr2); + + #ifdef THREADED_CODE +-extern char ** caml_instr_table; +-extern char * caml_instr_base; ++void caml_init_thread_code(void ** instr_table, void * instr_base); + void caml_thread_code (code_t code, asize_t len); + #endif + +diff --git a/runtime/fix_code.c b/runtime/fix_code.c +index aa059be5df..5584019867 100644 +--- a/runtime/fix_code.c ++++ b/runtime/fix_code.c +@@ -82,8 +82,14 @@ void caml_fixup_endianness(code_t code, asize_t len) + + #ifdef THREADED_CODE + +-char ** caml_instr_table; +-char * caml_instr_base; ++static char ** caml_instr_table; ++static char * caml_instr_base; ++ ++void caml_init_thread_code(void ** instr_table, void * instr_base) ++{ ++ caml_instr_table = (char **) instr_table; ++ caml_instr_base = (char *) instr_base; ++} + + static int* opcode_nargs = NULL; + int* caml_init_opcode_nargs(void) +diff --git a/runtime/interp.c b/runtime/interp.c +index a59811c87d..e6700994bc 100644 +--- a/runtime/interp.c ++++ b/runtime/interp.c +@@ -50,9 +50,9 @@ sp is a local copy of the global variable Caml_state->extern_sp. */ + #ifdef THREADED_CODE + # define Instruct(name) lbl_##name + # if defined(ARCH_SIXTYFOUR) && !defined(ARCH_CODE32) +-# define Jumptbl_base ((char *) &&lbl_ACC0) ++# define Jumptbl_base &&lbl_ACC0 + # else +-# define Jumptbl_base ((char *) 0) ++# define Jumptbl_base 0 + # define jumptbl_base ((char *) 0) + # endif + # ifdef DEBUG +@@ -249,8 +249,7 @@ value caml_interprete(code_t prog, asize_t prog_size) + + if (prog == NULL) { /* Interpreter is initializing */ + #ifdef THREADED_CODE +- caml_instr_table = (char **) jumptable; +- caml_instr_base = Jumptbl_base; ++ caml_init_thread_code(jumptable, Jumptbl_base); + #endif + return Val_unit; + } +-- +2.37.0.rc2 + diff --git a/0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch b/0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch new file mode 100644 index 0000000..7f1ef7e --- /dev/null +++ b/0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch @@ -0,0 +1,49 @@ +From 7315c73e283eca4313403e959241d86d63f88d58 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Tue, 5 Jul 2022 09:27:54 +0200 +Subject: [PATCH 09/24] Merge pull request #11397 from + Octachron/tast_mapper_fix_for_with_modtype + + #11387: clean up envs inside Twith_modtype(subst) + +(cherry picked from commit d9afa408c612e74a266b95f0fa25bb1efde72112) +--- + Changes | 3 +++ + typing/tast_mapper.ml | 6 +++--- + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/Changes b/Changes +index 7ea4475b8d..0fe7732a02 100644 +--- a/Changes ++++ b/Changes +@@ -18,6 +18,9 @@ OCaml 4.14 maintenance branch + This avoids a "dangling pointer" warning of GCC 12.1. + (Xavier Leroy, report by Armaël Guéneau, review by Gabriel Scherer) + ++- #11387, module type with constraints no longer crash the compiler in presence ++ of both shadowing warnings and the `-bin-annot` compiler flag. ++ (Florian Angeletti, report by Christophe Raffalli, review by Gabriel Scherer) + + OCaml 4.14.0 (28 March 2022) + ---------------------------- +diff --git a/typing/tast_mapper.ml b/typing/tast_mapper.ml +index 6d359a59a7..9eb7f64e88 100644 +--- a/typing/tast_mapper.ml ++++ b/typing/tast_mapper.ml +@@ -458,10 +458,10 @@ let module_type sub x = + let with_constraint sub = function + | Twith_type decl -> Twith_type (sub.type_declaration sub decl) + | Twith_typesubst decl -> Twith_typesubst (sub.type_declaration sub decl) ++ | Twith_modtype mty -> Twith_modtype (sub.module_type sub mty) ++ | Twith_modtypesubst mty -> Twith_modtypesubst (sub.module_type sub mty) + | Twith_module _ +- | Twith_modsubst _ +- | Twith_modtype _ +- | Twith_modtypesubst _ as d -> d ++ | Twith_modsubst _ as d -> d + + let open_description sub od = + {od with open_env = sub.env sub od.open_env} +-- +2.37.0.rc2 + diff --git a/0010-Merge-pull-request-11396-from-gasche-fix11392.patch b/0010-Merge-pull-request-11396-from-gasche-fix11392.patch new file mode 100644 index 0000000..0b9cbd6 --- /dev/null +++ b/0010-Merge-pull-request-11396-from-gasche-fix11392.patch @@ -0,0 +1,85 @@ +From 9f72a2a2fec0902aeae5e5082779bb197657c1f4 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Tue, 5 Jul 2022 10:38:50 +0200 +Subject: [PATCH 10/24] Merge pull request #11396 from gasche/fix11392 + +Fix 11392 (assertion failure on external with -rectypes) + +(cherry picked from commit 724cefb8b0f1f96ef5181fffc24975ac9460ce3e) +--- + Changes | 3 ++ + testsuite/tests/typing-external/pr11392.ml | 34 ++++++++++++++++++++++ + typing/typedecl.ml | 2 +- + 3 files changed, 38 insertions(+), 1 deletion(-) + create mode 100644 testsuite/tests/typing-external/pr11392.ml + +diff --git a/Changes b/Changes +index 0fe7732a02..8182f5ced7 100644 +--- a/Changes ++++ b/Changes +@@ -22,6 +22,9 @@ OCaml 4.14 maintenance branch + of both shadowing warnings and the `-bin-annot` compiler flag. + (Florian Angeletti, report by Christophe Raffalli, review by Gabriel Scherer) + ++- #11392, #11392: assertion failure with -rectypes and external definitions ++ (Gabriel Scherer, review by Florian Angeletti, report by Dmitrii Kosarev) ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +diff --git a/testsuite/tests/typing-external/pr11392.ml b/testsuite/tests/typing-external/pr11392.ml +new file mode 100644 +index 0000000000..91c8ea77eb +--- /dev/null ++++ b/testsuite/tests/typing-external/pr11392.ml +@@ -0,0 +1,34 @@ ++(* TEST ++ * expect ++*) ++ ++type 'self nat = ++ | Z ++ | S of 'self ++;; ++[%%expect{| ++type 'self nat = Z | S of 'self ++|}] ++ ++ ++ ++(* without rectypes: rejected *) ++external cast : int -> 'self nat as 'self = "%identity" ++;; ++[%%expect{| ++Line 1, characters 16-41: ++1 | external cast : int -> 'self nat as 'self = "%identity" ++ ^^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: This alias is bound to type int -> 'a nat ++ but is used as an instance of type 'a ++ The type variable 'a occurs inside int -> 'a nat ++|}] ++ ++#rectypes;; ++ ++(* with rectypes: accepted (used to crash) *) ++external cast : int -> 'self nat as 'self = "%identity" ++;; ++[%%expect{| ++external cast : int -> 'a nat as 'a = "%identity" ++|}] +diff --git a/typing/typedecl.ml b/typing/typedecl.ml +index 9d38ebe97e..d00c0fc450 100644 +--- a/typing/typedecl.ml ++++ b/typing/typedecl.ml +@@ -1334,7 +1334,7 @@ let rec parse_native_repr_attributes env core_type ty ~global_repr = + parse_native_repr_attributes env ct2 t2 ~global_repr + in + (repr_arg :: repr_args, repr_res) +- | Ptyp_poly (_, t), _, _ -> ++ | (Ptyp_poly (_, t) | Ptyp_alias (t, _)), _, _ -> + parse_native_repr_attributes env t ty ~global_repr + | Ptyp_arrow _, _, _ | _, Tarrow _, _ -> assert false + | _ -> ([], make_native_repr env core_type ty ~global_repr) +-- +2.37.0.rc2 + diff --git a/0011-Document-limitation-on-caml_callbackN-11409.patch b/0011-Document-limitation-on-caml_callbackN-11409.patch new file mode 100644 index 0000000..bf09575 --- /dev/null +++ b/0011-Document-limitation-on-caml_callbackN-11409.patch @@ -0,0 +1,53 @@ +From 9d4faca7af8d9849093ff8d36509ad60608ac239 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Thu, 7 Jul 2022 18:22:22 +0200 +Subject: [PATCH 11/24] Document limitation on `caml_callbackN` (#11409) + +The `args` argument array must not be declared with `CAMLlocalN`, otherwise +the array can be registered a second time by `caml_callbackN`, confusing +the compactor. + +Also: suggests using a C99 compound literal, it looks good and avoids the issue. + +Fixes: #11045 +--- + Changes | 7 +++++++ + manual/src/cmds/intf-c.etex | 4 ++++ + 2 files changed, 11 insertions(+) + +diff --git a/Changes b/Changes +index 8182f5ced7..13eb7fef98 100644 +--- a/Changes ++++ b/Changes +@@ -25,6 +25,13 @@ OCaml 4.14 maintenance branch + - #11392, #11392: assertion failure with -rectypes and external definitions + (Gabriel Scherer, review by Florian Angeletti, report by Dmitrii Kosarev) + ++### Manual and documentation: ++ ++- #11045, #11409: document that the array argument to `caml_callbackN` ++ must not have been declared by `CAMLlocalN`. ++ (Xavier Leroy, report by Stephen Dolan, review by Gabriel Scherer.) ++ ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +diff --git a/manual/src/cmds/intf-c.etex b/manual/src/cmds/intf-c.etex +index 7cd50a1372..bb420c2940 100644 +--- a/manual/src/cmds/intf-c.etex ++++ b/manual/src/cmds/intf-c.etex +@@ -1449,6 +1449,10 @@ the value \var{a} and returns the value returned by~\var{f}. + (a curried OCaml function with three arguments) to \var{a}, \var{b} and \var{c}. + \item "caml_callbackN("\var{f, n, args}")" applies the functional value \var{f} + to the \var{n} arguments contained in the C array of values \var{args}. ++The array \var{args} must \emph{not} be declared with "CAMLlocalN". ++It should be declared as "value "\var{args}"["\var{n}"];". ++Alternatively, a C99 compound literal can be used: ++"caml_callbackN("\var{f, n, }"(value[]){"\nth{arg}{1}, \ldots, \nth{arg}{n}"})". + \end{itemize} + If the function \var{f} does not return, but raises an exception that + escapes the scope of the application, then this exception is +-- +2.37.0.rc2 + diff --git a/0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch b/0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch new file mode 100644 index 0000000..739914c --- /dev/null +++ b/0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch @@ -0,0 +1,327 @@ +From 50fbd6685ec88f1dc81451923d7c80fb0d18ca8b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=A9bastien=20Hinderer?= +Date: Thu, 14 Apr 2022 19:19:46 +0200 +Subject: [PATCH 12/24] Stop calling ranlib on created / installed libraries + (#11184) + +`ranlib` seems unnecessary if a POSIX-compliant `ar` is used and time stamps are preserved when a `.a` file is installed. + +(cherry picked from commit c8e41bade529998c4e66975c88fabf3ac47d7078) +--- + Changes | 5 +++++ + INSTALL.adoc | 4 ++-- + Makefile | 2 -- + Makefile.build_config.in | 2 +- + Makefile.config.in | 4 ---- + configure | Bin 581827 -> 581549 bytes + configure.ac | 16 +++------------- + otherlibs/Makefile.otherlibs.common | 2 -- + otherlibs/dynlink/Makefile | 11 +++++------ + otherlibs/systhreads/Makefile | 3 --- + stdlib/Makefile | 1 - + tools/ocamlmklib.ml | 6 ++---- + utils/Makefile | 1 - + utils/ccomp.ml | 8 ++------ + utils/config.mli | 3 --- + utils/config.mlp | 2 -- + 16 files changed, 20 insertions(+), 50 deletions(-) + +diff --git a/Changes b/Changes +index 13eb7fef98..6f92ee9965 100644 +--- a/Changes ++++ b/Changes +@@ -25,6 +25,11 @@ OCaml 4.14 maintenance branch + - #11392, #11392: assertion failure with -rectypes and external definitions + (Gabriel Scherer, review by Florian Angeletti, report by Dmitrii Kosarev) + ++### Compiler user-interface and warnings: ++ ++- #11184: Stop calling ranlib on created / installed libraries ++ (Sébastien Hinderer, review by Xavier Leroy) ++ + ### Manual and documentation: + + - #11045, #11409: document that the array argument to `caml_callbackN` +diff --git a/INSTALL.adoc b/INSTALL.adoc +index f4199ca49a..08d67ebbbe 100644 +--- a/INSTALL.adoc ++++ b/INSTALL.adoc +@@ -43,8 +43,8 @@ + * Under Cygwin, the `gcc-core` package is required. `flexdll` is also necessary + for shared library support. + +-* Binutils including `ar`, `ranlib`, and `strip` are required if your +- distribution does not already provide them with the C compiler. ++* Binutils including `ar` and `strip` are required if your distribution ++ does not already provide them with the C compiler. + + == Configuration + +diff --git a/Makefile b/Makefile +index 3c74bc79df..0e92785da2 100644 +--- a/Makefile ++++ b/Makefile +@@ -585,8 +585,6 @@ endif + ifeq "$(INSTALL_OCAMLNAT)" "true" + $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)" + endif +- cd "$(INSTALL_COMPLIBDIR)" && \ +- $(RANLIB) ocamlcommon.$(A) ocamlbytecomp.$(A) ocamloptcomp.$(A) + + # Installation of the *.ml sources of compiler-libs + .PHONY: install-compiler-sources +diff --git a/Makefile.build_config.in b/Makefile.build_config.in +index eeac09dd76..4d6705d252 100644 +--- a/Makefile.build_config.in ++++ b/Makefile.build_config.in +@@ -20,7 +20,7 @@ + # $(ROOTDIR) has been defined. + + include $(ROOTDIR)/Makefile.config +-INSTALL ?= @INSTALL@ ++INSTALL ?= @INSTALL@ -p + INSTALL_DATA ?= @INSTALL_DATA@ + INSTALL_PROG ?= @INSTALL_PROGRAM@ + +diff --git a/Makefile.config.in b/Makefile.config.in +index eb3d85eb1d..4badb74c3f 100644 +--- a/Makefile.config.in ++++ b/Makefile.config.in +@@ -88,10 +88,6 @@ LDFLAGS?=@LDFLAGS@ + ### How to invoke the C preprocessor through the C compiler + CPP=@CPP@ + +-### How to invoke ranlib +-RANLIB=@RANLIB@ +-RANLIBCMD=@RANLIBCMD@ +- + ### How to invoke ar + ARCMD=@AR@ + +diff --git a/configure b/configure +index 8a2c007fd221bc897a255b4aa80c7f23710fcb10..73ce66bfa0a3de5e886a88c973b2db288b5e4d03 100755 +GIT binary patch +delta 91 +zcmX?nP-EJyt==60{S#P(`nZ^plY(UJueamx2P^N?Ror2wRCOHK#ZgE(H{K3{og6RYK +zU>4b?CTHZsIKV)ezG4dNJs|}(H3gMwh?TVpF)A8{?X6Q;ftU@5*|)b&< + assert(String.length Config.ar > 0); +- let r1 = +- command(Printf.sprintf "%s rc %s %s" +- Config.ar quoted_archive (quote_files file_list)) in +- if r1 <> 0 || String.length Config.ranlib = 0 +- then r1 +- else command(Config.ranlib ^ " " ^ quoted_archive) ++ command(Printf.sprintf "%s rc %s %s" ++ Config.ar quoted_archive (quote_files file_list)) + + let expand_libname cclibs = + cclibs |> List.map (fun cclib -> +diff --git a/utils/config.mli b/utils/config.mli +index 7f70a52d52..94dee3cb92 100644 +--- a/utils/config.mli ++++ b/utils/config.mli +@@ -82,9 +82,6 @@ val mkexe: string + val mkmaindll: string + (** The linker command line to build main programs as dlls. *) + +-val ranlib: string +-(** Command to randomize a library, or "" if not needed *) +- + val default_rpath: string + (** Option to add a directory to be searched for libraries at runtime + (used by ocamlmklib) *) +diff --git a/utils/config.mlp b/utils/config.mlp +index 44c6ff8fa5..f758a9b483 100644 +--- a/utils/config.mlp ++++ b/utils/config.mlp +@@ -54,7 +54,6 @@ let native_c_compiler = + c_compiler ^ " " ^ ocamlopt_cflags ^ " " ^ ocamlopt_cppflags + let native_c_libraries = "%%NATIVECCLIBS%%" + let native_pack_linker = "%%PACKLD%%" +-let ranlib = "%%RANLIBCMD%%" + let default_rpath = "%%RPATH%%" + let mksharedlibrpath = "%%MKSHAREDLIBRPATH%%" + let ar = "%%ARCMD%%" +@@ -177,7 +176,6 @@ let configuration_variables = + p "bytecomp_c_libraries" bytecomp_c_libraries; + p "native_c_libraries" native_c_libraries; + p "native_pack_linker" native_pack_linker; +- p "ranlib" ranlib; + p "architecture" architecture; + p "model" model; + p_int "int_size" Sys.int_size; +-- +2.37.0.rc2 + diff --git a/0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch b/0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch new file mode 100644 index 0000000..7d5b111 --- /dev/null +++ b/0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch @@ -0,0 +1,27 @@ +From c04f2fbb3ae4dc8f67882bfe35d8565f016dee0f Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Fri, 15 Jul 2022 14:23:10 +0200 +Subject: [PATCH 13/24] tests/lib-bigarray-2/has-gfortran.sh: don't print + anything on stdout + +It confuses the summarize.awk script. +--- + testsuite/tests/lib-bigarray-2/has-gfortran.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/testsuite/tests/lib-bigarray-2/has-gfortran.sh b/testsuite/tests/lib-bigarray-2/has-gfortran.sh +index 051122113a..7eef1e662e 100644 +--- a/testsuite/tests/lib-bigarray-2/has-gfortran.sh ++++ b/testsuite/tests/lib-bigarray-2/has-gfortran.sh +@@ -5,7 +5,7 @@ if ! which gfortran > /dev/null 2>&1; then + elif ! grep -q '^CC=gcc' ${ocamlsrcdir}/Makefile.config; then + echo "OCaml was not compiled with gcc" > ${ocamltest_response} + test_result=${TEST_SKIP} +-elif gcc --version 2>&1 | grep 'Apple clang version'; then ++elif gcc --version 2>&1 | grep -q 'Apple clang version'; then + echo "OCaml was not compiled with gcc" > ${ocamltest_response} + test_result=${TEST_SKIP} + else +-- +2.37.0.rc2 + diff --git a/0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch b/0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch new file mode 100644 index 0000000..5a53fad --- /dev/null +++ b/0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch @@ -0,0 +1,147 @@ +From 4bb84be29e2ea5eb9f979c5e3bcbde1933aa300e Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Mon, 18 Jul 2022 10:08:53 +0200 +Subject: [PATCH 14/24] Merge pull request #11417 from + lpw25/fix-virtual-class-type-constrs + +Fix regression allowing virtual methods in non-virtual classes + +(cherry picked from commit 4be851ed8ea1f0c6be13dce04dcc97493c6c004b) +--- + Changes | 13 +----- + testsuite/tests/typing-objects/Tests.ml | 61 +++++++++++++++++++++++++ + typing/typeclass.ml | 11 +++++ + 3 files changed, 74 insertions(+), 11 deletions(-) + +diff --git a/Changes b/Changes +index 6f92ee9965..a9a9ee92f4 100644 +--- a/Changes ++++ b/Changes +@@ -25,17 +25,8 @@ OCaml 4.14 maintenance branch + - #11392, #11392: assertion failure with -rectypes and external definitions + (Gabriel Scherer, review by Florian Angeletti, report by Dmitrii Kosarev) + +-### Compiler user-interface and warnings: +- +-- #11184: Stop calling ranlib on created / installed libraries +- (Sébastien Hinderer, review by Xavier Leroy) +- +-### Manual and documentation: +- +-- #11045, #11409: document that the array argument to `caml_callbackN` +- must not have been declared by `CAMLlocalN`. +- (Xavier Leroy, report by Stephen Dolan, review by Gabriel Scherer.) +- ++- #11417: Fix regression allowing virtual methods in non-virtual classes. ++ (Leo White, review by Florian Angeletti) + + OCaml 4.14.0 (28 March 2022) + ---------------------------- +diff --git a/testsuite/tests/typing-objects/Tests.ml b/testsuite/tests/typing-objects/Tests.ml +index 3dcd87c43c..9cab28e432 100644 +--- a/testsuite/tests/typing-objects/Tests.ml ++++ b/testsuite/tests/typing-objects/Tests.ml +@@ -1344,3 +1344,64 @@ let _ = (new foo)#f true + class foo : object method f : bool -> bool end + - : bool = true + |}];; ++ ++ ++class c : object ++ method virtual m : int ++end = object ++ method m = 9 ++ end ++[%%expect {| ++Lines 1-3, characters 10-3: ++1 | ..........object ++2 | method virtual m : int ++3 | end......... ++Error: This non-virtual class type has virtual methods. ++ The following methods are virtual : m ++|}];; ++ ++class virtual c : object ++ method virtual m : int ++end = object ++ method m = 42 ++ end ++[%%expect {| ++class virtual c : object method virtual m : int end ++|}];; ++ ++class virtual cv = object ++ method virtual m : int ++ end ++ ++class c : cv = object ++ method m = 42 ++ end ++[%%expect {| ++class virtual cv : object method virtual m : int end ++Line 5, characters 10-12: ++5 | class c : cv = object ++ ^^ ++Error: This non-virtual class type has virtual methods. ++ The following methods are virtual : m ++|}];; ++ ++class virtual c : cv = object ++ method m = 41 ++ end ++[%%expect {| ++class virtual c : cv ++|}];; ++ ++class c = cv ++[%%expect {| ++Line 1, characters 10-12: ++1 | class c = cv ++ ^^ ++Error: This non-virtual class has virtual methods. ++ The following methods are virtual : m ++|}];; ++ ++class virtual c = cv ++[%%expect {| ++class virtual c : cv ++|}];; +diff --git a/typing/typeclass.ml b/typing/typeclass.ml +index fedbc0e025..8fa8523cc9 100644 +--- a/typing/typeclass.ml ++++ b/typing/typeclass.ml +@@ -177,6 +177,13 @@ let check_virtual loc env virt kind sign = + | meths, vars -> + raise(Error(loc, env, Virtual_class(kind, meths, vars))) + ++let rec check_virtual_clty loc env virt kind clty = ++ match clty with ++ | Cty_constr(_, _, clty) | Cty_arrow(_, _, clty) -> ++ check_virtual_clty loc env virt kind clty ++ | Cty_signature sign -> ++ check_virtual loc env virt kind sign ++ + (* Return the constructor type associated to a class type *) + let rec constructor_type constr cty = + match cty with +@@ -398,6 +405,8 @@ and class_type_aux env virt self_scope scty = + ) styl params + in + let typ = Cty_constr (path, params, clty) in ++ (* Check for unexpected virtual methods *) ++ check_virtual_clty scty.pcty_loc env virt Class_type typ; + cltyp (Tcty_constr ( path, lid , ctys)) typ + + | Pcty_signature pcsig -> +@@ -1077,6 +1086,8 @@ and class_expr_aux cl_num val_env met_env virt self_scope scl = + try Ctype.unify val_env ty' ty with Ctype.Unify err -> + raise(Error(cty'.ctyp_loc, val_env, Parameter_mismatch err))) + tyl params; ++ (* Check for unexpected virtual methods *) ++ check_virtual_clty scl.pcl_loc val_env virt Class clty'; + let cl = + rc {cl_desc = Tcl_ident (path, lid, tyl); + cl_loc = scl.pcl_loc; +-- +2.37.0.rc2 + diff --git a/0015-Do-not-elide-the-whole-module-type-error-message-114.patch b/0015-Do-not-elide-the-whole-module-type-error-message-114.patch new file mode 100644 index 0000000..2922112 --- /dev/null +++ b/0015-Do-not-elide-the-whole-module-type-error-message-114.patch @@ -0,0 +1,154 @@ +From 54eef17aeecfdbc6eeecd60b9cc64cd7c0129429 Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Wed, 20 Jul 2022 10:58:18 +0200 +Subject: [PATCH 15/24] Do not elide the whole module type error message + (#11416) + +(cherry picked from commit 8218be9e2b24907b8558776a34d12032bcc42496) +--- + Changes | 5 +- + .../inclusion_errors_elision.ml | 93 +++++++++++++++++++ + typing/includemod_errorprinter.ml | 11 ++- + 3 files changed, 107 insertions(+), 2 deletions(-) + create mode 100644 testsuite/tests/typing-modules/inclusion_errors_elision.ml + +diff --git a/Changes b/Changes +index a9a9ee92f4..6b9855f707 100644 +--- a/Changes ++++ b/Changes +@@ -14,7 +14,10 @@ OCaml 4.14 maintenance branch + (David Allsopp and Nicolás Ojeda Bär, review by Nicolás Ojeda Bär and + Sebastien Hinderer) + +-- #11358, #11378: Refactor the initialization of bytecode threading. ++- #11314, #11416: fix non-informative error message for module inclusion ++ (Florian Angeletti, report by Thierry Martinez, review by Gabriel Scherer) ++ ++- #11358, #11379: Refactor the initialization of bytecode threading, + This avoids a "dangling pointer" warning of GCC 12.1. + (Xavier Leroy, report by Armaël Guéneau, review by Gabriel Scherer) + +diff --git a/testsuite/tests/typing-modules/inclusion_errors_elision.ml b/testsuite/tests/typing-modules/inclusion_errors_elision.ml +new file mode 100644 +index 0000000000..3dbd0e67ff +--- /dev/null ++++ b/testsuite/tests/typing-modules/inclusion_errors_elision.ml +@@ -0,0 +1,93 @@ ++(* TEST ++ flags ="-keep-original-error-size" ++ * expect ++ *) ++ ++ ++module A = struct ++ type a and b and c and d ++end ++ ++module type S = sig ++ module B = A ++end ++ ++module C : S = struct ++ module B = struct ++ type a and b and c and d and e and f and g and h ++ end ++end ++[%%expect {| ++module A : sig type a and b and c and d end ++module type S = sig module B = A end ++Lines 9-13, characters 15-3: ++ 9 | ...............struct ++10 | module B = struct ++11 | type a and b and c and d and e and f and g and h ++12 | end ++13 | end ++Error: Signature mismatch: ++ ... ++ In module B: ++ Modules do not match: ++ sig ++ type a = B.a ++ and b = B.b ++ and c = B.c ++ and d = B.d ++ and e = B.e ++ and f = B.f ++ and g = B.g ++ and h = B.h ++ end ++ is not included in ++ (module A) ++|}] ++ ++module A = struct ++ type a and b and c and d ++end ++ ++module type S = sig ++ module type B = sig ++ module C = A ++ end ++end ++ ++module D : S = struct ++ module type B = sig ++ module C: sig ++ type a and b and c and d and e and f and g and h ++ end ++ end ++end ++[%%expect{| ++module A : sig type a and b and c and d end ++module type S = sig module type B = sig module C = A end end ++Lines 11-17, characters 15-3: ++11 | ...............struct ++12 | module type B = sig ++13 | module C: sig ++14 | type a and b and c and d and e and f and g and h ++15 | end ++16 | end ++17 | end ++Error: Signature mismatch: ++ ... ++ ... ++ ... ++ At position module type B = sig module C : end ++ Modules do not match: ++ sig ++ type a = C.a ++ and b = C.b ++ and c = C.c ++ and d = C.d ++ and e = C.e ++ and f = C.f ++ and g = C.g ++ and h = C.h ++ end ++ is not included in ++ (module A) ++|}] +diff --git a/typing/includemod_errorprinter.ml b/typing/includemod_errorprinter.ml +index 24d452fddc..b719e1627d 100644 +--- a/typing/includemod_errorprinter.ml ++++ b/typing/includemod_errorprinter.ml +@@ -709,7 +709,16 @@ let rec module_type ~expansion_token ~eqmode ~env ~before ~ctx diff = + functor_params ~expansion_token ~env ~before ~ctx d + | _ -> + let inner = if eqmode then eq_module_types else module_types in +- let next = dwith_context_and_elision ctx inner diff in ++ let next = ++ match diff.symptom with ++ | Mt_core _ -> ++ (* In those cases, the refined error messages for the current error ++ will at most add some minor comments on the current error. ++ It is thus better to avoid eliding the current error message. ++ *) ++ dwith_context ctx (inner diff) ++ | _ -> dwith_context_and_elision ctx inner diff ++ in + let before = next :: before in + module_type_symptom ~eqmode ~expansion_token ~env ~before ~ctx + diff.symptom +-- +2.37.0.rc2 + diff --git a/0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch b/0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch new file mode 100644 index 0000000..059fc99 --- /dev/null +++ b/0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch @@ -0,0 +1,57 @@ +From 4d316cbe4b564be3aa57b969acf9ba03910dcba4 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Sat, 30 Jul 2022 11:51:12 +0200 +Subject: [PATCH 16/24] Merge pull request #11373 from dra27/flexlink-detect + +Don't use CFLAGS when testing flexlink + +(cherry picked from commit 004d313ce4fdb071d0aeda8736b9e74bb6c6a21b) +--- + Changes | 6 ++++++ + aclocal.m4 | 1 + + configure | Bin 581549 -> 581563 bytes + 3 files changed, 7 insertions(+) + +diff --git a/Changes b/Changes +index 6b9855f707..99907b950a 100644 +--- a/Changes ++++ b/Changes +@@ -1,6 +1,12 @@ + OCaml 4.14 maintenance branch + ----------------------------- + ++### Build system: ++ ++- #11370, #11373: Don't pass CFLAGS to flexlink during configure. ++ (David Allsopp, report by William Hu, review by Xavier Leroy and ++ Sébastien Hinderer) ++ + ### Bug fixes: + + - #11204: Fix regression introduced in 4.14.0 that would trigger Warning 17 when +diff --git a/aclocal.m4 b/aclocal.m4 +index 7e49468e48..2bc0a1dcc9 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -328,6 +328,7 @@ AC_DEFUN([OCAML_TEST_FLEXLINK], [ + CC="$1 -chain $2 -exe" + LIBS="conftest2.$ac_objext" + CPPFLAGS="$3 $CPPFLAGS" ++ CFLAGS="" + AC_LINK_IFELSE( + [AC_LANG_SOURCE([int main() { return 0; }])], + [AC_MSG_RESULT([yes])], +diff --git a/configure b/configure +index 73ce66bfa0a3de5e886a88c973b2db288b5e4d03..c0dde03f183f86677b22a81238defdba60ad0080 100755 +GIT binary patch +delta 57 +zcmZ3xUwQX_<%Sl<7N!>F7M3lnkFIk%yZJb}2iqzsO&46x?lIl3ot?8??*=OnvjH*t +KcD)-M_3Qv?gA|zn + +delta 47 +zcmdnJUwQ3*<%Sl<7N!>F7M3lnkFHM-Tg~P?U2ZNbN4xb6Rv=~rV)pIUH#i#D0n)${ +AvH$=8 + +-- +2.37.0.rc2 + diff --git a/0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch b/0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch new file mode 100644 index 0000000..433fda9 --- /dev/null +++ b/0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch @@ -0,0 +1,55 @@ +From defecc867a0b5653554c41b06e78c0f24f6c10a8 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Tue, 2 Aug 2022 17:21:08 +0100 +Subject: [PATCH 17/24] Merge pull request #11468 from dra27/i686-mingw-ipv6 + +Fix detection of IPv6 on mingw-w64 i686 + +(cherry picked from commit 98392895940cc1c18534280ae001b70fa5bf24c2) +--- + Changes | 4 ++++ + configure | Bin 581563 -> 581611 bytes + configure.ac | 1 + + 3 files changed, 5 insertions(+) + +diff --git a/Changes b/Changes +index 99907b950a..6b537edca9 100644 +--- a/Changes ++++ b/Changes +@@ -37,6 +37,10 @@ OCaml 4.14 maintenance branch + - #11417: Fix regression allowing virtual methods in non-virtual classes. + (Leo White, review by Florian Angeletti) + ++- #11468: Fix regression from #10186 (OCaml 4.13) detecting IPv6 on Windows for ++ mingw-w64 i686 port. ++ (David Allsopp, review by Xavier Leroy and Sébastien Hinderer) ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +diff --git a/configure b/configure +index c0dde03f183f86677b22a81238defdba60ad0080..536a1cbee58a430692bfa3de11901e7e2f6b4ee2 100755 +GIT binary patch +delta 53 +zcmdnJU-|WZ<%Sl<7N!>F7M2#)7Pc+y(YK}x+-47$p3}xEG`-+2o7nVsH`#OBfnwVQ +JZgZ?=0RTku6-595 + +delta 53 +zcmV-50LuUCzazW9BY=bfgaU*Egam{Iga)(+TiTa!+Xo<*Y=#9AmvH?C7MJeX2fc@o +L+XuIh+X!0(RZ +Date: Mon, 22 Aug 2022 16:06:50 +0200 +Subject: [PATCH 18/24] More prudent deallocation of alternate signal stack + (#11496) + +After `caml_setup_stack_overflow_detection` is called, +a C library can install its own alternate stack for signal handling. + +Therefore, `caml_stop_stack_overflow_detection` must not free the +alternate signal stack block, only the block that +`caml_setup_stack_overflow_detection` allocated. + +Fixes: #11489 +--- + Changes | 4 +++ + otherlibs/systhreads/st_stubs.c | 5 ++-- + runtime/caml/signals.h | 4 +-- + runtime/signals_byt.c | 4 +-- + runtime/signals_nat.c | 47 +++++++++++++++++++++------------ + 5 files changed, 41 insertions(+), 23 deletions(-) + +diff --git a/Changes b/Changes +index 6b537edca9..4d1bb10435 100644 +--- a/Changes ++++ b/Changes +@@ -41,6 +41,10 @@ OCaml 4.14 maintenance branch + mingw-w64 i686 port. + (David Allsopp, review by Xavier Leroy and Sébastien Hinderer) + ++- #11489, #11496: More prudent deallocation of alternate signal stack ++ (Xavier Leroy, report by @rajdakin, review by Florian Angeletti) ++ ++ + OCaml 4.14.0 (28 March 2022) + ---------------------------- + +diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c +index b7a6a9a6bb..043e07031e 100644 +--- a/otherlibs/systhreads/st_stubs.c ++++ b/otherlibs/systhreads/st_stubs.c +@@ -524,6 +524,7 @@ static ST_THREAD_FUNCTION caml_thread_start(void * arg) + { + caml_thread_t th = (caml_thread_t) arg; + value clos; ++ void * signal_stack; + #ifdef NATIVE_CODE + struct longjmp_buffer termination_buf; + char tos; +@@ -536,7 +537,7 @@ static ST_THREAD_FUNCTION caml_thread_start(void * arg) + /* Acquire the global mutex */ + caml_leave_blocking_section(); + st_thread_set_id(Ident(th->descr)); +- caml_setup_stack_overflow_detection(); ++ signal_stack = caml_setup_stack_overflow_detection(); + #ifdef NATIVE_CODE + /* Setup termination handler (for caml_thread_exit) */ + if (sigsetjmp(termination_buf.buf, 0) == 0) { +@@ -550,7 +551,7 @@ static ST_THREAD_FUNCTION caml_thread_start(void * arg) + #ifdef NATIVE_CODE + } + #endif +- caml_stop_stack_overflow_detection(); ++ caml_stop_stack_overflow_detection(signal_stack); + /* The thread now stops running */ + return 0; + } +diff --git a/runtime/caml/signals.h b/runtime/caml/signals.h +index c6aeebfc78..62b0e7fafa 100644 +--- a/runtime/caml/signals.h ++++ b/runtime/caml/signals.h +@@ -87,8 +87,8 @@ value caml_do_pending_actions_exn (void); + value caml_process_pending_actions_with_root (value extra_root); // raises + value caml_process_pending_actions_with_root_exn (value extra_root); + int caml_set_signal_action(int signo, int action); +-CAMLextern int caml_setup_stack_overflow_detection(void); +-CAMLextern int caml_stop_stack_overflow_detection(void); ++CAMLextern void * caml_setup_stack_overflow_detection(void); ++CAMLextern int caml_stop_stack_overflow_detection(void *); + CAMLextern void caml_init_signals(void); + CAMLextern void caml_terminate_signals(void); + CAMLextern void (*caml_enter_blocking_section_hook)(void); +diff --git a/runtime/signals_byt.c b/runtime/signals_byt.c +index 439fb56404..7cb461ac4d 100644 +--- a/runtime/signals_byt.c ++++ b/runtime/signals_byt.c +@@ -81,7 +81,7 @@ int caml_set_signal_action(int signo, int action) + return 0; + } + +-CAMLexport int caml_setup_stack_overflow_detection(void) { return 0; } +-CAMLexport int caml_stop_stack_overflow_detection(void) { return 0; } ++CAMLexport void * caml_setup_stack_overflow_detection(void) { return NULL; } ++CAMLexport int caml_stop_stack_overflow_detection(void * p) { return 0; } + CAMLexport void caml_init_signals(void) { } + CAMLexport void caml_terminate_signals(void) { } +diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c +index 443f5d53b6..1dd8289c12 100644 +--- a/runtime/signals_nat.c ++++ b/runtime/signals_nat.c +@@ -254,6 +254,10 @@ DECLARE_SIGNAL_HANDLER(segv_handler) + + /* Initialization of signal stuff */ + ++#ifdef HAS_STACK_OVERFLOW_DETECTION ++static void * caml_signal_stack = NULL; ++#endif ++ + void caml_init_signals(void) + { + /* Bound-check trap handling */ +@@ -278,7 +282,8 @@ void caml_init_signals(void) + #endif + + #ifdef HAS_STACK_OVERFLOW_DETECTION +- if (caml_setup_stack_overflow_detection() != -1) { ++ caml_signal_stack = caml_setup_stack_overflow_detection(); ++ if (caml_signal_stack != NULL) { + struct sigaction act; + SET_SIGACT(act, segv_handler); + act.sa_flags |= SA_ONSTACK | SA_NODEFER; +@@ -314,7 +319,8 @@ void caml_terminate_signals(void) + + #ifdef HAS_STACK_OVERFLOW_DETECTION + set_signal_default(SIGSEGV); +- caml_stop_stack_overflow_detection(); ++ caml_stop_stack_overflow_detection(caml_signal_stack); ++ caml_signal_stack = NULL; + #endif + } + +@@ -323,37 +329,44 @@ void caml_terminate_signals(void) + Each thread needs its own alternate stack. + The alternate stack used to be statically-allocated for the main thread, + but this is incompatible with Glibc 2.34 and newer, where SIGSTKSZ +- may not be a compile-time constant (issue #10250). */ ++ may not be a compile-time constant (issue #10250). ++ Return the dynamically-allocated alternate signal stack, or NULL ++ if an error occurred. ++ The returned pointer must be passed to [caml_stop_stack_overflow_detection]. ++*/ + +-CAMLexport int caml_setup_stack_overflow_detection(void) ++CAMLexport void * caml_setup_stack_overflow_detection(void) + { + #ifdef HAS_STACK_OVERFLOW_DETECTION + stack_t stk; +- stk.ss_sp = malloc(SIGSTKSZ); +- if (stk.ss_sp == NULL) return -1; + stk.ss_size = SIGSTKSZ; ++ stk.ss_sp = malloc(stk.ss_size); ++ if (stk.ss_sp == NULL) return NULL; + stk.ss_flags = 0; + if (sigaltstack(&stk, NULL) == -1) { + free(stk.ss_sp); +- return -1; ++ return NULL; + } ++ return stk.ss_sp; ++#else ++ return NULL; + #endif +- /* Success (or stack overflow detection not available) */ +- return 0; + } + +-CAMLexport int caml_stop_stack_overflow_detection(void) ++CAMLexport int caml_stop_stack_overflow_detection(void * signal_stack) + { + #ifdef HAS_STACK_OVERFLOW_DETECTION + stack_t oldstk, stk; + stk.ss_flags = SS_DISABLE; ++ stk.ss_sp = NULL; /* not required but avoids a valgrind false alarm */ ++ stk.ss_size = SIGSTKSZ; /* macOS wants a valid size here */ + if (sigaltstack(&stk, &oldstk) == -1) return -1; +- /* If caml_setup_stack_overflow_detection failed, we are not using +- an alternate signal stack. SS_DISABLE will be set in oldstk, +- and there is nothing to free in this case. */ +- if (! (oldstk.ss_flags & SS_DISABLE)) free(oldstk.ss_sp); +- return 0; +-#else +- return 0; ++ /* Check whether someone else installed their own signal stack */ ++ if (!(oldstk.ss_flags & SS_DISABLE) && oldstk.ss_sp != signal_stack) { ++ /* Re-activate their signal stack. */ ++ sigaltstack(&oldstk, NULL); ++ } ++ free(signal_stack); + #endif ++ return 0; + } +-- +2.37.0.rc2 + diff --git a/0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch b/0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch new file mode 100644 index 0000000..67376f4 --- /dev/null +++ b/0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch @@ -0,0 +1,54 @@ +From a4633757e352b30f136d2a1cda827289d826ddc0 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Thu, 25 Aug 2022 08:44:47 +0100 +Subject: [PATCH 19/24] Merge pull request #11487 from + purplearmadillo77/fma_test + +Thwart FMA test optimization during configure + +(cherry picked from commit cd7dc7f6b9b5353acc2aa70bdc7bbecff56634d0) +--- + Changes | 3 +++ + aclocal.m4 | 2 +- + configure | Bin 581611 -> 581620 bytes + 3 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Changes b/Changes +index 4d1bb10435..763c0fa4b7 100644 +--- a/Changes ++++ b/Changes +@@ -7,6 +7,9 @@ OCaml 4.14 maintenance branch + (David Allsopp, report by William Hu, review by Xavier Leroy and + Sébastien Hinderer) + ++- #11???: Thwart FMA test optimization during configure ++ (William Hu, review by ???) ++ + ### Bug fixes: + + - #11204: Fix regression introduced in 4.14.0 that would trigger Warning 17 when +diff --git a/aclocal.m4 b/aclocal.m4 +index 2bc0a1dcc9..addb0d8bbf 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -440,7 +440,7 @@ int main (void) { + broken implementations of Cygwin64, mingw-w64 (x86_64) and VS2013-2017. + The static volatile variables aim to thwart GCC's constant folding. */ + static volatile double x, y, z; +- double t264, t265, t266; ++ volatile double t264, t265, t266; + x = 0x3.bd5b7dde5fddap-496; + y = 0x3.bd5b7dde5fddap-496; + z = -0xd.fc352bc352bap-992; +diff --git a/configure b/configure +index 536a1cbee58a430692bfa3de11901e7e2f6b4ee2..1a1dd61863e0435952ba6d6baf8131e68f070b3d 100755 +GIT binary patch +delta 44 +zcmaF8U-`>^<%Sl<7N!>F7M2#)Eo_r#a+KxgB$j06q_$6*$p*yi+b7NBh;#!0qIVJx + +delta 35 +qcmeyeU-|WZ<%Sl<7N!>F7M2#)Eo_r#w$GW#2E^>!=gj1Ya037qBM!s> + +-- +2.37.0.rc2 + diff --git a/0020-Fixup-Changes.patch b/0020-Fixup-Changes.patch new file mode 100644 index 0000000..1301d95 --- /dev/null +++ b/0020-Fixup-Changes.patch @@ -0,0 +1,36 @@ +From 19f5ef04dc344a82a3831f4b16f0be75c813dbf6 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Thu, 25 Aug 2022 08:48:34 +0100 +Subject: [PATCH 20/24] Fixup Changes + +--- + Changes | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/Changes b/Changes +index 763c0fa4b7..92d0837eb6 100644 +--- a/Changes ++++ b/Changes +@@ -7,8 +7,8 @@ OCaml 4.14 maintenance branch + (David Allsopp, report by William Hu, review by Xavier Leroy and + Sébastien Hinderer) + +-- #11???: Thwart FMA test optimization during configure +- (William Hu, review by ???) ++- #11487: Thwart FMA test optimization during configure ++ (William Hu, review by David Allsopp and Sébastien Hinderer) + + ### Bug fixes: + +@@ -21,7 +21,7 @@ OCaml 4.14 maintenance branch + before using it to ensure that the headers can always be used in code which + turns on -Wundef (or equivalent). + (David Allsopp and Nicolás Ojeda Bär, review by Nicolás Ojeda Bär and +- Sebastien Hinderer) ++ Sébastien Hinderer) + + - #11314, #11416: fix non-informative error message for module inclusion + (Florian Angeletti, report by Thierry Martinez, review by Gabriel Scherer) +-- +2.37.0.rc2 + diff --git a/0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch b/0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch new file mode 100644 index 0000000..913074d --- /dev/null +++ b/0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch @@ -0,0 +1,90 @@ +From e6dfa704c0f7847fe8e7a2a153714b4075019a0f Mon Sep 17 00:00:00 2001 +From: Chris Casinghino +Date: Fri, 2 Sep 2022 10:28:55 -0400 +Subject: [PATCH 21/24] Fix [@deprecated_mutable], which couldn't be triggered. + (#11524) + +Fixes #11516 + +(cherry picked from commit 024ca164ab844a9be94e0675bb5a1693bab7c08f) +--- + Changes | 2 ++ + .../warnings/deprecated_mutable.compilers.reference | 4 ++++ + testsuite/tests/warnings/deprecated_mutable.ml | 13 +++++++++++++ + typing/env.ml | 9 ++++++++- + 4 files changed, 27 insertions(+), 1 deletion(-) + create mode 100644 testsuite/tests/warnings/deprecated_mutable.compilers.reference + create mode 100644 testsuite/tests/warnings/deprecated_mutable.ml + +diff --git a/Changes b/Changes +index 92d0837eb6..aa8880ad07 100644 +--- a/Changes ++++ b/Changes +@@ -47,6 +47,8 @@ OCaml 4.14 maintenance branch + - #11489, #11496: More prudent deallocation of alternate signal stack + (Xavier Leroy, report by @rajdakin, review by Florian Angeletti) + ++- #11516, #11524: Fix the `deprecated_mutable` attribute. ++ (Chris Casinghino, review by Nicolás Ojeda Bär and Florian Angeletti) + + OCaml 4.14.0 (28 March 2022) + ---------------------------- +diff --git a/testsuite/tests/warnings/deprecated_mutable.compilers.reference b/testsuite/tests/warnings/deprecated_mutable.compilers.reference +new file mode 100644 +index 0000000000..620dc57de9 +--- /dev/null ++++ b/testsuite/tests/warnings/deprecated_mutable.compilers.reference +@@ -0,0 +1,4 @@ ++File "deprecated_mutable.ml", line 13, characters 11-12: ++13 | let () = y.x <- 42 ++ ^ ++Alert deprecated: mutating field x +diff --git a/testsuite/tests/warnings/deprecated_mutable.ml b/testsuite/tests/warnings/deprecated_mutable.ml +new file mode 100644 +index 0000000000..78fb12ac41 +--- /dev/null ++++ b/testsuite/tests/warnings/deprecated_mutable.ml +@@ -0,0 +1,13 @@ ++(* TEST ++ ++flags = "-w +A-70" ++ ++* bytecode ++ ++*) ++ ++type t = {mutable x : int [@deprecated_mutable]} ++ ++let y : t = {x = 5} ++ ++let () = y.x <- 42 +diff --git a/typing/env.ml b/typing/env.ml +index 06b99f4159..29d7cdb0e4 100644 +--- a/typing/env.ml ++++ b/typing/env.ml +@@ -104,6 +104,10 @@ let add_label_usage lu usage = + lu.lu_mutation <- true; + lu.lu_construct <- true + ++let is_mutating_label_usage = function ++ | Mutation -> true ++ | (Projection | Construct | Exported_private | Exported) -> false ++ + let label_usages () = + {lu_projection = false; lu_mutation = false; lu_construct = false} + +@@ -2723,7 +2727,10 @@ let use_cltype ~use ~loc path desc = + let use_label ~use ~loc usage env lbl = + if use then begin + mark_label_description_used usage env lbl; +- Builtin_attributes.check_alerts loc lbl.lbl_attributes lbl.lbl_name ++ Builtin_attributes.check_alerts loc lbl.lbl_attributes lbl.lbl_name; ++ if is_mutating_label_usage usage then ++ Builtin_attributes.check_deprecated_mutable loc lbl.lbl_attributes ++ lbl.lbl_name + end + + let use_constructor_desc ~use ~loc usage env cstr = +-- +2.37.0.rc2 + diff --git a/0022-Don-t-add-rpaths-to-libraries.patch b/0022-Don-t-add-rpaths-to-libraries.patch new file mode 100644 index 0000000..52b102b --- /dev/null +++ b/0022-Don-t-add-rpaths-to-libraries.patch @@ -0,0 +1,27 @@ +From e5312a9c481f91f2ca2cae1dc4176a78baaebf40 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 24 Jun 2014 10:00:15 +0100 +Subject: [PATCH 22/24] Don't add rpaths to libraries. + +--- + utils/config.mlp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/utils/config.mlp b/utils/config.mlp +index f758a9b483..ee17a737dc 100644 +--- a/utils/config.mlp ++++ b/utils/config.mlp +@@ -54,8 +54,8 @@ let native_c_compiler = + c_compiler ^ " " ^ ocamlopt_cflags ^ " " ^ ocamlopt_cppflags + let native_c_libraries = "%%NATIVECCLIBS%%" + let native_pack_linker = "%%PACKLD%%" +-let default_rpath = "%%RPATH%%" +-let mksharedlibrpath = "%%MKSHAREDLIBRPATH%%" ++let default_rpath = "" ++let mksharedlibrpath = "" + let ar = "%%ARCMD%%" + let supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%% + let mkdll, mkexe, mkmaindll = +-- +2.37.0.rc2 + diff --git a/0023-configure-Allow-user-defined-C-compiler-flags.patch b/0023-configure-Allow-user-defined-C-compiler-flags.patch new file mode 100644 index 0000000..fc715f8 --- /dev/null +++ b/0023-configure-Allow-user-defined-C-compiler-flags.patch @@ -0,0 +1,27 @@ +From 2501cd8b3c40188e5eb6dd2158d61cfa023236c2 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 29 May 2012 20:44:18 +0100 +Subject: [PATCH 23/24] configure: Allow user defined C compiler flags. + +--- + configure.ac | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/configure.ac b/configure.ac +index ebb8bbdb80..9e6c0b9745 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -680,6 +680,10 @@ AS_CASE([$host], + internal_cflags="$cc_warnings"], + [common_cflags="-O"])]) + ++# Allow CFLAGS and LDFLAGS to be added. ++common_cflags="$common_cflags $CFLAGS" ++cclibs="$cclibs $LDFLAGS" ++ + internal_cppflags="-DCAML_NAME_SPACE $internal_cppflags" + + # Enable SSE2 on x86 mingw to avoid using 80-bit registers. +-- +2.37.0.rc2 + diff --git a/0024-configure-Only-use-OC_-for-building-executables.patch b/0024-configure-Only-use-OC_-for-building-executables.patch new file mode 100644 index 0000000..1dbe2f2 --- /dev/null +++ b/0024-configure-Only-use-OC_-for-building-executables.patch @@ -0,0 +1,31 @@ +From 8e9ee6f765273d2c385b590a593e784472753d87 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 26 Jan 2022 15:47:02 +0000 +Subject: [PATCH 24/24] configure: Only use OC_* for building executables + +Fedora >= 36 fills LD_FLAGS with lots of cruft, particularly stuff for +"package notes" which contains build paths. + +In any case it seems pointless having both the OC_* variables and also +including the regular CFLAGS/LDFLAGS. Give me full control over what +ocamlopt uses. +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 9e6c0b9745..cab4cbd579 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -37,7 +37,7 @@ CONFIGURE_ARGS="$*" + # at the moment they are not taken into account on Windows, because + # flexlink, which is used to build executables on this platform, can + # not handle them. +-mkexe="\$(CC) \$(OC_CFLAGS) \$(CFLAGS) \$(OC_LDFLAGS) \$(LDFLAGS)" ++mkexe="\$(CC) \$(OC_CFLAGS) \$(OC_LDFLAGS)" + + # Flags for building executable files with debugging symbols + mkexedebugflag="-g" +-- +2.37.0.rc2 + diff --git a/gating.yaml b/gating.yaml deleted file mode 100755 index 2c7ed80..0000000 --- a/gating.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- !Policy -product_versions: - - rhel-* -decision_context: osci_compose_gate -rules: - - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/macros.ocaml-rpm b/macros.ocaml-rpm deleted file mode 100644 index ac94c48..0000000 --- a/macros.ocaml-rpm +++ /dev/null @@ -1,69 +0,0 @@ -# Make %files lists from an installed tree of files. -# Options: -# -s: separate packaging; every subdirectory of %%{ocamldir}, except stublibs, -# is placed in its own package. This option requires the existence of opam -# *.install files in the build tree. -# -n: suppress creation of a devel subpackage. -%ocaml_files(sn) %{python3} /usr/lib/rpm/redhat/ocaml_files.py %{-s} %{-n} %{buildroot} %{ocamldir} - -# Internal macro holding the common parts of ocaml_install and dune_install -%ocaml_install_common(sn) %{expand: -rm -rf %{buildroot}%{_prefix}/doc -mlis=$(find %{buildroot}%{_libdir}/ocaml -name '*.mli') -rm -f ${mlis//.mli/.ml} -%ocaml_files %{-s} %{-n}} - -# Install files listed in opam *.install files. -# Options: -# -s: separate packaging; every subdirectory of %%{ocamldir}, except stublibs, -# is placed in its own package. -# -n: suppress creation of a devel subpackage. -%ocaml_install(sn) %{expand: -%{python3} /usr/lib/rpm/redhat/ocaml_files.py -i %{-s} %{-n} %{buildroot} %{ocamldir} -%ocaml_install_common %{-s} %{-n}} - -# Add smp_mflags to arguments if no -j release option is given. -# Add --release to arguments if no -p or --release option is given. -# Add --verbose to arguments if it is not given. -%dune_add_flags(-) %{lua: - has_j = false - has_p = false - has_v = false - for _, flag in pairs(arg) do - if flag:find("^-j") then - has_j = true - elseif flag:find("^-p") or flag:find("^--release)") then - has_p = true - elseif flag:find("^--verbose") then - has_v = true - end - end - if not has_j then - table.insert(arg, 1, rpm.expand("%{?_smp_mflags}")) - end - if not has_p then - table.insert(arg, 1, "--release") - end - if not has_v then - table.insert(arg, 1, "--verbose") - end - print(table.concat(arg, " ")) -} - -# Build with dune -%dune_build(-) dune build %{dune_add_flags %*} - -# Run tests with dune -%dune_check(-) dune runtest %{dune_add_flags %*} - -# Install with dune -# Options: -# -s: separate packaging; every subdirectory of %%{ocamldir}, except stublibs, -# is placed in its own package. -# -n: suppress creation of a devel subpackage. -%dune_install(sn) %{expand: -dune install --destdir=%{buildroot} %{dune_add_flags %*} -if [ -d _build/default/_doc/_html ]; then - find _build/default/_doc/_html -name .dune-keep -delete -fi -%ocaml_install_common %{-s} %{-n}} diff --git a/ocaml.spec b/ocaml.spec index 3b39d37..3f03c76 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -18,14 +18,9 @@ %global natdynlink 0 %endif -%global giturl https://github.com/ocaml/ocaml - -# i686 support was dropped in OCaml 5 / Fedora 39. -ExcludeArch: %{ix86} - # These are all the architectures that the tests run on. The tests # take a long time to run, so don't run them on slow machines. -%global test_arches %{arm64} %{power64} %{riscv64} s390x %{x86_64} +%global test_arches aarch64 %{power64} riscv64 x86_64 # These are the architectures for which the tests must pass otherwise # the build will fail. #global test_arches_required aarch64 ppc64le x86_64 @@ -38,19 +33,16 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.5.0 -Release: 2%{?dist} +Version: 4.14.0 +Release: 3%{?dist} Summary: OCaml compiler and programming environment -License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception +License: QPL and (LGPLv2+ with exceptions) URL: https://www.ocaml.org -VCS: git:%{giturl}.git -Source0: %{giturl}/archive/%{version}%{rcver}/%{name}-%{version}%{rcver}.tar.gz -Source1: macros.ocaml-rpm -Source2: ocaml_files.py +Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{version}.tar.gz # IMPORTANT NOTE: # @@ -61,55 +53,71 @@ Source2: ocaml_files.py # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-45-5.4.1 +# Current branch: fedora-38-4.14.0 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should # be incorporated into the git repo at a later time. +# Patches added after 4.14.0 was released +Patch0001: 0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch +Patch0002: 0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch +Patch0003: 0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch +Patch0004: 0004-Changes.patch +Patch0005: 0005-Guard-more-instances-of-undefined-_MSC_VER.patch +Patch0006: 0006-Better-documentation-for-string_of_float-.-11353.patch +Patch0007: 0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch +Patch0008: 0008-Refactor-the-initialization-of-bytecode-threading-11.patch +Patch0009: 0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch +Patch0010: 0010-Merge-pull-request-11396-from-gasche-fix11392.patch +Patch0011: 0011-Document-limitation-on-caml_callbackN-11409.patch +Patch0012: 0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch +Patch0013: 0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch +Patch0014: 0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch +Patch0015: 0015-Do-not-elide-the-whole-module-type-error-message-114.patch +Patch0016: 0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch +Patch0017: 0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch +Patch0018: 0018-More-prudent-deallocation-of-alternate-signal-stack-.patch +Patch0019: 0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch +Patch0020: 0020-Fixup-Changes.patch +Patch0021: 0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch + # Fedora-specific patches -Patch: 0001-Don-t-add-rpaths-to-libraries.patch -Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch +Patch0022: 0022-Don-t-add-rpaths-to-libraries.patch +Patch0023: 0023-configure-Allow-user-defined-C-compiler-flags.patch +Patch0024: 0024-configure-Only-use-OC_-for-building-executables.patch BuildRequires: make -BuildRequires: git-core +BuildRequires: git BuildRequires: gcc BuildRequires: autoconf +BuildRequires: binutils-devel +BuildRequires: ncurses-devel +BuildRequires: gdbm-devel BuildRequires: gawk BuildRequires: perl-interpreter -BuildRequires: annobin-annocheck -BuildRequires: pkgconfig(libzstd) - -# Documentation requirements -BuildRequires: asciidoc +BuildRequires: util-linux +BuildRequires: /usr/bin/annocheck # ocamlopt runs gcc to link binaries. Because Fedora includes # hardening flags automatically, redhat-rpm-config is also required. -# Compressed marshaling requires libzstd-devel. Requires: gcc Requires: redhat-rpm-config -Requires: libzstd-devel%{?_isa} # Because we pass -c flag to ocaml-find-requires (to avoid circular # dependencies) we also have to explicitly depend on the right version # of ocaml-runtime. Requires: ocaml-runtime%{?_isa} = %{version}-%{release} -# Force ocaml-srpm-macros to be at the latest version, both for builds -# and installs, since OCaml 5.2 has a different set of native code -# generators than previous versions. -BuildRequires: ocaml-srpm-macros >= 10 -Requires: ocaml-srpm-macros >= 10 +# Bundles an MD5 implementation in runtime/caml/md5.h and runtime/md5.c +Provides: bundled(md5-plumb) Provides: ocaml(compiler) = %{version} -%if %{native_compiler} -%global __ocaml_requires_opts -c -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' -i Dynlink_cmo_format -i Dynlink_cmxs_format -%else -%global __ocaml_requires_opts -c -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' -i Backend_intf -i Inlining_decision_intf -i Simplify_boxed_integer_ops_intf -%endif +%global __ocaml_requires_opts -c -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' %global __ocaml_provides_opts -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' + %description OCaml is a high-level, strongly-typed, functional and object-oriented programming language from the ML family of languages. @@ -121,16 +129,10 @@ and a comprehensive library. %package runtime -# LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception: the project as a whole -# LicenseRef-Fedora-Public-Domain: the MD5 implementation in runtime/caml/md5.h -# and runtime/md5.c -License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception AND LicenseRef-Fedora-Public-Domain Summary: OCaml runtime environment +Requires: util-linux Provides: ocaml(runtime) = %{version} -# Bundles an MD5 implementation in runtime/caml/md5.h and runtime/md5.c -Provides: bundled(md5-plumb) - %description runtime OCaml is a high-level, strongly-typed, functional and object-oriented programming language from the ML family of languages. @@ -148,9 +150,6 @@ Source code for OCaml libraries. %package ocamldoc -# LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception: the project as a whole -# LicenseRef-Fedora-Public-Domain: ocamldoc/ocamldoc.sty -License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception AND LicenseRef-Fedora-Public-Domain Summary: Documentation generator for OCaml Requires: ocaml%{?_isa} = %{version}-%{release} Provides: ocamldoc = %{version} @@ -161,7 +160,6 @@ Documentation generator for OCaml. %package docs Summary: Documentation for OCaml -BuildArch: noarch Requires: ocaml = %{version}-%{release} @@ -187,20 +185,6 @@ Note that this exposes internal details of the OCaml compiler which may not be portable between versions. -%package rpm-macros -# LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception: the project as a whole -# BSD-3-Clause: ocaml_files.py -License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception AND BSD-3-Clause -Summary: RPM macros for building OCaml packages -BuildArch: noarch -Requires: ocaml = %{version}-%{release} -Requires: python3 - - -%description rpm-macros -This package contains macros that are useful for building OCaml RPMs. - - %prep %autosetup -S git -n %{name}-%{version}%{rcver} # Patches touch configure.ac, so rebuild it: @@ -215,12 +199,6 @@ unset MAKEFLAGS make=make %endif -# Set ocamlmklib default flags to include Fedora linker flags -sed -i '/ld_opts/s|\[\]|["%{build_ldflags}"]|' tools/ocamlmklib.ml - -# Expose a dependency on the math library -sed -i '/^EXTRACAMLFLAGS=/aLINKOPTS=-cclib -lm' otherlibs/unix/Makefile - # Don't use %%configure macro because it sets --build, --host which # breaks some incorrect assumptions made by OCaml's configure.ac # @@ -240,26 +218,8 @@ sed -i '/^EXTRACAMLFLAGS=/aLINKOPTS=-cclib -lm' otherlibs/unix/Makefile --sysconfdir=%{_sysconfdir} \ --mandir=%{_mandir} \ --libdir=%{_libdir}/ocaml \ - --enable-flambda \ -%if %{native_compiler} - --enable-native-compiler \ - --enable-native-toplevel \ -%else - --disable-native-compiler \ - --disable-native-toplevel \ -%endif -%ifarch %{x86_64} %{arm64} -%if 0%{?_include_frame_pointers} - --enable-frame-pointers \ -%endif -%endif -%ifarch %{test_arches} - --enable-ocamltest \ -%else - --disable-ocamltest \ -%endif - OC_CFLAGS='%{build_cflags}' \ - OC_LDFLAGS='%{build_ldflags}' \ + OC_CFLAGS="$CFLAGS" \ + OC_LDFLAGS="$LDFLAGS" \ %{nil} $make world %if %{native_compiler} @@ -267,13 +227,6 @@ $make opt $make opt.opt %endif -# Build the README and fix up references to other doc files -asciidoc -d book README.adoc -for fil in CONTRIBUTING.md HACKING.adoc INSTALL.adoc README.win32.adoc; do - sed -e "s,\"$fil\",\"https://github.com/ocaml/ocaml/blob/trunk/$fil\"," \ - -i README.html -done - %check %ifarch %{ocaml_native_compiler} @@ -286,6 +239,10 @@ annocheck -v hello ||: %endif %ifarch %{test_arches} +make ocamltest +%ifarch %{ocaml_native_compiler} +make ocamltest.opt +%endif %ifarch %{test_arches_required} make -j1 tests %else @@ -296,21 +253,16 @@ make -j1 tests ||: %install %make_install - -# OCaml 5.5.0 uses relative paths in ld.conf by default to support relocatable -# OCaml, which we don't need. Overwrite ld.conf with the absolute path. -echo %{_libdir}/ocaml/stublibs > $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf +perl -pi -e "s|^$RPM_BUILD_ROOT||" $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf echo %{version} > $RPM_BUILD_ROOT%{_libdir}/ocaml/fedora-ocaml-release # Remove the installed documentation. We will install it using %%doc rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml -mkdir -p $RPM_BUILD_ROOT%{rpmmacrodir} -install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT%{rpmmacrodir}/macros.ocaml-rpm - -mkdir -p $RPM_BUILD_ROOT%{_rpmconfigdir}/redhat -install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_rpmconfigdir}/redhat +# Remove this file. It's only created in certain situations and it's +# unclear why it is created at all. +rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files @@ -318,110 +270,98 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_rpmconfigdir}/redhat %{_bindir}/ocaml %{_bindir}/ocamlcmt -%{_bindir}/ocamlcp %{_bindir}/ocamldebug -%{_bindir}/ocamlmklib -%{_bindir}/ocamlmktop -%{_bindir}/ocamlprof +#{_bindir}/ocaml-instr-graph +#{_bindir}/ocaml-instr-report %{_bindir}/ocamlyacc # symlink to either .byte or .opt version %{_bindir}/ocamlc +%{_bindir}/ocamlcp %{_bindir}/ocamldep %{_bindir}/ocamllex +%{_bindir}/ocamlmklib +%{_bindir}/ocamlmktop %{_bindir}/ocamlobjinfo +%{_bindir}/ocamloptp +%{_bindir}/ocamlprof # bytecode versions %{_bindir}/ocamlc.byte +%{_bindir}/ocamlcp.byte %{_bindir}/ocamldep.byte %{_bindir}/ocamllex.byte +%{_bindir}/ocamlmklib.byte +%{_bindir}/ocamlmktop.byte %{_bindir}/ocamlobjinfo.byte +%{_bindir}/ocamloptp.byte +%{_bindir}/ocamlprof.byte %if %{native_compiler} # native code versions %{_bindir}/ocamlc.opt +%{_bindir}/ocamlcp.opt %{_bindir}/ocamldep.opt %{_bindir}/ocamllex.opt +%{_bindir}/ocamlmklib.opt +%{_bindir}/ocamlmktop.opt %{_bindir}/ocamlobjinfo.opt +%{_bindir}/ocamloptp.opt +%{_bindir}/ocamlprof.opt %endif %if %{native_compiler} -%{_bindir}/ocamlnat %{_bindir}/ocamlopt %{_bindir}/ocamlopt.byte %{_bindir}/ocamlopt.opt -%{_bindir}/ocamloptp %endif +#%%{_libdir}/ocaml/addlabels +#%%{_libdir}/ocaml/scrapelabels +%{_libdir}/ocaml/camlheader +%{_libdir}/ocaml/camlheader_ur %{_libdir}/ocaml/expunge +%{_libdir}/ocaml/ld.conf %{_libdir}/ocaml/Makefile.config - %{_libdir}/ocaml/*.a +%if %{natdynlink} +%{_libdir}/ocaml/*.cmxs +%endif %if %{native_compiler} %{_libdir}/ocaml/*.cmxa %{_libdir}/ocaml/*.cmx %{_libdir}/ocaml/*.o +%{_libdir}/ocaml/libasmrun_shared.so %endif %{_libdir}/ocaml/*.mli -%{_libdir}/ocaml/sys.ml.in - -%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.mli +%{_libdir}/ocaml/libcamlrun_shared.so +#%%{_libdir}/ocaml/objinfo_helper +%{_libdir}/ocaml/threads/*.mli %if %{native_compiler} -%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.a -%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.cmxa -%{_libdir}/ocaml/{dynlink,profiling,runtime_events,str,threads,unix}/*.cmx -%{_libdir}/ocaml/profiling/*.o +%{_libdir}/ocaml/threads/*.a +%{_libdir}/ocaml/threads/*.cmxa +%{_libdir}/ocaml/threads/*.cmx %endif -%if %{natdynlink} -%{_libdir}/ocaml/{runtime_events,str,unix}/*.cmxs -%endif - -# headers %{_libdir}/ocaml/caml %files runtime -%doc README.html Changes +%doc README.adoc Changes %license LICENSE %{_bindir}/ocamlrun -%{_bindir}/*ocamlrun-a100 %{_bindir}/ocamlrund -%{_bindir}/*ocamlrund-a100 %{_bindir}/ocamlruni -%{_bindir}/*ocamlruni-a100 %dir %{_libdir}/ocaml -%{_libdir}/ocaml/libasmrun*.so -%{_libdir}/ocaml/libcamlrun*.so +#%%{_libdir}/ocaml/VERSION %{_libdir}/ocaml/*.cmo %{_libdir}/ocaml/*.cmi %{_libdir}/ocaml/*.cma -%{_libdir}/ocaml/ld.conf +%{_libdir}/ocaml/camlheaderd +%{_libdir}/ocaml/camlheaderi %{_libdir}/ocaml/stublibs -%dir %{_libdir}/ocaml/dynlink -%{_libdir}/ocaml/dynlink/META -%{_libdir}/ocaml/dynlink/*.cmi -%{_libdir}/ocaml/dynlink/*.cma -%dir %{_libdir}/ocaml/profiling -%{_libdir}/ocaml/profiling/*.cmo -%{_libdir}/ocaml/profiling/*.cmi -%dir %{_libdir}/ocaml/runtime_events -%{_libdir}/ocaml/runtime_events/META -%{_libdir}/ocaml/runtime_events/*.cmi -%{_libdir}/ocaml/runtime_events/*.cma -%{_libdir}/ocaml/runtime-launch-info -%{_libdir}/ocaml/stdlib -%dir %{_libdir}/ocaml/str -%{_libdir}/ocaml/str/META -%{_libdir}/ocaml/str/*.cmi -%{_libdir}/ocaml/str/*.cma %dir %{_libdir}/ocaml/threads -%{_libdir}/ocaml/threads/META %{_libdir}/ocaml/threads/*.cmi %{_libdir}/ocaml/threads/*.cma -%dir %{_libdir}/ocaml/unix -%{_libdir}/ocaml/unix/META -%{_libdir}/ocaml/unix/*.cmi -%{_libdir}/ocaml/unix/*.cma %{_libdir}/ocaml/fedora-ocaml-release @@ -446,113 +386,20 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_rpmconfigdir}/redhat %files compiler-libs %license LICENSE -%{_libdir}/ocaml/compiler-libs - - -%files rpm-macros -%{rpmmacrodir}/macros.ocaml-rpm -%{_rpmconfigdir}/redhat/ocaml_files.py +%dir %{_libdir}/ocaml/compiler-libs +%{_libdir}/ocaml/compiler-libs/*.mli +%{_libdir}/ocaml/compiler-libs/*.cmi +%{_libdir}/ocaml/compiler-libs/*.cmo +%{_libdir}/ocaml/compiler-libs/*.cma +%if %{native_compiler} +%{_libdir}/ocaml/compiler-libs/*.a +%{_libdir}/ocaml/compiler-libs/*.cmxa +%{_libdir}/ocaml/compiler-libs/*.cmx +%{_libdir}/ocaml/compiler-libs/*.o +%endif %changelog -* Thu Jul 16 2026 Fedora Release Engineering - 5.5.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild - -* Tue Jun 23 2026 Jerry James - 5.5.0-1 -- New upstream version 5.5.0 (RHBZ#2442622) -- Drop upstreamed fix for arm64 frame pointers -- Reenable LTO -- Move ld.conf, libasmrun, and libcamlrun to ocaml-runtime -- Drop hardlink dependency; rpm now does this by default -- Drop unused utilx-linux dependency - -* Thu Feb 26 2026 Richard W.M. Jones - 5.4.1-4 -- Backport fix for arm64 frame pointers - -* Fri Feb 20 2026 Richard W.M. Jones - 5.4.1-1 -- New upstream version 5.4.1 (RHBZ#2440356) - -* Fri Jan 16 2026 Fedora Release Engineering - 5.4.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild - -* Mon Oct 13 2025 Richard W.M. Jones - 5.4.0-1 -- New upstream version 5.4.0 (RHBZ#2368289) - -* Thu Jul 24 2025 Fedora Release Engineering - 5.3.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Sun Jun 22 2025 Yaakov Selkowitz - 5.3.0-3 -- Fix RPM macros for Python 3.14 - -* Fri Jan 17 2025 Fedora Release Engineering - 5.3.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Thu Jan 9 2025 Jerry James - 5.3.0-1 -- New upstream version 5.3.0 -- Drop upstreamed patches -- BR git-core instead of git - -* Thu Jul 18 2024 Fedora Release Engineering - 5.2.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Wed Jun 19 2024 Richard W.M. Jones - 5.2.0-2 -- Add fix for ppc64le code generation issue found after 5.2.0 was released - -* Thu May 23 2024 Jerry James - 5.2.0-1 -- New upstream version 5.2.0 (RHBZ#2269805) -- Drop upstreamed frame pointer and s390x patches - -* Thu Jan 25 2024 Fedora Release Engineering - 5.1.1-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Sun Jan 21 2024 Fedora Release Engineering - 5.1.1-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Mon Dec 18 2023 Richard W.M. Jones - 5.1.1-2 -- Add s390x code generation fix - https://github.com/ocaml/ocaml/issues/12829 - -* Mon Dec 11 2023 Richard W.M. Jones - 5.1.1-1 -- New upstream version 5.1.1 (RHBZ#2239227) - -* Tue Nov 14 2023 Yaakov Selkowitz - 5.1.0-5 -- Drop unused BR parallel - -* Fri Oct 06 2023 Richard W.M. Jones - 5.1.0-4 -- Use BR ocaml-srpm-macros to force latest to be built against - -* Thu Oct 05 2023 Richard W.M. Jones - 5.1.0-3 -- Rebuild against updated ocaml-srpm-macros - -* Thu Oct 5 2023 Richard W.M. Jones - 5.1.0-2 -- Add upstream patch added after 5.1.0 - -* Wed Oct 4 2023 Jerry James - 5.1.0-1 -- Version 5.1.0 -- Add LicenseRef-Fedora-Public-Domain to the runtime License field -- New ocaml-rpm-macros subpackage -- Depend on libzstd-devel for compressed marshaling -- Disable LTO - -* Thu Jul 20 2023 Fedora Release Engineering - 5.0.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Wed Jul 12 2023 Richard W.M. Jones - 5.0.0-3 -- Force ocaml-srpm-macros to be the latest version. - -* Wed Jun 14 2023 Jerry James - 5.0.0-2 -- Version 5.0.0 -- Convert License tag to SPDX -- Ship HTML documentation instead of asciidoc source -- Set ocamlmklib default flags to the Fedora linker flags -- Enable frame pointers on x86_64 - -* Mon Jan 23 2023 Richard W.M. Jones - 4.14.0-5 -- Rebuild OCaml packages for F38 - -* Thu Jan 19 2023 Fedora Release Engineering - 4.14.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - * Mon Sep 5 2022 Richard W.M. Jones - 4.14.0-3 - Include more upstream patches from 4.14 branch diff --git a/ocaml_files.py b/ocaml_files.py deleted file mode 100644 index 0e4658e..0000000 --- a/ocaml_files.py +++ /dev/null @@ -1,451 +0,0 @@ -# Copyright 2022-3, Jerry James -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# 3. Neither the name of Red Hat nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import argparse -import os -import shutil -import string -import sys -from collections.abc import Iterable, Iterator -from enum import Enum, auto -from typing import Callable, final - -# Version of this script -version=2 - -# -# BUILDROOT CATEGORIZATION -# - -# Directories to ignore when generating %dir entries -root_dirs: set[str] = { - '/', - '/etc', - '/usr', - '/usr/bin', - '/usr/lib', - '/usr/lib/ocaml', - '/usr/lib/ocaml/caml', - '/usr/lib/ocaml/stublibs', - '/usr/lib/ocaml/threads', - '/usr/lib64', - '/usr/lib64/ocaml', - '/usr/lib64/ocaml/caml', - '/usr/lib64/ocaml/stublibs', - '/usr/lib64/ocaml/threads', - '/usr/libexec', - '/usr/sbin', - '/usr/share', - '/usr/share/doc' -} - -def find_buildroot_toplevel(buildroot: str) -> list[str]: - """Find toplevel files and directories in the buildroot. - - :param str buildroot: path to the buildroot - :return: a list of toplevel files and directories in the buildroot - """ - bfiles: list[str] = [] - for path, dirs, files in os.walk(buildroot): - for i in range(len(dirs) - 1, -1, -1): - d = os.path.join(path, dirs[i])[len(buildroot):] - if d not in root_dirs and not d.startswith('/usr/share/man'): - bfiles.append(d) - del dirs[i] - for f in files: - realfile = os.path.join(path, f)[len(buildroot):] - if realfile.startswith('/usr/share/man'): - bfiles.append(realfile + '*') - else: - bfiles.append(realfile) - return bfiles - -# File suffixes that go into a devel subpackage -dev_suffixes: set[str] = { - 'a', 'cmo', 'cmt', 'cmti', 'cmx', 'cmxa', 'h', 'idl', 'ml', 'mli', 'o' -} - -def is_devel_file(filname: str) -> bool: - """Determine whether a file belongs to a devel subpackage. - - :param str filname: the filename to check - :return: True if the file belongs to a devel subpackage, else False - """ - return (filname == 'dune-package' or filname == 'opam' or - (os.path.splitext(filname)[1][1:] in dev_suffixes - and not filname.endswith('_top_init.ml'))) - -def find_buildroot_all(buildroot: str, devel: bool, add_star: bool) -> list[set[str]]: - """Find all files and directories in the buildroot and optionally - categorize them as 'main' or 'devel'. - - :param Namespace args: parsed command line arguments - :param bool devel: True to split into 'main' and 'devel', False otherwise - :param bool add_star: True to add a star to man page filenames - :return: a list of files and directories, in this order: main files, - main directories, devel files, and devel directories - """ - bfiles: list[set[str]] = [set(), set(), set()] - bdirs: set[str] = set() - for path, dirs, files in os.walk(buildroot): - for d in dirs: - realdir = os.path.join(path, d)[len(buildroot):] - if realdir not in root_dirs and not realdir.startswith('/usr/share/man'): - bdirs.add(realdir) - for f in files: - realfile = os.path.join(path, f)[len(buildroot):] - if devel and is_devel_file(os.path.basename(realfile)): - bfiles[2].add(realfile) - else: - if add_star and realfile.startswith('/usr/share/man'): - bfiles[0].add(realfile + '*') - else: - bfiles[0].add(realfile) - parentdir = os.path.dirname(realfile) - if parentdir in bdirs: - bfiles[1].add(parentdir) - bdirs.remove(parentdir) - # Catch intermediate directories, as in ocaml-mtime - parentdir = os.path.dirname(parentdir) - if parentdir in bdirs: - bfiles[1].add(parentdir) - bdirs.remove(parentdir) - bfiles.append(bdirs) - return bfiles - -# -# INSTALL FILE LEXER AND PARSER -# - -class TokenType(Enum): - """The types of tokens that can appear in an opam *.install file.""" - ERROR = auto() - COLON = auto() - LBRACE = auto() - RBRACE = auto() - LBRACK = auto() - RBRACK = auto() - STRING = auto() - FIELD = auto() - -@final -class InstallFileLexer(Iterator[tuple[TokenType, str]]): - """Convert an opam *.install file into a sequence of tokens.""" - __slots__ = ['index', 'text'] - - def __init__(self, filname: str) -> None: - """Create an opam *.install file lexer. - - :param str filname: the name of the file to read from - """ - self.index = 0 - with open(filname, 'r') as f: - # Limit reads to 4 MB in case this file is bogus. - # Most install files are under 4K. - self.text = f.read(4194304) - - def skip_whitespace(self) -> None: - """Skip over whitespace in the input.""" - while self.index < len(self.text) and \ - (self.text[self.index] == '#' or - self.text[self.index] in string.whitespace): - if self.text[self.index] == '#': - while (self.index < len(self.text) and - self.text[self.index] != '\n' and - self.text[self.index] != '\r'): - self.index += 1 - else: - self.index += 1 - - def __next__(self) -> tuple[TokenType, str]: - """Get the next token from the opam *.install file. - - :return: a pair containing the type and text of the next token - """ - self.skip_whitespace() - if self.index < len(self.text): - ch = self.text[self.index] - if ch == ':': - self.index += 1 - return (TokenType.COLON, ch) - if ch == '{': - self.index += 1 - return (TokenType.LBRACE, ch) - if ch == '}': - self.index += 1 - return (TokenType.RBRACE, ch) - if ch == '[': - self.index += 1 - return (TokenType.LBRACK, ch) - if ch == ']': - self.index += 1 - return (TokenType.RBRACK, ch) - if ch == '"': - start = self.index + 1 - end = start - while end < len(self.text) and self.text[end] != '"': - end += 2 if self.text[end] == '\\' else 1 - self.index = end + 1 - return (TokenType.STRING, self.text[start:end]) - if ch in string.ascii_letters: - start = self.index - end = start + 1 - while (end < len(self.text) and - (self.text[end] == '_' or - self.text[end] in string.ascii_letters)): - end += 1 - self.index = end - return (TokenType.FIELD, self.text[start:end]) - return (TokenType.ERROR, ch) - else: - raise StopIteration - -@final -class InstallFileParser(Iterable[tuple[str, bool, str, str]]): - """Parse opam *.install files.""" - - __slots__ = ['pkgname', 'lexer', 'libdir'] - - def __init__(self, filname: str, libdir: str) -> None: - """Initialize an OCaml .install file parser. - - :param str filname: name of the .install file to parse - :param str libdir: the OCaml library directory - """ - self.pkgname = os.path.splitext(os.path.basename(filname))[0] - self.lexer = InstallFileLexer(filname) - self.libdir = libdir - - def __iter__(self) -> Iterator[tuple[str, bool, str, str]]: - """Parse a .install file. - If there are any parse errors, we assume this file is not really an - opam .install file and abandon the parse. - """ - # Map opam installer names to directories - opammap: dict[str, str] = { - 'lib': os.path.join(self.libdir, self.pkgname), - 'lib_root': self.libdir, - 'libexec': os.path.join(self.libdir, self.pkgname), - 'libexec_root': self.libdir, - 'bin': '/usr/bin', - 'sbin': '/usr/sbin', - 'toplevel': os.path.join(self.libdir, 'toplevel'), - 'share': os.path.join('/usr/share', self.pkgname), - 'share_root': '/usr/share', - 'etc': os.path.join('/etc', self.pkgname), - 'doc': os.path.join('/usr/doc', self.pkgname), - 'stublibs': os.path.join(self.libdir, 'stublibs'), - 'man': '/usr/share/man' - } - - # Parse the file - try: - toktyp, token = next(self.lexer) - while toktyp == TokenType.FIELD: - libname = token - toktyp, token = next(self.lexer) - if toktyp != TokenType.COLON: - return - - toktyp, token = next(self.lexer) - if toktyp != TokenType.LBRACK: - return - - directory = opammap.get(libname) - if not directory: - return - - toktyp, token = next(self.lexer) - while toktyp == TokenType.STRING: - source = token - optional = source[0] == '?' - if optional: - source = source[1:] - nexttp, nexttk = next(self.lexer) - if nexttp == TokenType.LBRACE: - nexttp, nexttk = next(self.lexer) - if nexttp == TokenType.STRING: - filname = os.path.join(directory, nexttk) - bracetp, bractk = next(self.lexer) - if bracetp != TokenType.RBRACE: - return - nexttp, nexttk = next(self.lexer) - else: - return - elif libname == 'man': - index = token.rfind('.') - if index < 0: - return - mandir = os.path.join(directory, 'man' + token[index+1:]) - filname = os.path.join(mandir, os.path.basename(token)) - else: - filname = os.path.join(directory, os.path.basename(token)) - toktyp, token = nexttp, nexttk - yield (self.pkgname, optional, source, filname) - - if toktyp != TokenType.RBRACK: - return - toktyp, token = next(self.lexer) - except StopIteration: - return - -def install_files(buildroot: str, libdir: str) -> None: - """Install the files listed in opam .install files in the buildroot. - - For some projects, there are install files in both the project root - directory and somewhere under "_build", so be careful not to parse the same - install file twice. - - :param str buildroot: path to the buildroot - :param str libdir: the OCaml library directory - """ - install_files = set() - for path, dirs, files in os.walk('.'): - for f in files: - if f.endswith('.install') and f not in install_files: - install_files.add(f) - parser = InstallFileParser(os.path.join(path, f), libdir) - for _, optional, source, filname in parser: - if not optional or os.path.exists(source): - installpath = os.path.join(buildroot, filname[1:]) - os.makedirs(os.path.dirname(installpath), exist_ok=True) - shutil.copy2(source, installpath) - -def get_package_map(buildroot: str, libdir: str, devel: bool) -> dict[str, set[str]]: - """Create a map from package names to installed files from the opam .install - files in the buildroot. - - For some projects, there are install files in both the project root - directory and somewhere under "_build", so be careful not to parse the same - install file twice.""" - - pmap: dict[str, set[str]] = dict() - install_files = set() - - def add_pkg(pkgname: str, filname: str) -> None: - """Add a mapping from a package name to a filename. - - :param str pkgname: the package that acts as the map key - :param str filname: the filename to add to the package set - """ - if pkgname not in pmap: - pmap[pkgname] = set() - pmap[pkgname].add(filname) - - installed = find_buildroot_all(buildroot, devel, False) - for path, dirs, files in os.walk('.'): - for f in files: - if f.endswith('.install') and f not in install_files: - install_files.add(f) - parser = InstallFileParser(os.path.join(path, f), libdir) - for pkgname, _, _, filname in parser: - if filname in installed[0]: - if filname.startswith('/usr/share/man'): - add_pkg(pkgname, filname + '*') - else: - add_pkg(pkgname, filname) - dirname = os.path.dirname(filname) - if dirname in installed[1]: - add_pkg(pkgname, '%dir ' + dirname) - installed[1].remove(dirname) - elif filname in installed[2]: - if filname.startswith('/usr/share/man'): - add_pkg(pkgname + '-devel', filname + '*') - else: - add_pkg(pkgname + '-devel', filname) - dirname = os.path.dirname(filname) - if dirname in installed[3]: - add_pkg(pkgname + '-devel', '%dir ' + dirname) - installed[3].remove(dirname) - return pmap - -# -# MAIN INTERFACE -# - -def ocaml_files(no_devel: bool, separate: bool, install: bool, buildroot: str, - libdir: str) -> None: - """Generate %files lists from an installed buildroot. - - :param bool no_devel: False to split files into a main package and a devel - package - :param bool separate: True to place each OCaml module in an RPM package - :param bool install: True to install files, False to generate %files - :param str buildroot: the installed buildroot - :param str libdir: the OCaml library directory - """ - if install: - install_files(buildroot, libdir) - elif separate: - pkgmap = get_package_map(buildroot, libdir, not no_devel) - for pkg in pkgmap: - with open('.ofiles-' + pkg, 'w') as f: - for entry in pkgmap[pkg]: - f.write(entry + '\n') - elif no_devel: - with open('.ofiles', 'w') as f: - for entry in find_buildroot_toplevel(buildroot): - f.write(entry + '\n') - else: - files = find_buildroot_all(buildroot, True, True) - with open('.ofiles', 'w') as f: - for entry in files[0]: - f.write(entry + '\n') - for entry in files[1]: - f.write('%dir ' + entry + '\n') - with open('.ofiles-devel', 'w') as f: - for entry in files[2]: - f.write(entry + '\n') - for entry in files[3]: - f.write('%dir ' + entry + '\n') - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Support for building OCaml RPM packages') - parser.add_argument('-i', '--install', - action='store_true', - default=False, - help='install files instead of generating %%files') - parser.add_argument('-n', '--no-devel', - action='store_true', - default=False, - help='suppress creation of a devel subpackage') - parser.add_argument('-s', '--separate', - action='store_true', - default=False, - help='separate packaging. Each OCaml module is in a distinct RPM package. All modules are in a single RPM package by default.') - parser.add_argument('-v', '--version', - action='version', - version=f'%(prog)s {str(version)}') - parser.add_argument('buildroot', help='RPM build root') - parser.add_argument('libdir', help='OCaml library directory') - args = parser.parse_args() - ocaml_files(args.no_devel, - args.separate, - args.install, - args.buildroot, - args.libdir) diff --git a/sources b/sources index 7c0afd0..6de827b 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.5.0.tar.gz) = bf13c18cd1fc7b2e5e9623024ea8623710f646ff2fbc0f59dab70e4d4318ed8623bdcc3ec59ce37af07af2b767f520dea23fb474c26297b3e858b6c8e080b4e6 +SHA512 (ocaml-4.14.0.tar.gz) = 3c5e5b9f00bb109dd99b5f7b0078cf8663d4247e548f3e601d6b2a55582e04bb20f6de85005c4cf2f78ae9aaa449f5ca6f2bab2f6ce83eeb3aeb386e3f2fcc32 diff --git a/tests/basic-test.sh b/tests/basic-test.sh deleted file mode 100755 index 514bea0..0000000 --- a/tests/basic-test.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -e -set -x - -# Compile a trivial program and run it. -echo 'print_endline "hello, world"' > hello.ml -ocamlc.opt hello.ml -o hello -./hello -ocamlopt.opt hello.ml -o hello -./hello diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100755 index b9ec89a..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,11 +0,0 @@ -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - classic - required_packages: - - ocaml - tests: - - simple: - dir: . - run: ./basic-test.sh