From fe05d6a1384e126b27309515f0ad23dd6d007589 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 16 Aug 2019 08:56:11 +0100 Subject: [PATCH 01/91] OCaml 4.08.1 final. --- ...> 0001-Don-t-add-rpaths-to-libraries.patch | 4 +- ...sion-number-after-tagging-4.08.1-rc2.patch | 141 -------------- ...-spelling-errors-reported-by-Lintian.patch | 172 ------------------ ...-Allow-user-defined-C-compiler-flags.patch | 6 +- ...e-of-some-error-messages-in-ocamldoc.patch | 40 ---- ...-incorrect-assumption-about-cross-co.patch | 12 +- ...end.patch => 0004-Add-RISC-V-backend.patch | 16 +- ....patch => 0005-riscv-Emit-debug-info.patch | 4 +- ...-or-system-provided-off_t-rather-tha.patch | 58 ------ ocaml.spec | 26 ++- sources | 2 +- 11 files changed, 34 insertions(+), 447 deletions(-) rename 0004-Don-t-add-rpaths-to-libraries.patch => 0001-Don-t-add-rpaths-to-libraries.patch (88%) delete mode 100644 0001-increment-version-number-after-tagging-4.08.1-rc2.patch delete mode 100644 0002-Fix-spelling-errors-reported-by-Lintian.patch rename 0005-configure-Allow-user-defined-C-compiler-flags.patch => 0002-configure-Allow-user-defined-C-compiler-flags.patch (78%) delete mode 100644 0003-Fix-language-of-some-error-messages-in-ocamldoc.patch rename 0006-configure-Remove-incorrect-assumption-about-cross-co.patch => 0003-configure-Remove-incorrect-assumption-about-cross-co.patch (61%) rename 0007-Add-RISC-V-backend.patch => 0004-Add-RISC-V-backend.patch (99%) rename 0008-riscv-Emit-debug-info.patch => 0005-riscv-Emit-debug-info.patch (90%) delete mode 100644 0009-Use-the-autoconf-or-system-provided-off_t-rather-tha.patch diff --git a/0004-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch similarity index 88% rename from 0004-Don-t-add-rpaths-to-libraries.patch rename to 0001-Don-t-add-rpaths-to-libraries.patch index cce40f4..5b60aef 100644 --- a/0004-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ -From 9378a6a792cd1e2f6861483a2a73122b8c5296dd Mon Sep 17 00:00:00 2001 +From d3bc916ff1bc467c503e21015db9c1e2a47a64f2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 4/9] Don't add rpaths to libraries. +Subject: [PATCH 1/5] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- diff --git a/0001-increment-version-number-after-tagging-4.08.1-rc2.patch b/0001-increment-version-number-after-tagging-4.08.1-rc2.patch deleted file mode 100644 index e286a62..0000000 --- a/0001-increment-version-number-after-tagging-4.08.1-rc2.patch +++ /dev/null @@ -1,141 +0,0 @@ -From 92c1042e5ba899fca8eed351a7bc210879cdc9d7 Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Wed, 24 Jul 2019 14:25:14 +0200 -Subject: [PATCH 1/9] increment version number after tagging 4.08.1+rc2 - ---- - VERSION | 2 +- - configure | 26 +++++++++++++------------- - ocaml-variants.opam | 2 +- - 3 files changed, 15 insertions(+), 15 deletions(-) - -diff --git a/VERSION b/VERSION -index 9bbc45c85..6be2f109a 100644 ---- a/VERSION -+++ b/VERSION -@@ -1,4 +1,4 @@ --4.08.1+rc2 -+4.08.1+dev4-2019-07-24 - - # The version string is the first line of this file. - # It must be in the format described in stdlib/sys.mli -diff --git a/configure b/configure -index 450374d2d..0de9771d3 100755 ---- a/configure -+++ b/configure -@@ -1,6 +1,6 @@ - #! /bin/sh - # Guess values for system-dependent variables and create Makefiles. --# Generated by GNU Autoconf 2.69 for OCaml 4.08.1+rc2. -+# Generated by GNU Autoconf 2.69 for OCaml 4.08.1+dev4-2019-07-24. - # - # Report bugs to . - # -@@ -590,8 +590,8 @@ MAKEFLAGS= - # Identity of this package. - PACKAGE_NAME='OCaml' - PACKAGE_TARNAME='ocaml' --PACKAGE_VERSION='4.08.1+rc2' --PACKAGE_STRING='OCaml 4.08.1+rc2' -+PACKAGE_VERSION='4.08.1+dev4-2019-07-24' -+PACKAGE_STRING='OCaml 4.08.1+dev4-2019-07-24' - PACKAGE_BUGREPORT='caml-list@inria.fr' - PACKAGE_URL='http://www.ocaml.org' - -@@ -1430,7 +1430,7 @@ if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF --\`configure' configures OCaml 4.08.1+rc2 to adapt to many kinds of systems. -+\`configure' configures OCaml 4.08.1+dev4-2019-07-24 to adapt to many kinds of systems. - - Usage: $0 [OPTION]... [VAR=VALUE]... - -@@ -1501,7 +1501,7 @@ fi - - if test -n "$ac_init_help"; then - case $ac_init_help in -- short | recursive ) echo "Configuration of OCaml 4.08.1+rc2:";; -+ short | recursive ) echo "Configuration of OCaml 4.08.1+dev4-2019-07-24:";; - esac - cat <<\_ACEOF - -@@ -1657,7 +1657,7 @@ fi - test -n "$ac_init_help" && exit $ac_status - if $ac_init_version; then - cat <<\_ACEOF --OCaml configure 4.08.1+rc2 -+OCaml configure 4.08.1+dev4-2019-07-24 - generated by GNU Autoconf 2.69 - - Copyright (C) 2012 Free Software Foundation, Inc. -@@ -2320,7 +2320,7 @@ cat >config.log <<_ACEOF - This file contains any messages produced by compilers while - running configure, to aid debugging if configure makes a mistake. - --It was created by OCaml $as_me 4.08.1+rc2, which was -+It was created by OCaml $as_me 4.08.1+dev4-2019-07-24, which was - generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ -@@ -2669,8 +2669,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - --{ $as_echo "$as_me:${as_lineno-$LINENO}: Configuring OCaml version 4.08.1+rc2" >&5 --$as_echo "$as_me: Configuring OCaml version 4.08.1+rc2" >&6;} -+{ $as_echo "$as_me:${as_lineno-$LINENO}: Configuring OCaml version 4.08.1+dev4-2019-07-24" >&5 -+$as_echo "$as_me: Configuring OCaml version 4.08.1+dev4-2019-07-24" >&6;} - - # Configuration variables - -@@ -2745,7 +2745,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - ## Output variables - - --VERSION=4.08.1+rc2 -+VERSION=4.08.1+dev4-2019-07-24 - - - # Note: This is present for the flexdll bootstrap where it exposed as the old -@@ -12365,7 +12365,7 @@ case $ocaml_cv_cc_vendor in #( - msvc-*) : - outputobj=-Fo; CPP="cl -nologo -EP"; gcc_warnings="" ;; #( - *) : -- outputobj='-o $(EMPTY)'; case 4.08.1+rc2 in #( -+ outputobj='-o $(EMPTY)'; case 4.08.1+dev4-2019-07-24 in #( - *+dev*) : - gcc_warnings="-Wall -Werror" ;; #( - *) : -@@ -17560,7 +17560,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - # report actual input values of CONFIG_FILES etc. instead of their - # values after options handling. - ac_log=" --This file was extended by OCaml $as_me 4.08.1+rc2, which was -+This file was extended by OCaml $as_me 4.08.1+dev4-2019-07-24, which was - generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES -@@ -17627,7 +17627,7 @@ _ACEOF - cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" - ac_cs_version="\\ --OCaml config.status 4.08.1+rc2 -+OCaml config.status 4.08.1+dev4-2019-07-24 - configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -diff --git a/ocaml-variants.opam b/ocaml-variants.opam -index dcadf49f8..69b727f5c 100644 ---- a/ocaml-variants.opam -+++ b/ocaml-variants.opam -@@ -1,5 +1,5 @@ - opam-version: "2.0" --version: "4.08.1+rc2" -+version: "4.08.1+trunk" - synopsis: "OCaml development version" - depends: [ - "ocaml" {= "4.08.1" & post} --- -2.22.0.rc3 - diff --git a/0002-Fix-spelling-errors-reported-by-Lintian.patch b/0002-Fix-spelling-errors-reported-by-Lintian.patch deleted file mode 100644 index a5497c8..0000000 --- a/0002-Fix-spelling-errors-reported-by-Lintian.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 44306329db8a86a2362b6345bdde69deea4935dc Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Wed, 24 Jul 2019 14:45:33 +0100 -Subject: [PATCH 2/9] Fix spelling errors reported by Lintian - -No change entry needed ---- - asmcomp/cmmgen.ml | 4 ++-- - manual/manual/library/compilerlibs.etex | 2 +- - middle_end/inlining_transforms.ml | 2 +- - otherlibs/systhreads/event.mli | 4 ++-- - parsing/ast_iterator.mli | 2 +- - parsing/ast_mapper.mli | 2 +- - stdlib/bigarray.mli | 2 +- - stdlib/filename.mli | 4 ++-- - stdlib/format.ml | 2 +- - testsuite/tests/parsetree/source.ml | 2 +- - testsuite/tests/typing-implicit_unpack/implicit_unpack.ml | 2 +- - 11 files changed, 14 insertions(+), 14 deletions(-) - -diff --git a/asmcomp/cmmgen.ml b/asmcomp/cmmgen.ml -index d0490998c..68e36d0d9 100644 ---- a/asmcomp/cmmgen.ml -+++ b/asmcomp/cmmgen.ml -@@ -1528,8 +1528,8 @@ end - phases, we only share exits *) - (* Some specific patterns can lead to switches where several cases - point to the same action, but this action is not an exit (see GPR#1370). -- The addition of the index in the action array as context allows to -- share them correctly without duplication. *) -+ The addition of the index in the action array as context allows -+ sharing them correctly without duplication. *) - module StoreExpForSwitch = - Switch.CtxStore - (struct -diff --git a/manual/manual/library/compilerlibs.etex b/manual/manual/library/compilerlibs.etex -index 88abbb823..d49193767 100644 ---- a/manual/manual/library/compilerlibs.etex -+++ b/manual/manual/library/compilerlibs.etex -@@ -3,7 +3,7 @@ - - This chapter describes the OCaml front-end, which declares the abstract - syntax tree used by the compiler, provides a way to parse, print --and pretty-print OCaml code, and ultimately allows to write abstract -+and pretty-print OCaml code, and ultimately allows one to write abstract - syntax tree preprocessors invoked via the {\tt -ppx} flag (see chapters~\ref{c:camlc} - and~\ref{c:nativecomp}) and plugins invoked via the {\tt -plugin} flag - (see chapter~\ref{c:plugins}). -diff --git a/middle_end/inlining_transforms.ml b/middle_end/inlining_transforms.ml -index b08e62bb0..c46a6cbe6 100755 ---- a/middle_end/inlining_transforms.ml -+++ b/middle_end/inlining_transforms.ml -@@ -118,7 +118,7 @@ let inline_by_copying_function_body ~env ~r - && ((not default_inline) || (not default_specialise)) then - (* When the function inlined function is a stub, the annotation - is reported to the function applications inside the stub. -- This allows to report the annotation to the application the -+ This allows reporting the annotation to the application the - original programmer really intended: the stub is not visible - in the source. *) - set_inline_attribute_on_all_apply body -diff --git a/otherlibs/systhreads/event.mli b/otherlibs/systhreads/event.mli -index 83dbe9a17..fd452652c 100644 ---- a/otherlibs/systhreads/event.mli -+++ b/otherlibs/systhreads/event.mli -@@ -59,8 +59,8 @@ val wrap_abort : 'a event -> (unit -> unit) -> 'a event - - val guard : (unit -> 'a event) -> 'a event - (** [guard fn] returns the event that, when synchronized, computes -- [fn()] and behaves as the resulting event. This allows to -- compute events with side-effects at the time of the synchronization -+ [fn()] and behaves as the resulting event. This enables -+ computing events with side-effects at the time of the synchronization - operation. *) - - val sync : 'a event -> 'a -diff --git a/parsing/ast_iterator.mli b/parsing/ast_iterator.mli -index 5dc1c0ec5..26308d20d 100755 ---- a/parsing/ast_iterator.mli -+++ b/parsing/ast_iterator.mli -@@ -13,7 +13,7 @@ - (* *) - (**************************************************************************) - --(** {!iterator} allows to implement AST inspection using open recursion. A -+(** {!iterator} enables AST inspection using open recursion. A - typical mapper would be based on {!default_iterator}, a trivial iterator, - and will fall back on it for handling the syntax it does not modify. - -diff --git a/parsing/ast_mapper.mli b/parsing/ast_mapper.mli -index b342ca8a9..80d70fcca 100644 ---- a/parsing/ast_mapper.mli -+++ b/parsing/ast_mapper.mli -@@ -21,7 +21,7 @@ - the -ppx rewriters, handling such details as the serialization format, - forwarding of command-line flags, and storing state. - -- {!mapper} allows to implement AST rewriting using open recursion. -+ {!mapper} enables AST rewriting using open recursion. - A typical mapper would be based on {!default_mapper}, a deep - identity mapper, and will fall back on it for handling the syntax it - does not modify. For example: -diff --git a/stdlib/bigarray.mli b/stdlib/bigarray.mli -index 2c1261212..ea26f66f5 100644 ---- a/stdlib/bigarray.mli -+++ b/stdlib/bigarray.mli -@@ -133,7 +133,7 @@ type ('a, 'b) kind = - of OCaml types with element kinds, and are re-exported below for - backward-compatibility reasons. - -- Using a generalized algebraic datatype (GADT) here allows to write -+ Using a generalized algebraic datatype (GADT) here allows writing - well-typed polymorphic functions whose return type depend on the - argument type, such as: - -diff --git a/stdlib/filename.mli b/stdlib/filename.mli -index b05ad0d2e..9221c9ef5 100644 ---- a/stdlib/filename.mli -+++ b/stdlib/filename.mli -@@ -52,8 +52,8 @@ val check_suffix : string -> string -> bool - val chop_suffix : string -> string -> string - (** [chop_suffix name suff] removes the suffix [suff] from - the filename [name]. The behavior is undefined if [name] does not -- end with the suffix [suff]. It is thus recommmended to use -- [chop_suffix_opt] instead. -+ end with the suffix [suff]. [chop_suffix_opt] is thus recommended -+ instead. - *) - - val chop_suffix_opt: suffix:string -> string -> string option -diff --git a/stdlib/format.ml b/stdlib/format.ml -index ae1f3c647..369c50c36 100644 ---- a/stdlib/format.ml -+++ b/stdlib/format.ml -@@ -687,7 +687,7 @@ let pp_print_if_newline state () = - { size = Size.zero; token = Pp_if_newline; length = 0 } - - --(* Generalized break hint that allows to print strings before/after -+(* Generalized break hint that allows printing strings before/after - same-line offset (width) or new-line offset *) - let pp_print_custom_break state ~fits ~breaks = - let before, width, after = fits in -diff --git a/testsuite/tests/parsetree/source.ml b/testsuite/tests/parsetree/source.ml -index c67012e18..a183f4482 100644 ---- a/testsuite/tests/parsetree/source.ml -+++ b/testsuite/tests/parsetree/source.ml -@@ -3072,7 +3072,7 @@ Error: Types marked with the immediate attribute must be - non-pointer types like int or bool - |}];; - (* -- Implicit unpack allows to omit the signature in (val ...) expressions. -+ Implicit unpack allows the signature in (val ...) expressions to be omitted. - - It also adds (module M : S) and (module M) patterns, relying on - implicit (val ...) for the implementation. Such patterns can only -diff --git a/testsuite/tests/typing-implicit_unpack/implicit_unpack.ml b/testsuite/tests/typing-implicit_unpack/implicit_unpack.ml -index a6b4d697c..e503ee736 100644 ---- a/testsuite/tests/typing-implicit_unpack/implicit_unpack.ml -+++ b/testsuite/tests/typing-implicit_unpack/implicit_unpack.ml -@@ -3,7 +3,7 @@ - *) - - (* -- Implicit unpack allows to omit the signature in (val ...) expressions. -+ Implicit unpack allows the signature in (val ...) expressions to be omitted. - - It also adds (module M : S) and (module M) patterns, relying on - implicit (val ...) for the implementation. Such patterns can only --- -2.22.0.rc3 - diff --git a/0005-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch similarity index 78% rename from 0005-configure-Allow-user-defined-C-compiler-flags.patch rename to 0002-configure-Allow-user-defined-C-compiler-flags.patch index 2ba82c7..093be83 100644 --- a/0005-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,14 +1,14 @@ -From 4af3619375230488b370e5b3d5a8f48cef688607 Mon Sep 17 00:00:00 2001 +From 8cc56a1515816c9cef84694e63eaed63a0474090 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 5/9] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index 5bb061162..6e37ff6c0 100644 +index f5d8a2687..ad5b701bd 100644 --- a/configure.ac +++ b/configure.ac @@ -553,6 +553,10 @@ AS_CASE([$host], diff --git a/0003-Fix-language-of-some-error-messages-in-ocamldoc.patch b/0003-Fix-language-of-some-error-messages-in-ocamldoc.patch deleted file mode 100644 index f0313e9..0000000 --- a/0003-Fix-language-of-some-error-messages-in-ocamldoc.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 655519a3653a8e5b90e0fd862f9c5e20465ab7d0 Mon Sep 17 00:00:00 2001 -From: Stephane Glondu -Date: Thu, 25 Jul 2019 09:08:03 +0200 -Subject: [PATCH 3/9] Fix language of some error messages in ocamldoc - -No change entry needed ---- - ocamldoc/odoc_sig.ml | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/ocamldoc/odoc_sig.ml b/ocamldoc/odoc_sig.ml -index fb2eac671..e413c11a6 100644 ---- a/ocamldoc/odoc_sig.ml -+++ b/ocamldoc/odoc_sig.ml -@@ -1740,11 +1740,11 @@ module Analyser = - ) - else - ( -- raise (Failure "Parsetree.Pcty_arrow (parse_label, _, pclass_type), labels differents") -+ raise (Failure "Parsetree.Pcty_arrow (parse_label, _, pclass_type), different labels") - ) - - | _ -> -- raise (Failure "analyse_class_kind pas de correspondance dans le match") -+ raise (Failure "analyse_class_kind: match failure") - - (** Analyse of a Parsetree.class_type and a Types.class_type to return a class_type_kind.*) - and analyse_class_type_kind env current_class_name last_pos parse_class_type sig_class_type = -@@ -1799,7 +1799,7 @@ module Analyser = - ([], k) - *) - | _ -> -- raise (Failure "analyse_class_type_kind pas de correspondance dans le match") -+ raise (Failure "analyse_class_type_kind: match failure") - - let analyse_signature source_file input_file - (ast : Parsetree.signature) (signat : Types.signature) = --- -2.22.0.rc3 - diff --git a/0006-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch similarity index 61% rename from 0006-configure-Remove-incorrect-assumption-about-cross-co.patch rename to 0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 933a1cf..99bca0e 100644 --- a/0006-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From 84381bccf6293903392d3d045bfb66b10b3e3bc3 Mon Sep 17 00:00:00 2001 +From 0204a1137a8e8058afd1665aa6112656bc7bf0be Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 6/9] configure: Remove incorrect assumption about +Subject: [PATCH 3/5] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -10,15 +10,15 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 6e37ff6c0..3c287fbd0 100644 +index ad5b701bd..2227769e8 100644 --- a/configure.ac +++ b/configure.ac -@@ -958,7 +958,7 @@ AS_CASE([$host], +@@ -959,7 +959,7 @@ AS_CASE([$host], [*-*-mingw32|*-pc-windows], [asppprofflags=''], [asppprofflags='-DPROFILING']) --AS_IF([test -n "$host_alias"], [toolpref="${host}-"], [toolpref=""]) -+#AS_IF([test -n "$host_alias"], [toolpref="${host}-"], [toolpref=""]) +-AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""]) ++#AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""]) # We first compute default values for as and aspp # If values have been given by the user then they take precedence over diff --git a/0007-Add-RISC-V-backend.patch b/0004-Add-RISC-V-backend.patch similarity index 99% rename from 0007-Add-RISC-V-backend.patch rename to 0004-Add-RISC-V-backend.patch index 7b17ec6..63ceeb6 100644 --- a/0007-Add-RISC-V-backend.patch +++ b/0004-Add-RISC-V-backend.patch @@ -1,7 +1,7 @@ -From b4554d2e93dd2db471b4498761824875e41adc8c Mon Sep 17 00:00:00 2001 +From acc93802cac96da98ad5468756da2025625ca416 Mon Sep 17 00:00:00 2001 From: Nicolas Ojeda Bar Date: Fri, 27 Oct 2017 17:05:25 +0200 -Subject: [PATCH 7/9] Add RISC-V backend +Subject: [PATCH 4/5] Add RISC-V backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -6077,10 +6077,10 @@ index 8b612ab89..3b4c7624b 100755 # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/configure b/configure -index 0de9771d3..33a0aa526 100755 +index 9a78a4554..00bb37bae 100755 --- a/configure +++ b/configure -@@ -13417,6 +13417,8 @@ fi ;; #( +@@ -13415,6 +13415,8 @@ fi ;; #( natdynlink=true ;; #( aarch64-*-linux*) : natdynlink=true ;; #( @@ -6112,10 +6112,10 @@ index 0de9771d3..33a0aa526 100755 case $ocaml_cv_cc_vendor in #( clang-*) : diff --git a/configure.ac b/configure.ac -index 3c287fbd0..5731e0f98 100644 +index 2227769e8..94b7e2b35 100644 --- a/configure.ac +++ b/configure.ac -@@ -804,7 +804,8 @@ AS_IF([test x"$enable_shared" != "xno"], +@@ -803,7 +803,8 @@ AS_IF([test x"$enable_shared" != "xno"], [arm*-*-linux*], [natdynlink=true], [arm*-*-freebsd*], [natdynlink=true], [earm*-*-netbsd*], [natdynlink=true], @@ -6125,7 +6125,7 @@ index 3c287fbd0..5731e0f98 100644 # Try to work around the Skylake/Kaby Lake processor bug. AS_CASE(["$CC,$host"], -@@ -897,7 +898,11 @@ AS_CASE([$host], +@@ -898,7 +899,11 @@ AS_CASE([$host], [aarch64-*-linux*], [arch=arm64; system=linux], [x86_64-*-cygwin*], @@ -6138,7 +6138,7 @@ index 3c287fbd0..5731e0f98 100644 ) AS_IF([test x"$enable_native_compiler" = "xno"], -@@ -1007,7 +1012,7 @@ AS_CASE(["$arch,$system"], +@@ -1008,7 +1013,7 @@ AS_CASE(["$arch,$system"], [*,freebsd], [default_as="${toolpref}as" default_aspp="${toolpref}cc -c"], diff --git a/0008-riscv-Emit-debug-info.patch b/0005-riscv-Emit-debug-info.patch similarity index 90% rename from 0008-riscv-Emit-debug-info.patch rename to 0005-riscv-Emit-debug-info.patch index c099edf..ff732cf 100644 --- a/0008-riscv-Emit-debug-info.patch +++ b/0005-riscv-Emit-debug-info.patch @@ -1,7 +1,7 @@ -From e238841a2e41f4473dcc40a06a7ac1b9ad1c0357 Mon Sep 17 00:00:00 2001 +From 2f23a53b4aa1b672b3919cc021b83548f713b90a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 5 Jun 2018 19:48:08 +0000 -Subject: [PATCH 8/9] riscv: Emit debug info. +Subject: [PATCH 5/5] riscv: Emit debug info. --- asmcomp/riscv/emit.mlp | 3 +++ diff --git a/0009-Use-the-autoconf-or-system-provided-off_t-rather-tha.patch b/0009-Use-the-autoconf-or-system-provided-off_t-rather-tha.patch deleted file mode 100644 index 9353c5c..0000000 --- a/0009-Use-the-autoconf-or-system-provided-off_t-rather-tha.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 9217fab965cbde2a47dd91acb6e6452844d288ba Mon Sep 17 00:00:00 2001 -From: Stephen Dolan -Date: Mon, 29 Jul 2019 14:12:56 +0100 -Subject: [PATCH 9/9] Use the autoconf- or system-provided off_t rather than - redetecting. - -Hopefully fixes #8841 ---- - configure | 2 -- - configure.ac | 1 - - runtime/caml/io.h | 4 +--- - 3 files changed, 1 insertion(+), 6 deletions(-) - -diff --git a/configure b/configure -index 33a0aa526..a43846117 100755 ---- a/configure -+++ b/configure -@@ -12787,8 +12787,6 @@ _ACEOF - - fi - --$as_echo "#define HAS_OFF_T 1" >>confdefs.h -- - - # Checks for structures - -diff --git a/configure.ac b/configure.ac -index 5731e0f98..38ff1235f 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -674,7 +674,6 @@ AC_CHECK_HEADER([sys/select.h], [AC_DEFINE([HAS_SYS_SELECT_H])], [], - - ## off_t - AC_TYPE_OFF_T --AC_DEFINE([HAS_OFF_T]) - - # Checks for structures - -diff --git a/runtime/caml/io.h b/runtime/caml/io.h -index 87de679e5..2d961f956 100644 ---- a/runtime/caml/io.h -+++ b/runtime/caml/io.h -@@ -29,11 +29,9 @@ - - #if defined(_WIN32) - typedef __int64 file_offset; --#elif defined(HAS_OFF_T) -+#else - #include - typedef off_t file_offset; --#else --typedef long file_offset; - #endif - - struct channel { --- -2.22.0.rc3 - diff --git a/ocaml.spec b/ocaml.spec index 41f8bfa..bb793d0 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -26,12 +26,12 @@ # Architectures where parallel builds fail. #%global no_parallel_build_arches aarch64 -#%global rcver %{nil} -%global rcver +rc2 +%global rcver %{nil} +#global rcver +rc2 Name: ocaml Version: 4.08.1 -Release: 0.rc2.1%{?dist} +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -50,26 +50,21 @@ Source0: http://caml.inria.fr/pub/distrib/ocaml-4.08/ocaml-%{version}%{rc # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-31-4.08.1 +# Current branch: fedora-32-4.08.1 # # 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. # -Patch0001: 0001-increment-version-number-after-tagging-4.08.1-rc2.patch -Patch0002: 0002-Fix-spelling-errors-reported-by-Lintian.patch -Patch0003: 0003-Fix-language-of-some-error-messages-in-ocamldoc.patch # Fedora-specific downstream patches. -Patch0004: 0004-Don-t-add-rpaths-to-libraries.patch -Patch0005: 0005-configure-Allow-user-defined-C-compiler-flags.patch -Patch0006: 0006-configure-Remove-incorrect-assumption-about-cross-co.patch +Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch +Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch +Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch # Out of tree patch for RISC-V support. # https://github.com/nojb/riscv-ocaml -Patch0007: 0007-Add-RISC-V-backend.patch -Patch0008: 0008-riscv-Emit-debug-info.patch -# Fix for https://github.com/ocaml/ocaml/issues/8841 -Patch0009: 0009-Use-the-autoconf-or-system-provided-off_t-rather-tha.patch +Patch0004: 0004-Add-RISC-V-backend.patch +Patch0005: 0005-riscv-Emit-debug-info.patch BuildRequires: gcc BuildRequires: autoconf @@ -386,6 +381,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Fri Aug 16 2019 Richard W.M. Jones - 4.08.1-1 +- OCaml 4.08.1 final. + * Tue Jul 30 2019 Richard W.M. Jones - 4.08.1-0.rc2.1 - OCaml 4.08.1+rc2. - Include fix for miscompilation of off_t on 32 bit architectures. diff --git a/sources b/sources index 1e7ae92..af4a53c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.08.1+rc2.tar.xz) = 74d5929e75ec4dd6cd69250005a18cede7e8036301dc05660aee99330f1ba4013575df1f9fe03dc7e913de3719215122b71681f0fad6f571a5feecb594c1e460 +SHA512 (ocaml-4.08.1.tar.xz) = ebcc065c4cc4bf16256c6dad6795d9660d355c5facbe432591811dc4aa02af6498899219ec4e786358dffcfc38c68f5af2d1c3787d418a78732ec37e84a28cd4 From 643d0943583b4d801acd9c139810f5bfd8ecefa0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Dec 2019 12:56:42 +0000 Subject: [PATCH 02/91] OCaml 4.09.0 final. --- ...-version-number-after-tagging-4.09.0.patch | 52 + 0002-mark-the-release-in-the-Changes.patch | 27 + ...st-8954-from-Armael-fix-toplevel-sub.patch | 46 + 0004-Add-RISC-V-backend.patch | 6598 ----------------- ...st-8979-from-gasche-fix-Makefile.men.patch | 102 + ...e-of-gen_primitives.sh-with-LC_ALL-C.patch | 51 + 0005-riscv-Emit-debug-info.patch | 40 - ...est-8988-from-Octachron-fix_ocamlnat.patch | 28 + 0007-Fix-failure-to-install-tools-links.patch | 45 + ...uest-8996-from-dra27-win-reconfigure.patch | 31 + ...> 0009-Don-t-add-rpaths-to-libraries.patch | 8 +- ...-Allow-user-defined-C-compiler-flags.patch | 10 +- ...-incorrect-assumption-about-cross-co.patch | 14 +- 0012-Add-riscv64-backend.patch | 1912 +++++ ocaml.spec | 27 +- sources | 2 +- 16 files changed, 2330 insertions(+), 6663 deletions(-) create mode 100644 0001-increment-version-number-after-tagging-4.09.0.patch create mode 100644 0002-mark-the-release-in-the-Changes.patch create mode 100644 0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch delete mode 100644 0004-Add-RISC-V-backend.patch create mode 100644 0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch create mode 100644 0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch delete mode 100644 0005-riscv-Emit-debug-info.patch create mode 100644 0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch create mode 100644 0007-Fix-failure-to-install-tools-links.patch create mode 100644 0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch rename 0001-Don-t-add-rpaths-to-libraries.patch => 0009-Don-t-add-rpaths-to-libraries.patch (83%) rename 0002-configure-Allow-user-defined-C-compiler-flags.patch => 0010-configure-Allow-user-defined-C-compiler-flags.patch (71%) rename 0003-configure-Remove-incorrect-assumption-about-cross-co.patch => 0011-configure-Remove-incorrect-assumption-about-cross-co.patch (67%) create mode 100644 0012-Add-riscv64-backend.patch diff --git a/0001-increment-version-number-after-tagging-4.09.0.patch b/0001-increment-version-number-after-tagging-4.09.0.patch new file mode 100644 index 0000000..646daeb --- /dev/null +++ b/0001-increment-version-number-after-tagging-4.09.0.patch @@ -0,0 +1,52 @@ +From 6207460e793f8c5538bfd8164fa3078f7300b57a Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Tue, 17 Sep 2019 14:35:00 +0200 +Subject: [PATCH 01/12] increment version number after tagging 4.09.0 + +--- + VERSION | 2 +- + configure | Bin 542920 -> 542985 bytes + ocaml-variants.opam | 4 ++-- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/VERSION b/VERSION +index 7128cac1f..ff541f87c 100644 +--- a/VERSION ++++ b/VERSION +@@ -1,4 +1,4 @@ +-4.09.0 ++4.09.1+dev0 + + # The version string is the first line of this file. + # It must be in the format described in stdlib/sys.mli +diff --git a/configure b/configure +index 85fb6842dffc1ba52a07895aefa7d49f7f383d17..c364be4e3a365e01c667023ea23238037446a3c3 100755 +GIT binary patch +delta 189 +zcmX>xQL%H9;)HruL+zB*vW@kPP7u~4XE_LCvz&8XD3m#8#&>QgbMlgF5>RI5-Yp&w +z=5|>&Ml~Hauu%rn8#gjaOph^Ql!r=I8!_gwL)h&vEg6BB35c12m}UD*OIB{E&Fx>R +iS%H{s`pItkZr(8CJNM=_ORh;U8cg?LW0c>#eD4&G?G9{= +zYC1rXkJ^k9(_4%f<+raeV$5T2m$qUAVkRJF24a@&(pIe8PVL$?tU%1RUAu;T8Pjy2 +TUf=D?_3WDL+XLI!cN_u$b;&5C + +diff --git a/ocaml-variants.opam b/ocaml-variants.opam +index 30d48eb24..5410d1f4c 100644 +--- a/ocaml-variants.opam ++++ b/ocaml-variants.opam +@@ -1,8 +1,8 @@ + opam-version: "2.0" +-version: "4.09.0" ++version: "4.09.1+trunk" + synopsis: "OCaml development version" + depends: [ +- "ocaml" {= "4.09.0" & post} ++ "ocaml" {= "4.09.1" & post} + "base-unix" {post} + "base-bigarray" {post} + "base-threads" {post} +-- +2.23.0 + diff --git a/0002-mark-the-release-in-the-Changes.patch b/0002-mark-the-release-in-the-Changes.patch new file mode 100644 index 0000000..78a91d2 --- /dev/null +++ b/0002-mark-the-release-in-the-Changes.patch @@ -0,0 +1,27 @@ +From c1db490f8d92e7b5f1a4685cd9a095f24429bb3e Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Thu, 19 Sep 2019 15:40:49 +0200 +Subject: [PATCH 02/12] mark the release in the Changes + +--- + Changes | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/Changes b/Changes +index d4b8a994d..e95ae5e49 100644 +--- a/Changes ++++ b/Changes +@@ -1,5 +1,8 @@ +-OCaml 4.09.0 +------------- ++OCaml 4.09 maintenance branch: ++------------------------------ ++ ++OCaml 4.09.0 (19 September 2019): ++--------------------------------- + + (Changes that can break existing programs are marked with a "*") + +-- +2.23.0 + diff --git a/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch b/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch new file mode 100644 index 0000000..2cb9cc4 --- /dev/null +++ b/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch @@ -0,0 +1,46 @@ +From 1204abd71a4ef585dbb70ba68a5879856d24c1a9 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Fri, 20 Sep 2019 10:58:09 +0200 +Subject: [PATCH 03/12] Merge pull request #8954 from + Armael/fix-toplevel-submsg-locs + +Fix error submessages in the toplevel: do not display dummy locations + +(cherry picked from commit 8f7708a0fbc3e1199ccf04a6b9e1ba8e0f0d5254) +--- + Changes | 4 ++++ + parsing/location.ml | 3 ++- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/Changes b/Changes +index e95ae5e49..355cb1a94 100644 +--- a/Changes ++++ b/Changes +@@ -1,6 +1,10 @@ + OCaml 4.09 maintenance branch: + ------------------------------ + ++- #8953, #8954: Fix error submessages in the toplevel: do not display ++ dummy locations ++ (Armaël Guéneau, review by Gabriel Scherer) ++ + OCaml 4.09.0 (19 September 2019): + --------------------------------- + +diff --git a/parsing/location.ml b/parsing/location.ml +index 25cba42c7..ab823d36f 100644 +--- a/parsing/location.ml ++++ b/parsing/location.ml +@@ -752,7 +752,8 @@ let terminfo_toplevel_printer (lb: lexbuf): report_printer = + in + let pp_main_loc _ _ _ _ = () in + let pp_submsg_loc _ _ ppf loc = +- Format.fprintf ppf "%a:@ " print_loc loc in ++ if not loc.loc_ghost then ++ Format.fprintf ppf "%a:@ " print_loc loc in + { batch_mode_printer with pp; pp_main_loc; pp_submsg_loc } + + let best_toplevel_printer () = +-- +2.23.0 + diff --git a/0004-Add-RISC-V-backend.patch b/0004-Add-RISC-V-backend.patch deleted file mode 100644 index 63ceeb6..0000000 --- a/0004-Add-RISC-V-backend.patch +++ /dev/null @@ -1,6598 +0,0 @@ -From acc93802cac96da98ad5468756da2025625ca416 Mon Sep 17 00:00:00 2001 -From: Nicolas Ojeda Bar -Date: Fri, 27 Oct 2017 17:05:25 +0200 -Subject: [PATCH 4/5] Add RISC-V backend -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This is the RISC-V backend by Nicolás Ojeda Bär, cherry-picked for -Fedora from https://github.com/nojb/riscv-ocaml/commits/trunk - -The following additional commits are included: - -- Copyright, untabify - -- fix caml_c_call: reload caml_young_limit - -- Adapt to changes in trunk - -- Adapt to changes in trunk - -- Adapt configure.ac - -- Update config.{guess,sub} - -- Regenerate configure - -- Add Proc.dwarf_register_numbers - -- Add Proc.stack_ptr_dwarf_register_number - -- Add Proc.destroyed_at_reloadretaddr - -- Typo - -- Rename - -- riscv.S: align to 16 - -- Test CI ---- - .travis.yml | 32 +- - README.adoc | 1 + - asmcomp/riscv/CSE.ml | 36 + - asmcomp/riscv/arch.ml | 87 ++ - asmcomp/riscv/emit.mlp | 655 +++++++++ - asmcomp/riscv/proc.ml | 330 +++++ - asmcomp/riscv/reload.ml | 16 + - asmcomp/riscv/scheduling.ml | 19 + - asmcomp/riscv/selection.ml | 71 + - config/gnu/config.guess | 925 ++++++------- - config/gnu/config.sub | 2505 ++++++++++++++++++----------------- - configure | 10 +- - configure.ac | 11 +- - runtime/caml/stack.h | 5 + - runtime/riscv.S | 424 ++++++ - 15 files changed, 3352 insertions(+), 1775 deletions(-) - create mode 100644 asmcomp/riscv/CSE.ml - create mode 100644 asmcomp/riscv/arch.ml - create mode 100644 asmcomp/riscv/emit.mlp - create mode 100644 asmcomp/riscv/proc.ml - create mode 100644 asmcomp/riscv/reload.ml - create mode 100644 asmcomp/riscv/scheduling.ml - create mode 100644 asmcomp/riscv/selection.ml - create mode 100644 runtime/riscv.S - -diff --git a/.travis.yml b/.travis.yml -index 60b2d7abb..410ed8b51 100644 ---- a/.travis.yml -+++ b/.travis.yml -@@ -13,36 +13,16 @@ - #* * - #************************************************************************** - --sudo: false - language: c -+services: -+ - docker - git: - submodules: false --script: bash -e tools/ci/travis/travis-ci.sh --matrix: -- include: -- - env: CI_KIND=build XARCH=i386 -- addons: -- apt: -- packages: -- - gcc:i386 -- - cpp:i386 -- - binutils:i386 -- - binutils-dev:i386 -- - libx11-dev:i386 -- - libc6-dev:i386 -- - env: CI_KIND=build XARCH=x64 -- - env: CI_KIND=build XARCH=x64 CONFIG_ARG=--enable-flambda OCAMLRUNPARAM=b,v=0 -- - env: CI_KIND=changes -- - env: CI_KIND=manual -- - env: CI_KIND=check-typo -- - env: CI_KIND=tests -- allow_failures: -- - env: CI_KIND=tests -+before_install: -+ - docker pull nojb/riscv-ocaml-ci -+ - echo ':riscv64:M::\x7f\x45\x4c\x46\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf3\x00:\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff:/usr/bin/qemu-riscv64:' | sudo tee /proc/sys/fs/binfmt_misc/register >/dev/null -+ - docker run -v $TRAVIS_BUILD_DIR:/home/root/ocaml nojb/riscv-ocaml-ci /bin/sh -c "cd ocaml && ./configure && make world.opt" - addons: - apt: - packages: - - binutils-dev -- --notifications: -- email: -- - ocaml-ci-notifications@inria.fr -diff --git a/README.adoc b/README.adoc -index 53cd4512e..60fe53f62 100644 ---- a/README.adoc -+++ b/README.adoc -@@ -55,6 +55,7 @@ AMD64:: FreeBSD, OpenBSD, NetBSD - IA32 (Pentium):: NetBSD, OpenBSD, Solaris 9 - PowerPC:: NetBSD - ARM:: NetBSD -+RISC-V:: Linux - - Other operating systems for the processors above have not been tested, but - the compiler may work under other operating systems with little work. -diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml -new file mode 100644 -index 000000000..302811a99 ---- /dev/null -+++ b/asmcomp/riscv/CSE.ml -@@ -0,0 +1,36 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2106 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* CSE for the RISC-V *) -+ -+open Arch -+open Mach -+open CSEgen -+ -+class cse = object (_self) -+ -+inherit cse_generic as super -+ -+method! class_of_operation op = -+ match op with -+ | Ispecific(Imultaddf _ | Imultsubf _) -> Op_pure -+ | _ -> super#class_of_operation op -+ -+method! is_cheap_operation op = -+ match op with -+ | Iconst_int n -> n <= 0x7FFn && n >= -0x800n -+ | _ -> false -+ -+end -+ -+let fundecl f = -+ (new cse)#fundecl f -diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml -new file mode 100644 -index 000000000..22c807c49 ---- /dev/null -+++ b/asmcomp/riscv/arch.ml -@@ -0,0 +1,87 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* Specific operations for the RISC-V processor *) -+ -+open Format -+ -+(* Machine-specific command-line options *) -+ -+let command_line_options = [] -+ -+(* Specific operations *) -+ -+type specific_operation = -+ | Imultaddf of bool (* multiply, optionally negate, and add *) -+ | Imultsubf of bool (* multiply, optionally negate, and subtract *) -+ -+let spacetime_node_hole_pointer_is_live_before = function -+ | Imultaddf _ | Imultsubf _ -> false -+ -+(* Addressing modes *) -+ -+type addressing_mode = -+ | Iindexed of int (* reg + displ *) -+ -+let is_immediate n = -+ (n <= 2047) && (n >= -2048) -+ -+(* Sizes, endianness *) -+ -+let big_endian = false -+ -+let rv64 = -+ match Config.model with "riscv64" -> true | "riscv32" -> false | _ -> assert false -+ -+let size_addr = if rv64 then 8 else 4 -+let size_int = size_addr -+let size_float = 8 -+ -+let allow_unaligned_access = false -+ -+(* Behavior of division *) -+ -+let division_crashes_on_overflow = false -+ -+(* Operations on addressing modes *) -+ -+let identity_addressing = Iindexed 0 -+ -+let offset_addressing addr delta = -+ match addr with -+ | Iindexed n -> Iindexed(n + delta) -+ -+let num_args_addressing = function -+ | Iindexed _ -> 1 -+ -+(* Printing operations and addressing modes *) -+ -+let print_addressing printreg addr ppf arg = -+ match addr with -+ | Iindexed n -> -+ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in -+ fprintf ppf "%a%s" printreg arg.(0) idx -+ -+let print_specific_operation printreg op ppf arg = -+ match op with -+ | Imultaddf false -> -+ fprintf ppf "%a *f %a +f %a" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultaddf true -> -+ fprintf ppf "-f (%a *f %a +f %a)" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultsubf false -> -+ fprintf ppf "%a *f %a -f %a" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultsubf true -> -+ fprintf ppf "-f (%a *f %a -f %a)" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp -new file mode 100644 -index 000000000..88ea9f884 ---- /dev/null -+++ b/asmcomp/riscv/emit.mlp -@@ -0,0 +1,655 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* Emission of RISC-V assembly code *) -+ -+open Misc -+open Cmm -+open Arch -+open Proc -+open Reg -+open Mach -+open Linearize -+open Emitaux -+ -+(* Layout of the stack. The stack is kept 16-aligned. *) -+ -+let stack_offset = ref 0 -+ -+let frame_size () = -+ let size = -+ !stack_offset + (* Trap frame, outgoing parameters *) -+ size_int * num_stack_slots.(0) + (* Local int variables *) -+ size_float * num_stack_slots.(1) + (* Local float variables *) -+ (if !contains_calls then size_addr else 0) in (* The return address *) -+ Misc.align size 16 -+ -+let slot_offset loc cls = -+ match loc with -+ | Local n -> -+ if cls = 0 -+ then !stack_offset + num_stack_slots.(1) * size_float + n * size_int -+ else !stack_offset + n * size_float -+ | Incoming n -> frame_size() + n -+ | Outgoing n -> n -+ -+(* Output a symbol *) -+ -+let emit_symbol s = -+ Emitaux.emit_symbol '.' s -+ -+(* Output a label *) -+ -+let label_prefix = "L" -+ -+let emit_label lbl = -+ emit_string label_prefix; emit_int lbl -+ -+(* Section switching *) -+ -+let data_space = -+ ".section .data" -+ -+let code_space = -+ ".section .text" -+ -+let rodata_space = -+ ".section .rodata" -+ -+let reg_tmp1 = phys_reg 21 (* used by the assembler *) -+let reg_tmp2 = phys_reg 22 -+let reg_t2 = phys_reg 16 -+(* let reg_fp = phys_reg 23 *) -+let reg_trap = phys_reg 24 -+let reg_alloc_ptr = phys_reg 25 -+let reg_alloc_lim = phys_reg 26 -+ -+(* Names of instructions that differ in 32 and 64-bit modes *) -+ -+let lg = if rv64 then "ld" else "lw" -+let stg = if rv64 then "sd" else "sw" -+let datag = if rv64 then ".quad" else ".long" -+ -+(* Output a pseudo-register *) -+ -+let emit_reg = function -+ | {loc = Reg r} -> emit_string (register_name r) -+ | _ -> fatal_error "Emit.emit_reg" -+ -+(* Adjust sp by the given byte amount *) -+ -+let emit_stack_adjustment = function -+ | 0 -> () -+ | n when is_immediate n -> -+ ` addi sp, sp, {emit_int n}\n` -+ | n -> -+ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; -+ ` add sp, sp, {emit_reg reg_tmp1}\n` -+ -+let reload_ra n = -+ let ofs = n - size_addr in -+ if is_immediate ofs then -+ ` {emit_string lg} ra, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string lg} ra, 0({emit_reg reg_tmp1})\n` -+ end -+ -+let store_ra n = -+ let ofs = n - size_addr in -+ if is_immediate ofs then -+ ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string stg} ra, 0({emit_reg reg_tmp1})\n` -+ end -+ -+let emit_store stg src ofs = -+ if is_immediate ofs then -+ ` {emit_string stg} {emit_reg src}, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string stg} {emit_reg src}, 0({emit_reg reg_tmp1})\n` -+ end -+ -+let emit_load lg dst ofs = -+ if is_immediate ofs then -+ ` {emit_string lg} {emit_reg dst}, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string lg} {emit_reg dst}, 0({emit_reg reg_tmp1})\n` -+ end -+ -+(* Record live pointers at call points *) -+ -+let record_frame_label ?label live raise_ dbg = -+ let lbl = -+ match label with -+ | None -> new_label() -+ | Some label -> label -+ in -+ let live_offset = ref [] in -+ Reg.Set.iter -+ (function -+ {typ = Val; loc = Reg r} -> -+ live_offset := (r lsl 1) + 1 :: !live_offset -+ | {typ = Val; loc = Stack s} as reg -> -+ live_offset := slot_offset s (register_class reg) :: !live_offset -+ | {typ = Addr} as r -> -+ Misc.fatal_error ("bad GC root " ^ Reg.name r) -+ | _ -> () -+ ) -+ live; -+ record_frame_descr ~label:lbl ~frame_size:(frame_size()) -+ ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ lbl -+ -+let record_frame ?label live raise_ dbg = -+ let lbl = record_frame_label ?label live raise_ dbg in -+ `{emit_label lbl}:\n` -+ -+(* Record calls to the GC -- we've moved them out of the way *) -+ -+type gc_call = -+ { gc_lbl: label; (* Entry label *) -+ gc_return_lbl: label; (* Where to branch after GC *) -+ gc_frame_lbl: label } (* Label of frame descriptor *) -+ -+let call_gc_sites = ref ([] : gc_call list) -+ -+let emit_call_gc gc = -+ `{emit_label gc.gc_lbl}:\n`; -+ ` call {emit_symbol "caml_call_gc"}\n`; -+ `{emit_label gc.gc_frame_lbl}:\n`; -+ ` j {emit_label gc.gc_return_lbl}\n` -+ -+(* Record calls to caml_ml_array_bound_error. -+ In debug mode, we maintain one call to caml_ml_array_bound_error -+ per bound check site. Otherwise, we can share a single call. *) -+ -+type bound_error_call = -+ { bd_lbl: label; (* Entry label *) -+ bd_frame_lbl: label } (* Label of frame descriptor *) -+ -+let bound_error_sites = ref ([] : bound_error_call list) -+ -+let bound_error_label ?label dbg = -+ if !Clflags.debug || !bound_error_sites = [] then begin -+ let lbl_bound_error = new_label() in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in -+ bound_error_sites := -+ { bd_lbl = lbl_bound_error; -+ bd_frame_lbl = lbl_frame } :: !bound_error_sites; -+ lbl_bound_error -+ end else -+ let bd = List.hd !bound_error_sites in -+ bd.bd_lbl -+ -+let emit_call_bound_error bd = -+ `{emit_label bd.bd_lbl}:\n`; -+ ` call {emit_symbol "caml_ml_array_bound_error"}\n`; -+ `{emit_label bd.bd_frame_lbl}:\n` -+ -+(* Record floating-point literals *) -+ -+let float_literals = ref ([] : (int64 * int) list) -+ -+(* Names for various instructions *) -+ -+let name_for_intop = function -+ | Iadd -> "add" -+ | Isub -> "sub" -+ | Imul -> "mul" -+ | Imulh -> "mulh" -+ | Idiv -> "div" -+ | Iand -> "and" -+ | Ior -> "or" -+ | Ixor -> "xor" -+ | Ilsl -> "sll" -+ | Ilsr -> "srl" -+ | Iasr -> "sra" -+ | Imod -> "rem" -+ | _ -> fatal_error "Emit.Intop" -+ -+let name_for_intop_imm = function -+ | Iadd -> "addi" -+ | Iand -> "andi" -+ | Ior -> "ori" -+ | Ixor -> "xori" -+ | Ilsl -> "slli" -+ | Ilsr -> "srli" -+ | Iasr -> "srai" -+ | _ -> fatal_error "Emit.Intop_imm" -+ -+let name_for_floatop1 = function -+ | Inegf -> "fneg.d" -+ | Iabsf -> "fabs.d" -+ | _ -> fatal_error "Emit.Iopf1" -+ -+let name_for_floatop2 = function -+ | Iaddf -> "fadd.d" -+ | Isubf -> "fsub.d" -+ | Imulf -> "fmul.d" -+ | Idivf -> "fdiv.d" -+ | _ -> fatal_error "Emit.Iopf2" -+ -+let name_for_specific = function -+ | Imultaddf false -> "fmadd.d" -+ | Imultaddf true -> "fnmadd.d" -+ | Imultsubf false -> "fmsub.d" -+ | Imultsubf true -> "fnmsub.d" -+ -+(* Name of current function *) -+let function_name = ref "" -+ -+(* Entry point for tail recursive calls *) -+let tailrec_entry_point = ref 0 -+ -+(* Output the assembly code for an instruction *) -+ -+let emit_instr i = -+ match i.desc with -+ Lend -> () -+ | Lprologue -> -+ let n = frame_size() in -+ emit_stack_adjustment (-n); -+ if !contains_calls then store_ra n; -+ `{emit_label !tailrec_entry_point}:\n`; -+ | Lop(Imove | Ispill | Ireload) -> -+ let src = i.arg.(0) and dst = i.res.(0) in -+ if src.loc <> dst.loc then begin -+ match (src, dst) with -+ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> -+ ` mv {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> -+ ` fmv.d {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> -+ let ofs = slot_offset s (register_class dst) in -+ emit_store stg src ofs -+ | {loc = Reg _; typ = Float}, {loc = Stack s} -> -+ let ofs = slot_offset s (register_class dst) in -+ emit_store "fsd" src ofs -+ | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> -+ let ofs = slot_offset s (register_class src) in -+ emit_load lg dst ofs -+ | {loc = Stack s; typ = Float}, {loc = Reg _} -> -+ let ofs = slot_offset s (register_class src) in -+ emit_load "fld" dst ofs -+ | _ -> -+ fatal_error "Emit: Imove" -+ end -+ | Lop(Iconst_int n) -> -+ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` -+ | Lop(Iconst_float f) -> -+ let lbl = new_label() in -+ float_literals := (f, lbl) :: !float_literals; -+ ` fld {emit_reg i.res.(0)}, {emit_label lbl}, {emit_reg reg_tmp1}\n` -+ | Lop(Iconst_symbol s) -> -+ ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` -+ | Lop(Icall_ind {label_after = label}) -> -+ ` jalr {emit_reg i.arg.(0)}\n`; -+ record_frame ~label i.live false i.dbg -+ | Lop(Icall_imm {func; label_after = label}) -> -+ ` call {emit_symbol func}\n`; -+ record_frame ~label i.live false i.dbg -+ | Lop(Itailcall_ind {label_after = _}) -> -+ let n = frame_size() in -+ if !contains_calls then reload_ra n; -+ emit_stack_adjustment n; -+ ` jr {emit_reg i.arg.(0)}\n` -+ | Lop(Itailcall_imm {func; label_after = _}) -> -+ if func = !function_name then begin -+ ` j {emit_label !tailrec_entry_point}\n` -+ end else begin -+ let n = frame_size() in -+ if !contains_calls then reload_ra n; -+ emit_stack_adjustment n; -+ ` tail {emit_symbol func}\n` -+ end -+ | Lop(Iextcall{func; alloc = true; label_after = label}) -> -+ ` la {emit_reg reg_t2}, {emit_symbol func}\n`; -+ ` call {emit_symbol "caml_c_call"}\n`; -+ record_frame ~label i.live false i.dbg -+ | Lop(Iextcall{func; alloc = false; label_after = _}) -> -+ ` call {emit_symbol func}\n` -+ | Lop(Istackoffset n) -> -+ assert (n mod 16 = 0); -+ emit_stack_adjustment (-n); -+ stack_offset := !stack_offset + n -+ | Lop(Iload(Single, Iindexed ofs)) -> -+ ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; -+ ` fcvt.d.s {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Lop(Iload(chunk, Iindexed ofs)) -> -+ let instr = -+ match chunk with -+ | Byte_unsigned -> "lbu" -+ | Byte_signed -> "lb" -+ | Sixteen_unsigned -> "lhu" -+ | Sixteen_signed -> "lh" -+ | Thirtytwo_unsigned -> if rv64 then "lwu" else "lw" -+ | Thirtytwo_signed -> "lw" -+ | Word_int | Word_val -> lg -+ | Single -> assert false -+ | Double | Double_u -> "fld" -+ in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n` -+ | Lop(Istore(Single, Iindexed ofs, _)) -> -+ ` fmv.x.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}\n`; -+ ` fcvt.s.d {emit_reg i.arg.(0)}, {emit_reg i.arg.(0)}\n`; -+ ` fsw {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n`; -+ ` fmv.d.x {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}\n` -+ | Lop(Istore(chunk, Iindexed ofs, _)) -> -+ let instr = -+ match chunk with -+ | Byte_unsigned | Byte_signed -> "sb" -+ | Sixteen_unsigned | Sixteen_signed -> "sh" -+ | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" -+ | Word_int | Word_val -> stg -+ | Single -> assert false -+ | Double | Double_u -> "fsd" -+ in -+ ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` -+ | Lop(Ialloc {bytes = n; label_after_call_gc = label; _}) -> -+ let lbl_frame_lbl = record_frame_label ?label i.live false i.dbg in -+ let lbl_redo = new_label () in -+ let lbl_call_gc = new_label () in -+ `{emit_label lbl_redo}:\n`; -+ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, -{emit_int n}\n`; -+ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; -+ ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; -+ call_gc_sites := -+ { gc_lbl = lbl_call_gc; -+ gc_return_lbl = lbl_redo; -+ gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites -+ | Lop(Iintop(Icomp cmp)) -> -+ begin match cmp with -+ | Isigned Clt -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Isigned Cge -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Isigned Cgt -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | Isigned Cle -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Isigned Ceq | Iunsigned Ceq -> -+ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` seqz {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Isigned Cne | Iunsigned Cne -> -+ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` snez {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Iunsigned Clt -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Iunsigned Cge -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Iunsigned Cgt -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | Iunsigned Cle -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ end -+ | Lop(Iintop (Icheckbound {label_after_error = label; _})) -> -+ let lbl = bound_error_label ?label i.dbg in -+ ` bleu {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` -+ | Lop(Iintop op) -> -+ let instr = name_for_intop op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Lop(Iintop_imm(Isub, n)) -> -+ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` -+ | Lop(Iintop_imm(Icomp _, _)) -> -+ fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" -+ | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> -+ let lbl = bound_error_label ?label i.dbg in -+ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; -+ ` bleu {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ | Lop(Iintop_imm(op, n)) -> -+ let instr = name_for_intop_imm op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` -+ | Lop(Inegf | Iabsf as op) -> -+ let instr = name_for_floatop1 op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> -+ let instr = name_for_floatop2 op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Lop(Ifloatofint) -> -+ let name = if rv64 then "fcvt.d.l" else "fcvt.d.w" in -+ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Iintoffloat) -> -+ let name = if rv64 then "fcvt.l.d" else "fcvt.w.d" in -+ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Ispecific sop) -> -+ let instr = name_for_specific sop in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` -+ | Lop (Iname_for_debugger _) -> -+ () -+ | Lreloadretaddr -> -+ let n = frame_size () in -+ reload_ra n -+ | Lreturn -> -+ let n = frame_size() in -+ emit_stack_adjustment n; -+ ` ret\n` -+ | Llabel lbl -> -+ `{emit_label lbl}:\n` -+ | Lbranch lbl -> -+ ` j {emit_label lbl}\n` -+ | Lcondbranch(tst, lbl) -> -+ begin match tst with -+ | Itruetest -> -+ ` bnez {emit_reg i.arg.(0)}, {emit_label lbl}\n` -+ | Ifalsetest -> -+ ` beqz {emit_reg i.arg.(0)}, {emit_label lbl}\n` -+ | Iinttest cmp -> -+ let name = match cmp with -+ | Iunsigned Ceq | Isigned Ceq -> "beq" -+ | Iunsigned Cne | Isigned Cne -> "bne" -+ | Iunsigned Cle -> "bleu" | Isigned Cle -> "ble" -+ | Iunsigned Cge -> "bgeu" | Isigned Cge -> "bge" -+ | Iunsigned Clt -> "bltu" | Isigned Clt -> "blt" -+ | Iunsigned Cgt -> "bgtu" | Isigned Cgt -> "bgt" -+ in -+ ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` -+ | Iinttest_imm _ -> -+ fatal_error "Emit.emit_instr (Iinttest_imm _)" -+ | Ifloattest cmp -> -+ let branch = -+ match cmp with -+ | CFneq | CFnlt | CFngt | CFnle | CFnge -> "beqz" -+ | CFeq | CFlt | CFgt | CFle | CFge -> "bnez" -+ in -+ begin match cmp with -+ | CFeq | CFneq -> ` feq.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFlt | CFnlt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFgt | CFngt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | CFle | CFnle -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFge | CFnge -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ end; -+ ` {emit_string branch} {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ | Ioddtest -> -+ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; -+ ` bnez {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ | Ieventest -> -+ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; -+ ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end -+ | Lcondbranch3(lbl0, lbl1, lbl2) -> -+ ` addi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, -1\n`; -+ begin match lbl0 with -+ | None -> () -+ | Some lbl -> ` bltz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end; -+ begin match lbl1 with -+ | None -> () -+ | Some lbl -> ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end; -+ begin match lbl2 with -+ | None -> () -+ | Some lbl -> ` bgtz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end -+ | Lswitch jumptbl -> (* FIXME FIXME ? *) -+ let lbl = new_label() in -+ ` la {emit_reg reg_tmp1}, {emit_label lbl}\n`; -+ ` slli {emit_reg reg_tmp2}, {emit_reg i.arg.(0)}, 2\n`; -+ ` add {emit_reg reg_tmp1}, {emit_reg reg_tmp1}, {emit_reg reg_tmp2}\n`; -+ ` jr {emit_reg reg_tmp1}\n`; -+ `{emit_label lbl}:\n`; -+ for i = 0 to Array.length jumptbl - 1 do -+ ` j {emit_label jumptbl.(i)}\n` -+ done -+ | Lsetuptrap lbl -> -+ ` addi sp, sp, -16\n`; -+ ` jal {emit_label lbl}\n` -+ | Lpushtrap -> -+ stack_offset := !stack_offset + 16; -+ ` {emit_string stg} ra, {emit_int size_addr}(sp)\n`; -+ ` {emit_string stg} {emit_reg reg_trap}, 0(sp)\n`; -+ ` mv {emit_reg reg_trap}, sp\n` -+ | Lpoptrap -> -+ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; -+ ` addi sp, sp, 16\n`; -+ stack_offset := !stack_offset - 16 -+ | Lraise k -> -+ begin match !Clflags.debug, k with -+ | true, Cmm.Raise_withtrace -> -+ ` call {emit_symbol "caml_raise_exn"}\n`; -+ record_frame Reg.Set.empty true i.dbg -+ | false, _ -+ | true, Cmm.Raise_notrace -> -+ ` mv sp, {emit_reg reg_trap}\n`; -+ ` {emit_string lg} {emit_reg reg_tmp1}, {emit_int size_addr}(sp)\n`; -+ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; -+ ` addi sp, sp, 16\n`; -+ ` jalr {emit_reg reg_tmp1}\n` -+ end -+ -+(* Emit a sequence of instructions *) -+ -+let rec emit_all = function -+ | {desc = Lend} -> () | i -> emit_instr i; emit_all i.next -+ -+(* Emission of a function declaration *) -+ -+let fundecl fundecl = -+ function_name := fundecl.fun_name; -+ tailrec_entry_point := new_label(); -+ stack_offset := 0; -+ call_gc_sites := []; -+ bound_error_sites := []; -+ float_literals := []; -+ ` .globl {emit_symbol fundecl.fun_name}\n`; -+ ` .type {emit_symbol fundecl.fun_name}, @function\n`; -+ ` {emit_string code_space}\n`; -+ ` .align 2\n`; -+ `{emit_symbol fundecl.fun_name}:\n`; -+ emit_all fundecl.fun_body; -+ List.iter emit_call_gc !call_gc_sites; -+ List.iter emit_call_bound_error !bound_error_sites; -+ ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; -+ (* Emit the float literals *) -+ if !float_literals <> [] then begin -+ ` {emit_string rodata_space}\n`; -+ ` .align 3\n`; -+ List.iter -+ (fun (f, lbl) -> -+ `{emit_label lbl}:\n`; -+ if rv64 -+ then emit_float64_directive ".quad" f -+ else emit_float64_split_directive ".long" f) -+ !float_literals; -+ end -+ -+(* Emission of data *) -+ -+let declare_global_data s = -+ ` .globl {emit_symbol s}\n`; -+ ` .type {emit_symbol s}, @object\n` -+ -+let emit_item = function -+ | Cglobal_symbol s -> -+ declare_global_data s -+ | Cdefine_symbol s -> -+ `{emit_symbol s}:\n`; -+ | Cint8 n -> -+ ` .byte {emit_int n}\n` -+ | Cint16 n -> -+ ` .short {emit_int n}\n` -+ | Cint32 n -> -+ ` .long {emit_nativeint n}\n` -+ | Cint n -> -+ ` {emit_string datag} {emit_nativeint n}\n` -+ | Csingle f -> -+ emit_float32_directive ".long" (Int32.bits_of_float f) -+ | Cdouble f -> -+ if rv64 -+ then emit_float64_directive ".quad" (Int64.bits_of_float f) -+ else emit_float64_split_directive ".long" (Int64.bits_of_float f) -+ | Csymbol_address s -> -+ ` {emit_string datag} {emit_symbol s}\n` -+ | Cstring s -> -+ emit_bytes_directive " .byte " s -+ | Cskip n -> -+ if n > 0 then ` .space {emit_int n}\n` -+ | Calign n -> -+ ` .align {emit_int (Misc.log2 n)}\n` -+ -+let data l = -+ ` {emit_string data_space}\n`; -+ List.iter emit_item l -+ -+(* Beginning / end of an assembly file *) -+ -+let begin_assembly() = -+ ` .file \"\"\n`; (* PR#7073 *) -+ (* Emit the beginning of the segments *) -+ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in -+ ` {emit_string data_space}\n`; -+ declare_global_data lbl_begin; -+ `{emit_symbol lbl_begin}:\n`; -+ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in -+ ` {emit_string code_space}\n`; -+ declare_global_data lbl_begin; -+ `{emit_symbol lbl_begin}:\n` -+ -+let end_assembly() = -+ ` {emit_string code_space}\n`; -+ let lbl_end = Compilenv.make_symbol (Some "code_end") in -+ declare_global_data lbl_end; -+ `{emit_symbol lbl_end}:\n`; -+ ` .long 0\n`; -+ ` {emit_string data_space}\n`; -+ let lbl_end = Compilenv.make_symbol (Some "data_end") in -+ declare_global_data lbl_end; -+ `{emit_symbol lbl_end}:\n`; -+ ` {emit_string datag} 0\n`; -+ (* Emit the frame descriptors *) -+ ` {emit_string rodata_space}\n`; -+ let lbl = Compilenv.make_symbol (Some "frametable") in -+ declare_global_data lbl; -+ `{emit_symbol lbl}:\n`; -+ emit_frames -+ { efa_code_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); -+ efa_data_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); -+ efa_16 = (fun n -> ` .short {emit_int n}\n`); -+ efa_32 = (fun n -> ` .long {emit_int32 n}\n`); -+ efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); -+ efa_align = (fun n -> ` .align {emit_int (Misc.log2 n)}\n`); -+ efa_label_rel = (fun lbl ofs -> -+ ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); -+ efa_def_label = (fun l -> `{emit_label l}:\n`); -+ efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) -+ } -diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml -new file mode 100644 -index 000000000..c0db0fd7b ---- /dev/null -+++ b/asmcomp/riscv/proc.ml -@@ -0,0 +1,330 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* Description of the RISC-V *) -+ -+open Misc -+open Cmm -+open Reg -+open Arch -+open Mach -+ -+(* Instruction selection *) -+ -+let word_addressed = false -+ -+(* Registers available for register allocation *) -+ -+(* Integer register map: -+ zero always zero -+ ra return address -+ sp, gp, tp stack pointer, global pointer, thread pointer (preserved by C) -+ a0 - a7 0 - 7 arguments/results -+ s2 - s9 8 - 15 arguments/results (preserved by C) -+ t2 - t6 16 - 20 temporary -+ t0 21 temporary (used by assembler) -+ t1 22 temporary (reserved for code gen) -+ s0 23 frame pointer (preserved by C) -+ s1 24 trap pointer (preserved by C) -+ s10 25 allocation pointer (preserved by C) -+ s11 26 allocation limit (preserved by C) -+ Floating-point register map: -+ ft0 - ft7 100 - 107 temporary -+ fs0 - fs1 108 - 109 general purpose (preserved by C) -+ fa0 - fa7 110 - 117 arguments/results -+ fs2 - fs9 118 - 125 arguments/results (preserved by C) -+ fs10 - fs11 126 - 127 general purpose (preserved by C) -+ ft8 - ft11 128 - 131 temporary -+*) -+ -+let int_reg_name = -+ [| "a0"; "a1"; "a2"; "a3"; "a4"; "a5"; "a6"; "a7"; -+ "s2"; "s3"; "s4"; "s5"; "s6"; "s7"; "s8"; "s9"; -+ "t2"; "t3"; "t4"; "t5"; "t6"; -+ "t0"; "t1"; -+ "s0"; "s1"; "s10"; "s11" |] -+ -+let float_reg_name = -+ [| "ft0"; "ft1"; "ft2"; "ft3"; "ft4"; "ft5"; "ft6"; "ft7"; -+ "fs0"; "fs1"; -+ "fa0"; "fa1"; "fa2"; "fa3"; "fa4"; "fa5"; "fa6"; "fa7"; -+ "fs2"; "fs3"; "fs4"; "fs5"; "fs6"; "fs7"; "fs8"; "fs9"; "fs10"; "fs11"; -+ "ft8"; "ft9"; "ft10"; "ft11" |] -+ -+let num_register_classes = 2 -+ -+let register_class r = -+ match r.typ with -+ | Val | Int | Addr -> 0 -+ | Float -> 1 -+ -+let num_available_registers = [| 21; 32 |] -+ -+let first_available_register = [| 0; 100 |] -+ -+let register_name r = -+ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) -+ -+let rotate_registers = true -+ -+(* Representation of hard registers by pseudo-registers *) -+ -+let hard_int_reg = -+ let v = Array.make 27 Reg.dummy in -+ for i = 0 to 26 do -+ v.(i) <- Reg.at_location Int (Reg i) -+ done; -+ v -+ -+let hard_float_reg = -+ let v = Array.make 32 Reg.dummy in -+ for i = 0 to 31 do -+ v.(i) <- Reg.at_location Float (Reg(100 + i)) -+ done; -+ v -+ -+let all_phys_regs = -+ Array.append hard_int_reg hard_float_reg -+ -+let phys_reg n = -+ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) -+ -+let stack_slot slot ty = -+ Reg.at_location ty (Stack slot) -+ -+(* Calling conventions *) -+ -+let calling_conventions -+ first_int last_int first_float last_float make_stack arg = -+ let loc = Array.make (Array.length arg) Reg.dummy in -+ let int = ref first_int in -+ let float = ref first_float in -+ let ofs = ref 0 in -+ for i = 0 to Array.length arg - 1 do -+ match arg.(i).typ with -+ | Val | Int | Addr as ty -> -+ if !int <= last_int then begin -+ loc.(i) <- phys_reg !int; -+ incr int -+ end else begin -+ loc.(i) <- stack_slot (make_stack !ofs) ty; -+ ofs := !ofs + size_int -+ end -+ | Float -> -+ if !float <= last_float then begin -+ loc.(i) <- phys_reg !float; -+ incr float -+ end else begin -+ loc.(i) <- stack_slot (make_stack !ofs) Float; -+ ofs := !ofs + size_float -+ end -+ done; -+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) -+ -+let incoming ofs = Incoming ofs -+let outgoing ofs = Outgoing ofs -+let not_supported _ = fatal_error "Proc.loc_results: cannot call" -+ -+let max_arguments_for_tailcalls = 16 -+ -+let loc_spacetime_node_hole = Reg.dummy (* Spacetime unsupported *) -+ -+(* OCaml calling convention: -+ first integer args in a0 .. a7, s2 .. s9 -+ first float args in fa0 .. fa7, fs2 .. fs9 -+ remaining args on stack. -+ Return values in a0 .. a7, s2 .. s9 or fa0 .. fa7, fs2 .. fs9. *) -+ -+let single_regs arg = Array.map (fun arg -> [| arg |]) arg -+let ensure_single_regs res = -+ Array.map (function -+ | [| res |] -> res -+ | _ -> failwith "proc.ensure_single_regs" -+ ) res -+ -+let loc_arguments arg = -+ calling_conventions 0 15 110 125 outgoing arg -+ -+let loc_parameters arg = -+ let (loc, _ofs) = -+ calling_conventions 0 15 110 125 incoming arg -+ in -+ loc -+ -+let loc_results res = -+ let (loc, _ofs) = -+ calling_conventions 0 15 110 125 not_supported res -+ in -+ loc -+ -+(* C calling convention: -+ first integer args in a0 .. a7 -+ first float args in fa0 .. fa7 -+ remaining args on stack. -+ Return values in a0 .. a1 or fa0 .. fa1. *) -+ -+let external_calling_conventions -+ first_int last_int first_float last_float make_stack arg = -+ let loc = Array.make (Array.length arg) [| Reg.dummy |] in -+ let int = ref first_int in -+ let float = ref first_float in -+ let ofs = ref 0 in -+ for i = 0 to Array.length arg - 1 do -+ match arg.(i) with -+ | [| arg |] -> -+ begin match arg.typ with -+ | Val | Int | Addr as ty -> -+ if !int <= last_int then begin -+ loc.(i) <- [| phys_reg !int |]; -+ incr int; -+ incr float; -+ end else begin -+ loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; -+ ofs := !ofs + size_int -+ end -+ | Float -> -+ if !float <= last_float then begin -+ loc.(i) <- [| phys_reg !float |]; -+ incr float; -+ incr int; -+ end else begin -+ loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; -+ ofs := !ofs + size_float -+ end -+ end -+ | [| arg1; arg2 |] -> -+ (* Passing of 64-bit quantities to external functions on 32-bit -+ platform. *) -+ assert (size_int = 4); -+ begin match arg1.typ, arg2.typ with -+ | Int, Int -> -+ int := Misc.align !int 2; -+ if !int <= last_int - 1 then begin -+ let reg_lower = phys_reg !int in -+ let reg_upper = phys_reg (!int + 1) in -+ loc.(i) <- [| reg_lower; reg_upper |]; -+ int := !int + 2 -+ end else begin -+ let size_int64 = 8 in -+ ofs := Misc.align !ofs size_int64; -+ let ofs_lower = !ofs in -+ let ofs_upper = !ofs + size_int in -+ let stack_lower = stack_slot (make_stack ofs_lower) Int in -+ let stack_upper = stack_slot (make_stack ofs_upper) Int in -+ loc.(i) <- [| stack_lower; stack_upper |]; -+ ofs := !ofs + size_int64 -+ end -+ | _ -> -+ let f = function Int -> "I" | Addr -> "A" | Val -> "V" | Float -> "F" in -+ fatal_error (Printf.sprintf "Proc.calling_conventions: bad register \ -+ type(s) for multi-register argument: %s, %s" -+ (f arg1.typ) (f arg2.typ)) -+ end -+ | _ -> -+ fatal_error "Proc.calling_conventions: bad number of register for \ -+ multi-register argument" -+ done; -+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) -+ -+let loc_external_arguments arg = -+ external_calling_conventions 0 7 110 117 outgoing arg -+ -+let loc_external_results res = -+ let (loc, _ofs) = -+ external_calling_conventions 0 1 110 111 not_supported (single_regs res) -+ in -+ ensure_single_regs loc -+ -+(* Exceptions are in GPR 3 *) -+ -+let loc_exn_bucket = phys_reg 0 -+ -+(* Volatile registers: none *) -+ -+let regs_are_volatile _ = false -+ -+(* Registers destroyed by operations *) -+ -+let destroyed_at_c_call = -+ Array.of_list(List.map phys_reg -+ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; (* 21; 22; *) -+ 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; -+ 117; 128; 129; 130; 131]) -+ -+let destroyed_at_oper = function -+ | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs -+ | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call -+ | _ -> [||] -+ -+let destroyed_at_raise = all_phys_regs -+ -+let destroyed_at_reloadretaddr = [| |] (* CHECK *) -+ -+(* Maximal register pressure *) -+ -+let safe_register_pressure = function -+ | Iextcall _ -> 15 -+ | _ -> 21 -+ -+let max_register_pressure = function -+ | Iextcall _ -> [| 15; 18 |] -+ | _ -> [| 21; 30 |] -+ -+(* Pure operations (without any side effect besides updating their result -+ registers). *) -+ -+let op_is_pure = function -+ | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ -+ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ -+ | Iintop(Icheckbound _) | Iintop_imm(Icheckbound _, _) -> false -+ | Ispecific(Imultaddf _ | Imultsubf _) -> true -+ | _ -> true -+ -+(* Layout of the stack *) -+ -+let num_stack_slots = [| 0; 0 |] -+let contains_calls = ref false -+ -+(* See -+ https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md *) -+ -+let int_dwarf_reg_numbers = -+ [| 10; 11; 12; 13; 14; 15; 16; 17; -+ 18; 19; 20; 21; 22; 23; 24; 25; -+ 7; 29; 29; 30; 31; -+ 5; 6; 8; 9; 26; 27; -+ |] -+ -+let float_dwarf_reg_numbers = -+ [| 32; 33; 34; 35; 36; 37; 38; 39; -+ 40; 41; -+ 42; 43; 44; 45; 46; 47; 48; 49; -+ 50; 51; 52; 53; 54; 55; 56; 57; -+ 58; 59; -+ 60; 61; 62; 63; -+ |] -+ -+let dwarf_register_numbers ~reg_class = -+ match reg_class with -+ | 0 -> int_dwarf_reg_numbers -+ | 1 -> float_dwarf_reg_numbers -+ | _ -> Misc.fatal_errorf "Bad register class %d" reg_class -+ -+let stack_ptr_dwarf_register_number = 2 -+ -+(* Calling the assembler *) -+ -+let assemble_file infile outfile = -+ Ccomp.command -+ (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) -+ -+let init () = () -diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml -new file mode 100644 -index 000000000..85b970342 ---- /dev/null -+++ b/asmcomp/riscv/reload.ml -@@ -0,0 +1,16 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* Reloading for the RISC-V *) -+ -+let fundecl f = -+ (new Reloadgen.reload_generic)#fundecl f -diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml -new file mode 100644 -index 000000000..e436be1cc ---- /dev/null -+++ b/asmcomp/riscv/scheduling.ml -@@ -0,0 +1,19 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* Instruction scheduling for the RISC-V *) -+ -+let _ = let module M = Schedgen in () (* to create a dependency *) -+ -+(* Scheduling is turned off. *) -+ -+let fundecl f = f -diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml -new file mode 100644 -index 000000000..85bac1161 ---- /dev/null -+++ b/asmcomp/riscv/selection.ml -@@ -0,0 +1,71 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) -+ -+(* Instruction selection for the RISC-V processor *) -+ -+open Cmm -+open Arch -+open Mach -+ -+(* Instruction selection *) -+ -+class selector = object (self) -+ -+inherit Selectgen.selector_generic as super -+ -+method is_immediate n = is_immediate n -+ -+method select_addressing _ = function -+ | Cop(Cadda, [arg; Cconst_int n], _) when self#is_immediate n -> -+ (Iindexed n, arg) -+ | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int n], _)], dbg) when self#is_immediate n -> -+ (Iindexed n, Cop(Caddi, [arg1; arg2], dbg)) -+ | arg -> -+ (Iindexed 0, arg) -+ -+method! select_operation op args dbg = -+ match (op, args) with -+ (* RISC-V does not support immediate operands for multiply high *) -+ | (Cmulhi, _) -> (Iintop Imulh, args) -+ (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) -+ | (Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -+ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2], _)]) -> -+ (Ispecific (Imultaddf false), [arg1; arg2; arg3]) -+ | (Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -> -+ (Ispecific (Imultsubf false), [arg1; arg2; arg3]) -+ | (Cnegf, [Cop(Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> -+ (Ispecific (Imultsubf true), [arg1; arg2; arg3]) -+ | (Cnegf, [Cop(Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> -+ (Ispecific (Imultaddf true), [arg1; arg2; arg3]) -+ (* RISC-V does not support immediate operands for comparison operators *) -+ | (Ccmpi comp, args) -> (Iintop(Icomp (Isigned comp)), args) -+ | (Ccmpa comp, args) -> (Iintop(Icomp (Iunsigned comp)), args) -+ | (Cmuli, _) -> (Iintop Imul, args) -+ | _ -> -+ super#select_operation op args dbg -+ -+(* Instruction selection for conditionals *) -+ -+method! select_condition = function -+ Cop(Ccmpi cmp, args, _) -> -+ (Iinttest(Isigned cmp), Ctuple args) -+ | Cop(Ccmpa cmp, args, _) -> -+ (Iinttest(Iunsigned cmp), Ctuple args) -+ | Cop(Ccmpf cmp, args, _) -> -+ (Ifloattest cmp, Ctuple args) -+ | Cop(Cand, [arg; Cconst_int 1], _) -> -+ (Ioddtest, arg) -+ | arg -> -+ (Itruetest, arg) -+end -+ -+let fundecl f = (new selector)#emit_fundecl f -diff --git a/config/gnu/config.guess b/config/gnu/config.guess -index b79252d6b..a81aa505b 100755 ---- a/config/gnu/config.guess -+++ b/config/gnu/config.guess -@@ -1,8 +1,8 @@ - #! /bin/sh - # Attempt to guess a canonical system name. --# Copyright 1992-2013 Free Software Foundation, Inc. -+# Copyright 1992-2019 Free Software Foundation, Inc. - --timestamp='2013-06-10' -+timestamp='2019-01-15' - - # This file is free software; you can redistribute it and/or modify it - # under the terms of the GNU General Public License as published by -@@ -15,7 +15,7 @@ timestamp='2013-06-10' - # General Public License for more details. - # - # You should have received a copy of the GNU General Public License --# along with this program; if not, see . -+# along with this program; if not, see . - # - # As a special exception to the GNU General Public License, if you - # distribute this file as part of a program that contains a -@@ -24,12 +24,12 @@ timestamp='2013-06-10' - # program. This Exception is an additional permission under section 7 - # of the GNU General Public License, version 3 ("GPLv3"). - # --# Originally written by Per Bothner. -+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. - # - # You can get the latest version of this script from: --# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess - # --# Please send patches with a ChangeLog entry to config-patches@gnu.org. -+# Please send patches to . - - - me=`echo "$0" | sed -e 's,.*/,,'` -@@ -39,7 +39,7 @@ Usage: $0 [OPTION] - - Output the configuration name of the system \`$me' is run on. - --Operation modes: -+Options: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit -@@ -50,7 +50,7 @@ version="\ - GNU config.guess ($timestamp) - - Originally written by Per Bothner. --Copyright 1992-2013 Free Software Foundation, Inc. -+Copyright 1992-2019 Free Software Foundation, Inc. - - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -@@ -84,8 +84,6 @@ if test $# != 0; then - exit 1 - fi - --trap 'exit 1' 1 2 15 -- - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a - # compiler to aid in system detection is discouraged as it requires - # temporary files to be created and, as you can see below, it is a -@@ -96,34 +94,38 @@ trap 'exit 1' 1 2 15 - - # Portable tmp directory creation inspired by the Autoconf team. - --set_cc_for_build=' --trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; --trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; --: ${TMPDIR=/tmp} ; -- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || -- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || -- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || -- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; --dummy=$tmp/dummy ; --tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; --case $CC_FOR_BUILD,$HOST_CC,$CC in -- ,,) echo "int x;" > $dummy.c ; -- for c in cc gcc c89 c99 ; do -- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then -- CC_FOR_BUILD="$c"; break ; -- fi ; -- done ; -- if test x"$CC_FOR_BUILD" = x ; then -- CC_FOR_BUILD=no_compiler_found ; -- fi -- ;; -- ,,*) CC_FOR_BUILD=$CC ;; -- ,*,*) CC_FOR_BUILD=$HOST_CC ;; --esac ; set_cc_for_build= ;' -+tmp= -+# shellcheck disable=SC2172 -+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 -+ -+set_cc_for_build() { -+ : "${TMPDIR=/tmp}" -+ # shellcheck disable=SC2039 -+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || -+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || -+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || -+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } -+ dummy=$tmp/dummy -+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in -+ ,,) echo "int x;" > "$dummy.c" -+ for driver in cc gcc c89 c99 ; do -+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then -+ CC_FOR_BUILD="$driver" -+ break -+ fi -+ done -+ if test x"$CC_FOR_BUILD" = x ; then -+ CC_FOR_BUILD=no_compiler_found -+ fi -+ ;; -+ ,,*) CC_FOR_BUILD=$CC ;; -+ ,*,*) CC_FOR_BUILD=$HOST_CC ;; -+ esac -+} - - # This is needed to find uname on a Pyramid OSx when run in the BSD universe. - # (ghazi@noc.rutgers.edu 1994-08-24) --if (test -f /.attbin/uname) >/dev/null 2>&1 ; then -+if test -f /.attbin/uname ; then - PATH=$PATH:/.attbin ; export PATH - fi - -@@ -132,14 +134,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown - UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown - UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - --case "${UNAME_SYSTEM}" in -+case "$UNAME_SYSTEM" in - Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - -- eval $set_cc_for_build -- cat <<-EOF > $dummy.c -+ set_cc_for_build -+ cat <<-EOF > "$dummy.c" - #include - #if defined(__UCLIBC__) - LIBC=uclibc -@@ -149,13 +151,20 @@ Linux|GNU|GNU/*) - LIBC=gnu - #endif - EOF -- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` -+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" -+ -+ # If ldd exists, use it to detect musl libc. -+ if command -v ldd >/dev/null && \ -+ ldd --version 2>&1 | grep -q ^musl -+ then -+ LIBC=musl -+ fi - ;; - esac - - # Note: order is significant - the case branches are not exclusive. - --case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in -+case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, -@@ -168,21 +177,31 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" -- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ -- /usr/sbin/$sysctl 2>/dev/null || echo unknown)` -- case "${UNAME_MACHINE_ARCH}" in -+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ -+ "/sbin/$sysctl" 2>/dev/null || \ -+ "/usr/sbin/$sysctl" 2>/dev/null || \ -+ echo unknown)` -+ case "$UNAME_MACHINE_ARCH" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; -- *) machine=${UNAME_MACHINE_ARCH}-unknown ;; -+ earmv*) -+ arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` -+ endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` -+ machine="${arch}${endian}"-unknown -+ ;; -+ *) machine="$UNAME_MACHINE_ARCH"-unknown ;; - esac - # The Operating System including object format, if it has switched -- # to ELF recently, or will in the future. -- case "${UNAME_MACHINE_ARCH}" in -+ # to ELF recently (or will in the future) and ABI. -+ case "$UNAME_MACHINE_ARCH" in -+ earm*) -+ os=netbsdelf -+ ;; - arm*|i386|m68k|ns32k|sh3*|sparc|vax) -- eval $set_cc_for_build -+ set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then -@@ -197,44 +216,67 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - os=netbsd - ;; - esac -+ # Determine ABI tags. -+ case "$UNAME_MACHINE_ARCH" in -+ earm*) -+ expr='s/^earmv[0-9]/-eabi/;s/eb$//' -+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` -+ ;; -+ esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. -- case "${UNAME_VERSION}" in -+ case "$UNAME_VERSION" in - Debian*) - release='-gnu' - ;; - *) -- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` -+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. -- echo "${machine}-${os}${release}" -+ echo "$machine-${os}${release}${abi-}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` -- echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} -+ echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` -- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} -+ echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" -+ exit ;; -+ *:LibertyBSD:*:*) -+ UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` -+ echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" -+ exit ;; -+ *:MidnightBSD:*:*) -+ echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" - exit ;; - *:ekkoBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" - exit ;; - *:SolidBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" - exit ;; - macppc:MirBSD:*:*) -- echo powerpc-unknown-mirbsd${UNAME_RELEASE} -+ echo powerpc-unknown-mirbsd"$UNAME_RELEASE" - exit ;; - *:MirBSD:*:*) -- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" -+ exit ;; -+ *:Sortix:*:*) -+ echo "$UNAME_MACHINE"-unknown-sortix -+ exit ;; -+ *:Redox:*:*) -+ echo "$UNAME_MACHINE"-unknown-redox - exit ;; -+ mips:OSF1:*.*) -+ echo mips-dec-osf1 -+ exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) -@@ -251,63 +293,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") -- UNAME_MACHINE="alpha" ;; -+ UNAME_MACHINE=alpha ;; - "EV4.5 (21064)") -- UNAME_MACHINE="alpha" ;; -+ UNAME_MACHINE=alpha ;; - "LCA4 (21066/21068)") -- UNAME_MACHINE="alpha" ;; -+ UNAME_MACHINE=alpha ;; - "EV5 (21164)") -- UNAME_MACHINE="alphaev5" ;; -+ UNAME_MACHINE=alphaev5 ;; - "EV5.6 (21164A)") -- UNAME_MACHINE="alphaev56" ;; -+ UNAME_MACHINE=alphaev56 ;; - "EV5.6 (21164PC)") -- UNAME_MACHINE="alphapca56" ;; -+ UNAME_MACHINE=alphapca56 ;; - "EV5.7 (21164PC)") -- UNAME_MACHINE="alphapca57" ;; -+ UNAME_MACHINE=alphapca57 ;; - "EV6 (21264)") -- UNAME_MACHINE="alphaev6" ;; -+ UNAME_MACHINE=alphaev6 ;; - "EV6.7 (21264A)") -- UNAME_MACHINE="alphaev67" ;; -+ UNAME_MACHINE=alphaev67 ;; - "EV6.8CB (21264C)") -- UNAME_MACHINE="alphaev68" ;; -+ UNAME_MACHINE=alphaev68 ;; - "EV6.8AL (21264B)") -- UNAME_MACHINE="alphaev68" ;; -+ UNAME_MACHINE=alphaev68 ;; - "EV6.8CX (21264D)") -- UNAME_MACHINE="alphaev68" ;; -+ UNAME_MACHINE=alphaev68 ;; - "EV6.9A (21264/EV69A)") -- UNAME_MACHINE="alphaev69" ;; -+ UNAME_MACHINE=alphaev69 ;; - "EV7 (21364)") -- UNAME_MACHINE="alphaev7" ;; -+ UNAME_MACHINE=alphaev7 ;; - "EV7.9 (21364A)") -- UNAME_MACHINE="alphaev79" ;; -+ UNAME_MACHINE=alphaev79 ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. -- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -+ echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; -- Alpha\ *:Windows_NT*:*) -- # How do we know it's Interix rather than the generic POSIX subsystem? -- # Should we change UNAME_MACHINE based on the output of uname instead -- # of the specific Alpha model? -- echo alpha-pc-interix -- exit ;; -- 21064:Windows_NT:50:3) -- echo alpha-dec-winnt3.5 -- exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) -- echo ${UNAME_MACHINE}-unknown-amigaos -+ echo "$UNAME_MACHINE"-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) -- echo ${UNAME_MACHINE}-unknown-morphos -+ echo "$UNAME_MACHINE"-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition -@@ -319,7 +352,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) -- echo arm-acorn-riscix${UNAME_RELEASE} -+ echo arm-acorn-riscix"$UNAME_RELEASE" - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos -@@ -346,38 +379,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) -- echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -+ echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" - exit ;; - sun4H:SunOS:5.*:*) -- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -+ echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) -- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -+ echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) -- echo i386-pc-auroraux${UNAME_RELEASE} -+ echo i386-pc-auroraux"$UNAME_RELEASE" - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) -- eval $set_cc_for_build -- SUN_ARCH="i386" -+ set_cc_for_build -+ SUN_ARCH=i386 - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. -- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then -+ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ -- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then -- SUN_ARCH="x86_64" -+ SUN_ARCH=x86_64 - fi - fi -- echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -+ echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. -- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -+ echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in -@@ -386,25 +419,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. -- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` -+ echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" - exit ;; - sun3*:SunOS:*:*) -- echo m68k-sun-sunos${UNAME_RELEASE} -+ echo m68k-sun-sunos"$UNAME_RELEASE" - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` -- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 -+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) -- echo m68k-sun-sunos${UNAME_RELEASE} -+ echo m68k-sun-sunos"$UNAME_RELEASE" - ;; - sun4) -- echo sparc-sun-sunos${UNAME_RELEASE} -+ echo sparc-sun-sunos"$UNAME_RELEASE" - ;; - esac - exit ;; - aushp:SunOS:*:*) -- echo sparc-auspex-sunos${UNAME_RELEASE} -+ echo sparc-auspex-sunos"$UNAME_RELEASE" - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not -@@ -415,44 +448,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) -- echo m68k-atari-mint${UNAME_RELEASE} -+ echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) -- echo m68k-atari-mint${UNAME_RELEASE} -+ echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) -- echo m68k-atari-mint${UNAME_RELEASE} -+ echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) -- echo m68k-milan-mint${UNAME_RELEASE} -+ echo m68k-milan-mint"$UNAME_RELEASE" - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) -- echo m68k-hades-mint${UNAME_RELEASE} -+ echo m68k-hades-mint"$UNAME_RELEASE" - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) -- echo m68k-unknown-mint${UNAME_RELEASE} -+ echo m68k-unknown-mint"$UNAME_RELEASE" - exit ;; - m68k:machten:*:*) -- echo m68k-apple-machten${UNAME_RELEASE} -+ echo m68k-apple-machten"$UNAME_RELEASE" - exit ;; - powerpc:machten:*:*) -- echo powerpc-apple-machten${UNAME_RELEASE} -+ echo powerpc-apple-machten"$UNAME_RELEASE" - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) -- echo mips-dec-ultrix${UNAME_RELEASE} -+ echo mips-dec-ultrix"$UNAME_RELEASE" - exit ;; - VAX*:ULTRIX*:*:*) -- echo vax-dec-ultrix${UNAME_RELEASE} -+ echo vax-dec-ultrix"$UNAME_RELEASE" - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) -- echo clipper-intergraph-clix${UNAME_RELEASE} -+ echo clipper-intergraph-clix"$UNAME_RELEASE" - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #ifdef __cplusplus - #include /* for printf() prototype */ - int main (int argc, char *argv[]) { -@@ -461,23 +494,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - #endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) -- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); -+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) -- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); -+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) -- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); -+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } - EOF -- $CC_FOR_BUILD -o $dummy $dummy.c && -- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && -- SYSTEM_NAME=`$dummy $dummyarg` && -+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && -+ dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && -+ SYSTEM_NAME=`"$dummy" "$dummyarg"` && - { echo "$SYSTEM_NAME"; exit; } -- echo mips-mips-riscos${UNAME_RELEASE} -+ echo mips-mips-riscos"$UNAME_RELEASE" - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax -@@ -503,17 +536,17 @@ EOF - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` -- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] -+ if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] - then -- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ -- [ ${TARGET_BINARY_INTERFACE}x = x ] -+ if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ -+ [ "$TARGET_BINARY_INTERFACE"x = x ] - then -- echo m88k-dg-dgux${UNAME_RELEASE} -+ echo m88k-dg-dgux"$UNAME_RELEASE" - else -- echo m88k-dg-dguxbcs${UNAME_RELEASE} -+ echo m88k-dg-dguxbcs"$UNAME_RELEASE" - fi - else -- echo i586-dg-dgux${UNAME_RELEASE} -+ echo i586-dg-dgux"$UNAME_RELEASE" - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) -@@ -530,7 +563,7 @@ EOF - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) -- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` -+ echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id -@@ -542,14 +575,14 @@ EOF - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else -- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} -+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" - fi -- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} -+ echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #include - - main() -@@ -560,7 +593,7 @@ EOF - exit(0); - } - EOF -- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` -+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` - then - echo "$SYSTEM_NAME" - else -@@ -574,26 +607,27 @@ EOF - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` -- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then -+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi -- if [ -x /usr/bin/oslevel ] ; then -- IBM_REV=`/usr/bin/oslevel` -+ if [ -x /usr/bin/lslpp ] ; then -+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | -+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` - else -- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} -+ IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" - fi -- echo ${IBM_ARCH}-ibm-aix${IBM_REV} -+ echo "$IBM_ARCH"-ibm-aix"$IBM_REV" - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; -- ibmrt:4.4BSD:*|romp-ibm:BSD:*) -+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and -- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to -+ echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx -@@ -608,28 +642,28 @@ EOF - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) -- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` -- case "${UNAME_MACHINE}" in -- 9000/31? ) HP_ARCH=m68000 ;; -- 9000/[34]?? ) HP_ARCH=m68k ;; -+ HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` -+ case "$UNAME_MACHINE" in -+ 9000/31?) HP_ARCH=m68000 ;; -+ 9000/[34]??) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` -- case "${sc_cpu_version}" in -- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 -- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 -+ case "$sc_cpu_version" in -+ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 -+ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 -- case "${sc_kernel_bits}" in -- 32) HP_ARCH="hppa2.0n" ;; -- 64) HP_ARCH="hppa2.0w" ;; -- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 -+ case "$sc_kernel_bits" in -+ 32) HP_ARCH=hppa2.0n ;; -+ 64) HP_ARCH=hppa2.0w ;; -+ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 - esac ;; - esac - fi -- if [ "${HP_ARCH}" = "" ]; then -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ if [ "$HP_ARCH" = "" ]; then -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - - #define _HPUX_SOURCE - #include -@@ -662,13 +696,13 @@ EOF - exit (0); - } - EOF -- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` -+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac -- if [ ${HP_ARCH} = "hppa2.0w" ] -+ if [ "$HP_ARCH" = hppa2.0w ] - then -- eval $set_cc_for_build -+ set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler -@@ -679,23 +713,23 @@ EOF - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - -- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | -+ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then -- HP_ARCH="hppa2.0w" -+ HP_ARCH=hppa2.0w - else -- HP_ARCH="hppa64" -+ HP_ARCH=hppa64 - fi - fi -- echo ${HP_ARCH}-hp-hpux${HPUX_REV} -+ echo "$HP_ARCH"-hp-hpux"$HPUX_REV" - exit ;; - ia64:HP-UX:*:*) -- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` -- echo ia64-hp-hpux${HPUX_REV} -+ HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` -+ echo ia64-hp-hpux"$HPUX_REV" - exit ;; - 3050*:HI-UX:*:*) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #include - int - main () -@@ -720,11 +754,11 @@ EOF - exit (0); - } - EOF -- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && -+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; -- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) -+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) -@@ -733,7 +767,7 @@ EOF - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; -- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) -+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) -@@ -741,9 +775,9 @@ EOF - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then -- echo ${UNAME_MACHINE}-unknown-osf1mk -+ echo "$UNAME_MACHINE"-unknown-osf1mk - else -- echo ${UNAME_MACHINE}-unknown-osf1 -+ echo "$UNAME_MACHINE"-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) -@@ -768,127 +802,120 @@ EOF - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) -- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -+ echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) -- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ -+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) -- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -+ echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) -- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -+ echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) -- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -+ echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) -- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -+ echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) -- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` -+ FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` -+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` -+ FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) -- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` -+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` -+ FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) -- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" - exit ;; - sparc*:BSD/OS:*:*) -- echo sparc-unknown-bsdi${UNAME_RELEASE} -+ echo sparc-unknown-bsdi"$UNAME_RELEASE" - exit ;; - *:BSD/OS:*:*) -- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" -+ exit ;; -+ arm:FreeBSD:*:*) -+ UNAME_PROCESSOR=`uname -p` -+ set_cc_for_build -+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_PCS_VFP -+ then -+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi -+ else -+ echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf -+ fi - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` -- case ${UNAME_PROCESSOR} in -+ case "$UNAME_PROCESSOR" in - amd64) -- echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; -- *) -- echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; -+ UNAME_PROCESSOR=x86_64 ;; -+ i386) -+ UNAME_PROCESSOR=i586 ;; - esac -+ echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" - exit ;; - i*:CYGWIN*:*) -- echo ${UNAME_MACHINE}-pc-cygwin -+ echo "$UNAME_MACHINE"-pc-cygwin - exit ;; - *:MINGW64*:*) -- echo ${UNAME_MACHINE}-pc-mingw64 -+ echo "$UNAME_MACHINE"-pc-mingw64 - exit ;; - *:MINGW*:*) -- echo ${UNAME_MACHINE}-pc-mingw32 -- exit ;; -- i*:MSYS*:*) -- echo ${UNAME_MACHINE}-pc-msys -+ echo "$UNAME_MACHINE"-pc-mingw32 - exit ;; -- i*:windows32*:*) -- # uname -m includes "-pc" on this system. -- echo ${UNAME_MACHINE}-mingw32 -+ *:MSYS*:*) -+ echo "$UNAME_MACHINE"-pc-msys - exit ;; - i*:PW*:*) -- echo ${UNAME_MACHINE}-pc-pw32 -+ echo "$UNAME_MACHINE"-pc-pw32 - exit ;; - *:Interix*:*) -- case ${UNAME_MACHINE} in -+ case "$UNAME_MACHINE" in - x86) -- echo i586-pc-interix${UNAME_RELEASE} -+ echo i586-pc-interix"$UNAME_RELEASE" - exit ;; - authenticamd | genuineintel | EM64T) -- echo x86_64-unknown-interix${UNAME_RELEASE} -+ echo x86_64-unknown-interix"$UNAME_RELEASE" - exit ;; - IA64) -- echo ia64-unknown-interix${UNAME_RELEASE} -+ echo ia64-unknown-interix"$UNAME_RELEASE" - exit ;; - esac ;; -- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) -- echo i${UNAME_MACHINE}-pc-mks -- exit ;; -- 8664:Windows_NT:*) -- echo x86_64-pc-mks -- exit ;; -- i*:Windows_NT*:* | Pentium*:Windows_NT*:*) -- # How do we know it's Interix rather than the generic POSIX subsystem? -- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we -- # UNAME_MACHINE based on the output of uname instead of i386? -- echo i586-pc-interix -- exit ;; - i*:UWIN*:*) -- echo ${UNAME_MACHINE}-pc-uwin -+ echo "$UNAME_MACHINE"-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) -- echo x86_64-unknown-cygwin -- exit ;; -- p*:CYGWIN*:*) -- echo powerpcle-unknown-cygwin -+ echo x86_64-pc-cygwin - exit ;; - prep*:SunOS:5.*:*) -- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -+ echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; - *:GNU:*:*) - # the GNU system -- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` -+ echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland -- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} -+ echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" - exit ;; -- i*86:Minix:*:*) -- echo ${UNAME_MACHINE}-pc-minix -+ *:Minix:*:*) -+ echo "$UNAME_MACHINE"-unknown-minix - exit ;; - aarch64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in -@@ -901,58 +928,64 @@ EOF - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 -- if test "$?" = 0 ; then LIBC="gnulibc1" ; fi -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - arm*:Linux:*:*) -- eval $set_cc_for_build -+ set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi - else -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - cris:Linux:*:*) -- echo ${UNAME_MACHINE}-axis-linux-${LIBC} -+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; - crisv32:Linux:*:*) -- echo ${UNAME_MACHINE}-axis-linux-${LIBC} -+ echo "$UNAME_MACHINE"-axis-linux-"$LIBC" -+ exit ;; -+ e2k:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - frv:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - hexagon:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - i*86:Linux:*:*) -- echo ${UNAME_MACHINE}-pc-linux-${LIBC} -+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; - ia64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ k1om:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - m32r*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - m68*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) -- eval $set_cc_for_build -- sed 's/^ //' << EOF >$dummy.c -+ set_cc_for_build -+ sed 's/^ //' << EOF > "$dummy.c" - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el -@@ -966,64 +999,70 @@ EOF - #endif - #endif - EOF -- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` -- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } -+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" -+ test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } - ;; -- or1k:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ mips64el:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" -+ exit ;; -+ openrisc*:Linux:*:*) -+ echo or1k-unknown-linux-"$LIBC" - exit ;; -- or32:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ or32:Linux:*:* | or1k*:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - padre:Linux:*:*) -- echo sparc-unknown-linux-${LIBC} -+ echo sparc-unknown-linux-"$LIBC" - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) -- echo hppa64-unknown-linux-${LIBC} -+ echo hppa64-unknown-linux-"$LIBC" - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in -- PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; -- PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; -- *) echo hppa-unknown-linux-${LIBC} ;; -+ PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; -+ PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; -+ *) echo hppa-unknown-linux-"$LIBC" ;; - esac - exit ;; - ppc64:Linux:*:*) -- echo powerpc64-unknown-linux-${LIBC} -+ echo powerpc64-unknown-linux-"$LIBC" - exit ;; - ppc:Linux:*:*) -- echo powerpc-unknown-linux-${LIBC} -+ echo powerpc-unknown-linux-"$LIBC" - exit ;; - ppc64le:Linux:*:*) -- echo powerpc64le-unknown-linux-${LIBC} -+ echo powerpc64le-unknown-linux-"$LIBC" - exit ;; - ppcle:Linux:*:*) -- echo powerpcle-unknown-linux-${LIBC} -+ echo powerpcle-unknown-linux-"$LIBC" -+ exit ;; -+ riscv32:Linux:*:* | riscv64:Linux:*:*) -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) -- echo ${UNAME_MACHINE}-ibm-linux-${LIBC} -+ echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" - exit ;; - sh64*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - sh*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - tile*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - vax:Linux:*:*) -- echo ${UNAME_MACHINE}-dec-linux-${LIBC} -+ echo "$UNAME_MACHINE"-dec-linux-"$LIBC" - exit ;; - x86_64:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; - xtensa*:Linux:*:*) -- echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. -@@ -1037,34 +1076,34 @@ EOF - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. -- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} -+ echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. -- echo ${UNAME_MACHINE}-pc-os2-emx -+ echo "$UNAME_MACHINE"-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) -- echo ${UNAME_MACHINE}-unknown-stop -+ echo "$UNAME_MACHINE"-unknown-stop - exit ;; - i*86:atheos:*:*) -- echo ${UNAME_MACHINE}-unknown-atheos -+ echo "$UNAME_MACHINE"-unknown-atheos - exit ;; - i*86:syllable:*:*) -- echo ${UNAME_MACHINE}-pc-syllable -+ echo "$UNAME_MACHINE"-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) -- echo i386-unknown-lynxos${UNAME_RELEASE} -+ echo i386-unknown-lynxos"$UNAME_RELEASE" - exit ;; - i*86:*DOS:*:*) -- echo ${UNAME_MACHINE}-pc-msdosdjgpp -+ echo "$UNAME_MACHINE"-pc-msdosdjgpp - exit ;; -- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) -- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` -+ i*86:*:4.*:*) -+ UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then -- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} -+ echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" - else -- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} -+ echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" - fi - exit ;; - i*86:*:5:[678]*) -@@ -1074,12 +1113,12 @@ EOF - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac -- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} -+ echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 -@@ -1089,9 +1128,9 @@ EOF - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 -- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL -+ echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" - else -- echo ${UNAME_MACHINE}-pc-sysv32 -+ echo "$UNAME_MACHINE"-pc-sysv32 - fi - exit ;; - pc:*:*:*) -@@ -1099,7 +1138,7 @@ EOF - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub -- # prints for the "djgpp" host, or else GDB configury will decide that -+ # prints for the "djgpp" host, or else GDB configure will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; -@@ -1111,9 +1150,9 @@ EOF - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then -- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 -+ echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. -- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 -+ echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) -@@ -1133,9 +1172,9 @@ EOF - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -- && { echo i486-ncr-sysv4.3${OS_REL}; exit; } -+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ -- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; -+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; -@@ -1144,28 +1183,28 @@ EOF - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -- && { echo i486-ncr-sysv4.3${OS_REL}; exit; } -+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ -- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } -+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ -- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; -+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) -- echo m68k-unknown-lynxos${UNAME_RELEASE} -+ echo m68k-unknown-lynxos"$UNAME_RELEASE" - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) -- echo sparc-unknown-lynxos${UNAME_RELEASE} -+ echo sparc-unknown-lynxos"$UNAME_RELEASE" - exit ;; - rs6000:LynxOS:2.*:*) -- echo rs6000-unknown-lynxos${UNAME_RELEASE} -+ echo rs6000-unknown-lynxos"$UNAME_RELEASE" - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) -- echo powerpc-unknown-lynxos${UNAME_RELEASE} -+ echo powerpc-unknown-lynxos"$UNAME_RELEASE" - exit ;; - SM[BE]S:UNIX_SV:*:*) -- echo mips-dde-sysv${UNAME_RELEASE} -+ echo mips-dde-sysv"$UNAME_RELEASE" - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 -@@ -1176,7 +1215,7 @@ EOF - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` -- echo ${UNAME_MACHINE}-sni-sysv4 -+ echo "$UNAME_MACHINE"-sni-sysv4 - else - echo ns32k-sni-sysv - fi -@@ -1196,23 +1235,23 @@ EOF - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. -- echo ${UNAME_MACHINE}-stratus-vos -+ echo "$UNAME_MACHINE"-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) -- echo m68k-apple-aux${UNAME_RELEASE} -+ echo m68k-apple-aux"$UNAME_RELEASE" - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then -- echo mips-nec-sysv${UNAME_RELEASE} -+ echo mips-nec-sysv"$UNAME_RELEASE" - else -- echo mips-unknown-sysv${UNAME_RELEASE} -+ echo mips-unknown-sysv"$UNAME_RELEASE" - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. -@@ -1231,67 +1270,93 @@ EOF - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) -- echo sx4-nec-superux${UNAME_RELEASE} -+ echo sx4-nec-superux"$UNAME_RELEASE" - exit ;; - SX-5:SUPER-UX:*:*) -- echo sx5-nec-superux${UNAME_RELEASE} -+ echo sx5-nec-superux"$UNAME_RELEASE" - exit ;; - SX-6:SUPER-UX:*:*) -- echo sx6-nec-superux${UNAME_RELEASE} -+ echo sx6-nec-superux"$UNAME_RELEASE" - exit ;; - SX-7:SUPER-UX:*:*) -- echo sx7-nec-superux${UNAME_RELEASE} -+ echo sx7-nec-superux"$UNAME_RELEASE" - exit ;; - SX-8:SUPER-UX:*:*) -- echo sx8-nec-superux${UNAME_RELEASE} -+ echo sx8-nec-superux"$UNAME_RELEASE" - exit ;; - SX-8R:SUPER-UX:*:*) -- echo sx8r-nec-superux${UNAME_RELEASE} -+ echo sx8r-nec-superux"$UNAME_RELEASE" -+ exit ;; -+ SX-ACE:SUPER-UX:*:*) -+ echo sxace-nec-superux"$UNAME_RELEASE" - exit ;; - Power*:Rhapsody:*:*) -- echo powerpc-apple-rhapsody${UNAME_RELEASE} -+ echo powerpc-apple-rhapsody"$UNAME_RELEASE" - exit ;; - *:Rhapsody:*:*) -- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown -- eval $set_cc_for_build -+ set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi -- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then -- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ -- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ -- grep IS_64BIT_ARCH >/dev/null -- then -- case $UNAME_PROCESSOR in -- i386) UNAME_PROCESSOR=x86_64 ;; -- powerpc) UNAME_PROCESSOR=powerpc64 ;; -- esac -+ if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then -+ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then -+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ grep IS_64BIT_ARCH >/dev/null -+ then -+ case $UNAME_PROCESSOR in -+ i386) UNAME_PROCESSOR=x86_64 ;; -+ powerpc) UNAME_PROCESSOR=powerpc64 ;; -+ esac -+ fi -+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc -+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ -+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ -+ grep IS_PPC >/dev/null -+ then -+ UNAME_PROCESSOR=powerpc -+ fi - fi -+ elif test "$UNAME_PROCESSOR" = i386 ; then -+ # Avoid executing cc on OS X 10.9, as it ships with a stub -+ # that puts up a graphical alert prompting to install -+ # developer tools. Any system running Mac OS X 10.7 or -+ # later (Darwin 11 and later) is required to have a 64-bit -+ # processor. This is not true of the ARM version of Darwin -+ # that Apple uses in portable devices. -+ UNAME_PROCESSOR=x86_64 - fi -- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} -+ echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` -- if test "$UNAME_PROCESSOR" = "x86"; then -+ if test "$UNAME_PROCESSOR" = x86; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi -- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} -+ echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; -- NEO-?:NONSTOP_KERNEL:*:*) -- echo neo-tandem-nsk${UNAME_RELEASE} -+ NEO-*:NONSTOP_KERNEL:*:*) -+ echo neo-tandem-nsk"$UNAME_RELEASE" - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) -- echo nse-tandem-nsk${UNAME_RELEASE} -+ echo nse-tandem-nsk"$UNAME_RELEASE" -+ exit ;; -+ NSR-*:NONSTOP_KERNEL:*:*) -+ echo nsr-tandem-nsk"$UNAME_RELEASE" -+ exit ;; -+ NSV-*:NONSTOP_KERNEL:*:*) -+ echo nsv-tandem-nsk"$UNAME_RELEASE" - exit ;; -- NSR-?:NONSTOP_KERNEL:*:*) -- echo nsr-tandem-nsk${UNAME_RELEASE} -+ NSX-*:NONSTOP_KERNEL:*:*) -+ echo nsx-tandem-nsk"$UNAME_RELEASE" - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux -@@ -1300,18 +1365,19 @@ EOF - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) -- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} -+ echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. -- if test "$cputype" = "386"; then -+ # shellcheck disable=SC2154 -+ if test "$cputype" = 386; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi -- echo ${UNAME_MACHINE}-unknown-plan9 -+ echo "$UNAME_MACHINE"-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 -@@ -1332,14 +1398,14 @@ EOF - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) -- echo mips-sei-seiux${UNAME_RELEASE} -+ echo mips-sei-seiux"$UNAME_RELEASE" - exit ;; - *:DragonFly:*:*) -- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` -+ echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` -- case "${UNAME_MACHINE}" in -+ case "$UNAME_MACHINE" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; -@@ -1348,182 +1414,51 @@ EOF - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) -- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' -+ echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" - exit ;; - i*86:rdos:*:*) -- echo ${UNAME_MACHINE}-pc-rdos -+ echo "$UNAME_MACHINE"-pc-rdos - exit ;; - i*86:AROS:*:*) -- echo ${UNAME_MACHINE}-pc-aros -+ echo "$UNAME_MACHINE"-pc-aros - exit ;; - x86_64:VMkernel:*:*) -- echo ${UNAME_MACHINE}-unknown-esx -+ echo "$UNAME_MACHINE"-unknown-esx -+ exit ;; -+ amd64:Isilon\ OneFS:*:*) -+ echo x86_64-unknown-onefs -+ exit ;; -+ *:Unleashed:*:*) -+ echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" - exit ;; - esac - --eval $set_cc_for_build --cat >$dummy.c < --# include --#endif --main () --{ --#if defined (sony) --#if defined (MIPSEB) -- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, -- I don't know.... */ -- printf ("mips-sony-bsd\n"); exit (0); --#else --#include -- printf ("m68k-sony-newsos%s\n", --#ifdef NEWSOS4 -- "4" --#else -- "" --#endif -- ); exit (0); --#endif --#endif -- --#if defined (__arm) && defined (__acorn) && defined (__unix) -- printf ("arm-acorn-riscix\n"); exit (0); --#endif -- --#if defined (hp300) && !defined (hpux) -- printf ("m68k-hp-bsd\n"); exit (0); --#endif -- --#if defined (NeXT) --#if !defined (__ARCHITECTURE__) --#define __ARCHITECTURE__ "m68k" --#endif -- int version; -- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; -- if (version < 4) -- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); -- else -- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); -- exit (0); --#endif -- --#if defined (MULTIMAX) || defined (n16) --#if defined (UMAXV) -- printf ("ns32k-encore-sysv\n"); exit (0); --#else --#if defined (CMU) -- printf ("ns32k-encore-mach\n"); exit (0); --#else -- printf ("ns32k-encore-bsd\n"); exit (0); --#endif --#endif --#endif -- --#if defined (__386BSD__) -- printf ("i386-pc-bsd\n"); exit (0); --#endif -- --#if defined (sequent) --#if defined (i386) -- printf ("i386-sequent-dynix\n"); exit (0); --#endif --#if defined (ns32000) -- printf ("ns32k-sequent-dynix\n"); exit (0); --#endif --#endif -- --#if defined (_SEQUENT_) -- struct utsname un; -- -- uname(&un); -- -- if (strncmp(un.version, "V2", 2) == 0) { -- printf ("i386-sequent-ptx2\n"); exit (0); -- } -- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ -- printf ("i386-sequent-ptx1\n"); exit (0); -- } -- printf ("i386-sequent-ptx\n"); exit (0); -- --#endif -- --#if defined (vax) --# if !defined (ultrix) --# include --# if defined (BSD) --# if BSD == 43 -- printf ("vax-dec-bsd4.3\n"); exit (0); --# else --# if BSD == 199006 -- printf ("vax-dec-bsd4.3reno\n"); exit (0); --# else -- printf ("vax-dec-bsd\n"); exit (0); --# endif --# endif --# else -- printf ("vax-dec-bsd\n"); exit (0); --# endif --# else -- printf ("vax-dec-ultrix\n"); exit (0); --# endif --#endif -+echo "$0: unable to guess system type" >&2 - --#if defined (alliant) && defined (i860) -- printf ("i860-alliant-bsd\n"); exit (0); --#endif -+case "$UNAME_MACHINE:$UNAME_SYSTEM" in -+ mips:Linux | mips64:Linux) -+ # If we got here on MIPS GNU/Linux, output extra information. -+ cat >&2 </dev/null && SYSTEM_NAME=`$dummy` && -- { echo "$SYSTEM_NAME"; exit; } -- --# Apollos put the system type in the environment. -- --test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } -- --# Convex versions that predate uname can use getsysinfo(1) -- --if [ -x /usr/convex/getsysinfo ] --then -- case `getsysinfo -f cpu_type` in -- c1*) -- echo c1-convex-bsd -- exit ;; -- c2*) -- if getsysinfo -f scalar_acc -- then echo c32-convex-bsd -- else echo c2-convex-bsd -- fi -- exit ;; -- c34*) -- echo c34-convex-bsd -- exit ;; -- c38*) -- echo c38-convex-bsd -- exit ;; -- c4*) -- echo c4-convex-bsd -- exit ;; -- esac --fi -+ ;; -+esac - - cat >&2 < in order to provide the needed --information to handle your system. -+If $0 has already been updated, send the following data and any -+information you think might be pertinent to config-patches@gnu.org to -+provide the necessary information to handle your system. - - config.guess timestamp = $timestamp - -@@ -1542,16 +1477,16 @@ hostinfo = `(hostinfo) 2>/dev/null` - /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` - /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - --UNAME_MACHINE = ${UNAME_MACHINE} --UNAME_RELEASE = ${UNAME_RELEASE} --UNAME_SYSTEM = ${UNAME_SYSTEM} --UNAME_VERSION = ${UNAME_VERSION} -+UNAME_MACHINE = "$UNAME_MACHINE" -+UNAME_RELEASE = "$UNAME_RELEASE" -+UNAME_SYSTEM = "$UNAME_SYSTEM" -+UNAME_VERSION = "$UNAME_VERSION" - EOF - - exit 1 - - # Local variables: --# eval: (add-hook 'write-file-hooks 'time-stamp) -+# eval: (add-hook 'before-save-hook 'time-stamp) - # time-stamp-start: "timestamp='" - # time-stamp-format: "%:y-%02m-%02d" - # time-stamp-end: "'" -diff --git a/config/gnu/config.sub b/config/gnu/config.sub -index 8b612ab89..3b4c7624b 100755 ---- a/config/gnu/config.sub -+++ b/config/gnu/config.sub -@@ -1,8 +1,8 @@ - #! /bin/sh - # Configuration validation subroutine script. --# Copyright 1992-2013 Free Software Foundation, Inc. -+# Copyright 1992-2019 Free Software Foundation, Inc. - --timestamp='2013-04-24' -+timestamp='2019-01-05' - - # This file is free software; you can redistribute it and/or modify it - # under the terms of the GNU General Public License as published by -@@ -15,7 +15,7 @@ timestamp='2013-04-24' - # General Public License for more details. - # - # You should have received a copy of the GNU General Public License --# along with this program; if not, see . -+# along with this program; if not, see . - # - # As a special exception to the GNU General Public License, if you - # distribute this file as part of a program that contains a -@@ -25,7 +25,7 @@ timestamp='2013-04-24' - # of the GNU General Public License, version 3 ("GPLv3"). - - --# Please send patches with a ChangeLog entry to config-patches@gnu.org. -+# Please send patches to . - # - # Configuration subroutine to validate and canonicalize a configuration type. - # Supply the specified configuration type as an argument. -@@ -33,7 +33,7 @@ timestamp='2013-04-24' - # Otherwise, we print the canonical config type on stdout and succeed. - - # You can get the latest version of this script from: --# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD -+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub - - # This file is supposed to be the same for all GNU packages - # and recognize all the CPU types, system types and aliases -@@ -53,12 +53,11 @@ timestamp='2013-04-24' - me=`echo "$0" | sed -e 's,.*/,,'` - - usage="\ --Usage: $0 [OPTION] CPU-MFR-OPSYS -- $0 [OPTION] ALIAS -+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS - - Canonicalize a configuration name. - --Operation modes: -+Options: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit -@@ -68,7 +67,7 @@ Report bugs and patches to ." - version="\ - GNU config.sub ($timestamp) - --Copyright 1992-2013 Free Software Foundation, Inc. -+Copyright 1992-2019 Free Software Foundation, Inc. - - This is free software; see the source for copying conditions. There is NO - warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -@@ -90,12 +89,12 @@ while test $# -gt 0 ; do - - ) # Use stdin as input. - break ;; - -* ) -- echo "$me: invalid option $1$help" -+ echo "$me: invalid option $1$help" >&2 - exit 1 ;; - - *local*) - # First pass through any local machine types. -- echo $1 -+ echo "$1" - exit ;; - - * ) -@@ -111,1209 +110,1164 @@ case $# in - exit 1;; - esac - --# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). --# Here we must recognize all the valid KERNEL-OS combinations. --maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` --case $maybe_os in -- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ -- linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ -- knetbsd*-gnu* | netbsd*-gnu* | \ -- kopensolaris*-gnu* | \ -- storm-chaos* | os2-emx* | rtmk-nova*) -- os=-$maybe_os -- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` -- ;; -- android-linux) -- os=-linux-android -- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown -- ;; -- *) -- basic_machine=`echo $1 | sed 's/-[^-]*$//'` -- if [ $basic_machine != $1 ] -- then os=`echo $1 | sed 's/.*-/-/'` -- else os=; fi -- ;; --esac -+# Split fields of configuration type -+# shellcheck disable=SC2162 -+IFS="-" read field1 field2 field3 field4 <&2 -+ exit 1 - ;; -- -ptx*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` -+ *-*-*-*) -+ basic_machine=$field1-$field2 -+ os=$field3-$field4 - ;; -- -windowsnt*) -- os=`echo $os | sed -e 's/windowsnt/winnt/'` -+ *-*-*) -+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two -+ # parts -+ maybe_os=$field2-$field3 -+ case $maybe_os in -+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ -+ | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ -+ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ -+ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ -+ | storm-chaos* | os2-emx* | rtmk-nova*) -+ basic_machine=$field1 -+ os=$maybe_os -+ ;; -+ android-linux) -+ basic_machine=$field1-unknown -+ os=linux-android -+ ;; -+ *) -+ basic_machine=$field1-$field2 -+ os=$field3 -+ ;; -+ esac - ;; -- -psos*) -- os=-psos -+ *-*) -+ # A lone config we happen to match not fitting any pattern -+ case $field1-$field2 in -+ decstation-3100) -+ basic_machine=mips-dec -+ os= -+ ;; -+ *-*) -+ # Second component is usually, but not always the OS -+ case $field2 in -+ # Prevent following clause from handling this valid os -+ sun*os*) -+ basic_machine=$field1 -+ os=$field2 -+ ;; -+ # Manufacturers -+ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ -+ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ -+ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ -+ | convergent* | ncr* | news | 32* | 3600* | 3100* \ -+ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ -+ | ultra | tti* | harris | dolphin | highlevel | gould \ -+ | cbm | ns | masscomp | apple | axis | knuth | cray \ -+ | microblaze* | sim | cisco \ -+ | oki | wec | wrs | winbond) -+ basic_machine=$field1-$field2 -+ os= -+ ;; -+ *) -+ basic_machine=$field1 -+ os=$field2 -+ ;; -+ esac -+ ;; -+ esac - ;; -- -mint | -mint[0-9]*) -- basic_machine=m68k-atari -- os=-mint -+ *) -+ # Convert single-component short-hands not valid as part of -+ # multi-component configurations. -+ case $field1 in -+ 386bsd) -+ basic_machine=i386-pc -+ os=bsd -+ ;; -+ a29khif) -+ basic_machine=a29k-amd -+ os=udi -+ ;; -+ adobe68k) -+ basic_machine=m68010-adobe -+ os=scout -+ ;; -+ alliant) -+ basic_machine=fx80-alliant -+ os= -+ ;; -+ altos | altos3068) -+ basic_machine=m68k-altos -+ os= -+ ;; -+ am29k) -+ basic_machine=a29k-none -+ os=bsd -+ ;; -+ amdahl) -+ basic_machine=580-amdahl -+ os=sysv -+ ;; -+ amiga) -+ basic_machine=m68k-unknown -+ os= -+ ;; -+ amigaos | amigados) -+ basic_machine=m68k-unknown -+ os=amigaos -+ ;; -+ amigaunix | amix) -+ basic_machine=m68k-unknown -+ os=sysv4 -+ ;; -+ apollo68) -+ basic_machine=m68k-apollo -+ os=sysv -+ ;; -+ apollo68bsd) -+ basic_machine=m68k-apollo -+ os=bsd -+ ;; -+ aros) -+ basic_machine=i386-pc -+ os=aros -+ ;; -+ aux) -+ basic_machine=m68k-apple -+ os=aux -+ ;; -+ balance) -+ basic_machine=ns32k-sequent -+ os=dynix -+ ;; -+ blackfin) -+ basic_machine=bfin-unknown -+ os=linux -+ ;; -+ cegcc) -+ basic_machine=arm-unknown -+ os=cegcc -+ ;; -+ convex-c1) -+ basic_machine=c1-convex -+ os=bsd -+ ;; -+ convex-c2) -+ basic_machine=c2-convex -+ os=bsd -+ ;; -+ convex-c32) -+ basic_machine=c32-convex -+ os=bsd -+ ;; -+ convex-c34) -+ basic_machine=c34-convex -+ os=bsd -+ ;; -+ convex-c38) -+ basic_machine=c38-convex -+ os=bsd -+ ;; -+ cray) -+ basic_machine=j90-cray -+ os=unicos -+ ;; -+ crds | unos) -+ basic_machine=m68k-crds -+ os= -+ ;; -+ da30) -+ basic_machine=m68k-da30 -+ os= -+ ;; -+ decstation | pmax | pmin | dec3100 | decstatn) -+ basic_machine=mips-dec -+ os= -+ ;; -+ delta88) -+ basic_machine=m88k-motorola -+ os=sysv3 -+ ;; -+ dicos) -+ basic_machine=i686-pc -+ os=dicos -+ ;; -+ djgpp) -+ basic_machine=i586-pc -+ os=msdosdjgpp -+ ;; -+ ebmon29k) -+ basic_machine=a29k-amd -+ os=ebmon -+ ;; -+ es1800 | OSE68k | ose68k | ose | OSE) -+ basic_machine=m68k-ericsson -+ os=ose -+ ;; -+ gmicro) -+ basic_machine=tron-gmicro -+ os=sysv -+ ;; -+ go32) -+ basic_machine=i386-pc -+ os=go32 -+ ;; -+ h8300hms) -+ basic_machine=h8300-hitachi -+ os=hms -+ ;; -+ h8300xray) -+ basic_machine=h8300-hitachi -+ os=xray -+ ;; -+ h8500hms) -+ basic_machine=h8500-hitachi -+ os=hms -+ ;; -+ harris) -+ basic_machine=m88k-harris -+ os=sysv3 -+ ;; -+ hp300) -+ basic_machine=m68k-hp -+ ;; -+ hp300bsd) -+ basic_machine=m68k-hp -+ os=bsd -+ ;; -+ hp300hpux) -+ basic_machine=m68k-hp -+ os=hpux -+ ;; -+ hppaosf) -+ basic_machine=hppa1.1-hp -+ os=osf -+ ;; -+ hppro) -+ basic_machine=hppa1.1-hp -+ os=proelf -+ ;; -+ i386mach) -+ basic_machine=i386-mach -+ os=mach -+ ;; -+ vsta) -+ basic_machine=i386-pc -+ os=vsta -+ ;; -+ isi68 | isi) -+ basic_machine=m68k-isi -+ os=sysv -+ ;; -+ m68knommu) -+ basic_machine=m68k-unknown -+ os=linux -+ ;; -+ magnum | m3230) -+ basic_machine=mips-mips -+ os=sysv -+ ;; -+ merlin) -+ basic_machine=ns32k-utek -+ os=sysv -+ ;; -+ mingw64) -+ basic_machine=x86_64-pc -+ os=mingw64 -+ ;; -+ mingw32) -+ basic_machine=i686-pc -+ os=mingw32 -+ ;; -+ mingw32ce) -+ basic_machine=arm-unknown -+ os=mingw32ce -+ ;; -+ monitor) -+ basic_machine=m68k-rom68k -+ os=coff -+ ;; -+ morphos) -+ basic_machine=powerpc-unknown -+ os=morphos -+ ;; -+ moxiebox) -+ basic_machine=moxie-unknown -+ os=moxiebox -+ ;; -+ msdos) -+ basic_machine=i386-pc -+ os=msdos -+ ;; -+ msys) -+ basic_machine=i686-pc -+ os=msys -+ ;; -+ mvs) -+ basic_machine=i370-ibm -+ os=mvs -+ ;; -+ nacl) -+ basic_machine=le32-unknown -+ os=nacl -+ ;; -+ ncr3000) -+ basic_machine=i486-ncr -+ os=sysv4 -+ ;; -+ netbsd386) -+ basic_machine=i386-pc -+ os=netbsd -+ ;; -+ netwinder) -+ basic_machine=armv4l-rebel -+ os=linux -+ ;; -+ news | news700 | news800 | news900) -+ basic_machine=m68k-sony -+ os=newsos -+ ;; -+ news1000) -+ basic_machine=m68030-sony -+ os=newsos -+ ;; -+ necv70) -+ basic_machine=v70-nec -+ os=sysv -+ ;; -+ nh3000) -+ basic_machine=m68k-harris -+ os=cxux -+ ;; -+ nh[45]000) -+ basic_machine=m88k-harris -+ os=cxux -+ ;; -+ nindy960) -+ basic_machine=i960-intel -+ os=nindy -+ ;; -+ mon960) -+ basic_machine=i960-intel -+ os=mon960 -+ ;; -+ nonstopux) -+ basic_machine=mips-compaq -+ os=nonstopux -+ ;; -+ os400) -+ basic_machine=powerpc-ibm -+ os=os400 -+ ;; -+ OSE68000 | ose68000) -+ basic_machine=m68000-ericsson -+ os=ose -+ ;; -+ os68k) -+ basic_machine=m68k-none -+ os=os68k -+ ;; -+ paragon) -+ basic_machine=i860-intel -+ os=osf -+ ;; -+ parisc) -+ basic_machine=hppa-unknown -+ os=linux -+ ;; -+ pw32) -+ basic_machine=i586-unknown -+ os=pw32 -+ ;; -+ rdos | rdos64) -+ basic_machine=x86_64-pc -+ os=rdos -+ ;; -+ rdos32) -+ basic_machine=i386-pc -+ os=rdos -+ ;; -+ rom68k) -+ basic_machine=m68k-rom68k -+ os=coff -+ ;; -+ sa29200) -+ basic_machine=a29k-amd -+ os=udi -+ ;; -+ sei) -+ basic_machine=mips-sei -+ os=seiux -+ ;; -+ sequent) -+ basic_machine=i386-sequent -+ os= -+ ;; -+ sps7) -+ basic_machine=m68k-bull -+ os=sysv2 -+ ;; -+ st2000) -+ basic_machine=m68k-tandem -+ os= -+ ;; -+ stratus) -+ basic_machine=i860-stratus -+ os=sysv4 -+ ;; -+ sun2) -+ basic_machine=m68000-sun -+ os= -+ ;; -+ sun2os3) -+ basic_machine=m68000-sun -+ os=sunos3 -+ ;; -+ sun2os4) -+ basic_machine=m68000-sun -+ os=sunos4 -+ ;; -+ sun3) -+ basic_machine=m68k-sun -+ os= -+ ;; -+ sun3os3) -+ basic_machine=m68k-sun -+ os=sunos3 -+ ;; -+ sun3os4) -+ basic_machine=m68k-sun -+ os=sunos4 -+ ;; -+ sun4) -+ basic_machine=sparc-sun -+ os= -+ ;; -+ sun4os3) -+ basic_machine=sparc-sun -+ os=sunos3 -+ ;; -+ sun4os4) -+ basic_machine=sparc-sun -+ os=sunos4 -+ ;; -+ sun4sol2) -+ basic_machine=sparc-sun -+ os=solaris2 -+ ;; -+ sun386 | sun386i | roadrunner) -+ basic_machine=i386-sun -+ os= -+ ;; -+ sv1) -+ basic_machine=sv1-cray -+ os=unicos -+ ;; -+ symmetry) -+ basic_machine=i386-sequent -+ os=dynix -+ ;; -+ t3e) -+ basic_machine=alphaev5-cray -+ os=unicos -+ ;; -+ t90) -+ basic_machine=t90-cray -+ os=unicos -+ ;; -+ toad1) -+ basic_machine=pdp10-xkl -+ os=tops20 -+ ;; -+ tpf) -+ basic_machine=s390x-ibm -+ os=tpf -+ ;; -+ udi29k) -+ basic_machine=a29k-amd -+ os=udi -+ ;; -+ ultra3) -+ basic_machine=a29k-nyu -+ os=sym1 -+ ;; -+ v810 | necv810) -+ basic_machine=v810-nec -+ os=none -+ ;; -+ vaxv) -+ basic_machine=vax-dec -+ os=sysv -+ ;; -+ vms) -+ basic_machine=vax-dec -+ os=vms -+ ;; -+ vxworks960) -+ basic_machine=i960-wrs -+ os=vxworks -+ ;; -+ vxworks68) -+ basic_machine=m68k-wrs -+ os=vxworks -+ ;; -+ vxworks29k) -+ basic_machine=a29k-wrs -+ os=vxworks -+ ;; -+ xbox) -+ basic_machine=i686-pc -+ os=mingw32 -+ ;; -+ ymp) -+ basic_machine=ymp-cray -+ os=unicos -+ ;; -+ *) -+ basic_machine=$1 -+ os= -+ ;; -+ esac - ;; - esac - --# Decode aliases for certain CPU-COMPANY combinations. -+# Decode 1-component or ad-hoc basic machines - case $basic_machine in -- # Recognize the basic CPU types without company name. -- # Some are omitted here because they have special meanings below. -- 1750a | 580 \ -- | a29k \ -- | aarch64 | aarch64_be \ -- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ -- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ -- | am33_2.0 \ -- | arc | arceb \ -- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ -- | avr | avr32 \ -- | be32 | be64 \ -- | bfin \ -- | c4x | clipper \ -- | d10v | d30v | dlx | dsp16xx \ -- | epiphany \ -- | fido | fr30 | frv \ -- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ -- | hexagon \ -- | i370 | i860 | i960 | ia64 \ -- | ip2k | iq2000 \ -- | le32 | le64 \ -- | lm32 \ -- | m32c | m32r | m32rle | m68000 | m68k | m88k \ -- | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ -- | mips | mipsbe | mipseb | mipsel | mipsle \ -- | mips16 \ -- | mips64 | mips64el \ -- | mips64octeon | mips64octeonel \ -- | mips64orion | mips64orionel \ -- | mips64r5900 | mips64r5900el \ -- | mips64vr | mips64vrel \ -- | mips64vr4100 | mips64vr4100el \ -- | mips64vr4300 | mips64vr4300el \ -- | mips64vr5000 | mips64vr5000el \ -- | mips64vr5900 | mips64vr5900el \ -- | mipsisa32 | mipsisa32el \ -- | mipsisa32r2 | mipsisa32r2el \ -- | mipsisa64 | mipsisa64el \ -- | mipsisa64r2 | mipsisa64r2el \ -- | mipsisa64sb1 | mipsisa64sb1el \ -- | mipsisa64sr71k | mipsisa64sr71kel \ -- | mipsr5900 | mipsr5900el \ -- | mipstx39 | mipstx39el \ -- | mn10200 | mn10300 \ -- | moxie \ -- | mt \ -- | msp430 \ -- | nds32 | nds32le | nds32be \ -- | nios | nios2 | nios2eb | nios2el \ -- | ns16k | ns32k \ -- | open8 \ -- | or1k | or32 \ -- | pdp10 | pdp11 | pj | pjl \ -- | powerpc | powerpc64 | powerpc64le | powerpcle \ -- | pyramid \ -- | rl78 | rx \ -- | score \ -- | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ -- | sh64 | sh64le \ -- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ -- | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ -- | spu \ -- | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ -- | ubicom32 \ -- | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ -- | we32k \ -- | x86 | xc16x | xstormy16 | xtensa \ -- | z8k | z80) -- basic_machine=$basic_machine-unknown -- ;; -- c54x) -- basic_machine=tic54x-unknown -- ;; -- c55x) -- basic_machine=tic55x-unknown -- ;; -- c6x) -- basic_machine=tic6x-unknown -- ;; -- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) -- basic_machine=$basic_machine-unknown -- os=-none -- ;; -- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) -- ;; -- ms1) -- basic_machine=mt-unknown -+ # Here we handle the default manufacturer of certain CPU types. It is in -+ # some cases the only manufacturer, in others, it is the most popular. -+ w89k) -+ cpu=hppa1.1 -+ vendor=winbond - ;; -- -- strongarm | thumb | xscale) -- basic_machine=arm-unknown -+ op50n) -+ cpu=hppa1.1 -+ vendor=oki - ;; -- xgate) -- basic_machine=$basic_machine-unknown -- os=-none -+ op60c) -+ cpu=hppa1.1 -+ vendor=oki - ;; -- xscaleeb) -- basic_machine=armeb-unknown -+ ibm*) -+ cpu=i370 -+ vendor=ibm - ;; -- -- xscaleel) -- basic_machine=armel-unknown -+ orion105) -+ cpu=clipper -+ vendor=highlevel - ;; -- -- # We use `pc' rather than `unknown' -- # because (1) that's what they normally are, and -- # (2) the word "unknown" tends to confuse beginning users. -- i*86 | x86_64) -- basic_machine=$basic_machine-pc -- ;; -- # Object if more than one company name word. -- *-*-*) -- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 -- exit 1 -+ mac | mpw | mac-mpw) -+ cpu=m68k -+ vendor=apple - ;; -- # Recognize the basic CPU types with company name. -- 580-* \ -- | a29k-* \ -- | aarch64-* | aarch64_be-* \ -- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ -- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ -- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ -- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ -- | avr-* | avr32-* \ -- | be32-* | be64-* \ -- | bfin-* | bs2000-* \ -- | c[123]* | c30-* | [cjt]90-* | c4x-* \ -- | clipper-* | craynv-* | cydra-* \ -- | d10v-* | d30v-* | dlx-* \ -- | elxsi-* \ -- | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ -- | h8300-* | h8500-* \ -- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ -- | hexagon-* \ -- | i*86-* | i860-* | i960-* | ia64-* \ -- | ip2k-* | iq2000-* \ -- | le32-* | le64-* \ -- | lm32-* \ -- | m32c-* | m32r-* | m32rle-* \ -- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ -- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ -- | microblaze-* | microblazeel-* \ -- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ -- | mips16-* \ -- | mips64-* | mips64el-* \ -- | mips64octeon-* | mips64octeonel-* \ -- | mips64orion-* | mips64orionel-* \ -- | mips64r5900-* | mips64r5900el-* \ -- | mips64vr-* | mips64vrel-* \ -- | mips64vr4100-* | mips64vr4100el-* \ -- | mips64vr4300-* | mips64vr4300el-* \ -- | mips64vr5000-* | mips64vr5000el-* \ -- | mips64vr5900-* | mips64vr5900el-* \ -- | mipsisa32-* | mipsisa32el-* \ -- | mipsisa32r2-* | mipsisa32r2el-* \ -- | mipsisa64-* | mipsisa64el-* \ -- | mipsisa64r2-* | mipsisa64r2el-* \ -- | mipsisa64sb1-* | mipsisa64sb1el-* \ -- | mipsisa64sr71k-* | mipsisa64sr71kel-* \ -- | mipsr5900-* | mipsr5900el-* \ -- | mipstx39-* | mipstx39el-* \ -- | mmix-* \ -- | mt-* \ -- | msp430-* \ -- | nds32-* | nds32le-* | nds32be-* \ -- | nios-* | nios2-* | nios2eb-* | nios2el-* \ -- | none-* | np1-* | ns16k-* | ns32k-* \ -- | open8-* \ -- | orion-* \ -- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ -- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ -- | pyramid-* \ -- | rl78-* | romp-* | rs6000-* | rx-* \ -- | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ -- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ -- | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ -- | sparclite-* \ -- | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ -- | tahoe-* \ -- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ -- | tile*-* \ -- | tron-* \ -- | ubicom32-* \ -- | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ -- | vax-* \ -- | we32k-* \ -- | x86-* | x86_64-* | xc16x-* | xps100-* \ -- | xstormy16-* | xtensa*-* \ -- | ymp-* \ -- | z8k-* | z80-*) -- ;; -- # Recognize the basic CPU types without company name, with glob match. -- xtensa*) -- basic_machine=$basic_machine-unknown -+ pmac | pmac-mpw) -+ cpu=powerpc -+ vendor=apple - ;; -+ - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. -- 386bsd) -- basic_machine=i386-unknown -- os=-bsd -- ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) -- basic_machine=m68000-att -+ cpu=m68000 -+ vendor=att - ;; - 3b*) -- basic_machine=we32k-att -- ;; -- a29khif) -- basic_machine=a29k-amd -- os=-udi -- ;; -- abacus) -- basic_machine=abacus-unknown -- ;; -- adobe68k) -- basic_machine=m68010-adobe -- os=-scout -- ;; -- alliant | fx80) -- basic_machine=fx80-alliant -- ;; -- altos | altos3068) -- basic_machine=m68k-altos -- ;; -- am29k) -- basic_machine=a29k-none -- os=-bsd -- ;; -- amd64) -- basic_machine=x86_64-pc -- ;; -- amd64-*) -- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- amdahl) -- basic_machine=580-amdahl -- os=-sysv -- ;; -- amiga | amiga-*) -- basic_machine=m68k-unknown -- ;; -- amigaos | amigados) -- basic_machine=m68k-unknown -- os=-amigaos -- ;; -- amigaunix | amix) -- basic_machine=m68k-unknown -- os=-sysv4 -- ;; -- apollo68) -- basic_machine=m68k-apollo -- os=-sysv -- ;; -- apollo68bsd) -- basic_machine=m68k-apollo -- os=-bsd -- ;; -- aros) -- basic_machine=i386-pc -- os=-aros -- ;; -- aux) -- basic_machine=m68k-apple -- os=-aux -- ;; -- balance) -- basic_machine=ns32k-sequent -- os=-dynix -- ;; -- blackfin) -- basic_machine=bfin-unknown -- os=-linux -- ;; -- blackfin-*) -- basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` -- os=-linux -+ cpu=we32k -+ vendor=att - ;; - bluegene*) -- basic_machine=powerpc-ibm -- os=-cnk -- ;; -- c54x-*) -- basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c55x-*) -- basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c6x-*) -- basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c90) -- basic_machine=c90-cray -- os=-unicos -- ;; -- cegcc) -- basic_machine=arm-unknown -- os=-cegcc -- ;; -- convex-c1) -- basic_machine=c1-convex -- os=-bsd -- ;; -- convex-c2) -- basic_machine=c2-convex -- os=-bsd -- ;; -- convex-c32) -- basic_machine=c32-convex -- os=-bsd -- ;; -- convex-c34) -- basic_machine=c34-convex -- os=-bsd -- ;; -- convex-c38) -- basic_machine=c38-convex -- os=-bsd -- ;; -- cray | j90) -- basic_machine=j90-cray -- os=-unicos -- ;; -- craynv) -- basic_machine=craynv-cray -- os=-unicosmp -- ;; -- cr16 | cr16-*) -- basic_machine=cr16-unknown -- os=-elf -- ;; -- crds | unos) -- basic_machine=m68k-crds -- ;; -- crisv32 | crisv32-* | etraxfs*) -- basic_machine=crisv32-axis -- ;; -- cris | cris-* | etrax*) -- basic_machine=cris-axis -- ;; -- crx) -- basic_machine=crx-unknown -- os=-elf -- ;; -- da30 | da30-*) -- basic_machine=m68k-da30 -- ;; -- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) -- basic_machine=mips-dec -+ cpu=powerpc -+ vendor=ibm -+ os=cnk - ;; - decsystem10* | dec10*) -- basic_machine=pdp10-dec -- os=-tops10 -+ cpu=pdp10 -+ vendor=dec -+ os=tops10 - ;; - decsystem20* | dec20*) -- basic_machine=pdp10-dec -- os=-tops20 -+ cpu=pdp10 -+ vendor=dec -+ os=tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) -- basic_machine=m68k-motorola -- ;; -- delta88) -- basic_machine=m88k-motorola -- os=-sysv3 -- ;; -- dicos) -- basic_machine=i686-pc -- os=-dicos -+ cpu=m68k -+ vendor=motorola - ;; -- djgpp) -- basic_machine=i586-pc -- os=-msdosdjgpp -- ;; -- dpx20 | dpx20-*) -- basic_machine=rs6000-bull -- os=-bosx -- ;; -- dpx2* | dpx2*-bull) -- basic_machine=m68k-bull -- os=-sysv3 -- ;; -- ebmon29k) -- basic_machine=a29k-amd -- os=-ebmon -- ;; -- elxsi) -- basic_machine=elxsi-elxsi -- os=-bsd -+ dpx2*) -+ cpu=m68k -+ vendor=bull -+ os=sysv3 - ;; - encore | umax | mmax) -- basic_machine=ns32k-encore -+ cpu=ns32k -+ vendor=encore - ;; -- es1800 | OSE68k | ose68k | ose | OSE) -- basic_machine=m68k-ericsson -- os=-ose -+ elxsi) -+ cpu=elxsi -+ vendor=elxsi -+ os=${os:-bsd} - ;; - fx2800) -- basic_machine=i860-alliant -+ cpu=i860 -+ vendor=alliant - ;; - genix) -- basic_machine=ns32k-ns -- ;; -- gmicro) -- basic_machine=tron-gmicro -- os=-sysv -- ;; -- go32) -- basic_machine=i386-pc -- os=-go32 -+ cpu=ns32k -+ vendor=ns - ;; - h3050r* | hiux*) -- basic_machine=hppa1.1-hitachi -- os=-hiuxwe2 -- ;; -- h8300hms) -- basic_machine=h8300-hitachi -- os=-hms -- ;; -- h8300xray) -- basic_machine=h8300-hitachi -- os=-xray -- ;; -- h8500hms) -- basic_machine=h8500-hitachi -- os=-hms -- ;; -- harris) -- basic_machine=m88k-harris -- os=-sysv3 -- ;; -- hp300-*) -- basic_machine=m68k-hp -- ;; -- hp300bsd) -- basic_machine=m68k-hp -- os=-bsd -- ;; -- hp300hpux) -- basic_machine=m68k-hp -- os=-hpux -+ cpu=hppa1.1 -+ vendor=hitachi -+ os=hiuxwe2 - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) -- basic_machine=hppa1.0-hp -+ cpu=hppa1.0 -+ vendor=hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) -- basic_machine=m68000-hp -+ cpu=m68000 -+ vendor=hp - ;; - hp9k3[2-9][0-9]) -- basic_machine=m68k-hp -+ cpu=m68k -+ vendor=hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) -- basic_machine=hppa1.0-hp -+ cpu=hppa1.0 -+ vendor=hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) -- basic_machine=hppa1.1-hp -+ cpu=hppa1.1 -+ vendor=hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) -- basic_machine=hppa1.0-hp -- ;; -- hppa-next) -- os=-nextstep3 -- ;; -- hppaosf) -- basic_machine=hppa1.1-hp -- os=-osf -- ;; -- hppro) -- basic_machine=hppa1.1-hp -- os=-proelf -- ;; -- i370-ibm* | ibm*) -- basic_machine=i370-ibm -+ cpu=hppa1.0 -+ vendor=hp - ;; - i*86v32) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv32 -+ cpu=`echo "$1" | sed -e 's/86.*/86/'` -+ vendor=pc -+ os=sysv32 - ;; - i*86v4*) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv4 -+ cpu=`echo "$1" | sed -e 's/86.*/86/'` -+ vendor=pc -+ os=sysv4 - ;; - i*86v) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv -+ cpu=`echo "$1" | sed -e 's/86.*/86/'` -+ vendor=pc -+ os=sysv - ;; - i*86sol2) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-solaris2 -+ cpu=`echo "$1" | sed -e 's/86.*/86/'` -+ vendor=pc -+ os=solaris2 - ;; -- i386mach) -- basic_machine=i386-mach -- os=-mach -- ;; -- i386-vsta | vsta) -- basic_machine=i386-unknown -- os=-vsta -+ j90 | j90-cray) -+ cpu=j90 -+ vendor=cray -+ os=${os:-unicos} - ;; - iris | iris4d) -- basic_machine=mips-sgi -+ cpu=mips -+ vendor=sgi - case $os in -- -irix*) -+ irix*) - ;; - *) -- os=-irix4 -+ os=irix4 - ;; - esac - ;; -- isi68 | isi) -- basic_machine=m68k-isi -- os=-sysv -- ;; -- m68knommu) -- basic_machine=m68k-unknown -- os=-linux -- ;; -- m68knommu-*) -- basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` -- os=-linux -- ;; -- m88k-omron*) -- basic_machine=m88k-omron -- ;; -- magnum | m3230) -- basic_machine=mips-mips -- os=-sysv -- ;; -- merlin) -- basic_machine=ns32k-utek -- os=-sysv -- ;; -- microblaze*) -- basic_machine=microblaze-xilinx -- ;; -- mingw64) -- basic_machine=x86_64-pc -- os=-mingw64 -- ;; -- mingw32) -- basic_machine=i386-pc -- os=-mingw32 -- ;; -- mingw32ce) -- basic_machine=arm-unknown -- os=-mingw32ce -- ;; - miniframe) -- basic_machine=m68000-convergent -- ;; -- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) -- basic_machine=m68k-atari -- os=-mint -- ;; -- mips3*-*) -- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` -- ;; -- mips3*) -- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown -- ;; -- monitor) -- basic_machine=m68k-rom68k -- os=-coff -- ;; -- morphos) -- basic_machine=powerpc-unknown -- os=-morphos -- ;; -- msdos) -- basic_machine=i386-pc -- os=-msdos -- ;; -- ms1-*) -- basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` -- ;; -- msys) -- basic_machine=i386-pc -- os=-msys -- ;; -- mvs) -- basic_machine=i370-ibm -- os=-mvs -- ;; -- nacl) -- basic_machine=le32-unknown -- os=-nacl -- ;; -- ncr3000) -- basic_machine=i486-ncr -- os=-sysv4 -+ cpu=m68000 -+ vendor=convergent - ;; -- netbsd386) -- basic_machine=i386-unknown -- os=-netbsd -- ;; -- netwinder) -- basic_machine=armv4l-rebel -- os=-linux -- ;; -- news | news700 | news800 | news900) -- basic_machine=m68k-sony -- os=-newsos -- ;; -- news1000) -- basic_machine=m68030-sony -- os=-newsos -+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) -+ cpu=m68k -+ vendor=atari -+ os=mint - ;; - news-3600 | risc-news) -- basic_machine=mips-sony -- os=-newsos -- ;; -- necv70) -- basic_machine=v70-nec -- os=-sysv -+ cpu=mips -+ vendor=sony -+ os=newsos - ;; -- next | m*-next ) -- basic_machine=m68k-next -+ next | m*-next) -+ cpu=m68k -+ vendor=next - case $os in -- -nextstep* ) -+ nextstep* ) - ;; -- -ns2*) -- os=-nextstep2 -+ ns2*) -+ os=nextstep2 - ;; - *) -- os=-nextstep3 -+ os=nextstep3 - ;; - esac - ;; -- nh3000) -- basic_machine=m68k-harris -- os=-cxux -- ;; -- nh[45]000) -- basic_machine=m88k-harris -- os=-cxux -- ;; -- nindy960) -- basic_machine=i960-intel -- os=-nindy -- ;; -- mon960) -- basic_machine=i960-intel -- os=-mon960 -- ;; -- nonstopux) -- basic_machine=mips-compaq -- os=-nonstopux -- ;; - np1) -- basic_machine=np1-gould -- ;; -- neo-tandem) -- basic_machine=neo-tandem -- ;; -- nse-tandem) -- basic_machine=nse-tandem -- ;; -- nsr-tandem) -- basic_machine=nsr-tandem -+ cpu=np1 -+ vendor=gould - ;; - op50n-* | op60c-*) -- basic_machine=hppa1.1-oki -- os=-proelf -- ;; -- openrisc | openrisc-*) -- basic_machine=or32-unknown -- ;; -- os400) -- basic_machine=powerpc-ibm -- os=-os400 -- ;; -- OSE68000 | ose68000) -- basic_machine=m68000-ericsson -- os=-ose -- ;; -- os68k) -- basic_machine=m68k-none -- os=-os68k -+ cpu=hppa1.1 -+ vendor=oki -+ os=proelf - ;; - pa-hitachi) -- basic_machine=hppa1.1-hitachi -- os=-hiuxwe2 -- ;; -- paragon) -- basic_machine=i860-intel -- os=-osf -- ;; -- parisc) -- basic_machine=hppa-unknown -- os=-linux -- ;; -- parisc-*) -- basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` -- os=-linux -+ cpu=hppa1.1 -+ vendor=hitachi -+ os=hiuxwe2 - ;; - pbd) -- basic_machine=sparc-tti -+ cpu=sparc -+ vendor=tti - ;; - pbb) -- basic_machine=m68k-tti -- ;; -- pc532 | pc532-*) -- basic_machine=ns32k-pc532 -- ;; -- pc98) -- basic_machine=i386-pc -+ cpu=m68k -+ vendor=tti - ;; -- pc98-*) -- basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentium | p5 | k5 | k6 | nexgen | viac3) -- basic_machine=i586-pc -- ;; -- pentiumpro | p6 | 6x86 | athlon | athlon_*) -- basic_machine=i686-pc -- ;; -- pentiumii | pentium2 | pentiumiii | pentium3) -- basic_machine=i686-pc -- ;; -- pentium4) -- basic_machine=i786-pc -- ;; -- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) -- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentiumpro-* | p6-* | 6x86-* | athlon-*) -- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) -- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentium4-*) -- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` -+ pc532) -+ cpu=ns32k -+ vendor=pc532 - ;; - pn) -- basic_machine=pn-gould -- ;; -- power) basic_machine=power-ibm -+ cpu=pn -+ vendor=gould - ;; -- ppc | ppcbe) basic_machine=powerpc-unknown -- ;; -- ppc-* | ppcbe-*) -- basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppcle | powerpclittle | ppc-le | powerpc-little) -- basic_machine=powerpcle-unknown -- ;; -- ppcle-* | powerpclittle-*) -- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppc64) basic_machine=powerpc64-unknown -- ;; -- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppc64le | powerpc64little | ppc64-le | powerpc64-little) -- basic_machine=powerpc64le-unknown -- ;; -- ppc64le-* | powerpc64little-*) -- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` -+ power) -+ cpu=power -+ vendor=ibm - ;; - ps2) -- basic_machine=i386-ibm -- ;; -- pw32) -- basic_machine=i586-unknown -- os=-pw32 -- ;; -- rdos | rdos64) -- basic_machine=x86_64-pc -- os=-rdos -- ;; -- rdos32) -- basic_machine=i386-pc -- os=-rdos -- ;; -- rom68k) -- basic_machine=m68k-rom68k -- os=-coff -+ cpu=i386 -+ vendor=ibm - ;; - rm[46]00) -- basic_machine=mips-siemens -+ cpu=mips -+ vendor=siemens - ;; - rtpc | rtpc-*) -- basic_machine=romp-ibm -- ;; -- s390 | s390-*) -- basic_machine=s390-ibm -- ;; -- s390x | s390x-*) -- basic_machine=s390x-ibm -- ;; -- sa29200) -- basic_machine=a29k-amd -- os=-udi -+ cpu=romp -+ vendor=ibm - ;; -- sb1) -- basic_machine=mipsisa64sb1-unknown -+ sde) -+ cpu=mipsisa32 -+ vendor=sde -+ os=${os:-elf} - ;; -- sb1el) -- basic_machine=mipsisa64sb1el-unknown -+ simso-wrs) -+ cpu=sparclite -+ vendor=wrs -+ os=vxworks - ;; -- sde) -- basic_machine=mipsisa32-sde -- os=-elf -+ tower | tower-32) -+ cpu=m68k -+ vendor=ncr - ;; -- sei) -- basic_machine=mips-sei -- os=-seiux -+ vpp*|vx|vx-*) -+ cpu=f301 -+ vendor=fujitsu - ;; -- sequent) -- basic_machine=i386-sequent -+ w65) -+ cpu=w65 -+ vendor=wdc - ;; -- sh) -- basic_machine=sh-hitachi -- os=-hms -+ w89k-*) -+ cpu=hppa1.1 -+ vendor=winbond -+ os=proelf - ;; -- sh5el) -- basic_machine=sh5le-unknown -+ none) -+ cpu=none -+ vendor=none - ;; -- sh64) -- basic_machine=sh64-unknown -+ leon|leon[3-9]) -+ cpu=sparc -+ vendor=$basic_machine - ;; -- sparclite-wrs | simso-wrs) -- basic_machine=sparclite-wrs -- os=-vxworks -+ leon-*|leon[3-9]-*) -+ cpu=sparc -+ vendor=`echo "$basic_machine" | sed 's/-.*//'` - ;; -- sps7) -- basic_machine=m68k-bull -- os=-sysv2 -+ -+ *-*) -+ # shellcheck disable=SC2162 -+ IFS="-" read cpu vendor <&2 -- exit 1 -+ # Recognize the canonical CPU types that are allowed with any -+ # company name. -+ case $cpu in -+ 1750a | 580 \ -+ | a29k \ -+ | aarch64 | aarch64_be \ -+ | abacus \ -+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ -+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ -+ | alphapca5[67] | alpha64pca5[67] \ -+ | am33_2.0 \ -+ | amdgcn \ -+ | arc | arceb \ -+ | arm | arm[lb]e | arme[lb] | armv* \ -+ | avr | avr32 \ -+ | asmjs \ -+ | ba \ -+ | be32 | be64 \ -+ | bfin | bs2000 \ -+ | c[123]* | c30 | [cjt]90 | c4x \ -+ | c8051 | clipper | craynv | csky | cydra \ -+ | d10v | d30v | dlx | dsp16xx \ -+ | e2k | elxsi | epiphany \ -+ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ -+ | h8300 | h8500 \ -+ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ -+ | hexagon \ -+ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ -+ | ip2k | iq2000 \ -+ | k1om \ -+ | le32 | le64 \ -+ | lm32 \ -+ | m32c | m32r | m32rle \ -+ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ -+ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ -+ | m88110 | m88k | maxq | mb | mcore | mep | metag \ -+ | microblaze | microblazeel \ -+ | mips | mipsbe | mipseb | mipsel | mipsle \ -+ | mips16 \ -+ | mips64 | mips64eb | mips64el \ -+ | mips64octeon | mips64octeonel \ -+ | mips64orion | mips64orionel \ -+ | mips64r5900 | mips64r5900el \ -+ | mips64vr | mips64vrel \ -+ | mips64vr4100 | mips64vr4100el \ -+ | mips64vr4300 | mips64vr4300el \ -+ | mips64vr5000 | mips64vr5000el \ -+ | mips64vr5900 | mips64vr5900el \ -+ | mipsisa32 | mipsisa32el \ -+ | mipsisa32r2 | mipsisa32r2el \ -+ | mipsisa32r6 | mipsisa32r6el \ -+ | mipsisa64 | mipsisa64el \ -+ | mipsisa64r2 | mipsisa64r2el \ -+ | mipsisa64r6 | mipsisa64r6el \ -+ | mipsisa64sb1 | mipsisa64sb1el \ -+ | mipsisa64sr71k | mipsisa64sr71kel \ -+ | mipsr5900 | mipsr5900el \ -+ | mipstx39 | mipstx39el \ -+ | mmix \ -+ | mn10200 | mn10300 \ -+ | moxie \ -+ | mt \ -+ | msp430 \ -+ | nds32 | nds32le | nds32be \ -+ | nfp \ -+ | nios | nios2 | nios2eb | nios2el \ -+ | none | np1 | ns16k | ns32k | nvptx \ -+ | open8 \ -+ | or1k* \ -+ | or32 \ -+ | orion \ -+ | picochip \ -+ | pdp10 | pdp11 | pj | pjl | pn | power \ -+ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ -+ | pru \ -+ | pyramid \ -+ | riscv | riscv32 | riscv64 \ -+ | rl78 | romp | rs6000 | rx \ -+ | score \ -+ | sh | shl \ -+ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ -+ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ -+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ -+ | sparclite \ -+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ -+ | spu \ -+ | tahoe \ -+ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ -+ | tron \ -+ | ubicom32 \ -+ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ -+ | vax \ -+ | visium \ -+ | w65 | wasm32 \ -+ | we32k \ -+ | x86 | x86_64 | xc16x | xgate | xps100 \ -+ | xstormy16 | xtensa* \ -+ | ymp \ -+ | z8k | z80) -+ ;; -+ -+ *) -+ echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 -+ exit 1 -+ ;; -+ esac - ;; - esac - - # Here we canonicalize certain aliases for manufacturers. --case $basic_machine in -- *-digital*) -- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` -+case $vendor in -+ digital*) -+ vendor=dec - ;; -- *-commodore*) -- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` -+ commodore*) -+ vendor=cbm - ;; - *) - ;; -@@ -1321,197 +1275,246 @@ esac - - # Decode manufacturer-specific aliases for certain operating systems. - --if [ x"$os" != x"" ] -+if [ x$os != x ] - then - case $os in -- # First match some system type aliases -- # that might get confused with valid system types. -- # -solaris* is a basic system type, with this one exception. -- -auroraux) -- os=-auroraux -+ # First match some system type aliases that might get confused -+ # with valid system types. -+ # solaris* is a basic system type, with this one exception. -+ auroraux) -+ os=auroraux - ;; -- -solaris1 | -solaris1.*) -- os=`echo $os | sed -e 's|solaris1|sunos4|'` -+ bluegene*) -+ os=cnk - ;; -- -solaris) -- os=-solaris2 -+ solaris1 | solaris1.*) -+ os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; -- -svr4*) -- os=-sysv4 -+ solaris) -+ os=solaris2 - ;; -- -unixware*) -- os=-sysv4.2uw -+ unixware*) -+ os=sysv4.2uw - ;; -- -gnu/linux*) -+ gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; -- # First accept the basic system types. -+ # es1800 is here to avoid being matched by es* (a different OS) -+ es1800*) -+ os=ose -+ ;; -+ # Some version numbers need modification -+ chorusos*) -+ os=chorusos -+ ;; -+ isc) -+ os=isc2.2 -+ ;; -+ sco6) -+ os=sco5v6 -+ ;; -+ sco5) -+ os=sco3.2v5 -+ ;; -+ sco4) -+ os=sco3.2v4 -+ ;; -+ sco3.2.[4-9]*) -+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` -+ ;; -+ sco3.2v[4-9]* | sco5v6*) -+ # Don't forget version if it is 3.2v4 or newer. -+ ;; -+ scout) -+ # Don't match below -+ ;; -+ sco*) -+ os=sco3.2v2 -+ ;; -+ psos*) -+ os=psos -+ ;; -+ # Now accept the basic system types. - # The portable systems comes first. -- # Each alternative MUST END IN A *, to match a version number. -- # -sysv* is not here because it comes later, after sysvr4. -- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -- | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ -- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ -- | -sym* | -kopensolaris* | -plan9* \ -- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ -- | -aos* | -aros* \ -- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ -- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ -- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ -- | -bitrig* | -openbsd* | -solidbsd* \ -- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ -- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ -- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ -- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ -- | -chorusos* | -chorusrdb* | -cegcc* \ -- | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ -- | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ -- | -linux-newlib* | -linux-musl* | -linux-uclibc* \ -- | -uxpv* | -beos* | -mpeix* | -udk* \ -- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ -- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ -- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ -- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ -- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ -- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ -- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) -+ # Each alternative MUST end in a * to match a version number. -+ # sysv* is not here because it comes later, after sysvr4. -+ gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ -+ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ -+ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ -+ | sym* | kopensolaris* | plan9* \ -+ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ -+ | aos* | aros* | cloudabi* | sortix* \ -+ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ -+ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ -+ | knetbsd* | mirbsd* | netbsd* \ -+ | bitrig* | openbsd* | solidbsd* | libertybsd* \ -+ | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ -+ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ -+ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ -+ | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ -+ | chorusrdb* | cegcc* | glidix* \ -+ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ -+ | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ -+ | linux-newlib* | linux-musl* | linux-uclibc* \ -+ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ -+ | interix* | uwin* | mks* | rhapsody* | darwin* \ -+ | openstep* | oskit* | conix* | pw32* | nonstopux* \ -+ | storm-chaos* | tops10* | tenex* | tops20* | its* \ -+ | os2* | vos* | palmos* | uclinux* | nucleus* \ -+ | morphos* | superux* | rtmk* | windiss* \ -+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ -+ | skyos* | haiku* | rdos* | toppers* | drops* | es* \ -+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ -+ | midnightbsd* | amdhsa* | unleashed* | emscripten*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; -- -qnx*) -- case $basic_machine in -- x86-* | i*86-*) -+ qnx*) -+ case $cpu in -+ x86 | i*86) - ;; - *) -- os=-nto$os -+ os=nto-$os - ;; - esac - ;; -- -nto-qnx*) -+ hiux*) -+ os=hiuxwe2 - ;; -- -nto*) -- os=`echo $os | sed -e 's|nto|nto-qnx|'` -+ nto-qnx*) - ;; -- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ -- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) -+ nto*) -+ os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; -- -mac*) -- os=`echo $os | sed -e 's|mac|macos|'` -+ sim | xray | os68k* | v88r* \ -+ | windows* | osx | abug | netware* | os9* \ -+ | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) - ;; -- -linux-dietlibc) -- os=-linux-dietlibc -+ linux-dietlibc) -+ os=linux-dietlibc - ;; -- -linux*) -+ linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; -- -sunos5*) -- os=`echo $os | sed -e 's|sunos5|solaris2|'` -+ lynx*178) -+ os=lynxos178 -+ ;; -+ lynx*5) -+ os=lynxos5 - ;; -- -sunos6*) -- os=`echo $os | sed -e 's|sunos6|solaris3|'` -+ lynx*) -+ os=lynxos - ;; -- -opened*) -- os=-openedition -+ mac*) -+ os=`echo "$os" | sed -e 's|mac|macos|'` - ;; -- -os400*) -- os=-os400 -+ opened*) -+ os=openedition - ;; -- -wince*) -- os=-wince -+ os400*) -+ os=os400 - ;; -- -osfrose*) -- os=-osfrose -+ sunos5*) -+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'` - ;; -- -osf*) -- os=-osf -+ sunos6*) -+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'` - ;; -- -utek*) -- os=-bsd -+ wince*) -+ os=wince - ;; -- -dynix*) -- os=-bsd -+ utek*) -+ os=bsd - ;; -- -acis*) -- os=-aos -+ dynix*) -+ os=bsd - ;; -- -atheos*) -- os=-atheos -+ acis*) -+ os=aos - ;; -- -syllable*) -- os=-syllable -+ atheos*) -+ os=atheos - ;; -- -386bsd) -- os=-bsd -+ syllable*) -+ os=syllable - ;; -- -ctix* | -uts*) -- os=-sysv -+ 386bsd) -+ os=bsd - ;; -- -nova*) -- os=-rtmk-nova -+ ctix* | uts*) -+ os=sysv - ;; -- -ns2 ) -- os=-nextstep2 -+ nova*) -+ os=rtmk-nova - ;; -- -nsk*) -- os=-nsk -+ ns2) -+ os=nextstep2 -+ ;; -+ nsk*) -+ os=nsk - ;; - # Preserve the version number of sinix5. -- -sinix5.*) -+ sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; -- -sinix*) -- os=-sysv4 -+ sinix*) -+ os=sysv4 - ;; -- -tpf*) -- os=-tpf -+ tpf*) -+ os=tpf - ;; -- -triton*) -- os=-sysv3 -+ triton*) -+ os=sysv3 - ;; -- -oss*) -- os=-sysv3 -+ oss*) -+ os=sysv3 - ;; -- -svr4) -- os=-sysv4 -+ svr4*) -+ os=sysv4 - ;; -- -svr3) -- os=-sysv3 -+ svr3) -+ os=sysv3 - ;; -- -sysvr4) -- os=-sysv4 -+ sysvr4) -+ os=sysv4 - ;; -- # This must come after -sysvr4. -- -sysv*) -+ # This must come after sysvr4. -+ sysv*) - ;; -- -ose*) -- os=-ose -+ ose*) -+ os=ose - ;; -- -es1800*) -- os=-ose -+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) -+ os=mint - ;; -- -xenix) -- os=-xenix -+ zvmoe) -+ os=zvmoe - ;; -- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -- os=-mint -+ dicos*) -+ os=dicos - ;; -- -aros*) -- os=-aros -+ pikeos*) -+ # Until real need of OS specific support for -+ # particular features comes up, bare metal -+ # configurations are quite functional. -+ case $cpu in -+ arm*) -+ os=eabi -+ ;; -+ *) -+ os=elf -+ ;; -+ esac - ;; -- -zvmoe) -- os=-zvmoe -+ nacl*) - ;; -- -dicos*) -- os=-dicos -+ ios) - ;; -- -nacl*) -+ none) - ;; -- -none) -+ *-eabi) - ;; - *) -- # Get rid of the `-' at the beginning of $os. -- os=`echo $os | sed 's/[^-]*-//'` -- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 -+ echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 - exit 1 - ;; - esac -@@ -1527,261 +1530,265 @@ else - # will signal an error saying that MANUFACTURER isn't an operating - # system, and we'll never get to this point. - --case $basic_machine in -+case $cpu-$vendor in - score-*) -- os=-elf -+ os=elf - ;; - spu-*) -- os=-elf -+ os=elf - ;; - *-acorn) -- os=-riscix1.2 -+ os=riscix1.2 - ;; - arm*-rebel) -- os=-linux -+ os=linux - ;; - arm*-semi) -- os=-aout -+ os=aout - ;; - c4x-* | tic4x-*) -- os=-coff -+ os=coff -+ ;; -+ c8051-*) -+ os=elf -+ ;; -+ clipper-intergraph) -+ os=clix - ;; - hexagon-*) -- os=-elf -+ os=elf - ;; - tic54x-*) -- os=-coff -+ os=coff - ;; - tic55x-*) -- os=-coff -+ os=coff - ;; - tic6x-*) -- os=-coff -+ os=coff - ;; - # This must come before the *-dec entry. - pdp10-*) -- os=-tops20 -+ os=tops20 - ;; - pdp11-*) -- os=-none -+ os=none - ;; - *-dec | vax-*) -- os=-ultrix4.2 -+ os=ultrix4.2 - ;; - m68*-apollo) -- os=-domain -+ os=domain - ;; - i386-sun) -- os=-sunos4.0.2 -+ os=sunos4.0.2 - ;; - m68000-sun) -- os=-sunos3 -+ os=sunos3 - ;; - m68*-cisco) -- os=-aout -+ os=aout - ;; - mep-*) -- os=-elf -+ os=elf - ;; - mips*-cisco) -- os=-elf -+ os=elf - ;; - mips*-*) -- os=-elf -- ;; -- or1k-*) -- os=-elf -+ os=elf - ;; - or32-*) -- os=-coff -+ os=coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. -- os=-sysv3 -+ os=sysv3 - ;; - sparc-* | *-sun) -- os=-sunos4.1.1 -+ os=sunos4.1.1 - ;; -- *-be) -- os=-beos -+ pru-*) -+ os=elf - ;; -- *-haiku) -- os=-haiku -+ *-be) -+ os=beos - ;; - *-ibm) -- os=-aix -+ os=aix - ;; - *-knuth) -- os=-mmixware -+ os=mmixware - ;; - *-wec) -- os=-proelf -+ os=proelf - ;; - *-winbond) -- os=-proelf -+ os=proelf - ;; - *-oki) -- os=-proelf -+ os=proelf - ;; - *-hp) -- os=-hpux -+ os=hpux - ;; - *-hitachi) -- os=-hiux -+ os=hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) -- os=-sysv -+ os=sysv - ;; - *-cbm) -- os=-amigaos -+ os=amigaos - ;; - *-dg) -- os=-dgux -+ os=dgux - ;; - *-dolphin) -- os=-sysv3 -+ os=sysv3 - ;; - m68k-ccur) -- os=-rtu -+ os=rtu - ;; - m88k-omron*) -- os=-luna -+ os=luna - ;; -- *-next ) -- os=-nextstep -+ *-next) -+ os=nextstep - ;; - *-sequent) -- os=-ptx -+ os=ptx - ;; - *-crds) -- os=-unos -+ os=unos - ;; - *-ns) -- os=-genix -+ os=genix - ;; - i370-*) -- os=-mvs -- ;; -- *-next) -- os=-nextstep3 -+ os=mvs - ;; - *-gould) -- os=-sysv -+ os=sysv - ;; - *-highlevel) -- os=-bsd -+ os=bsd - ;; - *-encore) -- os=-bsd -+ os=bsd - ;; - *-sgi) -- os=-irix -+ os=irix - ;; - *-siemens) -- os=-sysv4 -+ os=sysv4 - ;; - *-masscomp) -- os=-rtu -+ os=rtu - ;; - f30[01]-fujitsu | f700-fujitsu) -- os=-uxpv -+ os=uxpv - ;; - *-rom68k) -- os=-coff -+ os=coff - ;; - *-*bug) -- os=-coff -+ os=coff - ;; - *-apple) -- os=-macos -+ os=macos - ;; - *-atari*) -- os=-mint -+ os=mint -+ ;; -+ *-wrs) -+ os=vxworks - ;; - *) -- os=-none -+ os=none - ;; - esac - fi - - # Here we handle the case where we know the os, and the CPU type, but not the - # manufacturer. We pick the logical manufacturer. --vendor=unknown --case $basic_machine in -- *-unknown) -+case $vendor in -+ unknown) - case $os in -- -riscix*) -+ riscix*) - vendor=acorn - ;; -- -sunos*) -+ sunos*) - vendor=sun - ;; -- -cnk*|-aix*) -+ cnk*|-aix*) - vendor=ibm - ;; -- -beos*) -+ beos*) - vendor=be - ;; -- -hpux*) -+ hpux*) - vendor=hp - ;; -- -mpeix*) -+ mpeix*) - vendor=hp - ;; -- -hiux*) -+ hiux*) - vendor=hitachi - ;; -- -unos*) -+ unos*) - vendor=crds - ;; -- -dgux*) -+ dgux*) - vendor=dg - ;; -- -luna*) -+ luna*) - vendor=omron - ;; -- -genix*) -+ genix*) - vendor=ns - ;; -- -mvs* | -opened*) -+ clix*) -+ vendor=intergraph -+ ;; -+ mvs* | opened*) - vendor=ibm - ;; -- -os400*) -+ os400*) - vendor=ibm - ;; -- -ptx*) -+ ptx*) - vendor=sequent - ;; -- -tpf*) -+ tpf*) - vendor=ibm - ;; -- -vxsim* | -vxworks* | -windiss*) -+ vxsim* | vxworks* | windiss*) - vendor=wrs - ;; -- -aux*) -+ aux*) - vendor=apple - ;; -- -hms*) -+ hms*) - vendor=hitachi - ;; -- -mpw* | -macos*) -+ mpw* | macos*) - vendor=apple - ;; -- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) - vendor=atari - ;; -- -vos*) -+ vos*) - vendor=stratus - ;; - esac -- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; - esac - --echo $basic_machine$os -+echo "$cpu-$vendor-$os" - exit - - # Local variables: --# eval: (add-hook 'write-file-hooks 'time-stamp) -+# eval: (add-hook 'before-save-hook 'time-stamp) - # time-stamp-start: "timestamp='" - # time-stamp-format: "%:y-%02m-%02d" - # time-stamp-end: "'" -diff --git a/configure b/configure -index 9a78a4554..00bb37bae 100755 ---- a/configure -+++ b/configure -@@ -13415,6 +13415,8 @@ fi ;; #( - natdynlink=true ;; #( - aarch64-*-linux*) : - natdynlink=true ;; #( -+ riscv*-*-linux*) : -+ natdynlink=true ;; #( - *) : - ;; - esac -@@ -13545,7 +13547,11 @@ fi; system=elf ;; #( - aarch64-*-linux*) : - arch=arm64; system=linux ;; #( - x86_64-*-cygwin*) : -- arch=amd64; system=cygwin -+ arch=amd64; system=cygwin ;; #( -+ riscv32-*-linux*) : -+ arch=riscv; model=riscv32; system=linux ;; #( -+ riscv64-*-linux*) : -+ arch=riscv; model=riscv64; system=linux - ;; #( - *) : - ;; -@@ -13801,7 +13807,7 @@ esac ;; #( - *,freebsd) : - default_as="${toolpref}as" - default_aspp="${toolpref}cc -c" ;; #( -- amd64,*|arm,*|arm64,*|i386,*|power,bsd*|power,netbsd) : -+ amd64,*|arm,*|arm64,*|i386,*|power,bsd*|power,netbsd|riscv,*) : - default_as="${toolpref}as" - case $ocaml_cv_cc_vendor in #( - clang-*) : -diff --git a/configure.ac b/configure.ac -index 2227769e8..94b7e2b35 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -803,7 +803,8 @@ AS_IF([test x"$enable_shared" != "xno"], - [arm*-*-linux*], [natdynlink=true], - [arm*-*-freebsd*], [natdynlink=true], - [earm*-*-netbsd*], [natdynlink=true], -- [aarch64-*-linux*], [natdynlink=true])]) -+ [aarch64-*-linux*], [natdynlink=true], -+ [riscv*-*-linux*], [natdynlink=true])]) - - # Try to work around the Skylake/Kaby Lake processor bug. - AS_CASE(["$CC,$host"], -@@ -898,7 +899,11 @@ AS_CASE([$host], - [aarch64-*-linux*], - [arch=arm64; system=linux], - [x86_64-*-cygwin*], -- [arch=amd64; system=cygwin] -+ [arch=amd64; system=cygwin], -+ [riscv32-*-linux*], -+ [arch=riscv; model=riscv32; system=linux], -+ [riscv64-*-linux*], -+ [arch=riscv; model=riscv64; system=linux] - ) - - AS_IF([test x"$enable_native_compiler" = "xno"], -@@ -1008,7 +1013,7 @@ AS_CASE(["$arch,$system"], - [*,freebsd], - [default_as="${toolpref}as" - default_aspp="${toolpref}cc -c"], -- [amd64,*|arm,*|arm64,*|i386,*|power,bsd*|power,netbsd], -+ [amd64,*|arm,*|arm64,*|i386,*|power,bsd*|power,netbsd|riscv,*], - [default_as="${toolpref}as" - AS_CASE([$ocaml_cv_cc_vendor], - [clang-*], [default_aspp="${toolpref}clang -c -Wno-trigraphs"], -diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index 0c4aab159..f2fdec554 100644 ---- a/runtime/caml/stack.h -+++ b/runtime/caml/stack.h -@@ -70,6 +70,11 @@ - #define Callback_link(sp) ((struct caml_context *)((sp) + 16)) - #endif - -+#ifdef TARGET_riscv /* FIXME FIXME */ -+#define Saved_return_address(sp) *((intnat *)((sp) - 8)) -+#define Callback_link(sp) ((struct caml_context *)((sp) + 16)) -+#endif -+ - /* Structure of OCaml callback contexts */ - - struct caml_context { -diff --git a/runtime/riscv.S b/runtime/riscv.S -new file mode 100644 -index 000000000..d7e4e2d83 ---- /dev/null -+++ b/runtime/riscv.S -@@ -0,0 +1,424 @@ -+/***********************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2017 Institut National de Recherche en Informatique et */ -+/* en Automatique. All rights reserved. This file is distributed */ -+/* under the terms of the GNU Library General Public License, with */ -+/* the special exception on linking described in file ../LICENSE. */ -+/* */ -+/***********************************************************************/ -+ -+/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ -+/* Must be preprocessed by cpp */ -+ -+#define TRAP_PTR s1 -+#define ALLOC_PTR s10 -+#define ALLOC_LIMIT s11 -+#define TMP0 t0 -+#define TMP1 t1 -+#define ARG t2 -+ -+#if defined(MODEL_riscv64) -+#define store sd -+#define load ld -+#define WSZ 8 -+#else -+#define store sw -+#define load lw -+#define WSZ 4 -+#endif -+ -+#if defined(__PIC__) -+ .option pic -+#else -+ .option nopic -+#endif -+ -+ .section .text -+/* Invoke the garbage collector. */ -+ -+ .globl caml_system__code_begin -+caml_system__code_begin: -+ -+ .align 4 -+ .globl caml_call_gc -+ .type caml_call_gc, @function -+caml_call_gc: -+ /* Record return address */ -+ store ra, caml_last_return_address, TMP0 -+ /* Record lowest stack address */ -+ mv TMP1, sp -+ store sp, caml_bottom_of_stack, TMP0 -+.Lcaml_call_gc: -+ /* Set up stack space, saving return address */ -+ /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, 20 caller-save float regs) * 8 */ -+ /* + 1 for alignment */ -+ addi sp, sp, -0x160 -+ mv s0, sp -+ store ra, 0x8(sp) -+ store s0, 0x0(sp) -+ /* Save allocatable integer registers on the stack, -+ in the order given in proc.ml */ -+ store a0, 0x10(sp) -+ store a1, 0x18(sp) -+ store a2, 0x20(sp) -+ store a3, 0x28(sp) -+ store a4, 0x30(sp) -+ store a5, 0x38(sp) -+ store a6, 0x40(sp) -+ store a7, 0x48(sp) -+ store s2, 0x50(sp) -+ store s3, 0x58(sp) -+ store s4, 0x60(sp) -+ store s5, 0x68(sp) -+ store s6, 0x70(sp) -+ store s7, 0x78(sp) -+ store s8, 0x80(sp) -+ store s9, 0x88(sp) -+ store t2, 0x90(sp) -+ store t3, 0x98(sp) -+ store t4, 0xa0(sp) -+ store t5, 0xa8(sp) -+ store t6, 0xb0(sp) -+ /* Save caller-save floating-point registers on the stack -+ (callee-saves are preserved by caml_garbage_collection) */ -+ fsd ft0, 0xb8(sp) -+ fsd ft1, 0xc0(sp) -+ fsd ft2, 0xc8(sp) -+ fsd ft3, 0xd0(sp) -+ fsd ft4, 0xd8(sp) -+ fsd ft5, 0xe0(sp) -+ fsd ft6, 0xe8(sp) -+ fsd ft7, 0xf0(sp) -+ fsd fa0, 0xf8(sp) -+ fsd fa1, 0x100(sp) -+ fsd fa2, 0x108(sp) -+ fsd fa3, 0x110(sp) -+ fsd fa4, 0x118(sp) -+ fsd fa5, 0x120(sp) -+ fsd fa6, 0x128(sp) -+ fsd fa7, 0x130(sp) -+ fsd ft8, 0x138(sp) -+ fsd ft9, 0x140(sp) -+ fsd ft9, 0x148(sp) -+ fsd ft10, 0x150(sp) -+ fsd ft11, 0x158(sp) -+ /* Store pointer to saved integer registers in caml_gc_regs */ -+ addi TMP1, sp, 16 -+ store TMP1, caml_gc_regs, TMP0 -+ /* Save current allocation pointer for debugging purposes */ -+ store ALLOC_PTR, caml_young_ptr, TMP0 -+ /* Save trap pointer in case an exception is raised during GC */ -+ store TRAP_PTR, caml_exception_pointer, TMP0 -+ /* Call the garbage collector */ -+ call caml_garbage_collection -+ /* Restore registers */ -+ load a0, 0x10(sp) -+ load a1, 0x18(sp) -+ load a2, 0x20(sp) -+ load a3, 0x28(sp) -+ load a4, 0x30(sp) -+ load a5, 0x38(sp) -+ load a6, 0x40(sp) -+ load a7, 0x48(sp) -+ load s2, 0x50(sp) -+ load s3, 0x58(sp) -+ load s4, 0x60(sp) -+ load s5, 0x68(sp) -+ load s6, 0x70(sp) -+ load s7, 0x78(sp) -+ load s8, 0x80(sp) -+ load s9, 0x88(sp) -+ load t2, 0x90(sp) -+ load t3, 0x98(sp) -+ load t4, 0xa0(sp) -+ load t5, 0xa8(sp) -+ load t6, 0xb0(sp) -+ fld ft0, 0xb8(sp) -+ fld ft1, 0xc0(sp) -+ fld ft2, 0xc8(sp) -+ fld ft3, 0xd0(sp) -+ fld ft4, 0xd8(sp) -+ fld ft5, 0xe0(sp) -+ fld ft6, 0xe8(sp) -+ fld ft7, 0xf0(sp) -+ fld fa0, 0xf8(sp) -+ fld fa1, 0x100(sp) -+ fld fa2, 0x108(sp) -+ fld fa3, 0x110(sp) -+ fld fa4, 0x118(sp) -+ fld fa5, 0x120(sp) -+ fld fa6, 0x128(sp) -+ fld fa7, 0x130(sp) -+ fld ft8, 0x138(sp) -+ fld ft9, 0x140(sp) -+ fld ft9, 0x148(sp) -+ fld ft10, 0x150(sp) -+ fld ft11, 0x158(sp) -+ /* Reload new allocation pointer and allocation limit */ -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit -+ /* Free stack space and return to caller */ -+ load ra, 0x8(sp) -+ load s0, 0x0(sp) -+ addi sp, sp, 0x160 -+ ret -+ .size caml_call_gc, .-caml_call_gc -+ -+/* Call a C function from OCaml */ -+/* Function to call is in ARG */ -+ -+ .align 4 -+ .globl caml_c_call -+ .type caml_c_call, @function -+caml_c_call: -+ /* Preserve return address in callee-save register s2 */ -+ mv s2, ra -+ /* Record lowest stack address and return address */ -+ store ra, caml_last_return_address, TMP0 -+ store sp, caml_bottom_of_stack, TMP0 -+ /* Make the exception handler alloc ptr available to the C code */ -+ store ALLOC_PTR, caml_young_ptr, TMP0 -+ store TRAP_PTR, caml_exception_pointer, TMP0 -+ /* Call the function */ -+ jalr ARG -+ /* Reload alloc ptr and alloc limit */ -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit -+ /* Return */ -+ jr s2 -+ .size caml_c_call, .-caml_c_call -+ -+/* Raise an exception from OCaml */ -+ .align 4 -+ .globl caml_raise_exn -+ .type caml_raise_exn, @function -+caml_raise_exn: -+ /* Test if backtrace is active */ -+ load TMP1, caml_backtrace_active -+ bnez TMP1, 2f -+1: /* Cut stack at current trap handler */ -+ mv sp, TRAP_PTR -+ /* Pop previous handler and jump to it */ -+ load TMP1, 8(sp) -+ load TRAP_PTR, 0(sp) -+ addi sp, sp, 16 -+ jr TMP1 -+2: /* Preserve exception bucket in callee-save register s2 */ -+ mv s2, a0 -+ /* Stash the backtrace */ -+ mv a1, ra -+ mv a2, sp -+ mv a3, TRAP_PTR -+ call caml_stash_backtrace -+ /* Restore exception bucket and raise */ -+ mv a0, s2 -+ j 1b -+ .size caml_raise_exn, .-caml_raise_exn -+ -+ .globl caml_reraise_exn -+ .type caml_reraise_exn, @function -+ -+/* Raise an exception from C */ -+ -+ .align 4 -+ .globl caml_raise_exception -+ .type caml_raise_exception, @function -+caml_raise_exception: -+ load TRAP_PTR, caml_exception_pointer -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit -+ load TMP1, caml_backtrace_active -+ bnez TMP1, 2f -+1: /* Cut stack at current trap handler */ -+ mv sp, TRAP_PTR -+ load TMP1, 8(sp) -+ load TRAP_PTR, 0(sp) -+ addi sp, sp, 16 -+ jr TMP1 -+2: /* Preserve exception bucket in callee-save register s2 */ -+ mv s2, a0 -+ load a1, caml_last_return_address -+ load a2, caml_bottom_of_stack -+ mv a3, TRAP_PTR -+ call caml_stash_backtrace -+ mv a0, s2 -+ j 1b -+ .size caml_raise_exception, .-caml_raise_exception -+ -+/* Start the OCaml program */ -+ -+ .align 4 -+ .globl caml_start_program -+ .type caml_start_program, @function -+caml_start_program: -+ -+ la ARG, caml_program -+ /* Code shared with caml_callback* */ -+ /* Address of OCaml code to call is in ARG */ -+ /* Arguments to the OCaml code are in a0 ... a7 */ -+.Ljump_to_caml: -+ /* Set up stack frame and save callee-save registers */ -+ addi sp, sp, -0xd0 -+ store ra, 0xc0(sp) -+ store s0, 0x0(sp) -+ store s1, 0x8(sp) -+ store s2, 0x10(sp) -+ store s3, 0x18(sp) -+ store s4, 0x20(sp) -+ store s5, 0x28(sp) -+ store s6, 0x30(sp) -+ store s7, 0x38(sp) -+ store s8, 0x40(sp) -+ store s9, 0x48(sp) -+ store s10, 0x50(sp) -+ store s11, 0x58(sp) -+ fsd fs0, 0x60(sp) -+ fsd fs1, 0x68(sp) -+ fsd fs2, 0x70(sp) -+ fsd fs3, 0x78(sp) -+ fsd fs4, 0x80(sp) -+ fsd fs5, 0x88(sp) -+ fsd fs6, 0x90(sp) -+ fsd fs7, 0x98(sp) -+ fsd fs8, 0xa0(sp) -+ fsd fs9, 0xa8(sp) -+ fsd fs10, 0xb0(sp) -+ fsd fs11, 0xb8(sp) -+ addi sp, sp, -32 -+ /* Setup a callback link on the stack */ -+ load TMP1, caml_bottom_of_stack -+ store TMP1, 0(sp) -+ load TMP1, caml_last_return_address -+ store TMP1, 8(sp) -+ load TMP1, caml_gc_regs -+ store TMP1, 16(sp) -+ /* set up a trap frame */ -+ addi sp, sp, -16 -+ load TMP1, caml_exception_pointer -+ store TMP1, 0(sp) -+ lla TMP0, .Ltrap_handler -+ store TMP0, 8(sp) -+ mv TRAP_PTR, sp -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit -+ store x0, caml_last_return_address, TMP0 -+ jalr ARG -+.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ -+ load TMP1, 0(sp) -+ store TMP1, caml_exception_pointer, TMP0 -+ addi sp, sp, 16 -+.Lreturn_result: /* pop callback link, restoring global variables */ -+ load TMP1, 0(sp) -+ store TMP1, caml_bottom_of_stack, TMP0 -+ load TMP1, 8(sp) -+ store TMP1, caml_last_return_address, TMP0 -+ load TMP1, 16(sp) -+ store TMP1, caml_gc_regs, TMP0 -+ addi sp, sp, 32 -+ /* Update allocation pointer */ -+ store ALLOC_PTR, caml_young_ptr, TMP0 -+ /* reload callee-save registers and return */ -+ load ra, 0xc0(sp) -+ load s0, 0x0(sp) -+ load s1, 0x8(sp) -+ load s2, 0x10(sp) -+ load s3, 0x18(sp) -+ load s4, 0x20(sp) -+ load s5, 0x28(sp) -+ load s6, 0x30(sp) -+ load s7, 0x38(sp) -+ load s8, 0x40(sp) -+ load s9, 0x48(sp) -+ load s10, 0x50(sp) -+ load s11, 0x58(sp) -+ fld fs0, 0x60(sp) -+ fld fs1, 0x68(sp) -+ fld fs2, 0x70(sp) -+ fld fs3, 0x78(sp) -+ fld fs4, 0x80(sp) -+ fld fs5, 0x88(sp) -+ fld fs6, 0x90(sp) -+ fld fs7, 0x98(sp) -+ fld fs8, 0xa0(sp) -+ fld fs9, 0xa8(sp) -+ fld fs10, 0xb0(sp) -+ fld fs11, 0xb8(sp) -+ addi sp, sp, 0xd0 -+ ret -+.Ltrap_handler: -+ store TRAP_PTR, caml_exception_pointer, TMP0 -+ ori a0, a0, 2 -+ j .Lreturn_result -+ .size caml_start_program, .-caml_start_program -+ -+/* Callback from C to OCaml */ -+ -+ .align 4 -+ .globl caml_callback_exn -+ .type caml_callback_exn, @function -+caml_callback_exn: -+ /* Initial shuffling of arguments (a0 = closure, a1 = first arg) */ -+ mv TMP1, a0 -+ mv a0, a1 /* a0 = first arg */ -+ mv a1, TMP1 /* a1 = closure environment */ -+ load ARG, 0(TMP1) /* code pointer */ -+ j .Ljump_to_caml -+ .size caml_callback_exn, .-caml_callback_exn -+ -+ .align 4 -+ .globl caml_callback2_exn -+ .type caml_callback2_exn, @function -+caml_callback2_exn: -+ /* Initial shuffling of arguments (a0 = closure, a1 = arg1, a2 = arg2) */ -+ mv TMP1, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, TMP1 -+ la ARG, caml_apply2 -+ j .Ljump_to_caml -+ .size caml_callback2_exn, .-caml_callback2_exn -+ -+ .align 4 -+ .globl caml_callback3_exn -+ .type caml_callback3_exn, @function -+caml_callback3_exn: -+ /* Initial shuffling of argumnets */ -+ /* (a0 = closure, a1 = arg1, a2 = arg2, a3 = arg3) */ -+ mv TMP1, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, a3 -+ mv a3, TMP1 -+ la ARG, caml_apply3 -+ j .Ljump_to_caml -+ .size caml_callback3_exn, .-caml_callback3_exn -+ -+ .align 4 -+ .globl caml_ml_array_bound_error -+ .type caml_ml_array_bound_error, @function -+caml_ml_array_bound_error: -+ /* Load address of [caml_array_bound_error] in ARG */ -+ la ARG, caml_array_bound_error -+ /* Call that function */ -+ j caml_c_call -+ -+ .globl caml_system__code_end -+caml_system__code_end: -+ -+/* GC roots for callback */ -+ -+ .section .data -+ .align 3 -+ .globl caml_system__frametable -+ .type caml_system__frametable, @object -+caml_system__frametable: -+ .quad 1 /* one descriptor */ -+ .quad .Lcaml_retaddr /* return address into callback */ -+ .short -1 /* negative frame size => use callback link */ -+ .short 0 /* no roots */ -+ .align 3 -+ .size caml_system__frametable, .-caml_system__frametable --- -2.22.0.rc3 - diff --git a/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch b/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch new file mode 100644 index 0000000..db2e66e --- /dev/null +++ b/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch @@ -0,0 +1,102 @@ +From 987e819b8fb8e36e660340931270a2ade02c439e Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Thu, 26 Sep 2019 21:46:03 +0200 +Subject: [PATCH 04/12] Merge pull request #8979 from + gasche/fix-Makefile.menhir + +Fix tools/check-parser-uptodate-or-warn.sh + +(cherry picked from commit f075ab6fdeedc8d53ececd1184d69a1cc35c0fd5) +--- + Changes | 3 +++ + Makefile | 6 +++--- + tools/check-parser-uptodate-or-warn.sh | 21 +++++++++++++++++---- + 3 files changed, 23 insertions(+), 7 deletions(-) + +diff --git a/Changes b/Changes +index 355cb1a94..63cac3ef9 100644 +--- a/Changes ++++ b/Changes +@@ -5,6 +5,9 @@ OCaml 4.09 maintenance branch: + dummy locations + (Armaël Guéneau, review by Gabriel Scherer) + ++- #8965, #8979: Alpine build failure caused by check-parser-uptodate-or-warn.sh ++ (Gabriel Scherer and David Allsopp, report by Anton Kochkov) ++ + OCaml 4.09.0 (19 September 2019): + --------------------------------- + +diff --git a/Makefile b/Makefile +index 47548c79d..7ac446f62 100644 +--- a/Makefile ++++ b/Makefile +@@ -1076,10 +1076,10 @@ parsing/camlinternalMenhirLib.mli: boot/menhir/menhirLib.mli + + parsing/parser.ml: boot/menhir/parser.ml parsing/parser.mly \ + tools/check-parser-uptodate-or-warn.sh +- @tools/check-parser-uptodate-or-warn.sh +- cat $< | sed "s/MenhirLib/CamlinternalMenhirLib/g" > $@ ++ @-tools/check-parser-uptodate-or-warn.sh ++ sed "s/MenhirLib/CamlinternalMenhirLib/g" $< > $@ + parsing/parser.mli: boot/menhir/parser.mli +- cat $< | sed "s/MenhirLib/CamlinternalMenhirLib/g" > $@ ++ sed "s/MenhirLib/CamlinternalMenhirLib/g" $< > $@ + + + partialclean:: partialclean-menhir +diff --git a/tools/check-parser-uptodate-or-warn.sh b/tools/check-parser-uptodate-or-warn.sh +index 5502eae54..2f07619a6 100755 +--- a/tools/check-parser-uptodate-or-warn.sh ++++ b/tools/check-parser-uptodate-or-warn.sh +@@ -15,6 +15,9 @@ + #* * + #************************************************************************** + ++# stop early if we are not on a development version ++grep -Fq '+dev' VERSION || exit 0 ++ + # We try to warn if the user edits parsing/parser.mly but forgets to + # rebuild the generated parser. Our heuristic is to use the file + # modification timestamp, but just testing +@@ -24,15 +27,20 @@ + # seconds after boot/menhir/parser.ml. + + # mtime(): access a file's last modification time as a timestamp, +-# using either GNU coreutils' stat --format, or BSD/macos stat -f. ++# using either ++# GNU coreutils' stat --format, or ++# busybox's stat -c, or ++# BSD/macOS stat -f. + # Default to 0 if 'stat' is not available. + + stat . 2>/dev/null 1>/dev/null + if test $? != 0 + then MTIME="" +-elif test -n "$(stat --version 2>/dev/null | grep coreutils)" ++elif stat --version 2>/dev/null | grep -Fq 'coreutils' + then MTIME="stat --format %Y" +-else MTIME="stat -f %m" ++elif stat 2>&1 | grep -Fq 'busybox' ++then MTIME="stat -c %Y" ++else MTIME="stat -f %m" # BSD stat? + fi + + mtime() { +@@ -45,7 +53,12 @@ mtime() { + # The check itself + SOURCE_MTIME=$(mtime parsing/parser.mly) + GENERATED_MTIME=$(mtime boot/menhir/parser.ml) +-if test $SOURCE_MTIME -gt $(( $GENERATED_MTIME + 10 )) ++if test -z "$SOURCE_MTIME" -o -z "$GENERATED_MTIME" ++then ++ echo ++ tput setaf 3; tput bold; printf "Warning: "; tput sgr0 ++ echo "Failed to check if boot/menhir/parser.ml is up-to-date." ++elif test "$SOURCE_MTIME" -gt $(( GENERATED_MTIME + 10 )) + then + echo + tput setaf 3; tput bold; printf "Warning: "; tput sgr0 +-- +2.23.0 + diff --git a/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch b/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch new file mode 100644 index 0000000..4865a5b --- /dev/null +++ b/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch @@ -0,0 +1,51 @@ +From 3ef8ce701db0a010771c62171fc7ae355214ed05 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Thu, 26 Sep 2019 13:51:08 +0100 +Subject: [PATCH 05/12] Run whole of gen_primitives.sh with LC_ALL=C + +Fixes #8985. Assuming the locale has been generated, running +LC_COLLATE=sv_SE.UTF-8 make world failed previously since the w +character is not matched in [a-z] in this locale. +--- + Changes | 4 ++++ + runtime/gen_primitives.sh | 5 ++++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/Changes b/Changes +index 63cac3ef9..257a75e3d 100644 +--- a/Changes ++++ b/Changes +@@ -8,6 +8,10 @@ OCaml 4.09 maintenance branch: + - #8965, #8979: Alpine build failure caused by check-parser-uptodate-or-warn.sh + (Gabriel Scherer and David Allsopp, report by Anton Kochkov) + ++- #8985, #8986: fix generation of the primitives when the locale collation is ++ incompatible with C. ++ (David Allsopp, review by Nicolás Ojeda Bär, report by Sebastian Rasmussen) ++ + OCaml 4.09.0 (19 September 2019): + --------------------------------- + +diff --git a/runtime/gen_primitives.sh b/runtime/gen_primitives.sh +index e3ca2779b..63365a7fb 100755 +--- a/runtime/gen_primitives.sh ++++ b/runtime/gen_primitives.sh +@@ -17,6 +17,9 @@ + + # duplicated from $(ROOTDIR)/runtime/Makefile + ++# #8985: the meaning of character range a-z depends on the locale, so force C ++# locale throughout. ++export LC_ALL=C + ( + for prim in \ + alloc array compare extern floats gc_ctrl hash intern interp ints io \ +@@ -27,4 +30,4 @@ + done + sed -n -e 's/^CAMLprim_int64_[0-9](\([a-z0-9_][a-z0-9_]*\)).*/caml_int64_\1\ + caml_int64_\1_native/p' ints.c +-) | LC_ALL=C sort | uniq ++) | sort | uniq +-- +2.23.0 + diff --git a/0005-riscv-Emit-debug-info.patch b/0005-riscv-Emit-debug-info.patch deleted file mode 100644 index ff732cf..0000000 --- a/0005-riscv-Emit-debug-info.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 2f23a53b4aa1b672b3919cc021b83548f713b90a Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 5 Jun 2018 19:48:08 +0000 -Subject: [PATCH 5/5] riscv: Emit debug info. - ---- - asmcomp/riscv/emit.mlp | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp -index 88ea9f884..cc05aefe4 100644 ---- a/asmcomp/riscv/emit.mlp -+++ b/asmcomp/riscv/emit.mlp -@@ -261,6 +261,7 @@ let tailrec_entry_point = ref 0 - (* Output the assembly code for an instruction *) - - let emit_instr i = -+ emit_debug_info i.dbg; - match i.desc with - Lend -> () - | Lprologue -> -@@ -556,6 +557,7 @@ let fundecl fundecl = - ` {emit_string code_space}\n`; - ` .align 2\n`; - `{emit_symbol fundecl.fun_name}:\n`; -+ emit_debug_info fundecl.fun_dbg; - emit_all fundecl.fun_body; - List.iter emit_call_gc !call_gc_sites; - List.iter emit_call_bound_error !bound_error_sites; -@@ -615,6 +617,7 @@ let data l = - - let begin_assembly() = - ` .file \"\"\n`; (* PR#7073 *) -+ reset_debug_info (); - (* Emit the beginning of the segments *) - let lbl_begin = Compilenv.make_symbol (Some "data_begin") in - ` {emit_string data_space}\n`; --- -2.22.0.rc3 - diff --git a/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch b/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch new file mode 100644 index 0000000..0e3709a --- /dev/null +++ b/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch @@ -0,0 +1,28 @@ +From 8995e5828ebfe933b74d0c3704c0524a63c73467 Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Fri, 27 Sep 2019 17:15:26 +0200 +Subject: [PATCH 06/12] Merge pull request #8988 from Octachron/fix_ocamlnat + +Fix ocamlnat + +(cherry picked from commit afb90bdf7476a92c024eee2e5745ed85200c654b) +--- + toplevel/opttoploop.ml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/toplevel/opttoploop.ml b/toplevel/opttoploop.ml +index 0d1f73921..0174a9ab5 100644 +--- a/toplevel/opttoploop.ml ++++ b/toplevel/opttoploop.ml +@@ -257,7 +257,7 @@ let load_lambda ppf ~module_ident ~required_globals lam size = + else + Asmgen.compile_implementation_flambda + ~required_globals ~backend ~toplevel:need_symbol fn ~ppf_dump:ppf +- (Flambda_middle_end.middle_end ~ppf_dump:ppf ~prefixname:"" ~backend ~size ++ (Flambda_middle_end.middle_end ~ppf_dump:ppf ~prefixname:fn ~backend ~size + ~module_ident ~module_initializer:slam ~filename:"toplevel"); + Asmlink.call_linker_shared [fn ^ ext_obj] dll; + Sys.remove (fn ^ ext_obj); +-- +2.23.0 + diff --git a/0007-Fix-failure-to-install-tools-links.patch b/0007-Fix-failure-to-install-tools-links.patch new file mode 100644 index 0000000..5824bd8 --- /dev/null +++ b/0007-Fix-failure-to-install-tools-links.patch @@ -0,0 +1,45 @@ +From fa36269c5752bfb8f4b65dd0f9a2dd8f9c9eeb8f Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Tue, 6 Aug 2019 09:23:06 +0100 +Subject: [PATCH 07/12] Fix failure to install tools links + +In --disable-installing-bytecode-programs mode, the .opt version of the +tools is installed, but the symlink for the tool itself is not created. + +(cherry picked from commit 705739fa54260b7a0e6cbba0b5a99e52c79f9c09) +--- + Changes | 5 +++++ + tools/Makefile | 1 + + 2 files changed, 6 insertions(+) + +diff --git a/Changes b/Changes +index 257a75e3d..3fdc31a5f 100644 +--- a/Changes ++++ b/Changes +@@ -1,6 +1,11 @@ + OCaml 4.09 maintenance branch: + ------------------------------ + ++- #8855, #8858: Links for tools not created when installing with ++ --disable-installing-byecode-programs (e.g. ocamldep.opt installed, but ++ ocamldep link not created) ++ (David Allsopp, report by Thomas Leonard) ++ + - #8953, #8954: Fix error submessages in the toplevel: do not display + dummy locations + (Armaël Guéneau, review by Gabriel Scherer) +diff --git a/tools/Makefile b/tools/Makefile +index afefc4d83..84ddd79fb 100644 +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -242,6 +242,7 @@ else + do \ + if test -f "$$i".opt; then \ + $(INSTALL_PROG) "$$i.opt" "$(INSTALL_BINDIR)/$$i.opt$(EXE)"; \ ++ (cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \ + fi; \ + done + endif +-- +2.23.0 + diff --git a/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch b/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch new file mode 100644 index 0000000..56ebcde --- /dev/null +++ b/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch @@ -0,0 +1,31 @@ +From 308ea9a8d526160e2b45f16d63a0aee70984b814 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Sun, 29 Sep 2019 19:33:29 +0200 +Subject: [PATCH 08/12] Merge pull request #8996 from dra27/win-reconfigure + +Windows supports make reconfigure now + +(cherry picked from commit c71997a167c3670d202c6ecaf830c6a25b4b95b8) +--- + Makefile | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 7ac446f62..90583f1bc 100644 +--- a/Makefile ++++ b/Makefile +@@ -326,11 +326,9 @@ endif + utils/config.ml: utils/config.mlp Makefile.config utils/Makefile Makefile + $(MAKE) -C utils config.ml + +-ifeq "$(UNIX_OR_WIN32)" "unix" + .PHONY: reconfigure + reconfigure: + ./configure $(CONFIGURE_ARGS) +-endif + + .PHONY: partialclean + partialclean:: +-- +2.23.0 + diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0009-Don-t-add-rpaths-to-libraries.patch similarity index 83% rename from 0001-Don-t-add-rpaths-to-libraries.patch rename to 0009-Don-t-add-rpaths-to-libraries.patch index 5b60aef..f2589ba 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0009-Don-t-add-rpaths-to-libraries.patch @@ -1,14 +1,14 @@ -From d3bc916ff1bc467c503e21015db9c1e2a47a64f2 Mon Sep 17 00:00:00 2001 +From 065c173840d0c379c26376b1de6363736043c969 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/5] Don't add rpaths to libraries. +Subject: [PATCH 09/12] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile -index ee0e0be4c..7c96b6405 100644 +index 84ddd79fb..796821968 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -153,8 +153,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ @@ -23,5 +23,5 @@ index ee0e0be4c..7c96b6405 100644 > ocamlmklibconfig.ml -- -2.22.0.rc3 +2.23.0 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0010-configure-Allow-user-defined-C-compiler-flags.patch similarity index 71% rename from 0002-configure-Allow-user-defined-C-compiler-flags.patch rename to 0010-configure-Allow-user-defined-C-compiler-flags.patch index 093be83..7d532d4 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0010-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From 8cc56a1515816c9cef84694e63eaed63a0474090 Mon Sep 17 00:00:00 2001 +From f1c04c17f5b42a969cbf3119ebbb851e799d664d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. +Subject: [PATCH 10/12] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index f5d8a2687..ad5b701bd 100644 +index c2f185373..12d9f6cde 100644 --- a/configure.ac +++ b/configure.ac -@@ -553,6 +553,10 @@ AS_CASE([$host], +@@ -549,6 +549,10 @@ AS_CASE([$host], internal_cflags="$gcc_warnings"], [common_cflags="-O"])]) @@ -23,5 +23,5 @@ index f5d8a2687..ad5b701bd 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.22.0.rc3 +2.23.0 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0011-configure-Remove-incorrect-assumption-about-cross-co.patch similarity index 67% rename from 0003-configure-Remove-incorrect-assumption-about-cross-co.patch rename to 0011-configure-Remove-incorrect-assumption-about-cross-co.patch index 99bca0e..d7ab72d 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0011-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From 0204a1137a8e8058afd1665aa6112656bc7bf0be Mon Sep 17 00:00:00 2001 +From 3432e0eb653e670025642b6e40e2d4a2eb4c28ae Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/5] configure: Remove incorrect assumption about +Subject: [PATCH 11/12] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -10,12 +10,12 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index ad5b701bd..2227769e8 100644 +index 12d9f6cde..e85cc9ffa 100644 --- a/configure.ac +++ b/configure.ac -@@ -959,7 +959,7 @@ AS_CASE([$host], - [*-*-mingw32|*-pc-windows], [asppprofflags=''], - [asppprofflags='-DPROFILING']) +@@ -927,7 +927,7 @@ AS_IF([test $arch != "none" && $arch64 ], + + # Assembler -AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""]) +#AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""]) @@ -23,5 +23,5 @@ index ad5b701bd..2227769e8 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.22.0.rc3 +2.23.0 diff --git a/0012-Add-riscv64-backend.patch b/0012-Add-riscv64-backend.patch new file mode 100644 index 0000000..5883ba8 --- /dev/null +++ b/0012-Add-riscv64-backend.patch @@ -0,0 +1,1912 @@ +From a861b131c28af6b313c7e778e2b6712e6b6fa5f2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= +Date: Mon, 18 Nov 2019 01:13:30 +0100 +Subject: [PATCH 12/12] Add riscv64 backend + +(cherry picked from commit c8a361f586c21eca25108ee79c495bb480a1c3f3) +--- + README.adoc | 1 + + asmcomp/riscv/CSE.ml | 36 ++ + asmcomp/riscv/arch.ml | 87 +++++ + asmcomp/riscv/emit.mlp | 669 +++++++++++++++++++++++++++++++++ + asmcomp/riscv/proc.ml | 336 +++++++++++++++++ + asmcomp/riscv/reload.ml | 16 + + asmcomp/riscv/scheduling.ml | 19 + + asmcomp/riscv/selection.ml | 71 ++++ + configure | Bin 542985 -> 543184 bytes + configure.ac | 11 +- + runtime/caml/stack.h | 5 + + runtime/riscv.S | 427 +++++++++++++++++++++ + testsuite/tools/asmgen_riscv.S | 87 +++++ + 13 files changed, 1762 insertions(+), 3 deletions(-) + create mode 100644 asmcomp/riscv/CSE.ml + create mode 100644 asmcomp/riscv/arch.ml + create mode 100644 asmcomp/riscv/emit.mlp + create mode 100644 asmcomp/riscv/proc.ml + create mode 100644 asmcomp/riscv/reload.ml + create mode 100644 asmcomp/riscv/scheduling.ml + create mode 100644 asmcomp/riscv/selection.ml + create mode 100644 runtime/riscv.S + create mode 100644 testsuite/tools/asmgen_riscv.S + +diff --git a/README.adoc b/README.adoc +index 504c7a708..4dc404da3 100644 +--- a/README.adoc ++++ b/README.adoc +@@ -54,6 +54,7 @@ compiler currently runs on the following platforms: + | ARM 32 bits | Linux | FreeBSD, NetBSD, OpenBSD + | Power 64 bits | Linux | + | Power 32 bits | | Linux ++| RISC-V 64 bits | Linux | + | IBM Z (s390x) | Linux | + |==== + +diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml +new file mode 100644 +index 000000000..302811a99 +--- /dev/null ++++ b/asmcomp/riscv/CSE.ml +@@ -0,0 +1,36 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2106 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* CSE for the RISC-V *) ++ ++open Arch ++open Mach ++open CSEgen ++ ++class cse = object (_self) ++ ++inherit cse_generic as super ++ ++method! class_of_operation op = ++ match op with ++ | Ispecific(Imultaddf _ | Imultsubf _) -> Op_pure ++ | _ -> super#class_of_operation op ++ ++method! is_cheap_operation op = ++ match op with ++ | Iconst_int n -> n <= 0x7FFn && n >= -0x800n ++ | _ -> false ++ ++end ++ ++let fundecl f = ++ (new cse)#fundecl f +diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml +new file mode 100644 +index 000000000..22c807c49 +--- /dev/null ++++ b/asmcomp/riscv/arch.ml +@@ -0,0 +1,87 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Specific operations for the RISC-V processor *) ++ ++open Format ++ ++(* Machine-specific command-line options *) ++ ++let command_line_options = [] ++ ++(* Specific operations *) ++ ++type specific_operation = ++ | Imultaddf of bool (* multiply, optionally negate, and add *) ++ | Imultsubf of bool (* multiply, optionally negate, and subtract *) ++ ++let spacetime_node_hole_pointer_is_live_before = function ++ | Imultaddf _ | Imultsubf _ -> false ++ ++(* Addressing modes *) ++ ++type addressing_mode = ++ | Iindexed of int (* reg + displ *) ++ ++let is_immediate n = ++ (n <= 2047) && (n >= -2048) ++ ++(* Sizes, endianness *) ++ ++let big_endian = false ++ ++let rv64 = ++ match Config.model with "riscv64" -> true | "riscv32" -> false | _ -> assert false ++ ++let size_addr = if rv64 then 8 else 4 ++let size_int = size_addr ++let size_float = 8 ++ ++let allow_unaligned_access = false ++ ++(* Behavior of division *) ++ ++let division_crashes_on_overflow = false ++ ++(* Operations on addressing modes *) ++ ++let identity_addressing = Iindexed 0 ++ ++let offset_addressing addr delta = ++ match addr with ++ | Iindexed n -> Iindexed(n + delta) ++ ++let num_args_addressing = function ++ | Iindexed _ -> 1 ++ ++(* Printing operations and addressing modes *) ++ ++let print_addressing printreg addr ppf arg = ++ match addr with ++ | Iindexed n -> ++ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in ++ fprintf ppf "%a%s" printreg arg.(0) idx ++ ++let print_specific_operation printreg op ppf arg = ++ match op with ++ | Imultaddf false -> ++ fprintf ppf "%a *f %a +f %a" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultaddf true -> ++ fprintf ppf "-f (%a *f %a +f %a)" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultsubf false -> ++ fprintf ppf "%a *f %a -f %a" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultsubf true -> ++ fprintf ppf "-f (%a *f %a -f %a)" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +new file mode 100644 +index 000000000..f9e3874d9 +--- /dev/null ++++ b/asmcomp/riscv/emit.mlp +@@ -0,0 +1,669 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Emission of RISC-V assembly code *) ++ ++open Misc ++open Cmm ++open Arch ++open Proc ++open Reg ++open Mach ++open Linearize ++open Emitaux ++ ++(* Layout of the stack. The stack is kept 16-aligned. *) ++ ++let stack_offset = ref 0 ++ ++let frame_size () = ++ let size = ++ !stack_offset + (* Trap frame, outgoing parameters *) ++ size_int * num_stack_slots.(0) + (* Local int variables *) ++ size_float * num_stack_slots.(1) + (* Local float variables *) ++ (if !contains_calls then size_addr else 0) in (* The return address *) ++ Misc.align size 16 ++ ++let slot_offset loc cls = ++ match loc with ++ | Local n -> ++ if cls = 0 ++ then !stack_offset + num_stack_slots.(1) * size_float + n * size_int ++ else !stack_offset + n * size_float ++ | Incoming n -> frame_size() + n ++ | Outgoing n -> n ++ ++(* Output a symbol *) ++ ++let emit_symbol s = ++ Emitaux.emit_symbol '.' s ++ ++let emit_jump op s = ++ if !Clflags.dlcode || !Clflags.pic_code ++ then `{emit_string op} {emit_symbol s}@plt` ++ else `{emit_string op} {emit_symbol s}` ++ ++let emit_call = emit_jump "call" ++let emit_tail = emit_jump "tail" ++ ++(* Output a label *) ++ ++let label_prefix = "L" ++ ++let emit_label lbl = ++ emit_string label_prefix; emit_int lbl ++ ++(* Section switching *) ++ ++let data_space = ++ ".section .data" ++ ++let code_space = ++ ".section .text" ++ ++let rodata_space = ++ ".section .rodata" ++ ++let reg_tmp1 = phys_reg 21 (* used by the assembler *) ++let reg_tmp2 = phys_reg 22 ++let reg_t2 = phys_reg 16 ++(* let reg_fp = phys_reg 23 *) ++let reg_trap = phys_reg 24 ++let reg_alloc_ptr = phys_reg 25 ++let reg_alloc_lim = phys_reg 26 ++ ++(* Names of instructions that differ in 32 and 64-bit modes *) ++ ++let lg = if rv64 then "ld" else "lw" ++let stg = if rv64 then "sd" else "sw" ++let datag = if rv64 then ".quad" else ".long" ++ ++(* Output a pseudo-register *) ++ ++let emit_reg = function ++ | {loc = Reg r} -> emit_string (register_name r) ++ | _ -> fatal_error "Emit.emit_reg" ++ ++(* Adjust sp by the given byte amount *) ++ ++let emit_stack_adjustment = function ++ | 0 -> () ++ | n when is_immediate n -> ++ ` addi sp, sp, {emit_int n}\n` ++ | n -> ++ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; ++ ` add sp, sp, {emit_reg reg_tmp1}\n` ++ ++let reload_ra n = ++ let ofs = n - size_addr in ++ if is_immediate ofs then ++ ` {emit_string lg} ra, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string lg} ra, 0({emit_reg reg_tmp1})\n` ++ end ++ ++let store_ra n = ++ let ofs = n - size_addr in ++ if is_immediate ofs then ++ ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string stg} ra, 0({emit_reg reg_tmp1})\n` ++ end ++ ++let emit_store stg src ofs = ++ if is_immediate ofs then ++ ` {emit_string stg} {emit_reg src}, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string stg} {emit_reg src}, 0({emit_reg reg_tmp1})\n` ++ end ++ ++let emit_load lg dst ofs = ++ if is_immediate ofs then ++ ` {emit_string lg} {emit_reg dst}, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string lg} {emit_reg dst}, 0({emit_reg reg_tmp1})\n` ++ end ++ ++(* Record live pointers at call points *) ++ ++let record_frame_label ?label live raise_ dbg = ++ let lbl = ++ match label with ++ | None -> new_label() ++ | Some label -> label ++ in ++ let live_offset = ref [] in ++ Reg.Set.iter ++ (function ++ {typ = Val; loc = Reg r} -> ++ live_offset := (r lsl 1) + 1 :: !live_offset ++ | {typ = Val; loc = Stack s} as reg -> ++ live_offset := slot_offset s (register_class reg) :: !live_offset ++ | {typ = Addr} as r -> ++ Misc.fatal_error ("bad GC root " ^ Reg.name r) ++ | _ -> () ++ ) ++ live; ++ record_frame_descr ~label:lbl ~frame_size:(frame_size()) ++ ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ lbl ++ ++let record_frame ?label live raise_ dbg = ++ let lbl = record_frame_label ?label live raise_ dbg in ++ `{emit_label lbl}:\n` ++ ++(* Record calls to the GC -- we've moved them out of the way *) ++ ++type gc_call = ++ { gc_lbl: label; (* Entry label *) ++ gc_return_lbl: label; (* Where to branch after GC *) ++ gc_frame_lbl: label } (* Label of frame descriptor *) ++ ++let call_gc_sites = ref ([] : gc_call list) ++ ++let emit_call_gc gc = ++ `{emit_label gc.gc_lbl}:\n`; ++ ` {emit_call "caml_call_gc"}\n`; ++ `{emit_label gc.gc_frame_lbl}:\n`; ++ ` j {emit_label gc.gc_return_lbl}\n` ++ ++(* Record calls to caml_ml_array_bound_error. ++ In debug mode, we maintain one call to caml_ml_array_bound_error ++ per bound check site. Otherwise, we can share a single call. *) ++ ++type bound_error_call = ++ { bd_lbl: label; (* Entry label *) ++ bd_frame_lbl: label } (* Label of frame descriptor *) ++ ++let bound_error_sites = ref ([] : bound_error_call list) ++ ++let bound_error_label ?label dbg = ++ if !Clflags.debug || !bound_error_sites = [] then begin ++ let lbl_bound_error = new_label() in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ bound_error_sites := ++ { bd_lbl = lbl_bound_error; ++ bd_frame_lbl = lbl_frame } :: !bound_error_sites; ++ lbl_bound_error ++ end else ++ let bd = List.hd !bound_error_sites in ++ bd.bd_lbl ++ ++let emit_call_bound_error bd = ++ `{emit_label bd.bd_lbl}:\n`; ++ ` {emit_call "caml_ml_array_bound_error"}\n`; ++ `{emit_label bd.bd_frame_lbl}:\n` ++ ++(* Record floating-point literals *) ++ ++let float_literals = ref ([] : (int64 * int) list) ++ ++(* Names for various instructions *) ++ ++let name_for_intop = function ++ | Iadd -> "add" ++ | Isub -> "sub" ++ | Imul -> "mul" ++ | Imulh -> "mulh" ++ | Idiv -> "div" ++ | Iand -> "and" ++ | Ior -> "or" ++ | Ixor -> "xor" ++ | Ilsl -> "sll" ++ | Ilsr -> "srl" ++ | Iasr -> "sra" ++ | Imod -> "rem" ++ | _ -> fatal_error "Emit.Intop" ++ ++let name_for_intop_imm = function ++ | Iadd -> "addi" ++ | Iand -> "andi" ++ | Ior -> "ori" ++ | Ixor -> "xori" ++ | Ilsl -> "slli" ++ | Ilsr -> "srli" ++ | Iasr -> "srai" ++ | _ -> fatal_error "Emit.Intop_imm" ++ ++let name_for_floatop1 = function ++ | Inegf -> "fneg.d" ++ | Iabsf -> "fabs.d" ++ | _ -> fatal_error "Emit.Iopf1" ++ ++let name_for_floatop2 = function ++ | Iaddf -> "fadd.d" ++ | Isubf -> "fsub.d" ++ | Imulf -> "fmul.d" ++ | Idivf -> "fdiv.d" ++ | _ -> fatal_error "Emit.Iopf2" ++ ++let name_for_specific = function ++ | Imultaddf false -> "fmadd.d" ++ | Imultaddf true -> "fnmadd.d" ++ | Imultsubf false -> "fmsub.d" ++ | Imultsubf true -> "fnmsub.d" ++ ++(* Name of current function *) ++let function_name = ref "" ++ ++(* Entry point for tail recursive calls *) ++let tailrec_entry_point = ref 0 ++ ++(* Output the assembly code for an instruction *) ++ ++let emit_instr i = ++ emit_debug_info i.dbg; ++ match i.desc with ++ Lend -> () ++ | Lprologue -> ++ assert (Proc.prologue_required ()); ++ let n = frame_size() in ++ emit_stack_adjustment (-n); ++ if !contains_calls then store_ra n ++ | Lop(Imove | Ispill | Ireload) -> ++ let src = i.arg.(0) and dst = i.res.(0) in ++ if src.loc <> dst.loc then begin ++ match (src, dst) with ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> ++ ` mv {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> ++ ` fmv.d {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> ++ let ofs = slot_offset s (register_class dst) in ++ emit_store stg src ofs ++ | {loc = Reg _; typ = Float}, {loc = Stack s} -> ++ let ofs = slot_offset s (register_class dst) in ++ emit_store "fsd" src ofs ++ | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> ++ let ofs = slot_offset s (register_class src) in ++ emit_load lg dst ofs ++ | {loc = Stack s; typ = Float}, {loc = Reg _} -> ++ let ofs = slot_offset s (register_class src) in ++ emit_load "fld" dst ofs ++ | _ -> ++ fatal_error "Emit: Imove" ++ end ++ | Lop(Iconst_int n) -> ++ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` ++ | Lop(Iconst_float f) -> ++ let lbl = new_label() in ++ float_literals := (f, lbl) :: !float_literals; ++ ` fld {emit_reg i.res.(0)}, {emit_label lbl}, {emit_reg reg_tmp1}\n` ++ | Lop(Iconst_symbol s) -> ++ ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` ++ | Lop(Icall_ind {label_after = label}) -> ++ ` jalr {emit_reg i.arg.(0)}\n`; ++ record_frame ~label i.live false i.dbg ++ | Lop(Icall_imm {func; label_after = label}) -> ++ ` {emit_call func}\n`; ++ record_frame ~label i.live false i.dbg ++ | Lop(Itailcall_ind {label_after = _}) -> ++ let n = frame_size() in ++ if !contains_calls then reload_ra n; ++ emit_stack_adjustment n; ++ ` jr {emit_reg i.arg.(0)}\n` ++ | Lop(Itailcall_imm {func; label_after = _}) -> ++ if func = !function_name then begin ++ ` j {emit_label !tailrec_entry_point}\n` ++ end else begin ++ let n = frame_size() in ++ if !contains_calls then reload_ra n; ++ emit_stack_adjustment n; ++ ` {emit_tail func}\n` ++ end ++ | Lop(Iextcall{func; alloc = true; label_after = label}) -> ++ ` la {emit_reg reg_t2}, {emit_symbol func}\n`; ++ ` {emit_call "caml_c_call"}\n`; ++ record_frame ~label i.live false i.dbg ++ | Lop(Iextcall{func; alloc = false; label_after = _}) -> ++ ` {emit_call func}\n` ++ | Lop(Istackoffset n) -> ++ assert (n mod 16 = 0); ++ emit_stack_adjustment (-n); ++ stack_offset := !stack_offset + n ++ | Lop(Iload(Single, Iindexed ofs)) -> ++ ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; ++ ` fcvt.d.s {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Lop(Iload(chunk, Iindexed ofs)) -> ++ let instr = ++ match chunk with ++ | Byte_unsigned -> "lbu" ++ | Byte_signed -> "lb" ++ | Sixteen_unsigned -> "lhu" ++ | Sixteen_signed -> "lh" ++ | Thirtytwo_unsigned -> if rv64 then "lwu" else "lw" ++ | Thirtytwo_signed -> "lw" ++ | Word_int | Word_val -> lg ++ | Single -> assert false ++ | Double | Double_u -> "fld" ++ in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n` ++ | Lop(Istore(Single, Iindexed ofs, _)) -> ++ ` fmv.x.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}\n`; ++ ` fcvt.s.d {emit_reg i.arg.(0)}, {emit_reg i.arg.(0)}\n`; ++ ` fsw {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n`; ++ ` fmv.d.x {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}\n` ++ | Lop(Istore(chunk, Iindexed ofs, _)) -> ++ let instr = ++ match chunk with ++ | Byte_unsigned | Byte_signed -> "sb" ++ | Sixteen_unsigned | Sixteen_signed -> "sh" ++ | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" ++ | Word_int | Word_val -> stg ++ | Single -> assert false ++ | Double | Double_u -> "fsd" ++ in ++ ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` ++ | Lop(Ialloc {bytes = n; label_after_call_gc = label; _}) -> ++ let lbl_frame_lbl = record_frame_label ?label i.live false i.dbg in ++ let lbl_redo = new_label () in ++ let lbl_call_gc = new_label () in ++ `{emit_label lbl_redo}:\n`; ++ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, -{emit_int n}\n`; ++ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; ++ ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; ++ call_gc_sites := ++ { gc_lbl = lbl_call_gc; ++ gc_return_lbl = lbl_redo; ++ gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites ++ | Lop(Iintop(Icomp cmp)) -> ++ begin match cmp with ++ | Isigned Clt -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Isigned Cge -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Isigned Cgt -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | Isigned Cle -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Isigned Ceq | Iunsigned Ceq -> ++ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` seqz {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Isigned Cne | Iunsigned Cne -> ++ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` snez {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Iunsigned Clt -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Iunsigned Cge -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Iunsigned Cgt -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | Iunsigned Cle -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ end ++ | Lop(Iintop (Icheckbound {label_after_error = label; _})) -> ++ let lbl = bound_error_label ?label i.dbg in ++ ` bleu {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` ++ | Lop(Iintop op) -> ++ let instr = name_for_intop op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Lop(Iintop_imm(Isub, n)) -> ++ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` ++ | Lop(Iintop_imm(Icomp _, _)) -> ++ fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" ++ | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> ++ let lbl = bound_error_label ?label i.dbg in ++ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; ++ ` bleu {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ | Lop(Iintop_imm(op, n)) -> ++ let instr = name_for_intop_imm op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` ++ | Lop(Inegf | Iabsf as op) -> ++ let instr = name_for_floatop1 op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> ++ let instr = name_for_floatop2 op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Lop(Ifloatofint) -> ++ let name = if rv64 then "fcvt.d.l" else "fcvt.d.w" in ++ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Iintoffloat) -> ++ let name = if rv64 then "fcvt.l.d" else "fcvt.w.d" in ++ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, rtz\n` ++ | Lop(Ispecific sop) -> ++ let instr = name_for_specific sop in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` ++ | Lop (Iname_for_debugger _) -> ++ () ++ | Lreloadretaddr -> ++ let n = frame_size () in ++ reload_ra n ++ | Lreturn -> ++ let n = frame_size() in ++ emit_stack_adjustment n; ++ ` ret\n` ++ | Llabel lbl -> ++ `{emit_label lbl}:\n` ++ | Lbranch lbl -> ++ ` j {emit_label lbl}\n` ++ | Lcondbranch(tst, lbl) -> ++ begin match tst with ++ | Itruetest -> ++ ` bnez {emit_reg i.arg.(0)}, {emit_label lbl}\n` ++ | Ifalsetest -> ++ ` beqz {emit_reg i.arg.(0)}, {emit_label lbl}\n` ++ | Iinttest cmp -> ++ let name = match cmp with ++ | Iunsigned Ceq | Isigned Ceq -> "beq" ++ | Iunsigned Cne | Isigned Cne -> "bne" ++ | Iunsigned Cle -> "bleu" | Isigned Cle -> "ble" ++ | Iunsigned Cge -> "bgeu" | Isigned Cge -> "bge" ++ | Iunsigned Clt -> "bltu" | Isigned Clt -> "blt" ++ | Iunsigned Cgt -> "bgtu" | Isigned Cgt -> "bgt" ++ in ++ ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` ++ | Iinttest_imm _ -> ++ fatal_error "Emit.emit_instr (Iinttest_imm _)" ++ | Ifloattest cmp -> ++ let branch = ++ match cmp with ++ | CFneq | CFnlt | CFngt | CFnle | CFnge -> "beqz" ++ | CFeq | CFlt | CFgt | CFle | CFge -> "bnez" ++ in ++ begin match cmp with ++ | CFeq | CFneq -> ` feq.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | CFlt | CFnlt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | CFgt | CFngt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | CFle | CFnle -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | CFge | CFnge -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ end; ++ ` {emit_string branch} {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ | Ioddtest -> ++ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; ++ ` bnez {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ | Ieventest -> ++ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; ++ ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end ++ | Lcondbranch3(lbl0, lbl1, lbl2) -> ++ ` addi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, -1\n`; ++ begin match lbl0 with ++ | None -> () ++ | Some lbl -> ` bltz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end; ++ begin match lbl1 with ++ | None -> () ++ | Some lbl -> ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end; ++ begin match lbl2 with ++ | None -> () ++ | Some lbl -> ` bgtz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end ++ | Lswitch jumptbl -> (* FIXME FIXME ? *) ++ let lbl = new_label() in ++ ` la {emit_reg reg_tmp1}, {emit_label lbl}\n`; ++ ` slli {emit_reg reg_tmp2}, {emit_reg i.arg.(0)}, 2\n`; ++ ` add {emit_reg reg_tmp1}, {emit_reg reg_tmp1}, {emit_reg reg_tmp2}\n`; ++ ` jr {emit_reg reg_tmp1}\n`; ++ `{emit_label lbl}:\n`; ++ for i = 0 to Array.length jumptbl - 1 do ++ ` j {emit_label jumptbl.(i)}\n` ++ done ++ | Lentertrap -> ++ () ++ | Lpushtrap {lbl_handler} -> ++ ` la {emit_reg reg_tmp1}, {emit_label lbl_handler}\n`; ++ ` addi sp, sp, -16\n`; ++ stack_offset := !stack_offset + 16; ++ ` {emit_string stg} {emit_reg reg_tmp1}, {emit_int size_addr}(sp)\n`; ++ ` {emit_string stg} {emit_reg reg_trap}, 0(sp)\n`; ++ ` mv {emit_reg reg_trap}, sp\n` ++ | Lpoptrap -> ++ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; ++ ` addi sp, sp, 16\n`; ++ stack_offset := !stack_offset - 16 ++ | Lraise k -> ++ begin match !Clflags.debug, k with ++ | true, Cmm.Raise_withtrace -> ++ ` {emit_call "caml_raise_exn"}\n`; ++ record_frame Reg.Set.empty true i.dbg ++ | false, _ ++ | true, Cmm.Raise_notrace -> ++ ` mv sp, {emit_reg reg_trap}\n`; ++ ` {emit_string lg} {emit_reg reg_tmp1}, {emit_int size_addr}(sp)\n`; ++ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; ++ ` addi sp, sp, 16\n`; ++ ` jalr {emit_reg reg_tmp1}\n` ++ end ++ ++(* Emit a sequence of instructions *) ++ ++let rec emit_all = function ++ | {desc = Lend} -> () | i -> emit_instr i; emit_all i.next ++ ++(* Emission of a function declaration *) ++ ++let fundecl fundecl = ++ function_name := fundecl.fun_name; ++ tailrec_entry_point := fundecl.fun_tailrec_entry_point_label; ++ stack_offset := 0; ++ call_gc_sites := []; ++ bound_error_sites := []; ++ float_literals := []; ++ ` .globl {emit_symbol fundecl.fun_name}\n`; ++ ` .type {emit_symbol fundecl.fun_name}, @function\n`; ++ ` {emit_string code_space}\n`; ++ ` .align 2\n`; ++ `{emit_symbol fundecl.fun_name}:\n`; ++ emit_debug_info fundecl.fun_dbg; ++ emit_all fundecl.fun_body; ++ List.iter emit_call_gc !call_gc_sites; ++ List.iter emit_call_bound_error !bound_error_sites; ++ ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; ++ (* Emit the float literals *) ++ if !float_literals <> [] then begin ++ ` {emit_string rodata_space}\n`; ++ ` .align 3\n`; ++ List.iter ++ (fun (f, lbl) -> ++ `{emit_label lbl}:\n`; ++ if rv64 ++ then emit_float64_directive ".quad" f ++ else emit_float64_split_directive ".long" f) ++ !float_literals; ++ end ++ ++(* Emission of data *) ++ ++let declare_global_data s = ++ ` .globl {emit_symbol s}\n`; ++ ` .type {emit_symbol s}, @object\n` ++ ++let emit_item = function ++ | Cglobal_symbol s -> ++ declare_global_data s ++ | Cdefine_symbol s -> ++ `{emit_symbol s}:\n`; ++ | Cint8 n -> ++ ` .byte {emit_int n}\n` ++ | Cint16 n -> ++ ` .short {emit_int n}\n` ++ | Cint32 n -> ++ ` .long {emit_nativeint n}\n` ++ | Cint n -> ++ ` {emit_string datag} {emit_nativeint n}\n` ++ | Csingle f -> ++ emit_float32_directive ".long" (Int32.bits_of_float f) ++ | Cdouble f -> ++ if rv64 ++ then emit_float64_directive ".quad" (Int64.bits_of_float f) ++ else emit_float64_split_directive ".long" (Int64.bits_of_float f) ++ | Csymbol_address s -> ++ ` {emit_string datag} {emit_symbol s}\n` ++ | Cstring s -> ++ emit_bytes_directive " .byte " s ++ | Cskip n -> ++ if n > 0 then ` .space {emit_int n}\n` ++ | Calign n -> ++ ` .align {emit_int (Misc.log2 n)}\n` ++ ++let data l = ++ ` {emit_string data_space}\n`; ++ List.iter emit_item l ++ ++(* Beginning / end of an assembly file *) ++ ++let begin_assembly() = ++ if !Clflags.dlcode || !Clflags.pic_code then ` .option pic\n`; ++ ` .file \"\"\n`; (* PR#7073 *) ++ reset_debug_info (); ++ (* Emit the beginning of the segments *) ++ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in ++ ` {emit_string data_space}\n`; ++ declare_global_data lbl_begin; ++ `{emit_symbol lbl_begin}:\n`; ++ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in ++ ` {emit_string code_space}\n`; ++ declare_global_data lbl_begin; ++ `{emit_symbol lbl_begin}:\n` ++ ++let end_assembly() = ++ ` {emit_string code_space}\n`; ++ let lbl_end = Compilenv.make_symbol (Some "code_end") in ++ declare_global_data lbl_end; ++ `{emit_symbol lbl_end}:\n`; ++ ` .long 0\n`; ++ ` {emit_string data_space}\n`; ++ let lbl_end = Compilenv.make_symbol (Some "data_end") in ++ declare_global_data lbl_end; ++ ` {emit_string datag} 0\n`; (* PR#6329 *) ++ `{emit_symbol lbl_end}:\n`; ++ ` {emit_string datag} 0\n`; ++ (* Emit the frame descriptors *) ++ ` {emit_string rodata_space}\n`; ++ let lbl = Compilenv.make_symbol (Some "frametable") in ++ declare_global_data lbl; ++ `{emit_symbol lbl}:\n`; ++ emit_frames ++ { efa_code_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); ++ efa_data_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); ++ efa_16 = (fun n -> ` .short {emit_int n}\n`); ++ efa_32 = (fun n -> ` .long {emit_int32 n}\n`); ++ efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); ++ efa_align = (fun n -> ` .align {emit_int (Misc.log2 n)}\n`); ++ efa_label_rel = (fun lbl ofs -> ++ ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); ++ efa_def_label = (fun l -> `{emit_label l}:\n`); ++ efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) ++ } +diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml +new file mode 100644 +index 000000000..0981fae73 +--- /dev/null ++++ b/asmcomp/riscv/proc.ml +@@ -0,0 +1,336 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Description of the RISC-V *) ++ ++open Misc ++open Cmm ++open Reg ++open Arch ++open Mach ++ ++(* Instruction selection *) ++ ++let word_addressed = false ++ ++(* Registers available for register allocation *) ++ ++(* Integer register map: ++ zero always zero ++ ra return address ++ sp, gp, tp stack pointer, global pointer, thread pointer (preserved by C) ++ a0 - a7 0 - 7 arguments/results ++ s2 - s9 8 - 15 arguments/results (preserved by C) ++ t2 - t6 16 - 20 temporary ++ t0 21 temporary (used by assembler) ++ t1 22 temporary (reserved for code gen) ++ s0 23 frame pointer (preserved by C) ++ s1 24 trap pointer (preserved by C) ++ s10 25 allocation pointer (preserved by C) ++ s11 26 allocation limit (preserved by C) ++ Floating-point register map: ++ ft0 - ft7 100 - 107 temporary ++ fs0 - fs1 108 - 109 general purpose (preserved by C) ++ fa0 - fa7 110 - 117 arguments/results ++ fs2 - fs9 118 - 125 arguments/results (preserved by C) ++ fs10 - fs11 126 - 127 general purpose (preserved by C) ++ ft8 - ft11 128 - 131 temporary ++*) ++ ++let int_reg_name = ++ [| "a0"; "a1"; "a2"; "a3"; "a4"; "a5"; "a6"; "a7"; ++ "s2"; "s3"; "s4"; "s5"; "s6"; "s7"; "s8"; "s9"; ++ "t2"; "t3"; "t4"; "t5"; "t6"; ++ "t0"; "t1"; ++ "s0"; "s1"; "s10"; "s11" |] ++ ++let float_reg_name = ++ [| "ft0"; "ft1"; "ft2"; "ft3"; "ft4"; "ft5"; "ft6"; "ft7"; ++ "fs0"; "fs1"; ++ "fa0"; "fa1"; "fa2"; "fa3"; "fa4"; "fa5"; "fa6"; "fa7"; ++ "fs2"; "fs3"; "fs4"; "fs5"; "fs6"; "fs7"; "fs8"; "fs9"; "fs10"; "fs11"; ++ "ft8"; "ft9"; "ft10"; "ft11" |] ++ ++let num_register_classes = 2 ++ ++let register_class r = ++ match r.typ with ++ | Val | Int | Addr -> 0 ++ | Float -> 1 ++ ++let num_available_registers = [| 21; 32 |] ++ ++let first_available_register = [| 0; 100 |] ++ ++let register_name r = ++ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) ++ ++let rotate_registers = true ++ ++(* Representation of hard registers by pseudo-registers *) ++ ++let hard_int_reg = ++ let v = Array.make 27 Reg.dummy in ++ for i = 0 to 26 do ++ v.(i) <- Reg.at_location Int (Reg i) ++ done; ++ v ++ ++let hard_float_reg = ++ let v = Array.make 32 Reg.dummy in ++ for i = 0 to 31 do ++ v.(i) <- Reg.at_location Float (Reg(100 + i)) ++ done; ++ v ++ ++let all_phys_regs = ++ Array.append hard_int_reg hard_float_reg ++ ++let phys_reg n = ++ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) ++ ++let stack_slot slot ty = ++ Reg.at_location ty (Stack slot) ++ ++(* Calling conventions *) ++ ++let calling_conventions ++ first_int last_int first_float last_float make_stack arg = ++ let loc = Array.make (Array.length arg) Reg.dummy in ++ let int = ref first_int in ++ let float = ref first_float in ++ let ofs = ref 0 in ++ for i = 0 to Array.length arg - 1 do ++ match arg.(i).typ with ++ | Val | Int | Addr as ty -> ++ if !int <= last_int then begin ++ loc.(i) <- phys_reg !int; ++ incr int ++ end else begin ++ loc.(i) <- stack_slot (make_stack !ofs) ty; ++ ofs := !ofs + size_int ++ end ++ | Float -> ++ if !float <= last_float then begin ++ loc.(i) <- phys_reg !float; ++ incr float ++ end else begin ++ loc.(i) <- stack_slot (make_stack !ofs) Float; ++ ofs := !ofs + size_float ++ end ++ done; ++ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) ++ ++let incoming ofs = Incoming ofs ++let outgoing ofs = Outgoing ofs ++let not_supported _ = fatal_error "Proc.loc_results: cannot call" ++ ++let max_arguments_for_tailcalls = 16 ++ ++let loc_spacetime_node_hole = Reg.dummy (* Spacetime unsupported *) ++ ++(* OCaml calling convention: ++ first integer args in a0 .. a7, s2 .. s9 ++ first float args in fa0 .. fa7, fs2 .. fs9 ++ remaining args on stack. ++ Return values in a0 .. a7, s2 .. s9 or fa0 .. fa7, fs2 .. fs9. *) ++ ++let single_regs arg = Array.map (fun arg -> [| arg |]) arg ++let ensure_single_regs res = ++ Array.map (function ++ | [| res |] -> res ++ | _ -> failwith "proc.ensure_single_regs" ++ ) res ++ ++let loc_arguments arg = ++ calling_conventions 0 15 110 125 outgoing arg ++ ++let loc_parameters arg = ++ let (loc, _ofs) = ++ calling_conventions 0 15 110 125 incoming arg ++ in ++ loc ++ ++let loc_results res = ++ let (loc, _ofs) = ++ calling_conventions 0 15 110 125 not_supported res ++ in ++ loc ++ ++(* C calling convention: ++ first integer args in a0 .. a7 ++ first float args in fa0 .. fa7 ++ remaining args on stack. ++ Return values in a0 .. a1 or fa0 .. fa1. *) ++ ++let external_calling_conventions ++ first_int last_int first_float last_float make_stack arg = ++ let loc = Array.make (Array.length arg) [| Reg.dummy |] in ++ let int = ref first_int in ++ let float = ref first_float in ++ let ofs = ref 0 in ++ for i = 0 to Array.length arg - 1 do ++ match arg.(i) with ++ | [| arg |] -> ++ begin match arg.typ with ++ | Val | Int | Addr as ty -> ++ if !int <= last_int then begin ++ loc.(i) <- [| phys_reg !int |]; ++ incr int; ++ incr float; ++ end else begin ++ loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; ++ ofs := !ofs + size_int ++ end ++ | Float -> ++ if !float <= last_float then begin ++ loc.(i) <- [| phys_reg !float |]; ++ incr float; ++ incr int; ++ end else begin ++ loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; ++ ofs := !ofs + size_float ++ end ++ end ++ | [| arg1; arg2 |] -> ++ (* Passing of 64-bit quantities to external functions on 32-bit ++ platform. *) ++ assert (size_int = 4); ++ begin match arg1.typ, arg2.typ with ++ | Int, Int -> ++ int := Misc.align !int 2; ++ if !int <= last_int - 1 then begin ++ let reg_lower = phys_reg !int in ++ let reg_upper = phys_reg (!int + 1) in ++ loc.(i) <- [| reg_lower; reg_upper |]; ++ int := !int + 2 ++ end else begin ++ let size_int64 = 8 in ++ ofs := Misc.align !ofs size_int64; ++ let ofs_lower = !ofs in ++ let ofs_upper = !ofs + size_int in ++ let stack_lower = stack_slot (make_stack ofs_lower) Int in ++ let stack_upper = stack_slot (make_stack ofs_upper) Int in ++ loc.(i) <- [| stack_lower; stack_upper |]; ++ ofs := !ofs + size_int64 ++ end ++ | _ -> ++ let f = function Int -> "I" | Addr -> "A" | Val -> "V" | Float -> "F" in ++ fatal_error (Printf.sprintf "Proc.calling_conventions: bad register \ ++ type(s) for multi-register argument: %s, %s" ++ (f arg1.typ) (f arg2.typ)) ++ end ++ | _ -> ++ fatal_error "Proc.calling_conventions: bad number of register for \ ++ multi-register argument" ++ done; ++ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) ++ ++let loc_external_arguments arg = ++ external_calling_conventions 0 7 110 117 outgoing arg ++ ++let loc_external_results res = ++ let (loc, _ofs) = ++ external_calling_conventions 0 1 110 111 not_supported (single_regs res) ++ in ++ ensure_single_regs loc ++ ++(* Exceptions are in GPR 3 *) ++ ++let loc_exn_bucket = phys_reg 0 ++ ++(* Volatile registers: none *) ++ ++let regs_are_volatile _ = false ++ ++(* Registers destroyed by operations *) ++ ++let destroyed_at_c_call = ++ Array.of_list(List.map phys_reg ++ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; (* 21; 22; *) ++ 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; ++ 117; 128; 129; 130; 131]) ++ ++let destroyed_at_oper = function ++ | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs ++ | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call ++ | _ -> [||] ++ ++let destroyed_at_raise = all_phys_regs ++ ++let destroyed_at_reloadretaddr = [| |] (* CHECK *) ++ ++(* Maximal register pressure *) ++ ++let safe_register_pressure = function ++ | Iextcall _ -> 15 ++ | _ -> 21 ++ ++let max_register_pressure = function ++ | Iextcall _ -> [| 15; 18 |] ++ | _ -> [| 21; 30 |] ++ ++(* Pure operations (without any side effect besides updating their result ++ registers). *) ++ ++let op_is_pure = function ++ | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ ++ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ ++ | Iintop(Icheckbound _) | Iintop_imm(Icheckbound _, _) -> false ++ | Ispecific(Imultaddf _ | Imultsubf _) -> true ++ | _ -> true ++ ++(* Layout of the stack *) ++ ++let num_stack_slots = [| 0; 0 |] ++let contains_calls = ref false ++ ++let frame_required () = ++ !contains_calls || num_stack_slots.(0) > 0 || num_stack_slots.(1) > 0 ++ ++let prologue_required () = ++ frame_required () ++ ++(* See ++ https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md *) ++ ++let int_dwarf_reg_numbers = ++ [| 10; 11; 12; 13; 14; 15; 16; 17; ++ 18; 19; 20; 21; 22; 23; 24; 25; ++ 7; 29; 29; 30; 31; ++ 5; 6; 8; 9; 26; 27; ++ |] ++ ++let float_dwarf_reg_numbers = ++ [| 32; 33; 34; 35; 36; 37; 38; 39; ++ 40; 41; ++ 42; 43; 44; 45; 46; 47; 48; 49; ++ 50; 51; 52; 53; 54; 55; 56; 57; ++ 58; 59; ++ 60; 61; 62; 63; ++ |] ++ ++let dwarf_register_numbers ~reg_class = ++ match reg_class with ++ | 0 -> int_dwarf_reg_numbers ++ | 1 -> float_dwarf_reg_numbers ++ | _ -> Misc.fatal_errorf "Bad register class %d" reg_class ++ ++let stack_ptr_dwarf_register_number = 2 ++ ++(* Calling the assembler *) ++ ++let assemble_file infile outfile = ++ Ccomp.command ++ (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) ++ ++let init () = () +diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml +new file mode 100644 +index 000000000..85b970342 +--- /dev/null ++++ b/asmcomp/riscv/reload.ml +@@ -0,0 +1,16 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Reloading for the RISC-V *) ++ ++let fundecl f = ++ (new Reloadgen.reload_generic)#fundecl f +diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml +new file mode 100644 +index 000000000..e436be1cc +--- /dev/null ++++ b/asmcomp/riscv/scheduling.ml +@@ -0,0 +1,19 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Instruction scheduling for the RISC-V *) ++ ++let _ = let module M = Schedgen in () (* to create a dependency *) ++ ++(* Scheduling is turned off. *) ++ ++let fundecl f = f +diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml +new file mode 100644 +index 000000000..62fccb648 +--- /dev/null ++++ b/asmcomp/riscv/selection.ml +@@ -0,0 +1,71 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Instruction selection for the RISC-V processor *) ++ ++open Cmm ++open Arch ++open Mach ++ ++(* Instruction selection *) ++ ++class selector = object (self) ++ ++inherit Selectgen.selector_generic as super ++ ++method is_immediate n = is_immediate n ++ ++method select_addressing _ = function ++ | Cop(Cadda, [arg; Cconst_int (n, _)], _) when self#is_immediate n -> ++ (Iindexed n, arg) ++ | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int (n, _)], _)], dbg) when self#is_immediate n -> ++ (Iindexed n, Cop(Caddi, [arg1; arg2], dbg)) ++ | arg -> ++ (Iindexed 0, arg) ++ ++method! select_operation op args dbg = ++ match (op, args) with ++ (* RISC-V does not support immediate operands for multiply high *) ++ | (Cmulhi, _) -> (Iintop Imulh, args) ++ (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) ++ | (Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3]) ++ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2], _)]) -> ++ (Ispecific (Imultaddf false), [arg1; arg2; arg3]) ++ | (Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -> ++ (Ispecific (Imultsubf false), [arg1; arg2; arg3]) ++ | (Cnegf, [Cop(Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> ++ (Ispecific (Imultsubf true), [arg1; arg2; arg3]) ++ | (Cnegf, [Cop(Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> ++ (Ispecific (Imultaddf true), [arg1; arg2; arg3]) ++ (* RISC-V does not support immediate operands for comparison operators *) ++ | (Ccmpi comp, args) -> (Iintop(Icomp (Isigned comp)), args) ++ | (Ccmpa comp, args) -> (Iintop(Icomp (Iunsigned comp)), args) ++ | (Cmuli, _) -> (Iintop Imul, args) ++ | _ -> ++ super#select_operation op args dbg ++ ++(* Instruction selection for conditionals *) ++ ++method! select_condition = function ++ Cop(Ccmpi cmp, args, _) -> ++ (Iinttest(Isigned cmp), Ctuple args) ++ | Cop(Ccmpa cmp, args, _) -> ++ (Iinttest(Iunsigned cmp), Ctuple args) ++ | Cop(Ccmpf cmp, args, _) -> ++ (Ifloattest cmp, Ctuple args) ++ | Cop(Cand, [arg; Cconst_int (1, _)], _) -> ++ (Ioddtest, arg) ++ | arg -> ++ (Itruetest, arg) ++end ++ ++let fundecl f = (new selector)#emit_fundecl f +diff --git a/configure b/configure +index c364be4e3a365e01c667023ea23238037446a3c3..75f1d15cb6847544bdf00c5fd8d12ce958072e21 100755 +GIT binary patch +delta 168 +zcmeC2qnZ?OvTGQXWV%3~J?D->52m!#&} +m=49rTR!pz&Ws}`*@R#+WI9m-^c{{%-8xXT^=NIMpWefm-I6Vgd + +delta 67 +zcmcaGS+R4HVnYjK3sVbo3(FQ(q4(40y<`>J9{!&7H7_IAbVhe}>Fw|SvOW@@t|-E$ +WI9*SajjjE^C */ ++/* */ ++/* Copyright 2017 Institut National de Recherche en Informatique et */ ++/* en Automatique. All rights reserved. This file is distributed */ ++/* under the terms of the GNU Library General Public License, with */ ++/* the special exception on linking described in file ../LICENSE. */ ++/* */ ++/***********************************************************************/ ++ ++/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ ++/* Must be preprocessed by cpp */ ++ ++#define TRAP_PTR s1 ++#define ALLOC_PTR s10 ++#define ALLOC_LIMIT s11 ++#define TMP0 t0 ++#define TMP1 t1 ++#define ARG t2 ++ ++#if defined(MODEL_riscv64) ++#define store sd ++#define load ld ++#define WSZ 8 ++#else ++#define store sw ++#define load lw ++#define WSZ 4 ++#endif ++ ++#if defined(__PIC__) ++ .option pic ++#define PLT(r) r@plt ++#else ++ .option nopic ++#define PLT(r) r ++#endif ++ ++ .section .text ++/* Invoke the garbage collector. */ ++ ++ .globl caml_system__code_begin ++caml_system__code_begin: ++ ++ .align 2 ++ .globl caml_call_gc ++ .type caml_call_gc, @function ++caml_call_gc: ++ /* Record return address */ ++ store ra, caml_last_return_address, TMP0 ++ /* Record lowest stack address */ ++ mv TMP1, sp ++ store sp, caml_bottom_of_stack, TMP0 ++.Lcaml_call_gc: ++ /* Set up stack space, saving return address */ ++ /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, 20 caller-save float regs) * 8 */ ++ /* + 1 for alignment */ ++ addi sp, sp, -0x160 ++ mv s0, sp ++ store ra, 0x8(sp) ++ store s0, 0x0(sp) ++ /* Save allocatable integer registers on the stack, ++ in the order given in proc.ml */ ++ store a0, 0x10(sp) ++ store a1, 0x18(sp) ++ store a2, 0x20(sp) ++ store a3, 0x28(sp) ++ store a4, 0x30(sp) ++ store a5, 0x38(sp) ++ store a6, 0x40(sp) ++ store a7, 0x48(sp) ++ store s2, 0x50(sp) ++ store s3, 0x58(sp) ++ store s4, 0x60(sp) ++ store s5, 0x68(sp) ++ store s6, 0x70(sp) ++ store s7, 0x78(sp) ++ store s8, 0x80(sp) ++ store s9, 0x88(sp) ++ store t2, 0x90(sp) ++ store t3, 0x98(sp) ++ store t4, 0xa0(sp) ++ store t5, 0xa8(sp) ++ store t6, 0xb0(sp) ++ /* Save caller-save floating-point registers on the stack ++ (callee-saves are preserved by caml_garbage_collection) */ ++ fsd ft0, 0xb8(sp) ++ fsd ft1, 0xc0(sp) ++ fsd ft2, 0xc8(sp) ++ fsd ft3, 0xd0(sp) ++ fsd ft4, 0xd8(sp) ++ fsd ft5, 0xe0(sp) ++ fsd ft6, 0xe8(sp) ++ fsd ft7, 0xf0(sp) ++ fsd fa0, 0xf8(sp) ++ fsd fa1, 0x100(sp) ++ fsd fa2, 0x108(sp) ++ fsd fa3, 0x110(sp) ++ fsd fa4, 0x118(sp) ++ fsd fa5, 0x120(sp) ++ fsd fa6, 0x128(sp) ++ fsd fa7, 0x130(sp) ++ fsd ft8, 0x138(sp) ++ fsd ft9, 0x140(sp) ++ fsd ft9, 0x148(sp) ++ fsd ft10, 0x150(sp) ++ fsd ft11, 0x158(sp) ++ /* Store pointer to saved integer registers in caml_gc_regs */ ++ addi TMP1, sp, 16 ++ store TMP1, caml_gc_regs, TMP0 ++ /* Save current allocation pointer for debugging purposes */ ++ store ALLOC_PTR, caml_young_ptr, TMP0 ++ /* Save trap pointer in case an exception is raised during GC */ ++ store TRAP_PTR, caml_exception_pointer, TMP0 ++ /* Call the garbage collector */ ++ call PLT(caml_garbage_collection) ++ /* Restore registers */ ++ load a0, 0x10(sp) ++ load a1, 0x18(sp) ++ load a2, 0x20(sp) ++ load a3, 0x28(sp) ++ load a4, 0x30(sp) ++ load a5, 0x38(sp) ++ load a6, 0x40(sp) ++ load a7, 0x48(sp) ++ load s2, 0x50(sp) ++ load s3, 0x58(sp) ++ load s4, 0x60(sp) ++ load s5, 0x68(sp) ++ load s6, 0x70(sp) ++ load s7, 0x78(sp) ++ load s8, 0x80(sp) ++ load s9, 0x88(sp) ++ load t2, 0x90(sp) ++ load t3, 0x98(sp) ++ load t4, 0xa0(sp) ++ load t5, 0xa8(sp) ++ load t6, 0xb0(sp) ++ fld ft0, 0xb8(sp) ++ fld ft1, 0xc0(sp) ++ fld ft2, 0xc8(sp) ++ fld ft3, 0xd0(sp) ++ fld ft4, 0xd8(sp) ++ fld ft5, 0xe0(sp) ++ fld ft6, 0xe8(sp) ++ fld ft7, 0xf0(sp) ++ fld fa0, 0xf8(sp) ++ fld fa1, 0x100(sp) ++ fld fa2, 0x108(sp) ++ fld fa3, 0x110(sp) ++ fld fa4, 0x118(sp) ++ fld fa5, 0x120(sp) ++ fld fa6, 0x128(sp) ++ fld fa7, 0x130(sp) ++ fld ft8, 0x138(sp) ++ fld ft9, 0x140(sp) ++ fld ft9, 0x148(sp) ++ fld ft10, 0x150(sp) ++ fld ft11, 0x158(sp) ++ /* Reload new allocation pointer and allocation limit */ ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ /* Free stack space and return to caller */ ++ load ra, 0x8(sp) ++ load s0, 0x0(sp) ++ addi sp, sp, 0x160 ++ ret ++ .size caml_call_gc, .-caml_call_gc ++ ++/* Call a C function from OCaml */ ++/* Function to call is in ARG */ ++ ++ .align 2 ++ .globl caml_c_call ++ .type caml_c_call, @function ++caml_c_call: ++ /* Preserve return address in callee-save register s2 */ ++ mv s2, ra ++ /* Record lowest stack address and return address */ ++ store ra, caml_last_return_address, TMP0 ++ store sp, caml_bottom_of_stack, TMP0 ++ /* Make the exception handler alloc ptr available to the C code */ ++ store ALLOC_PTR, caml_young_ptr, TMP0 ++ store TRAP_PTR, caml_exception_pointer, TMP0 ++ /* Call the function */ ++ jalr ARG ++ /* Reload alloc ptr and alloc limit */ ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ /* Return */ ++ jr s2 ++ .size caml_c_call, .-caml_c_call ++ ++/* Raise an exception from OCaml */ ++ .align 2 ++ .globl caml_raise_exn ++ .type caml_raise_exn, @function ++caml_raise_exn: ++ /* Test if backtrace is active */ ++ load TMP1, caml_backtrace_active ++ bnez TMP1, 2f ++1: /* Cut stack at current trap handler */ ++ mv sp, TRAP_PTR ++ /* Pop previous handler and jump to it */ ++ load TMP1, 8(sp) ++ load TRAP_PTR, 0(sp) ++ addi sp, sp, 16 ++ jr TMP1 ++2: /* Preserve exception bucket in callee-save register s2 */ ++ mv s2, a0 ++ /* Stash the backtrace */ ++ mv a1, ra ++ mv a2, sp ++ mv a3, TRAP_PTR ++ call PLT(caml_stash_backtrace) ++ /* Restore exception bucket and raise */ ++ mv a0, s2 ++ j 1b ++ .size caml_raise_exn, .-caml_raise_exn ++ ++ .globl caml_reraise_exn ++ .type caml_reraise_exn, @function ++ ++/* Raise an exception from C */ ++ ++ .align 2 ++ .globl caml_raise_exception ++ .type caml_raise_exception, @function ++caml_raise_exception: ++ load TRAP_PTR, caml_exception_pointer ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ load TMP1, caml_backtrace_active ++ bnez TMP1, 2f ++1: /* Cut stack at current trap handler */ ++ mv sp, TRAP_PTR ++ load TMP1, 8(sp) ++ load TRAP_PTR, 0(sp) ++ addi sp, sp, 16 ++ jr TMP1 ++2: /* Preserve exception bucket in callee-save register s2 */ ++ mv s2, a0 ++ load a1, caml_last_return_address ++ load a2, caml_bottom_of_stack ++ mv a3, TRAP_PTR ++ call PLT(caml_stash_backtrace) ++ mv a0, s2 ++ j 1b ++ .size caml_raise_exception, .-caml_raise_exception ++ ++/* Start the OCaml program */ ++ ++ .align 2 ++ .globl caml_start_program ++ .type caml_start_program, @function ++caml_start_program: ++ ++ la ARG, caml_program ++ /* Code shared with caml_callback* */ ++ /* Address of OCaml code to call is in ARG */ ++ /* Arguments to the OCaml code are in a0 ... a7 */ ++.Ljump_to_caml: ++ /* Set up stack frame and save callee-save registers */ ++ addi sp, sp, -0xd0 ++ store ra, 0xc0(sp) ++ store s0, 0x0(sp) ++ store s1, 0x8(sp) ++ store s2, 0x10(sp) ++ store s3, 0x18(sp) ++ store s4, 0x20(sp) ++ store s5, 0x28(sp) ++ store s6, 0x30(sp) ++ store s7, 0x38(sp) ++ store s8, 0x40(sp) ++ store s9, 0x48(sp) ++ store s10, 0x50(sp) ++ store s11, 0x58(sp) ++ fsd fs0, 0x60(sp) ++ fsd fs1, 0x68(sp) ++ fsd fs2, 0x70(sp) ++ fsd fs3, 0x78(sp) ++ fsd fs4, 0x80(sp) ++ fsd fs5, 0x88(sp) ++ fsd fs6, 0x90(sp) ++ fsd fs7, 0x98(sp) ++ fsd fs8, 0xa0(sp) ++ fsd fs9, 0xa8(sp) ++ fsd fs10, 0xb0(sp) ++ fsd fs11, 0xb8(sp) ++ addi sp, sp, -32 ++ /* Setup a callback link on the stack */ ++ load TMP1, caml_bottom_of_stack ++ store TMP1, 0(sp) ++ load TMP1, caml_last_return_address ++ store TMP1, 8(sp) ++ load TMP1, caml_gc_regs ++ store TMP1, 16(sp) ++ /* set up a trap frame */ ++ addi sp, sp, -16 ++ load TMP1, caml_exception_pointer ++ store TMP1, 0(sp) ++ lla TMP0, .Ltrap_handler ++ store TMP0, 8(sp) ++ mv TRAP_PTR, sp ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ store x0, caml_last_return_address, TMP0 ++ jalr ARG ++.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ ++ load TMP1, 0(sp) ++ store TMP1, caml_exception_pointer, TMP0 ++ addi sp, sp, 16 ++.Lreturn_result: /* pop callback link, restoring global variables */ ++ load TMP1, 0(sp) ++ store TMP1, caml_bottom_of_stack, TMP0 ++ load TMP1, 8(sp) ++ store TMP1, caml_last_return_address, TMP0 ++ load TMP1, 16(sp) ++ store TMP1, caml_gc_regs, TMP0 ++ addi sp, sp, 32 ++ /* Update allocation pointer */ ++ store ALLOC_PTR, caml_young_ptr, TMP0 ++ /* reload callee-save registers and return */ ++ load ra, 0xc0(sp) ++ load s0, 0x0(sp) ++ load s1, 0x8(sp) ++ load s2, 0x10(sp) ++ load s3, 0x18(sp) ++ load s4, 0x20(sp) ++ load s5, 0x28(sp) ++ load s6, 0x30(sp) ++ load s7, 0x38(sp) ++ load s8, 0x40(sp) ++ load s9, 0x48(sp) ++ load s10, 0x50(sp) ++ load s11, 0x58(sp) ++ fld fs0, 0x60(sp) ++ fld fs1, 0x68(sp) ++ fld fs2, 0x70(sp) ++ fld fs3, 0x78(sp) ++ fld fs4, 0x80(sp) ++ fld fs5, 0x88(sp) ++ fld fs6, 0x90(sp) ++ fld fs7, 0x98(sp) ++ fld fs8, 0xa0(sp) ++ fld fs9, 0xa8(sp) ++ fld fs10, 0xb0(sp) ++ fld fs11, 0xb8(sp) ++ addi sp, sp, 0xd0 ++ ret ++.Ltrap_handler: ++ store TRAP_PTR, caml_exception_pointer, TMP0 ++ ori a0, a0, 2 ++ j .Lreturn_result ++ .size caml_start_program, .-caml_start_program ++ ++/* Callback from C to OCaml */ ++ ++ .align 2 ++ .globl caml_callback_exn ++ .type caml_callback_exn, @function ++caml_callback_exn: ++ /* Initial shuffling of arguments (a0 = closure, a1 = first arg) */ ++ mv TMP1, a0 ++ mv a0, a1 /* a0 = first arg */ ++ mv a1, TMP1 /* a1 = closure environment */ ++ load ARG, 0(TMP1) /* code pointer */ ++ j .Ljump_to_caml ++ .size caml_callback_exn, .-caml_callback_exn ++ ++ .align 2 ++ .globl caml_callback2_exn ++ .type caml_callback2_exn, @function ++caml_callback2_exn: ++ /* Initial shuffling of arguments (a0 = closure, a1 = arg1, a2 = arg2) */ ++ mv TMP1, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, TMP1 ++ la ARG, caml_apply2 ++ j .Ljump_to_caml ++ .size caml_callback2_exn, .-caml_callback2_exn ++ ++ .align 2 ++ .globl caml_callback3_exn ++ .type caml_callback3_exn, @function ++caml_callback3_exn: ++ /* Initial shuffling of argumnets */ ++ /* (a0 = closure, a1 = arg1, a2 = arg2, a3 = arg3) */ ++ mv TMP1, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, a3 ++ mv a3, TMP1 ++ la ARG, caml_apply3 ++ j .Ljump_to_caml ++ .size caml_callback3_exn, .-caml_callback3_exn ++ ++ .align 2 ++ .globl caml_ml_array_bound_error ++ .type caml_ml_array_bound_error, @function ++caml_ml_array_bound_error: ++ /* Load address of [caml_array_bound_error] in ARG */ ++ la ARG, caml_array_bound_error ++ /* Call that function */ ++ tail caml_c_call ++ .size caml_ml_array_bound_error, .-caml_ml_array_bound_error ++ ++ .globl caml_system__code_end ++caml_system__code_end: ++ ++/* GC roots for callback */ ++ ++ .section .data ++ .align 3 ++ .globl caml_system__frametable ++ .type caml_system__frametable, @object ++caml_system__frametable: ++ .quad 1 /* one descriptor */ ++ .quad .Lcaml_retaddr /* return address into callback */ ++ .short -1 /* negative frame size => use callback link */ ++ .short 0 /* no roots */ ++ .align 3 ++ .size caml_system__frametable, .-caml_system__frametable +diff --git a/testsuite/tools/asmgen_riscv.S b/testsuite/tools/asmgen_riscv.S +new file mode 100644 +index 000000000..8b34a40f8 +--- /dev/null ++++ b/testsuite/tools/asmgen_riscv.S +@@ -0,0 +1,87 @@ ++/***********************************************************************/ ++/* */ ++/* OCaml */ ++/* */ ++/* Nicolas Ojeda Bar */ ++/* */ ++/* Copyright 2019 Institut National de Recherche en Informatique et */ ++/* en Automatique. All rights reserved. This file is distributed */ ++/* under the terms of the GNU Library General Public License, with */ ++/* the special exception on linking described in file ../LICENSE. */ ++/* */ ++/***********************************************************************/ ++ ++#define STORE sd ++#define LOAD ld ++ ++ .globl call_gen_code ++ .align 2 ++call_gen_code: ++ /* Set up stack frame and save callee-save registers */ ++ ADDI sp, sp, -208 ++ STORE ra, 192(sp) ++ STORE s0, 0(sp) ++ STORE s1, 8(sp) ++ STORE s2, 16(sp) ++ STORE s3, 24(sp) ++ STORE s4, 32(sp) ++ STORE s5, 40(sp) ++ STORE s6, 48(sp) ++ STORE s7, 56(sp) ++ STORE s8, 64(sp) ++ STORE s9, 72(sp) ++ STORE s10, 80(sp) ++ STORE s11, 88(sp) ++ fsd fs0, 96(sp) ++ fsd fs1, 104(sp) ++ fsd fs2, 112(sp) ++ fsd fs3, 120(sp) ++ fsd fs4, 128(sp) ++ fsd fs5, 136(sp) ++ fsd fs6, 144(sp) ++ fsd fs7, 152(sp) ++ fsd fs8, 160(sp) ++ fsd fs9, 168(sp) ++ fsd fs10, 176(sp) ++ fsd fs11, 184(sp) ++ /* Shuffle arguments */ ++ mv t0, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, a3 ++ mv a3, a4 ++ /* Call generated asm */ ++ jalr t0 ++ /* Reload callee-save registers and return address */ ++ LOAD ra, 192(sp) ++ LOAD s0, 0(sp) ++ LOAD s1, 8(sp) ++ LOAD s2, 16(sp) ++ LOAD s3, 24(sp) ++ LOAD s4, 32(sp) ++ LOAD s5, 40(sp) ++ LOAD s6, 48(sp) ++ LOAD s7, 56(sp) ++ LOAD s8, 64(sp) ++ LOAD s9, 72(sp) ++ LOAD s10, 80(sp) ++ LOAD s11, 88(sp) ++ fld fs0, 96(sp) ++ fld fs1, 104(sp) ++ fld fs2, 112(sp) ++ fld fs3, 120(sp) ++ fld fs4, 128(sp) ++ fld fs5, 136(sp) ++ fld fs6, 144(sp) ++ fld fs7, 152(sp) ++ fld fs8, 160(sp) ++ fld fs9, 168(sp) ++ fld fs10, 176(sp) ++ fld fs11, 184(sp) ++ addi sp, sp, 208 ++ ret ++ ++ .globl caml_c_call ++ .align 2 ++caml_c_call: ++ jr t2 +-- +2.23.0 + diff --git a/ocaml.spec b/ocaml.spec index bb793d0..d994957 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -30,7 +30,7 @@ #global rcver +rc2 Name: ocaml -Version: 4.08.1 +Version: 4.09.0 Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -39,7 +39,7 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org -Source0: http://caml.inria.fr/pub/distrib/ocaml-4.08/ocaml-%{version}%{rcver}.tar.xz +Source0: http://caml.inria.fr/pub/distrib/ocaml-4.09/ocaml-%{version}%{rcver}.tar.xz # IMPORTANT NOTE: # @@ -50,21 +50,29 @@ Source0: http://caml.inria.fr/pub/distrib/ocaml-4.08/ocaml-%{version}%{rc # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-32-4.08.1 +# Current branch: fedora-32-4.09.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. # +# Upstream patches after 4.09.0 was released. +Patch0001: 0001-increment-version-number-after-tagging-4.09.0.patch +Patch0002: 0002-mark-the-release-in-the-Changes.patch +Patch0003: 0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch +Patch0004: 0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch +Patch0005: 0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch +Patch0006: 0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch +Patch0007: 0007-Fix-failure-to-install-tools-links.patch +Patch0008: 0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch # Fedora-specific downstream patches. -Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch -Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch -Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch +Patch0009: 0009-Don-t-add-rpaths-to-libraries.patch +Patch0010: 0010-configure-Allow-user-defined-C-compiler-flags.patch +Patch0011: 0011-configure-Remove-incorrect-assumption-about-cross-co.patch # Out of tree patch for RISC-V support. # https://github.com/nojb/riscv-ocaml -Patch0004: 0004-Add-RISC-V-backend.patch -Patch0005: 0005-riscv-Emit-debug-info.patch +Patch0012: 0012-Add-riscv64-backend.patch BuildRequires: gcc BuildRequires: autoconf @@ -381,6 +389,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Thu Dec 05 2019 Richard W.M. Jones - 4.09.0-1 +- OCaml 4.09.0 final. + * Fri Aug 16 2019 Richard W.M. Jones - 4.08.1-1 - OCaml 4.08.1 final. diff --git a/sources b/sources index af4a53c..79a0e77 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.08.1.tar.xz) = ebcc065c4cc4bf16256c6dad6795d9660d355c5facbe432591811dc4aa02af6498899219ec4e786358dffcfc38c68f5af2d1c3787d418a78732ec37e84a28cd4 +SHA512 (ocaml-4.09.0.tar.xz) = 5cd745802ee53ab85ee676a20fbb28985ba68965df1d7242de5763d982b0a744951da742615fe478c4d3c98b34531632e3a71de89da6c717ccd90cc01e6fff26 From 14856c2d7f4a0a41ba7078fff10c56f283534742 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Dec 2019 13:08:57 +0000 Subject: [PATCH 03/91] Use autosetup, remove old setup line. --- ocaml.spec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index d994957..29c37ff 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -74,6 +74,7 @@ Patch0011: 0011-configure-Remove-incorrect-assumption-about-cross-co.patch # https://github.com/nojb/riscv-ocaml Patch0012: 0012-Add-riscv64-backend.patch +BuildRequires: git BuildRequires: gcc BuildRequires: autoconf BuildRequires: binutils-devel @@ -186,8 +187,7 @@ may not be portable between versions. %prep -%setup -q -T -b 0 -n %{name}-%{version}%{rcver} -%autopatch -p1 +%autosetup -S git -n %{name}-%{version}%{rcver} # Patches touch configure.ac, so rebuild it: autoconf --force @@ -391,6 +391,7 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog * Thu Dec 05 2019 Richard W.M. Jones - 4.09.0-1 - OCaml 4.09.0 final. +- Use autosetup, remove old setup line. * Fri Aug 16 2019 Richard W.M. Jones - 4.08.1-1 - OCaml 4.08.1 final. From 2f37856e84bdab79f08febb8fc79a86ea850b761 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Dec 2019 13:56:30 +0000 Subject: [PATCH 04/91] Remove ocamloptp binaries. Rename target_camlheader[di] -> camlheader[di] files. Remove vmthreads - old threading library which is no longer built. Remove x11 subpackage which is obsolete. Reenable required tests on aarch64, ppc64le and x86_64. --- ocaml.spec | 46 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 29c37ff..7d7e3db 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -20,8 +20,7 @@ %global test_arches aarch64 %{power64} 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 -%global test_arches_required NONE +%global test_arches_required aarch64 ppc64le x86_64 # Architectures where parallel builds fail. #%global no_parallel_build_arches aarch64 @@ -83,15 +82,6 @@ BuildRequires: gdbm-devel BuildRequires: gawk BuildRequires: perl-interpreter BuildRequires: util-linux -BuildRequires: libICE-devel -BuildRequires: libSM-devel -BuildRequires: libX11-devel -BuildRequires: libXaw-devel -BuildRequires: libXext-devel -BuildRequires: libXft-devel -BuildRequires: libXmu-devel -BuildRequires: libXrender-devel -BuildRequires: libXt-devel BuildRequires: chrpath Requires: gcc @@ -141,15 +131,6 @@ Requires: ocaml = %{version}-%{release} Source code for OCaml libraries. -%package x11 -Summary: X11 support for OCaml -Requires: ocaml-runtime = %{version}-%{release} -Requires: libX11-devel - -%description x11 -X11 support for OCaml. - - %package ocamldoc Summary: Documentation generator for OCaml Requires: ocaml = %{version}-%{release} @@ -261,7 +242,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_bindir}/ocamlmklib %{_bindir}/ocamlmktop %{_bindir}/ocamlobjinfo -%{_bindir}/ocamloptp %{_bindir}/ocamlprof # bytecode versions @@ -272,7 +252,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_bindir}/ocamlmklib.byte %{_bindir}/ocamlmktop.byte %{_bindir}/ocamlobjinfo.byte -%{_bindir}/ocamloptp.byte %{_bindir}/ocamlprof.byte %if %{native_compiler} @@ -284,7 +263,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_bindir}/ocamlmklib.opt %{_bindir}/ocamlmktop.opt %{_bindir}/ocamlobjinfo.opt -%{_bindir}/ocamloptp.opt %{_bindir}/ocamlprof.opt %endif @@ -315,8 +293,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_libdir}/ocaml/*.mli %{_libdir}/ocaml/libcamlrun_shared.so %{_libdir}/ocaml/objinfo_helper -%{_libdir}/ocaml/vmthreads/*.mli -%{_libdir}/ocaml/vmthreads/*.a %{_libdir}/ocaml/threads/*.mli %if %{native_compiler} %{_libdir}/ocaml/threads/*.a @@ -324,7 +300,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_libdir}/ocaml/threads/*.cmx %endif %{_libdir}/ocaml/caml -%exclude %{_libdir}/ocaml/graphicsX11.mli %files runtime @@ -337,17 +312,13 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_libdir}/ocaml/*.cmo %{_libdir}/ocaml/*.cmi %{_libdir}/ocaml/*.cma +%{_libdir}/ocaml/camlheaderd +%{_libdir}/ocaml/camlheaderi %{_libdir}/ocaml/stublibs -%{_libdir}/ocaml/target_camlheaderd -%{_libdir}/ocaml/target_camlheaderi -%dir %{_libdir}/ocaml/vmthreads -%{_libdir}/ocaml/vmthreads/*.cmi -%{_libdir}/ocaml/vmthreads/*.cma %dir %{_libdir}/ocaml/threads %{_libdir}/ocaml/threads/*.cmi %{_libdir}/ocaml/threads/*.cma %{_libdir}/ocaml/fedora-ocaml-release -%exclude %{_libdir}/ocaml/graphicsX11.cmi %files source @@ -355,12 +326,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_libdir}/ocaml/*.ml -%files x11 -%doc LICENSE -%{_libdir}/ocaml/graphicsX11.cmi -%{_libdir}/ocaml/graphicsX11.mli - - %files ocamldoc %doc LICENSE %doc ocamldoc/Changes.txt @@ -392,6 +357,11 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete * Thu Dec 05 2019 Richard W.M. Jones - 4.09.0-1 - OCaml 4.09.0 final. - Use autosetup, remove old setup line. +- Remove ocamloptp binaries. +- Rename target_camlheader[di] -> camlheader[di] files. +- Remove vmthreads - old threading library which is no longer built. +- Remove x11 subpackage which is obsolete. +- Reenable required tests on aarch64, ppc64le and x86_64. * Fri Aug 16 2019 Richard W.M. Jones - 4.08.1-1 - OCaml 4.08.1 final. From 6dcdd9e9c2353bf50009d53a7334bf6b08fad78d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Dec 2019 14:44:55 +0000 Subject: [PATCH 05/91] Disable required tests again, these always fail. --- ocaml.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 7d7e3db..2e4666b 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -20,7 +20,8 @@ %global test_arches aarch64 %{power64} 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 +#global test_arches_required aarch64 ppc64le x86_64 +%global test_arches_required NONE # Architectures where parallel builds fail. #%global no_parallel_build_arches aarch64 @@ -361,7 +362,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete - Rename target_camlheader[di] -> camlheader[di] files. - Remove vmthreads - old threading library which is no longer built. - Remove x11 subpackage which is obsolete. -- Reenable required tests on aarch64, ppc64le and x86_64. * Fri Aug 16 2019 Richard W.M. Jones - 4.08.1-1 - OCaml 4.08.1 final. From ab47d2524d5989d0857a12153335ce80b1a454e6 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Dec 2019 15:52:23 +0000 Subject: [PATCH 06/91] Further fixes to CFLAGS and annobin. --- ...-Allow-user-defined-C-compiler-flags.patch | 6 ++--- ...-incorrect-assumption-about-cross-co.patch | 26 +++++++++++++++---- 0012-Add-riscv64-backend.patch | 10 +++---- ocaml.spec | 21 ++++++++++++++- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/0010-configure-Allow-user-defined-C-compiler-flags.patch b/0010-configure-Allow-user-defined-C-compiler-flags.patch index 7d532d4..34ff372 100644 --- a/0010-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0010-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,4 +1,4 @@ -From f1c04c17f5b42a969cbf3119ebbb851e799d664d Mon Sep 17 00:00:00 2001 +From aab08177e52b9951b5e95c949c7b61c690a0efd7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 Subject: [PATCH 10/12] configure: Allow user defined C compiler flags. @@ -8,7 +8,7 @@ Subject: [PATCH 10/12] configure: Allow user defined C compiler flags. 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index c2f185373..12d9f6cde 100644 +index c2f185373..547640906 100644 --- a/configure.ac +++ b/configure.ac @@ -549,6 +549,10 @@ AS_CASE([$host], @@ -17,7 +17,7 @@ index c2f185373..12d9f6cde 100644 +# Allow CFLAGS and LDFLAGS to be added. +common_cflags="$common_cflags $CFLAGS" -+oc_ldflags="$oc_ldflags $LDFLAGS" ++cclibs="$cclibs $LDFLAGS" + internal_cppflags="-DCAML_NAME_SPACE $internal_cppflags" diff --git a/0011-configure-Remove-incorrect-assumption-about-cross-co.patch b/0011-configure-Remove-incorrect-assumption-about-cross-co.patch index d7ab72d..f2743cf 100644 --- a/0011-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0011-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,4 +1,4 @@ -From 3432e0eb653e670025642b6e40e2d4a2eb4c28ae Mon Sep 17 00:00:00 2001 +From 272b31bbd8c35a613f035465441ac5a34de8450e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 Subject: [PATCH 11/12] configure: Remove incorrect assumption about @@ -6,14 +6,30 @@ Subject: [PATCH 11/12] configure: Remove incorrect assumption about See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 --- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + configure.ac | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 12d9f6cde..e85cc9ffa 100644 +index 547640906..9ee8dcaae 100644 --- a/configure.ac +++ b/configure.ac -@@ -927,7 +927,7 @@ AS_IF([test $arch != "none" && $arch64 ], +@@ -461,10 +461,11 @@ AS_IF( + + # Are we building a cross-compiler + +-AS_IF( +- [test x"$host" = x"$target"], +- [cross_compiler=false], +- [cross_compiler=true]) ++#AS_IF( ++# [test x"$host" = x"$target"], ++# [cross_compiler=false], ++# [cross_compiler=true]) ++cross_compiler=false + + # Checks for programs + +@@ -927,7 +928,7 @@ AS_IF([test $arch != "none" && $arch64 ], # Assembler diff --git a/0012-Add-riscv64-backend.patch b/0012-Add-riscv64-backend.patch index 5883ba8..7666e22 100644 --- a/0012-Add-riscv64-backend.patch +++ b/0012-Add-riscv64-backend.patch @@ -1,4 +1,4 @@ -From a861b131c28af6b313c7e778e2b6712e6b6fa5f2 Mon Sep 17 00:00:00 2001 +From 46230ada6483449154c465243edd80d9e539b73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Mon, 18 Nov 2019 01:13:30 +0100 Subject: [PATCH 12/12] Add riscv64 backend @@ -1330,10 +1330,10 @@ zcmcaGS+R4HVnYjK3sVbo3(FQ(q4(40y<`>J9{!&7H7_IAbVhe}>Fw|SvOW@@t|-E$ WI9*SajjjE^C hello.ml +./ocamlopt.opt -verbose -I stdlib hello.ml -o hello ||: +annocheck -v hello ||: +%endif + %ifarch %{test_arches} cd testsuite @@ -362,6 +380,7 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete - Rename target_camlheader[di] -> camlheader[di] files. - Remove vmthreads - old threading library which is no longer built. - Remove x11 subpackage which is obsolete. +- Further fixes to CFLAGS and annobin. * Fri Aug 16 2019 Richard W.M. Jones - 4.08.1-1 - OCaml 4.08.1 final. From 54390d6011a662e771f7d87508003d8b3c8ca78b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Dec 2019 18:09:05 +0000 Subject: [PATCH 07/91] Reset the version number back to 4.09.0. So we generate ocaml(runtime) = 4.09.0 dependency correctly. --- ...-version-number-after-tagging-4.09.0.patch | 2 +- 0002-mark-the-release-in-the-Changes.patch | 2 +- ...st-8954-from-Armael-fix-toplevel-sub.patch | 2 +- ...st-8979-from-gasche-fix-Makefile.men.patch | 2 +- ...e-of-gen_primitives.sh-with-LC_ALL-C.patch | 2 +- ...est-8988-from-Octachron-fix_ocamlnat.patch | 2 +- 0007-Fix-failure-to-install-tools-links.patch | 2 +- ...uest-8996-from-dra27-win-reconfigure.patch | 2 +- 0009-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...-incorrect-assumption-about-cross-co.patch | 2 +- 0012-Add-riscv64-backend.patch | 2 +- ...-version-number-after-tagging-4.09.0.patch | 41 +++++++++++++++++++ ocaml.spec | 6 ++- 14 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 0013-Revert-increment-version-number-after-tagging-4.09.0.patch diff --git a/0001-increment-version-number-after-tagging-4.09.0.patch b/0001-increment-version-number-after-tagging-4.09.0.patch index 646daeb..108de03 100644 --- a/0001-increment-version-number-after-tagging-4.09.0.patch +++ b/0001-increment-version-number-after-tagging-4.09.0.patch @@ -1,7 +1,7 @@ From 6207460e793f8c5538bfd8164fa3078f7300b57a Mon Sep 17 00:00:00 2001 From: Florian Angeletti Date: Tue, 17 Sep 2019 14:35:00 +0200 -Subject: [PATCH 01/12] increment version number after tagging 4.09.0 +Subject: [PATCH 01/13] increment version number after tagging 4.09.0 --- VERSION | 2 +- diff --git a/0002-mark-the-release-in-the-Changes.patch b/0002-mark-the-release-in-the-Changes.patch index 78a91d2..b004485 100644 --- a/0002-mark-the-release-in-the-Changes.patch +++ b/0002-mark-the-release-in-the-Changes.patch @@ -1,7 +1,7 @@ From c1db490f8d92e7b5f1a4685cd9a095f24429bb3e Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Thu, 19 Sep 2019 15:40:49 +0200 -Subject: [PATCH 02/12] mark the release in the Changes +Subject: [PATCH 02/13] mark the release in the Changes --- Changes | 7 +++++-- diff --git a/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch b/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch index 2cb9cc4..3ddfbb1 100644 --- a/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch +++ b/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch @@ -1,7 +1,7 @@ From 1204abd71a4ef585dbb70ba68a5879856d24c1a9 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Fri, 20 Sep 2019 10:58:09 +0200 -Subject: [PATCH 03/12] Merge pull request #8954 from +Subject: [PATCH 03/13] Merge pull request #8954 from Armael/fix-toplevel-submsg-locs Fix error submessages in the toplevel: do not display dummy locations diff --git a/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch b/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch index db2e66e..406b851 100644 --- a/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch +++ b/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch @@ -1,7 +1,7 @@ From 987e819b8fb8e36e660340931270a2ade02c439e Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Thu, 26 Sep 2019 21:46:03 +0200 -Subject: [PATCH 04/12] Merge pull request #8979 from +Subject: [PATCH 04/13] Merge pull request #8979 from gasche/fix-Makefile.menhir Fix tools/check-parser-uptodate-or-warn.sh diff --git a/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch b/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch index 4865a5b..a0fb4b9 100644 --- a/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch +++ b/0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch @@ -1,7 +1,7 @@ From 3ef8ce701db0a010771c62171fc7ae355214ed05 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Thu, 26 Sep 2019 13:51:08 +0100 -Subject: [PATCH 05/12] Run whole of gen_primitives.sh with LC_ALL=C +Subject: [PATCH 05/13] Run whole of gen_primitives.sh with LC_ALL=C Fixes #8985. Assuming the locale has been generated, running LC_COLLATE=sv_SE.UTF-8 make world failed previously since the w diff --git a/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch b/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch index 0e3709a..41f5db5 100644 --- a/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch +++ b/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch @@ -1,7 +1,7 @@ From 8995e5828ebfe933b74d0c3704c0524a63c73467 Mon Sep 17 00:00:00 2001 From: Florian Angeletti Date: Fri, 27 Sep 2019 17:15:26 +0200 -Subject: [PATCH 06/12] Merge pull request #8988 from Octachron/fix_ocamlnat +Subject: [PATCH 06/13] Merge pull request #8988 from Octachron/fix_ocamlnat Fix ocamlnat diff --git a/0007-Fix-failure-to-install-tools-links.patch b/0007-Fix-failure-to-install-tools-links.patch index 5824bd8..6463c15 100644 --- a/0007-Fix-failure-to-install-tools-links.patch +++ b/0007-Fix-failure-to-install-tools-links.patch @@ -1,7 +1,7 @@ From fa36269c5752bfb8f4b65dd0f9a2dd8f9c9eeb8f Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Tue, 6 Aug 2019 09:23:06 +0100 -Subject: [PATCH 07/12] Fix failure to install tools links +Subject: [PATCH 07/13] Fix failure to install tools links In --disable-installing-bytecode-programs mode, the .opt version of the tools is installed, but the symlink for the tool itself is not created. diff --git a/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch b/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch index 56ebcde..969530f 100644 --- a/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch +++ b/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch @@ -1,7 +1,7 @@ From 308ea9a8d526160e2b45f16d63a0aee70984b814 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Sun, 29 Sep 2019 19:33:29 +0200 -Subject: [PATCH 08/12] Merge pull request #8996 from dra27/win-reconfigure +Subject: [PATCH 08/13] Merge pull request #8996 from dra27/win-reconfigure Windows supports make reconfigure now diff --git a/0009-Don-t-add-rpaths-to-libraries.patch b/0009-Don-t-add-rpaths-to-libraries.patch index f2589ba..c150f8a 100644 --- a/0009-Don-t-add-rpaths-to-libraries.patch +++ b/0009-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 065c173840d0c379c26376b1de6363736043c969 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 09/12] Don't add rpaths to libraries. +Subject: [PATCH 09/13] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- diff --git a/0010-configure-Allow-user-defined-C-compiler-flags.patch b/0010-configure-Allow-user-defined-C-compiler-flags.patch index 34ff372..2d9c5c3 100644 --- a/0010-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0010-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From aab08177e52b9951b5e95c949c7b61c690a0efd7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 10/12] configure: Allow user defined C compiler flags. +Subject: [PATCH 10/13] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ diff --git a/0011-configure-Remove-incorrect-assumption-about-cross-co.patch b/0011-configure-Remove-incorrect-assumption-about-cross-co.patch index f2743cf..9a74aea 100644 --- a/0011-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0011-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ From 272b31bbd8c35a613f035465441ac5a34de8450e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 11/12] configure: Remove incorrect assumption about +Subject: [PATCH 11/13] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 diff --git a/0012-Add-riscv64-backend.patch b/0012-Add-riscv64-backend.patch index 7666e22..7697762 100644 --- a/0012-Add-riscv64-backend.patch +++ b/0012-Add-riscv64-backend.patch @@ -1,7 +1,7 @@ From 46230ada6483449154c465243edd80d9e539b73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Mon, 18 Nov 2019 01:13:30 +0100 -Subject: [PATCH 12/12] Add riscv64 backend +Subject: [PATCH 12/13] Add riscv64 backend (cherry picked from commit c8a361f586c21eca25108ee79c495bb480a1c3f3) --- diff --git a/0013-Revert-increment-version-number-after-tagging-4.09.0.patch b/0013-Revert-increment-version-number-after-tagging-4.09.0.patch new file mode 100644 index 0000000..86ebf7e --- /dev/null +++ b/0013-Revert-increment-version-number-after-tagging-4.09.0.patch @@ -0,0 +1,41 @@ +From 76a56065047f9160b0db2491c8f303c9dee6cb59 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 5 Dec 2019 18:07:29 +0000 +Subject: [PATCH 13/13] Revert "increment version number after tagging 4.09.0" + +Downgrade version number back to 4.09.0 for Fedora. + +This reverts commit 6207460e793f8c5538bfd8164fa3078f7300b57a. +--- + VERSION | 2 +- + ocaml-variants.opam | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/VERSION b/VERSION +index ff541f87c..7128cac1f 100644 +--- a/VERSION ++++ b/VERSION +@@ -1,4 +1,4 @@ +-4.09.1+dev0 ++4.09.0 + + # The version string is the first line of this file. + # It must be in the format described in stdlib/sys.mli +diff --git a/ocaml-variants.opam b/ocaml-variants.opam +index 5410d1f4c..30d48eb24 100644 +--- a/ocaml-variants.opam ++++ b/ocaml-variants.opam +@@ -1,8 +1,8 @@ + opam-version: "2.0" +-version: "4.09.1+trunk" ++version: "4.09.0" + synopsis: "OCaml development version" + depends: [ +- "ocaml" {= "4.09.1" & post} ++ "ocaml" {= "4.09.0" & post} + "base-unix" {post} + "base-bigarray" {post} + "base-threads" {post} +-- +2.23.0 + diff --git a/ocaml.spec b/ocaml.spec index abf8161..1911150 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -73,6 +73,8 @@ Patch0011: 0011-configure-Remove-incorrect-assumption-about-cross-co.patch # Out of tree patch for RISC-V support. # https://github.com/nojb/riscv-ocaml Patch0012: 0012-Add-riscv64-backend.patch +# Resets the version number back to 4.09.0. +Patch0013: 0013-Revert-increment-version-number-after-tagging-4.09.0.patch BuildRequires: git BuildRequires: gcc @@ -373,7 +375,7 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog -* Thu Dec 05 2019 Richard W.M. Jones - 4.09.0-1 +* Thu Dec 05 2019 Richard W.M. Jones - 4.09.0-2 - OCaml 4.09.0 final. - Use autosetup, remove old setup line. - Remove ocamloptp binaries. From d9e51264fc93f2fb39c62e6976df6eed982b8e7b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 10 Dec 2019 18:24:31 +0000 Subject: [PATCH 08/91] Require redhat-rpm-config to get hardening flags when linking. --- ocaml.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 1911150..4871cca 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -88,7 +88,10 @@ BuildRequires: util-linux BuildRequires: /usr/bin/annocheck BuildRequires: chrpath +# ocamlopt runs gcc to link binaries. Because Fedora includes +# hardening flags automatically, redhat-rpm-config is also required. Requires: gcc +Requires: redhat-rpm-config # Because we pass -c flag to ocaml-find-requires (to avoid circular # dependencies) we also have to explicitly depend on the right version @@ -375,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Dec 10 2019 Richard W.M. Jones - 4.09.0-3 +- Require redhat-rpm-config to get hardening flags when linking. + * Thu Dec 05 2019 Richard W.M. Jones - 4.09.0-2 - OCaml 4.09.0 final. - Use autosetup, remove old setup line. From 47619598e95e3d2c3ab2dcf78f410d15a46d90c0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 11:54:25 +0000 Subject: [PATCH 09/91] OCaml 4.09.0 for riscv64 --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 4871cca..c1abb5d 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-4 +- OCaml 4.09.0 for riscv64 + * Tue Dec 10 2019 Richard W.M. Jones - 4.09.0-3 - Require redhat-rpm-config to get hardening flags when linking. From c6050323b471f6cd6f091a05b19bc5146b7d3594 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 12:22:13 +0000 Subject: [PATCH 10/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index c1abb5d..d8acb3e 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-5 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-4 - OCaml 4.09.0 for riscv64 From 3779563b6a185a38372b5dbec4cf5cb80d9b3dc8 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 12:24:48 +0000 Subject: [PATCH 11/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index d8acb3e..17bfb2d 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 5%{?dist} +Release: 6%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-6 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-5 - Bump release and rebuild. From 5028b94a94414e6dbc5b48882a356f5c24558951 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 12:57:19 +0000 Subject: [PATCH 12/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 17bfb2d..b5e681b 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 6%{?dist} +Release: 7%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-7 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-6 - Bump release and rebuild. From 45edde154b59409be1ef91e7084ceb2fad7ae603 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 13:18:50 +0000 Subject: [PATCH 13/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index b5e681b..38638c7 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 7%{?dist} +Release: 8%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-8 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-7 - Bump release and rebuild. From b59110214ec706aa0b0ba19826140c445adcfd80 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 13:36:53 +0000 Subject: [PATCH 14/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 38638c7..8c3b7fe 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 8%{?dist} +Release: 9%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-9 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-8 - Bump release and rebuild. From 785927384bf6b382d663ccce211ee3568fda17c5 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 13:40:04 +0000 Subject: [PATCH 15/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 8c3b7fe..94385a9 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 9%{?dist} +Release: 10%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-10 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-9 - Bump release and rebuild. From be199402b5308b74f2db39f11f6fdb2c7bff91b4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 16:39:39 +0000 Subject: [PATCH 16/91] Drop some %changelog messages left over from trying to build on riscv64. --- ocaml.spec | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 94385a9..9695fda 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 10%{?dist} +Release: 11%{?dist} Summary: OCaml compiler and programming environment @@ -378,24 +378,6 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-10 -- Bump release and rebuild. - -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-9 -- Bump release and rebuild. - -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-8 -- Bump release and rebuild. - -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-7 -- Bump release and rebuild. - -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-6 -- Bump release and rebuild. - -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-5 -- Bump release and rebuild. - * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-4 - OCaml 4.09.0 for riscv64 From d999c1ca0278d262d30b8ffd8d1a9b81f2f7f1e3 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 16:41:00 +0000 Subject: [PATCH 17/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 9695fda..292b8eb 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 11%{?dist} +Release: 12%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-12 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-4 - OCaml 4.09.0 for riscv64 From 71ffd8d2046850990b467ae441efb96194df951a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 7 Jan 2020 17:10:09 +0000 Subject: [PATCH 18/91] Bump release and rebuild. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 292b8eb..56bb1f5 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.09.0 -Release: 12%{?dist} +Release: 13%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-13 +- Bump release and rebuild. + * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-12 - Bump release and rebuild. From f986cb165c9dbca1d337a02438dcb62f4a425a84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:43:26 +0000 Subject: [PATCH 19/91] OCaml 4.10.0+beta1. --- ...> 0001-Don-t-add-rpaths-to-libraries.patch | 8 +- ...-version-number-after-tagging-4.09.0.patch | 52 --------- ...-Allow-user-defined-C-compiler-flags.patch | 10 +- 0002-mark-the-release-in-the-Changes.patch | 27 ----- ...st-8954-from-Armael-fix-toplevel-sub.patch | 46 -------- ...-incorrect-assumption-about-cross-co.patch | 12 +-- ...st-8979-from-gasche-fix-Makefile.men.patch | 102 ------------------ ...Remove-configure-from-.gitattributes.patch | 28 +++++ ...nd.patch => 0005-Add-riscv64-backend.patch | 65 +++++++---- ...e-of-gen_primitives.sh-with-LC_ALL-C.patch | 51 --------- ...est-8988-from-Octachron-fix_ocamlnat.patch | 28 ----- 0007-Fix-failure-to-install-tools-links.patch | 45 -------- ...uest-8996-from-dra27-win-reconfigure.patch | 31 ------ ...-version-number-after-tagging-4.09.0.patch | 41 ------- ocaml.spec | 36 +++---- sources | 2 +- 16 files changed, 101 insertions(+), 483 deletions(-) rename 0009-Don-t-add-rpaths-to-libraries.patch => 0001-Don-t-add-rpaths-to-libraries.patch (83%) delete mode 100644 0001-increment-version-number-after-tagging-4.09.0.patch rename 0010-configure-Allow-user-defined-C-compiler-flags.patch => 0002-configure-Allow-user-defined-C-compiler-flags.patch (71%) delete mode 100644 0002-mark-the-release-in-the-Changes.patch delete mode 100644 0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch rename 0011-configure-Remove-incorrect-assumption-about-cross-co.patch => 0003-configure-Remove-incorrect-assumption-about-cross-co.patch (77%) delete mode 100644 0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch create mode 100644 0004-Remove-configure-from-.gitattributes.patch rename 0012-Add-riscv64-backend.patch => 0005-Add-riscv64-backend.patch (97%) delete mode 100644 0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch delete mode 100644 0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch delete mode 100644 0007-Fix-failure-to-install-tools-links.patch delete mode 100644 0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch delete mode 100644 0013-Revert-increment-version-number-after-tagging-4.09.0.patch diff --git a/0009-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch similarity index 83% rename from 0009-Don-t-add-rpaths-to-libraries.patch rename to 0001-Don-t-add-rpaths-to-libraries.patch index c150f8a..c36c24b 100644 --- a/0009-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,14 +1,14 @@ -From 065c173840d0c379c26376b1de6363736043c969 Mon Sep 17 00:00:00 2001 +From 1f575196cc7c26a1edc016bca8f7ff052636186b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 09/13] Don't add rpaths to libraries. +Subject: [PATCH 1/5] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile -index 84ddd79fb..796821968 100644 +index 18aead935..e374c05ee 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -153,8 +153,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ @@ -23,5 +23,5 @@ index 84ddd79fb..796821968 100644 > ocamlmklibconfig.ml -- -2.23.0 +2.24.1 diff --git a/0001-increment-version-number-after-tagging-4.09.0.patch b/0001-increment-version-number-after-tagging-4.09.0.patch deleted file mode 100644 index 108de03..0000000 --- a/0001-increment-version-number-after-tagging-4.09.0.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 6207460e793f8c5538bfd8164fa3078f7300b57a Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Tue, 17 Sep 2019 14:35:00 +0200 -Subject: [PATCH 01/13] increment version number after tagging 4.09.0 - ---- - VERSION | 2 +- - configure | Bin 542920 -> 542985 bytes - ocaml-variants.opam | 4 ++-- - 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/VERSION b/VERSION -index 7128cac1f..ff541f87c 100644 ---- a/VERSION -+++ b/VERSION -@@ -1,4 +1,4 @@ --4.09.0 -+4.09.1+dev0 - - # The version string is the first line of this file. - # It must be in the format described in stdlib/sys.mli -diff --git a/configure b/configure -index 85fb6842dffc1ba52a07895aefa7d49f7f383d17..c364be4e3a365e01c667023ea23238037446a3c3 100755 -GIT binary patch -delta 189 -zcmX>xQL%H9;)HruL+zB*vW@kPP7u~4XE_LCvz&8XD3m#8#&>QgbMlgF5>RI5-Yp&w -z=5|>&Ml~Hauu%rn8#gjaOph^Ql!r=I8!_gwL)h&vEg6BB35c12m}UD*OIB{E&Fx>R -iS%H{s`pItkZr(8CJNM=_ORh;U8cg?LW0c>#eD4&G?G9{= -zYC1rXkJ^k9(_4%f<+raeV$5T2m$qUAVkRJF24a@&(pIe8PVL$?tU%1RUAu;T8Pjy2 -TUf=D?_3WDL+XLI!cN_u$b;&5C - -diff --git a/ocaml-variants.opam b/ocaml-variants.opam -index 30d48eb24..5410d1f4c 100644 ---- a/ocaml-variants.opam -+++ b/ocaml-variants.opam -@@ -1,8 +1,8 @@ - opam-version: "2.0" --version: "4.09.0" -+version: "4.09.1+trunk" - synopsis: "OCaml development version" - depends: [ -- "ocaml" {= "4.09.0" & post} -+ "ocaml" {= "4.09.1" & post} - "base-unix" {post} - "base-bigarray" {post} - "base-threads" {post} --- -2.23.0 - diff --git a/0010-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch similarity index 71% rename from 0010-configure-Allow-user-defined-C-compiler-flags.patch rename to 0002-configure-Allow-user-defined-C-compiler-flags.patch index 2d9c5c3..8d28bd4 100644 --- a/0010-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From aab08177e52b9951b5e95c949c7b61c690a0efd7 Mon Sep 17 00:00:00 2001 +From 122b350037d93e9f44357b215d5ecfbadb8d8fa5 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 10/13] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index c2f185373..547640906 100644 +index 90e6a041e..2f7e829e5 100644 --- a/configure.ac +++ b/configure.ac -@@ -549,6 +549,10 @@ AS_CASE([$host], +@@ -590,6 +590,10 @@ AS_CASE([$host], internal_cflags="$gcc_warnings"], [common_cflags="-O"])]) @@ -23,5 +23,5 @@ index c2f185373..547640906 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.23.0 +2.24.1 diff --git a/0002-mark-the-release-in-the-Changes.patch b/0002-mark-the-release-in-the-Changes.patch deleted file mode 100644 index b004485..0000000 --- a/0002-mark-the-release-in-the-Changes.patch +++ /dev/null @@ -1,27 +0,0 @@ -From c1db490f8d92e7b5f1a4685cd9a095f24429bb3e Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Thu, 19 Sep 2019 15:40:49 +0200 -Subject: [PATCH 02/13] mark the release in the Changes - ---- - Changes | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/Changes b/Changes -index d4b8a994d..e95ae5e49 100644 ---- a/Changes -+++ b/Changes -@@ -1,5 +1,8 @@ --OCaml 4.09.0 -------------- -+OCaml 4.09 maintenance branch: -+------------------------------ -+ -+OCaml 4.09.0 (19 September 2019): -+--------------------------------- - - (Changes that can break existing programs are marked with a "*") - --- -2.23.0 - diff --git a/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch b/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch deleted file mode 100644 index 3ddfbb1..0000000 --- a/0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 1204abd71a4ef585dbb70ba68a5879856d24c1a9 Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Fri, 20 Sep 2019 10:58:09 +0200 -Subject: [PATCH 03/13] Merge pull request #8954 from - Armael/fix-toplevel-submsg-locs - -Fix error submessages in the toplevel: do not display dummy locations - -(cherry picked from commit 8f7708a0fbc3e1199ccf04a6b9e1ba8e0f0d5254) ---- - Changes | 4 ++++ - parsing/location.ml | 3 ++- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/Changes b/Changes -index e95ae5e49..355cb1a94 100644 ---- a/Changes -+++ b/Changes -@@ -1,6 +1,10 @@ - OCaml 4.09 maintenance branch: - ------------------------------ - -+- #8953, #8954: Fix error submessages in the toplevel: do not display -+ dummy locations -+ (Armaël Guéneau, review by Gabriel Scherer) -+ - OCaml 4.09.0 (19 September 2019): - --------------------------------- - -diff --git a/parsing/location.ml b/parsing/location.ml -index 25cba42c7..ab823d36f 100644 ---- a/parsing/location.ml -+++ b/parsing/location.ml -@@ -752,7 +752,8 @@ let terminfo_toplevel_printer (lb: lexbuf): report_printer = - in - let pp_main_loc _ _ _ _ = () in - let pp_submsg_loc _ _ ppf loc = -- Format.fprintf ppf "%a:@ " print_loc loc in -+ if not loc.loc_ghost then -+ Format.fprintf ppf "%a:@ " print_loc loc in - { batch_mode_printer with pp; pp_main_loc; pp_submsg_loc } - - let best_toplevel_printer () = --- -2.23.0 - diff --git a/0011-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch similarity index 77% rename from 0011-configure-Remove-incorrect-assumption-about-cross-co.patch rename to 0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 9a74aea..a7e1df5 100644 --- a/0011-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From 272b31bbd8c35a613f035465441ac5a34de8450e Mon Sep 17 00:00:00 2001 +From 4481368be15b3dbd07c9ed8a3194194fe8594fc5 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 11/13] configure: Remove incorrect assumption about +Subject: [PATCH 3/5] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -10,10 +10,10 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 547640906..9ee8dcaae 100644 +index 2f7e829e5..ed6e0b0ca 100644 --- a/configure.ac +++ b/configure.ac -@@ -461,10 +461,11 @@ AS_IF( +@@ -505,10 +505,11 @@ AS_IF( # Are we building a cross-compiler @@ -29,7 +29,7 @@ index 547640906..9ee8dcaae 100644 # Checks for programs -@@ -927,7 +928,7 @@ AS_IF([test $arch != "none" && $arch64 ], +@@ -970,7 +971,7 @@ AS_IF([test $arch != "none" && $arch64 ], # Assembler @@ -39,5 +39,5 @@ index 547640906..9ee8dcaae 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.23.0 +2.24.1 diff --git a/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch b/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch deleted file mode 100644 index 406b851..0000000 --- a/0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 987e819b8fb8e36e660340931270a2ade02c439e Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Thu, 26 Sep 2019 21:46:03 +0200 -Subject: [PATCH 04/13] Merge pull request #8979 from - gasche/fix-Makefile.menhir - -Fix tools/check-parser-uptodate-or-warn.sh - -(cherry picked from commit f075ab6fdeedc8d53ececd1184d69a1cc35c0fd5) ---- - Changes | 3 +++ - Makefile | 6 +++--- - tools/check-parser-uptodate-or-warn.sh | 21 +++++++++++++++++---- - 3 files changed, 23 insertions(+), 7 deletions(-) - -diff --git a/Changes b/Changes -index 355cb1a94..63cac3ef9 100644 ---- a/Changes -+++ b/Changes -@@ -5,6 +5,9 @@ OCaml 4.09 maintenance branch: - dummy locations - (Armaël Guéneau, review by Gabriel Scherer) - -+- #8965, #8979: Alpine build failure caused by check-parser-uptodate-or-warn.sh -+ (Gabriel Scherer and David Allsopp, report by Anton Kochkov) -+ - OCaml 4.09.0 (19 September 2019): - --------------------------------- - -diff --git a/Makefile b/Makefile -index 47548c79d..7ac446f62 100644 ---- a/Makefile -+++ b/Makefile -@@ -1076,10 +1076,10 @@ parsing/camlinternalMenhirLib.mli: boot/menhir/menhirLib.mli - - parsing/parser.ml: boot/menhir/parser.ml parsing/parser.mly \ - tools/check-parser-uptodate-or-warn.sh -- @tools/check-parser-uptodate-or-warn.sh -- cat $< | sed "s/MenhirLib/CamlinternalMenhirLib/g" > $@ -+ @-tools/check-parser-uptodate-or-warn.sh -+ sed "s/MenhirLib/CamlinternalMenhirLib/g" $< > $@ - parsing/parser.mli: boot/menhir/parser.mli -- cat $< | sed "s/MenhirLib/CamlinternalMenhirLib/g" > $@ -+ sed "s/MenhirLib/CamlinternalMenhirLib/g" $< > $@ - - - partialclean:: partialclean-menhir -diff --git a/tools/check-parser-uptodate-or-warn.sh b/tools/check-parser-uptodate-or-warn.sh -index 5502eae54..2f07619a6 100755 ---- a/tools/check-parser-uptodate-or-warn.sh -+++ b/tools/check-parser-uptodate-or-warn.sh -@@ -15,6 +15,9 @@ - #* * - #************************************************************************** - -+# stop early if we are not on a development version -+grep -Fq '+dev' VERSION || exit 0 -+ - # We try to warn if the user edits parsing/parser.mly but forgets to - # rebuild the generated parser. Our heuristic is to use the file - # modification timestamp, but just testing -@@ -24,15 +27,20 @@ - # seconds after boot/menhir/parser.ml. - - # mtime(): access a file's last modification time as a timestamp, --# using either GNU coreutils' stat --format, or BSD/macos stat -f. -+# using either -+# GNU coreutils' stat --format, or -+# busybox's stat -c, or -+# BSD/macOS stat -f. - # Default to 0 if 'stat' is not available. - - stat . 2>/dev/null 1>/dev/null - if test $? != 0 - then MTIME="" --elif test -n "$(stat --version 2>/dev/null | grep coreutils)" -+elif stat --version 2>/dev/null | grep -Fq 'coreutils' - then MTIME="stat --format %Y" --else MTIME="stat -f %m" -+elif stat 2>&1 | grep -Fq 'busybox' -+then MTIME="stat -c %Y" -+else MTIME="stat -f %m" # BSD stat? - fi - - mtime() { -@@ -45,7 +53,12 @@ mtime() { - # The check itself - SOURCE_MTIME=$(mtime parsing/parser.mly) - GENERATED_MTIME=$(mtime boot/menhir/parser.ml) --if test $SOURCE_MTIME -gt $(( $GENERATED_MTIME + 10 )) -+if test -z "$SOURCE_MTIME" -o -z "$GENERATED_MTIME" -+then -+ echo -+ tput setaf 3; tput bold; printf "Warning: "; tput sgr0 -+ echo "Failed to check if boot/menhir/parser.ml is up-to-date." -+elif test "$SOURCE_MTIME" -gt $(( GENERATED_MTIME + 10 )) - then - echo - tput setaf 3; tput bold; printf "Warning: "; tput sgr0 --- -2.23.0 - diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch new file mode 100644 index 0000000..741ddb3 --- /dev/null +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -0,0 +1,28 @@ +From 95c9c4486c1c23cc735d4986d1b3e6b812514184 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sat, 18 Jan 2020 11:31:27 +0000 +Subject: [PATCH 4/5] Remove configure from .gitattributes. + +It's not a binary file. +--- + .gitattributes | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/.gitattributes b/.gitattributes +index 9be9e33a0..5df88ab4e 100644 +--- a/.gitattributes ++++ b/.gitattributes +@@ -29,10 +29,6 @@ + + /boot/menhir/parser.ml* -diff + +-# configure is declared as binary so that it doesn't get included in diffs. +-# This also means it will have the correct Unix line-endings, even on Windows. +-/configure binary +- + # 'union' merge driver just unions textual content in case of conflict + # http://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/ + /.mailmap merge=union +-- +2.24.1 + diff --git a/0012-Add-riscv64-backend.patch b/0005-Add-riscv64-backend.patch similarity index 97% rename from 0012-Add-riscv64-backend.patch rename to 0005-Add-riscv64-backend.patch index 7697762..3214650 100644 --- a/0012-Add-riscv64-backend.patch +++ b/0005-Add-riscv64-backend.patch @@ -1,7 +1,7 @@ -From 46230ada6483449154c465243edd80d9e539b73a Mon Sep 17 00:00:00 2001 +From 17f5c84a20466e9ef6f1821a45b88e6bb0df8102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Mon, 18 Nov 2019 01:13:30 +0100 -Subject: [PATCH 12/13] Add riscv64 backend +Subject: [PATCH 5/5] Add riscv64 backend (cherry picked from commit c8a361f586c21eca25108ee79c495bb480a1c3f3) --- @@ -13,12 +13,12 @@ Subject: [PATCH 12/13] Add riscv64 backend asmcomp/riscv/reload.ml | 16 + asmcomp/riscv/scheduling.ml | 19 + asmcomp/riscv/selection.ml | 71 ++++ - configure | Bin 542985 -> 543184 bytes + configure | 10 +- configure.ac | 11 +- runtime/caml/stack.h | 5 + runtime/riscv.S | 427 +++++++++++++++++++++ testsuite/tools/asmgen_riscv.S | 87 +++++ - 13 files changed, 1762 insertions(+), 3 deletions(-) + 13 files changed, 1770 insertions(+), 5 deletions(-) create mode 100644 asmcomp/riscv/CSE.ml create mode 100644 asmcomp/riscv/arch.ml create mode 100644 asmcomp/riscv/emit.mlp @@ -1318,22 +1318,45 @@ index 000000000..62fccb648 + +let fundecl f = (new selector)#emit_fundecl f diff --git a/configure b/configure -index c364be4e3a365e01c667023ea23238037446a3c3..75f1d15cb6847544bdf00c5fd8d12ce958072e21 100755 -GIT binary patch -delta 168 -zcmeC2qnZ?OvTGQXWV%3~J?D->52m!#&} -m=49rTR!pz&Ws}`*@R#+WI9m-^c{{%-8xXT^=NIMpWefm-I6Vgd - -delta 67 -zcmcaGS+R4HVnYjK3sVbo3(FQ(q4(40y<`>J9{!&7H7_IAbVhe}>Fw|SvOW@@t|-E$ -WI9*SajjjE^C -Date: Thu, 26 Sep 2019 13:51:08 +0100 -Subject: [PATCH 05/13] Run whole of gen_primitives.sh with LC_ALL=C - -Fixes #8985. Assuming the locale has been generated, running -LC_COLLATE=sv_SE.UTF-8 make world failed previously since the w -character is not matched in [a-z] in this locale. ---- - Changes | 4 ++++ - runtime/gen_primitives.sh | 5 ++++- - 2 files changed, 8 insertions(+), 1 deletion(-) - -diff --git a/Changes b/Changes -index 63cac3ef9..257a75e3d 100644 ---- a/Changes -+++ b/Changes -@@ -8,6 +8,10 @@ OCaml 4.09 maintenance branch: - - #8965, #8979: Alpine build failure caused by check-parser-uptodate-or-warn.sh - (Gabriel Scherer and David Allsopp, report by Anton Kochkov) - -+- #8985, #8986: fix generation of the primitives when the locale collation is -+ incompatible with C. -+ (David Allsopp, review by Nicolás Ojeda Bär, report by Sebastian Rasmussen) -+ - OCaml 4.09.0 (19 September 2019): - --------------------------------- - -diff --git a/runtime/gen_primitives.sh b/runtime/gen_primitives.sh -index e3ca2779b..63365a7fb 100755 ---- a/runtime/gen_primitives.sh -+++ b/runtime/gen_primitives.sh -@@ -17,6 +17,9 @@ - - # duplicated from $(ROOTDIR)/runtime/Makefile - -+# #8985: the meaning of character range a-z depends on the locale, so force C -+# locale throughout. -+export LC_ALL=C - ( - for prim in \ - alloc array compare extern floats gc_ctrl hash intern interp ints io \ -@@ -27,4 +30,4 @@ - done - sed -n -e 's/^CAMLprim_int64_[0-9](\([a-z0-9_][a-z0-9_]*\)).*/caml_int64_\1\ - caml_int64_\1_native/p' ints.c --) | LC_ALL=C sort | uniq -+) | sort | uniq --- -2.23.0 - diff --git a/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch b/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch deleted file mode 100644 index 41f5db5..0000000 --- a/0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 8995e5828ebfe933b74d0c3704c0524a63c73467 Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Fri, 27 Sep 2019 17:15:26 +0200 -Subject: [PATCH 06/13] Merge pull request #8988 from Octachron/fix_ocamlnat - -Fix ocamlnat - -(cherry picked from commit afb90bdf7476a92c024eee2e5745ed85200c654b) ---- - toplevel/opttoploop.ml | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/toplevel/opttoploop.ml b/toplevel/opttoploop.ml -index 0d1f73921..0174a9ab5 100644 ---- a/toplevel/opttoploop.ml -+++ b/toplevel/opttoploop.ml -@@ -257,7 +257,7 @@ let load_lambda ppf ~module_ident ~required_globals lam size = - else - Asmgen.compile_implementation_flambda - ~required_globals ~backend ~toplevel:need_symbol fn ~ppf_dump:ppf -- (Flambda_middle_end.middle_end ~ppf_dump:ppf ~prefixname:"" ~backend ~size -+ (Flambda_middle_end.middle_end ~ppf_dump:ppf ~prefixname:fn ~backend ~size - ~module_ident ~module_initializer:slam ~filename:"toplevel"); - Asmlink.call_linker_shared [fn ^ ext_obj] dll; - Sys.remove (fn ^ ext_obj); --- -2.23.0 - diff --git a/0007-Fix-failure-to-install-tools-links.patch b/0007-Fix-failure-to-install-tools-links.patch deleted file mode 100644 index 6463c15..0000000 --- a/0007-Fix-failure-to-install-tools-links.patch +++ /dev/null @@ -1,45 +0,0 @@ -From fa36269c5752bfb8f4b65dd0f9a2dd8f9c9eeb8f Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Tue, 6 Aug 2019 09:23:06 +0100 -Subject: [PATCH 07/13] Fix failure to install tools links - -In --disable-installing-bytecode-programs mode, the .opt version of the -tools is installed, but the symlink for the tool itself is not created. - -(cherry picked from commit 705739fa54260b7a0e6cbba0b5a99e52c79f9c09) ---- - Changes | 5 +++++ - tools/Makefile | 1 + - 2 files changed, 6 insertions(+) - -diff --git a/Changes b/Changes -index 257a75e3d..3fdc31a5f 100644 ---- a/Changes -+++ b/Changes -@@ -1,6 +1,11 @@ - OCaml 4.09 maintenance branch: - ------------------------------ - -+- #8855, #8858: Links for tools not created when installing with -+ --disable-installing-byecode-programs (e.g. ocamldep.opt installed, but -+ ocamldep link not created) -+ (David Allsopp, report by Thomas Leonard) -+ - - #8953, #8954: Fix error submessages in the toplevel: do not display - dummy locations - (Armaël Guéneau, review by Gabriel Scherer) -diff --git a/tools/Makefile b/tools/Makefile -index afefc4d83..84ddd79fb 100644 ---- a/tools/Makefile -+++ b/tools/Makefile -@@ -242,6 +242,7 @@ else - do \ - if test -f "$$i".opt; then \ - $(INSTALL_PROG) "$$i.opt" "$(INSTALL_BINDIR)/$$i.opt$(EXE)"; \ -+ (cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \ - fi; \ - done - endif --- -2.23.0 - diff --git a/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch b/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch deleted file mode 100644 index 969530f..0000000 --- a/0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 308ea9a8d526160e2b45f16d63a0aee70984b814 Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Sun, 29 Sep 2019 19:33:29 +0200 -Subject: [PATCH 08/13] Merge pull request #8996 from dra27/win-reconfigure - -Windows supports make reconfigure now - -(cherry picked from commit c71997a167c3670d202c6ecaf830c6a25b4b95b8) ---- - Makefile | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/Makefile b/Makefile -index 7ac446f62..90583f1bc 100644 ---- a/Makefile -+++ b/Makefile -@@ -326,11 +326,9 @@ endif - utils/config.ml: utils/config.mlp Makefile.config utils/Makefile Makefile - $(MAKE) -C utils config.ml - --ifeq "$(UNIX_OR_WIN32)" "unix" - .PHONY: reconfigure - reconfigure: - ./configure $(CONFIGURE_ARGS) --endif - - .PHONY: partialclean - partialclean:: --- -2.23.0 - diff --git a/0013-Revert-increment-version-number-after-tagging-4.09.0.patch b/0013-Revert-increment-version-number-after-tagging-4.09.0.patch deleted file mode 100644 index 86ebf7e..0000000 --- a/0013-Revert-increment-version-number-after-tagging-4.09.0.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 76a56065047f9160b0db2491c8f303c9dee6cb59 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Thu, 5 Dec 2019 18:07:29 +0000 -Subject: [PATCH 13/13] Revert "increment version number after tagging 4.09.0" - -Downgrade version number back to 4.09.0 for Fedora. - -This reverts commit 6207460e793f8c5538bfd8164fa3078f7300b57a. ---- - VERSION | 2 +- - ocaml-variants.opam | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/VERSION b/VERSION -index ff541f87c..7128cac1f 100644 ---- a/VERSION -+++ b/VERSION -@@ -1,4 +1,4 @@ --4.09.1+dev0 -+4.09.0 - - # The version string is the first line of this file. - # It must be in the format described in stdlib/sys.mli -diff --git a/ocaml-variants.opam b/ocaml-variants.opam -index 5410d1f4c..30d48eb24 100644 ---- a/ocaml-variants.opam -+++ b/ocaml-variants.opam -@@ -1,8 +1,8 @@ - opam-version: "2.0" --version: "4.09.1+trunk" -+version: "4.09.0" - synopsis: "OCaml development version" - depends: [ -- "ocaml" {= "4.09.1" & post} -+ "ocaml" {= "4.09.0" & post} - "base-unix" {post} - "base-bigarray" {post} - "base-threads" {post} --- -2.23.0 - diff --git a/ocaml.spec b/ocaml.spec index 56bb1f5..6006d2c 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -26,12 +26,11 @@ # Architectures where parallel builds fail. #%global no_parallel_build_arches aarch64 -%global rcver %{nil} -#global rcver +rc2 +%global rcver +beta1 Name: ocaml -Version: 4.09.0 -Release: 13%{?dist} +Version: 4.10.0 +Release: 0.beta1.0%{?dist} Summary: OCaml compiler and programming environment @@ -39,7 +38,7 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org -Source0: http://caml.inria.fr/pub/distrib/ocaml-4.09/ocaml-%{version}%{rcver}.tar.xz +Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rcver}.tar.xz # IMPORTANT NOTE: # @@ -50,31 +49,22 @@ Source0: http://caml.inria.fr/pub/distrib/ocaml-4.09/ocaml-%{version}%{rc # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-32-4.09.0 +# Current branch: fedora-32-4.10.0-beta1 # # 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. # -# Upstream patches after 4.09.0 was released. -Patch0001: 0001-increment-version-number-after-tagging-4.09.0.patch -Patch0002: 0002-mark-the-release-in-the-Changes.patch -Patch0003: 0003-Merge-pull-request-8954-from-Armael-fix-toplevel-sub.patch -Patch0004: 0004-Merge-pull-request-8979-from-gasche-fix-Makefile.men.patch -Patch0005: 0005-Run-whole-of-gen_primitives.sh-with-LC_ALL-C.patch -Patch0006: 0006-Merge-pull-request-8988-from-Octachron-fix_ocamlnat.patch -Patch0007: 0007-Fix-failure-to-install-tools-links.patch -Patch0008: 0008-Merge-pull-request-8996-from-dra27-win-reconfigure.patch # Fedora-specific downstream patches. -Patch0009: 0009-Don-t-add-rpaths-to-libraries.patch -Patch0010: 0010-configure-Allow-user-defined-C-compiler-flags.patch -Patch0011: 0011-configure-Remove-incorrect-assumption-about-cross-co.patch +Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch +Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch +Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch +Patch0004: 0004-Remove-configure-from-.gitattributes.patch # Out of tree patch for RISC-V support. # https://github.com/nojb/riscv-ocaml -Patch0012: 0012-Add-riscv64-backend.patch # Resets the version number back to 4.09.0. -Patch0013: 0013-Revert-increment-version-number-after-tagging-4.09.0.patch +Patch0005: 0005-Add-riscv64-backend.patch BuildRequires: git BuildRequires: gcc @@ -378,10 +368,10 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-13 -- Bump release and rebuild. +* Sat Jan 18 2020 Richard W.M. Jones - 4.10.0-0.beta1 +- OCaml 4.10.0+beta1. -* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-12 +* Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-13 - Bump release and rebuild. * Tue Jan 07 2020 Richard W.M. Jones - 4.09.0-4 diff --git a/sources b/sources index 79a0e77..c669a22 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.09.0.tar.xz) = 5cd745802ee53ab85ee676a20fbb28985ba68965df1d7242de5763d982b0a744951da742615fe478c4d3c98b34531632e3a71de89da6c717ccd90cc01e6fff26 +SHA512 (ocaml-4.10.0+beta1.tar.xz) = 97be0fcf6dee2309c43bca86ace21c83dc5b36bac34b70144a06f36883d7bd5bc457d3e95c6ac47a2ec5e3262058d3be39fc2559f118e4e6b58ec5970ffa88dc From 39e6786df8c11ffa960ba61bf2d3a85f69441fc4 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 29 Jan 2020 19:28:15 +0000 Subject: [PATCH 20/91] - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 6006d2c..ca555a8 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -30,7 +30,7 @@ Name: ocaml Version: 4.10.0 -Release: 0.beta1.0%{?dist} +Release: 0.beta1.0%{?dist}.1 Summary: OCaml compiler and programming environment @@ -368,6 +368,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Wed Jan 29 2020 Fedora Release Engineering - 4.10.0-0.beta1.0.1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + * Sat Jan 18 2020 Richard W.M. Jones - 4.10.0-0.beta1 - OCaml 4.10.0+beta1. From dc143d5bb64c11cfe702c29d2651068b807a0086 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 25 Feb 2020 21:25:57 +0000 Subject: [PATCH 21/91] OCaml 4.10.0 final. --- 0001-Don-t-add-rpaths-to-libraries.patch | 4 ++-- ...nfigure-Allow-user-defined-C-compiler-flags.patch | 6 +++--- ...-Remove-incorrect-assumption-about-cross-co.patch | 6 +++--- 0004-Remove-configure-from-.gitattributes.patch | 4 ++-- 0005-Add-riscv64-backend.patch | 10 +++++----- ocaml.spec | 12 ++++++++---- sources | 2 +- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index c36c24b..1dde81c 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,4 +1,4 @@ -From 1f575196cc7c26a1edc016bca8f7ff052636186b Mon Sep 17 00:00:00 2001 +From bf123e43c444ff14fcb76f806d90806e4960a1a4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 Subject: [PATCH 1/5] Don't add rpaths to libraries. @@ -23,5 +23,5 @@ index 18aead935..e374c05ee 100644 > ocamlmklibconfig.ml -- -2.24.1 +2.25.0 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 8d28bd4..918cf61 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,4 +1,4 @@ -From 122b350037d93e9f44357b215d5ecfbadb8d8fa5 Mon Sep 17 00:00:00 2001 +From 3a5dfecb2e4078bcd7388412783b50014006e7c9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. @@ -8,7 +8,7 @@ Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index 90e6a041e..2f7e829e5 100644 +index e3e28fb6f..0648f0553 100644 --- a/configure.ac +++ b/configure.ac @@ -590,6 +590,10 @@ AS_CASE([$host], @@ -23,5 +23,5 @@ index 90e6a041e..2f7e829e5 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.24.1 +2.25.0 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index a7e1df5..2dc32d0 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,4 +1,4 @@ -From 4481368be15b3dbd07c9ed8a3194194fe8594fc5 Mon Sep 17 00:00:00 2001 +From b32e6fc3318a2d25d7ae233a8999beb752d6131d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 Subject: [PATCH 3/5] configure: Remove incorrect assumption about @@ -10,7 +10,7 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 2f7e829e5..ed6e0b0ca 100644 +index 0648f0553..ad07516e7 100644 --- a/configure.ac +++ b/configure.ac @@ -505,10 +505,11 @@ AS_IF( @@ -39,5 +39,5 @@ index 2f7e829e5..ed6e0b0ca 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.24.1 +2.25.0 diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index 741ddb3..4886740 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,4 +1,4 @@ -From 95c9c4486c1c23cc735d4986d1b3e6b812514184 Mon Sep 17 00:00:00 2001 +From 9ea729ce863396484d2e4c5a93af4b625fc5c90c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 Subject: [PATCH 4/5] Remove configure from .gitattributes. @@ -24,5 +24,5 @@ index 9be9e33a0..5df88ab4e 100644 # http://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/ /.mailmap merge=union -- -2.24.1 +2.25.0 diff --git a/0005-Add-riscv64-backend.patch b/0005-Add-riscv64-backend.patch index 3214650..ce69f7a 100644 --- a/0005-Add-riscv64-backend.patch +++ b/0005-Add-riscv64-backend.patch @@ -1,4 +1,4 @@ -From 17f5c84a20466e9ef6f1821a45b88e6bb0df8102 Mon Sep 17 00:00:00 2001 +From 68ad1dae406a172cd3b0a4b38b8b36150c270b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Mon, 18 Nov 2019 01:13:30 +0100 Subject: [PATCH 5/5] Add riscv64 backend @@ -1318,7 +1318,7 @@ index 000000000..62fccb648 + +let fundecl f = (new selector)#emit_fundecl f diff --git a/configure b/configure -index eb5f3a685..76fd3331b 100755 +index b8f74728f..ec3d7e83d 100755 --- a/configure +++ b/configure @@ -13509,6 +13509,8 @@ if test x"$enable_shared" != "xno"; then : @@ -1353,7 +1353,7 @@ index eb5f3a685..76fd3331b 100755 case $ocaml_cv_cc_vendor in #( clang-*) : diff --git a/configure.ac b/configure.ac -index ed6e0b0ca..0a1ad8f86 100644 +index ad07516e7..562f916dd 100644 --- a/configure.ac +++ b/configure.ac @@ -841,7 +841,8 @@ AS_IF([test x"$enable_shared" != "xno"], @@ -1389,7 +1389,7 @@ index ed6e0b0ca..0a1ad8f86 100644 AS_CASE([$ocaml_cv_cc_vendor], [clang-*], [default_aspp="${toolpref}clang -c -Wno-trigraphs"], diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index cb8b77922..1d1305c8d 100644 +index 259f97ac4..dac7cb3f7 100644 --- a/runtime/caml/stack.h +++ b/runtime/caml/stack.h @@ -70,6 +70,11 @@ @@ -1931,5 +1931,5 @@ index 000000000..8b34a40f8 +caml_c_call: + jr t2 -- -2.24.1 +2.25.0 diff --git a/ocaml.spec b/ocaml.spec index ca555a8..8843566 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -24,13 +24,14 @@ %global test_arches_required NONE # Architectures where parallel builds fail. -#%global no_parallel_build_arches aarch64 +#global no_parallel_build_arches aarch64 -%global rcver +beta1 +#global rcver +beta1 +%global rcver %{nil} Name: ocaml Version: 4.10.0 -Release: 0.beta1.0%{?dist}.1 +Release: 1 Summary: OCaml compiler and programming environment @@ -49,7 +50,7 @@ Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rc # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-32-4.10.0-beta1 +# Current branch: fedora-32-4.10.0 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -368,6 +369,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Feb 25 2020 Richard W.M. Jones - 4.10.0-1 +- OCaml 4.10.0 final. + * Wed Jan 29 2020 Fedora Release Engineering - 4.10.0-0.beta1.0.1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild diff --git a/sources b/sources index c669a22..38b14bf 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.10.0+beta1.tar.xz) = 97be0fcf6dee2309c43bca86ace21c83dc5b36bac34b70144a06f36883d7bd5bc457d3e95c6ac47a2ec5e3262058d3be39fc2559f118e4e6b58ec5970ffa88dc +SHA512 (ocaml-4.10.0.tar.xz) = d2ed8b6162898da45ccc231c97a1b46a330467b9b24390ed17cf3e5367ae6d198ecac8e0df11e5501cdf22cc6313ec23c6cf477d621d017f69f9744eb0050e2e From fc7aa1636a0f7d7bd98b2267b0628a5e8cb3c849 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 27 Feb 2020 11:53:01 +0000 Subject: [PATCH 22/91] Add %{?dist} to Release tag. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks: Lubomír Sedlář --- ocaml.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 8843566..0f54cbc 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.10.0 -Release: 1 +Release: 1%{?dist} Summary: OCaml compiler and programming environment From 790c0c334b7711e3db6d0024d6f520c876d12210 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 27 Feb 2020 11:53:01 +0000 Subject: [PATCH 23/91] Add %{?dist} to Release tag. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks: Lubomír Sedlář --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 0f54cbc..5292fa7 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.10.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -369,6 +369,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Thu Feb 27 2020 Richard W.M. Jones - 4.10.0-2.fc33 +- Add dist tag. + * Tue Feb 25 2020 Richard W.M. Jones - 4.10.0-1 - OCaml 4.10.0 final. From 7c612a100baa2192064a0b051c5795bcb4d0cc7a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 2 Apr 2020 09:49:05 +0100 Subject: [PATCH 24/91] Update all OCaml dependencies for RPM 4.16. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 5292fa7..54403af 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.10.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -369,6 +369,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Thu Apr 02 2020 Richard W.M. Jones - 4.10.0-3.fc33 +- Update all OCaml dependencies for RPM 4.16. + * Thu Feb 27 2020 Richard W.M. Jones - 4.10.0-2.fc33 - Add dist tag. From db6ffb193edca5d37ee7b8fd7468ee4f4a36ebe9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 11 Apr 2020 18:20:06 +0100 Subject: [PATCH 25/91] Fix RISC-V backend. --- 0001-Don-t-add-rpaths-to-libraries.patch | 4 +- ...-Allow-user-defined-C-compiler-flags.patch | 4 +- ...-incorrect-assumption-about-cross-co.patch | 4 +- ...Remove-configure-from-.gitattributes.patch | 4 +- ...ct-representation-of-debug-informati.patch | 504 +++++++ ...ormation-about-allocation-sizes-for-.patch | 620 +++++++++ ...on-size-info-on-more-than-just-amd64.patch | 926 +++++++++++++ ...nd.patch => 0008-Add-riscv64-backend.patch | 1207 +++++++++-------- ocaml.spec | 17 +- 9 files changed, 2748 insertions(+), 542 deletions(-) create mode 100644 0005-Use-a-more-compact-representation-of-debug-informati.patch create mode 100644 0006-Retain-debug-information-about-allocation-sizes-for-.patch create mode 100644 0007-Use-allocation-size-info-on-more-than-just-amd64.patch rename 0005-Add-riscv64-backend.patch => 0008-Add-riscv64-backend.patch (65%) diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 1dde81c..f557009 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From bf123e43c444ff14fcb76f806d90806e4960a1a4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/5] Don't add rpaths to libraries. +Subject: [PATCH 1/8] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- @@ -23,5 +23,5 @@ index 18aead935..e374c05ee 100644 > ocamlmklibconfig.ml -- -2.25.0 +2.24.1 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 918cf61..2781d29 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From 3a5dfecb2e4078bcd7388412783b50014006e7c9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/8] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ @@ -23,5 +23,5 @@ index e3e28fb6f..0648f0553 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.25.0 +2.24.1 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 2dc32d0..df4aca2 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ From b32e6fc3318a2d25d7ae233a8999beb752d6131d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/5] configure: Remove incorrect assumption about +Subject: [PATCH 3/8] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -39,5 +39,5 @@ index 0648f0553..ad07516e7 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.25.0 +2.24.1 diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index 4886740..06a1c2e 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,7 +1,7 @@ From 9ea729ce863396484d2e4c5a93af4b625fc5c90c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 -Subject: [PATCH 4/5] Remove configure from .gitattributes. +Subject: [PATCH 4/8] Remove configure from .gitattributes. It's not a binary file. --- @@ -24,5 +24,5 @@ index 9be9e33a0..5df88ab4e 100644 # http://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/ /.mailmap merge=union -- -2.25.0 +2.24.1 diff --git a/0005-Use-a-more-compact-representation-of-debug-informati.patch b/0005-Use-a-more-compact-representation-of-debug-informati.patch new file mode 100644 index 0000000..cc3443e --- /dev/null +++ b/0005-Use-a-more-compact-representation-of-debug-informati.patch @@ -0,0 +1,504 @@ +From f54d138e2cbabbfb6488a1605f995aaf4a663e0b Mon Sep 17 00:00:00 2001 +From: Stephen Dolan +Date: Tue, 23 Apr 2019 14:11:11 +0100 +Subject: [PATCH 5/8] Use a more compact representation of debug information. + +Locations of inlined frames are now represented as contiguous +sequences rather than linked lists. + +The frame tables now refer to debug info by 32-bit offset rather +than word-sized pointer. + +(cherry picked from commit b0ad600b88b3eb6e53be681794f36dd58b6a493d) +--- + Changes | 1 - + asmcomp/amd64/emit.mlp | 38 ++++++++------- + asmcomp/emitaux.ml | 88 ++++++++++++++++++++--------------- + asmcomp/emitaux.mli | 8 +++- + runtime/backtrace_nat.c | 34 ++++++++------ + runtime/caml/backtrace_prim.h | 2 +- + runtime/caml/stack.h | 12 ++++- + runtime/roots_nat.c | 22 +++++---- + 8 files changed, 124 insertions(+), 81 deletions(-) + +diff --git a/Changes b/Changes +index fc5591eb4..fef04de44 100644 +--- a/Changes ++++ b/Changes +@@ -565,7 +565,6 @@ OCaml 4.09.0 (19 September 2019): + - #8787, #8788: avoid integer overflow in caml_output_value_to_bytes + (Jeremy Yallop, report by Marcello Seri) + +- + - #2075, #7729: rename _T macro used to support Unicode in the (Windows) runtime + in order to avoid compiler warning + (Nicolás Ojeda Bär, review by Gabriel Scherer and David Allsopp) +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index e3ff9653d..69cc48b6d 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -239,7 +239,7 @@ let addressing addr typ i n = + + (* Record live pointers at call points -- see Emitaux *) + +-let record_frame_label ?label live raise_ dbg = ++let record_frame_label ?label live dbg = + let lbl = + match label with + | None -> new_label() +@@ -258,11 +258,11 @@ let record_frame_label ?label live raise_ dbg = + ) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) +- ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + lbl + +-let record_frame ?label live raise_ dbg = +- let lbl = record_frame_label ?label live raise_ dbg in ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in + def_label lbl + + (* Spacetime instrumentation *) +@@ -327,7 +327,7 @@ let bound_error_call = ref 0 + let bound_error_label ?label dbg ~spacetime = + if !Clflags.debug || Config.spacetime then begin + let lbl_bound_error = new_label() in +- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in + bound_error_sites := + { bd_lbl = lbl_bound_error; bd_frame = lbl_frame; + bd_spacetime = spacetime; } :: !bound_error_sites; +@@ -573,16 +573,16 @@ let emit_instr fallthrough i = + load_symbol_addr s (res i 0) + | Lop(Icall_ind { label_after; }) -> + I.call (arg i 0); +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + | Lop(Icall_imm { func; label_after; }) -> + add_used_symbol func; + emit_call func; +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + | Lop(Itailcall_ind { label_after; }) -> + output_epilogue begin fun () -> + I.jmp (arg i 0); + if Config.spacetime then begin +- record_frame Reg.Set.empty false i.dbg ~label:label_after ++ record_frame Reg.Set.empty (Dbg_other i.dbg) ~label:label_after + end + end + | Lop(Itailcall_imm { func; label_after; }) -> +@@ -597,14 +597,14 @@ let emit_instr fallthrough i = + end + end; + if Config.spacetime then begin +- record_frame Reg.Set.empty false i.dbg ~label:label_after ++ record_frame Reg.Set.empty (Dbg_other i.dbg) ~label:label_after + end + | Lop(Iextcall { func; alloc; label_after; }) -> + add_used_symbol func; + if alloc then begin + load_symbol_addr func rax; + emit_call "caml_c_call"; +- record_frame i.live false i.dbg ~label:label_after; ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after; + if system <> S_win64 then begin + (* TODO: investigate why such a diff. + This comes from: +@@ -618,7 +618,7 @@ let emit_instr fallthrough i = + end else begin + emit_call func; + if Config.spacetime then begin +- record_frame Reg.Set.empty false i.dbg ~label:label_after ++ record_frame Reg.Set.empty (Dbg_other i.dbg) ~label:label_after + end + end + | Lop(Istackoffset n) -> +@@ -668,7 +668,7 @@ let emit_instr fallthrough i = + I.movsd (arg i 0) (addressing addr REAL8 i 1) + end + | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; }) -> +- if !fastcode_flag then begin ++ if !fastcode_flag then begin + let lbl_redo = new_label() in + def_label lbl_redo; + I.sub (int n) r15; +@@ -679,7 +679,7 @@ let emit_instr fallthrough i = + else i.dbg + in + let lbl_frame = +- record_frame_label ?label:label_after_call_gc i.live false dbg ++ record_frame_label ?label:label_after_call_gc i.live (Dbg_other dbg) + in + I.jb (label lbl_call_gc); + I.lea (mem64 NONE 8 R15) (res i 0); +@@ -707,8 +707,8 @@ let emit_instr fallthrough i = + emit_call "caml_allocN" + end; + let label = +- record_frame_label ?label:label_after_call_gc i.live false +- Debuginfo.none ++ record_frame_label ?label:label_after_call_gc i.live ++ (Dbg_other i.dbg) + in + def_label label; + I.lea (mem64 NONE 8 R15) (res i 0) +@@ -914,10 +914,10 @@ let emit_instr fallthrough i = + | Lambda.Raise_regular -> + I.mov (int 0) (domain_field Domainstate.Domain_backtrace_pos); + emit_call "caml_raise_exn"; +- record_frame Reg.Set.empty true i.dbg ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) + | Lambda.Raise_reraise -> + emit_call "caml_raise_exn"; +- record_frame Reg.Set.empty true i.dbg ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) + | Lambda.Raise_notrace -> + I.mov (domain_field Domainstate.Domain_exception_pointer) rsp; + I.pop (domain_field Domainstate.Domain_exception_pointer); +@@ -1119,6 +1119,7 @@ let end_assembly() = + emit_frames + { efa_code_label = (fun l -> D.qword (ConstLabel (emit_label l))); + efa_data_label = (fun l -> D.qword (ConstLabel (emit_label l))); ++ efa_8 = (fun n -> D.byte (const n)); + efa_16 = (fun n -> D.word (const n)); + efa_32 = (fun n -> D.long (const_32 n)); + efa_word = (fun n -> D.qword (const n)); +@@ -1142,6 +1143,9 @@ let end_assembly() = + efa_string = (fun s -> D.bytes (s ^ "\000")) + }; + ++ let frametable = Compilenv.make_symbol (Some "frametable") in ++ D.size frametable (ConstSub (ConstThis, ConstLabel frametable)); ++ + if Config.spacetime then begin + emit_spacetime_shapes () + end; +diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml +index e0476d171..9e7221096 100644 +--- a/asmcomp/emitaux.ml ++++ b/asmcomp/emitaux.ml +@@ -105,26 +105,29 @@ let emit_float32_directive directive x = + + (* Record live pointers at call points *) + ++type frame_debuginfo = ++ | Dbg_raise of Debuginfo.t ++ | Dbg_other of Debuginfo.t ++ + type frame_descr = + { fd_lbl: int; (* Return address *) + fd_frame_size: int; (* Size of stack frame *) + fd_live_offset: int list; (* Offsets/regs of live addresses *) +- fd_raise: bool; (* Is frame for a raise? *) +- fd_debuginfo: Debuginfo.t } (* Location, if any *) ++ fd_debuginfo: frame_debuginfo } (* Location, if any *) + + let frame_descriptors = ref([] : frame_descr list) + +-let record_frame_descr ~label ~frame_size ~live_offset ~raise_frame debuginfo = ++let record_frame_descr ~label ~frame_size ~live_offset debuginfo = + frame_descriptors := + { fd_lbl = label; + fd_frame_size = frame_size; + fd_live_offset = List.sort_uniq (-) live_offset; +- fd_raise = raise_frame; + fd_debuginfo = debuginfo } :: !frame_descriptors + + type emit_frame_actions = + { efa_code_label: int -> unit; + efa_data_label: int -> unit; ++ efa_8: int -> unit; + efa_16: int -> unit; + efa_32: int32 -> unit; + efa_word: int -> unit; +@@ -155,64 +158,73 @@ let emit_frames a = + end) + in + let debuginfos = Label_table.create 7 in +- let rec label_debuginfos rs rdbg = ++ let label_debuginfos rs dbg = ++ let rdbg = List.rev dbg in + let key = (rs, rdbg) in +- try fst (Label_table.find debuginfos key) ++ try Label_table.find debuginfos key + with Not_found -> + let lbl = Cmm.new_label () in +- let next = +- match rdbg with +- | [] -> assert false +- | _ :: [] -> None +- | _ :: ((_ :: _) as rdbg') -> Some (label_debuginfos false rdbg') +- in +- Label_table.add debuginfos key (lbl, next); ++ Label_table.add debuginfos key lbl; + lbl + in +- let emit_debuginfo_label rs rdbg = +- a.efa_data_label (label_debuginfos rs rdbg) +- in + let emit_frame fd = ++ assert (fd.fd_frame_size land 3 = 0); ++ let flags = ++ match fd.fd_debuginfo with ++ | Dbg_other d | Dbg_raise d -> ++ if Debuginfo.is_none d then 0 else 1 ++ in + a.efa_code_label fd.fd_lbl; +- a.efa_16 (if Debuginfo.is_none fd.fd_debuginfo +- then fd.fd_frame_size +- else fd.fd_frame_size + 1); ++ a.efa_16 (fd.fd_frame_size + flags); + a.efa_16 (List.length fd.fd_live_offset); + List.iter a.efa_16 fd.fd_live_offset; +- a.efa_align Arch.size_addr; +- match List.rev fd.fd_debuginfo with +- | [] -> () +- | _ :: _ as rdbg -> emit_debuginfo_label fd.fd_raise rdbg ++ begin match fd.fd_debuginfo with ++ | _ when flags = 0 -> ++ () ++ | Dbg_other dbg -> ++ a.efa_align 4; ++ a.efa_label_rel (label_debuginfos false dbg) Int32.zero ++ | Dbg_raise dbg -> ++ a.efa_align 4; ++ a.efa_label_rel (label_debuginfos true dbg) Int32.zero ++ end; ++ a.efa_align Arch.size_addr + in + let emit_filename name lbl = + a.efa_def_label lbl; + a.efa_string name; + a.efa_align Arch.size_addr + in +- let pack_info fd_raise d = ++ let pack_info fd_raise d has_next = + let line = min 0xFFFFF d.Debuginfo.dinfo_line + and char_start = min 0xFF d.Debuginfo.dinfo_char_start + and char_end = min 0x3FF d.Debuginfo.dinfo_char_end +- and kind = if fd_raise then 1 else 0 in ++ and kind = if fd_raise then 1 else 0 ++ and has_next = if has_next then 1 else 0 in + Int64.(add (shift_left (of_int line) 44) + (add (shift_left (of_int char_start) 36) + (add (shift_left (of_int char_end) 26) +- (of_int kind)))) ++ (add (shift_left (of_int kind) 1) ++ (of_int has_next))))) + in +- let emit_debuginfo (rs, rdbg) (lbl,next) = +- let d = List.hd rdbg in ++ let emit_debuginfo (rs, rdbg) lbl = ++ (* Due to inlined functions, a single debuginfo may have multiple locations. ++ These are represented sequentially in memory (innermost frame first), ++ with the low bit of the packed debuginfo being 0 on the last entry. *) + a.efa_align Arch.size_addr; + a.efa_def_label lbl; +- let info = pack_info rs d in +- a.efa_label_rel +- (label_filename d.Debuginfo.dinfo_file) +- (Int64.to_int32 info); +- a.efa_32 (Int64.to_int32 (Int64.shift_right info 32)); +- begin match next with +- | Some next -> a.efa_data_label next +- | None -> a.efa_word 0 +- end +- in ++ let rec emit rs d rest = ++ let info = pack_info rs d (rest <> []) in ++ a.efa_label_rel ++ (label_filename d.Debuginfo.dinfo_file) ++ (Int64.to_int32 info); ++ a.efa_32 (Int64.to_int32 (Int64.shift_right info 32)); ++ match rest with ++ | [] -> () ++ | d :: rest -> emit false d rest in ++ match rdbg with ++ | [] -> assert false ++ | d :: rest -> emit rs d rest in + a.efa_word (List.length !frame_descriptors); + List.iter emit_frame !frame_descriptors; + Label_table.iter emit_debuginfo debuginfos; +diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli +index b2b2141c5..a4a60e07c 100644 +--- a/asmcomp/emitaux.mli ++++ b/asmcomp/emitaux.mli +@@ -38,17 +38,21 @@ val emit_debug_info_gen : + (file_num:int -> file_name:string -> unit) -> + (file_num:int -> line:int -> col:int -> unit) -> unit + ++type frame_debuginfo = ++ | Dbg_raise of Debuginfo.t ++ | Dbg_other of Debuginfo.t ++ + val record_frame_descr : + label:int -> (* Return address *) + frame_size:int -> (* Size of stack frame *) + live_offset:int list -> (* Offsets/regs of live addresses *) +- raise_frame:bool -> (* Is frame for a raise? *) +- Debuginfo.t -> (* Location, if any *) ++ frame_debuginfo -> (* Location, if any *) + unit + + type emit_frame_actions = + { efa_code_label: int -> unit; + efa_data_label: int -> unit; ++ efa_8: int -> unit; + efa_16: int -> unit; + efa_32: int32 -> unit; + efa_word: int -> unit; +diff --git a/runtime/backtrace_nat.c b/runtime/backtrace_nat.c +index 81cb6d8e1..acf31d644 100644 +--- a/runtime/backtrace_nat.c ++++ b/runtime/backtrace_nat.c +@@ -137,18 +137,20 @@ void caml_current_callstack_write(value trace) { + + debuginfo caml_debuginfo_extract(backtrace_slot slot) + { +- uintnat infoptr; ++ unsigned char* infoptr; ++ uint32_t debuginfo_offset; + frame_descr * d = (frame_descr *)slot; + + if ((d->frame_size & 1) == 0) { + return NULL; + } + /* Recover debugging info */ +- infoptr = ((uintnat) d + +- sizeof(char *) + sizeof(short) + sizeof(short) + +- sizeof(short) * d->num_live + sizeof(frame_descr *) - 1) +- & -sizeof(frame_descr *); +- return *((debuginfo*)infoptr); ++ infoptr = (unsigned char*)&d->live_ofs[d->num_live]; ++ /* align to 32 bits */ ++ infoptr = Align_to(infoptr, uint32_t); ++ /* read offset to debuginfo */ ++ debuginfo_offset = *(uint32_t*)infoptr; ++ return (debuginfo)(infoptr + debuginfo_offset); + } + + debuginfo caml_debuginfo_next(debuginfo dbg) +@@ -159,8 +161,12 @@ debuginfo caml_debuginfo_next(debuginfo dbg) + return NULL; + + infoptr = dbg; +- infoptr += 2; /* Two packed info fields */ +- return *((debuginfo*)infoptr); ++ if ((infoptr[0] & 1) == 0) ++ /* No next debuginfo */ ++ return NULL; ++ else ++ /* Next debuginfo is after the two packed info fields */ ++ return (debuginfo*)(infoptr + 2); + } + + /* Extract location information for the given frame descriptor */ +@@ -181,17 +187,19 @@ void caml_debuginfo_location(debuginfo dbg, /*out*/ struct caml_loc_info * li) + info1 = ((uint32_t *)dbg)[0]; + info2 = ((uint32_t *)dbg)[1]; + /* Format of the two info words: +- llllllllllllllllllll aaaaaaaa bbbbbbbbbb nnnnnnnnnnnnnnnnnnnnnnnn kk +- 44 36 26 2 0 ++ llllllllllllllllllll aaaaaaaa bbbbbbbbbb ffffffffffffffffffffffff k n ++ 44 36 26 2 1 0 + (32+12) (32+4) +- k ( 2 bits): 0 if it's a call ++ n ( 1 bit ): 0 if this is the final debuginfo ++ 1 if there's another following this one ++ k ( 1 bit ): 0 if it's a call + 1 if it's a raise +- n (24 bits): offset (in 4-byte words) of file name relative to dbg ++ f (24 bits): offset (in 4-byte words) of file name relative to dbg + l (20 bits): line number + a ( 8 bits): beginning of character range + b (10 bits): end of character range */ + li->loc_valid = 1; +- li->loc_is_raise = (info1 & 3) == 1; ++ li->loc_is_raise = (info1 & 2) == 2; + li->loc_is_inlined = caml_debuginfo_next(dbg) != NULL; + li->loc_filename = (char *) dbg + (info1 & 0x3FFFFFC); + li->loc_lnum = info2 >> 12; +diff --git a/runtime/caml/backtrace_prim.h b/runtime/caml/backtrace_prim.h +index 08c236047..4d8ce9096 100644 +--- a/runtime/caml/backtrace_prim.h ++++ b/runtime/caml/backtrace_prim.h +@@ -43,7 +43,7 @@ struct caml_loc_info { + }; + + /* When compiling with -g, backtrace slots have debug info associated. +- * When a call is inlined in native mode, debuginfos form a linked list. ++ * When a call is inlined in native mode, debuginfos form a sequence. + */ + typedef void * debuginfo; + +diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h +index 259f97ac4..30a18d274 100644 +--- a/runtime/caml/stack.h ++++ b/runtime/caml/stack.h +@@ -87,9 +87,19 @@ typedef struct { + uintnat retaddr; + unsigned short frame_size; + unsigned short num_live; +- unsigned short live_ofs[1]; ++ unsigned short live_ofs[1 /* num_live */]; ++ /* ++ If frame_size & 1, then debug info follows: ++ uint32_t debug_info_offset; ++ Debug info is stored as a relative offset to a debuginfo structure. */ + } frame_descr; + ++/* Used to compute offsets in frame tables. ++ ty must have power-of-2 size */ ++#define Align_to(p, ty) \ ++ (void*)(((uintnat)(p) + sizeof(ty) - 1) & -sizeof(ty)) ++ ++ + /* Hash table of frame descriptors */ + + extern frame_descr ** caml_frame_descriptors; +diff --git a/runtime/roots_nat.c b/runtime/roots_nat.c +index d8feb1bdc..f61e56d90 100644 +--- a/runtime/roots_nat.c ++++ b/runtime/roots_nat.c +@@ -29,6 +29,7 @@ + #include "caml/memprof.h" + #include + #include ++#include + + /* Roots registered from C functions */ + +@@ -78,14 +79,19 @@ static link* frametables_list_tail(link *list) { + } + + static frame_descr * next_frame_descr(frame_descr * d) { +- uintnat nextd; +- nextd = +- ((uintnat)d + +- sizeof(char *) + sizeof(short) + sizeof(short) + +- sizeof(short) * d->num_live + sizeof(frame_descr *) - 1) +- & -sizeof(frame_descr *); +- if (d->frame_size & 1) nextd += sizeof(void *); /* pointer to debuginfo */ +- return((frame_descr *) nextd); ++ unsigned char num_allocs = 0, *p; ++ CAMLassert(d->retaddr >= 4096); ++ /* Skip to end of live_ofs */ ++ p = (unsigned char*)&d->live_ofs[d->num_live]; ++ /* Skip debug info if present */ ++ if (d->frame_size & 1) { ++ /* Align to 32 bits */ ++ p = Align_to(p, uint32_t); ++ p += sizeof(uint32_t) * (d->frame_size & 2 ? num_allocs : 1); ++ } ++ /* Align to word size */ ++ p = Align_to(p, void*); ++ return ((frame_descr*) p); + } + + static void fill_hashtable(link *frametables) { +-- +2.24.1 + diff --git a/0006-Retain-debug-information-about-allocation-sizes-for-.patch b/0006-Retain-debug-information-about-allocation-sizes-for-.patch new file mode 100644 index 0000000..de504d3 --- /dev/null +++ b/0006-Retain-debug-information-about-allocation-sizes-for-.patch @@ -0,0 +1,620 @@ +From dac12e5db7f4ca4a32b0eccea1d16d27f9df86d2 Mon Sep 17 00:00:00 2001 +From: Stephen Dolan +Date: Tue, 16 Jul 2019 16:24:01 +0100 +Subject: [PATCH 6/8] Retain debug information about allocation sizes, for + statmemprof. + +This code is adapted from jhjourdan's 2c93ca1e711. Comballoc is +extended to keep track of allocation sizes and debug info for each +allocation, and the frame table format is modified to store them. + +The native code GC-entry logic is changed to match bytecode, by +calling the garbage collector at most once per allocation. + +amd64 only, for now. + +(cherry picked from commit 34f97941ec302129f516c926c9ef65e4d68b8121) +--- + asmcomp/amd64/emit.mlp | 30 ++++++++----------- + asmcomp/comballoc.ml | 55 +++++++++++++++++++--------------- + asmcomp/emitaux.ml | 22 ++++++++++++++ + asmcomp/emitaux.mli | 1 + + asmcomp/mach.ml | 6 +++- + asmcomp/mach.mli | 11 ++++++- + asmcomp/selectgen.ml | 8 +++-- + asmcomp/spacetime_profiling.ml | 1 + + runtime/amd64.S | 53 ++++---------------------------- + runtime/backtrace_nat.c | 16 ++++++++-- + runtime/caml/stack.h | 10 +++++-- + runtime/minor_gc.c | 5 ++++ + runtime/roots_nat.c | 5 ++++ + runtime/signals_nat.c | 37 +++++++++++------------ + 14 files changed, 143 insertions(+), 117 deletions(-) + +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index 69cc48b6d..6c3950a6d 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -299,13 +299,7 @@ let emit_call_gc gc = + assert Config.spacetime; + spacetime_before_uninstrumented_call ~node_ptr ~index + end; +- begin match gc.gc_size with +- | 16 -> emit_call "caml_call_gc1" +- | 24 -> emit_call "caml_call_gc2" +- | 32 -> emit_call "caml_call_gc3" +- | n -> I.add (int n) r15; +- emit_call "caml_call_gc" +- end; ++ emit_call "caml_call_gc"; + def_label gc.gc_frame; + I.jmp (label gc.gc_return_lbl) + +@@ -667,21 +661,21 @@ let emit_instr fallthrough i = + | Double | Double_u -> + I.movsd (arg i 0) (addressing addr REAL8 i 1) + end +- | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; }) -> +- if !fastcode_flag then begin +- let lbl_redo = new_label() in +- def_label lbl_redo; ++ | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; dbginfo }) -> ++ let dbginfo = ++ if not !Clflags.debug && not Config.spacetime then ++ List.map (fun d -> { d with alloc_dbg = Debuginfo.none }) dbginfo ++ else dbginfo in ++ if !fastcode_flag then begin + I.sub (int n) r15; + I.cmp (domain_field Domainstate.Domain_young_limit) r15; + let lbl_call_gc = new_label() in +- let dbg = +- if not Config.spacetime then Debuginfo.none +- else i.dbg +- in + let lbl_frame = +- record_frame_label ?label:label_after_call_gc i.live (Dbg_other dbg) ++ record_frame_label ?label:label_after_call_gc i.live (Dbg_alloc dbginfo) + in + I.jb (label lbl_call_gc); ++ let lbl_after_alloc = new_label() in ++ def_label lbl_after_alloc; + I.lea (mem64 NONE 8 R15) (res i 0); + let gc_spacetime = + if not Config.spacetime then None +@@ -690,7 +684,7 @@ let emit_instr fallthrough i = + call_gc_sites := + { gc_size = n; + gc_lbl = lbl_call_gc; +- gc_return_lbl = lbl_redo; ++ gc_return_lbl = lbl_after_alloc; + gc_frame = lbl_frame; + gc_spacetime; } :: !call_gc_sites + end else begin +@@ -708,7 +702,7 @@ let emit_instr fallthrough i = + end; + let label = + record_frame_label ?label:label_after_call_gc i.live +- (Dbg_other i.dbg) ++ (Dbg_alloc dbginfo) + in + def_label label; + I.lea (mem64 NONE 8 R15) (res i 0) +diff --git a/asmcomp/comballoc.ml b/asmcomp/comballoc.ml +index 29ee15b36..b8ebcf374 100644 +--- a/asmcomp/comballoc.ml ++++ b/asmcomp/comballoc.ml +@@ -17,34 +17,41 @@ + + open Mach + ++type pending_alloc = ++ { reg: Reg.t; (* register holding the result of the last allocation *) ++ dbginfos: alloc_dbginfo list; (* debug info for each pending allocation *) ++ totalsz: int } (* amount to be allocated in this block *) ++ + type allocation_state = + No_alloc +- | Pending_alloc of +- { reg: Reg.t; (* register holding the result of the last allocation *) +- totalsz: int } (* amount to be allocated in this block *) +- +-let allocated_size = function +- No_alloc -> 0 +- | Pending_alloc {totalsz; _} -> totalsz ++ | Pending_alloc of pending_alloc + + let rec combine i allocstate = + match i.desc with + Iend | Ireturn | Iexit _ | Iraise _ -> +- (i, allocated_size allocstate) +- | Iop(Ialloc { bytes = sz; _ }) -> ++ (i, allocstate) ++ | Iop(Ialloc { bytes = sz; dbginfo; _ }) -> + begin match allocstate with +- | Pending_alloc {reg; totalsz} ++ | Pending_alloc {reg; dbginfos; totalsz} + when totalsz + sz < Config.max_young_wosize * Arch.size_addr -> + let (next, totalsz) = + combine i.next +- (Pending_alloc { reg = i.res.(0); totalsz = totalsz + sz }) in ++ (Pending_alloc { reg = i.res.(0); ++ dbginfos = dbginfo @ dbginfos; ++ totalsz = totalsz + sz }) in + (instr_cons_debug (Iop(Iintop_imm(Iadd, -sz))) + [| reg |] i.res i.dbg next, + totalsz) + | No_alloc | Pending_alloc _ -> +- let (next, totalsz) = ++ let (next, state) = + combine i.next +- (Pending_alloc { reg = i.res.(0); totalsz = sz }) in ++ (Pending_alloc { reg = i.res.(0); ++ dbginfos = dbginfo; ++ totalsz = sz }) in ++ let totalsz, dbginfo = ++ match state with ++ | No_alloc -> 0, dbginfo ++ | Pending_alloc { totalsz; dbginfos; _ } -> totalsz, dbginfos in + let next = + let offset = totalsz - sz in + if offset = 0 then next +@@ -52,40 +59,40 @@ let rec combine i allocstate = + i.res i.dbg next + in + (instr_cons_debug (Iop(Ialloc {bytes = totalsz; spacetime_index = 0; +- label_after_call_gc = None; })) +- i.arg i.res i.dbg next, allocated_size allocstate) ++ dbginfo; label_after_call_gc = None; })) ++ i.arg i.res i.dbg next, allocstate) + end + | Iop(Icall_ind _ | Icall_imm _ | Iextcall _ | + Itailcall_ind _ | Itailcall_imm _) -> + let newnext = combine_restart i.next in + (instr_cons_debug i.desc i.arg i.res i.dbg newnext, +- allocated_size allocstate) ++ allocstate) + | Iop _ -> +- let (newnext, sz) = combine i.next allocstate in +- (instr_cons_debug i.desc i.arg i.res i.dbg newnext, sz) ++ let (newnext, s') = combine i.next allocstate in ++ (instr_cons_debug i.desc i.arg i.res i.dbg newnext, s') + | Iifthenelse(test, ifso, ifnot) -> + let newifso = combine_restart ifso in + let newifnot = combine_restart ifnot in + let newnext = combine_restart i.next in + (instr_cons (Iifthenelse(test, newifso, newifnot)) i.arg i.res newnext, +- allocated_size allocstate) ++ allocstate) + | Iswitch(table, cases) -> + let newcases = Array.map combine_restart cases in + let newnext = combine_restart i.next in + (instr_cons (Iswitch(table, newcases)) i.arg i.res newnext, +- allocated_size allocstate) ++ allocstate) + | Icatch(rec_flag, handlers, body) -> +- let (newbody, sz) = combine body allocstate in ++ let (newbody, s') = combine body allocstate in + let newhandlers = + List.map (fun (io, handler) -> io, combine_restart handler) handlers in + let newnext = combine_restart i.next in + (instr_cons (Icatch(rec_flag, newhandlers, newbody)) +- i.arg i.res newnext, sz) ++ i.arg i.res newnext, s') + | Itrywith(body, handler) -> +- let (newbody, sz) = combine body allocstate in ++ let (newbody, s') = combine body allocstate in + let newhandler = combine_restart handler in + let newnext = combine_restart i.next in +- (instr_cons (Itrywith(newbody, newhandler)) i.arg i.res newnext, sz) ++ (instr_cons (Itrywith(newbody, newhandler)) i.arg i.res newnext, s') + + and combine_restart i = + let (newi, _) = combine i No_alloc in newi +diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml +index 9e7221096..8ed63af28 100644 +--- a/asmcomp/emitaux.ml ++++ b/asmcomp/emitaux.ml +@@ -106,6 +106,7 @@ let emit_float32_directive directive x = + (* Record live pointers at call points *) + + type frame_debuginfo = ++ | Dbg_alloc of Mach.alloc_dbginfo list + | Dbg_raise of Debuginfo.t + | Dbg_other of Debuginfo.t + +@@ -173,6 +174,10 @@ let emit_frames a = + match fd.fd_debuginfo with + | Dbg_other d | Dbg_raise d -> + if Debuginfo.is_none d then 0 else 1 ++ | Dbg_alloc dbgs -> ++ if List.for_all (fun d -> ++ Debuginfo.is_none d.Mach.alloc_dbg) dbgs ++ then 2 else 3 + in + a.efa_code_label fd.fd_lbl; + a.efa_16 (fd.fd_frame_size + flags); +@@ -187,6 +192,23 @@ let emit_frames a = + | Dbg_raise dbg -> + a.efa_align 4; + a.efa_label_rel (label_debuginfos true dbg) Int32.zero ++ | Dbg_alloc dbg -> ++ assert (List.length dbg < 256); ++ a.efa_8 (List.length dbg); ++ List.iter (fun Mach.{alloc_words;_} -> ++ (* Possible allocations range between 2 and 257 *) ++ assert (2 <= alloc_words && ++ alloc_words - 1 <= Config.max_young_wosize && ++ Config.max_young_wosize <= 256); ++ a.efa_8 (alloc_words - 2)) dbg; ++ if flags = 3 then begin ++ a.efa_align 4; ++ List.iter (fun Mach.{alloc_dbg; _} -> ++ if Debuginfo.is_none alloc_dbg then ++ a.efa_32 Int32.zero ++ else ++ a.efa_label_rel (label_debuginfos false alloc_dbg) Int32.zero) dbg ++ end + end; + a.efa_align Arch.size_addr + in +diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli +index a4a60e07c..1a8982a07 100644 +--- a/asmcomp/emitaux.mli ++++ b/asmcomp/emitaux.mli +@@ -39,6 +39,7 @@ val emit_debug_info_gen : + (file_num:int -> line:int -> col:int -> unit) -> unit + + type frame_debuginfo = ++ | Dbg_alloc of Mach.alloc_dbginfo list + | Dbg_raise of Debuginfo.t + | Dbg_other of Debuginfo.t + +diff --git a/asmcomp/mach.ml b/asmcomp/mach.ml +index ab69e0ca3..8df94d039 100644 +--- a/asmcomp/mach.ml ++++ b/asmcomp/mach.ml +@@ -39,6 +39,10 @@ type test = + | Ioddtest + | Ieventest + ++type alloc_dbginfo = ++ { alloc_words : int; ++ alloc_dbg : Debuginfo.t } ++ + type operation = + Imove + | Ispill +@@ -55,7 +59,7 @@ type operation = + | Iload of Cmm.memory_chunk * Arch.addressing_mode + | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool + | Ialloc of { bytes : int; label_after_call_gc : label option; +- spacetime_index : int; } ++ dbginfo : alloc_dbginfo list; spacetime_index : int; } + | Iintop of integer_operation + | Iintop_imm of integer_operation * int + | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf +diff --git a/asmcomp/mach.mli b/asmcomp/mach.mli +index 5df79585c..fd3e033bf 100644 +--- a/asmcomp/mach.mli ++++ b/asmcomp/mach.mli +@@ -46,6 +46,15 @@ type test = + | Ioddtest + | Ieventest + ++type alloc_dbginfo = ++ { alloc_words : int; ++ alloc_dbg : Debuginfo.t } ++(** Due to Comballoc, a single Ialloc instruction may combine several ++ unrelated allocations. Their Debuginfo.t (which may differ) are stored ++ as a list of alloc_dbginfo. This list is in order of increasing memory ++ address, which is the reverse of the original allocation order. Later ++ allocations are consed to the front of this list by Comballoc. *) ++ + type operation = + Imove + | Ispill +@@ -63,7 +72,7 @@ type operation = + | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool + (* false = initialization, true = assignment *) + | Ialloc of { bytes : int; label_after_call_gc : label option; +- spacetime_index : int; } ++ dbginfo : alloc_dbginfo list; spacetime_index : int; } + (** For Spacetime only, Ialloc instructions take one argument, being the + pointer to the trie node for the current function. *) + | Iintop of integer_operation +diff --git a/asmcomp/selectgen.ml b/asmcomp/selectgen.ml +index b024dfe7d..d5f54b699 100644 +--- a/asmcomp/selectgen.ml ++++ b/asmcomp/selectgen.ml +@@ -419,7 +419,8 @@ method mark_instr = function + (* Default instruction selection for operators *) + + method select_allocation bytes = +- Ialloc { bytes; spacetime_index = 0; label_after_call_gc = None; } ++ Ialloc { bytes; label_after_call_gc = None; ++ dbginfo = []; spacetime_index = 0; } + method select_allocation_args _env = [| |] + + method select_checkbound () = +@@ -775,8 +776,11 @@ method emit_expr (env:environment) exp = + | Ialloc { bytes = _; spacetime_index; label_after_call_gc; } -> + let rd = self#regs_for typ_val in + let bytes = size_expr env (Ctuple new_args) in ++ assert (bytes mod Arch.size_addr = 0); ++ let alloc_words = bytes / Arch.size_addr in + let op = +- Ialloc { bytes; spacetime_index; label_after_call_gc; } ++ Ialloc { bytes; spacetime_index; label_after_call_gc; ++ dbginfo = [{alloc_words; alloc_dbg = dbg}] } + in + let args = self#select_allocation_args env in + self#insert_debug env (Iop op) dbg args rd; +diff --git a/asmcomp/spacetime_profiling.ml b/asmcomp/spacetime_profiling.ml +index a61cd1c43..62e182ab9 100644 +--- a/asmcomp/spacetime_profiling.ml ++++ b/asmcomp/spacetime_profiling.ml +@@ -396,6 +396,7 @@ class virtual instruction_selection = object (self) + in + Mach.Ialloc { + bytes; ++ dbginfo = []; + label_after_call_gc = Some label; + spacetime_index = index; + } +diff --git a/runtime/amd64.S b/runtime/amd64.S +index 77a4f85aa..03c1f4e81 100644 +--- a/runtime/amd64.S ++++ b/runtime/amd64.S +@@ -425,111 +425,70 @@ ENDFUNCTION(G(caml_call_gc)) + + FUNCTION(G(caml_alloc1)) + CFI_STARTPROC +-LBL(caml_alloc1): + subq $16, %r15 + cmpq Caml_state(young_limit), %r15 + jb LBL(100) + ret + LBL(100): +- addq $16, %r15 + RECORD_STACK_FRAME(0) + ENTER_FUNCTION + /* subq $8, %rsp; CFI_ADJUST (8); */ + call LBL(caml_call_gc) + /* addq $8, %rsp; CFI_ADJUST (-8); */ + LEAVE_FUNCTION +- jmp LBL(caml_alloc1) ++ ret + CFI_ENDPROC + ENDFUNCTION(G(caml_alloc1)) + + FUNCTION(G(caml_alloc2)) + CFI_STARTPROC +-LBL(caml_alloc2): + subq $24, %r15 + cmpq Caml_state(young_limit), %r15 + jb LBL(101) + ret + LBL(101): +- addq $24, %r15 + RECORD_STACK_FRAME(0) + ENTER_FUNCTION + /* subq $8, %rsp; CFI_ADJUST (8); */ + call LBL(caml_call_gc) + /* addq $8, %rsp; CFI_ADJUST (-8); */ + LEAVE_FUNCTION +- jmp LBL(caml_alloc2) ++ ret + CFI_ENDPROC + ENDFUNCTION(G(caml_alloc2)) + + FUNCTION(G(caml_alloc3)) + CFI_STARTPROC +-LBL(caml_alloc3): + subq $32, %r15 + cmpq Caml_state(young_limit), %r15 + jb LBL(102) + ret + LBL(102): +- addq $32, %r15 + RECORD_STACK_FRAME(0) + ENTER_FUNCTION + /* subq $8, %rsp; CFI_ADJUST (8) */ + call LBL(caml_call_gc) + /* addq $8, %rsp; CFI_ADJUST (-8) */ + LEAVE_FUNCTION +- jmp LBL(caml_alloc3) ++ ret + CFI_ENDPROC + ENDFUNCTION(G(caml_alloc3)) + + FUNCTION(G(caml_allocN)) + CFI_STARTPROC +-LBL(caml_allocN): +- pushq %rax; CFI_ADJUST(8) /* save desired size */ + subq %rax, %r15 + cmpq Caml_state(young_limit), %r15 + jb LBL(103) +- addq $8, %rsp; CFI_ADJUST (-8) /* drop desired size */ + ret + LBL(103): +- addq 0(%rsp), %r15 +- CFI_ADJUST(8) +- RECORD_STACK_FRAME(8) +-#ifdef WITH_FRAME_POINTERS +- /* ensure 16 byte alignment by subq + enter using 16-bytes, PR#7417 */ +- subq $8, %rsp; CFI_ADJUST (8) ++ RECORD_STACK_FRAME(0) + ENTER_FUNCTION +-#endif + call LBL(caml_call_gc) +-#ifdef WITH_FRAME_POINTERS +- /* ensure 16 byte alignment by leave + addq using 16-bytes PR#7417 */ + LEAVE_FUNCTION +- addq $8, %rsp; CFI_ADJUST (-8) +-#endif +- popq %rax; CFI_ADJUST(-8) /* recover desired size */ +- jmp LBL(caml_allocN) ++ ret + CFI_ENDPROC + ENDFUNCTION(G(caml_allocN)) +- +-/* Reset the allocation pointer and invoke the GC */ +- +-FUNCTION(G(caml_call_gc1)) +-CFI_STARTPROC +- addq $16, %r15 +- jmp GCALL(caml_call_gc) +-CFI_ENDPROC +- +-FUNCTION(G(caml_call_gc2)) +-CFI_STARTPROC +- addq $24, %r15 +- jmp GCALL(caml_call_gc) +-CFI_ENDPROC +- +-FUNCTION(G(caml_call_gc3)) +-CFI_STARTPROC +- addq $32, %r15 +- jmp GCALL(caml_call_gc) +-CFI_ENDPROC +- +- ++ + /* Call a C function from OCaml */ + + FUNCTION(G(caml_c_call)) +diff --git a/runtime/backtrace_nat.c b/runtime/backtrace_nat.c +index acf31d644..ee18f2a00 100644 +--- a/runtime/backtrace_nat.c ++++ b/runtime/backtrace_nat.c +@@ -146,8 +146,20 @@ debuginfo caml_debuginfo_extract(backtrace_slot slot) + } + /* Recover debugging info */ + infoptr = (unsigned char*)&d->live_ofs[d->num_live]; +- /* align to 32 bits */ +- infoptr = Align_to(infoptr, uint32_t); ++ if (d->frame_size & 2) { ++ /* skip alloc_lengths */ ++ infoptr += *infoptr + 1; ++ /* align to 32 bits */ ++ infoptr = Align_to(infoptr, uint32_t); ++ /* we know there's at least one valid debuginfo, ++ but it may not be the one for the first alloc */ ++ while (*(uint32_t*)infoptr == 0) { ++ infoptr += sizeof(uint32_t); ++ } ++ } else { ++ /* align to 32 bits */ ++ infoptr = Align_to(infoptr, uint32_t); ++ } + /* read offset to debuginfo */ + debuginfo_offset = *(uint32_t*)infoptr; + return (debuginfo)(infoptr + debuginfo_offset); +diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h +index 30a18d274..44a881e41 100644 +--- a/runtime/caml/stack.h ++++ b/runtime/caml/stack.h +@@ -89,9 +89,15 @@ typedef struct { + unsigned short num_live; + unsigned short live_ofs[1 /* num_live */]; + /* ++ If frame_size & 2, then allocation info follows: ++ unsigned char num_allocs; ++ unsigned char alloc_lengths[num_alloc]; ++ + If frame_size & 1, then debug info follows: +- uint32_t debug_info_offset; +- Debug info is stored as a relative offset to a debuginfo structure. */ ++ uint32_t debug_info_offset[num_debug]; ++ ++ Debug info is stored as relative offsets to debuginfo structures. ++ num_debug is num_alloc if frame_size & 2, otherwise 1. */ + } frame_descr; + + /* Used to compute offsets in frame tables. +diff --git a/runtime/minor_gc.c b/runtime/minor_gc.c +index e4dacfc51..4b3634275 100644 +--- a/runtime/minor_gc.c ++++ b/runtime/minor_gc.c +@@ -509,6 +509,11 @@ void caml_alloc_small_dispatch (tag_t tag, intnat wosize, int flags) + callbacks. */ + CAML_INSTR_INT ("force_minor/alloc_small@", 1); + caml_gc_dispatch (); ++#if defined(NATIVE_CODE) && defined(WITH_SPACETIME) ++ if (caml_young_ptr == caml_young_alloc_end) { ++ caml_spacetime_automatic_snapshot(); ++ } ++#endif + } + + /* Re-do the allocation: we now have enough space in the minor heap. */ +diff --git a/runtime/roots_nat.c b/runtime/roots_nat.c +index f61e56d90..b98555838 100644 +--- a/runtime/roots_nat.c ++++ b/runtime/roots_nat.c +@@ -83,6 +83,11 @@ static frame_descr * next_frame_descr(frame_descr * d) { + CAMLassert(d->retaddr >= 4096); + /* Skip to end of live_ofs */ + p = (unsigned char*)&d->live_ofs[d->num_live]; ++ /* Skip alloc_lengths if present */ ++ if (d->frame_size & 2) { ++ num_allocs = *p; ++ p += num_allocs + 1; ++ } + /* Skip debug info if present */ + if (d->frame_size & 1) { + /* Align to 32 bits */ +diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c +index 017298394..075db46e3 100644 +--- a/runtime/signals_nat.c ++++ b/runtime/signals_nat.c +@@ -69,29 +69,26 @@ extern char caml_system__code_begin, caml_system__code_end; + + void caml_garbage_collection(void) + { +- /* TEMPORARY: if we have just sampled an allocation in native mode, +- we simply renew the sample to ignore it. Otherwise, renewing now +- will not have any effect on the sampling distribution, because of +- the memorylessness of the Bernoulli process. +- +- FIXME: if the sampling rate is 1, this leads to infinite loop, +- because we are using a binomial distribution in [memprof.c]. This +- will go away when the sampling of natively allocated blocks will +- be correctly implemented. +- */ +- caml_memprof_renew_minor_sample(); +- if (Caml_state->requested_major_slice || Caml_state->requested_minor_gc || +- Caml_state->young_ptr - Caml_state->young_trigger < Max_young_whsize){ +- caml_gc_dispatch (); ++ frame_descr* d; ++ uintnat h; ++ h = Hash_retaddr(Caml_state->last_return_address); ++ while (1) { ++ d = caml_frame_descriptors[h]; ++ if (d->retaddr == Caml_state->last_return_address) break; ++ h = (h + 1) & caml_frame_descriptors_mask; + } + +-#ifdef WITH_SPACETIME +- if (Caml_state->young_ptr == Caml_state->young_alloc_end) { +- caml_spacetime_automatic_snapshot(); +- } +-#endif ++ /* Must be an allocation frame */ ++ CAMLassert(d && d->frame_size != 0xFFFF && (d->frame_size & 2)); ++ ++ unsigned char* alloc_len = (unsigned char*)(&d->live_ofs[d->num_live]); ++ int nallocs = *alloc_len++; ++ int allocsz = 0; ++ for (int i = 0; i < nallocs; i++) allocsz += alloc_len[i] + 2; ++ allocsz -= 1; + +- caml_raise_if_exception(caml_do_pending_actions_exn()); ++ caml_alloc_small_dispatch(0 /* FIXME */, allocsz, ++ /* CAML_DO_TRACK | */ CAML_FROM_CAML); + } + + DECLARE_SIGNAL_HANDLER(handle_signal) +-- +2.24.1 + diff --git a/0007-Use-allocation-size-info-on-more-than-just-amd64.patch b/0007-Use-allocation-size-info-on-more-than-just-amd64.patch new file mode 100644 index 0000000..25aa5a8 --- /dev/null +++ b/0007-Use-allocation-size-info-on-more-than-just-amd64.patch @@ -0,0 +1,926 @@ +From 69eac75740fafad36246392c666410e9e66388d7 Mon Sep 17 00:00:00 2001 +From: Stephen Dolan +Date: Wed, 18 Sep 2019 16:15:18 +0100 +Subject: [PATCH 7/8] Use allocation-size info on more than just amd64. + +Moves the alloc_dbginfo type to Debuginfo, to avoid a circular +dependency on architectures that use Branch_relaxation. + +This commit generates frame tables with allocation sizes on all +architectures, but does not yet update the allocation code for +non-amd64 backends. + +(cherry picked from commit 768dcce48f79c33beb2af342a4c3551c276afe11) +--- + .depend | 4 ++-- + asmcomp/amd64/emit.mlp | 14 +++-------- + asmcomp/arm/emit.mlp | 27 ++++++++++----------- + asmcomp/arm64/arch.ml | 3 ++- + asmcomp/arm64/emit.mlp | 37 +++++++++++++++-------------- + asmcomp/branch_relaxation.ml | 5 ++-- + asmcomp/branch_relaxation_intf.ml | 1 + + asmcomp/comballoc.ml | 6 ++--- + asmcomp/emitaux.ml | 13 ++++++----- + asmcomp/emitaux.mli | 2 +- + asmcomp/i386/emit.mlp | 37 +++++++++++++++-------------- + asmcomp/mach.ml | 6 +---- + asmcomp/mach.mli | 11 +-------- + asmcomp/power/arch.ml | 3 ++- + asmcomp/power/emit.mlp | 39 ++++++++++++++++--------------- + asmcomp/s390x/emit.mlp | 25 ++++++++++---------- + lambda/debuginfo.ml | 5 ++++ + lambda/debuginfo.mli | 11 +++++++++ + 18 files changed, 128 insertions(+), 121 deletions(-) + +diff --git a/.depend b/.depend +index c40e2f0f7..becb7bcc0 100644 +--- a/.depend ++++ b/.depend +@@ -2152,10 +2152,12 @@ asmcomp/branch_relaxation.cmi : \ + asmcomp/linear.cmi \ + asmcomp/branch_relaxation_intf.cmo + asmcomp/branch_relaxation_intf.cmo : \ ++ asmcomp/mach.cmi \ + asmcomp/linear.cmi \ + asmcomp/cmm.cmi \ + asmcomp/arch.cmo + asmcomp/branch_relaxation_intf.cmx : \ ++ asmcomp/mach.cmx \ + asmcomp/linear.cmx \ + asmcomp/cmm.cmx \ + asmcomp/arch.cmx +@@ -2351,7 +2353,6 @@ asmcomp/emit.cmo : \ + lambda/lambda.cmi \ + asmcomp/emitaux.cmi \ + utils/domainstate.cmi \ +- lambda/debuginfo.cmi \ + utils/config.cmi \ + middle_end/compilenv.cmi \ + asmcomp/cmm.cmi \ +@@ -2373,7 +2374,6 @@ asmcomp/emit.cmx : \ + lambda/lambda.cmx \ + asmcomp/emitaux.cmx \ + utils/domainstate.cmx \ +- lambda/debuginfo.cmx \ + utils/config.cmx \ + middle_end/compilenv.cmx \ + asmcomp/cmm.cmx \ +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index 6c3950a6d..bdf3462ec 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -281,8 +281,7 @@ let spacetime_before_uninstrumented_call ~node_ptr ~index = + (* Record calls to the GC -- we've moved them out of the way *) + + type gc_call = +- { gc_size: int; (* Allocation size, in bytes *) +- gc_lbl: label; (* Entry label *) ++ { gc_lbl: label; (* Entry label *) + gc_return_lbl: label; (* Where to branch after GC *) + gc_frame: label; (* Label of frame descriptor *) + gc_spacetime : (X86_ast.arg * int) option; +@@ -662,10 +661,7 @@ let emit_instr fallthrough i = + I.movsd (arg i 0) (addressing addr REAL8 i 1) + end + | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; dbginfo }) -> +- let dbginfo = +- if not !Clflags.debug && not Config.spacetime then +- List.map (fun d -> { d with alloc_dbg = Debuginfo.none }) dbginfo +- else dbginfo in ++ assert (n <= (Config.max_young_wosize + 1) * Arch.size_addr); + if !fastcode_flag then begin + I.sub (int n) r15; + I.cmp (domain_field Domainstate.Domain_young_limit) r15; +@@ -682,8 +678,7 @@ let emit_instr fallthrough i = + else Some (arg i 0, spacetime_index) + in + call_gc_sites := +- { gc_size = n; +- gc_lbl = lbl_call_gc; ++ { gc_lbl = lbl_call_gc; + gc_return_lbl = lbl_after_alloc; + gc_frame = lbl_frame; + gc_spacetime; } :: !call_gc_sites +@@ -1009,9 +1004,6 @@ let begin_assembly() = + all_functions := []; + if system = S_win64 then begin + D.extrn "caml_call_gc" NEAR; +- D.extrn "caml_call_gc1" NEAR; +- D.extrn "caml_call_gc2" NEAR; +- D.extrn "caml_call_gc3" NEAR; + D.extrn "caml_c_call" NEAR; + D.extrn "caml_allocN" NEAR; + D.extrn "caml_alloc1" NEAR; +diff --git a/asmcomp/arm/emit.mlp b/asmcomp/arm/emit.mlp +index 1393d4576..0689cd17c 100644 +--- a/asmcomp/arm/emit.mlp ++++ b/asmcomp/arm/emit.mlp +@@ -105,7 +105,7 @@ let emit_addressing addr r n = + + (* Record live pointers at call points *) + +-let record_frame_label ?label live raise_ dbg = ++let record_frame_label ?label live dbg = + let lbl = + match label with + | None -> new_label() +@@ -123,11 +123,11 @@ let record_frame_label ?label live raise_ dbg = + | _ -> ()) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) +- ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + lbl + +-let record_frame ?label live raise_ dbg = +- let lbl = record_frame_label ?label live raise_ dbg in `{emit_label lbl}:` ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in `{emit_label lbl}:` + + (* Record calls to the GC -- we've moved them out of the way *) + +@@ -155,7 +155,7 @@ let bound_error_sites = ref ([] : bound_error_call list) + let bound_error_label ?label dbg = + if !Clflags.debug || !bound_error_sites = [] then begin + let lbl_bound_error = new_label() in +- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in + bound_error_sites := + { bd_lbl = lbl_bound_error; + bd_frame_lbl = lbl_frame } :: !bound_error_sites; +@@ -542,15 +542,15 @@ let emit_instr i = + | Lop(Icall_ind { label_after; }) -> + if !arch >= ARMv5 then begin + ` blx {emit_reg i.arg.(0)}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n`; 1 ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; 1 + end else begin + ` mov lr, pc\n`; + ` bx {emit_reg i.arg.(0)}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n`; 2 ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; 2 + end + | Lop(Icall_imm { func; label_after; }) -> + ` {emit_call func}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n`; 1 ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; 1 + | Lop(Itailcall_ind { label_after = _; }) -> + output_epilogue begin fun () -> + if !contains_calls then +@@ -572,7 +572,7 @@ let emit_instr i = + | Lop(Iextcall { func; alloc = true; label_after; }) -> + let ninstr = emit_load_symbol_addr (phys_reg 7 (* r7 *)) func in + ` {emit_call "caml_c_call"}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n`; ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; + 1 + ninstr + | Lop(Istackoffset n) -> + assert (n mod 8 = 0); +@@ -642,9 +642,9 @@ let emit_instr i = + | Double_u -> "fstd" + | _ (* 32-bit quantities *) -> "str" in + ` {emit_string instr} {emit_reg r}, {emit_addressing addr i.arg 1}\n`; 1 +- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> ++ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> + let lbl_frame = +- record_frame_label i.live false i.dbg ?label:label_after_call_gc ++ record_frame_label i.live (Dbg_alloc dbginfo) ?label:label_after_call_gc + in + if !fastcode_flag then begin + let lbl_redo = new_label() in +@@ -912,10 +912,10 @@ let emit_instr i = + ` mov r12, #0\n`; + ` str r12, [domain_state_ptr, {emit_int offset}]\n`; + ` {emit_call "caml_raise_exn"}\n`; +- `{record_frame Reg.Set.empty true i.dbg}\n`; 3 ++ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n`; 3 + | Lambda.Raise_reraise -> + ` {emit_call "caml_raise_exn"}\n`; +- `{record_frame Reg.Set.empty true i.dbg}\n`; 1 ++ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n`; 1 + | Lambda.Raise_notrace -> + ` mov sp, trap_ptr\n`; + ` pop \{trap_ptr, pc}\n`; 2 +@@ -1072,6 +1072,7 @@ let end_assembly () = + efa_data_label = (fun lbl -> + ` .type {emit_label lbl}, %object\n`; + ` .word {emit_label lbl}\n`); ++ efa_8 = (fun n -> ` .byte {emit_int n}\n`); + efa_16 = (fun n -> ` .short {emit_int n}\n`); + efa_32 = (fun n -> ` .long {emit_int32 n}\n`); + efa_word = (fun n -> ` .word {emit_int n}\n`); +diff --git a/asmcomp/arm64/arch.ml b/asmcomp/arm64/arch.ml +index ce5902aa2..9cf923c6c 100644 +--- a/asmcomp/arm64/arch.ml ++++ b/asmcomp/arm64/arch.ml +@@ -38,7 +38,8 @@ type cmm_label = int + (* Do not introduce a dependency to Cmm *) + + type specific_operation = +- | Ifar_alloc of { bytes : int; label_after_call_gc : cmm_label option; } ++ | Ifar_alloc of { bytes : int; label_after_call_gc : cmm_label option; ++ dbginfo : Debuginfo.alloc_dbginfo } + | Ifar_intop_checkbound of { label_after_error : cmm_label option; } + | Ifar_intop_imm_checkbound of + { bound : int; label_after_error : cmm_label option; } +diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp +index eb8424bf5..cb5e75d7a 100644 +--- a/asmcomp/arm64/emit.mlp ++++ b/asmcomp/arm64/emit.mlp +@@ -126,7 +126,7 @@ let emit_addressing addr r = + + (* Record live pointers at call points *) + +-let record_frame_label ?label live raise_ dbg = ++let record_frame_label ?label live dbg = + let lbl = + match label with + | None -> new_label() +@@ -144,11 +144,11 @@ let record_frame_label ?label live raise_ dbg = + | _ -> ()) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) +- ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + lbl + +-let record_frame ?label live raise_ dbg = +- let lbl = record_frame_label ?label live raise_ dbg in `{emit_label lbl}:` ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in `{emit_label lbl}:` + + (* Record calls to the GC -- we've moved them out of the way *) + +@@ -176,7 +176,7 @@ let bound_error_sites = ref ([] : bound_error_call list) + let bound_error_label ?label dbg = + if !Clflags.debug || !bound_error_sites = [] then begin + let lbl_bound_error = new_label() in +- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in + bound_error_sites := + { bd_lbl = lbl_bound_error; + bd_frame_lbl = lbl_frame } :: !bound_error_sites; +@@ -512,8 +512,8 @@ module BR = Branch_relaxation.Make (struct + | Lambda.Raise_notrace -> 4 + end + +- let relax_allocation ~num_bytes ~label_after_call_gc = +- Lop (Ispecific (Ifar_alloc { bytes = num_bytes; label_after_call_gc; })) ++ let relax_allocation ~num_bytes ~label_after_call_gc ~dbginfo = ++ Lop (Ispecific (Ifar_alloc { bytes = num_bytes; label_after_call_gc; dbginfo })) + + let relax_intop_checkbound ~label_after_error = + Lop (Ispecific (Ifar_intop_checkbound { label_after_error; })) +@@ -529,9 +529,9 @@ end) + + (* Output the assembly code for allocation. *) + +-let assembly_code_for_allocation ?label_after_call_gc i ~n ~far = ++let assembly_code_for_allocation ~label_after_call_gc i ~n ~far ~dbginfo = + let lbl_frame = +- record_frame_label ?label:label_after_call_gc i.live false i.dbg ++ record_frame_label ?label:label_after_call_gc i.live (Dbg_alloc dbginfo) + in + if !fastcode_flag then begin + let lbl_redo = new_label() in +@@ -626,10 +626,10 @@ let emit_instr i = + emit_load_symbol_addr i.res.(0) s + | Lop(Icall_ind { label_after; }) -> + ` blr {emit_reg i.arg.(0)}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n` ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` + | Lop(Icall_imm { func; label_after; }) -> + ` bl {emit_symbol func}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n` ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` + | Lop(Itailcall_ind { label_after = _; }) -> + output_epilogue (fun () -> ` br {emit_reg i.arg.(0)}\n`) + | Lop(Itailcall_imm { func; label_after = _; }) -> +@@ -642,7 +642,7 @@ let emit_instr i = + | Lop(Iextcall { func; alloc = true; label_after; }) -> + emit_load_symbol_addr reg_x15 func; + ` bl {emit_symbol "caml_c_call"}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n` ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` + | Lop(Istackoffset n) -> + assert (n mod 16 = 0); + emit_stack_adjustment (-n); +@@ -697,10 +697,10 @@ let emit_instr i = + | Word_int | Word_val | Double | Double_u -> + ` str {emit_reg src}, {emit_addressing addr base}\n` + end +- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> +- assembly_code_for_allocation i ~n ~far:false ?label_after_call_gc +- | Lop(Ispecific (Ifar_alloc { bytes = n; label_after_call_gc; })) -> +- assembly_code_for_allocation i ~n ~far:true ?label_after_call_gc ++ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> ++ assembly_code_for_allocation i ~n ~far:false ~label_after_call_gc ~dbginfo ++ | Lop(Ispecific (Ifar_alloc { bytes = n; label_after_call_gc; dbginfo })) -> ++ assembly_code_for_allocation i ~n ~far:true ~label_after_call_gc ~dbginfo + | Lop(Iintop(Icomp cmp)) -> + ` cmp {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; + ` cset {emit_reg i.res.(0)}, {emit_string (name_for_comparison cmp)}\n` +@@ -906,10 +906,10 @@ let emit_instr i = + let offset = Domainstate.(idx_of_field Domain_backtrace_pos) * 8 in + ` str xzr, [{emit_reg reg_domain_state_ptr}, {emit_int offset}]\n`; + ` bl {emit_symbol "caml_raise_exn"}\n`; +- `{record_frame Reg.Set.empty true i.dbg}\n` ++ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` + | Lambda.Raise_reraise -> + ` bl {emit_symbol "caml_raise_exn"}\n`; +- `{record_frame Reg.Set.empty true i.dbg}\n` ++ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` + | Lambda.Raise_notrace -> + ` mov sp, {emit_reg reg_trap_ptr}\n`; + ` ldr {emit_reg reg_tmp1}, [sp, #8]\n`; +@@ -1027,6 +1027,7 @@ let end_assembly () = + efa_data_label = (fun lbl -> + ` .type {emit_label lbl}, %object\n`; + ` .quad {emit_label lbl}\n`); ++ efa_8 = (fun n -> ` .byte {emit_int n}\n`); + efa_16 = (fun n -> ` .short {emit_int n}\n`); + efa_32 = (fun n -> ` .long {emit_int32 n}\n`); + efa_word = (fun n -> ` .quad {emit_int n}\n`); +diff --git a/asmcomp/branch_relaxation.ml b/asmcomp/branch_relaxation.ml +index 953c2827c..74b749ea8 100644 +--- a/asmcomp/branch_relaxation.ml ++++ b/asmcomp/branch_relaxation.ml +@@ -86,8 +86,9 @@ module Make (T : Branch_relaxation_intf.S) = struct + fixup did_fix (pc + T.instr_size instr.desc) instr.next + else + match instr.desc with +- | Lop (Ialloc { bytes = num_bytes; label_after_call_gc; }) -> +- instr.desc <- T.relax_allocation ~num_bytes ~label_after_call_gc; ++ | Lop (Ialloc { bytes = num_bytes; label_after_call_gc; dbginfo }) -> ++ instr.desc <- T.relax_allocation ~num_bytes ++ ~dbginfo ~label_after_call_gc; + fixup true (pc + T.instr_size instr.desc) instr.next + | Lop (Iintop (Icheckbound { label_after_error; })) -> + instr.desc <- T.relax_intop_checkbound ~label_after_error; +diff --git a/asmcomp/branch_relaxation_intf.ml b/asmcomp/branch_relaxation_intf.ml +index d5552f83f..b7a7271fb 100644 +--- a/asmcomp/branch_relaxation_intf.ml ++++ b/asmcomp/branch_relaxation_intf.ml +@@ -63,6 +63,7 @@ module type S = sig + val relax_allocation + : num_bytes:int + -> label_after_call_gc:Cmm.label option ++ -> dbginfo:Debuginfo.alloc_dbginfo + -> Linear.instruction_desc + val relax_intop_checkbound + : label_after_error:Cmm.label option +diff --git a/asmcomp/comballoc.ml b/asmcomp/comballoc.ml +index b8ebcf374..16bda3772 100644 +--- a/asmcomp/comballoc.ml ++++ b/asmcomp/comballoc.ml +@@ -18,9 +18,9 @@ + open Mach + + type pending_alloc = +- { reg: Reg.t; (* register holding the result of the last allocation *) +- dbginfos: alloc_dbginfo list; (* debug info for each pending allocation *) +- totalsz: int } (* amount to be allocated in this block *) ++ { reg: Reg.t; (* register holding the result of the last allocation *) ++ dbginfos: Debuginfo.alloc_dbginfo; (* debug info for each pending alloc *) ++ totalsz: int } (* amount to be allocated in this block *) + + type allocation_state = + No_alloc +diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml +index 8ed63af28..8e3ec8d50 100644 +--- a/asmcomp/emitaux.ml ++++ b/asmcomp/emitaux.ml +@@ -106,7 +106,7 @@ let emit_float32_directive directive x = + (* Record live pointers at call points *) + + type frame_debuginfo = +- | Dbg_alloc of Mach.alloc_dbginfo list ++ | Dbg_alloc of Debuginfo.alloc_dbginfo + | Dbg_raise of Debuginfo.t + | Dbg_other of Debuginfo.t + +@@ -175,9 +175,10 @@ let emit_frames a = + | Dbg_other d | Dbg_raise d -> + if Debuginfo.is_none d then 0 else 1 + | Dbg_alloc dbgs -> +- if List.for_all (fun d -> +- Debuginfo.is_none d.Mach.alloc_dbg) dbgs +- then 2 else 3 ++ if !Clflags.debug && not Config.spacetime && ++ List.exists (fun d -> ++ not (Debuginfo.is_none d.Debuginfo.alloc_dbg)) dbgs ++ then 3 else 2 + in + a.efa_code_label fd.fd_lbl; + a.efa_16 (fd.fd_frame_size + flags); +@@ -195,7 +196,7 @@ let emit_frames a = + | Dbg_alloc dbg -> + assert (List.length dbg < 256); + a.efa_8 (List.length dbg); +- List.iter (fun Mach.{alloc_words;_} -> ++ List.iter (fun Debuginfo.{alloc_words;_} -> + (* Possible allocations range between 2 and 257 *) + assert (2 <= alloc_words && + alloc_words - 1 <= Config.max_young_wosize && +@@ -203,7 +204,7 @@ let emit_frames a = + a.efa_8 (alloc_words - 2)) dbg; + if flags = 3 then begin + a.efa_align 4; +- List.iter (fun Mach.{alloc_dbg; _} -> ++ List.iter (fun Debuginfo.{alloc_dbg; _} -> + if Debuginfo.is_none alloc_dbg then + a.efa_32 Int32.zero + else +diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli +index 1a8982a07..2b4867d0b 100644 +--- a/asmcomp/emitaux.mli ++++ b/asmcomp/emitaux.mli +@@ -39,7 +39,7 @@ val emit_debug_info_gen : + (file_num:int -> line:int -> col:int -> unit) -> unit + + type frame_debuginfo = +- | Dbg_alloc of Mach.alloc_dbginfo list ++ | Dbg_alloc of Debuginfo.alloc_dbginfo + | Dbg_raise of Debuginfo.t + | Dbg_other of Debuginfo.t + +diff --git a/asmcomp/i386/emit.mlp b/asmcomp/i386/emit.mlp +index 9c1ca30a2..614bb33fe 100644 +--- a/asmcomp/i386/emit.mlp ++++ b/asmcomp/i386/emit.mlp +@@ -200,7 +200,7 @@ let addressing addr typ i n = + + (* Record live pointers at call points *) + +-let record_frame_label ?label live raise_ dbg = ++let record_frame_label ?label live dbg = + let lbl = + match label with + | None -> new_label() +@@ -218,11 +218,11 @@ let record_frame_label ?label live raise_ dbg = + | _ -> ()) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) +- ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + lbl + +-let record_frame ?label live raise_ dbg = +- let lbl = record_frame_label ?label live raise_ dbg in ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in + def_label lbl + + (* Record calls to the GC -- we've moved them out of the way *) +@@ -254,7 +254,7 @@ let bound_error_call = ref 0 + let bound_error_label ?label dbg = + if !Clflags.debug then begin + let lbl_bound_error = new_label() in +- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in + bound_error_sites := + { bd_lbl = lbl_bound_error; bd_frame = lbl_frame } :: !bound_error_sites; + lbl_bound_error +@@ -540,11 +540,11 @@ let emit_instr fallthrough i = + I.mov (immsym s) (reg i.res.(0)) + | Lop(Icall_ind { label_after; }) -> + I.call (reg i.arg.(0)); +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + | Lop(Icall_imm { func; label_after; }) -> + add_used_symbol func; + emit_call func; +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + | Lop(Itailcall_ind { label_after = _; }) -> + output_epilogue begin fun () -> + I.jmp (reg i.arg.(0)) +@@ -563,7 +563,7 @@ let emit_instr fallthrough i = + if alloc then begin + I.mov (immsym func) eax; + emit_call "caml_c_call"; +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + end else begin + emit_call func + end +@@ -614,22 +614,24 @@ let emit_instr fallthrough i = + I.fstp (addressing addr REAL8 i 1) + end + end +- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> ++ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> + if !fastcode_flag then begin +- let lbl_redo = new_label() in +- def_label lbl_redo; + load_domain_state ebx; + I.mov (domain_field Domain_young_ptr RBX) eax; + I.sub (int n) eax; + I.cmp (domain_field Domain_young_limit RBX) eax; + let lbl_call_gc = new_label() in +- let lbl_frame = record_frame_label i.live false Debuginfo.none in ++ let lbl_frame = ++ record_frame_label ?label:label_after_call_gc ++ i.live (Dbg_alloc dbginfo) in + I.jb (label lbl_call_gc); + I.mov eax (domain_field Domain_young_ptr RBX); ++ let lbl_after_alloc = new_label() in ++ def_label lbl_after_alloc; + I.lea (mem32 NONE 4 RAX) (reg i.res.(0)); + call_gc_sites := + { gc_lbl = lbl_call_gc; +- gc_return_lbl = lbl_redo; ++ gc_return_lbl = lbl_after_alloc; + gc_frame = lbl_frame } :: !call_gc_sites + end else begin + begin match n with +@@ -641,8 +643,8 @@ let emit_instr fallthrough i = + emit_call "caml_allocN" + end; + let label = +- record_frame_label ?label:label_after_call_gc i.live false +- Debuginfo.none ++ record_frame_label ?label:label_after_call_gc ++ i.live (Dbg_alloc dbginfo) + in + def_label label; + I.lea (mem32 NONE 4 RAX) (reg i.res.(0)) +@@ -895,10 +897,10 @@ let emit_instr fallthrough i = + load_domain_state ebx; + I.mov (int 0) (domain_field Domain_backtrace_pos RBX); + emit_call "caml_raise_exn"; +- record_frame Reg.Set.empty true i.dbg ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) + | Lambda.Raise_reraise -> + emit_call "caml_raise_exn"; +- record_frame Reg.Set.empty true i.dbg ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) + | Lambda.Raise_notrace -> + load_domain_state ebx; + I.mov (domain_field Domain_exception_pointer RBX) esp; +@@ -1019,6 +1021,7 @@ let end_assembly() = + emit_frames + { efa_code_label = (fun l -> D.long (ConstLabel (emit_label l))); + efa_data_label = (fun l -> D.long (ConstLabel (emit_label l))); ++ efa_8 = (fun n -> D.byte (const n)); + efa_16 = (fun n -> D.word (const n)); + efa_32 = (fun n -> D.long (const_32 n)); + efa_word = (fun n -> D.long (const n)); +diff --git a/asmcomp/mach.ml b/asmcomp/mach.ml +index 8df94d039..8518e9da6 100644 +--- a/asmcomp/mach.ml ++++ b/asmcomp/mach.ml +@@ -39,10 +39,6 @@ type test = + | Ioddtest + | Ieventest + +-type alloc_dbginfo = +- { alloc_words : int; +- alloc_dbg : Debuginfo.t } +- + type operation = + Imove + | Ispill +@@ -59,7 +55,7 @@ type operation = + | Iload of Cmm.memory_chunk * Arch.addressing_mode + | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool + | Ialloc of { bytes : int; label_after_call_gc : label option; +- dbginfo : alloc_dbginfo list; spacetime_index : int; } ++ dbginfo : Debuginfo.alloc_dbginfo; spacetime_index : int; } + | Iintop of integer_operation + | Iintop_imm of integer_operation * int + | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf +diff --git a/asmcomp/mach.mli b/asmcomp/mach.mli +index fd3e033bf..1141d57d0 100644 +--- a/asmcomp/mach.mli ++++ b/asmcomp/mach.mli +@@ -46,15 +46,6 @@ type test = + | Ioddtest + | Ieventest + +-type alloc_dbginfo = +- { alloc_words : int; +- alloc_dbg : Debuginfo.t } +-(** Due to Comballoc, a single Ialloc instruction may combine several +- unrelated allocations. Their Debuginfo.t (which may differ) are stored +- as a list of alloc_dbginfo. This list is in order of increasing memory +- address, which is the reverse of the original allocation order. Later +- allocations are consed to the front of this list by Comballoc. *) +- + type operation = + Imove + | Ispill +@@ -72,7 +63,7 @@ type operation = + | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool + (* false = initialization, true = assignment *) + | Ialloc of { bytes : int; label_after_call_gc : label option; +- dbginfo : alloc_dbginfo list; spacetime_index : int; } ++ dbginfo : Debuginfo.alloc_dbginfo; spacetime_index : int; } + (** For Spacetime only, Ialloc instructions take one argument, being the + pointer to the trie node for the current function. *) + | Iintop of integer_operation +diff --git a/asmcomp/power/arch.ml b/asmcomp/power/arch.ml +index 70cd75ddb..11d9e2328 100644 +--- a/asmcomp/power/arch.ml ++++ b/asmcomp/power/arch.ml +@@ -47,7 +47,8 @@ type specific_operation = + Imultaddf (* multiply and add *) + | Imultsubf (* multiply and subtract *) + | Ialloc_far of (* allocation in large functions *) +- { bytes : int; label_after_call_gc : int (*Cmm.label*) option; } ++ { bytes : int; label_after_call_gc : int (*Cmm.label*) option; ++ dbginfo : Debuginfo.alloc_dbginfo } + + (* note: we avoid introducing a dependency to Cmm since this dep + is not detected when "make depend" is run under amd64 *) +diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp +index 4c577d0b1..5053d2505 100644 +--- a/asmcomp/power/emit.mlp ++++ b/asmcomp/power/emit.mlp +@@ -308,7 +308,7 @@ let adjust_stack_offset delta = + + (* Record live pointers at call points *) + +-let record_frame ?label live raise_ dbg = ++let record_frame ?label live dbg = + let lbl = + match label with + | None -> new_label() +@@ -326,7 +326,7 @@ let record_frame ?label live raise_ dbg = + | _ -> ()) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) +- ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + `{emit_label lbl}:\n` + + (* Record floating-point literals (for PPC32) *) +@@ -546,8 +546,8 @@ module BR = Branch_relaxation.Make (struct + | Lpoptrap -> 2 + | Lraise _ -> 6 + +- let relax_allocation ~num_bytes:bytes ~label_after_call_gc = +- Lop (Ispecific (Ialloc_far { bytes; label_after_call_gc; })) ++ let relax_allocation ~num_bytes:bytes ~label_after_call_gc ~dbginfo = ++ Lop (Ispecific (Ialloc_far { bytes; label_after_call_gc; dbginfo })) + + (* [classify_addr], above, never identifies these instructions as needing + relaxing. As such, these functions should never be called. *) +@@ -652,26 +652,26 @@ let emit_instr i = + | ELF32 -> + ` mtctr {emit_reg i.arg.(0)}\n`; + ` bctrl\n`; +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + | ELF64v1 -> + ` ld 0, 0({emit_reg i.arg.(0)})\n`; (* code pointer *) + ` mtctr 0\n`; + ` ld 2, 8({emit_reg i.arg.(0)})\n`; (* TOC for callee *) + ` bctrl\n`; +- record_frame i.live false i.dbg ~label:label_after; ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after; + emit_reload_toc() + | ELF64v2 -> + ` mtctr {emit_reg i.arg.(0)}\n`; + ` mr 12, {emit_reg i.arg.(0)}\n`; (* addr of fn in r12 *) + ` bctrl\n`; +- record_frame i.live false i.dbg ~label:label_after; ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after; + emit_reload_toc() + end + | Lop(Icall_imm { func; label_after; }) -> + begin match abi with + | ELF32 -> + emit_call func; +- record_frame i.live false i.dbg ~label:label_after ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after + | ELF64v1 | ELF64v2 -> + (* For PPC64, we cannot just emit a "bl s; nop" sequence, because + of the following scenario: +@@ -691,7 +691,7 @@ let emit_instr i = + Cost: 3 instructions if same TOC, 7 if different TOC. + Let's try option 2. *) + emit_call func; +- record_frame i.live false i.dbg ~label:label_after; ++ record_frame i.live (Dbg_other i.dbg) ~label:label_after; + ` nop\n`; + emit_reload_toc() + end +@@ -751,11 +751,11 @@ let emit_instr i = + ` addis 25, 0, {emit_upper emit_symbol func}\n`; + ` addi 25, 25, {emit_lower emit_symbol func}\n`; + emit_call "caml_c_call"; +- record_frame i.live false i.dbg ++ record_frame i.live (Dbg_other i.dbg) + | ELF64v1 | ELF64v2 -> + emit_tocload emit_gpr 25 (TocSym func); + emit_call "caml_c_call"; +- record_frame i.live false i.dbg; ++ record_frame i.live (Dbg_other i.dbg); + ` nop\n` + end + | Lop(Istackoffset n) -> +@@ -786,15 +786,15 @@ let emit_instr i = + | Single -> "stfs" + | Double | Double_u -> "stfd" in + emit_load_store storeinstr addr i.arg 1 i.arg.(0) +- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> ++ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> + let call_gc_lbl = label_for_call_gc ?label_after_call_gc n in + ` addi 31, 31, {emit_int(-n)}\n`; + ` {emit_string cmplg} 31, 30\n`; + ` addi {emit_reg i.res.(0)}, 31, {emit_int size_addr}\n`; + ` bltl {emit_label call_gc_lbl}\n`; + (* Exactly 4 instructions after the beginning of the alloc sequence *) +- record_frame i.live false Debuginfo.none +- | Lop(Ispecific(Ialloc_far { bytes = n; label_after_call_gc; })) -> ++ record_frame i.live (Dbg_alloc dbginfo) ++ | Lop(Ispecific(Ialloc_far { bytes = n; label_after_call_gc; dbginfo })) -> + let call_gc_lbl = label_for_call_gc ?label_after_call_gc n in + let lbl = new_label() in + ` addi 31, 31, {emit_int(-n)}\n`; +@@ -802,7 +802,7 @@ let emit_instr i = + ` bge {emit_label lbl}\n`; + ` bl {emit_label call_gc_lbl}\n`; + (* Exactly 4 instructions after the beginning of the alloc sequence *) +- record_frame i.live false Debuginfo.none; ++ record_frame i.live (Dbg_alloc dbginfo); + `{emit_label lbl}: addi {emit_reg i.res.(0)}, 31, {emit_int size_addr}\n` + | Lop(Iintop Isub) -> (* subfc has swapped arguments *) + ` subfc {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` +@@ -821,7 +821,7 @@ let emit_instr i = + end + | Lop(Iintop (Icheckbound { label_after_error; })) -> + if !Clflags.debug then +- record_frame Reg.Set.empty false i.dbg ?label:label_after_error; ++ record_frame Reg.Set.empty (Dbg_other i.dbg) ?label:label_after_error; + ` {emit_string tglle} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` + | Lop(Iintop op) -> + let instr = name_for_intop op in +@@ -839,7 +839,7 @@ let emit_instr i = + end + | Lop(Iintop_imm(Icheckbound { label_after_error; }, n)) -> + if !Clflags.debug then +- record_frame Reg.Set.empty false i.dbg ?label:label_after_error; ++ record_frame Reg.Set.empty (Dbg_other i.dbg) ?label:label_after_error; + ` {emit_string tglle}i {emit_reg i.arg.(0)}, {emit_int n}\n` + | Lop(Iintop_imm(op, n)) -> + let instr = name_for_intop_imm op in +@@ -1023,11 +1023,11 @@ let emit_instr i = + | _ -> ` std 0, {emit_int (backtrace_pos * 8)}(28)\n` + end; + emit_call "caml_raise_exn"; +- record_frame Reg.Set.empty true i.dbg; ++ record_frame Reg.Set.empty (Dbg_raise i.dbg); + emit_call_nop() + | Lambda.Raise_reraise -> + emit_call "caml_raise_exn"; +- record_frame Reg.Set.empty true i.dbg; ++ record_frame Reg.Set.empty (Dbg_raise i.dbg); + emit_call_nop() + | Lambda.Raise_notrace -> + ` {emit_string lg} 0, {emit_int trap_handler_offset}(29)\n`; +@@ -1249,6 +1249,7 @@ let end_assembly() = + (fun l -> ` {emit_string datag} {emit_label l}\n`); + efa_data_label = + (fun l -> ` {emit_string datag} {emit_label l}\n`); ++ efa_8 = (fun n -> ` .byte {emit_int n}\n`); + efa_16 = (fun n -> ` .short {emit_int n}\n`); + efa_32 = (fun n -> ` .long {emit_int32 n}\n`); + efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); +diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp +index 05070ec7c..ad3e09037 100644 +--- a/asmcomp/s390x/emit.mlp ++++ b/asmcomp/s390x/emit.mlp +@@ -168,7 +168,7 @@ let emit_set_comp cmp res = + + (* Record live pointers at call points *) + +-let record_frame_label ?label live raise_ dbg = ++let record_frame_label ?label live dbg = + let lbl = + match label with + | None -> new_label() +@@ -186,11 +186,11 @@ let record_frame_label ?label live raise_ dbg = + | _ -> ()) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) +- ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + lbl + +-let record_frame ?label live raise_ dbg = +- let lbl = record_frame_label ?label live raise_ dbg in ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in + `{emit_label lbl}:` + + (* Record calls to caml_call_gc, emitted out of line. *) +@@ -218,7 +218,7 @@ let bound_error_call = ref 0 + let bound_error_label ?label dbg = + if !Clflags.debug then begin + let lbl_bound_error = new_label() in +- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in + bound_error_sites := + { bd_lbl = lbl_bound_error; bd_frame = lbl_frame } :: !bound_error_sites; + lbl_bound_error +@@ -357,11 +357,11 @@ let emit_instr i = + emit_load_symbol_addr i.res.(0) s + | Lop(Icall_ind { label_after; }) -> + ` basr %r14, {emit_reg i.arg.(0)}\n`; +- `{record_frame i.live false i.dbg ~label:label_after}\n` ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` + + | Lop(Icall_imm { func; label_after; }) -> + emit_call func; +- `{record_frame i.live false i.dbg ~label:label_after}\n` ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` + | Lop(Itailcall_ind { label_after = _; }) -> + let n = frame_size() in + if !contains_calls then +@@ -387,7 +387,7 @@ let emit_instr i = + else begin + emit_load_symbol_addr reg_r7 func; + emit_call "caml_c_call"; +- `{record_frame i.live false i.dbg ~label:label_after}\n` ++ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` + end + + | Lop(Istackoffset n) -> +@@ -424,11 +424,11 @@ let emit_instr i = + | Double | Double_u -> "stdy" in + emit_load_store storeinstr addr i.arg 1 i.arg.(0) + +- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> ++ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> + let lbl_redo = new_label() in + let lbl_call_gc = new_label() in + let lbl_frame = +- record_frame_label i.live false i.dbg ?label:label_after_call_gc ++ record_frame_label i.live (Dbg_alloc dbginfo) ?label:label_after_call_gc + in + call_gc_sites := + { gc_lbl = lbl_call_gc; +@@ -641,10 +641,10 @@ let emit_instr i = + ` lghi %r1, 0\n`; + ` stg %r1, {emit_int offset}(%r10)\n`; + emit_call "caml_raise_exn"; +- `{record_frame Reg.Set.empty true i.dbg}\n` ++ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` + | Lambda.Raise_reraise -> + emit_call "caml_raise_exn"; +- `{record_frame Reg.Set.empty true i.dbg}\n` ++ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` + | Lambda.Raise_notrace -> + ` lg %r1, 0(%r13)\n`; + ` lgr %r15, %r13\n`; +@@ -782,6 +782,7 @@ let end_assembly() = + emit_frames + { efa_code_label = (fun l -> ` .quad {emit_label l}\n`); + efa_data_label = (fun l -> ` .quad {emit_label l}\n`); ++ efa_8 = (fun n -> ` .byte {emit_int n}\n`); + efa_16 = (fun n -> ` .short {emit_int n}\n`); + efa_32 = (fun n -> ` .long {emit_int32 n}\n`); + efa_word = (fun n -> ` .quad {emit_int n}\n`); +diff --git a/lambda/debuginfo.ml b/lambda/debuginfo.ml +index 7a3390222..29c098f1e 100644 +--- a/lambda/debuginfo.ml ++++ b/lambda/debuginfo.ml +@@ -29,6 +29,11 @@ type item = { + + type t = item list + ++type alloc_dbginfo_item = ++ { alloc_words : int; ++ alloc_dbg : t } ++type alloc_dbginfo = alloc_dbginfo_item list ++ + let none = [] + + let is_none = function +diff --git a/lambda/debuginfo.mli b/lambda/debuginfo.mli +index 4dc5e5990..954a152dd 100644 +--- a/lambda/debuginfo.mli ++++ b/lambda/debuginfo.mli +@@ -25,6 +25,17 @@ type item = private { + + type t = item list + ++type alloc_dbginfo_item = ++ { alloc_words : int; ++ alloc_dbg : t } ++(** Due to Comballoc, a single Ialloc instruction may combine several ++ unrelated allocations. Their Debuginfo.t (which may differ) are stored ++ as a list of alloc_dbginfo. This list is in order of increasing memory ++ address, which is the reverse of the original allocation order. Later ++ allocations are consed to the front of this list by Comballoc. *) ++ ++type alloc_dbginfo = alloc_dbginfo_item list ++ + val none : t + + val is_none : t -> bool +-- +2.24.1 + diff --git a/0005-Add-riscv64-backend.patch b/0008-Add-riscv64-backend.patch similarity index 65% rename from 0005-Add-riscv64-backend.patch rename to 0008-Add-riscv64-backend.patch index ce69f7a..07622f1 100644 --- a/0005-Add-riscv64-backend.patch +++ b/0008-Add-riscv64-backend.patch @@ -1,24 +1,25 @@ -From 68ad1dae406a172cd3b0a4b38b8b36150c270b96 Mon Sep 17 00:00:00 2001 +From f5d7b834c50945c30cf55f284346128ab5cdeb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= -Date: Mon, 18 Nov 2019 01:13:30 +0100 -Subject: [PATCH 5/5] Add riscv64 backend +Date: Mon, 11 Nov 2019 23:28:15 +0100 +Subject: [PATCH 8/8] Add riscv64 backend -(cherry picked from commit c8a361f586c21eca25108ee79c495bb480a1c3f3) +(cherry picked from commit d6b3808de753266a44fc941aeb5224a6d2164ce1) --- + Makefile | 2 +- README.adoc | 1 + - asmcomp/riscv/CSE.ml | 36 ++ - asmcomp/riscv/arch.ml | 87 +++++ - asmcomp/riscv/emit.mlp | 669 +++++++++++++++++++++++++++++++++ - asmcomp/riscv/proc.ml | 336 +++++++++++++++++ - asmcomp/riscv/reload.ml | 16 + - asmcomp/riscv/scheduling.ml | 19 + - asmcomp/riscv/selection.ml | 71 ++++ - configure | 10 +- - configure.ac | 11 +- + asmcomp/riscv/CSE.ml | 39 ++ + asmcomp/riscv/arch.ml | 90 +++++ + asmcomp/riscv/emit.mlp | 693 +++++++++++++++++++++++++++++++++ + asmcomp/riscv/proc.ml | 359 +++++++++++++++++ + asmcomp/riscv/reload.ml | 19 + + asmcomp/riscv/scheduling.ml | 22 ++ + asmcomp/riscv/selection.ml | 74 ++++ + configure | 71 +--- + configure.ac | 18 +- runtime/caml/stack.h | 5 + - runtime/riscv.S | 427 +++++++++++++++++++++ - testsuite/tools/asmgen_riscv.S | 87 +++++ - 13 files changed, 1770 insertions(+), 5 deletions(-) + runtime/riscv.S | 422 ++++++++++++++++++++ + testsuite/tools/asmgen_riscv.S | 89 +++++ + 14 files changed, 1835 insertions(+), 69 deletions(-) create mode 100644 asmcomp/riscv/CSE.ml create mode 100644 asmcomp/riscv/arch.ml create mode 100644 asmcomp/riscv/emit.mlp @@ -29,6 +30,19 @@ Subject: [PATCH 5/5] Add riscv64 backend create mode 100644 runtime/riscv.S create mode 100644 testsuite/tools/asmgen_riscv.S +diff --git a/Makefile b/Makefile +index 802196d1e..c862a48b1 100644 +--- a/Makefile ++++ b/Makefile +@@ -38,7 +38,7 @@ include stdlib/StdlibModules + + CAMLC=$(BOOT_OCAMLC) -g -nostdlib -I boot -use-prims runtime/primitives + CAMLOPT=$(CAMLRUN) ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink +-ARCHES=amd64 i386 arm arm64 power s390x ++ARCHES=amd64 i386 arm arm64 power s390x riscv + INCLUDES=-I utils -I parsing -I typing -I bytecomp -I file_formats \ + -I lambda -I middle_end -I middle_end/closure \ + -I middle_end/flambda -I middle_end/flambda/base_types \ diff --git a/README.adoc b/README.adoc index 504c7a708..4dc404da3 100644 --- a/README.adoc @@ -43,21 +57,24 @@ index 504c7a708..4dc404da3 100644 diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml new file mode 100644 -index 000000000..302811a99 +index 000000000..6aed1c07f --- /dev/null +++ b/asmcomp/riscv/CSE.ml -@@ -0,0 +1,36 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2106 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,39 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* CSE for the RISC-V *) + @@ -85,21 +102,24 @@ index 000000000..302811a99 + (new cse)#fundecl f diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml new file mode 100644 -index 000000000..22c807c49 +index 000000000..4d95a6f5e --- /dev/null +++ b/asmcomp/riscv/arch.ml -@@ -0,0 +1,87 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,90 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* Specific operations for the RISC-V processor *) + @@ -178,37 +198,46 @@ index 000000000..22c807c49 + printreg arg.(0) printreg arg.(1) printreg arg.(2) diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp new file mode 100644 -index 000000000..f9e3874d9 +index 000000000..03af45de4 --- /dev/null +++ b/asmcomp/riscv/emit.mlp -@@ -0,0 +1,669 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,693 @@ ++# 2 "asmcomp/riscv/emit.mlp" ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* Emission of RISC-V assembly code *) + -+open Misc +open Cmm +open Arch +open Proc +open Reg +open Mach -+open Linearize ++open Linear +open Emitaux + +(* Layout of the stack. The stack is kept 16-aligned. *) + +let stack_offset = ref 0 + ++let num_stack_slots = Array.make Proc.num_register_classes 0 ++ ++let prologue_required = ref false ++ ++let contains_calls = ref false ++ +let frame_size () = + let size = + !stack_offset + (* Trap frame, outgoing parameters *) @@ -229,7 +258,7 @@ index 000000000..f9e3874d9 +(* Output a symbol *) + +let emit_symbol s = -+ Emitaux.emit_symbol '.' s ++ emit_symbol '.' s + +let emit_jump op s = + if !Clflags.dlcode || !Clflags.pic_code @@ -241,10 +270,8 @@ index 000000000..f9e3874d9 + +(* Output a label *) + -+let label_prefix = "L" -+ +let emit_label lbl = -+ emit_string label_prefix; emit_int lbl ++ emit_string ".L"; emit_int lbl + +(* Section switching *) + @@ -257,25 +284,24 @@ index 000000000..f9e3874d9 +let rodata_space = + ".section .rodata" + -+let reg_tmp1 = phys_reg 21 (* used by the assembler *) ++(* Names for special regs *) ++ ++let reg_tmp1 = phys_reg 21 +let reg_tmp2 = phys_reg 22 +let reg_t2 = phys_reg 16 -+(* let reg_fp = phys_reg 23 *) ++let reg_domain_state_ptr = phys_reg 23 +let reg_trap = phys_reg 24 +let reg_alloc_ptr = phys_reg 25 +let reg_alloc_lim = phys_reg 26 + -+(* Names of instructions that differ in 32 and 64-bit modes *) -+ -+let lg = if rv64 then "ld" else "lw" -+let stg = if rv64 then "sd" else "sw" -+let datag = if rv64 then ".quad" else ".long" -+ +(* Output a pseudo-register *) + -+let emit_reg = function -+ | {loc = Reg r} -> emit_string (register_name r) -+ | _ -> fatal_error "Emit.emit_reg" ++let reg_name = function ++ | {loc = Reg r} -> register_name r ++ | _ -> Misc.fatal_error "Emit.reg_name" ++ ++let emit_reg r = ++ emit_string (reg_name r) + +(* Adjust sp by the given byte amount *) + @@ -287,47 +313,42 @@ index 000000000..f9e3874d9 + ` li {emit_reg reg_tmp1}, {emit_int n}\n`; + ` add sp, sp, {emit_reg reg_tmp1}\n` + -+let reload_ra n = -+ let ofs = n - size_addr in ++let emit_mem_op op src ofs = + if is_immediate ofs then -+ ` {emit_string lg} ra, {emit_int ofs}(sp)\n` ++ ` {emit_string op} {emit_string src}, {emit_int ofs}(sp)\n` + else begin + ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; + ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string lg} ra, 0({emit_reg reg_tmp1})\n` ++ ` {emit_string op} {emit_string src}, 0({emit_reg reg_tmp1})\n` + end + ++let emit_store src ofs = ++ emit_mem_op (if rv64 then "sd" else "sw") src ofs ++ ++let emit_load dst ofs = ++ emit_mem_op (if rv64 then "ld" else "lw") dst ofs ++ ++let reload_ra n = ++ emit_load "ra" (n - size_addr) ++ +let store_ra n = -+ let ofs = n - size_addr in -+ if is_immediate ofs then -+ ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string stg} ra, 0({emit_reg reg_tmp1})\n` -+ end ++ emit_store "ra" (n - size_addr) + -+let emit_store stg src ofs = -+ if is_immediate ofs then -+ ` {emit_string stg} {emit_reg src}, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string stg} {emit_reg src}, 0({emit_reg reg_tmp1})\n` -+ end ++let emit_store src ofs = ++ emit_store (reg_name src) ofs + -+let emit_load lg dst ofs = -+ if is_immediate ofs then -+ ` {emit_string lg} {emit_reg dst}, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string lg} {emit_reg dst}, 0({emit_reg reg_tmp1})\n` -+ end ++let emit_load dst ofs = ++ emit_load (reg_name dst) ofs ++ ++let emit_float_load dst ofs = ++ emit_mem_op "fld" (reg_name dst) ofs ++ ++let emit_float_store src ofs = ++ emit_mem_op "fsd" (reg_name src) ofs + +(* Record live pointers at call points *) + -+let record_frame_label ?label live raise_ dbg = ++let record_frame_label ?label live dbg = + let lbl = + match label with + | None -> new_label() @@ -346,11 +367,11 @@ index 000000000..f9e3874d9 + ) + live; + record_frame_descr ~label:lbl ~frame_size:(frame_size()) -+ ~live_offset:!live_offset ~raise_frame:raise_ dbg; ++ ~live_offset:!live_offset dbg; + lbl + -+let record_frame ?label live raise_ dbg = -+ let lbl = record_frame_label ?label live raise_ dbg in ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in + `{emit_label lbl}:\n` + +(* Record calls to the GC -- we've moved them out of the way *) @@ -381,7 +402,7 @@ index 000000000..f9e3874d9 +let bound_error_label ?label dbg = + if !Clflags.debug || !bound_error_sites = [] then begin + let lbl_bound_error = new_label() in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in + bound_error_sites := + { bd_lbl = lbl_bound_error; + bd_frame_lbl = lbl_frame } :: !bound_error_sites; @@ -414,7 +435,7 @@ index 000000000..f9e3874d9 + | Ilsr -> "srl" + | Iasr -> "sra" + | Imod -> "rem" -+ | _ -> fatal_error "Emit.Intop" ++ | _ -> Misc.fatal_error "Emit.Intop" + +let name_for_intop_imm = function + | Iadd -> "addi" @@ -424,19 +445,19 @@ index 000000000..f9e3874d9 + | Ilsl -> "slli" + | Ilsr -> "srli" + | Iasr -> "srai" -+ | _ -> fatal_error "Emit.Intop_imm" ++ | _ -> Misc.fatal_error "Emit.Intop_imm" + +let name_for_floatop1 = function + | Inegf -> "fneg.d" + | Iabsf -> "fabs.d" -+ | _ -> fatal_error "Emit.Iopf1" ++ | _ -> Misc.fatal_error "Emit.Iopf1" + +let name_for_floatop2 = function + | Iaddf -> "fadd.d" + | Isubf -> "fsub.d" + | Imulf -> "fmul.d" + | Idivf -> "fdiv.d" -+ | _ -> fatal_error "Emit.Iopf2" ++ | _ -> Misc.fatal_error "Emit.Iopf2" + +let name_for_specific = function + | Imultaddf false -> "fmadd.d" @@ -457,7 +478,7 @@ index 000000000..f9e3874d9 + match i.desc with + Lend -> () + | Lprologue -> -+ assert (Proc.prologue_required ()); ++ assert (!prologue_required); + let n = frame_size() in + emit_stack_adjustment (-n); + if !contains_calls then store_ra n @@ -471,18 +492,18 @@ index 000000000..f9e3874d9 + ` fmv.d {emit_reg dst}, {emit_reg src}\n` + | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> + let ofs = slot_offset s (register_class dst) in -+ emit_store stg src ofs ++ emit_store src ofs + | {loc = Reg _; typ = Float}, {loc = Stack s} -> + let ofs = slot_offset s (register_class dst) in -+ emit_store "fsd" src ofs ++ emit_float_store src ofs + | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> + let ofs = slot_offset s (register_class src) in -+ emit_load lg dst ofs ++ emit_load dst ofs + | {loc = Stack s; typ = Float}, {loc = Reg _} -> + let ofs = slot_offset s (register_class src) in -+ emit_load "fld" dst ofs ++ emit_float_load dst ofs + | _ -> -+ fatal_error "Emit: Imove" ++ Misc.fatal_error "Emit: Imove" + end + | Lop(Iconst_int n) -> + ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` @@ -494,10 +515,10 @@ index 000000000..f9e3874d9 + ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` + | Lop(Icall_ind {label_after = label}) -> + ` jalr {emit_reg i.arg.(0)}\n`; -+ record_frame ~label i.live false i.dbg ++ record_frame ~label i.live (Dbg_other i.dbg) + | Lop(Icall_imm {func; label_after = label}) -> + ` {emit_call func}\n`; -+ record_frame ~label i.live false i.dbg ++ record_frame ~label i.live (Dbg_other i.dbg) + | Lop(Itailcall_ind {label_after = _}) -> + let n = frame_size() in + if !contains_calls then reload_ra n; @@ -515,7 +536,7 @@ index 000000000..f9e3874d9 + | Lop(Iextcall{func; alloc = true; label_after = label}) -> + ` la {emit_reg reg_t2}, {emit_symbol func}\n`; + ` {emit_call "caml_c_call"}\n`; -+ record_frame ~label i.live false i.dbg ++ record_frame ~label i.live (Dbg_other i.dbg) + | Lop(Iextcall{func; alloc = false; label_after = _}) -> + ` {emit_call func}\n` + | Lop(Istackoffset n) -> @@ -534,7 +555,7 @@ index 000000000..f9e3874d9 + | Sixteen_signed -> "lh" + | Thirtytwo_unsigned -> if rv64 then "lwu" else "lw" + | Thirtytwo_signed -> "lw" -+ | Word_int | Word_val -> lg ++ | Word_int | Word_val -> if rv64 then "ld" else "lw" + | Single -> assert false + | Double | Double_u -> "fld" + in @@ -550,22 +571,28 @@ index 000000000..f9e3874d9 + | Byte_unsigned | Byte_signed -> "sb" + | Sixteen_unsigned | Sixteen_signed -> "sh" + | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" -+ | Word_int | Word_val -> stg ++ | Word_int | Word_val -> if rv64 then "sd" else "sw" + | Single -> assert false + | Double | Double_u -> "fsd" + in + ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` -+ | Lop(Ialloc {bytes = n; label_after_call_gc = label; _}) -> -+ let lbl_frame_lbl = record_frame_label ?label i.live false i.dbg in -+ let lbl_redo = new_label () in ++ | Lop(Ialloc {bytes; label_after_call_gc = label; dbginfo}) -> ++ let lbl_frame_lbl = record_frame_label ?label i.live (Dbg_alloc dbginfo) in ++ let lbl_after_alloc = new_label () in + let lbl_call_gc = new_label () in -+ `{emit_label lbl_redo}:\n`; -+ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, -{emit_int n}\n`; -+ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; ++ let n = -bytes in ++ if is_immediate n then ++ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_int n}\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; ++ ` add {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_reg reg_tmp1}\n` ++ end; + ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; ++ `{emit_label lbl_after_alloc}:\n`; ++ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; + call_gc_sites := + { gc_lbl = lbl_call_gc; -+ gc_return_lbl = lbl_redo; ++ gc_return_lbl = lbl_after_alloc; + gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites + | Lop(Iintop(Icomp cmp)) -> + begin match cmp with @@ -605,7 +632,7 @@ index 000000000..f9e3874d9 + | Lop(Iintop_imm(Isub, n)) -> + ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` + | Lop(Iintop_imm(Icomp _, _)) -> -+ fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" ++ Misc.fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" + | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> + let lbl = bound_error_label ?label i.dbg in + ` li {emit_reg reg_tmp1}, {emit_int n}\n`; @@ -658,7 +685,7 @@ index 000000000..f9e3874d9 + in + ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` + | Iinttest_imm _ -> -+ fatal_error "Emit.emit_instr (Iinttest_imm _)" ++ Misc.fatal_error "Emit.emit_instr (Iinttest_imm _)" + | Ifloattest cmp -> + let branch = + match cmp with @@ -694,7 +721,7 @@ index 000000000..f9e3874d9 + | None -> () + | Some lbl -> ` bgtz {emit_reg reg_tmp1}, {emit_label lbl}\n` + end -+ | Lswitch jumptbl -> (* FIXME FIXME ? *) ++ | Lswitch jumptbl -> + let lbl = new_label() in + ` la {emit_reg reg_tmp1}, {emit_label lbl}\n`; + ` slli {emit_reg reg_tmp2}, {emit_reg i.arg.(0)}, 2\n`; @@ -706,27 +733,35 @@ index 000000000..f9e3874d9 + done + | Lentertrap -> + () ++ | Ladjust_trap_depth { delta_traps } -> ++ (* each trap occupes 16 bytes on the stack *) ++ let delta = 16 * delta_traps in ++ stack_offset := !stack_offset + delta + | Lpushtrap {lbl_handler} -> + ` la {emit_reg reg_tmp1}, {emit_label lbl_handler}\n`; + ` addi sp, sp, -16\n`; + stack_offset := !stack_offset + 16; -+ ` {emit_string stg} {emit_reg reg_tmp1}, {emit_int size_addr}(sp)\n`; -+ ` {emit_string stg} {emit_reg reg_trap}, 0(sp)\n`; ++ emit_store reg_tmp1 size_addr; ++ emit_store reg_trap 0; + ` mv {emit_reg reg_trap}, sp\n` + | Lpoptrap -> -+ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; ++ emit_load reg_trap 0; + ` addi sp, sp, 16\n`; + stack_offset := !stack_offset - 16 + | Lraise k -> -+ begin match !Clflags.debug, k with -+ | true, Cmm.Raise_withtrace -> ++ begin match k with ++ | Lambda.Raise_regular -> ++ let offset = Domainstate.(idx_of_field Domain_backtrace_pos) * 8 in ++ ` sd zero, {emit_int offset}({emit_reg reg_domain_state_ptr})\n`; + ` {emit_call "caml_raise_exn"}\n`; -+ record_frame Reg.Set.empty true i.dbg -+ | false, _ -+ | true, Cmm.Raise_notrace -> ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) ++ | Lambda.Raise_reraise -> ++ ` {emit_call "caml_raise_exn"}\n`; ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) ++ | Lambda.Raise_notrace -> + ` mv sp, {emit_reg reg_trap}\n`; -+ ` {emit_string lg} {emit_reg reg_tmp1}, {emit_int size_addr}(sp)\n`; -+ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; ++ emit_load reg_tmp1 size_addr; ++ emit_load reg_trap 0; + ` addi sp, sp, 16\n`; + ` jalr {emit_reg reg_tmp1}\n` + end @@ -744,6 +779,11 @@ index 000000000..f9e3874d9 + stack_offset := 0; + call_gc_sites := []; + bound_error_sites := []; ++ for i = 0 to Proc.num_register_classes - 1 do ++ num_stack_slots.(i) <- fundecl.fun_num_stack_slots.(i); ++ done; ++ prologue_required := fundecl.fun_prologue_required; ++ contains_calls := fundecl.fun_contains_calls; + float_literals := []; + ` .globl {emit_symbol fundecl.fun_name}\n`; + ` .type {emit_symbol fundecl.fun_name}, @function\n`; @@ -770,6 +810,9 @@ index 000000000..f9e3874d9 + +(* Emission of data *) + ++let datag = ++ if rv64 then ".quad" else ".long" ++ +let declare_global_data s = + ` .globl {emit_symbol s}\n`; + ` .type {emit_symbol s}, @object\n` @@ -842,6 +885,7 @@ index 000000000..f9e3874d9 + emit_frames + { efa_code_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); + efa_data_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); ++ efa_8 = (fun n -> ` .byte {emit_int n}\n`); + efa_16 = (fun n -> ` .short {emit_int n}\n`); + efa_32 = (fun n -> ` .long {emit_int32 n}\n`); + efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); @@ -853,21 +897,24 @@ index 000000000..f9e3874d9 + } diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml new file mode 100644 -index 000000000..0981fae73 +index 000000000..3342952b3 --- /dev/null +++ b/asmcomp/riscv/proc.ml -@@ -0,0 +1,336 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,359 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* Description of the RISC-V *) + @@ -883,26 +930,40 @@ index 000000000..0981fae73 + +(* Registers available for register allocation *) + -+(* Integer register map: -+ zero always zero -+ ra return address -+ sp, gp, tp stack pointer, global pointer, thread pointer (preserved by C) -+ a0 - a7 0 - 7 arguments/results -+ s2 - s9 8 - 15 arguments/results (preserved by C) -+ t2 - t6 16 - 20 temporary -+ t0 21 temporary (used by assembler) -+ t1 22 temporary (reserved for code gen) -+ s0 23 frame pointer (preserved by C) -+ s1 24 trap pointer (preserved by C) -+ s10 25 allocation pointer (preserved by C) -+ s11 26 allocation limit (preserved by C) -+ Floating-point register map: -+ ft0 - ft7 100 - 107 temporary -+ fs0 - fs1 108 - 109 general purpose (preserved by C) -+ fa0 - fa7 110 - 117 arguments/results -+ fs2 - fs9 118 - 125 arguments/results (preserved by C) -+ fs10 - fs11 126 - 127 general purpose (preserved by C) -+ ft8 - ft11 128 - 131 temporary ++(* Integer register map ++ -------------------- ++ ++ zero always zero ++ ra return address ++ sp, gp, tp stack pointer, global pointer, thread pointer ++ a0-a7 0-7 arguments/results ++ s2-s9 8-15 arguments/results (preserved by C) ++ t2-t6 16-20 temporary ++ t0-t1 21-22 temporary (used by code generator) ++ s0 23 domain pointer (preserved by C) ++ s1 24 trap pointer (preserved by C) ++ s10 25 allocation pointer (preserved by C) ++ s11 26 allocation limit (preserved by C) ++ ++ Floating-point register map ++ --------------------------- ++ ++ ft0-ft7 100-107 temporary ++ fs0-fs1 108-109 general purpose (preserved by C) ++ fa0-fa7 110-117 arguments/results ++ fs2-fs9 118-125 arguments/results (preserved by C) ++ fs10-fs11 126-127 general purpose (preserved by C) ++ ft8-ft11 128-131 temporary ++ ++ Additional notes ++ ---------------- ++ ++ - t0-t1 are used by the assembler and code generator, so ++ not available for register allocation. ++ ++ - t0-t6 may be used by PLT stubs, so should not be used to pass ++ arguments and may be clobbered by [Ialloc] in the presence of dynamic ++ linking. +*) + +let int_reg_name = @@ -1103,7 +1164,7 @@ index 000000000..0981fae73 + in + ensure_single_regs loc + -+(* Exceptions are in GPR 3 *) ++(* Exceptions are in a0 *) + +let loc_exn_bucket = phys_reg 0 + @@ -1114,19 +1175,25 @@ index 000000000..0981fae73 +(* Registers destroyed by operations *) + +let destroyed_at_c_call = ++ (* s0-s11 and fs0-fs11 are callee-save *) + Array.of_list(List.map phys_reg -+ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; (* 21; 22; *) ++ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; + 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; + 117; 128; 129; 130; 131]) + ++let destroyed_at_alloc = ++ (* t0-t3 are used for PLT stubs *) ++ if !Clflags.dlcode then Array.map phys_reg [|16; 17; 18; 19; 20|] else [| |] ++ +let destroyed_at_oper = function + | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs + | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call ++ | Iop(Ialloc _) -> destroyed_at_alloc + | _ -> [||] + +let destroyed_at_raise = all_phys_regs + -+let destroyed_at_reloadretaddr = [| |] (* CHECK *) ++let destroyed_at_reloadretaddr = [| |] + +(* Maximal register pressure *) + @@ -1150,14 +1217,13 @@ index 000000000..0981fae73 + +(* Layout of the stack *) + -+let num_stack_slots = [| 0; 0 |] -+let contains_calls = ref false ++let frame_required fd = ++ fd.fun_contains_calls ++ || fd.fun_num_stack_slots.(0) > 0 ++ || fd.fun_num_stack_slots.(1) > 0 + -+let frame_required () = -+ !contains_calls || num_stack_slots.(0) > 0 || num_stack_slots.(1) > 0 -+ -+let prologue_required () = -+ frame_required () ++let prologue_required fd = ++ frame_required fd + +(* See + https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md *) @@ -1165,8 +1231,9 @@ index 000000000..0981fae73 +let int_dwarf_reg_numbers = + [| 10; 11; 12; 13; 14; 15; 16; 17; + 18; 19; 20; 21; 22; 23; 24; 25; -+ 7; 29; 29; 30; 31; -+ 5; 6; 8; 9; 26; 27; ++ 7; 28; 29; 30; 31; ++ 5; 6; ++ 8; 9; 26; 27; + |] + +let float_dwarf_reg_numbers = @@ -1195,21 +1262,24 @@ index 000000000..0981fae73 +let init () = () diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml new file mode 100644 -index 000000000..85b970342 +index 000000000..be18cbd7f --- /dev/null +++ b/asmcomp/riscv/reload.ml -@@ -0,0 +1,16 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,19 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* Reloading for the RISC-V *) + @@ -1217,46 +1287,52 @@ index 000000000..85b970342 + (new Reloadgen.reload_generic)#fundecl f diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml new file mode 100644 -index 000000000..e436be1cc +index 000000000..e56b723c5 --- /dev/null +++ b/asmcomp/riscv/scheduling.ml -@@ -0,0 +1,19 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,22 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* Instruction scheduling for the RISC-V *) + -+let _ = let module M = Schedgen in () (* to create a dependency *) ++open! Schedgen (* to create a dependency *) + +(* Scheduling is turned off. *) + +let fundecl f = f diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml new file mode 100644 -index 000000000..62fccb648 +index 000000000..0e2d84f48 --- /dev/null +++ b/asmcomp/riscv/selection.ml -@@ -0,0 +1,71 @@ -+(***********************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. All rights reserved. This file is distributed *) -+(* under the terms of the Q Public License version 1.0. *) -+(* *) -+(***********************************************************************) +@@ -0,0 +1,74 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) + +(* Instruction selection for the RISC-V processor *) + @@ -1318,10 +1394,71 @@ index 000000000..62fccb648 + +let fundecl f = (new selector)#emit_fundecl f diff --git a/configure b/configure -index b8f74728f..ec3d7e83d 100755 +index b8f74728f..4b827c5cc 100755 --- a/configure +++ b/configure -@@ -13509,6 +13509,8 @@ if test x"$enable_shared" != "xno"; then : +@@ -1,60 +1,4 @@ + #! /bin/sh +- +-if test -e '.git' ; then : +- if test -z "$ac_read_git_config" ; then : +- extra_args=$(git config ocaml.configure 2>/dev/null) +- extended_cache=$(git config ocaml.configure-cache 2>/dev/null) +- cache_file= +- +- # If ocaml.configure-cache is set, parse the command-line for the --host +- # option, in order to determine the name of the cache file. +- if test -n "$extended_cache" ; then : +- echo "Detected Git configuration option ocaml.configure-cache set to \ +-\"$extended_cache\"" +- dashdash= +- prev= +- host=default +- # The logic here is pretty borrowed from autoconf's +- for option in $extra_args "$@" +- do +- if test -n "$prev" ; then : +- host=$option +- continue +- fi +- +- case $dashdash$option in +- --) +- dashdash=yes ;; +- -host | --host | --hos | --ho) +- prev=host ;; +- -host=* | --host=* | --hos=* | --ho=*) +- case $option in +- *=?*) host=$(expr "X$option" : '[^=]*=\(.*\)') ;; +- *=) host= ;; +- esac ;; +- esac +- done +- cache_file="`dirname "$0"`/$extended_cache/ocaml-$host.cache" +- fi +- +- # If either option has a value, re-invoke configure +- if test -n "$extra_args$cache_file" ; then : +- echo "Detected Git configuration option ocaml.configure set to \ +-\"$extra_args\"" +- # Too much effort to get the echo to show appropriate quoting - the +- # invocation itself intentionally quotes $0 and passes $@ exactly as given +- # but allows a single expansion of ocaml.configure +- if test -n "$cache_file" ; then : +- echo "Re-running $0 $extra_args --cache-file \"$cache_file\" $@" +- ac_read_git_config=true exec "$0" $extra_args \ +- --cache-file "$cache_file" "$@" +- else +- echo "Re-running $0 $extra_args $@" +- ac_read_git_config=true exec "$0" $extra_args "$@" +- fi +- fi +- fi +-fi + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for OCaml 4.10.0. + # +@@ -13509,6 +13453,8 @@ if test x"$enable_shared" != "xno"; then : natdynlink=true ;; #( aarch64-*-freebsd*) : natdynlink=true ;; #( @@ -1330,30 +1467,38 @@ index b8f74728f..ec3d7e83d 100755 *) : ;; esac -@@ -13649,7 +13651,11 @@ fi; system=elf ;; #( +@@ -13649,7 +13595,9 @@ fi; system=elf ;; #( aarch64-*-freebsd*) : arch=arm64; system=freebsd ;; #( x86_64-*-cygwin*) : - arch=amd64; system=cygwin + arch=amd64; system=cygwin ;; #( -+ riscv32-*-linux*) : -+ arch=riscv; model=riscv32; system=linux ;; #( + riscv64-*-linux*) : + arch=riscv; model=riscv64; system=linux ;; #( *) : ;; -@@ -13861,7 +13867,7 @@ esac ;; #( +@@ -13861,13 +13809,14 @@ esac ;; #( *,freebsd) : default_as="${toolpref}as" default_aspp="${toolpref}cc -c" ;; #( - amd64,*|arm,*|arm64,*|i386,*) : +- default_as="${toolpref}as" + amd64,*|arm,*|arm64,*|i386,*|riscv,*) : - default_as="${toolpref}as" case $ocaml_cv_cc_vendor in #( clang-*) : +- default_aspp="${toolpref}clang -c -Wno-trigraphs" ;; #( ++ default_as="${toolpref}clang -c -Wno-trigraphs" ++ default_aspp="${toolpref}clang -c -Wno-trigraphs" ;; #( + *) : +- default_aspp="${toolpref}gcc -c" ;; ++ default_as="${toolpref}as" ++ default_aspp="${toolpref}gcc -c" ;; + esac ;; #( + *) : + ;; diff --git a/configure.ac b/configure.ac -index ad07516e7..562f916dd 100644 +index ad07516e7..48fa4225c 100644 --- a/configure.ac +++ b/configure.ac @@ -841,7 +841,8 @@ AS_IF([test x"$enable_shared" != "xno"], @@ -1366,30 +1511,37 @@ index ad07516e7..562f916dd 100644 # Try to work around the Skylake/Kaby Lake processor bug. AS_CASE(["$CC,$host"], -@@ -934,7 +935,11 @@ AS_CASE([$host], +@@ -934,7 +935,9 @@ AS_CASE([$host], [aarch64-*-freebsd*], [arch=arm64; system=freebsd], [x86_64-*-cygwin*], - [arch=amd64; system=cygwin] + [arch=amd64; system=cygwin], -+ [riscv32-*-linux*], -+ [arch=riscv; model=riscv32; system=linux], + [riscv64-*-linux*], + [arch=riscv; model=riscv64; system=linux] ) AS_IF([test x"$enable_native_compiler" = "xno"], -@@ -1020,7 +1025,7 @@ AS_CASE(["$arch,$system"], +@@ -1020,11 +1023,12 @@ AS_CASE(["$arch,$system"], [*,freebsd], [default_as="${toolpref}as" default_aspp="${toolpref}cc -c"], - [amd64,*|arm,*|arm64,*|i386,*], +- [default_as="${toolpref}as" +- AS_CASE([$ocaml_cv_cc_vendor], +- [clang-*], [default_aspp="${toolpref}clang -c -Wno-trigraphs"], +- [default_aspp="${toolpref}gcc -c"])]) + [amd64,*|arm,*|arm64,*|i386,*|riscv,*], - [default_as="${toolpref}as" - AS_CASE([$ocaml_cv_cc_vendor], - [clang-*], [default_aspp="${toolpref}clang -c -Wno-trigraphs"], ++ [AS_CASE([$ocaml_cv_cc_vendor], ++ [clang-*], [default_as="${toolpref}clang -c -Wno-trigraphs" ++ default_aspp="${toolpref}clang -c -Wno-trigraphs"], ++ [default_as="${toolpref}as" ++ default_aspp="${toolpref}gcc -c"])]) + + AS_IF([test "$with_pic"], + [fpic=true diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index 259f97ac4..dac7cb3f7 100644 +index 44a881e41..3cffbfec9 100644 --- a/runtime/caml/stack.h +++ b/runtime/caml/stack.h @@ -70,6 +70,11 @@ @@ -1406,42 +1558,53 @@ index 259f97ac4..dac7cb3f7 100644 struct caml_context { diff --git a/runtime/riscv.S b/runtime/riscv.S new file mode 100644 -index 000000000..10bc665c6 +index 000000000..6c8da79d0 --- /dev/null +++ b/runtime/riscv.S -@@ -0,0 +1,427 @@ -+/***********************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2017 Institut National de Recherche en Informatique et */ -+/* en Automatique. All rights reserved. This file is distributed */ -+/* under the terms of the GNU Library General Public License, with */ -+/* the special exception on linking described in file ../LICENSE. */ -+/* */ -+/***********************************************************************/ +@@ -0,0 +1,422 @@ ++/**************************************************************************/ ++/* */ ++/* OCaml */ ++/* */ ++/* Nicolas Ojeda Bar */ ++/* */ ++/* Copyright 2016 Institut National de Recherche en Informatique et */ ++/* en Automatique. */ ++/* */ ++/* All rights reserved. This file is distributed under the terms of */ ++/* the GNU Lesser General Public License version 2.1, with the */ ++/* special exception on linking described in the file LICENSE. */ ++/* */ ++/**************************************************************************/ + +/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ +/* Must be preprocessed by cpp */ + ++#define ARG_DOMAIN_STATE_PTR t1 ++#define DOMAIN_STATE_PTR s0 +#define TRAP_PTR s1 +#define ALLOC_PTR s10 +#define ALLOC_LIMIT s11 -+#define TMP0 t0 -+#define TMP1 t1 ++#define TMP t0 +#define ARG t2 + -+#if defined(MODEL_riscv64) -+#define store sd -+#define load ld -+#define WSZ 8 -+#else -+#define store sw -+#define load lw -+#define WSZ 4 -+#endif ++#define STORE sd ++#define LOAD ld ++ ++ .set domain_curr_field, 0 ++#define DOMAIN_STATE(c_type, name) \ ++ .equ domain_field_caml_##name, domain_curr_field ; \ ++ .set domain_curr_field, domain_curr_field + 1 ++#include "../runtime/caml/domain_state.tbl" ++#undef DOMAIN_STATE ++ ++#define Caml_state(var) (8*domain_field_caml_##var)(s0) ++ ++#define FUNCTION(name) \ ++ .align 2; \ ++ .globl name; \ ++ .type name, @function; \ ++name: + +#if defined(__PIC__) + .option pic @@ -1457,46 +1620,41 @@ index 000000000..10bc665c6 + .globl caml_system__code_begin +caml_system__code_begin: + -+ .align 2 -+ .globl caml_call_gc -+ .type caml_call_gc, @function -+caml_call_gc: -+ /* Record return address */ -+ store ra, caml_last_return_address, TMP0 -+ /* Record lowest stack address */ -+ mv TMP1, sp -+ store sp, caml_bottom_of_stack, TMP0 ++FUNCTION(caml_call_gc) +.Lcaml_call_gc: ++ /* Record return address */ ++ STORE ra, Caml_state(last_return_address) ++ /* Record lowest stack address */ ++ STORE sp, Caml_state(bottom_of_stack) + /* Set up stack space, saving return address */ + /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, 20 caller-save float regs) * 8 */ + /* + 1 for alignment */ + addi sp, sp, -0x160 -+ mv s0, sp -+ store ra, 0x8(sp) -+ store s0, 0x0(sp) ++ STORE ra, 0x8(sp) ++ STORE s0, 0x0(sp) + /* Save allocatable integer registers on the stack, + in the order given in proc.ml */ -+ store a0, 0x10(sp) -+ store a1, 0x18(sp) -+ store a2, 0x20(sp) -+ store a3, 0x28(sp) -+ store a4, 0x30(sp) -+ store a5, 0x38(sp) -+ store a6, 0x40(sp) -+ store a7, 0x48(sp) -+ store s2, 0x50(sp) -+ store s3, 0x58(sp) -+ store s4, 0x60(sp) -+ store s5, 0x68(sp) -+ store s6, 0x70(sp) -+ store s7, 0x78(sp) -+ store s8, 0x80(sp) -+ store s9, 0x88(sp) -+ store t2, 0x90(sp) -+ store t3, 0x98(sp) -+ store t4, 0xa0(sp) -+ store t5, 0xa8(sp) -+ store t6, 0xb0(sp) ++ STORE a0, 0x10(sp) ++ STORE a1, 0x18(sp) ++ STORE a2, 0x20(sp) ++ STORE a3, 0x28(sp) ++ STORE a4, 0x30(sp) ++ STORE a5, 0x38(sp) ++ STORE a6, 0x40(sp) ++ STORE a7, 0x48(sp) ++ STORE s2, 0x50(sp) ++ STORE s3, 0x58(sp) ++ STORE s4, 0x60(sp) ++ STORE s5, 0x68(sp) ++ STORE s6, 0x70(sp) ++ STORE s7, 0x78(sp) ++ STORE s8, 0x80(sp) ++ STORE s9, 0x88(sp) ++ STORE t2, 0x90(sp) ++ STORE t3, 0x98(sp) ++ STORE t4, 0xa0(sp) ++ STORE t5, 0xa8(sp) ++ STORE t6, 0xb0(sp) + /* Save caller-save floating-point registers on the stack + (callee-saves are preserved by caml_garbage_collection) */ + fsd ft0, 0xb8(sp) @@ -1521,36 +1679,36 @@ index 000000000..10bc665c6 + fsd ft10, 0x150(sp) + fsd ft11, 0x158(sp) + /* Store pointer to saved integer registers in caml_gc_regs */ -+ addi TMP1, sp, 16 -+ store TMP1, caml_gc_regs, TMP0 ++ addi TMP, sp, 16 ++ STORE TMP, Caml_state(gc_regs) + /* Save current allocation pointer for debugging purposes */ -+ store ALLOC_PTR, caml_young_ptr, TMP0 ++ STORE ALLOC_PTR, Caml_state(young_ptr) + /* Save trap pointer in case an exception is raised during GC */ -+ store TRAP_PTR, caml_exception_pointer, TMP0 ++ STORE TRAP_PTR, Caml_state(exception_pointer) + /* Call the garbage collector */ + call PLT(caml_garbage_collection) + /* Restore registers */ -+ load a0, 0x10(sp) -+ load a1, 0x18(sp) -+ load a2, 0x20(sp) -+ load a3, 0x28(sp) -+ load a4, 0x30(sp) -+ load a5, 0x38(sp) -+ load a6, 0x40(sp) -+ load a7, 0x48(sp) -+ load s2, 0x50(sp) -+ load s3, 0x58(sp) -+ load s4, 0x60(sp) -+ load s5, 0x68(sp) -+ load s6, 0x70(sp) -+ load s7, 0x78(sp) -+ load s8, 0x80(sp) -+ load s9, 0x88(sp) -+ load t2, 0x90(sp) -+ load t3, 0x98(sp) -+ load t4, 0xa0(sp) -+ load t5, 0xa8(sp) -+ load t6, 0xb0(sp) ++ LOAD a0, 0x10(sp) ++ LOAD a1, 0x18(sp) ++ LOAD a2, 0x20(sp) ++ LOAD a3, 0x28(sp) ++ LOAD a4, 0x30(sp) ++ LOAD a5, 0x38(sp) ++ LOAD a6, 0x40(sp) ++ LOAD a7, 0x48(sp) ++ LOAD s2, 0x50(sp) ++ LOAD s3, 0x58(sp) ++ LOAD s4, 0x60(sp) ++ LOAD s5, 0x68(sp) ++ LOAD s6, 0x70(sp) ++ LOAD s7, 0x78(sp) ++ LOAD s8, 0x80(sp) ++ LOAD s9, 0x88(sp) ++ LOAD t2, 0x90(sp) ++ LOAD t3, 0x98(sp) ++ LOAD t4, 0xa0(sp) ++ LOAD t5, 0xa8(sp) ++ LOAD t6, 0xb0(sp) + fld ft0, 0xb8(sp) + fld ft1, 0xc0(sp) + fld ft2, 0xc8(sp) @@ -1573,11 +1731,11 @@ index 000000000..10bc665c6 + fld ft10, 0x150(sp) + fld ft11, 0x158(sp) + /* Reload new allocation pointer and allocation limit */ -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) + /* Free stack space and return to caller */ -+ load ra, 0x8(sp) -+ load s0, 0x0(sp) ++ LOAD ra, 0x8(sp) ++ LOAD s0, 0x0(sp) + addi sp, sp, 0x160 + ret + .size caml_call_gc, .-caml_call_gc @@ -1585,42 +1743,36 @@ index 000000000..10bc665c6 +/* Call a C function from OCaml */ +/* Function to call is in ARG */ + -+ .align 2 -+ .globl caml_c_call -+ .type caml_c_call, @function -+caml_c_call: ++FUNCTION(caml_c_call) + /* Preserve return address in callee-save register s2 */ + mv s2, ra + /* Record lowest stack address and return address */ -+ store ra, caml_last_return_address, TMP0 -+ store sp, caml_bottom_of_stack, TMP0 ++ STORE ra, Caml_state(last_return_address) ++ STORE sp, Caml_state(bottom_of_stack) + /* Make the exception handler alloc ptr available to the C code */ -+ store ALLOC_PTR, caml_young_ptr, TMP0 -+ store TRAP_PTR, caml_exception_pointer, TMP0 ++ STORE ALLOC_PTR, Caml_state(young_ptr) ++ STORE TRAP_PTR, Caml_state(exception_pointer) + /* Call the function */ + jalr ARG + /* Reload alloc ptr and alloc limit */ -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) + /* Return */ + jr s2 + .size caml_c_call, .-caml_c_call + +/* Raise an exception from OCaml */ -+ .align 2 -+ .globl caml_raise_exn -+ .type caml_raise_exn, @function -+caml_raise_exn: ++FUNCTION(caml_raise_exn) + /* Test if backtrace is active */ -+ load TMP1, caml_backtrace_active -+ bnez TMP1, 2f ++ LOAD TMP, Caml_state(backtrace_active) ++ bnez TMP, 2f +1: /* Cut stack at current trap handler */ + mv sp, TRAP_PTR + /* Pop previous handler and jump to it */ -+ load TMP1, 8(sp) -+ load TRAP_PTR, 0(sp) ++ LOAD TMP, 8(sp) ++ LOAD TRAP_PTR, 0(sp) + addi sp, sp, 16 -+ jr TMP1 ++ jr TMP +2: /* Preserve exception bucket in callee-save register s2 */ + mv s2, a0 + /* Stash the backtrace */ @@ -1638,25 +1790,24 @@ index 000000000..10bc665c6 + +/* Raise an exception from C */ + -+ .align 2 -+ .globl caml_raise_exception -+ .type caml_raise_exception, @function -+caml_raise_exception: -+ load TRAP_PTR, caml_exception_pointer -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit -+ load TMP1, caml_backtrace_active -+ bnez TMP1, 2f ++FUNCTION(caml_raise_exception) ++ mv DOMAIN_STATE_PTR, a0 ++ mv a0, a1 ++ LOAD TRAP_PTR, Caml_state(exception_pointer) ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) ++ LOAD TMP, Caml_state(backtrace_active) ++ bnez TMP, 2f +1: /* Cut stack at current trap handler */ + mv sp, TRAP_PTR -+ load TMP1, 8(sp) -+ load TRAP_PTR, 0(sp) ++ LOAD TMP, 8(sp) ++ LOAD TRAP_PTR, 0(sp) + addi sp, sp, 16 -+ jr TMP1 ++ jr TMP +2: /* Preserve exception bucket in callee-save register s2 */ + mv s2, a0 -+ load a1, caml_last_return_address -+ load a2, caml_bottom_of_stack ++ LOAD a1, Caml_state(last_return_address) ++ LOAD a2, Caml_state(bottom_of_stack) + mv a3, TRAP_PTR + call PLT(caml_stash_backtrace) + mv a0, s2 @@ -1665,11 +1816,8 @@ index 000000000..10bc665c6 + +/* Start the OCaml program */ + -+ .align 2 -+ .globl caml_start_program -+ .type caml_start_program, @function -+caml_start_program: -+ ++FUNCTION(caml_start_program) ++ mv ARG_DOMAIN_STATE_PTR, a0 + la ARG, caml_program + /* Code shared with caml_callback* */ + /* Address of OCaml code to call is in ARG */ @@ -1677,19 +1825,19 @@ index 000000000..10bc665c6 +.Ljump_to_caml: + /* Set up stack frame and save callee-save registers */ + addi sp, sp, -0xd0 -+ store ra, 0xc0(sp) -+ store s0, 0x0(sp) -+ store s1, 0x8(sp) -+ store s2, 0x10(sp) -+ store s3, 0x18(sp) -+ store s4, 0x20(sp) -+ store s5, 0x28(sp) -+ store s6, 0x30(sp) -+ store s7, 0x38(sp) -+ store s8, 0x40(sp) -+ store s9, 0x48(sp) -+ store s10, 0x50(sp) -+ store s11, 0x58(sp) ++ STORE ra, 0xc0(sp) ++ STORE s0, 0x0(sp) ++ STORE s1, 0x8(sp) ++ STORE s2, 0x10(sp) ++ STORE s3, 0x18(sp) ++ STORE s4, 0x20(sp) ++ STORE s5, 0x28(sp) ++ STORE s6, 0x30(sp) ++ STORE s7, 0x38(sp) ++ STORE s8, 0x40(sp) ++ STORE s9, 0x48(sp) ++ STORE s10, 0x50(sp) ++ STORE s11, 0x58(sp) + fsd fs0, 0x60(sp) + fsd fs1, 0x68(sp) + fsd fs2, 0x70(sp) @@ -1703,52 +1851,54 @@ index 000000000..10bc665c6 + fsd fs10, 0xb0(sp) + fsd fs11, 0xb8(sp) + addi sp, sp, -32 ++ /* Load domain state pointer from argument */ ++ mv DOMAIN_STATE_PTR, ARG_DOMAIN_STATE_PTR + /* Setup a callback link on the stack */ -+ load TMP1, caml_bottom_of_stack -+ store TMP1, 0(sp) -+ load TMP1, caml_last_return_address -+ store TMP1, 8(sp) -+ load TMP1, caml_gc_regs -+ store TMP1, 16(sp) ++ LOAD TMP, Caml_state(bottom_of_stack) ++ STORE TMP, 0(sp) ++ LOAD TMP, Caml_state(last_return_address) ++ STORE TMP, 8(sp) ++ LOAD TMP, Caml_state(gc_regs) ++ STORE TMP, 16(sp) + /* set up a trap frame */ + addi sp, sp, -16 -+ load TMP1, caml_exception_pointer -+ store TMP1, 0(sp) -+ lla TMP0, .Ltrap_handler -+ store TMP0, 8(sp) ++ LOAD TMP, Caml_state(exception_pointer) ++ STORE TMP, 0(sp) ++ lla TMP, .Ltrap_handler ++ STORE TMP, 8(sp) + mv TRAP_PTR, sp -+ load ALLOC_PTR, caml_young_ptr -+ load ALLOC_LIMIT, caml_young_limit -+ store x0, caml_last_return_address, TMP0 ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) ++ STORE x0, Caml_state(last_return_address) + jalr ARG +.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ -+ load TMP1, 0(sp) -+ store TMP1, caml_exception_pointer, TMP0 ++ LOAD TMP, 0(sp) ++ STORE TMP, Caml_state(exception_pointer) + addi sp, sp, 16 +.Lreturn_result: /* pop callback link, restoring global variables */ -+ load TMP1, 0(sp) -+ store TMP1, caml_bottom_of_stack, TMP0 -+ load TMP1, 8(sp) -+ store TMP1, caml_last_return_address, TMP0 -+ load TMP1, 16(sp) -+ store TMP1, caml_gc_regs, TMP0 ++ LOAD TMP, 0(sp) ++ STORE TMP, Caml_state(bottom_of_stack) ++ LOAD TMP, 8(sp) ++ STORE TMP, Caml_state(last_return_address) ++ LOAD TMP, 16(sp) ++ STORE TMP, Caml_state(gc_regs) + addi sp, sp, 32 + /* Update allocation pointer */ -+ store ALLOC_PTR, caml_young_ptr, TMP0 ++ STORE ALLOC_PTR, Caml_state(young_ptr) + /* reload callee-save registers and return */ -+ load ra, 0xc0(sp) -+ load s0, 0x0(sp) -+ load s1, 0x8(sp) -+ load s2, 0x10(sp) -+ load s3, 0x18(sp) -+ load s4, 0x20(sp) -+ load s5, 0x28(sp) -+ load s6, 0x30(sp) -+ load s7, 0x38(sp) -+ load s8, 0x40(sp) -+ load s9, 0x48(sp) -+ load s10, 0x50(sp) -+ load s11, 0x58(sp) ++ LOAD ra, 0xc0(sp) ++ LOAD s0, 0x0(sp) ++ LOAD s1, 0x8(sp) ++ LOAD s2, 0x10(sp) ++ LOAD s3, 0x18(sp) ++ LOAD s4, 0x20(sp) ++ LOAD s5, 0x28(sp) ++ LOAD s6, 0x30(sp) ++ LOAD s7, 0x38(sp) ++ LOAD s8, 0x40(sp) ++ LOAD s9, 0x48(sp) ++ LOAD s10, 0x50(sp) ++ LOAD s11, 0x58(sp) + fld fs0, 0x60(sp) + fld fs1, 0x68(sp) + fld fs2, 0x70(sp) @@ -1763,58 +1913,55 @@ index 000000000..10bc665c6 + fld fs11, 0xb8(sp) + addi sp, sp, 0xd0 + ret ++ .type .Lcaml_retaddr, @function ++ .size .Lcaml_retaddr, .-.Lcaml_retaddr ++ .size caml_start_program, .-caml_start_program ++ ++ .align 2 +.Ltrap_handler: -+ store TRAP_PTR, caml_exception_pointer, TMP0 ++ STORE TRAP_PTR, Caml_state(exception_pointer) + ori a0, a0, 2 + j .Lreturn_result -+ .size caml_start_program, .-caml_start_program ++ .type .Ltrap_handler, @function ++ .size .Ltrap_handler, .-.Ltrap_handler + +/* Callback from C to OCaml */ + -+ .align 2 -+ .globl caml_callback_exn -+ .type caml_callback_exn, @function -+caml_callback_exn: -+ /* Initial shuffling of arguments (a0 = closure, a1 = first arg) */ -+ mv TMP1, a0 -+ mv a0, a1 /* a0 = first arg */ -+ mv a1, TMP1 /* a1 = closure environment */ -+ load ARG, 0(TMP1) /* code pointer */ ++FUNCTION(caml_callback_asm) ++ /* Initial shuffling of arguments */ ++ /* a0 = Caml_state, a1 = closure, (a2) = args */ ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ LOAD a0, 0(a2) /* a0 = first arg */ ++ /* a1 = closure environment */ ++ LOAD ARG, 0(a1) /* code pointer */ + j .Ljump_to_caml -+ .size caml_callback_exn, .-caml_callback_exn ++ .size caml_callback_asm, .-caml_callback_asm + -+ .align 2 -+ .globl caml_callback2_exn -+ .type caml_callback2_exn, @function -+caml_callback2_exn: -+ /* Initial shuffling of arguments (a0 = closure, a1 = arg1, a2 = arg2) */ -+ mv TMP1, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, TMP1 ++FUNCTION(caml_callback2_asm) ++ /* Initial shuffling of arguments */ ++ /* a0 = Caml_state, a1 = closure, (a2) = args */ ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ mv TMP, a1 ++ LOAD a0, 0(a2) ++ LOAD a1, 8(a2) ++ mv a2, TMP + la ARG, caml_apply2 + j .Ljump_to_caml -+ .size caml_callback2_exn, .-caml_callback2_exn ++ .size caml_callback2_asm, .-caml_callback2_asm + -+ .align 2 -+ .globl caml_callback3_exn -+ .type caml_callback3_exn, @function -+caml_callback3_exn: -+ /* Initial shuffling of argumnets */ -+ /* (a0 = closure, a1 = arg1, a2 = arg2, a3 = arg3) */ -+ mv TMP1, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, a3 -+ mv a3, TMP1 ++FUNCTION(caml_callback3_asm) ++ /* Initial shuffling of arguments */ ++ /* a0 = Caml_state, a1 = closure, (a2) = args */ ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ mv a3, a1 ++ LOAD a0, 0(a2) ++ LOAD a1, 8(a2) ++ LOAD a2, 16(a2) + la ARG, caml_apply3 + j .Ljump_to_caml -+ .size caml_callback3_exn, .-caml_callback3_exn ++ .size caml_callback3_asm, .-caml_callback3_asm + -+ .align 2 -+ .globl caml_ml_array_bound_error -+ .type caml_ml_array_bound_error, @function -+caml_ml_array_bound_error: ++FUNCTION(caml_ml_array_bound_error) + /* Load address of [caml_array_bound_error] in ARG */ + la ARG, caml_array_bound_error + /* Call that function */ @@ -1839,97 +1986,99 @@ index 000000000..10bc665c6 + .size caml_system__frametable, .-caml_system__frametable diff --git a/testsuite/tools/asmgen_riscv.S b/testsuite/tools/asmgen_riscv.S new file mode 100644 -index 000000000..8b34a40f8 +index 000000000..806b23dfc --- /dev/null +++ b/testsuite/tools/asmgen_riscv.S -@@ -0,0 +1,87 @@ -+/***********************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2019 Institut National de Recherche en Informatique et */ -+/* en Automatique. All rights reserved. This file is distributed */ -+/* under the terms of the GNU Library General Public License, with */ -+/* the special exception on linking described in file ../LICENSE. */ -+/* */ -+/***********************************************************************/ +@@ -0,0 +1,89 @@ ++/**************************************************************************/ ++/* */ ++/* OCaml */ ++/* */ ++/* Nicolas Ojeda Bar */ ++/* */ ++/* Copyright 2019 Institut National de Recherche en Informatique et */ ++/* en Automatique. */ ++/* */ ++/* All rights reserved. This file is distributed under the terms of */ ++/* the GNU Lesser General Public License version 2.1, with the */ ++/* special exception on linking described in the file LICENSE. */ ++/* */ ++/**************************************************************************/ ++ ++#define STORE sd ++#define LOAD ld + -+#define STORE sd -+#define LOAD ld -+ + .globl call_gen_code + .align 2 +call_gen_code: + /* Set up stack frame and save callee-save registers */ -+ ADDI sp, sp, -208 -+ STORE ra, 192(sp) -+ STORE s0, 0(sp) -+ STORE s1, 8(sp) -+ STORE s2, 16(sp) -+ STORE s3, 24(sp) -+ STORE s4, 32(sp) -+ STORE s5, 40(sp) -+ STORE s6, 48(sp) -+ STORE s7, 56(sp) -+ STORE s8, 64(sp) -+ STORE s9, 72(sp) -+ STORE s10, 80(sp) -+ STORE s11, 88(sp) -+ fsd fs0, 96(sp) -+ fsd fs1, 104(sp) -+ fsd fs2, 112(sp) -+ fsd fs3, 120(sp) -+ fsd fs4, 128(sp) -+ fsd fs5, 136(sp) -+ fsd fs6, 144(sp) -+ fsd fs7, 152(sp) -+ fsd fs8, 160(sp) -+ fsd fs9, 168(sp) -+ fsd fs10, 176(sp) -+ fsd fs11, 184(sp) ++ ADDI sp, sp, -208 ++ STORE ra, 192(sp) ++ STORE s0, 0(sp) ++ STORE s1, 8(sp) ++ STORE s2, 16(sp) ++ STORE s3, 24(sp) ++ STORE s4, 32(sp) ++ STORE s5, 40(sp) ++ STORE s6, 48(sp) ++ STORE s7, 56(sp) ++ STORE s8, 64(sp) ++ STORE s9, 72(sp) ++ STORE s10, 80(sp) ++ STORE s11, 88(sp) ++ fsd fs0, 96(sp) ++ fsd fs1, 104(sp) ++ fsd fs2, 112(sp) ++ fsd fs3, 120(sp) ++ fsd fs4, 128(sp) ++ fsd fs5, 136(sp) ++ fsd fs6, 144(sp) ++ fsd fs7, 152(sp) ++ fsd fs8, 160(sp) ++ fsd fs9, 168(sp) ++ fsd fs10, 176(sp) ++ fsd fs11, 184(sp) + /* Shuffle arguments */ -+ mv t0, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, a3 -+ mv a3, a4 ++ mv t0, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, a3 ++ mv a3, a4 + /* Call generated asm */ -+ jalr t0 ++ jalr t0 + /* Reload callee-save registers and return address */ -+ LOAD ra, 192(sp) -+ LOAD s0, 0(sp) -+ LOAD s1, 8(sp) -+ LOAD s2, 16(sp) -+ LOAD s3, 24(sp) -+ LOAD s4, 32(sp) -+ LOAD s5, 40(sp) -+ LOAD s6, 48(sp) -+ LOAD s7, 56(sp) -+ LOAD s8, 64(sp) -+ LOAD s9, 72(sp) -+ LOAD s10, 80(sp) -+ LOAD s11, 88(sp) -+ fld fs0, 96(sp) -+ fld fs1, 104(sp) -+ fld fs2, 112(sp) -+ fld fs3, 120(sp) -+ fld fs4, 128(sp) -+ fld fs5, 136(sp) -+ fld fs6, 144(sp) -+ fld fs7, 152(sp) -+ fld fs8, 160(sp) -+ fld fs9, 168(sp) -+ fld fs10, 176(sp) -+ fld fs11, 184(sp) -+ addi sp, sp, 208 ++ LOAD ra, 192(sp) ++ LOAD s0, 0(sp) ++ LOAD s1, 8(sp) ++ LOAD s2, 16(sp) ++ LOAD s3, 24(sp) ++ LOAD s4, 32(sp) ++ LOAD s5, 40(sp) ++ LOAD s6, 48(sp) ++ LOAD s7, 56(sp) ++ LOAD s8, 64(sp) ++ LOAD s9, 72(sp) ++ LOAD s10, 80(sp) ++ LOAD s11, 88(sp) ++ fld fs0, 96(sp) ++ fld fs1, 104(sp) ++ fld fs2, 112(sp) ++ fld fs3, 120(sp) ++ fld fs4, 128(sp) ++ fld fs5, 136(sp) ++ fld fs6, 144(sp) ++ fld fs7, 152(sp) ++ fld fs8, 160(sp) ++ fld fs9, 168(sp) ++ fld fs10, 176(sp) ++ fld fs11, 184(sp) ++ addi sp, sp, 208 + ret + + .globl caml_c_call + .align 2 +caml_c_call: -+ jr t2 ++ jr t2 -- -2.25.0 +2.24.1 diff --git a/ocaml.spec b/ocaml.spec index 54403af..298d4a9 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.10.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -50,7 +50,7 @@ Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rc # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-32-4.10.0 +# Current branch: fedora-33-4.10.0 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -63,9 +63,13 @@ Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch Patch0004: 0004-Remove-configure-from-.gitattributes.patch # Out of tree patch for RISC-V support. -# https://github.com/nojb/riscv-ocaml -# Resets the version number back to 4.09.0. -Patch0005: 0005-Add-riscv64-backend.patch +# https://github.com/nojb/ocaml branch riscv +# I had to backport some other upstream patches from > 4.10 in +# order to get this to apply. +Patch0005: 0005-Use-a-more-compact-representation-of-debug-informati.patch +Patch0006: 0006-Retain-debug-information-about-allocation-sizes-for-.patch +Patch0007: 0007-Use-allocation-size-info-on-more-than-just-amd64.patch +Patch0008: 0008-Add-riscv64-backend.patch BuildRequires: git BuildRequires: gcc @@ -369,6 +373,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Sat Apr 11 2020 Richard W.M. Jones - 4.10.0-4.fc33 +- Fix RISC-V backend. + * Thu Apr 02 2020 Richard W.M. Jones - 4.10.0-3.fc33 - Update all OCaml dependencies for RPM 4.16. From 9ed29bd6b2483cfe97cd236d0a0b155f2290eed7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 17 Apr 2020 14:51:57 +0100 Subject: [PATCH 26/91] Move to OCaml 4.11.0 pre-release with support for RISC-V. --- 0001-Don-t-add-rpaths-to-libraries.patch | 6 +- ...-Allow-user-defined-C-compiler-flags.patch | 8 +- ...-incorrect-assumption-about-cross-co.patch | 10 +- ...Remove-configure-from-.gitattributes.patch | 6 +- ...ct-representation-of-debug-informati.patch | 504 ---- ...ormation-about-allocation-sizes-for-.patch | 620 ----- ...on-size-info-on-more-than-just-amd64.patch | 926 -------- 0008-Add-riscv64-backend.patch | 2084 ----------------- ocaml.spec | 26 +- sources | 2 +- 10 files changed, 28 insertions(+), 4164 deletions(-) delete mode 100644 0005-Use-a-more-compact-representation-of-debug-informati.patch delete mode 100644 0006-Retain-debug-information-about-allocation-sizes-for-.patch delete mode 100644 0007-Use-allocation-size-info-on-more-than-just-amd64.patch delete mode 100644 0008-Add-riscv64-backend.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index f557009..8a126a1 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,14 +1,14 @@ -From bf123e43c444ff14fcb76f806d90806e4960a1a4 Mon Sep 17 00:00:00 2001 +From 14d63e7a96ab39598f7c42b8513c914253afb173 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/8] Don't add rpaths to libraries. +Subject: [PATCH 1/4] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile -index 18aead935..e374c05ee 100644 +index 8bd51bfd8..b34cbbf32 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -153,8 +153,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 2781d29..fbadf53 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From 3a5dfecb2e4078bcd7388412783b50014006e7c9 Mon Sep 17 00:00:00 2001 +From 65456b148ad6532a6b0086ba5812b67c0371e768 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/8] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index e3e28fb6f..0648f0553 100644 +index e84dc0431..1687918a2 100644 --- a/configure.ac +++ b/configure.ac -@@ -590,6 +590,10 @@ AS_CASE([$host], +@@ -608,6 +608,10 @@ AS_CASE([$host], internal_cflags="$gcc_warnings"], [common_cflags="-O"])]) diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index df4aca2..9da35dc 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From b32e6fc3318a2d25d7ae233a8999beb752d6131d Mon Sep 17 00:00:00 2001 +From 0b1b91841a3a227321f8e155ed932893e285b429 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/8] configure: Remove incorrect assumption about +Subject: [PATCH 3/4] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -10,10 +10,10 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 0648f0553..ad07516e7 100644 +index 1687918a2..01edbff17 100644 --- a/configure.ac +++ b/configure.ac -@@ -505,10 +505,11 @@ AS_IF( +@@ -510,10 +510,11 @@ AS_IF( # Are we building a cross-compiler @@ -29,7 +29,7 @@ index 0648f0553..ad07516e7 100644 # Checks for programs -@@ -970,7 +971,7 @@ AS_IF([test $arch != "none" && $arch64 ], +@@ -996,7 +997,7 @@ AS_IF([test $arch != "none" && $arch64 ], # Assembler diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index 06a1c2e..7360765 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,7 +1,7 @@ -From 9ea729ce863396484d2e4c5a93af4b625fc5c90c Mon Sep 17 00:00:00 2001 +From 0b805df7403257a71b9852deb2f468aac16133b0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 -Subject: [PATCH 4/8] Remove configure from .gitattributes. +Subject: [PATCH 4/4] Remove configure from .gitattributes. It's not a binary file. --- @@ -9,7 +9,7 @@ It's not a binary file. 1 file changed, 4 deletions(-) diff --git a/.gitattributes b/.gitattributes -index 9be9e33a0..5df88ab4e 100644 +index db37bfbe5..b6e540188 100644 --- a/.gitattributes +++ b/.gitattributes @@ -29,10 +29,6 @@ diff --git a/0005-Use-a-more-compact-representation-of-debug-informati.patch b/0005-Use-a-more-compact-representation-of-debug-informati.patch deleted file mode 100644 index cc3443e..0000000 --- a/0005-Use-a-more-compact-representation-of-debug-informati.patch +++ /dev/null @@ -1,504 +0,0 @@ -From f54d138e2cbabbfb6488a1605f995aaf4a663e0b Mon Sep 17 00:00:00 2001 -From: Stephen Dolan -Date: Tue, 23 Apr 2019 14:11:11 +0100 -Subject: [PATCH 5/8] Use a more compact representation of debug information. - -Locations of inlined frames are now represented as contiguous -sequences rather than linked lists. - -The frame tables now refer to debug info by 32-bit offset rather -than word-sized pointer. - -(cherry picked from commit b0ad600b88b3eb6e53be681794f36dd58b6a493d) ---- - Changes | 1 - - asmcomp/amd64/emit.mlp | 38 ++++++++------- - asmcomp/emitaux.ml | 88 ++++++++++++++++++++--------------- - asmcomp/emitaux.mli | 8 +++- - runtime/backtrace_nat.c | 34 ++++++++------ - runtime/caml/backtrace_prim.h | 2 +- - runtime/caml/stack.h | 12 ++++- - runtime/roots_nat.c | 22 +++++---- - 8 files changed, 124 insertions(+), 81 deletions(-) - -diff --git a/Changes b/Changes -index fc5591eb4..fef04de44 100644 ---- a/Changes -+++ b/Changes -@@ -565,7 +565,6 @@ OCaml 4.09.0 (19 September 2019): - - #8787, #8788: avoid integer overflow in caml_output_value_to_bytes - (Jeremy Yallop, report by Marcello Seri) - -- - - #2075, #7729: rename _T macro used to support Unicode in the (Windows) runtime - in order to avoid compiler warning - (Nicolás Ojeda Bär, review by Gabriel Scherer and David Allsopp) -diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp -index e3ff9653d..69cc48b6d 100644 ---- a/asmcomp/amd64/emit.mlp -+++ b/asmcomp/amd64/emit.mlp -@@ -239,7 +239,7 @@ let addressing addr typ i n = - - (* Record live pointers at call points -- see Emitaux *) - --let record_frame_label ?label live raise_ dbg = -+let record_frame_label ?label live dbg = - let lbl = - match label with - | None -> new_label() -@@ -258,11 +258,11 @@ let record_frame_label ?label live raise_ dbg = - ) - live; - record_frame_descr ~label:lbl ~frame_size:(frame_size()) -- ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ ~live_offset:!live_offset dbg; - lbl - --let record_frame ?label live raise_ dbg = -- let lbl = record_frame_label ?label live raise_ dbg in -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in - def_label lbl - - (* Spacetime instrumentation *) -@@ -327,7 +327,7 @@ let bound_error_call = ref 0 - let bound_error_label ?label dbg ~spacetime = - if !Clflags.debug || Config.spacetime then begin - let lbl_bound_error = new_label() in -- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in - bound_error_sites := - { bd_lbl = lbl_bound_error; bd_frame = lbl_frame; - bd_spacetime = spacetime; } :: !bound_error_sites; -@@ -573,16 +573,16 @@ let emit_instr fallthrough i = - load_symbol_addr s (res i 0) - | Lop(Icall_ind { label_after; }) -> - I.call (arg i 0); -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - | Lop(Icall_imm { func; label_after; }) -> - add_used_symbol func; - emit_call func; -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - | Lop(Itailcall_ind { label_after; }) -> - output_epilogue begin fun () -> - I.jmp (arg i 0); - if Config.spacetime then begin -- record_frame Reg.Set.empty false i.dbg ~label:label_after -+ record_frame Reg.Set.empty (Dbg_other i.dbg) ~label:label_after - end - end - | Lop(Itailcall_imm { func; label_after; }) -> -@@ -597,14 +597,14 @@ let emit_instr fallthrough i = - end - end; - if Config.spacetime then begin -- record_frame Reg.Set.empty false i.dbg ~label:label_after -+ record_frame Reg.Set.empty (Dbg_other i.dbg) ~label:label_after - end - | Lop(Iextcall { func; alloc; label_after; }) -> - add_used_symbol func; - if alloc then begin - load_symbol_addr func rax; - emit_call "caml_c_call"; -- record_frame i.live false i.dbg ~label:label_after; -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after; - if system <> S_win64 then begin - (* TODO: investigate why such a diff. - This comes from: -@@ -618,7 +618,7 @@ let emit_instr fallthrough i = - end else begin - emit_call func; - if Config.spacetime then begin -- record_frame Reg.Set.empty false i.dbg ~label:label_after -+ record_frame Reg.Set.empty (Dbg_other i.dbg) ~label:label_after - end - end - | Lop(Istackoffset n) -> -@@ -668,7 +668,7 @@ let emit_instr fallthrough i = - I.movsd (arg i 0) (addressing addr REAL8 i 1) - end - | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; }) -> -- if !fastcode_flag then begin -+ if !fastcode_flag then begin - let lbl_redo = new_label() in - def_label lbl_redo; - I.sub (int n) r15; -@@ -679,7 +679,7 @@ let emit_instr fallthrough i = - else i.dbg - in - let lbl_frame = -- record_frame_label ?label:label_after_call_gc i.live false dbg -+ record_frame_label ?label:label_after_call_gc i.live (Dbg_other dbg) - in - I.jb (label lbl_call_gc); - I.lea (mem64 NONE 8 R15) (res i 0); -@@ -707,8 +707,8 @@ let emit_instr fallthrough i = - emit_call "caml_allocN" - end; - let label = -- record_frame_label ?label:label_after_call_gc i.live false -- Debuginfo.none -+ record_frame_label ?label:label_after_call_gc i.live -+ (Dbg_other i.dbg) - in - def_label label; - I.lea (mem64 NONE 8 R15) (res i 0) -@@ -914,10 +914,10 @@ let emit_instr fallthrough i = - | Lambda.Raise_regular -> - I.mov (int 0) (domain_field Domainstate.Domain_backtrace_pos); - emit_call "caml_raise_exn"; -- record_frame Reg.Set.empty true i.dbg -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) - | Lambda.Raise_reraise -> - emit_call "caml_raise_exn"; -- record_frame Reg.Set.empty true i.dbg -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) - | Lambda.Raise_notrace -> - I.mov (domain_field Domainstate.Domain_exception_pointer) rsp; - I.pop (domain_field Domainstate.Domain_exception_pointer); -@@ -1119,6 +1119,7 @@ let end_assembly() = - emit_frames - { efa_code_label = (fun l -> D.qword (ConstLabel (emit_label l))); - efa_data_label = (fun l -> D.qword (ConstLabel (emit_label l))); -+ efa_8 = (fun n -> D.byte (const n)); - efa_16 = (fun n -> D.word (const n)); - efa_32 = (fun n -> D.long (const_32 n)); - efa_word = (fun n -> D.qword (const n)); -@@ -1142,6 +1143,9 @@ let end_assembly() = - efa_string = (fun s -> D.bytes (s ^ "\000")) - }; - -+ let frametable = Compilenv.make_symbol (Some "frametable") in -+ D.size frametable (ConstSub (ConstThis, ConstLabel frametable)); -+ - if Config.spacetime then begin - emit_spacetime_shapes () - end; -diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml -index e0476d171..9e7221096 100644 ---- a/asmcomp/emitaux.ml -+++ b/asmcomp/emitaux.ml -@@ -105,26 +105,29 @@ let emit_float32_directive directive x = - - (* Record live pointers at call points *) - -+type frame_debuginfo = -+ | Dbg_raise of Debuginfo.t -+ | Dbg_other of Debuginfo.t -+ - type frame_descr = - { fd_lbl: int; (* Return address *) - fd_frame_size: int; (* Size of stack frame *) - fd_live_offset: int list; (* Offsets/regs of live addresses *) -- fd_raise: bool; (* Is frame for a raise? *) -- fd_debuginfo: Debuginfo.t } (* Location, if any *) -+ fd_debuginfo: frame_debuginfo } (* Location, if any *) - - let frame_descriptors = ref([] : frame_descr list) - --let record_frame_descr ~label ~frame_size ~live_offset ~raise_frame debuginfo = -+let record_frame_descr ~label ~frame_size ~live_offset debuginfo = - frame_descriptors := - { fd_lbl = label; - fd_frame_size = frame_size; - fd_live_offset = List.sort_uniq (-) live_offset; -- fd_raise = raise_frame; - fd_debuginfo = debuginfo } :: !frame_descriptors - - type emit_frame_actions = - { efa_code_label: int -> unit; - efa_data_label: int -> unit; -+ efa_8: int -> unit; - efa_16: int -> unit; - efa_32: int32 -> unit; - efa_word: int -> unit; -@@ -155,64 +158,73 @@ let emit_frames a = - end) - in - let debuginfos = Label_table.create 7 in -- let rec label_debuginfos rs rdbg = -+ let label_debuginfos rs dbg = -+ let rdbg = List.rev dbg in - let key = (rs, rdbg) in -- try fst (Label_table.find debuginfos key) -+ try Label_table.find debuginfos key - with Not_found -> - let lbl = Cmm.new_label () in -- let next = -- match rdbg with -- | [] -> assert false -- | _ :: [] -> None -- | _ :: ((_ :: _) as rdbg') -> Some (label_debuginfos false rdbg') -- in -- Label_table.add debuginfos key (lbl, next); -+ Label_table.add debuginfos key lbl; - lbl - in -- let emit_debuginfo_label rs rdbg = -- a.efa_data_label (label_debuginfos rs rdbg) -- in - let emit_frame fd = -+ assert (fd.fd_frame_size land 3 = 0); -+ let flags = -+ match fd.fd_debuginfo with -+ | Dbg_other d | Dbg_raise d -> -+ if Debuginfo.is_none d then 0 else 1 -+ in - a.efa_code_label fd.fd_lbl; -- a.efa_16 (if Debuginfo.is_none fd.fd_debuginfo -- then fd.fd_frame_size -- else fd.fd_frame_size + 1); -+ a.efa_16 (fd.fd_frame_size + flags); - a.efa_16 (List.length fd.fd_live_offset); - List.iter a.efa_16 fd.fd_live_offset; -- a.efa_align Arch.size_addr; -- match List.rev fd.fd_debuginfo with -- | [] -> () -- | _ :: _ as rdbg -> emit_debuginfo_label fd.fd_raise rdbg -+ begin match fd.fd_debuginfo with -+ | _ when flags = 0 -> -+ () -+ | Dbg_other dbg -> -+ a.efa_align 4; -+ a.efa_label_rel (label_debuginfos false dbg) Int32.zero -+ | Dbg_raise dbg -> -+ a.efa_align 4; -+ a.efa_label_rel (label_debuginfos true dbg) Int32.zero -+ end; -+ a.efa_align Arch.size_addr - in - let emit_filename name lbl = - a.efa_def_label lbl; - a.efa_string name; - a.efa_align Arch.size_addr - in -- let pack_info fd_raise d = -+ let pack_info fd_raise d has_next = - let line = min 0xFFFFF d.Debuginfo.dinfo_line - and char_start = min 0xFF d.Debuginfo.dinfo_char_start - and char_end = min 0x3FF d.Debuginfo.dinfo_char_end -- and kind = if fd_raise then 1 else 0 in -+ and kind = if fd_raise then 1 else 0 -+ and has_next = if has_next then 1 else 0 in - Int64.(add (shift_left (of_int line) 44) - (add (shift_left (of_int char_start) 36) - (add (shift_left (of_int char_end) 26) -- (of_int kind)))) -+ (add (shift_left (of_int kind) 1) -+ (of_int has_next))))) - in -- let emit_debuginfo (rs, rdbg) (lbl,next) = -- let d = List.hd rdbg in -+ let emit_debuginfo (rs, rdbg) lbl = -+ (* Due to inlined functions, a single debuginfo may have multiple locations. -+ These are represented sequentially in memory (innermost frame first), -+ with the low bit of the packed debuginfo being 0 on the last entry. *) - a.efa_align Arch.size_addr; - a.efa_def_label lbl; -- let info = pack_info rs d in -- a.efa_label_rel -- (label_filename d.Debuginfo.dinfo_file) -- (Int64.to_int32 info); -- a.efa_32 (Int64.to_int32 (Int64.shift_right info 32)); -- begin match next with -- | Some next -> a.efa_data_label next -- | None -> a.efa_word 0 -- end -- in -+ let rec emit rs d rest = -+ let info = pack_info rs d (rest <> []) in -+ a.efa_label_rel -+ (label_filename d.Debuginfo.dinfo_file) -+ (Int64.to_int32 info); -+ a.efa_32 (Int64.to_int32 (Int64.shift_right info 32)); -+ match rest with -+ | [] -> () -+ | d :: rest -> emit false d rest in -+ match rdbg with -+ | [] -> assert false -+ | d :: rest -> emit rs d rest in - a.efa_word (List.length !frame_descriptors); - List.iter emit_frame !frame_descriptors; - Label_table.iter emit_debuginfo debuginfos; -diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli -index b2b2141c5..a4a60e07c 100644 ---- a/asmcomp/emitaux.mli -+++ b/asmcomp/emitaux.mli -@@ -38,17 +38,21 @@ val emit_debug_info_gen : - (file_num:int -> file_name:string -> unit) -> - (file_num:int -> line:int -> col:int -> unit) -> unit - -+type frame_debuginfo = -+ | Dbg_raise of Debuginfo.t -+ | Dbg_other of Debuginfo.t -+ - val record_frame_descr : - label:int -> (* Return address *) - frame_size:int -> (* Size of stack frame *) - live_offset:int list -> (* Offsets/regs of live addresses *) -- raise_frame:bool -> (* Is frame for a raise? *) -- Debuginfo.t -> (* Location, if any *) -+ frame_debuginfo -> (* Location, if any *) - unit - - type emit_frame_actions = - { efa_code_label: int -> unit; - efa_data_label: int -> unit; -+ efa_8: int -> unit; - efa_16: int -> unit; - efa_32: int32 -> unit; - efa_word: int -> unit; -diff --git a/runtime/backtrace_nat.c b/runtime/backtrace_nat.c -index 81cb6d8e1..acf31d644 100644 ---- a/runtime/backtrace_nat.c -+++ b/runtime/backtrace_nat.c -@@ -137,18 +137,20 @@ void caml_current_callstack_write(value trace) { - - debuginfo caml_debuginfo_extract(backtrace_slot slot) - { -- uintnat infoptr; -+ unsigned char* infoptr; -+ uint32_t debuginfo_offset; - frame_descr * d = (frame_descr *)slot; - - if ((d->frame_size & 1) == 0) { - return NULL; - } - /* Recover debugging info */ -- infoptr = ((uintnat) d + -- sizeof(char *) + sizeof(short) + sizeof(short) + -- sizeof(short) * d->num_live + sizeof(frame_descr *) - 1) -- & -sizeof(frame_descr *); -- return *((debuginfo*)infoptr); -+ infoptr = (unsigned char*)&d->live_ofs[d->num_live]; -+ /* align to 32 bits */ -+ infoptr = Align_to(infoptr, uint32_t); -+ /* read offset to debuginfo */ -+ debuginfo_offset = *(uint32_t*)infoptr; -+ return (debuginfo)(infoptr + debuginfo_offset); - } - - debuginfo caml_debuginfo_next(debuginfo dbg) -@@ -159,8 +161,12 @@ debuginfo caml_debuginfo_next(debuginfo dbg) - return NULL; - - infoptr = dbg; -- infoptr += 2; /* Two packed info fields */ -- return *((debuginfo*)infoptr); -+ if ((infoptr[0] & 1) == 0) -+ /* No next debuginfo */ -+ return NULL; -+ else -+ /* Next debuginfo is after the two packed info fields */ -+ return (debuginfo*)(infoptr + 2); - } - - /* Extract location information for the given frame descriptor */ -@@ -181,17 +187,19 @@ void caml_debuginfo_location(debuginfo dbg, /*out*/ struct caml_loc_info * li) - info1 = ((uint32_t *)dbg)[0]; - info2 = ((uint32_t *)dbg)[1]; - /* Format of the two info words: -- llllllllllllllllllll aaaaaaaa bbbbbbbbbb nnnnnnnnnnnnnnnnnnnnnnnn kk -- 44 36 26 2 0 -+ llllllllllllllllllll aaaaaaaa bbbbbbbbbb ffffffffffffffffffffffff k n -+ 44 36 26 2 1 0 - (32+12) (32+4) -- k ( 2 bits): 0 if it's a call -+ n ( 1 bit ): 0 if this is the final debuginfo -+ 1 if there's another following this one -+ k ( 1 bit ): 0 if it's a call - 1 if it's a raise -- n (24 bits): offset (in 4-byte words) of file name relative to dbg -+ f (24 bits): offset (in 4-byte words) of file name relative to dbg - l (20 bits): line number - a ( 8 bits): beginning of character range - b (10 bits): end of character range */ - li->loc_valid = 1; -- li->loc_is_raise = (info1 & 3) == 1; -+ li->loc_is_raise = (info1 & 2) == 2; - li->loc_is_inlined = caml_debuginfo_next(dbg) != NULL; - li->loc_filename = (char *) dbg + (info1 & 0x3FFFFFC); - li->loc_lnum = info2 >> 12; -diff --git a/runtime/caml/backtrace_prim.h b/runtime/caml/backtrace_prim.h -index 08c236047..4d8ce9096 100644 ---- a/runtime/caml/backtrace_prim.h -+++ b/runtime/caml/backtrace_prim.h -@@ -43,7 +43,7 @@ struct caml_loc_info { - }; - - /* When compiling with -g, backtrace slots have debug info associated. -- * When a call is inlined in native mode, debuginfos form a linked list. -+ * When a call is inlined in native mode, debuginfos form a sequence. - */ - typedef void * debuginfo; - -diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index 259f97ac4..30a18d274 100644 ---- a/runtime/caml/stack.h -+++ b/runtime/caml/stack.h -@@ -87,9 +87,19 @@ typedef struct { - uintnat retaddr; - unsigned short frame_size; - unsigned short num_live; -- unsigned short live_ofs[1]; -+ unsigned short live_ofs[1 /* num_live */]; -+ /* -+ If frame_size & 1, then debug info follows: -+ uint32_t debug_info_offset; -+ Debug info is stored as a relative offset to a debuginfo structure. */ - } frame_descr; - -+/* Used to compute offsets in frame tables. -+ ty must have power-of-2 size */ -+#define Align_to(p, ty) \ -+ (void*)(((uintnat)(p) + sizeof(ty) - 1) & -sizeof(ty)) -+ -+ - /* Hash table of frame descriptors */ - - extern frame_descr ** caml_frame_descriptors; -diff --git a/runtime/roots_nat.c b/runtime/roots_nat.c -index d8feb1bdc..f61e56d90 100644 ---- a/runtime/roots_nat.c -+++ b/runtime/roots_nat.c -@@ -29,6 +29,7 @@ - #include "caml/memprof.h" - #include - #include -+#include - - /* Roots registered from C functions */ - -@@ -78,14 +79,19 @@ static link* frametables_list_tail(link *list) { - } - - static frame_descr * next_frame_descr(frame_descr * d) { -- uintnat nextd; -- nextd = -- ((uintnat)d + -- sizeof(char *) + sizeof(short) + sizeof(short) + -- sizeof(short) * d->num_live + sizeof(frame_descr *) - 1) -- & -sizeof(frame_descr *); -- if (d->frame_size & 1) nextd += sizeof(void *); /* pointer to debuginfo */ -- return((frame_descr *) nextd); -+ unsigned char num_allocs = 0, *p; -+ CAMLassert(d->retaddr >= 4096); -+ /* Skip to end of live_ofs */ -+ p = (unsigned char*)&d->live_ofs[d->num_live]; -+ /* Skip debug info if present */ -+ if (d->frame_size & 1) { -+ /* Align to 32 bits */ -+ p = Align_to(p, uint32_t); -+ p += sizeof(uint32_t) * (d->frame_size & 2 ? num_allocs : 1); -+ } -+ /* Align to word size */ -+ p = Align_to(p, void*); -+ return ((frame_descr*) p); - } - - static void fill_hashtable(link *frametables) { --- -2.24.1 - diff --git a/0006-Retain-debug-information-about-allocation-sizes-for-.patch b/0006-Retain-debug-information-about-allocation-sizes-for-.patch deleted file mode 100644 index de504d3..0000000 --- a/0006-Retain-debug-information-about-allocation-sizes-for-.patch +++ /dev/null @@ -1,620 +0,0 @@ -From dac12e5db7f4ca4a32b0eccea1d16d27f9df86d2 Mon Sep 17 00:00:00 2001 -From: Stephen Dolan -Date: Tue, 16 Jul 2019 16:24:01 +0100 -Subject: [PATCH 6/8] Retain debug information about allocation sizes, for - statmemprof. - -This code is adapted from jhjourdan's 2c93ca1e711. Comballoc is -extended to keep track of allocation sizes and debug info for each -allocation, and the frame table format is modified to store them. - -The native code GC-entry logic is changed to match bytecode, by -calling the garbage collector at most once per allocation. - -amd64 only, for now. - -(cherry picked from commit 34f97941ec302129f516c926c9ef65e4d68b8121) ---- - asmcomp/amd64/emit.mlp | 30 ++++++++----------- - asmcomp/comballoc.ml | 55 +++++++++++++++++++--------------- - asmcomp/emitaux.ml | 22 ++++++++++++++ - asmcomp/emitaux.mli | 1 + - asmcomp/mach.ml | 6 +++- - asmcomp/mach.mli | 11 ++++++- - asmcomp/selectgen.ml | 8 +++-- - asmcomp/spacetime_profiling.ml | 1 + - runtime/amd64.S | 53 ++++---------------------------- - runtime/backtrace_nat.c | 16 ++++++++-- - runtime/caml/stack.h | 10 +++++-- - runtime/minor_gc.c | 5 ++++ - runtime/roots_nat.c | 5 ++++ - runtime/signals_nat.c | 37 +++++++++++------------ - 14 files changed, 143 insertions(+), 117 deletions(-) - -diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp -index 69cc48b6d..6c3950a6d 100644 ---- a/asmcomp/amd64/emit.mlp -+++ b/asmcomp/amd64/emit.mlp -@@ -299,13 +299,7 @@ let emit_call_gc gc = - assert Config.spacetime; - spacetime_before_uninstrumented_call ~node_ptr ~index - end; -- begin match gc.gc_size with -- | 16 -> emit_call "caml_call_gc1" -- | 24 -> emit_call "caml_call_gc2" -- | 32 -> emit_call "caml_call_gc3" -- | n -> I.add (int n) r15; -- emit_call "caml_call_gc" -- end; -+ emit_call "caml_call_gc"; - def_label gc.gc_frame; - I.jmp (label gc.gc_return_lbl) - -@@ -667,21 +661,21 @@ let emit_instr fallthrough i = - | Double | Double_u -> - I.movsd (arg i 0) (addressing addr REAL8 i 1) - end -- | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; }) -> -- if !fastcode_flag then begin -- let lbl_redo = new_label() in -- def_label lbl_redo; -+ | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; dbginfo }) -> -+ let dbginfo = -+ if not !Clflags.debug && not Config.spacetime then -+ List.map (fun d -> { d with alloc_dbg = Debuginfo.none }) dbginfo -+ else dbginfo in -+ if !fastcode_flag then begin - I.sub (int n) r15; - I.cmp (domain_field Domainstate.Domain_young_limit) r15; - let lbl_call_gc = new_label() in -- let dbg = -- if not Config.spacetime then Debuginfo.none -- else i.dbg -- in - let lbl_frame = -- record_frame_label ?label:label_after_call_gc i.live (Dbg_other dbg) -+ record_frame_label ?label:label_after_call_gc i.live (Dbg_alloc dbginfo) - in - I.jb (label lbl_call_gc); -+ let lbl_after_alloc = new_label() in -+ def_label lbl_after_alloc; - I.lea (mem64 NONE 8 R15) (res i 0); - let gc_spacetime = - if not Config.spacetime then None -@@ -690,7 +684,7 @@ let emit_instr fallthrough i = - call_gc_sites := - { gc_size = n; - gc_lbl = lbl_call_gc; -- gc_return_lbl = lbl_redo; -+ gc_return_lbl = lbl_after_alloc; - gc_frame = lbl_frame; - gc_spacetime; } :: !call_gc_sites - end else begin -@@ -708,7 +702,7 @@ let emit_instr fallthrough i = - end; - let label = - record_frame_label ?label:label_after_call_gc i.live -- (Dbg_other i.dbg) -+ (Dbg_alloc dbginfo) - in - def_label label; - I.lea (mem64 NONE 8 R15) (res i 0) -diff --git a/asmcomp/comballoc.ml b/asmcomp/comballoc.ml -index 29ee15b36..b8ebcf374 100644 ---- a/asmcomp/comballoc.ml -+++ b/asmcomp/comballoc.ml -@@ -17,34 +17,41 @@ - - open Mach - -+type pending_alloc = -+ { reg: Reg.t; (* register holding the result of the last allocation *) -+ dbginfos: alloc_dbginfo list; (* debug info for each pending allocation *) -+ totalsz: int } (* amount to be allocated in this block *) -+ - type allocation_state = - No_alloc -- | Pending_alloc of -- { reg: Reg.t; (* register holding the result of the last allocation *) -- totalsz: int } (* amount to be allocated in this block *) -- --let allocated_size = function -- No_alloc -> 0 -- | Pending_alloc {totalsz; _} -> totalsz -+ | Pending_alloc of pending_alloc - - let rec combine i allocstate = - match i.desc with - Iend | Ireturn | Iexit _ | Iraise _ -> -- (i, allocated_size allocstate) -- | Iop(Ialloc { bytes = sz; _ }) -> -+ (i, allocstate) -+ | Iop(Ialloc { bytes = sz; dbginfo; _ }) -> - begin match allocstate with -- | Pending_alloc {reg; totalsz} -+ | Pending_alloc {reg; dbginfos; totalsz} - when totalsz + sz < Config.max_young_wosize * Arch.size_addr -> - let (next, totalsz) = - combine i.next -- (Pending_alloc { reg = i.res.(0); totalsz = totalsz + sz }) in -+ (Pending_alloc { reg = i.res.(0); -+ dbginfos = dbginfo @ dbginfos; -+ totalsz = totalsz + sz }) in - (instr_cons_debug (Iop(Iintop_imm(Iadd, -sz))) - [| reg |] i.res i.dbg next, - totalsz) - | No_alloc | Pending_alloc _ -> -- let (next, totalsz) = -+ let (next, state) = - combine i.next -- (Pending_alloc { reg = i.res.(0); totalsz = sz }) in -+ (Pending_alloc { reg = i.res.(0); -+ dbginfos = dbginfo; -+ totalsz = sz }) in -+ let totalsz, dbginfo = -+ match state with -+ | No_alloc -> 0, dbginfo -+ | Pending_alloc { totalsz; dbginfos; _ } -> totalsz, dbginfos in - let next = - let offset = totalsz - sz in - if offset = 0 then next -@@ -52,40 +59,40 @@ let rec combine i allocstate = - i.res i.dbg next - in - (instr_cons_debug (Iop(Ialloc {bytes = totalsz; spacetime_index = 0; -- label_after_call_gc = None; })) -- i.arg i.res i.dbg next, allocated_size allocstate) -+ dbginfo; label_after_call_gc = None; })) -+ i.arg i.res i.dbg next, allocstate) - end - | Iop(Icall_ind _ | Icall_imm _ | Iextcall _ | - Itailcall_ind _ | Itailcall_imm _) -> - let newnext = combine_restart i.next in - (instr_cons_debug i.desc i.arg i.res i.dbg newnext, -- allocated_size allocstate) -+ allocstate) - | Iop _ -> -- let (newnext, sz) = combine i.next allocstate in -- (instr_cons_debug i.desc i.arg i.res i.dbg newnext, sz) -+ let (newnext, s') = combine i.next allocstate in -+ (instr_cons_debug i.desc i.arg i.res i.dbg newnext, s') - | Iifthenelse(test, ifso, ifnot) -> - let newifso = combine_restart ifso in - let newifnot = combine_restart ifnot in - let newnext = combine_restart i.next in - (instr_cons (Iifthenelse(test, newifso, newifnot)) i.arg i.res newnext, -- allocated_size allocstate) -+ allocstate) - | Iswitch(table, cases) -> - let newcases = Array.map combine_restart cases in - let newnext = combine_restart i.next in - (instr_cons (Iswitch(table, newcases)) i.arg i.res newnext, -- allocated_size allocstate) -+ allocstate) - | Icatch(rec_flag, handlers, body) -> -- let (newbody, sz) = combine body allocstate in -+ let (newbody, s') = combine body allocstate in - let newhandlers = - List.map (fun (io, handler) -> io, combine_restart handler) handlers in - let newnext = combine_restart i.next in - (instr_cons (Icatch(rec_flag, newhandlers, newbody)) -- i.arg i.res newnext, sz) -+ i.arg i.res newnext, s') - | Itrywith(body, handler) -> -- let (newbody, sz) = combine body allocstate in -+ let (newbody, s') = combine body allocstate in - let newhandler = combine_restart handler in - let newnext = combine_restart i.next in -- (instr_cons (Itrywith(newbody, newhandler)) i.arg i.res newnext, sz) -+ (instr_cons (Itrywith(newbody, newhandler)) i.arg i.res newnext, s') - - and combine_restart i = - let (newi, _) = combine i No_alloc in newi -diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml -index 9e7221096..8ed63af28 100644 ---- a/asmcomp/emitaux.ml -+++ b/asmcomp/emitaux.ml -@@ -106,6 +106,7 @@ let emit_float32_directive directive x = - (* Record live pointers at call points *) - - type frame_debuginfo = -+ | Dbg_alloc of Mach.alloc_dbginfo list - | Dbg_raise of Debuginfo.t - | Dbg_other of Debuginfo.t - -@@ -173,6 +174,10 @@ let emit_frames a = - match fd.fd_debuginfo with - | Dbg_other d | Dbg_raise d -> - if Debuginfo.is_none d then 0 else 1 -+ | Dbg_alloc dbgs -> -+ if List.for_all (fun d -> -+ Debuginfo.is_none d.Mach.alloc_dbg) dbgs -+ then 2 else 3 - in - a.efa_code_label fd.fd_lbl; - a.efa_16 (fd.fd_frame_size + flags); -@@ -187,6 +192,23 @@ let emit_frames a = - | Dbg_raise dbg -> - a.efa_align 4; - a.efa_label_rel (label_debuginfos true dbg) Int32.zero -+ | Dbg_alloc dbg -> -+ assert (List.length dbg < 256); -+ a.efa_8 (List.length dbg); -+ List.iter (fun Mach.{alloc_words;_} -> -+ (* Possible allocations range between 2 and 257 *) -+ assert (2 <= alloc_words && -+ alloc_words - 1 <= Config.max_young_wosize && -+ Config.max_young_wosize <= 256); -+ a.efa_8 (alloc_words - 2)) dbg; -+ if flags = 3 then begin -+ a.efa_align 4; -+ List.iter (fun Mach.{alloc_dbg; _} -> -+ if Debuginfo.is_none alloc_dbg then -+ a.efa_32 Int32.zero -+ else -+ a.efa_label_rel (label_debuginfos false alloc_dbg) Int32.zero) dbg -+ end - end; - a.efa_align Arch.size_addr - in -diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli -index a4a60e07c..1a8982a07 100644 ---- a/asmcomp/emitaux.mli -+++ b/asmcomp/emitaux.mli -@@ -39,6 +39,7 @@ val emit_debug_info_gen : - (file_num:int -> line:int -> col:int -> unit) -> unit - - type frame_debuginfo = -+ | Dbg_alloc of Mach.alloc_dbginfo list - | Dbg_raise of Debuginfo.t - | Dbg_other of Debuginfo.t - -diff --git a/asmcomp/mach.ml b/asmcomp/mach.ml -index ab69e0ca3..8df94d039 100644 ---- a/asmcomp/mach.ml -+++ b/asmcomp/mach.ml -@@ -39,6 +39,10 @@ type test = - | Ioddtest - | Ieventest - -+type alloc_dbginfo = -+ { alloc_words : int; -+ alloc_dbg : Debuginfo.t } -+ - type operation = - Imove - | Ispill -@@ -55,7 +59,7 @@ type operation = - | Iload of Cmm.memory_chunk * Arch.addressing_mode - | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool - | Ialloc of { bytes : int; label_after_call_gc : label option; -- spacetime_index : int; } -+ dbginfo : alloc_dbginfo list; spacetime_index : int; } - | Iintop of integer_operation - | Iintop_imm of integer_operation * int - | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf -diff --git a/asmcomp/mach.mli b/asmcomp/mach.mli -index 5df79585c..fd3e033bf 100644 ---- a/asmcomp/mach.mli -+++ b/asmcomp/mach.mli -@@ -46,6 +46,15 @@ type test = - | Ioddtest - | Ieventest - -+type alloc_dbginfo = -+ { alloc_words : int; -+ alloc_dbg : Debuginfo.t } -+(** Due to Comballoc, a single Ialloc instruction may combine several -+ unrelated allocations. Their Debuginfo.t (which may differ) are stored -+ as a list of alloc_dbginfo. This list is in order of increasing memory -+ address, which is the reverse of the original allocation order. Later -+ allocations are consed to the front of this list by Comballoc. *) -+ - type operation = - Imove - | Ispill -@@ -63,7 +72,7 @@ type operation = - | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool - (* false = initialization, true = assignment *) - | Ialloc of { bytes : int; label_after_call_gc : label option; -- spacetime_index : int; } -+ dbginfo : alloc_dbginfo list; spacetime_index : int; } - (** For Spacetime only, Ialloc instructions take one argument, being the - pointer to the trie node for the current function. *) - | Iintop of integer_operation -diff --git a/asmcomp/selectgen.ml b/asmcomp/selectgen.ml -index b024dfe7d..d5f54b699 100644 ---- a/asmcomp/selectgen.ml -+++ b/asmcomp/selectgen.ml -@@ -419,7 +419,8 @@ method mark_instr = function - (* Default instruction selection for operators *) - - method select_allocation bytes = -- Ialloc { bytes; spacetime_index = 0; label_after_call_gc = None; } -+ Ialloc { bytes; label_after_call_gc = None; -+ dbginfo = []; spacetime_index = 0; } - method select_allocation_args _env = [| |] - - method select_checkbound () = -@@ -775,8 +776,11 @@ method emit_expr (env:environment) exp = - | Ialloc { bytes = _; spacetime_index; label_after_call_gc; } -> - let rd = self#regs_for typ_val in - let bytes = size_expr env (Ctuple new_args) in -+ assert (bytes mod Arch.size_addr = 0); -+ let alloc_words = bytes / Arch.size_addr in - let op = -- Ialloc { bytes; spacetime_index; label_after_call_gc; } -+ Ialloc { bytes; spacetime_index; label_after_call_gc; -+ dbginfo = [{alloc_words; alloc_dbg = dbg}] } - in - let args = self#select_allocation_args env in - self#insert_debug env (Iop op) dbg args rd; -diff --git a/asmcomp/spacetime_profiling.ml b/asmcomp/spacetime_profiling.ml -index a61cd1c43..62e182ab9 100644 ---- a/asmcomp/spacetime_profiling.ml -+++ b/asmcomp/spacetime_profiling.ml -@@ -396,6 +396,7 @@ class virtual instruction_selection = object (self) - in - Mach.Ialloc { - bytes; -+ dbginfo = []; - label_after_call_gc = Some label; - spacetime_index = index; - } -diff --git a/runtime/amd64.S b/runtime/amd64.S -index 77a4f85aa..03c1f4e81 100644 ---- a/runtime/amd64.S -+++ b/runtime/amd64.S -@@ -425,111 +425,70 @@ ENDFUNCTION(G(caml_call_gc)) - - FUNCTION(G(caml_alloc1)) - CFI_STARTPROC --LBL(caml_alloc1): - subq $16, %r15 - cmpq Caml_state(young_limit), %r15 - jb LBL(100) - ret - LBL(100): -- addq $16, %r15 - RECORD_STACK_FRAME(0) - ENTER_FUNCTION - /* subq $8, %rsp; CFI_ADJUST (8); */ - call LBL(caml_call_gc) - /* addq $8, %rsp; CFI_ADJUST (-8); */ - LEAVE_FUNCTION -- jmp LBL(caml_alloc1) -+ ret - CFI_ENDPROC - ENDFUNCTION(G(caml_alloc1)) - - FUNCTION(G(caml_alloc2)) - CFI_STARTPROC --LBL(caml_alloc2): - subq $24, %r15 - cmpq Caml_state(young_limit), %r15 - jb LBL(101) - ret - LBL(101): -- addq $24, %r15 - RECORD_STACK_FRAME(0) - ENTER_FUNCTION - /* subq $8, %rsp; CFI_ADJUST (8); */ - call LBL(caml_call_gc) - /* addq $8, %rsp; CFI_ADJUST (-8); */ - LEAVE_FUNCTION -- jmp LBL(caml_alloc2) -+ ret - CFI_ENDPROC - ENDFUNCTION(G(caml_alloc2)) - - FUNCTION(G(caml_alloc3)) - CFI_STARTPROC --LBL(caml_alloc3): - subq $32, %r15 - cmpq Caml_state(young_limit), %r15 - jb LBL(102) - ret - LBL(102): -- addq $32, %r15 - RECORD_STACK_FRAME(0) - ENTER_FUNCTION - /* subq $8, %rsp; CFI_ADJUST (8) */ - call LBL(caml_call_gc) - /* addq $8, %rsp; CFI_ADJUST (-8) */ - LEAVE_FUNCTION -- jmp LBL(caml_alloc3) -+ ret - CFI_ENDPROC - ENDFUNCTION(G(caml_alloc3)) - - FUNCTION(G(caml_allocN)) - CFI_STARTPROC --LBL(caml_allocN): -- pushq %rax; CFI_ADJUST(8) /* save desired size */ - subq %rax, %r15 - cmpq Caml_state(young_limit), %r15 - jb LBL(103) -- addq $8, %rsp; CFI_ADJUST (-8) /* drop desired size */ - ret - LBL(103): -- addq 0(%rsp), %r15 -- CFI_ADJUST(8) -- RECORD_STACK_FRAME(8) --#ifdef WITH_FRAME_POINTERS -- /* ensure 16 byte alignment by subq + enter using 16-bytes, PR#7417 */ -- subq $8, %rsp; CFI_ADJUST (8) -+ RECORD_STACK_FRAME(0) - ENTER_FUNCTION --#endif - call LBL(caml_call_gc) --#ifdef WITH_FRAME_POINTERS -- /* ensure 16 byte alignment by leave + addq using 16-bytes PR#7417 */ - LEAVE_FUNCTION -- addq $8, %rsp; CFI_ADJUST (-8) --#endif -- popq %rax; CFI_ADJUST(-8) /* recover desired size */ -- jmp LBL(caml_allocN) -+ ret - CFI_ENDPROC - ENDFUNCTION(G(caml_allocN)) -- --/* Reset the allocation pointer and invoke the GC */ -- --FUNCTION(G(caml_call_gc1)) --CFI_STARTPROC -- addq $16, %r15 -- jmp GCALL(caml_call_gc) --CFI_ENDPROC -- --FUNCTION(G(caml_call_gc2)) --CFI_STARTPROC -- addq $24, %r15 -- jmp GCALL(caml_call_gc) --CFI_ENDPROC -- --FUNCTION(G(caml_call_gc3)) --CFI_STARTPROC -- addq $32, %r15 -- jmp GCALL(caml_call_gc) --CFI_ENDPROC -- -- -+ - /* Call a C function from OCaml */ - - FUNCTION(G(caml_c_call)) -diff --git a/runtime/backtrace_nat.c b/runtime/backtrace_nat.c -index acf31d644..ee18f2a00 100644 ---- a/runtime/backtrace_nat.c -+++ b/runtime/backtrace_nat.c -@@ -146,8 +146,20 @@ debuginfo caml_debuginfo_extract(backtrace_slot slot) - } - /* Recover debugging info */ - infoptr = (unsigned char*)&d->live_ofs[d->num_live]; -- /* align to 32 bits */ -- infoptr = Align_to(infoptr, uint32_t); -+ if (d->frame_size & 2) { -+ /* skip alloc_lengths */ -+ infoptr += *infoptr + 1; -+ /* align to 32 bits */ -+ infoptr = Align_to(infoptr, uint32_t); -+ /* we know there's at least one valid debuginfo, -+ but it may not be the one for the first alloc */ -+ while (*(uint32_t*)infoptr == 0) { -+ infoptr += sizeof(uint32_t); -+ } -+ } else { -+ /* align to 32 bits */ -+ infoptr = Align_to(infoptr, uint32_t); -+ } - /* read offset to debuginfo */ - debuginfo_offset = *(uint32_t*)infoptr; - return (debuginfo)(infoptr + debuginfo_offset); -diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index 30a18d274..44a881e41 100644 ---- a/runtime/caml/stack.h -+++ b/runtime/caml/stack.h -@@ -89,9 +89,15 @@ typedef struct { - unsigned short num_live; - unsigned short live_ofs[1 /* num_live */]; - /* -+ If frame_size & 2, then allocation info follows: -+ unsigned char num_allocs; -+ unsigned char alloc_lengths[num_alloc]; -+ - If frame_size & 1, then debug info follows: -- uint32_t debug_info_offset; -- Debug info is stored as a relative offset to a debuginfo structure. */ -+ uint32_t debug_info_offset[num_debug]; -+ -+ Debug info is stored as relative offsets to debuginfo structures. -+ num_debug is num_alloc if frame_size & 2, otherwise 1. */ - } frame_descr; - - /* Used to compute offsets in frame tables. -diff --git a/runtime/minor_gc.c b/runtime/minor_gc.c -index e4dacfc51..4b3634275 100644 ---- a/runtime/minor_gc.c -+++ b/runtime/minor_gc.c -@@ -509,6 +509,11 @@ void caml_alloc_small_dispatch (tag_t tag, intnat wosize, int flags) - callbacks. */ - CAML_INSTR_INT ("force_minor/alloc_small@", 1); - caml_gc_dispatch (); -+#if defined(NATIVE_CODE) && defined(WITH_SPACETIME) -+ if (caml_young_ptr == caml_young_alloc_end) { -+ caml_spacetime_automatic_snapshot(); -+ } -+#endif - } - - /* Re-do the allocation: we now have enough space in the minor heap. */ -diff --git a/runtime/roots_nat.c b/runtime/roots_nat.c -index f61e56d90..b98555838 100644 ---- a/runtime/roots_nat.c -+++ b/runtime/roots_nat.c -@@ -83,6 +83,11 @@ static frame_descr * next_frame_descr(frame_descr * d) { - CAMLassert(d->retaddr >= 4096); - /* Skip to end of live_ofs */ - p = (unsigned char*)&d->live_ofs[d->num_live]; -+ /* Skip alloc_lengths if present */ -+ if (d->frame_size & 2) { -+ num_allocs = *p; -+ p += num_allocs + 1; -+ } - /* Skip debug info if present */ - if (d->frame_size & 1) { - /* Align to 32 bits */ -diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c -index 017298394..075db46e3 100644 ---- a/runtime/signals_nat.c -+++ b/runtime/signals_nat.c -@@ -69,29 +69,26 @@ extern char caml_system__code_begin, caml_system__code_end; - - void caml_garbage_collection(void) - { -- /* TEMPORARY: if we have just sampled an allocation in native mode, -- we simply renew the sample to ignore it. Otherwise, renewing now -- will not have any effect on the sampling distribution, because of -- the memorylessness of the Bernoulli process. -- -- FIXME: if the sampling rate is 1, this leads to infinite loop, -- because we are using a binomial distribution in [memprof.c]. This -- will go away when the sampling of natively allocated blocks will -- be correctly implemented. -- */ -- caml_memprof_renew_minor_sample(); -- if (Caml_state->requested_major_slice || Caml_state->requested_minor_gc || -- Caml_state->young_ptr - Caml_state->young_trigger < Max_young_whsize){ -- caml_gc_dispatch (); -+ frame_descr* d; -+ uintnat h; -+ h = Hash_retaddr(Caml_state->last_return_address); -+ while (1) { -+ d = caml_frame_descriptors[h]; -+ if (d->retaddr == Caml_state->last_return_address) break; -+ h = (h + 1) & caml_frame_descriptors_mask; - } - --#ifdef WITH_SPACETIME -- if (Caml_state->young_ptr == Caml_state->young_alloc_end) { -- caml_spacetime_automatic_snapshot(); -- } --#endif -+ /* Must be an allocation frame */ -+ CAMLassert(d && d->frame_size != 0xFFFF && (d->frame_size & 2)); -+ -+ unsigned char* alloc_len = (unsigned char*)(&d->live_ofs[d->num_live]); -+ int nallocs = *alloc_len++; -+ int allocsz = 0; -+ for (int i = 0; i < nallocs; i++) allocsz += alloc_len[i] + 2; -+ allocsz -= 1; - -- caml_raise_if_exception(caml_do_pending_actions_exn()); -+ caml_alloc_small_dispatch(0 /* FIXME */, allocsz, -+ /* CAML_DO_TRACK | */ CAML_FROM_CAML); - } - - DECLARE_SIGNAL_HANDLER(handle_signal) --- -2.24.1 - diff --git a/0007-Use-allocation-size-info-on-more-than-just-amd64.patch b/0007-Use-allocation-size-info-on-more-than-just-amd64.patch deleted file mode 100644 index 25aa5a8..0000000 --- a/0007-Use-allocation-size-info-on-more-than-just-amd64.patch +++ /dev/null @@ -1,926 +0,0 @@ -From 69eac75740fafad36246392c666410e9e66388d7 Mon Sep 17 00:00:00 2001 -From: Stephen Dolan -Date: Wed, 18 Sep 2019 16:15:18 +0100 -Subject: [PATCH 7/8] Use allocation-size info on more than just amd64. - -Moves the alloc_dbginfo type to Debuginfo, to avoid a circular -dependency on architectures that use Branch_relaxation. - -This commit generates frame tables with allocation sizes on all -architectures, but does not yet update the allocation code for -non-amd64 backends. - -(cherry picked from commit 768dcce48f79c33beb2af342a4c3551c276afe11) ---- - .depend | 4 ++-- - asmcomp/amd64/emit.mlp | 14 +++-------- - asmcomp/arm/emit.mlp | 27 ++++++++++----------- - asmcomp/arm64/arch.ml | 3 ++- - asmcomp/arm64/emit.mlp | 37 +++++++++++++++-------------- - asmcomp/branch_relaxation.ml | 5 ++-- - asmcomp/branch_relaxation_intf.ml | 1 + - asmcomp/comballoc.ml | 6 ++--- - asmcomp/emitaux.ml | 13 ++++++----- - asmcomp/emitaux.mli | 2 +- - asmcomp/i386/emit.mlp | 37 +++++++++++++++-------------- - asmcomp/mach.ml | 6 +---- - asmcomp/mach.mli | 11 +-------- - asmcomp/power/arch.ml | 3 ++- - asmcomp/power/emit.mlp | 39 ++++++++++++++++--------------- - asmcomp/s390x/emit.mlp | 25 ++++++++++---------- - lambda/debuginfo.ml | 5 ++++ - lambda/debuginfo.mli | 11 +++++++++ - 18 files changed, 128 insertions(+), 121 deletions(-) - -diff --git a/.depend b/.depend -index c40e2f0f7..becb7bcc0 100644 ---- a/.depend -+++ b/.depend -@@ -2152,10 +2152,12 @@ asmcomp/branch_relaxation.cmi : \ - asmcomp/linear.cmi \ - asmcomp/branch_relaxation_intf.cmo - asmcomp/branch_relaxation_intf.cmo : \ -+ asmcomp/mach.cmi \ - asmcomp/linear.cmi \ - asmcomp/cmm.cmi \ - asmcomp/arch.cmo - asmcomp/branch_relaxation_intf.cmx : \ -+ asmcomp/mach.cmx \ - asmcomp/linear.cmx \ - asmcomp/cmm.cmx \ - asmcomp/arch.cmx -@@ -2351,7 +2353,6 @@ asmcomp/emit.cmo : \ - lambda/lambda.cmi \ - asmcomp/emitaux.cmi \ - utils/domainstate.cmi \ -- lambda/debuginfo.cmi \ - utils/config.cmi \ - middle_end/compilenv.cmi \ - asmcomp/cmm.cmi \ -@@ -2373,7 +2374,6 @@ asmcomp/emit.cmx : \ - lambda/lambda.cmx \ - asmcomp/emitaux.cmx \ - utils/domainstate.cmx \ -- lambda/debuginfo.cmx \ - utils/config.cmx \ - middle_end/compilenv.cmx \ - asmcomp/cmm.cmx \ -diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp -index 6c3950a6d..bdf3462ec 100644 ---- a/asmcomp/amd64/emit.mlp -+++ b/asmcomp/amd64/emit.mlp -@@ -281,8 +281,7 @@ let spacetime_before_uninstrumented_call ~node_ptr ~index = - (* Record calls to the GC -- we've moved them out of the way *) - - type gc_call = -- { gc_size: int; (* Allocation size, in bytes *) -- gc_lbl: label; (* Entry label *) -+ { gc_lbl: label; (* Entry label *) - gc_return_lbl: label; (* Where to branch after GC *) - gc_frame: label; (* Label of frame descriptor *) - gc_spacetime : (X86_ast.arg * int) option; -@@ -662,10 +661,7 @@ let emit_instr fallthrough i = - I.movsd (arg i 0) (addressing addr REAL8 i 1) - end - | Lop(Ialloc { bytes = n; label_after_call_gc; spacetime_index; dbginfo }) -> -- let dbginfo = -- if not !Clflags.debug && not Config.spacetime then -- List.map (fun d -> { d with alloc_dbg = Debuginfo.none }) dbginfo -- else dbginfo in -+ assert (n <= (Config.max_young_wosize + 1) * Arch.size_addr); - if !fastcode_flag then begin - I.sub (int n) r15; - I.cmp (domain_field Domainstate.Domain_young_limit) r15; -@@ -682,8 +678,7 @@ let emit_instr fallthrough i = - else Some (arg i 0, spacetime_index) - in - call_gc_sites := -- { gc_size = n; -- gc_lbl = lbl_call_gc; -+ { gc_lbl = lbl_call_gc; - gc_return_lbl = lbl_after_alloc; - gc_frame = lbl_frame; - gc_spacetime; } :: !call_gc_sites -@@ -1009,9 +1004,6 @@ let begin_assembly() = - all_functions := []; - if system = S_win64 then begin - D.extrn "caml_call_gc" NEAR; -- D.extrn "caml_call_gc1" NEAR; -- D.extrn "caml_call_gc2" NEAR; -- D.extrn "caml_call_gc3" NEAR; - D.extrn "caml_c_call" NEAR; - D.extrn "caml_allocN" NEAR; - D.extrn "caml_alloc1" NEAR; -diff --git a/asmcomp/arm/emit.mlp b/asmcomp/arm/emit.mlp -index 1393d4576..0689cd17c 100644 ---- a/asmcomp/arm/emit.mlp -+++ b/asmcomp/arm/emit.mlp -@@ -105,7 +105,7 @@ let emit_addressing addr r n = - - (* Record live pointers at call points *) - --let record_frame_label ?label live raise_ dbg = -+let record_frame_label ?label live dbg = - let lbl = - match label with - | None -> new_label() -@@ -123,11 +123,11 @@ let record_frame_label ?label live raise_ dbg = - | _ -> ()) - live; - record_frame_descr ~label:lbl ~frame_size:(frame_size()) -- ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ ~live_offset:!live_offset dbg; - lbl - --let record_frame ?label live raise_ dbg = -- let lbl = record_frame_label ?label live raise_ dbg in `{emit_label lbl}:` -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in `{emit_label lbl}:` - - (* Record calls to the GC -- we've moved them out of the way *) - -@@ -155,7 +155,7 @@ let bound_error_sites = ref ([] : bound_error_call list) - let bound_error_label ?label dbg = - if !Clflags.debug || !bound_error_sites = [] then begin - let lbl_bound_error = new_label() in -- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in - bound_error_sites := - { bd_lbl = lbl_bound_error; - bd_frame_lbl = lbl_frame } :: !bound_error_sites; -@@ -542,15 +542,15 @@ let emit_instr i = - | Lop(Icall_ind { label_after; }) -> - if !arch >= ARMv5 then begin - ` blx {emit_reg i.arg.(0)}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n`; 1 -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; 1 - end else begin - ` mov lr, pc\n`; - ` bx {emit_reg i.arg.(0)}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n`; 2 -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; 2 - end - | Lop(Icall_imm { func; label_after; }) -> - ` {emit_call func}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n`; 1 -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; 1 - | Lop(Itailcall_ind { label_after = _; }) -> - output_epilogue begin fun () -> - if !contains_calls then -@@ -572,7 +572,7 @@ let emit_instr i = - | Lop(Iextcall { func; alloc = true; label_after; }) -> - let ninstr = emit_load_symbol_addr (phys_reg 7 (* r7 *)) func in - ` {emit_call "caml_c_call"}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n`; -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n`; - 1 + ninstr - | Lop(Istackoffset n) -> - assert (n mod 8 = 0); -@@ -642,9 +642,9 @@ let emit_instr i = - | Double_u -> "fstd" - | _ (* 32-bit quantities *) -> "str" in - ` {emit_string instr} {emit_reg r}, {emit_addressing addr i.arg 1}\n`; 1 -- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> -+ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> - let lbl_frame = -- record_frame_label i.live false i.dbg ?label:label_after_call_gc -+ record_frame_label i.live (Dbg_alloc dbginfo) ?label:label_after_call_gc - in - if !fastcode_flag then begin - let lbl_redo = new_label() in -@@ -912,10 +912,10 @@ let emit_instr i = - ` mov r12, #0\n`; - ` str r12, [domain_state_ptr, {emit_int offset}]\n`; - ` {emit_call "caml_raise_exn"}\n`; -- `{record_frame Reg.Set.empty true i.dbg}\n`; 3 -+ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n`; 3 - | Lambda.Raise_reraise -> - ` {emit_call "caml_raise_exn"}\n`; -- `{record_frame Reg.Set.empty true i.dbg}\n`; 1 -+ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n`; 1 - | Lambda.Raise_notrace -> - ` mov sp, trap_ptr\n`; - ` pop \{trap_ptr, pc}\n`; 2 -@@ -1072,6 +1072,7 @@ let end_assembly () = - efa_data_label = (fun lbl -> - ` .type {emit_label lbl}, %object\n`; - ` .word {emit_label lbl}\n`); -+ efa_8 = (fun n -> ` .byte {emit_int n}\n`); - efa_16 = (fun n -> ` .short {emit_int n}\n`); - efa_32 = (fun n -> ` .long {emit_int32 n}\n`); - efa_word = (fun n -> ` .word {emit_int n}\n`); -diff --git a/asmcomp/arm64/arch.ml b/asmcomp/arm64/arch.ml -index ce5902aa2..9cf923c6c 100644 ---- a/asmcomp/arm64/arch.ml -+++ b/asmcomp/arm64/arch.ml -@@ -38,7 +38,8 @@ type cmm_label = int - (* Do not introduce a dependency to Cmm *) - - type specific_operation = -- | Ifar_alloc of { bytes : int; label_after_call_gc : cmm_label option; } -+ | Ifar_alloc of { bytes : int; label_after_call_gc : cmm_label option; -+ dbginfo : Debuginfo.alloc_dbginfo } - | Ifar_intop_checkbound of { label_after_error : cmm_label option; } - | Ifar_intop_imm_checkbound of - { bound : int; label_after_error : cmm_label option; } -diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp -index eb8424bf5..cb5e75d7a 100644 ---- a/asmcomp/arm64/emit.mlp -+++ b/asmcomp/arm64/emit.mlp -@@ -126,7 +126,7 @@ let emit_addressing addr r = - - (* Record live pointers at call points *) - --let record_frame_label ?label live raise_ dbg = -+let record_frame_label ?label live dbg = - let lbl = - match label with - | None -> new_label() -@@ -144,11 +144,11 @@ let record_frame_label ?label live raise_ dbg = - | _ -> ()) - live; - record_frame_descr ~label:lbl ~frame_size:(frame_size()) -- ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ ~live_offset:!live_offset dbg; - lbl - --let record_frame ?label live raise_ dbg = -- let lbl = record_frame_label ?label live raise_ dbg in `{emit_label lbl}:` -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in `{emit_label lbl}:` - - (* Record calls to the GC -- we've moved them out of the way *) - -@@ -176,7 +176,7 @@ let bound_error_sites = ref ([] : bound_error_call list) - let bound_error_label ?label dbg = - if !Clflags.debug || !bound_error_sites = [] then begin - let lbl_bound_error = new_label() in -- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in - bound_error_sites := - { bd_lbl = lbl_bound_error; - bd_frame_lbl = lbl_frame } :: !bound_error_sites; -@@ -512,8 +512,8 @@ module BR = Branch_relaxation.Make (struct - | Lambda.Raise_notrace -> 4 - end - -- let relax_allocation ~num_bytes ~label_after_call_gc = -- Lop (Ispecific (Ifar_alloc { bytes = num_bytes; label_after_call_gc; })) -+ let relax_allocation ~num_bytes ~label_after_call_gc ~dbginfo = -+ Lop (Ispecific (Ifar_alloc { bytes = num_bytes; label_after_call_gc; dbginfo })) - - let relax_intop_checkbound ~label_after_error = - Lop (Ispecific (Ifar_intop_checkbound { label_after_error; })) -@@ -529,9 +529,9 @@ end) - - (* Output the assembly code for allocation. *) - --let assembly_code_for_allocation ?label_after_call_gc i ~n ~far = -+let assembly_code_for_allocation ~label_after_call_gc i ~n ~far ~dbginfo = - let lbl_frame = -- record_frame_label ?label:label_after_call_gc i.live false i.dbg -+ record_frame_label ?label:label_after_call_gc i.live (Dbg_alloc dbginfo) - in - if !fastcode_flag then begin - let lbl_redo = new_label() in -@@ -626,10 +626,10 @@ let emit_instr i = - emit_load_symbol_addr i.res.(0) s - | Lop(Icall_ind { label_after; }) -> - ` blr {emit_reg i.arg.(0)}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n` -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` - | Lop(Icall_imm { func; label_after; }) -> - ` bl {emit_symbol func}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n` -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` - | Lop(Itailcall_ind { label_after = _; }) -> - output_epilogue (fun () -> ` br {emit_reg i.arg.(0)}\n`) - | Lop(Itailcall_imm { func; label_after = _; }) -> -@@ -642,7 +642,7 @@ let emit_instr i = - | Lop(Iextcall { func; alloc = true; label_after; }) -> - emit_load_symbol_addr reg_x15 func; - ` bl {emit_symbol "caml_c_call"}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n` -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` - | Lop(Istackoffset n) -> - assert (n mod 16 = 0); - emit_stack_adjustment (-n); -@@ -697,10 +697,10 @@ let emit_instr i = - | Word_int | Word_val | Double | Double_u -> - ` str {emit_reg src}, {emit_addressing addr base}\n` - end -- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> -- assembly_code_for_allocation i ~n ~far:false ?label_after_call_gc -- | Lop(Ispecific (Ifar_alloc { bytes = n; label_after_call_gc; })) -> -- assembly_code_for_allocation i ~n ~far:true ?label_after_call_gc -+ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> -+ assembly_code_for_allocation i ~n ~far:false ~label_after_call_gc ~dbginfo -+ | Lop(Ispecific (Ifar_alloc { bytes = n; label_after_call_gc; dbginfo })) -> -+ assembly_code_for_allocation i ~n ~far:true ~label_after_call_gc ~dbginfo - | Lop(Iintop(Icomp cmp)) -> - ` cmp {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; - ` cset {emit_reg i.res.(0)}, {emit_string (name_for_comparison cmp)}\n` -@@ -906,10 +906,10 @@ let emit_instr i = - let offset = Domainstate.(idx_of_field Domain_backtrace_pos) * 8 in - ` str xzr, [{emit_reg reg_domain_state_ptr}, {emit_int offset}]\n`; - ` bl {emit_symbol "caml_raise_exn"}\n`; -- `{record_frame Reg.Set.empty true i.dbg}\n` -+ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` - | Lambda.Raise_reraise -> - ` bl {emit_symbol "caml_raise_exn"}\n`; -- `{record_frame Reg.Set.empty true i.dbg}\n` -+ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` - | Lambda.Raise_notrace -> - ` mov sp, {emit_reg reg_trap_ptr}\n`; - ` ldr {emit_reg reg_tmp1}, [sp, #8]\n`; -@@ -1027,6 +1027,7 @@ let end_assembly () = - efa_data_label = (fun lbl -> - ` .type {emit_label lbl}, %object\n`; - ` .quad {emit_label lbl}\n`); -+ efa_8 = (fun n -> ` .byte {emit_int n}\n`); - efa_16 = (fun n -> ` .short {emit_int n}\n`); - efa_32 = (fun n -> ` .long {emit_int32 n}\n`); - efa_word = (fun n -> ` .quad {emit_int n}\n`); -diff --git a/asmcomp/branch_relaxation.ml b/asmcomp/branch_relaxation.ml -index 953c2827c..74b749ea8 100644 ---- a/asmcomp/branch_relaxation.ml -+++ b/asmcomp/branch_relaxation.ml -@@ -86,8 +86,9 @@ module Make (T : Branch_relaxation_intf.S) = struct - fixup did_fix (pc + T.instr_size instr.desc) instr.next - else - match instr.desc with -- | Lop (Ialloc { bytes = num_bytes; label_after_call_gc; }) -> -- instr.desc <- T.relax_allocation ~num_bytes ~label_after_call_gc; -+ | Lop (Ialloc { bytes = num_bytes; label_after_call_gc; dbginfo }) -> -+ instr.desc <- T.relax_allocation ~num_bytes -+ ~dbginfo ~label_after_call_gc; - fixup true (pc + T.instr_size instr.desc) instr.next - | Lop (Iintop (Icheckbound { label_after_error; })) -> - instr.desc <- T.relax_intop_checkbound ~label_after_error; -diff --git a/asmcomp/branch_relaxation_intf.ml b/asmcomp/branch_relaxation_intf.ml -index d5552f83f..b7a7271fb 100644 ---- a/asmcomp/branch_relaxation_intf.ml -+++ b/asmcomp/branch_relaxation_intf.ml -@@ -63,6 +63,7 @@ module type S = sig - val relax_allocation - : num_bytes:int - -> label_after_call_gc:Cmm.label option -+ -> dbginfo:Debuginfo.alloc_dbginfo - -> Linear.instruction_desc - val relax_intop_checkbound - : label_after_error:Cmm.label option -diff --git a/asmcomp/comballoc.ml b/asmcomp/comballoc.ml -index b8ebcf374..16bda3772 100644 ---- a/asmcomp/comballoc.ml -+++ b/asmcomp/comballoc.ml -@@ -18,9 +18,9 @@ - open Mach - - type pending_alloc = -- { reg: Reg.t; (* register holding the result of the last allocation *) -- dbginfos: alloc_dbginfo list; (* debug info for each pending allocation *) -- totalsz: int } (* amount to be allocated in this block *) -+ { reg: Reg.t; (* register holding the result of the last allocation *) -+ dbginfos: Debuginfo.alloc_dbginfo; (* debug info for each pending alloc *) -+ totalsz: int } (* amount to be allocated in this block *) - - type allocation_state = - No_alloc -diff --git a/asmcomp/emitaux.ml b/asmcomp/emitaux.ml -index 8ed63af28..8e3ec8d50 100644 ---- a/asmcomp/emitaux.ml -+++ b/asmcomp/emitaux.ml -@@ -106,7 +106,7 @@ let emit_float32_directive directive x = - (* Record live pointers at call points *) - - type frame_debuginfo = -- | Dbg_alloc of Mach.alloc_dbginfo list -+ | Dbg_alloc of Debuginfo.alloc_dbginfo - | Dbg_raise of Debuginfo.t - | Dbg_other of Debuginfo.t - -@@ -175,9 +175,10 @@ let emit_frames a = - | Dbg_other d | Dbg_raise d -> - if Debuginfo.is_none d then 0 else 1 - | Dbg_alloc dbgs -> -- if List.for_all (fun d -> -- Debuginfo.is_none d.Mach.alloc_dbg) dbgs -- then 2 else 3 -+ if !Clflags.debug && not Config.spacetime && -+ List.exists (fun d -> -+ not (Debuginfo.is_none d.Debuginfo.alloc_dbg)) dbgs -+ then 3 else 2 - in - a.efa_code_label fd.fd_lbl; - a.efa_16 (fd.fd_frame_size + flags); -@@ -195,7 +196,7 @@ let emit_frames a = - | Dbg_alloc dbg -> - assert (List.length dbg < 256); - a.efa_8 (List.length dbg); -- List.iter (fun Mach.{alloc_words;_} -> -+ List.iter (fun Debuginfo.{alloc_words;_} -> - (* Possible allocations range between 2 and 257 *) - assert (2 <= alloc_words && - alloc_words - 1 <= Config.max_young_wosize && -@@ -203,7 +204,7 @@ let emit_frames a = - a.efa_8 (alloc_words - 2)) dbg; - if flags = 3 then begin - a.efa_align 4; -- List.iter (fun Mach.{alloc_dbg; _} -> -+ List.iter (fun Debuginfo.{alloc_dbg; _} -> - if Debuginfo.is_none alloc_dbg then - a.efa_32 Int32.zero - else -diff --git a/asmcomp/emitaux.mli b/asmcomp/emitaux.mli -index 1a8982a07..2b4867d0b 100644 ---- a/asmcomp/emitaux.mli -+++ b/asmcomp/emitaux.mli -@@ -39,7 +39,7 @@ val emit_debug_info_gen : - (file_num:int -> line:int -> col:int -> unit) -> unit - - type frame_debuginfo = -- | Dbg_alloc of Mach.alloc_dbginfo list -+ | Dbg_alloc of Debuginfo.alloc_dbginfo - | Dbg_raise of Debuginfo.t - | Dbg_other of Debuginfo.t - -diff --git a/asmcomp/i386/emit.mlp b/asmcomp/i386/emit.mlp -index 9c1ca30a2..614bb33fe 100644 ---- a/asmcomp/i386/emit.mlp -+++ b/asmcomp/i386/emit.mlp -@@ -200,7 +200,7 @@ let addressing addr typ i n = - - (* Record live pointers at call points *) - --let record_frame_label ?label live raise_ dbg = -+let record_frame_label ?label live dbg = - let lbl = - match label with - | None -> new_label() -@@ -218,11 +218,11 @@ let record_frame_label ?label live raise_ dbg = - | _ -> ()) - live; - record_frame_descr ~label:lbl ~frame_size:(frame_size()) -- ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ ~live_offset:!live_offset dbg; - lbl - --let record_frame ?label live raise_ dbg = -- let lbl = record_frame_label ?label live raise_ dbg in -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in - def_label lbl - - (* Record calls to the GC -- we've moved them out of the way *) -@@ -254,7 +254,7 @@ let bound_error_call = ref 0 - let bound_error_label ?label dbg = - if !Clflags.debug then begin - let lbl_bound_error = new_label() in -- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in - bound_error_sites := - { bd_lbl = lbl_bound_error; bd_frame = lbl_frame } :: !bound_error_sites; - lbl_bound_error -@@ -540,11 +540,11 @@ let emit_instr fallthrough i = - I.mov (immsym s) (reg i.res.(0)) - | Lop(Icall_ind { label_after; }) -> - I.call (reg i.arg.(0)); -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - | Lop(Icall_imm { func; label_after; }) -> - add_used_symbol func; - emit_call func; -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - | Lop(Itailcall_ind { label_after = _; }) -> - output_epilogue begin fun () -> - I.jmp (reg i.arg.(0)) -@@ -563,7 +563,7 @@ let emit_instr fallthrough i = - if alloc then begin - I.mov (immsym func) eax; - emit_call "caml_c_call"; -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - end else begin - emit_call func - end -@@ -614,22 +614,24 @@ let emit_instr fallthrough i = - I.fstp (addressing addr REAL8 i 1) - end - end -- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> -+ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> - if !fastcode_flag then begin -- let lbl_redo = new_label() in -- def_label lbl_redo; - load_domain_state ebx; - I.mov (domain_field Domain_young_ptr RBX) eax; - I.sub (int n) eax; - I.cmp (domain_field Domain_young_limit RBX) eax; - let lbl_call_gc = new_label() in -- let lbl_frame = record_frame_label i.live false Debuginfo.none in -+ let lbl_frame = -+ record_frame_label ?label:label_after_call_gc -+ i.live (Dbg_alloc dbginfo) in - I.jb (label lbl_call_gc); - I.mov eax (domain_field Domain_young_ptr RBX); -+ let lbl_after_alloc = new_label() in -+ def_label lbl_after_alloc; - I.lea (mem32 NONE 4 RAX) (reg i.res.(0)); - call_gc_sites := - { gc_lbl = lbl_call_gc; -- gc_return_lbl = lbl_redo; -+ gc_return_lbl = lbl_after_alloc; - gc_frame = lbl_frame } :: !call_gc_sites - end else begin - begin match n with -@@ -641,8 +643,8 @@ let emit_instr fallthrough i = - emit_call "caml_allocN" - end; - let label = -- record_frame_label ?label:label_after_call_gc i.live false -- Debuginfo.none -+ record_frame_label ?label:label_after_call_gc -+ i.live (Dbg_alloc dbginfo) - in - def_label label; - I.lea (mem32 NONE 4 RAX) (reg i.res.(0)) -@@ -895,10 +897,10 @@ let emit_instr fallthrough i = - load_domain_state ebx; - I.mov (int 0) (domain_field Domain_backtrace_pos RBX); - emit_call "caml_raise_exn"; -- record_frame Reg.Set.empty true i.dbg -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) - | Lambda.Raise_reraise -> - emit_call "caml_raise_exn"; -- record_frame Reg.Set.empty true i.dbg -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) - | Lambda.Raise_notrace -> - load_domain_state ebx; - I.mov (domain_field Domain_exception_pointer RBX) esp; -@@ -1019,6 +1021,7 @@ let end_assembly() = - emit_frames - { efa_code_label = (fun l -> D.long (ConstLabel (emit_label l))); - efa_data_label = (fun l -> D.long (ConstLabel (emit_label l))); -+ efa_8 = (fun n -> D.byte (const n)); - efa_16 = (fun n -> D.word (const n)); - efa_32 = (fun n -> D.long (const_32 n)); - efa_word = (fun n -> D.long (const n)); -diff --git a/asmcomp/mach.ml b/asmcomp/mach.ml -index 8df94d039..8518e9da6 100644 ---- a/asmcomp/mach.ml -+++ b/asmcomp/mach.ml -@@ -39,10 +39,6 @@ type test = - | Ioddtest - | Ieventest - --type alloc_dbginfo = -- { alloc_words : int; -- alloc_dbg : Debuginfo.t } -- - type operation = - Imove - | Ispill -@@ -59,7 +55,7 @@ type operation = - | Iload of Cmm.memory_chunk * Arch.addressing_mode - | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool - | Ialloc of { bytes : int; label_after_call_gc : label option; -- dbginfo : alloc_dbginfo list; spacetime_index : int; } -+ dbginfo : Debuginfo.alloc_dbginfo; spacetime_index : int; } - | Iintop of integer_operation - | Iintop_imm of integer_operation * int - | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf -diff --git a/asmcomp/mach.mli b/asmcomp/mach.mli -index fd3e033bf..1141d57d0 100644 ---- a/asmcomp/mach.mli -+++ b/asmcomp/mach.mli -@@ -46,15 +46,6 @@ type test = - | Ioddtest - | Ieventest - --type alloc_dbginfo = -- { alloc_words : int; -- alloc_dbg : Debuginfo.t } --(** Due to Comballoc, a single Ialloc instruction may combine several -- unrelated allocations. Their Debuginfo.t (which may differ) are stored -- as a list of alloc_dbginfo. This list is in order of increasing memory -- address, which is the reverse of the original allocation order. Later -- allocations are consed to the front of this list by Comballoc. *) -- - type operation = - Imove - | Ispill -@@ -72,7 +63,7 @@ type operation = - | Istore of Cmm.memory_chunk * Arch.addressing_mode * bool - (* false = initialization, true = assignment *) - | Ialloc of { bytes : int; label_after_call_gc : label option; -- dbginfo : alloc_dbginfo list; spacetime_index : int; } -+ dbginfo : Debuginfo.alloc_dbginfo; spacetime_index : int; } - (** For Spacetime only, Ialloc instructions take one argument, being the - pointer to the trie node for the current function. *) - | Iintop of integer_operation -diff --git a/asmcomp/power/arch.ml b/asmcomp/power/arch.ml -index 70cd75ddb..11d9e2328 100644 ---- a/asmcomp/power/arch.ml -+++ b/asmcomp/power/arch.ml -@@ -47,7 +47,8 @@ type specific_operation = - Imultaddf (* multiply and add *) - | Imultsubf (* multiply and subtract *) - | Ialloc_far of (* allocation in large functions *) -- { bytes : int; label_after_call_gc : int (*Cmm.label*) option; } -+ { bytes : int; label_after_call_gc : int (*Cmm.label*) option; -+ dbginfo : Debuginfo.alloc_dbginfo } - - (* note: we avoid introducing a dependency to Cmm since this dep - is not detected when "make depend" is run under amd64 *) -diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp -index 4c577d0b1..5053d2505 100644 ---- a/asmcomp/power/emit.mlp -+++ b/asmcomp/power/emit.mlp -@@ -308,7 +308,7 @@ let adjust_stack_offset delta = - - (* Record live pointers at call points *) - --let record_frame ?label live raise_ dbg = -+let record_frame ?label live dbg = - let lbl = - match label with - | None -> new_label() -@@ -326,7 +326,7 @@ let record_frame ?label live raise_ dbg = - | _ -> ()) - live; - record_frame_descr ~label:lbl ~frame_size:(frame_size()) -- ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ ~live_offset:!live_offset dbg; - `{emit_label lbl}:\n` - - (* Record floating-point literals (for PPC32) *) -@@ -546,8 +546,8 @@ module BR = Branch_relaxation.Make (struct - | Lpoptrap -> 2 - | Lraise _ -> 6 - -- let relax_allocation ~num_bytes:bytes ~label_after_call_gc = -- Lop (Ispecific (Ialloc_far { bytes; label_after_call_gc; })) -+ let relax_allocation ~num_bytes:bytes ~label_after_call_gc ~dbginfo = -+ Lop (Ispecific (Ialloc_far { bytes; label_after_call_gc; dbginfo })) - - (* [classify_addr], above, never identifies these instructions as needing - relaxing. As such, these functions should never be called. *) -@@ -652,26 +652,26 @@ let emit_instr i = - | ELF32 -> - ` mtctr {emit_reg i.arg.(0)}\n`; - ` bctrl\n`; -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - | ELF64v1 -> - ` ld 0, 0({emit_reg i.arg.(0)})\n`; (* code pointer *) - ` mtctr 0\n`; - ` ld 2, 8({emit_reg i.arg.(0)})\n`; (* TOC for callee *) - ` bctrl\n`; -- record_frame i.live false i.dbg ~label:label_after; -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after; - emit_reload_toc() - | ELF64v2 -> - ` mtctr {emit_reg i.arg.(0)}\n`; - ` mr 12, {emit_reg i.arg.(0)}\n`; (* addr of fn in r12 *) - ` bctrl\n`; -- record_frame i.live false i.dbg ~label:label_after; -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after; - emit_reload_toc() - end - | Lop(Icall_imm { func; label_after; }) -> - begin match abi with - | ELF32 -> - emit_call func; -- record_frame i.live false i.dbg ~label:label_after -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after - | ELF64v1 | ELF64v2 -> - (* For PPC64, we cannot just emit a "bl s; nop" sequence, because - of the following scenario: -@@ -691,7 +691,7 @@ let emit_instr i = - Cost: 3 instructions if same TOC, 7 if different TOC. - Let's try option 2. *) - emit_call func; -- record_frame i.live false i.dbg ~label:label_after; -+ record_frame i.live (Dbg_other i.dbg) ~label:label_after; - ` nop\n`; - emit_reload_toc() - end -@@ -751,11 +751,11 @@ let emit_instr i = - ` addis 25, 0, {emit_upper emit_symbol func}\n`; - ` addi 25, 25, {emit_lower emit_symbol func}\n`; - emit_call "caml_c_call"; -- record_frame i.live false i.dbg -+ record_frame i.live (Dbg_other i.dbg) - | ELF64v1 | ELF64v2 -> - emit_tocload emit_gpr 25 (TocSym func); - emit_call "caml_c_call"; -- record_frame i.live false i.dbg; -+ record_frame i.live (Dbg_other i.dbg); - ` nop\n` - end - | Lop(Istackoffset n) -> -@@ -786,15 +786,15 @@ let emit_instr i = - | Single -> "stfs" - | Double | Double_u -> "stfd" in - emit_load_store storeinstr addr i.arg 1 i.arg.(0) -- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> -+ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> - let call_gc_lbl = label_for_call_gc ?label_after_call_gc n in - ` addi 31, 31, {emit_int(-n)}\n`; - ` {emit_string cmplg} 31, 30\n`; - ` addi {emit_reg i.res.(0)}, 31, {emit_int size_addr}\n`; - ` bltl {emit_label call_gc_lbl}\n`; - (* Exactly 4 instructions after the beginning of the alloc sequence *) -- record_frame i.live false Debuginfo.none -- | Lop(Ispecific(Ialloc_far { bytes = n; label_after_call_gc; })) -> -+ record_frame i.live (Dbg_alloc dbginfo) -+ | Lop(Ispecific(Ialloc_far { bytes = n; label_after_call_gc; dbginfo })) -> - let call_gc_lbl = label_for_call_gc ?label_after_call_gc n in - let lbl = new_label() in - ` addi 31, 31, {emit_int(-n)}\n`; -@@ -802,7 +802,7 @@ let emit_instr i = - ` bge {emit_label lbl}\n`; - ` bl {emit_label call_gc_lbl}\n`; - (* Exactly 4 instructions after the beginning of the alloc sequence *) -- record_frame i.live false Debuginfo.none; -+ record_frame i.live (Dbg_alloc dbginfo); - `{emit_label lbl}: addi {emit_reg i.res.(0)}, 31, {emit_int size_addr}\n` - | Lop(Iintop Isub) -> (* subfc has swapped arguments *) - ` subfc {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -@@ -821,7 +821,7 @@ let emit_instr i = - end - | Lop(Iintop (Icheckbound { label_after_error; })) -> - if !Clflags.debug then -- record_frame Reg.Set.empty false i.dbg ?label:label_after_error; -+ record_frame Reg.Set.empty (Dbg_other i.dbg) ?label:label_after_error; - ` {emit_string tglle} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` - | Lop(Iintop op) -> - let instr = name_for_intop op in -@@ -839,7 +839,7 @@ let emit_instr i = - end - | Lop(Iintop_imm(Icheckbound { label_after_error; }, n)) -> - if !Clflags.debug then -- record_frame Reg.Set.empty false i.dbg ?label:label_after_error; -+ record_frame Reg.Set.empty (Dbg_other i.dbg) ?label:label_after_error; - ` {emit_string tglle}i {emit_reg i.arg.(0)}, {emit_int n}\n` - | Lop(Iintop_imm(op, n)) -> - let instr = name_for_intop_imm op in -@@ -1023,11 +1023,11 @@ let emit_instr i = - | _ -> ` std 0, {emit_int (backtrace_pos * 8)}(28)\n` - end; - emit_call "caml_raise_exn"; -- record_frame Reg.Set.empty true i.dbg; -+ record_frame Reg.Set.empty (Dbg_raise i.dbg); - emit_call_nop() - | Lambda.Raise_reraise -> - emit_call "caml_raise_exn"; -- record_frame Reg.Set.empty true i.dbg; -+ record_frame Reg.Set.empty (Dbg_raise i.dbg); - emit_call_nop() - | Lambda.Raise_notrace -> - ` {emit_string lg} 0, {emit_int trap_handler_offset}(29)\n`; -@@ -1249,6 +1249,7 @@ let end_assembly() = - (fun l -> ` {emit_string datag} {emit_label l}\n`); - efa_data_label = - (fun l -> ` {emit_string datag} {emit_label l}\n`); -+ efa_8 = (fun n -> ` .byte {emit_int n}\n`); - efa_16 = (fun n -> ` .short {emit_int n}\n`); - efa_32 = (fun n -> ` .long {emit_int32 n}\n`); - efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); -diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp -index 05070ec7c..ad3e09037 100644 ---- a/asmcomp/s390x/emit.mlp -+++ b/asmcomp/s390x/emit.mlp -@@ -168,7 +168,7 @@ let emit_set_comp cmp res = - - (* Record live pointers at call points *) - --let record_frame_label ?label live raise_ dbg = -+let record_frame_label ?label live dbg = - let lbl = - match label with - | None -> new_label() -@@ -186,11 +186,11 @@ let record_frame_label ?label live raise_ dbg = - | _ -> ()) - live; - record_frame_descr ~label:lbl ~frame_size:(frame_size()) -- ~live_offset:!live_offset ~raise_frame:raise_ dbg; -+ ~live_offset:!live_offset dbg; - lbl - --let record_frame ?label live raise_ dbg = -- let lbl = record_frame_label ?label live raise_ dbg in -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in - `{emit_label lbl}:` - - (* Record calls to caml_call_gc, emitted out of line. *) -@@ -218,7 +218,7 @@ let bound_error_call = ref 0 - let bound_error_label ?label dbg = - if !Clflags.debug then begin - let lbl_bound_error = new_label() in -- let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in - bound_error_sites := - { bd_lbl = lbl_bound_error; bd_frame = lbl_frame } :: !bound_error_sites; - lbl_bound_error -@@ -357,11 +357,11 @@ let emit_instr i = - emit_load_symbol_addr i.res.(0) s - | Lop(Icall_ind { label_after; }) -> - ` basr %r14, {emit_reg i.arg.(0)}\n`; -- `{record_frame i.live false i.dbg ~label:label_after}\n` -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` - - | Lop(Icall_imm { func; label_after; }) -> - emit_call func; -- `{record_frame i.live false i.dbg ~label:label_after}\n` -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` - | Lop(Itailcall_ind { label_after = _; }) -> - let n = frame_size() in - if !contains_calls then -@@ -387,7 +387,7 @@ let emit_instr i = - else begin - emit_load_symbol_addr reg_r7 func; - emit_call "caml_c_call"; -- `{record_frame i.live false i.dbg ~label:label_after}\n` -+ `{record_frame i.live (Dbg_other i.dbg) ~label:label_after}\n` - end - - | Lop(Istackoffset n) -> -@@ -424,11 +424,11 @@ let emit_instr i = - | Double | Double_u -> "stdy" in - emit_load_store storeinstr addr i.arg 1 i.arg.(0) - -- | Lop(Ialloc { bytes = n; label_after_call_gc; }) -> -+ | Lop(Ialloc { bytes = n; label_after_call_gc; dbginfo }) -> - let lbl_redo = new_label() in - let lbl_call_gc = new_label() in - let lbl_frame = -- record_frame_label i.live false i.dbg ?label:label_after_call_gc -+ record_frame_label i.live (Dbg_alloc dbginfo) ?label:label_after_call_gc - in - call_gc_sites := - { gc_lbl = lbl_call_gc; -@@ -641,10 +641,10 @@ let emit_instr i = - ` lghi %r1, 0\n`; - ` stg %r1, {emit_int offset}(%r10)\n`; - emit_call "caml_raise_exn"; -- `{record_frame Reg.Set.empty true i.dbg}\n` -+ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` - | Lambda.Raise_reraise -> - emit_call "caml_raise_exn"; -- `{record_frame Reg.Set.empty true i.dbg}\n` -+ `{record_frame Reg.Set.empty (Dbg_raise i.dbg)}\n` - | Lambda.Raise_notrace -> - ` lg %r1, 0(%r13)\n`; - ` lgr %r15, %r13\n`; -@@ -782,6 +782,7 @@ let end_assembly() = - emit_frames - { efa_code_label = (fun l -> ` .quad {emit_label l}\n`); - efa_data_label = (fun l -> ` .quad {emit_label l}\n`); -+ efa_8 = (fun n -> ` .byte {emit_int n}\n`); - efa_16 = (fun n -> ` .short {emit_int n}\n`); - efa_32 = (fun n -> ` .long {emit_int32 n}\n`); - efa_word = (fun n -> ` .quad {emit_int n}\n`); -diff --git a/lambda/debuginfo.ml b/lambda/debuginfo.ml -index 7a3390222..29c098f1e 100644 ---- a/lambda/debuginfo.ml -+++ b/lambda/debuginfo.ml -@@ -29,6 +29,11 @@ type item = { - - type t = item list - -+type alloc_dbginfo_item = -+ { alloc_words : int; -+ alloc_dbg : t } -+type alloc_dbginfo = alloc_dbginfo_item list -+ - let none = [] - - let is_none = function -diff --git a/lambda/debuginfo.mli b/lambda/debuginfo.mli -index 4dc5e5990..954a152dd 100644 ---- a/lambda/debuginfo.mli -+++ b/lambda/debuginfo.mli -@@ -25,6 +25,17 @@ type item = private { - - type t = item list - -+type alloc_dbginfo_item = -+ { alloc_words : int; -+ alloc_dbg : t } -+(** Due to Comballoc, a single Ialloc instruction may combine several -+ unrelated allocations. Their Debuginfo.t (which may differ) are stored -+ as a list of alloc_dbginfo. This list is in order of increasing memory -+ address, which is the reverse of the original allocation order. Later -+ allocations are consed to the front of this list by Comballoc. *) -+ -+type alloc_dbginfo = alloc_dbginfo_item list -+ - val none : t - - val is_none : t -> bool --- -2.24.1 - diff --git a/0008-Add-riscv64-backend.patch b/0008-Add-riscv64-backend.patch deleted file mode 100644 index 07622f1..0000000 --- a/0008-Add-riscv64-backend.patch +++ /dev/null @@ -1,2084 +0,0 @@ -From f5d7b834c50945c30cf55f284346128ab5cdeb50 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= -Date: Mon, 11 Nov 2019 23:28:15 +0100 -Subject: [PATCH 8/8] Add riscv64 backend - -(cherry picked from commit d6b3808de753266a44fc941aeb5224a6d2164ce1) ---- - Makefile | 2 +- - README.adoc | 1 + - asmcomp/riscv/CSE.ml | 39 ++ - asmcomp/riscv/arch.ml | 90 +++++ - asmcomp/riscv/emit.mlp | 693 +++++++++++++++++++++++++++++++++ - asmcomp/riscv/proc.ml | 359 +++++++++++++++++ - asmcomp/riscv/reload.ml | 19 + - asmcomp/riscv/scheduling.ml | 22 ++ - asmcomp/riscv/selection.ml | 74 ++++ - configure | 71 +--- - configure.ac | 18 +- - runtime/caml/stack.h | 5 + - runtime/riscv.S | 422 ++++++++++++++++++++ - testsuite/tools/asmgen_riscv.S | 89 +++++ - 14 files changed, 1835 insertions(+), 69 deletions(-) - create mode 100644 asmcomp/riscv/CSE.ml - create mode 100644 asmcomp/riscv/arch.ml - create mode 100644 asmcomp/riscv/emit.mlp - create mode 100644 asmcomp/riscv/proc.ml - create mode 100644 asmcomp/riscv/reload.ml - create mode 100644 asmcomp/riscv/scheduling.ml - create mode 100644 asmcomp/riscv/selection.ml - create mode 100644 runtime/riscv.S - create mode 100644 testsuite/tools/asmgen_riscv.S - -diff --git a/Makefile b/Makefile -index 802196d1e..c862a48b1 100644 ---- a/Makefile -+++ b/Makefile -@@ -38,7 +38,7 @@ include stdlib/StdlibModules - - CAMLC=$(BOOT_OCAMLC) -g -nostdlib -I boot -use-prims runtime/primitives - CAMLOPT=$(CAMLRUN) ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink --ARCHES=amd64 i386 arm arm64 power s390x -+ARCHES=amd64 i386 arm arm64 power s390x riscv - INCLUDES=-I utils -I parsing -I typing -I bytecomp -I file_formats \ - -I lambda -I middle_end -I middle_end/closure \ - -I middle_end/flambda -I middle_end/flambda/base_types \ -diff --git a/README.adoc b/README.adoc -index 504c7a708..4dc404da3 100644 ---- a/README.adoc -+++ b/README.adoc -@@ -54,6 +54,7 @@ compiler currently runs on the following platforms: - | ARM 32 bits | Linux | FreeBSD, NetBSD, OpenBSD - | Power 64 bits | Linux | - | Power 32 bits | | Linux -+| RISC-V 64 bits | Linux | - | IBM Z (s390x) | Linux | - |==== - -diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml -new file mode 100644 -index 000000000..6aed1c07f ---- /dev/null -+++ b/asmcomp/riscv/CSE.ml -@@ -0,0 +1,39 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* CSE for the RISC-V *) -+ -+open Arch -+open Mach -+open CSEgen -+ -+class cse = object (_self) -+ -+inherit cse_generic as super -+ -+method! class_of_operation op = -+ match op with -+ | Ispecific(Imultaddf _ | Imultsubf _) -> Op_pure -+ | _ -> super#class_of_operation op -+ -+method! is_cheap_operation op = -+ match op with -+ | Iconst_int n -> n <= 0x7FFn && n >= -0x800n -+ | _ -> false -+ -+end -+ -+let fundecl f = -+ (new cse)#fundecl f -diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml -new file mode 100644 -index 000000000..4d95a6f5e ---- /dev/null -+++ b/asmcomp/riscv/arch.ml -@@ -0,0 +1,90 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Specific operations for the RISC-V processor *) -+ -+open Format -+ -+(* Machine-specific command-line options *) -+ -+let command_line_options = [] -+ -+(* Specific operations *) -+ -+type specific_operation = -+ | Imultaddf of bool (* multiply, optionally negate, and add *) -+ | Imultsubf of bool (* multiply, optionally negate, and subtract *) -+ -+let spacetime_node_hole_pointer_is_live_before = function -+ | Imultaddf _ | Imultsubf _ -> false -+ -+(* Addressing modes *) -+ -+type addressing_mode = -+ | Iindexed of int (* reg + displ *) -+ -+let is_immediate n = -+ (n <= 2047) && (n >= -2048) -+ -+(* Sizes, endianness *) -+ -+let big_endian = false -+ -+let rv64 = -+ match Config.model with "riscv64" -> true | "riscv32" -> false | _ -> assert false -+ -+let size_addr = if rv64 then 8 else 4 -+let size_int = size_addr -+let size_float = 8 -+ -+let allow_unaligned_access = false -+ -+(* Behavior of division *) -+ -+let division_crashes_on_overflow = false -+ -+(* Operations on addressing modes *) -+ -+let identity_addressing = Iindexed 0 -+ -+let offset_addressing addr delta = -+ match addr with -+ | Iindexed n -> Iindexed(n + delta) -+ -+let num_args_addressing = function -+ | Iindexed _ -> 1 -+ -+(* Printing operations and addressing modes *) -+ -+let print_addressing printreg addr ppf arg = -+ match addr with -+ | Iindexed n -> -+ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in -+ fprintf ppf "%a%s" printreg arg.(0) idx -+ -+let print_specific_operation printreg op ppf arg = -+ match op with -+ | Imultaddf false -> -+ fprintf ppf "%a *f %a +f %a" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultaddf true -> -+ fprintf ppf "-f (%a *f %a +f %a)" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultsubf false -> -+ fprintf ppf "%a *f %a -f %a" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultsubf true -> -+ fprintf ppf "-f (%a *f %a -f %a)" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp -new file mode 100644 -index 000000000..03af45de4 ---- /dev/null -+++ b/asmcomp/riscv/emit.mlp -@@ -0,0 +1,693 @@ -+# 2 "asmcomp/riscv/emit.mlp" -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Emission of RISC-V assembly code *) -+ -+open Cmm -+open Arch -+open Proc -+open Reg -+open Mach -+open Linear -+open Emitaux -+ -+(* Layout of the stack. The stack is kept 16-aligned. *) -+ -+let stack_offset = ref 0 -+ -+let num_stack_slots = Array.make Proc.num_register_classes 0 -+ -+let prologue_required = ref false -+ -+let contains_calls = ref false -+ -+let frame_size () = -+ let size = -+ !stack_offset + (* Trap frame, outgoing parameters *) -+ size_int * num_stack_slots.(0) + (* Local int variables *) -+ size_float * num_stack_slots.(1) + (* Local float variables *) -+ (if !contains_calls then size_addr else 0) in (* The return address *) -+ Misc.align size 16 -+ -+let slot_offset loc cls = -+ match loc with -+ | Local n -> -+ if cls = 0 -+ then !stack_offset + num_stack_slots.(1) * size_float + n * size_int -+ else !stack_offset + n * size_float -+ | Incoming n -> frame_size() + n -+ | Outgoing n -> n -+ -+(* Output a symbol *) -+ -+let emit_symbol s = -+ emit_symbol '.' s -+ -+let emit_jump op s = -+ if !Clflags.dlcode || !Clflags.pic_code -+ then `{emit_string op} {emit_symbol s}@plt` -+ else `{emit_string op} {emit_symbol s}` -+ -+let emit_call = emit_jump "call" -+let emit_tail = emit_jump "tail" -+ -+(* Output a label *) -+ -+let emit_label lbl = -+ emit_string ".L"; emit_int lbl -+ -+(* Section switching *) -+ -+let data_space = -+ ".section .data" -+ -+let code_space = -+ ".section .text" -+ -+let rodata_space = -+ ".section .rodata" -+ -+(* Names for special regs *) -+ -+let reg_tmp1 = phys_reg 21 -+let reg_tmp2 = phys_reg 22 -+let reg_t2 = phys_reg 16 -+let reg_domain_state_ptr = phys_reg 23 -+let reg_trap = phys_reg 24 -+let reg_alloc_ptr = phys_reg 25 -+let reg_alloc_lim = phys_reg 26 -+ -+(* Output a pseudo-register *) -+ -+let reg_name = function -+ | {loc = Reg r} -> register_name r -+ | _ -> Misc.fatal_error "Emit.reg_name" -+ -+let emit_reg r = -+ emit_string (reg_name r) -+ -+(* Adjust sp by the given byte amount *) -+ -+let emit_stack_adjustment = function -+ | 0 -> () -+ | n when is_immediate n -> -+ ` addi sp, sp, {emit_int n}\n` -+ | n -> -+ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; -+ ` add sp, sp, {emit_reg reg_tmp1}\n` -+ -+let emit_mem_op op src ofs = -+ if is_immediate ofs then -+ ` {emit_string op} {emit_string src}, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; -+ ` {emit_string op} {emit_string src}, 0({emit_reg reg_tmp1})\n` -+ end -+ -+let emit_store src ofs = -+ emit_mem_op (if rv64 then "sd" else "sw") src ofs -+ -+let emit_load dst ofs = -+ emit_mem_op (if rv64 then "ld" else "lw") dst ofs -+ -+let reload_ra n = -+ emit_load "ra" (n - size_addr) -+ -+let store_ra n = -+ emit_store "ra" (n - size_addr) -+ -+let emit_store src ofs = -+ emit_store (reg_name src) ofs -+ -+let emit_load dst ofs = -+ emit_load (reg_name dst) ofs -+ -+let emit_float_load dst ofs = -+ emit_mem_op "fld" (reg_name dst) ofs -+ -+let emit_float_store src ofs = -+ emit_mem_op "fsd" (reg_name src) ofs -+ -+(* Record live pointers at call points *) -+ -+let record_frame_label ?label live dbg = -+ let lbl = -+ match label with -+ | None -> new_label() -+ | Some label -> label -+ in -+ let live_offset = ref [] in -+ Reg.Set.iter -+ (function -+ {typ = Val; loc = Reg r} -> -+ live_offset := (r lsl 1) + 1 :: !live_offset -+ | {typ = Val; loc = Stack s} as reg -> -+ live_offset := slot_offset s (register_class reg) :: !live_offset -+ | {typ = Addr} as r -> -+ Misc.fatal_error ("bad GC root " ^ Reg.name r) -+ | _ -> () -+ ) -+ live; -+ record_frame_descr ~label:lbl ~frame_size:(frame_size()) -+ ~live_offset:!live_offset dbg; -+ lbl -+ -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in -+ `{emit_label lbl}:\n` -+ -+(* Record calls to the GC -- we've moved them out of the way *) -+ -+type gc_call = -+ { gc_lbl: label; (* Entry label *) -+ gc_return_lbl: label; (* Where to branch after GC *) -+ gc_frame_lbl: label } (* Label of frame descriptor *) -+ -+let call_gc_sites = ref ([] : gc_call list) -+ -+let emit_call_gc gc = -+ `{emit_label gc.gc_lbl}:\n`; -+ ` {emit_call "caml_call_gc"}\n`; -+ `{emit_label gc.gc_frame_lbl}:\n`; -+ ` j {emit_label gc.gc_return_lbl}\n` -+ -+(* Record calls to caml_ml_array_bound_error. -+ In debug mode, we maintain one call to caml_ml_array_bound_error -+ per bound check site. Otherwise, we can share a single call. *) -+ -+type bound_error_call = -+ { bd_lbl: label; (* Entry label *) -+ bd_frame_lbl: label } (* Label of frame descriptor *) -+ -+let bound_error_sites = ref ([] : bound_error_call list) -+ -+let bound_error_label ?label dbg = -+ if !Clflags.debug || !bound_error_sites = [] then begin -+ let lbl_bound_error = new_label() in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in -+ bound_error_sites := -+ { bd_lbl = lbl_bound_error; -+ bd_frame_lbl = lbl_frame } :: !bound_error_sites; -+ lbl_bound_error -+ end else -+ let bd = List.hd !bound_error_sites in -+ bd.bd_lbl -+ -+let emit_call_bound_error bd = -+ `{emit_label bd.bd_lbl}:\n`; -+ ` {emit_call "caml_ml_array_bound_error"}\n`; -+ `{emit_label bd.bd_frame_lbl}:\n` -+ -+(* Record floating-point literals *) -+ -+let float_literals = ref ([] : (int64 * int) list) -+ -+(* Names for various instructions *) -+ -+let name_for_intop = function -+ | Iadd -> "add" -+ | Isub -> "sub" -+ | Imul -> "mul" -+ | Imulh -> "mulh" -+ | Idiv -> "div" -+ | Iand -> "and" -+ | Ior -> "or" -+ | Ixor -> "xor" -+ | Ilsl -> "sll" -+ | Ilsr -> "srl" -+ | Iasr -> "sra" -+ | Imod -> "rem" -+ | _ -> Misc.fatal_error "Emit.Intop" -+ -+let name_for_intop_imm = function -+ | Iadd -> "addi" -+ | Iand -> "andi" -+ | Ior -> "ori" -+ | Ixor -> "xori" -+ | Ilsl -> "slli" -+ | Ilsr -> "srli" -+ | Iasr -> "srai" -+ | _ -> Misc.fatal_error "Emit.Intop_imm" -+ -+let name_for_floatop1 = function -+ | Inegf -> "fneg.d" -+ | Iabsf -> "fabs.d" -+ | _ -> Misc.fatal_error "Emit.Iopf1" -+ -+let name_for_floatop2 = function -+ | Iaddf -> "fadd.d" -+ | Isubf -> "fsub.d" -+ | Imulf -> "fmul.d" -+ | Idivf -> "fdiv.d" -+ | _ -> Misc.fatal_error "Emit.Iopf2" -+ -+let name_for_specific = function -+ | Imultaddf false -> "fmadd.d" -+ | Imultaddf true -> "fnmadd.d" -+ | Imultsubf false -> "fmsub.d" -+ | Imultsubf true -> "fnmsub.d" -+ -+(* Name of current function *) -+let function_name = ref "" -+ -+(* Entry point for tail recursive calls *) -+let tailrec_entry_point = ref 0 -+ -+(* Output the assembly code for an instruction *) -+ -+let emit_instr i = -+ emit_debug_info i.dbg; -+ match i.desc with -+ Lend -> () -+ | Lprologue -> -+ assert (!prologue_required); -+ let n = frame_size() in -+ emit_stack_adjustment (-n); -+ if !contains_calls then store_ra n -+ | Lop(Imove | Ispill | Ireload) -> -+ let src = i.arg.(0) and dst = i.res.(0) in -+ if src.loc <> dst.loc then begin -+ match (src, dst) with -+ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> -+ ` mv {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> -+ ` fmv.d {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> -+ let ofs = slot_offset s (register_class dst) in -+ emit_store src ofs -+ | {loc = Reg _; typ = Float}, {loc = Stack s} -> -+ let ofs = slot_offset s (register_class dst) in -+ emit_float_store src ofs -+ | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> -+ let ofs = slot_offset s (register_class src) in -+ emit_load dst ofs -+ | {loc = Stack s; typ = Float}, {loc = Reg _} -> -+ let ofs = slot_offset s (register_class src) in -+ emit_float_load dst ofs -+ | _ -> -+ Misc.fatal_error "Emit: Imove" -+ end -+ | Lop(Iconst_int n) -> -+ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` -+ | Lop(Iconst_float f) -> -+ let lbl = new_label() in -+ float_literals := (f, lbl) :: !float_literals; -+ ` fld {emit_reg i.res.(0)}, {emit_label lbl}, {emit_reg reg_tmp1}\n` -+ | Lop(Iconst_symbol s) -> -+ ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` -+ | Lop(Icall_ind {label_after = label}) -> -+ ` jalr {emit_reg i.arg.(0)}\n`; -+ record_frame ~label i.live (Dbg_other i.dbg) -+ | Lop(Icall_imm {func; label_after = label}) -> -+ ` {emit_call func}\n`; -+ record_frame ~label i.live (Dbg_other i.dbg) -+ | Lop(Itailcall_ind {label_after = _}) -> -+ let n = frame_size() in -+ if !contains_calls then reload_ra n; -+ emit_stack_adjustment n; -+ ` jr {emit_reg i.arg.(0)}\n` -+ | Lop(Itailcall_imm {func; label_after = _}) -> -+ if func = !function_name then begin -+ ` j {emit_label !tailrec_entry_point}\n` -+ end else begin -+ let n = frame_size() in -+ if !contains_calls then reload_ra n; -+ emit_stack_adjustment n; -+ ` {emit_tail func}\n` -+ end -+ | Lop(Iextcall{func; alloc = true; label_after = label}) -> -+ ` la {emit_reg reg_t2}, {emit_symbol func}\n`; -+ ` {emit_call "caml_c_call"}\n`; -+ record_frame ~label i.live (Dbg_other i.dbg) -+ | Lop(Iextcall{func; alloc = false; label_after = _}) -> -+ ` {emit_call func}\n` -+ | Lop(Istackoffset n) -> -+ assert (n mod 16 = 0); -+ emit_stack_adjustment (-n); -+ stack_offset := !stack_offset + n -+ | Lop(Iload(Single, Iindexed ofs)) -> -+ ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; -+ ` fcvt.d.s {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Lop(Iload(chunk, Iindexed ofs)) -> -+ let instr = -+ match chunk with -+ | Byte_unsigned -> "lbu" -+ | Byte_signed -> "lb" -+ | Sixteen_unsigned -> "lhu" -+ | Sixteen_signed -> "lh" -+ | Thirtytwo_unsigned -> if rv64 then "lwu" else "lw" -+ | Thirtytwo_signed -> "lw" -+ | Word_int | Word_val -> if rv64 then "ld" else "lw" -+ | Single -> assert false -+ | Double | Double_u -> "fld" -+ in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n` -+ | Lop(Istore(Single, Iindexed ofs, _)) -> -+ ` fmv.x.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}\n`; -+ ` fcvt.s.d {emit_reg i.arg.(0)}, {emit_reg i.arg.(0)}\n`; -+ ` fsw {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n`; -+ ` fmv.d.x {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}\n` -+ | Lop(Istore(chunk, Iindexed ofs, _)) -> -+ let instr = -+ match chunk with -+ | Byte_unsigned | Byte_signed -> "sb" -+ | Sixteen_unsigned | Sixteen_signed -> "sh" -+ | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" -+ | Word_int | Word_val -> if rv64 then "sd" else "sw" -+ | Single -> assert false -+ | Double | Double_u -> "fsd" -+ in -+ ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` -+ | Lop(Ialloc {bytes; label_after_call_gc = label; dbginfo}) -> -+ let lbl_frame_lbl = record_frame_label ?label i.live (Dbg_alloc dbginfo) in -+ let lbl_after_alloc = new_label () in -+ let lbl_call_gc = new_label () in -+ let n = -bytes in -+ if is_immediate n then -+ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_int n}\n` -+ else begin -+ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; -+ ` add {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_reg reg_tmp1}\n` -+ end; -+ ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; -+ `{emit_label lbl_after_alloc}:\n`; -+ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; -+ call_gc_sites := -+ { gc_lbl = lbl_call_gc; -+ gc_return_lbl = lbl_after_alloc; -+ gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites -+ | Lop(Iintop(Icomp cmp)) -> -+ begin match cmp with -+ | Isigned Clt -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Isigned Cge -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Isigned Cgt -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | Isigned Cle -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Isigned Ceq | Iunsigned Ceq -> -+ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` seqz {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Isigned Cne | Iunsigned Cne -> -+ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` snez {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Iunsigned Clt -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Iunsigned Cge -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Iunsigned Cgt -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | Iunsigned Cle -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ end -+ | Lop(Iintop (Icheckbound {label_after_error = label; _})) -> -+ let lbl = bound_error_label ?label i.dbg in -+ ` bleu {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` -+ | Lop(Iintop op) -> -+ let instr = name_for_intop op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Lop(Iintop_imm(Isub, n)) -> -+ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` -+ | Lop(Iintop_imm(Icomp _, _)) -> -+ Misc.fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" -+ | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> -+ let lbl = bound_error_label ?label i.dbg in -+ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; -+ ` bleu {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ | Lop(Iintop_imm(op, n)) -> -+ let instr = name_for_intop_imm op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` -+ | Lop(Inegf | Iabsf as op) -> -+ let instr = name_for_floatop1 op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> -+ let instr = name_for_floatop2 op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Lop(Ifloatofint) -> -+ let name = if rv64 then "fcvt.d.l" else "fcvt.d.w" in -+ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Iintoffloat) -> -+ let name = if rv64 then "fcvt.l.d" else "fcvt.w.d" in -+ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, rtz\n` -+ | Lop(Ispecific sop) -> -+ let instr = name_for_specific sop in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` -+ | Lop (Iname_for_debugger _) -> -+ () -+ | Lreloadretaddr -> -+ let n = frame_size () in -+ reload_ra n -+ | Lreturn -> -+ let n = frame_size() in -+ emit_stack_adjustment n; -+ ` ret\n` -+ | Llabel lbl -> -+ `{emit_label lbl}:\n` -+ | Lbranch lbl -> -+ ` j {emit_label lbl}\n` -+ | Lcondbranch(tst, lbl) -> -+ begin match tst with -+ | Itruetest -> -+ ` bnez {emit_reg i.arg.(0)}, {emit_label lbl}\n` -+ | Ifalsetest -> -+ ` beqz {emit_reg i.arg.(0)}, {emit_label lbl}\n` -+ | Iinttest cmp -> -+ let name = match cmp with -+ | Iunsigned Ceq | Isigned Ceq -> "beq" -+ | Iunsigned Cne | Isigned Cne -> "bne" -+ | Iunsigned Cle -> "bleu" | Isigned Cle -> "ble" -+ | Iunsigned Cge -> "bgeu" | Isigned Cge -> "bge" -+ | Iunsigned Clt -> "bltu" | Isigned Clt -> "blt" -+ | Iunsigned Cgt -> "bgtu" | Isigned Cgt -> "bgt" -+ in -+ ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` -+ | Iinttest_imm _ -> -+ Misc.fatal_error "Emit.emit_instr (Iinttest_imm _)" -+ | Ifloattest cmp -> -+ let branch = -+ match cmp with -+ | CFneq | CFnlt | CFngt | CFnle | CFnge -> "beqz" -+ | CFeq | CFlt | CFgt | CFle | CFge -> "bnez" -+ in -+ begin match cmp with -+ | CFeq | CFneq -> ` feq.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFlt | CFnlt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFgt | CFngt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | CFle | CFnle -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFge | CFnge -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ end; -+ ` {emit_string branch} {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ | Ioddtest -> -+ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; -+ ` bnez {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ | Ieventest -> -+ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; -+ ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end -+ | Lcondbranch3(lbl0, lbl1, lbl2) -> -+ ` addi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, -1\n`; -+ begin match lbl0 with -+ | None -> () -+ | Some lbl -> ` bltz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end; -+ begin match lbl1 with -+ | None -> () -+ | Some lbl -> ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end; -+ begin match lbl2 with -+ | None -> () -+ | Some lbl -> ` bgtz {emit_reg reg_tmp1}, {emit_label lbl}\n` -+ end -+ | Lswitch jumptbl -> -+ let lbl = new_label() in -+ ` la {emit_reg reg_tmp1}, {emit_label lbl}\n`; -+ ` slli {emit_reg reg_tmp2}, {emit_reg i.arg.(0)}, 2\n`; -+ ` add {emit_reg reg_tmp1}, {emit_reg reg_tmp1}, {emit_reg reg_tmp2}\n`; -+ ` jr {emit_reg reg_tmp1}\n`; -+ `{emit_label lbl}:\n`; -+ for i = 0 to Array.length jumptbl - 1 do -+ ` j {emit_label jumptbl.(i)}\n` -+ done -+ | Lentertrap -> -+ () -+ | Ladjust_trap_depth { delta_traps } -> -+ (* each trap occupes 16 bytes on the stack *) -+ let delta = 16 * delta_traps in -+ stack_offset := !stack_offset + delta -+ | Lpushtrap {lbl_handler} -> -+ ` la {emit_reg reg_tmp1}, {emit_label lbl_handler}\n`; -+ ` addi sp, sp, -16\n`; -+ stack_offset := !stack_offset + 16; -+ emit_store reg_tmp1 size_addr; -+ emit_store reg_trap 0; -+ ` mv {emit_reg reg_trap}, sp\n` -+ | Lpoptrap -> -+ emit_load reg_trap 0; -+ ` addi sp, sp, 16\n`; -+ stack_offset := !stack_offset - 16 -+ | Lraise k -> -+ begin match k with -+ | Lambda.Raise_regular -> -+ let offset = Domainstate.(idx_of_field Domain_backtrace_pos) * 8 in -+ ` sd zero, {emit_int offset}({emit_reg reg_domain_state_ptr})\n`; -+ ` {emit_call "caml_raise_exn"}\n`; -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) -+ | Lambda.Raise_reraise -> -+ ` {emit_call "caml_raise_exn"}\n`; -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) -+ | Lambda.Raise_notrace -> -+ ` mv sp, {emit_reg reg_trap}\n`; -+ emit_load reg_tmp1 size_addr; -+ emit_load reg_trap 0; -+ ` addi sp, sp, 16\n`; -+ ` jalr {emit_reg reg_tmp1}\n` -+ end -+ -+(* Emit a sequence of instructions *) -+ -+let rec emit_all = function -+ | {desc = Lend} -> () | i -> emit_instr i; emit_all i.next -+ -+(* Emission of a function declaration *) -+ -+let fundecl fundecl = -+ function_name := fundecl.fun_name; -+ tailrec_entry_point := fundecl.fun_tailrec_entry_point_label; -+ stack_offset := 0; -+ call_gc_sites := []; -+ bound_error_sites := []; -+ for i = 0 to Proc.num_register_classes - 1 do -+ num_stack_slots.(i) <- fundecl.fun_num_stack_slots.(i); -+ done; -+ prologue_required := fundecl.fun_prologue_required; -+ contains_calls := fundecl.fun_contains_calls; -+ float_literals := []; -+ ` .globl {emit_symbol fundecl.fun_name}\n`; -+ ` .type {emit_symbol fundecl.fun_name}, @function\n`; -+ ` {emit_string code_space}\n`; -+ ` .align 2\n`; -+ `{emit_symbol fundecl.fun_name}:\n`; -+ emit_debug_info fundecl.fun_dbg; -+ emit_all fundecl.fun_body; -+ List.iter emit_call_gc !call_gc_sites; -+ List.iter emit_call_bound_error !bound_error_sites; -+ ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; -+ (* Emit the float literals *) -+ if !float_literals <> [] then begin -+ ` {emit_string rodata_space}\n`; -+ ` .align 3\n`; -+ List.iter -+ (fun (f, lbl) -> -+ `{emit_label lbl}:\n`; -+ if rv64 -+ then emit_float64_directive ".quad" f -+ else emit_float64_split_directive ".long" f) -+ !float_literals; -+ end -+ -+(* Emission of data *) -+ -+let datag = -+ if rv64 then ".quad" else ".long" -+ -+let declare_global_data s = -+ ` .globl {emit_symbol s}\n`; -+ ` .type {emit_symbol s}, @object\n` -+ -+let emit_item = function -+ | Cglobal_symbol s -> -+ declare_global_data s -+ | Cdefine_symbol s -> -+ `{emit_symbol s}:\n`; -+ | Cint8 n -> -+ ` .byte {emit_int n}\n` -+ | Cint16 n -> -+ ` .short {emit_int n}\n` -+ | Cint32 n -> -+ ` .long {emit_nativeint n}\n` -+ | Cint n -> -+ ` {emit_string datag} {emit_nativeint n}\n` -+ | Csingle f -> -+ emit_float32_directive ".long" (Int32.bits_of_float f) -+ | Cdouble f -> -+ if rv64 -+ then emit_float64_directive ".quad" (Int64.bits_of_float f) -+ else emit_float64_split_directive ".long" (Int64.bits_of_float f) -+ | Csymbol_address s -> -+ ` {emit_string datag} {emit_symbol s}\n` -+ | Cstring s -> -+ emit_bytes_directive " .byte " s -+ | Cskip n -> -+ if n > 0 then ` .space {emit_int n}\n` -+ | Calign n -> -+ ` .align {emit_int (Misc.log2 n)}\n` -+ -+let data l = -+ ` {emit_string data_space}\n`; -+ List.iter emit_item l -+ -+(* Beginning / end of an assembly file *) -+ -+let begin_assembly() = -+ if !Clflags.dlcode || !Clflags.pic_code then ` .option pic\n`; -+ ` .file \"\"\n`; (* PR#7073 *) -+ reset_debug_info (); -+ (* Emit the beginning of the segments *) -+ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in -+ ` {emit_string data_space}\n`; -+ declare_global_data lbl_begin; -+ `{emit_symbol lbl_begin}:\n`; -+ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in -+ ` {emit_string code_space}\n`; -+ declare_global_data lbl_begin; -+ `{emit_symbol lbl_begin}:\n` -+ -+let end_assembly() = -+ ` {emit_string code_space}\n`; -+ let lbl_end = Compilenv.make_symbol (Some "code_end") in -+ declare_global_data lbl_end; -+ `{emit_symbol lbl_end}:\n`; -+ ` .long 0\n`; -+ ` {emit_string data_space}\n`; -+ let lbl_end = Compilenv.make_symbol (Some "data_end") in -+ declare_global_data lbl_end; -+ ` {emit_string datag} 0\n`; (* PR#6329 *) -+ `{emit_symbol lbl_end}:\n`; -+ ` {emit_string datag} 0\n`; -+ (* Emit the frame descriptors *) -+ ` {emit_string rodata_space}\n`; -+ let lbl = Compilenv.make_symbol (Some "frametable") in -+ declare_global_data lbl; -+ `{emit_symbol lbl}:\n`; -+ emit_frames -+ { efa_code_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); -+ efa_data_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); -+ efa_8 = (fun n -> ` .byte {emit_int n}\n`); -+ efa_16 = (fun n -> ` .short {emit_int n}\n`); -+ efa_32 = (fun n -> ` .long {emit_int32 n}\n`); -+ efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); -+ efa_align = (fun n -> ` .align {emit_int (Misc.log2 n)}\n`); -+ efa_label_rel = (fun lbl ofs -> -+ ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); -+ efa_def_label = (fun l -> `{emit_label l}:\n`); -+ efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) -+ } -diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml -new file mode 100644 -index 000000000..3342952b3 ---- /dev/null -+++ b/asmcomp/riscv/proc.ml -@@ -0,0 +1,359 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Description of the RISC-V *) -+ -+open Misc -+open Cmm -+open Reg -+open Arch -+open Mach -+ -+(* Instruction selection *) -+ -+let word_addressed = false -+ -+(* Registers available for register allocation *) -+ -+(* Integer register map -+ -------------------- -+ -+ zero always zero -+ ra return address -+ sp, gp, tp stack pointer, global pointer, thread pointer -+ a0-a7 0-7 arguments/results -+ s2-s9 8-15 arguments/results (preserved by C) -+ t2-t6 16-20 temporary -+ t0-t1 21-22 temporary (used by code generator) -+ s0 23 domain pointer (preserved by C) -+ s1 24 trap pointer (preserved by C) -+ s10 25 allocation pointer (preserved by C) -+ s11 26 allocation limit (preserved by C) -+ -+ Floating-point register map -+ --------------------------- -+ -+ ft0-ft7 100-107 temporary -+ fs0-fs1 108-109 general purpose (preserved by C) -+ fa0-fa7 110-117 arguments/results -+ fs2-fs9 118-125 arguments/results (preserved by C) -+ fs10-fs11 126-127 general purpose (preserved by C) -+ ft8-ft11 128-131 temporary -+ -+ Additional notes -+ ---------------- -+ -+ - t0-t1 are used by the assembler and code generator, so -+ not available for register allocation. -+ -+ - t0-t6 may be used by PLT stubs, so should not be used to pass -+ arguments and may be clobbered by [Ialloc] in the presence of dynamic -+ linking. -+*) -+ -+let int_reg_name = -+ [| "a0"; "a1"; "a2"; "a3"; "a4"; "a5"; "a6"; "a7"; -+ "s2"; "s3"; "s4"; "s5"; "s6"; "s7"; "s8"; "s9"; -+ "t2"; "t3"; "t4"; "t5"; "t6"; -+ "t0"; "t1"; -+ "s0"; "s1"; "s10"; "s11" |] -+ -+let float_reg_name = -+ [| "ft0"; "ft1"; "ft2"; "ft3"; "ft4"; "ft5"; "ft6"; "ft7"; -+ "fs0"; "fs1"; -+ "fa0"; "fa1"; "fa2"; "fa3"; "fa4"; "fa5"; "fa6"; "fa7"; -+ "fs2"; "fs3"; "fs4"; "fs5"; "fs6"; "fs7"; "fs8"; "fs9"; "fs10"; "fs11"; -+ "ft8"; "ft9"; "ft10"; "ft11" |] -+ -+let num_register_classes = 2 -+ -+let register_class r = -+ match r.typ with -+ | Val | Int | Addr -> 0 -+ | Float -> 1 -+ -+let num_available_registers = [| 21; 32 |] -+ -+let first_available_register = [| 0; 100 |] -+ -+let register_name r = -+ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) -+ -+let rotate_registers = true -+ -+(* Representation of hard registers by pseudo-registers *) -+ -+let hard_int_reg = -+ let v = Array.make 27 Reg.dummy in -+ for i = 0 to 26 do -+ v.(i) <- Reg.at_location Int (Reg i) -+ done; -+ v -+ -+let hard_float_reg = -+ let v = Array.make 32 Reg.dummy in -+ for i = 0 to 31 do -+ v.(i) <- Reg.at_location Float (Reg(100 + i)) -+ done; -+ v -+ -+let all_phys_regs = -+ Array.append hard_int_reg hard_float_reg -+ -+let phys_reg n = -+ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) -+ -+let stack_slot slot ty = -+ Reg.at_location ty (Stack slot) -+ -+(* Calling conventions *) -+ -+let calling_conventions -+ first_int last_int first_float last_float make_stack arg = -+ let loc = Array.make (Array.length arg) Reg.dummy in -+ let int = ref first_int in -+ let float = ref first_float in -+ let ofs = ref 0 in -+ for i = 0 to Array.length arg - 1 do -+ match arg.(i).typ with -+ | Val | Int | Addr as ty -> -+ if !int <= last_int then begin -+ loc.(i) <- phys_reg !int; -+ incr int -+ end else begin -+ loc.(i) <- stack_slot (make_stack !ofs) ty; -+ ofs := !ofs + size_int -+ end -+ | Float -> -+ if !float <= last_float then begin -+ loc.(i) <- phys_reg !float; -+ incr float -+ end else begin -+ loc.(i) <- stack_slot (make_stack !ofs) Float; -+ ofs := !ofs + size_float -+ end -+ done; -+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) -+ -+let incoming ofs = Incoming ofs -+let outgoing ofs = Outgoing ofs -+let not_supported _ = fatal_error "Proc.loc_results: cannot call" -+ -+let max_arguments_for_tailcalls = 16 -+ -+let loc_spacetime_node_hole = Reg.dummy (* Spacetime unsupported *) -+ -+(* OCaml calling convention: -+ first integer args in a0 .. a7, s2 .. s9 -+ first float args in fa0 .. fa7, fs2 .. fs9 -+ remaining args on stack. -+ Return values in a0 .. a7, s2 .. s9 or fa0 .. fa7, fs2 .. fs9. *) -+ -+let single_regs arg = Array.map (fun arg -> [| arg |]) arg -+let ensure_single_regs res = -+ Array.map (function -+ | [| res |] -> res -+ | _ -> failwith "proc.ensure_single_regs" -+ ) res -+ -+let loc_arguments arg = -+ calling_conventions 0 15 110 125 outgoing arg -+ -+let loc_parameters arg = -+ let (loc, _ofs) = -+ calling_conventions 0 15 110 125 incoming arg -+ in -+ loc -+ -+let loc_results res = -+ let (loc, _ofs) = -+ calling_conventions 0 15 110 125 not_supported res -+ in -+ loc -+ -+(* C calling convention: -+ first integer args in a0 .. a7 -+ first float args in fa0 .. fa7 -+ remaining args on stack. -+ Return values in a0 .. a1 or fa0 .. fa1. *) -+ -+let external_calling_conventions -+ first_int last_int first_float last_float make_stack arg = -+ let loc = Array.make (Array.length arg) [| Reg.dummy |] in -+ let int = ref first_int in -+ let float = ref first_float in -+ let ofs = ref 0 in -+ for i = 0 to Array.length arg - 1 do -+ match arg.(i) with -+ | [| arg |] -> -+ begin match arg.typ with -+ | Val | Int | Addr as ty -> -+ if !int <= last_int then begin -+ loc.(i) <- [| phys_reg !int |]; -+ incr int; -+ incr float; -+ end else begin -+ loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; -+ ofs := !ofs + size_int -+ end -+ | Float -> -+ if !float <= last_float then begin -+ loc.(i) <- [| phys_reg !float |]; -+ incr float; -+ incr int; -+ end else begin -+ loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; -+ ofs := !ofs + size_float -+ end -+ end -+ | [| arg1; arg2 |] -> -+ (* Passing of 64-bit quantities to external functions on 32-bit -+ platform. *) -+ assert (size_int = 4); -+ begin match arg1.typ, arg2.typ with -+ | Int, Int -> -+ int := Misc.align !int 2; -+ if !int <= last_int - 1 then begin -+ let reg_lower = phys_reg !int in -+ let reg_upper = phys_reg (!int + 1) in -+ loc.(i) <- [| reg_lower; reg_upper |]; -+ int := !int + 2 -+ end else begin -+ let size_int64 = 8 in -+ ofs := Misc.align !ofs size_int64; -+ let ofs_lower = !ofs in -+ let ofs_upper = !ofs + size_int in -+ let stack_lower = stack_slot (make_stack ofs_lower) Int in -+ let stack_upper = stack_slot (make_stack ofs_upper) Int in -+ loc.(i) <- [| stack_lower; stack_upper |]; -+ ofs := !ofs + size_int64 -+ end -+ | _ -> -+ let f = function Int -> "I" | Addr -> "A" | Val -> "V" | Float -> "F" in -+ fatal_error (Printf.sprintf "Proc.calling_conventions: bad register \ -+ type(s) for multi-register argument: %s, %s" -+ (f arg1.typ) (f arg2.typ)) -+ end -+ | _ -> -+ fatal_error "Proc.calling_conventions: bad number of register for \ -+ multi-register argument" -+ done; -+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) -+ -+let loc_external_arguments arg = -+ external_calling_conventions 0 7 110 117 outgoing arg -+ -+let loc_external_results res = -+ let (loc, _ofs) = -+ external_calling_conventions 0 1 110 111 not_supported (single_regs res) -+ in -+ ensure_single_regs loc -+ -+(* Exceptions are in a0 *) -+ -+let loc_exn_bucket = phys_reg 0 -+ -+(* Volatile registers: none *) -+ -+let regs_are_volatile _ = false -+ -+(* Registers destroyed by operations *) -+ -+let destroyed_at_c_call = -+ (* s0-s11 and fs0-fs11 are callee-save *) -+ Array.of_list(List.map phys_reg -+ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; -+ 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; -+ 117; 128; 129; 130; 131]) -+ -+let destroyed_at_alloc = -+ (* t0-t3 are used for PLT stubs *) -+ if !Clflags.dlcode then Array.map phys_reg [|16; 17; 18; 19; 20|] else [| |] -+ -+let destroyed_at_oper = function -+ | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs -+ | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call -+ | Iop(Ialloc _) -> destroyed_at_alloc -+ | _ -> [||] -+ -+let destroyed_at_raise = all_phys_regs -+ -+let destroyed_at_reloadretaddr = [| |] -+ -+(* Maximal register pressure *) -+ -+let safe_register_pressure = function -+ | Iextcall _ -> 15 -+ | _ -> 21 -+ -+let max_register_pressure = function -+ | Iextcall _ -> [| 15; 18 |] -+ | _ -> [| 21; 30 |] -+ -+(* Pure operations (without any side effect besides updating their result -+ registers). *) -+ -+let op_is_pure = function -+ | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ -+ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ -+ | Iintop(Icheckbound _) | Iintop_imm(Icheckbound _, _) -> false -+ | Ispecific(Imultaddf _ | Imultsubf _) -> true -+ | _ -> true -+ -+(* Layout of the stack *) -+ -+let frame_required fd = -+ fd.fun_contains_calls -+ || fd.fun_num_stack_slots.(0) > 0 -+ || fd.fun_num_stack_slots.(1) > 0 -+ -+let prologue_required fd = -+ frame_required fd -+ -+(* See -+ https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md *) -+ -+let int_dwarf_reg_numbers = -+ [| 10; 11; 12; 13; 14; 15; 16; 17; -+ 18; 19; 20; 21; 22; 23; 24; 25; -+ 7; 28; 29; 30; 31; -+ 5; 6; -+ 8; 9; 26; 27; -+ |] -+ -+let float_dwarf_reg_numbers = -+ [| 32; 33; 34; 35; 36; 37; 38; 39; -+ 40; 41; -+ 42; 43; 44; 45; 46; 47; 48; 49; -+ 50; 51; 52; 53; 54; 55; 56; 57; -+ 58; 59; -+ 60; 61; 62; 63; -+ |] -+ -+let dwarf_register_numbers ~reg_class = -+ match reg_class with -+ | 0 -> int_dwarf_reg_numbers -+ | 1 -> float_dwarf_reg_numbers -+ | _ -> Misc.fatal_errorf "Bad register class %d" reg_class -+ -+let stack_ptr_dwarf_register_number = 2 -+ -+(* Calling the assembler *) -+ -+let assemble_file infile outfile = -+ Ccomp.command -+ (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) -+ -+let init () = () -diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml -new file mode 100644 -index 000000000..be18cbd7f ---- /dev/null -+++ b/asmcomp/riscv/reload.ml -@@ -0,0 +1,19 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Reloading for the RISC-V *) -+ -+let fundecl f = -+ (new Reloadgen.reload_generic)#fundecl f -diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml -new file mode 100644 -index 000000000..e56b723c5 ---- /dev/null -+++ b/asmcomp/riscv/scheduling.ml -@@ -0,0 +1,22 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Instruction scheduling for the RISC-V *) -+ -+open! Schedgen (* to create a dependency *) -+ -+(* Scheduling is turned off. *) -+ -+let fundecl f = f -diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml -new file mode 100644 -index 000000000..0e2d84f48 ---- /dev/null -+++ b/asmcomp/riscv/selection.ml -@@ -0,0 +1,74 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Instruction selection for the RISC-V processor *) -+ -+open Cmm -+open Arch -+open Mach -+ -+(* Instruction selection *) -+ -+class selector = object (self) -+ -+inherit Selectgen.selector_generic as super -+ -+method is_immediate n = is_immediate n -+ -+method select_addressing _ = function -+ | Cop(Cadda, [arg; Cconst_int (n, _)], _) when self#is_immediate n -> -+ (Iindexed n, arg) -+ | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int (n, _)], _)], dbg) when self#is_immediate n -> -+ (Iindexed n, Cop(Caddi, [arg1; arg2], dbg)) -+ | arg -> -+ (Iindexed 0, arg) -+ -+method! select_operation op args dbg = -+ match (op, args) with -+ (* RISC-V does not support immediate operands for multiply high *) -+ | (Cmulhi, _) -> (Iintop Imulh, args) -+ (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) -+ | (Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -+ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2], _)]) -> -+ (Ispecific (Imultaddf false), [arg1; arg2; arg3]) -+ | (Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -> -+ (Ispecific (Imultsubf false), [arg1; arg2; arg3]) -+ | (Cnegf, [Cop(Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> -+ (Ispecific (Imultsubf true), [arg1; arg2; arg3]) -+ | (Cnegf, [Cop(Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> -+ (Ispecific (Imultaddf true), [arg1; arg2; arg3]) -+ (* RISC-V does not support immediate operands for comparison operators *) -+ | (Ccmpi comp, args) -> (Iintop(Icomp (Isigned comp)), args) -+ | (Ccmpa comp, args) -> (Iintop(Icomp (Iunsigned comp)), args) -+ | (Cmuli, _) -> (Iintop Imul, args) -+ | _ -> -+ super#select_operation op args dbg -+ -+(* Instruction selection for conditionals *) -+ -+method! select_condition = function -+ Cop(Ccmpi cmp, args, _) -> -+ (Iinttest(Isigned cmp), Ctuple args) -+ | Cop(Ccmpa cmp, args, _) -> -+ (Iinttest(Iunsigned cmp), Ctuple args) -+ | Cop(Ccmpf cmp, args, _) -> -+ (Ifloattest cmp, Ctuple args) -+ | Cop(Cand, [arg; Cconst_int (1, _)], _) -> -+ (Ioddtest, arg) -+ | arg -> -+ (Itruetest, arg) -+end -+ -+let fundecl f = (new selector)#emit_fundecl f -diff --git a/configure b/configure -index b8f74728f..4b827c5cc 100755 ---- a/configure -+++ b/configure -@@ -1,60 +1,4 @@ - #! /bin/sh -- --if test -e '.git' ; then : -- if test -z "$ac_read_git_config" ; then : -- extra_args=$(git config ocaml.configure 2>/dev/null) -- extended_cache=$(git config ocaml.configure-cache 2>/dev/null) -- cache_file= -- -- # If ocaml.configure-cache is set, parse the command-line for the --host -- # option, in order to determine the name of the cache file. -- if test -n "$extended_cache" ; then : -- echo "Detected Git configuration option ocaml.configure-cache set to \ --\"$extended_cache\"" -- dashdash= -- prev= -- host=default -- # The logic here is pretty borrowed from autoconf's -- for option in $extra_args "$@" -- do -- if test -n "$prev" ; then : -- host=$option -- continue -- fi -- -- case $dashdash$option in -- --) -- dashdash=yes ;; -- -host | --host | --hos | --ho) -- prev=host ;; -- -host=* | --host=* | --hos=* | --ho=*) -- case $option in -- *=?*) host=$(expr "X$option" : '[^=]*=\(.*\)') ;; -- *=) host= ;; -- esac ;; -- esac -- done -- cache_file="`dirname "$0"`/$extended_cache/ocaml-$host.cache" -- fi -- -- # If either option has a value, re-invoke configure -- if test -n "$extra_args$cache_file" ; then : -- echo "Detected Git configuration option ocaml.configure set to \ --\"$extra_args\"" -- # Too much effort to get the echo to show appropriate quoting - the -- # invocation itself intentionally quotes $0 and passes $@ exactly as given -- # but allows a single expansion of ocaml.configure -- if test -n "$cache_file" ; then : -- echo "Re-running $0 $extra_args --cache-file \"$cache_file\" $@" -- ac_read_git_config=true exec "$0" $extra_args \ -- --cache-file "$cache_file" "$@" -- else -- echo "Re-running $0 $extra_args $@" -- ac_read_git_config=true exec "$0" $extra_args "$@" -- fi -- fi -- fi --fi - # Guess values for system-dependent variables and create Makefiles. - # Generated by GNU Autoconf 2.69 for OCaml 4.10.0. - # -@@ -13509,6 +13453,8 @@ if test x"$enable_shared" != "xno"; then : - natdynlink=true ;; #( - aarch64-*-freebsd*) : - natdynlink=true ;; #( -+ riscv*-*-linux*) : -+ natdynlink=true ;; #( - *) : - ;; - esac -@@ -13649,7 +13595,9 @@ fi; system=elf ;; #( - aarch64-*-freebsd*) : - arch=arm64; system=freebsd ;; #( - x86_64-*-cygwin*) : -- arch=amd64; system=cygwin -+ arch=amd64; system=cygwin ;; #( -+ riscv64-*-linux*) : -+ arch=riscv; model=riscv64; system=linux - ;; #( - *) : - ;; -@@ -13861,13 +13809,14 @@ esac ;; #( - *,freebsd) : - default_as="${toolpref}as" - default_aspp="${toolpref}cc -c" ;; #( -- amd64,*|arm,*|arm64,*|i386,*) : -- default_as="${toolpref}as" -+ amd64,*|arm,*|arm64,*|i386,*|riscv,*) : - case $ocaml_cv_cc_vendor in #( - clang-*) : -- default_aspp="${toolpref}clang -c -Wno-trigraphs" ;; #( -+ default_as="${toolpref}clang -c -Wno-trigraphs" -+ default_aspp="${toolpref}clang -c -Wno-trigraphs" ;; #( - *) : -- default_aspp="${toolpref}gcc -c" ;; -+ default_as="${toolpref}as" -+ default_aspp="${toolpref}gcc -c" ;; - esac ;; #( - *) : - ;; -diff --git a/configure.ac b/configure.ac -index ad07516e7..48fa4225c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -841,7 +841,8 @@ AS_IF([test x"$enable_shared" != "xno"], - [arm*-*-freebsd*], [natdynlink=true], - [earm*-*-netbsd*], [natdynlink=true], - [aarch64-*-linux*], [natdynlink=true], -- [aarch64-*-freebsd*], [natdynlink=true])]) -+ [aarch64-*-freebsd*], [natdynlink=true], -+ [riscv*-*-linux*], [natdynlink=true])]) - - # Try to work around the Skylake/Kaby Lake processor bug. - AS_CASE(["$CC,$host"], -@@ -934,7 +935,9 @@ AS_CASE([$host], - [aarch64-*-freebsd*], - [arch=arm64; system=freebsd], - [x86_64-*-cygwin*], -- [arch=amd64; system=cygwin] -+ [arch=amd64; system=cygwin], -+ [riscv64-*-linux*], -+ [arch=riscv; model=riscv64; system=linux] - ) - - AS_IF([test x"$enable_native_compiler" = "xno"], -@@ -1020,11 +1023,12 @@ AS_CASE(["$arch,$system"], - [*,freebsd], - [default_as="${toolpref}as" - default_aspp="${toolpref}cc -c"], -- [amd64,*|arm,*|arm64,*|i386,*], -- [default_as="${toolpref}as" -- AS_CASE([$ocaml_cv_cc_vendor], -- [clang-*], [default_aspp="${toolpref}clang -c -Wno-trigraphs"], -- [default_aspp="${toolpref}gcc -c"])]) -+ [amd64,*|arm,*|arm64,*|i386,*|riscv,*], -+ [AS_CASE([$ocaml_cv_cc_vendor], -+ [clang-*], [default_as="${toolpref}clang -c -Wno-trigraphs" -+ default_aspp="${toolpref}clang -c -Wno-trigraphs"], -+ [default_as="${toolpref}as" -+ default_aspp="${toolpref}gcc -c"])]) - - AS_IF([test "$with_pic"], - [fpic=true -diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index 44a881e41..3cffbfec9 100644 ---- a/runtime/caml/stack.h -+++ b/runtime/caml/stack.h -@@ -70,6 +70,11 @@ - #define Callback_link(sp) ((struct caml_context *)((sp) + 16)) - #endif - -+#ifdef TARGET_riscv -+#define Saved_return_address(sp) *((intnat *)((sp) - 8)) -+#define Callback_link(sp) ((struct caml_context *)((sp) + 16)) -+#endif -+ - /* Structure of OCaml callback contexts */ - - struct caml_context { -diff --git a/runtime/riscv.S b/runtime/riscv.S -new file mode 100644 -index 000000000..6c8da79d0 ---- /dev/null -+++ b/runtime/riscv.S -@@ -0,0 +1,422 @@ -+/**************************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2016 Institut National de Recherche en Informatique et */ -+/* en Automatique. */ -+/* */ -+/* All rights reserved. This file is distributed under the terms of */ -+/* the GNU Lesser General Public License version 2.1, with the */ -+/* special exception on linking described in the file LICENSE. */ -+/* */ -+/**************************************************************************/ -+ -+/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ -+/* Must be preprocessed by cpp */ -+ -+#define ARG_DOMAIN_STATE_PTR t1 -+#define DOMAIN_STATE_PTR s0 -+#define TRAP_PTR s1 -+#define ALLOC_PTR s10 -+#define ALLOC_LIMIT s11 -+#define TMP t0 -+#define ARG t2 -+ -+#define STORE sd -+#define LOAD ld -+ -+ .set domain_curr_field, 0 -+#define DOMAIN_STATE(c_type, name) \ -+ .equ domain_field_caml_##name, domain_curr_field ; \ -+ .set domain_curr_field, domain_curr_field + 1 -+#include "../runtime/caml/domain_state.tbl" -+#undef DOMAIN_STATE -+ -+#define Caml_state(var) (8*domain_field_caml_##var)(s0) -+ -+#define FUNCTION(name) \ -+ .align 2; \ -+ .globl name; \ -+ .type name, @function; \ -+name: -+ -+#if defined(__PIC__) -+ .option pic -+#define PLT(r) r@plt -+#else -+ .option nopic -+#define PLT(r) r -+#endif -+ -+ .section .text -+/* Invoke the garbage collector. */ -+ -+ .globl caml_system__code_begin -+caml_system__code_begin: -+ -+FUNCTION(caml_call_gc) -+.Lcaml_call_gc: -+ /* Record return address */ -+ STORE ra, Caml_state(last_return_address) -+ /* Record lowest stack address */ -+ STORE sp, Caml_state(bottom_of_stack) -+ /* Set up stack space, saving return address */ -+ /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, 20 caller-save float regs) * 8 */ -+ /* + 1 for alignment */ -+ addi sp, sp, -0x160 -+ STORE ra, 0x8(sp) -+ STORE s0, 0x0(sp) -+ /* Save allocatable integer registers on the stack, -+ in the order given in proc.ml */ -+ STORE a0, 0x10(sp) -+ STORE a1, 0x18(sp) -+ STORE a2, 0x20(sp) -+ STORE a3, 0x28(sp) -+ STORE a4, 0x30(sp) -+ STORE a5, 0x38(sp) -+ STORE a6, 0x40(sp) -+ STORE a7, 0x48(sp) -+ STORE s2, 0x50(sp) -+ STORE s3, 0x58(sp) -+ STORE s4, 0x60(sp) -+ STORE s5, 0x68(sp) -+ STORE s6, 0x70(sp) -+ STORE s7, 0x78(sp) -+ STORE s8, 0x80(sp) -+ STORE s9, 0x88(sp) -+ STORE t2, 0x90(sp) -+ STORE t3, 0x98(sp) -+ STORE t4, 0xa0(sp) -+ STORE t5, 0xa8(sp) -+ STORE t6, 0xb0(sp) -+ /* Save caller-save floating-point registers on the stack -+ (callee-saves are preserved by caml_garbage_collection) */ -+ fsd ft0, 0xb8(sp) -+ fsd ft1, 0xc0(sp) -+ fsd ft2, 0xc8(sp) -+ fsd ft3, 0xd0(sp) -+ fsd ft4, 0xd8(sp) -+ fsd ft5, 0xe0(sp) -+ fsd ft6, 0xe8(sp) -+ fsd ft7, 0xf0(sp) -+ fsd fa0, 0xf8(sp) -+ fsd fa1, 0x100(sp) -+ fsd fa2, 0x108(sp) -+ fsd fa3, 0x110(sp) -+ fsd fa4, 0x118(sp) -+ fsd fa5, 0x120(sp) -+ fsd fa6, 0x128(sp) -+ fsd fa7, 0x130(sp) -+ fsd ft8, 0x138(sp) -+ fsd ft9, 0x140(sp) -+ fsd ft9, 0x148(sp) -+ fsd ft10, 0x150(sp) -+ fsd ft11, 0x158(sp) -+ /* Store pointer to saved integer registers in caml_gc_regs */ -+ addi TMP, sp, 16 -+ STORE TMP, Caml_state(gc_regs) -+ /* Save current allocation pointer for debugging purposes */ -+ STORE ALLOC_PTR, Caml_state(young_ptr) -+ /* Save trap pointer in case an exception is raised during GC */ -+ STORE TRAP_PTR, Caml_state(exception_pointer) -+ /* Call the garbage collector */ -+ call PLT(caml_garbage_collection) -+ /* Restore registers */ -+ LOAD a0, 0x10(sp) -+ LOAD a1, 0x18(sp) -+ LOAD a2, 0x20(sp) -+ LOAD a3, 0x28(sp) -+ LOAD a4, 0x30(sp) -+ LOAD a5, 0x38(sp) -+ LOAD a6, 0x40(sp) -+ LOAD a7, 0x48(sp) -+ LOAD s2, 0x50(sp) -+ LOAD s3, 0x58(sp) -+ LOAD s4, 0x60(sp) -+ LOAD s5, 0x68(sp) -+ LOAD s6, 0x70(sp) -+ LOAD s7, 0x78(sp) -+ LOAD s8, 0x80(sp) -+ LOAD s9, 0x88(sp) -+ LOAD t2, 0x90(sp) -+ LOAD t3, 0x98(sp) -+ LOAD t4, 0xa0(sp) -+ LOAD t5, 0xa8(sp) -+ LOAD t6, 0xb0(sp) -+ fld ft0, 0xb8(sp) -+ fld ft1, 0xc0(sp) -+ fld ft2, 0xc8(sp) -+ fld ft3, 0xd0(sp) -+ fld ft4, 0xd8(sp) -+ fld ft5, 0xe0(sp) -+ fld ft6, 0xe8(sp) -+ fld ft7, 0xf0(sp) -+ fld fa0, 0xf8(sp) -+ fld fa1, 0x100(sp) -+ fld fa2, 0x108(sp) -+ fld fa3, 0x110(sp) -+ fld fa4, 0x118(sp) -+ fld fa5, 0x120(sp) -+ fld fa6, 0x128(sp) -+ fld fa7, 0x130(sp) -+ fld ft8, 0x138(sp) -+ fld ft9, 0x140(sp) -+ fld ft9, 0x148(sp) -+ fld ft10, 0x150(sp) -+ fld ft11, 0x158(sp) -+ /* Reload new allocation pointer and allocation limit */ -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ /* Free stack space and return to caller */ -+ LOAD ra, 0x8(sp) -+ LOAD s0, 0x0(sp) -+ addi sp, sp, 0x160 -+ ret -+ .size caml_call_gc, .-caml_call_gc -+ -+/* Call a C function from OCaml */ -+/* Function to call is in ARG */ -+ -+FUNCTION(caml_c_call) -+ /* Preserve return address in callee-save register s2 */ -+ mv s2, ra -+ /* Record lowest stack address and return address */ -+ STORE ra, Caml_state(last_return_address) -+ STORE sp, Caml_state(bottom_of_stack) -+ /* Make the exception handler alloc ptr available to the C code */ -+ STORE ALLOC_PTR, Caml_state(young_ptr) -+ STORE TRAP_PTR, Caml_state(exception_pointer) -+ /* Call the function */ -+ jalr ARG -+ /* Reload alloc ptr and alloc limit */ -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ /* Return */ -+ jr s2 -+ .size caml_c_call, .-caml_c_call -+ -+/* Raise an exception from OCaml */ -+FUNCTION(caml_raise_exn) -+ /* Test if backtrace is active */ -+ LOAD TMP, Caml_state(backtrace_active) -+ bnez TMP, 2f -+1: /* Cut stack at current trap handler */ -+ mv sp, TRAP_PTR -+ /* Pop previous handler and jump to it */ -+ LOAD TMP, 8(sp) -+ LOAD TRAP_PTR, 0(sp) -+ addi sp, sp, 16 -+ jr TMP -+2: /* Preserve exception bucket in callee-save register s2 */ -+ mv s2, a0 -+ /* Stash the backtrace */ -+ mv a1, ra -+ mv a2, sp -+ mv a3, TRAP_PTR -+ call PLT(caml_stash_backtrace) -+ /* Restore exception bucket and raise */ -+ mv a0, s2 -+ j 1b -+ .size caml_raise_exn, .-caml_raise_exn -+ -+ .globl caml_reraise_exn -+ .type caml_reraise_exn, @function -+ -+/* Raise an exception from C */ -+ -+FUNCTION(caml_raise_exception) -+ mv DOMAIN_STATE_PTR, a0 -+ mv a0, a1 -+ LOAD TRAP_PTR, Caml_state(exception_pointer) -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ LOAD TMP, Caml_state(backtrace_active) -+ bnez TMP, 2f -+1: /* Cut stack at current trap handler */ -+ mv sp, TRAP_PTR -+ LOAD TMP, 8(sp) -+ LOAD TRAP_PTR, 0(sp) -+ addi sp, sp, 16 -+ jr TMP -+2: /* Preserve exception bucket in callee-save register s2 */ -+ mv s2, a0 -+ LOAD a1, Caml_state(last_return_address) -+ LOAD a2, Caml_state(bottom_of_stack) -+ mv a3, TRAP_PTR -+ call PLT(caml_stash_backtrace) -+ mv a0, s2 -+ j 1b -+ .size caml_raise_exception, .-caml_raise_exception -+ -+/* Start the OCaml program */ -+ -+FUNCTION(caml_start_program) -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ la ARG, caml_program -+ /* Code shared with caml_callback* */ -+ /* Address of OCaml code to call is in ARG */ -+ /* Arguments to the OCaml code are in a0 ... a7 */ -+.Ljump_to_caml: -+ /* Set up stack frame and save callee-save registers */ -+ addi sp, sp, -0xd0 -+ STORE ra, 0xc0(sp) -+ STORE s0, 0x0(sp) -+ STORE s1, 0x8(sp) -+ STORE s2, 0x10(sp) -+ STORE s3, 0x18(sp) -+ STORE s4, 0x20(sp) -+ STORE s5, 0x28(sp) -+ STORE s6, 0x30(sp) -+ STORE s7, 0x38(sp) -+ STORE s8, 0x40(sp) -+ STORE s9, 0x48(sp) -+ STORE s10, 0x50(sp) -+ STORE s11, 0x58(sp) -+ fsd fs0, 0x60(sp) -+ fsd fs1, 0x68(sp) -+ fsd fs2, 0x70(sp) -+ fsd fs3, 0x78(sp) -+ fsd fs4, 0x80(sp) -+ fsd fs5, 0x88(sp) -+ fsd fs6, 0x90(sp) -+ fsd fs7, 0x98(sp) -+ fsd fs8, 0xa0(sp) -+ fsd fs9, 0xa8(sp) -+ fsd fs10, 0xb0(sp) -+ fsd fs11, 0xb8(sp) -+ addi sp, sp, -32 -+ /* Load domain state pointer from argument */ -+ mv DOMAIN_STATE_PTR, ARG_DOMAIN_STATE_PTR -+ /* Setup a callback link on the stack */ -+ LOAD TMP, Caml_state(bottom_of_stack) -+ STORE TMP, 0(sp) -+ LOAD TMP, Caml_state(last_return_address) -+ STORE TMP, 8(sp) -+ LOAD TMP, Caml_state(gc_regs) -+ STORE TMP, 16(sp) -+ /* set up a trap frame */ -+ addi sp, sp, -16 -+ LOAD TMP, Caml_state(exception_pointer) -+ STORE TMP, 0(sp) -+ lla TMP, .Ltrap_handler -+ STORE TMP, 8(sp) -+ mv TRAP_PTR, sp -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ STORE x0, Caml_state(last_return_address) -+ jalr ARG -+.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ -+ LOAD TMP, 0(sp) -+ STORE TMP, Caml_state(exception_pointer) -+ addi sp, sp, 16 -+.Lreturn_result: /* pop callback link, restoring global variables */ -+ LOAD TMP, 0(sp) -+ STORE TMP, Caml_state(bottom_of_stack) -+ LOAD TMP, 8(sp) -+ STORE TMP, Caml_state(last_return_address) -+ LOAD TMP, 16(sp) -+ STORE TMP, Caml_state(gc_regs) -+ addi sp, sp, 32 -+ /* Update allocation pointer */ -+ STORE ALLOC_PTR, Caml_state(young_ptr) -+ /* reload callee-save registers and return */ -+ LOAD ra, 0xc0(sp) -+ LOAD s0, 0x0(sp) -+ LOAD s1, 0x8(sp) -+ LOAD s2, 0x10(sp) -+ LOAD s3, 0x18(sp) -+ LOAD s4, 0x20(sp) -+ LOAD s5, 0x28(sp) -+ LOAD s6, 0x30(sp) -+ LOAD s7, 0x38(sp) -+ LOAD s8, 0x40(sp) -+ LOAD s9, 0x48(sp) -+ LOAD s10, 0x50(sp) -+ LOAD s11, 0x58(sp) -+ fld fs0, 0x60(sp) -+ fld fs1, 0x68(sp) -+ fld fs2, 0x70(sp) -+ fld fs3, 0x78(sp) -+ fld fs4, 0x80(sp) -+ fld fs5, 0x88(sp) -+ fld fs6, 0x90(sp) -+ fld fs7, 0x98(sp) -+ fld fs8, 0xa0(sp) -+ fld fs9, 0xa8(sp) -+ fld fs10, 0xb0(sp) -+ fld fs11, 0xb8(sp) -+ addi sp, sp, 0xd0 -+ ret -+ .type .Lcaml_retaddr, @function -+ .size .Lcaml_retaddr, .-.Lcaml_retaddr -+ .size caml_start_program, .-caml_start_program -+ -+ .align 2 -+.Ltrap_handler: -+ STORE TRAP_PTR, Caml_state(exception_pointer) -+ ori a0, a0, 2 -+ j .Lreturn_result -+ .type .Ltrap_handler, @function -+ .size .Ltrap_handler, .-.Ltrap_handler -+ -+/* Callback from C to OCaml */ -+ -+FUNCTION(caml_callback_asm) -+ /* Initial shuffling of arguments */ -+ /* a0 = Caml_state, a1 = closure, (a2) = args */ -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ LOAD a0, 0(a2) /* a0 = first arg */ -+ /* a1 = closure environment */ -+ LOAD ARG, 0(a1) /* code pointer */ -+ j .Ljump_to_caml -+ .size caml_callback_asm, .-caml_callback_asm -+ -+FUNCTION(caml_callback2_asm) -+ /* Initial shuffling of arguments */ -+ /* a0 = Caml_state, a1 = closure, (a2) = args */ -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ mv TMP, a1 -+ LOAD a0, 0(a2) -+ LOAD a1, 8(a2) -+ mv a2, TMP -+ la ARG, caml_apply2 -+ j .Ljump_to_caml -+ .size caml_callback2_asm, .-caml_callback2_asm -+ -+FUNCTION(caml_callback3_asm) -+ /* Initial shuffling of arguments */ -+ /* a0 = Caml_state, a1 = closure, (a2) = args */ -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ mv a3, a1 -+ LOAD a0, 0(a2) -+ LOAD a1, 8(a2) -+ LOAD a2, 16(a2) -+ la ARG, caml_apply3 -+ j .Ljump_to_caml -+ .size caml_callback3_asm, .-caml_callback3_asm -+ -+FUNCTION(caml_ml_array_bound_error) -+ /* Load address of [caml_array_bound_error] in ARG */ -+ la ARG, caml_array_bound_error -+ /* Call that function */ -+ tail caml_c_call -+ .size caml_ml_array_bound_error, .-caml_ml_array_bound_error -+ -+ .globl caml_system__code_end -+caml_system__code_end: -+ -+/* GC roots for callback */ -+ -+ .section .data -+ .align 3 -+ .globl caml_system__frametable -+ .type caml_system__frametable, @object -+caml_system__frametable: -+ .quad 1 /* one descriptor */ -+ .quad .Lcaml_retaddr /* return address into callback */ -+ .short -1 /* negative frame size => use callback link */ -+ .short 0 /* no roots */ -+ .align 3 -+ .size caml_system__frametable, .-caml_system__frametable -diff --git a/testsuite/tools/asmgen_riscv.S b/testsuite/tools/asmgen_riscv.S -new file mode 100644 -index 000000000..806b23dfc ---- /dev/null -+++ b/testsuite/tools/asmgen_riscv.S -@@ -0,0 +1,89 @@ -+/**************************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2019 Institut National de Recherche en Informatique et */ -+/* en Automatique. */ -+/* */ -+/* All rights reserved. This file is distributed under the terms of */ -+/* the GNU Lesser General Public License version 2.1, with the */ -+/* special exception on linking described in the file LICENSE. */ -+/* */ -+/**************************************************************************/ -+ -+#define STORE sd -+#define LOAD ld -+ -+ .globl call_gen_code -+ .align 2 -+call_gen_code: -+ /* Set up stack frame and save callee-save registers */ -+ ADDI sp, sp, -208 -+ STORE ra, 192(sp) -+ STORE s0, 0(sp) -+ STORE s1, 8(sp) -+ STORE s2, 16(sp) -+ STORE s3, 24(sp) -+ STORE s4, 32(sp) -+ STORE s5, 40(sp) -+ STORE s6, 48(sp) -+ STORE s7, 56(sp) -+ STORE s8, 64(sp) -+ STORE s9, 72(sp) -+ STORE s10, 80(sp) -+ STORE s11, 88(sp) -+ fsd fs0, 96(sp) -+ fsd fs1, 104(sp) -+ fsd fs2, 112(sp) -+ fsd fs3, 120(sp) -+ fsd fs4, 128(sp) -+ fsd fs5, 136(sp) -+ fsd fs6, 144(sp) -+ fsd fs7, 152(sp) -+ fsd fs8, 160(sp) -+ fsd fs9, 168(sp) -+ fsd fs10, 176(sp) -+ fsd fs11, 184(sp) -+ /* Shuffle arguments */ -+ mv t0, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, a3 -+ mv a3, a4 -+ /* Call generated asm */ -+ jalr t0 -+ /* Reload callee-save registers and return address */ -+ LOAD ra, 192(sp) -+ LOAD s0, 0(sp) -+ LOAD s1, 8(sp) -+ LOAD s2, 16(sp) -+ LOAD s3, 24(sp) -+ LOAD s4, 32(sp) -+ LOAD s5, 40(sp) -+ LOAD s6, 48(sp) -+ LOAD s7, 56(sp) -+ LOAD s8, 64(sp) -+ LOAD s9, 72(sp) -+ LOAD s10, 80(sp) -+ LOAD s11, 88(sp) -+ fld fs0, 96(sp) -+ fld fs1, 104(sp) -+ fld fs2, 112(sp) -+ fld fs3, 120(sp) -+ fld fs4, 128(sp) -+ fld fs5, 136(sp) -+ fld fs6, 144(sp) -+ fld fs7, 152(sp) -+ fld fs8, 160(sp) -+ fld fs9, 168(sp) -+ fld fs10, 176(sp) -+ fld fs11, 184(sp) -+ addi sp, sp, 208 -+ ret -+ -+ .globl caml_c_call -+ .align 2 -+caml_c_call: -+ jr t2 --- -2.24.1 - diff --git a/ocaml.spec b/ocaml.spec index 298d4a9..f1730af 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -26,12 +26,12 @@ # Architectures where parallel builds fail. #global no_parallel_build_arches aarch64 -#global rcver +beta1 +#global rcver +git %global rcver %{nil} Name: ocaml -Version: 4.10.0 -Release: 4%{?dist} +Version: 4.11.0 +Release: 0.1.pre%{?dist} Summary: OCaml compiler and programming environment @@ -39,7 +39,11 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org -Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rcver}.tar.xz +#Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rcver}.tar.xz +# This is a pre-release of OCaml 4.11.0 with addition of the RISC-V +# patches. See: +# https://pagure.io/fedora-ocaml/commits/fedora-33-4.11.0-pre +Source0: ocaml-4.11.0.tar.gz # IMPORTANT NOTE: # @@ -50,26 +54,17 @@ Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rc # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-33-4.10.0 +# Current branch: fedora-33-4.11.0-pre # # 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. -# # Fedora-specific downstream patches. Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch Patch0004: 0004-Remove-configure-from-.gitattributes.patch -# Out of tree patch for RISC-V support. -# https://github.com/nojb/ocaml branch riscv -# I had to backport some other upstream patches from > 4.10 in -# order to get this to apply. -Patch0005: 0005-Use-a-more-compact-representation-of-debug-informati.patch -Patch0006: 0006-Retain-debug-information-about-allocation-sizes-for-.patch -Patch0007: 0007-Use-allocation-size-info-on-more-than-just-amd64.patch -Patch0008: 0008-Add-riscv64-backend.patch BuildRequires: git BuildRequires: gcc @@ -373,6 +368,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Fri Apr 17 2020 Richard W.M. Jones - 4.11.0-0.1.pre.fc33 +- Move to OCaml 4.11.0 pre-release with support for RISC-V. + * Sat Apr 11 2020 Richard W.M. Jones - 4.10.0-4.fc33 - Fix RISC-V backend. diff --git a/sources b/sources index 38b14bf..582776a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.10.0.tar.xz) = d2ed8b6162898da45ccc231c97a1b46a330467b9b24390ed17cf3e5367ae6d198ecac8e0df11e5501cdf22cc6313ec23c6cf477d621d017f69f9744eb0050e2e +SHA512 (ocaml-4.11.0.tar.gz) = 3d41e50b73981af1f6d5e51cf1878a2fd54b52a4da434298a48159d48ea66166689c2fb30a8fe6a9e8dd6f4a483009af24e550fb03fa6dc736b6bf37c4534645 From a5fe6c6a381760c4cb53ab67d84009851bed38ce Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 17 Apr 2020 17:16:10 +0100 Subject: [PATCH 27/91] Build into the side tag instead of Rawhide. --- ocaml.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index f1730af..934b801 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.1.pre%{?dist} +Release: 0.2.pre%{?dist} Summary: OCaml compiler and programming environment @@ -368,7 +368,7 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog -* Fri Apr 17 2020 Richard W.M. Jones - 4.11.0-0.1.pre.fc33 +* Fri Apr 17 2020 Richard W.M. Jones - 4.11.0-0.2.pre.fc33 - Move to OCaml 4.11.0 pre-release with support for RISC-V. * Sat Apr 11 2020 Richard W.M. Jones - 4.10.0-4.fc33 From 7eb82f0e55da41443c1ed8ab7e6a808751daaa13 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 21 Apr 2020 15:12:14 +0100 Subject: [PATCH 28/91] Add fixes for various issues found in the previous build. --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...-incorrect-assumption-about-cross-co.patch | 2 +- ...Remove-configure-from-.gitattributes.patch | 2 +- ...-request-9457-from-dra27-fix-mod_use.patch | 174 ++++++++++++++++++ ...st-9463-from-lthls-fix_int64_cmm_typ.patch | 134 ++++++++++++++ ...nit-names-with-special-characters-94.patch | 55 ++++++ ocaml.spec | 10 +- 8 files changed, 376 insertions(+), 5 deletions(-) create mode 100644 0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch create mode 100644 0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch create mode 100644 0007-x86-asm-handle-unit-names-with-special-characters-94.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 8a126a1..2f9e58c 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 14d63e7a96ab39598f7c42b8513c914253afb173 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/4] Don't add rpaths to libraries. +Subject: [PATCH 1/7] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index fbadf53..dee5644 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From 65456b148ad6532a6b0086ba5812b67c0371e768 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/7] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 9da35dc..3c49bdd 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ From 0b1b91841a3a227321f8e155ed932893e285b429 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/4] configure: Remove incorrect assumption about +Subject: [PATCH 3/7] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index 7360765..6058177 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,7 +1,7 @@ From 0b805df7403257a71b9852deb2f468aac16133b0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 -Subject: [PATCH 4/4] Remove configure from .gitattributes. +Subject: [PATCH 4/7] Remove configure from .gitattributes. It's not a binary file. --- diff --git a/0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch b/0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch new file mode 100644 index 0000000..e2c4d9b --- /dev/null +++ b/0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch @@ -0,0 +1,174 @@ +From 2e40ed7452896a5ad043ca1297112d2a5bf6189b Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Mon, 20 Apr 2020 16:13:26 +0100 +Subject: [PATCH 5/7] Merge pull request #9457 from dra27/fix-mod_use + +Fix #mod_use in toplevel + +(cherry picked from commit f4dc3003d579e45f6ddeb6ffceb4c283a9e15bc7) +--- + Changes | 2 +- + testsuite/tests/tool-toplevel/mod.ml | 1 + + testsuite/tests/tool-toplevel/mod_use.ml | 9 +++++++++ + toplevel/opttoploop.ml | 19 +++++++++++-------- + toplevel/toploop.ml | 19 +++++++++++-------- + 5 files changed, 33 insertions(+), 17 deletions(-) + create mode 100644 testsuite/tests/tool-toplevel/mod.ml + create mode 100644 testsuite/tests/tool-toplevel/mod_use.ml + +diff --git a/Changes b/Changes +index f16158f12..a65573604 100644 +--- a/Changes ++++ b/Changes +@@ -164,7 +164,7 @@ Working version + points to the grammar. + (Andreas Abel, review by Xavier Leroy) + +-- #9283: add a new toplevel directive `#use_output ""` to ++- #9283, #9455, #9457: add a new toplevel directive `#use_output ""` to + run a command and evaluate its output. + (Jérémie Dimino, review by David Allsopp) + +diff --git a/testsuite/tests/tool-toplevel/mod.ml b/testsuite/tests/tool-toplevel/mod.ml +new file mode 100644 +index 000000000..cd298427b +--- /dev/null ++++ b/testsuite/tests/tool-toplevel/mod.ml +@@ -0,0 +1 @@ ++let answer = 42 +diff --git a/testsuite/tests/tool-toplevel/mod_use.ml b/testsuite/tests/tool-toplevel/mod_use.ml +new file mode 100644 +index 000000000..e068ffc3a +--- /dev/null ++++ b/testsuite/tests/tool-toplevel/mod_use.ml +@@ -0,0 +1,9 @@ ++(* TEST ++ files = "mod.ml" ++ * expect ++*) ++ ++#mod_use "mod.ml" ++[%%expect {| ++module Mod : sig val answer : int end ++|}];; +diff --git a/toplevel/opttoploop.ml b/toplevel/opttoploop.ml +index cd4210bbe..ad9a2569e 100644 +--- a/toplevel/opttoploop.ml ++++ b/toplevel/opttoploop.ml +@@ -449,7 +449,7 @@ let preprocess_phrase ppf phr = + if !Clflags.dump_source then Pprintast.top_phrase ppf phr; + phr + +-let use_channel ppf wrap_mod ic name filename = ++let use_channel ppf ~wrap_in_module ic name filename = + let lb = Lexing.from_channel ic in + Location.init lb filename; + (* Skip initial #! line if any *) +@@ -461,7 +461,7 @@ let use_channel ppf wrap_mod ic name filename = + (fun ph -> + let ph = preprocess_phrase ppf ph in + if not (execute_phrase !use_print_results ppf ph) then raise Exit) +- (if wrap_mod then ++ (if wrap_in_module then + parse_mod_use_file name lb + else + !parse_use_file lb); +@@ -485,27 +485,30 @@ let use_output ppf command = + | 0 -> + let ic = open_in_bin fn in + Misc.try_finally ~always:(fun () -> close_in ic) +- (fun () -> use_channel ppf false ic "" "(command-output)") ++ (fun () -> ++ use_channel ppf ~wrap_in_module:false ic "" "(command-output)") + | n -> + fprintf ppf "Command exited with code %d.@." n; + false) + +-let use_file ppf wrap_mode name = ++let use_file ppf ~wrap_in_module name = + match name with + | "" -> +- use_channel ppf wrap_mode stdin name "(stdin)" ++ use_channel ppf ~wrap_in_module stdin name "(stdin)" + | _ -> + match Load_path.find name with + | filename -> + let ic = open_in_bin filename in + Misc.try_finally ~always:(fun () -> close_in ic) +- (fun () -> use_channel ppf false ic name filename) ++ (fun () -> use_channel ppf ~wrap_in_module ic name filename) + | exception Not_found -> + fprintf ppf "Cannot find file %s.@." name; + false + +-let mod_use_file ppf name = use_file ppf true name +-let use_file ppf name = use_file ppf false name ++let mod_use_file ppf name = ++ use_file ppf ~wrap_in_module:true name ++let use_file ppf name = ++ use_file ppf ~wrap_in_module:false name + + let use_silently ppf name = + protect_refs [ R (use_print_results, false) ] (fun () -> use_file ppf name) +diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml +index 02f629f9d..09e550796 100644 +--- a/toplevel/toploop.ml ++++ b/toplevel/toploop.ml +@@ -394,7 +394,7 @@ let preprocess_phrase ppf phr = + if !Clflags.dump_source then Pprintast.top_phrase ppf phr; + phr + +-let use_channel ppf wrap_mod ic name filename = ++let use_channel ppf ~wrap_in_module ic name filename = + let lb = Lexing.from_channel ic in + Warnings.reset_fatal (); + Location.init lb filename; +@@ -408,7 +408,7 @@ let use_channel ppf wrap_mod ic name filename = + (fun ph -> + let ph = preprocess_phrase ppf ph in + if not (execute_phrase !use_print_results ppf ph) then raise Exit) +- (if wrap_mod then ++ (if wrap_in_module then + parse_mod_use_file name lb + else + !parse_use_file lb); +@@ -431,27 +431,30 @@ let use_output ppf command = + | 0 -> + let ic = open_in_bin fn in + Misc.try_finally ~always:(fun () -> close_in ic) +- (fun () -> use_channel ppf false ic "" "(command-output)") ++ (fun () -> ++ use_channel ppf ~wrap_in_module:false ic "" "(command-output)") + | n -> + fprintf ppf "Command exited with code %d.@." n; + false) + +-let use_file ppf wrap_mode name = ++let use_file ppf ~wrap_in_module name = + match name with + | "" -> +- use_channel ppf wrap_mode stdin name "(stdin)" ++ use_channel ppf ~wrap_in_module stdin name "(stdin)" + | _ -> + match Load_path.find name with + | filename -> + let ic = open_in_bin filename in + Misc.try_finally ~always:(fun () -> close_in ic) +- (fun () -> use_channel ppf false ic name filename) ++ (fun () -> use_channel ppf ~wrap_in_module ic name filename) + | exception Not_found -> + fprintf ppf "Cannot find file %s.@." name; + false + +-let mod_use_file ppf name = use_file ppf true name +-let use_file ppf name = use_file ppf false name ++let mod_use_file ppf name = ++ use_file ppf ~wrap_in_module:true name ++let use_file ppf name = ++ use_file ppf ~wrap_in_module:false name + + let use_silently ppf name = + protect_refs [ R (use_print_results, false) ] (fun () -> use_file ppf name) +-- +2.24.1 + diff --git a/0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch b/0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch new file mode 100644 index 0000000..96e74b2 --- /dev/null +++ b/0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch @@ -0,0 +1,134 @@ +From 13bec130864d682032f3b3086764487c26076093 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Mon, 20 Apr 2020 11:34:15 +0200 +Subject: [PATCH 6/7] Merge pull request #9463 from lthls/fix_int64_cmm_typ + +Fix Cmm type of unboxed integers in Clet_mut + +(cherry picked from commit 702e34fbe56f6f03db086efe42148395c5e395ff) +--- + Changes | 6 ++- + asmcomp/cmmgen.ml | 15 ++++---- + testsuite/tests/lib-int64/issue9460.ml | 37 +++++++++++++++++++ + testsuite/tests/lib-int64/issue9460.reference | 1 + + 4 files changed, 49 insertions(+), 10 deletions(-) + create mode 100644 testsuite/tests/lib-int64/issue9460.ml + create mode 100644 testsuite/tests/lib-int64/issue9460.reference + +diff --git a/Changes b/Changes +index a65573604..5f92e00c1 100644 +--- a/Changes ++++ b/Changes +@@ -66,8 +66,10 @@ Working version + - #9280: Micro-optimise allocations on amd64 to save a register. + (Stephen Dolan, review by Xavier Leroy) + +-- #9316: Use typing information from Clambda for mutable Cmm variables. +- (Stephen Dolan, review by Vincent Laviron, Guillaume Bury and Xavier Leroy) ++- #9316, #9443, #9463: Use typing information from Clambda ++ for mutable Cmm variables. ++ (Stephen Dolan, review by Vincent Laviron, Guillaume Bury, Xavier Leroy, ++ and Gabriel Scherer; temporary bug report by Richard Jones) + + - #9426: build the Mingw ports with higher levels of GCC optimization + (Xavier Leroy, review by Sébastien Hinderer) +diff --git a/asmcomp/cmmgen.ml b/asmcomp/cmmgen.ml +index 6e1c924dc..ec9697177 100644 +--- a/asmcomp/cmmgen.ml ++++ b/asmcomp/cmmgen.ml +@@ -247,6 +247,11 @@ let box_int dbg bi arg = + + (* Boxed numbers *) + ++let typ_of_boxed_number = function ++ | Boxed_float _ -> Cmm.typ_float ++ | Boxed_integer (Pint64, _) when size_int = 4 -> [|Int;Int|] ++ | Boxed_integer _ -> Cmm.typ_int ++ + let equal_unboxed_integer ui1 ui2 = + match ui1, ui2 with + | Pnativeint, Pnativeint -> true +@@ -687,11 +692,6 @@ and transl_catch env nfail ids body handler dbg = + in + let env_body = add_notify_catch nfail report env in + let body = transl env_body body in +- let typ_of_bn = function +- | Boxed_float _ -> Cmm.typ_float +- | Boxed_integer (Pint64, _) when size_int = 4 -> [|Int;Int|] +- | Boxed_integer _ -> Cmm.typ_int +- in + let new_env, rewrite, ids = + List.fold_right + (fun (id, _kind, u) (env, rewrite, ids) -> +@@ -704,7 +704,7 @@ and transl_catch env nfail ids body handler dbg = + let unboxed_id = V.create_local (VP.name id) in + add_unboxed_id (VP.var id) unboxed_id bn env, + (unbox_number Debuginfo.none bn) :: rewrite, +- (VP.create unboxed_id, typ_of_bn bn) :: ids ++ (VP.create unboxed_id, typ_of_boxed_number bn) :: ids + ) + ids (env, [], []) + in +@@ -1165,8 +1165,7 @@ and transl_let env str kind id exp body = + transl (add_unboxed_id (VP.var id) unboxed_id boxed_number env) body in + begin match str, boxed_number with + | Immutable, _ -> Clet (v, cexp, body) +- | Mutable, Boxed_float _ -> Clet_mut (v, typ_float, cexp, body) +- | Mutable, Boxed_integer _ -> Clet_mut (v, typ_int, cexp, body) ++ | Mutable, bn -> Clet_mut (v, typ_of_boxed_number bn, cexp, body) + end + + and make_catch ncatch body handler dbg = match body with +diff --git a/testsuite/tests/lib-int64/issue9460.ml b/testsuite/tests/lib-int64/issue9460.ml +new file mode 100644 +index 000000000..aacbe6189 +--- /dev/null ++++ b/testsuite/tests/lib-int64/issue9460.ml +@@ -0,0 +1,37 @@ ++(* TEST ++*) ++ ++(* See https://github.com/ocaml/ocaml/issues/9460 ++ This test comes from Richard Jones ++ at ++ https://github.com/libguestfs/libnbd/blob/0475bfe04a527051c0a37af59a733c4c8554e427/ocaml/tests/test_400_pread.ml#L21-L36 ++*) ++let test_result = ++ let b = Bytes.create 16 in ++ for i = 0 to 16/8-1 do ++ let i64 = ref (Int64.of_int (i*8)) in ++ for j = 0 to 7 do ++ let c = Int64.shift_right_logical !i64 56 in ++ let c = Int64.to_int c in ++ let c = Char.chr c in ++ Bytes.unsafe_set b (i*8+j) c; ++ i64 := Int64.shift_left !i64 8 ++ done ++ done; ++ (Bytes.to_string b) ;; ++ ++let expected = ++ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\008" ++ ++let () = ++ assert (test_result = expected) ++ ++(* Reproduction case by Jeremy Yallop in ++ https://github.com/ocaml/ocaml/pull/9463#issuecomment-615831765 ++*) ++let () = ++ let x = ref Int64.max_int in ++ assert (!x = Int64.max_int) ++ ++let () = ++ print_endline "OK" +diff --git a/testsuite/tests/lib-int64/issue9460.reference b/testsuite/tests/lib-int64/issue9460.reference +new file mode 100644 +index 000000000..d86bac9de +--- /dev/null ++++ b/testsuite/tests/lib-int64/issue9460.reference +@@ -0,0 +1 @@ ++OK +-- +2.24.1 + diff --git a/0007-x86-asm-handle-unit-names-with-special-characters-94.patch b/0007-x86-asm-handle-unit-names-with-special-characters-94.patch new file mode 100644 index 0000000..9ecfab9 --- /dev/null +++ b/0007-x86-asm-handle-unit-names-with-special-characters-94.patch @@ -0,0 +1,55 @@ +From 946b5c2563dbf7d8969781e6b05d9fc531cd65a2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= +Date: Sun, 19 Apr 2020 11:17:00 +0200 +Subject: [PATCH 7/7] x86 asm: handle unit names with special characters + (#9465) + +(cherry picked from commit ec6690fb53b6caced797e1a7a083a787ff8bd97c) +--- + asmcomp/amd64/emit.mlp | 2 +- + testsuite/tests/asmcomp/0-!@#%.compilers.reference | 2 ++ + testsuite/tests/asmcomp/0-!@#%.ml | 10 ++++++++++ + 3 files changed, 13 insertions(+), 1 deletion(-) + create mode 100644 testsuite/tests/asmcomp/0-!@#%.compilers.reference + create mode 100644 testsuite/tests/asmcomp/0-!@#%.ml + +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index 2e9e3a86d..d9c5eb6e6 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -1146,7 +1146,7 @@ let end_assembly() = + }; + + if system = S_linux then begin +- let frametable = Compilenv.make_symbol (Some "frametable") in ++ let frametable = emit_symbol (Compilenv.make_symbol (Some "frametable")) in + D.size frametable (ConstSub (ConstThis, ConstLabel frametable)) + end; + +diff --git a/testsuite/tests/asmcomp/0-!@#%.compilers.reference b/testsuite/tests/asmcomp/0-!@#%.compilers.reference +new file mode 100644 +index 000000000..7df9a5456 +--- /dev/null ++++ b/testsuite/tests/asmcomp/0-!@#%.compilers.reference +@@ -0,0 +1,2 @@ ++File "0-!@#%.ml", line 1: ++Warning 24: bad source file name: "0-!@#%" is not a valid module name. +diff --git a/testsuite/tests/asmcomp/0-!@#%.ml b/testsuite/tests/asmcomp/0-!@#%.ml +new file mode 100644 +index 000000000..9f24bc382 +--- /dev/null ++++ b/testsuite/tests/asmcomp/0-!@#%.ml +@@ -0,0 +1,10 @@ ++(* TEST *) ++ ++(* We could not include the following characters the file name: ++ ++ - '$' : this character is interpreted specially by [ocamltest] (as it uses ++ [Buffer.add_substitute] on the filenames). ++ ++ - '^' : this character causes problems under Windows if not properly ++ quoted. In particular, flexlink needed to be adapted. ++*) +-- +2.24.1 + diff --git a/ocaml.spec b/ocaml.spec index 934b801..34175e6 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.2.pre%{?dist} +Release: 0.3.pre%{?dist} Summary: OCaml compiler and programming environment @@ -66,6 +66,11 @@ Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch Patch0004: 0004-Remove-configure-from-.gitattributes.patch +# All of these fixes are upstream in 4.11. +Patch0005: 0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch +Patch0006: 0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch +Patch0007: 0007-x86-asm-handle-unit-names-with-special-characters-94.patch + BuildRequires: git BuildRequires: gcc BuildRequires: autoconf @@ -368,6 +373,9 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Tue Apr 21 2020 Richard W.M. Jones - 4.11.0-0.3.pre.fc33 +- Add fixes for various issues found in the previous build. + * Fri Apr 17 2020 Richard W.M. Jones - 4.11.0-0.2.pre.fc33 - Move to OCaml 4.11.0 pre-release with support for RISC-V. From a2dcfff43b33014a111e86f3c59f9911e933adfb Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 4 May 2020 10:16:53 +0100 Subject: [PATCH 29/91] Move to OCaml 4.11.0+dev2-2020-04-22. - Backport upstream RISC-V backend from 4.12 + fixes. - Enable tests on riscv64. - Disable ocaml-instr-* tools on riscv64. --- 0001-Don-t-add-rpaths-to-libraries.patch | 4 +- ...-Allow-user-defined-C-compiler-flags.patch | 6 +- ...-incorrect-assumption-about-cross-co.patch | 8 +- ...Remove-configure-from-.gitattributes.patch | 4 +- ...-Add-RISC-V-native-code-backend-9441.patch | 2012 +++++++++++++++++ ...-request-9457-from-dra27-fix-mod_use.patch | 174 -- ...st-9463-from-lthls-fix_int64_cmm_typ.patch | 134 -- 0006-Support-FP-reg-int-reg-moves.patch | 34 + ...-conventions-to-the-RISC-V-ELF-psABI.patch | 59 + ...nit-names-with-special-characters-94.patch | 55 - ocaml.spec | 32 +- sources | 2 +- 12 files changed, 2138 insertions(+), 386 deletions(-) create mode 100644 0005-Add-RISC-V-native-code-backend-9441.patch delete mode 100644 0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch delete mode 100644 0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch create mode 100644 0006-Support-FP-reg-int-reg-moves.patch create mode 100644 0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch delete mode 100644 0007-x86-asm-handle-unit-names-with-special-characters-94.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 2f9e58c..281cb7c 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,4 +1,4 @@ -From 14d63e7a96ab39598f7c42b8513c914253afb173 Mon Sep 17 00:00:00 2001 +From 1b1a2ad3294327e5bbbc753f306d1199b0a2a583 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 Subject: [PATCH 1/7] Don't add rpaths to libraries. @@ -8,7 +8,7 @@ Subject: [PATCH 1/7] Don't add rpaths to libraries. 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile -index 8bd51bfd8..b34cbbf32 100644 +index 96a4244cc..076411a91 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -153,8 +153,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index dee5644..3ffd213 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,4 +1,4 @@ -From 65456b148ad6532a6b0086ba5812b67c0371e768 Mon Sep 17 00:00:00 2001 +From 8ea0bc7713a89cd6340e35b4dae048be63c50aec Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 Subject: [PATCH 2/7] configure: Allow user defined C compiler flags. @@ -8,10 +8,10 @@ Subject: [PATCH 2/7] configure: Allow user defined C compiler flags. 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index e84dc0431..1687918a2 100644 +index fbd49c1ee..a35da2040 100644 --- a/configure.ac +++ b/configure.ac -@@ -608,6 +608,10 @@ AS_CASE([$host], +@@ -609,6 +609,10 @@ AS_CASE([$host], internal_cflags="$gcc_warnings"], [common_cflags="-O"])]) diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 3c49bdd..2b6d384 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,4 +1,4 @@ -From 0b1b91841a3a227321f8e155ed932893e285b429 Mon Sep 17 00:00:00 2001 +From 39df379f1aa139a073d7b436bb9bd33ef2f70caf Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 Subject: [PATCH 3/7] configure: Remove incorrect assumption about @@ -10,10 +10,10 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 1687918a2..01edbff17 100644 +index a35da2040..4c9358897 100644 --- a/configure.ac +++ b/configure.ac -@@ -510,10 +510,11 @@ AS_IF( +@@ -511,10 +511,11 @@ AS_IF( # Are we building a cross-compiler @@ -29,7 +29,7 @@ index 1687918a2..01edbff17 100644 # Checks for programs -@@ -996,7 +997,7 @@ AS_IF([test $arch != "none" && $arch64 ], +@@ -1018,7 +1019,7 @@ AS_CASE([$arch], # Assembler diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index 6058177..eb562e5 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,4 +1,4 @@ -From 0b805df7403257a71b9852deb2f468aac16133b0 Mon Sep 17 00:00:00 2001 +From e829051c3b35920db3c5e0dd913026f556448675 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 Subject: [PATCH 4/7] Remove configure from .gitattributes. @@ -9,7 +9,7 @@ It's not a binary file. 1 file changed, 4 deletions(-) diff --git a/.gitattributes b/.gitattributes -index db37bfbe5..b6e540188 100644 +index 200eb49c6..d871764de 100644 --- a/.gitattributes +++ b/.gitattributes @@ -29,10 +29,6 @@ diff --git a/0005-Add-RISC-V-native-code-backend-9441.patch b/0005-Add-RISC-V-native-code-backend-9441.patch new file mode 100644 index 0000000..f466fdd --- /dev/null +++ b/0005-Add-RISC-V-native-code-backend-9441.patch @@ -0,0 +1,2012 @@ +From 1a0ca036e40cbd701cbe3f0e5cf5e2a6b6d4c804 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= +Date: Fri, 24 Apr 2020 16:04:50 +0200 +Subject: [PATCH 5/7] Add RISC-V native-code backend (#9441) + +This is a port of ocamlopt for the RISC-V processor in 64-bit mode. + +(cherry picked from commit 8f3833c4d0ef656c826359f4137c1eb3d46ea0ef) +--- + Changes | 3 + + Makefile | 2 +- + README.adoc | 1 + + asmcomp/riscv/CSE.ml | 39 ++ + asmcomp/riscv/NOTES.md | 18 + + asmcomp/riscv/arch.ml | 87 +++++ + asmcomp/riscv/emit.mlp | 684 +++++++++++++++++++++++++++++++++ + asmcomp/riscv/proc.ml | 334 ++++++++++++++++ + asmcomp/riscv/reload.ml | 19 + + asmcomp/riscv/scheduling.ml | 22 ++ + asmcomp/riscv/selection.ml | 75 ++++ + configure | 8 +- + configure.ac | 9 +- + runtime/caml/stack.h | 5 + + runtime/riscv.S | 423 ++++++++++++++++++++ + testsuite/tools/asmgen_riscv.S | 89 +++++ + 16 files changed, 1812 insertions(+), 6 deletions(-) + create mode 100644 asmcomp/riscv/CSE.ml + create mode 100644 asmcomp/riscv/NOTES.md + create mode 100644 asmcomp/riscv/arch.ml + create mode 100644 asmcomp/riscv/emit.mlp + create mode 100644 asmcomp/riscv/proc.ml + create mode 100644 asmcomp/riscv/reload.ml + create mode 100644 asmcomp/riscv/scheduling.ml + create mode 100644 asmcomp/riscv/selection.ml + create mode 100644 runtime/riscv.S + create mode 100644 testsuite/tools/asmgen_riscv.S + +diff --git a/Changes b/Changes +index d92ade2df..b7336c154 100644 +--- a/Changes ++++ b/Changes +@@ -121,6 +121,9 @@ OCaml 4.11 + - #9392: Visit registers at most once in Coloring.iter_preferred. + (Stephen Dolan, review by Pierre Chambart and Xavier Leroy) + ++- #9441: Add RISC-V RV64G native-code backend. ++ (Nicolás Ojeda Bär, review by Xavier Leroy and Gabriel Scherer) ++ + ### Standard library: + + - #9077: Add Seq.cons and Seq.append +diff --git a/Makefile b/Makefile +index fc9b179a4..2984178a8 100644 +--- a/Makefile ++++ b/Makefile +@@ -51,7 +51,7 @@ include stdlib/StdlibModules + + CAMLC=$(BOOT_OCAMLC) -g -nostdlib -I boot -use-prims runtime/primitives + CAMLOPT=$(CAMLRUN) ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink +-ARCHES=amd64 i386 arm arm64 power s390x ++ARCHES=amd64 i386 arm arm64 power s390x riscv + INCLUDES=-I utils -I parsing -I typing -I bytecomp -I file_formats \ + -I lambda -I middle_end -I middle_end/closure \ + -I middle_end/flambda -I middle_end/flambda/base_types \ +diff --git a/README.adoc b/README.adoc +index 84eb169b2..4365c2f12 100644 +--- a/README.adoc ++++ b/README.adoc +@@ -62,6 +62,7 @@ compiler currently runs on the following platforms: + | ARM 32 bits | Linux | FreeBSD, NetBSD, OpenBSD + | Power 64 bits | Linux | + | Power 32 bits | | Linux ++| RISC-V 64 bits | Linux | + | IBM Z (s390x) | Linux | + |==== + +diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml +new file mode 100644 +index 000000000..6aed1c07f +--- /dev/null ++++ b/asmcomp/riscv/CSE.ml +@@ -0,0 +1,39 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* CSE for the RISC-V *) ++ ++open Arch ++open Mach ++open CSEgen ++ ++class cse = object (_self) ++ ++inherit cse_generic as super ++ ++method! class_of_operation op = ++ match op with ++ | Ispecific(Imultaddf _ | Imultsubf _) -> Op_pure ++ | _ -> super#class_of_operation op ++ ++method! is_cheap_operation op = ++ match op with ++ | Iconst_int n -> n <= 0x7FFn && n >= -0x800n ++ | _ -> false ++ ++end ++ ++let fundecl f = ++ (new cse)#fundecl f +diff --git a/asmcomp/riscv/NOTES.md b/asmcomp/riscv/NOTES.md +new file mode 100644 +index 000000000..3b00d08ec +--- /dev/null ++++ b/asmcomp/riscv/NOTES.md +@@ -0,0 +1,18 @@ ++# Supported platforms ++ ++RISC-V in 64-bit mode, general variant, a.k.a `RV64G`. ++ ++Debian architecture name: `riscv64` ++ ++# Reference documents ++ ++* Instruction set specification: ++ - https://riscv.org/specifications/isa-spec-pdf/ ++ - https://rv8.io/isa ++ ++* ELF ABI specification: ++ - https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md ++ ++* Assembly language manual ++ - https://github.com/riscv/riscv-asm-manual/blob/master/riscv-asm.md ++ - https://rv8.io/asm +diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml +new file mode 100644 +index 000000000..c6ade5279 +--- /dev/null ++++ b/asmcomp/riscv/arch.ml +@@ -0,0 +1,87 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* Specific operations for the RISC-V processor *) ++ ++open Format ++ ++(* Machine-specific command-line options *) ++ ++let command_line_options = [] ++ ++(* Specific operations *) ++ ++type specific_operation = ++ | Imultaddf of bool (* multiply, optionally negate, and add *) ++ | Imultsubf of bool (* multiply, optionally negate, and subtract *) ++ ++let spacetime_node_hole_pointer_is_live_before = function ++ | Imultaddf _ | Imultsubf _ -> false ++ ++(* Addressing modes *) ++ ++type addressing_mode = ++ | Iindexed of int (* reg + displ *) ++ ++let is_immediate n = ++ (n <= 0x7FF) && (n >= -0x800) ++ ++(* Sizes, endianness *) ++ ++let big_endian = false ++ ++let size_addr = 8 ++let size_int = size_addr ++let size_float = 8 ++ ++let allow_unaligned_access = false ++ ++(* Behavior of division *) ++ ++let division_crashes_on_overflow = false ++ ++(* Operations on addressing modes *) ++ ++let identity_addressing = Iindexed 0 ++ ++let offset_addressing addr delta = ++ match addr with ++ | Iindexed n -> Iindexed(n + delta) ++ ++let num_args_addressing = function ++ | Iindexed _ -> 1 ++ ++(* Printing operations and addressing modes *) ++ ++let print_addressing printreg addr ppf arg = ++ match addr with ++ | Iindexed n -> ++ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in ++ fprintf ppf "%a%s" printreg arg.(0) idx ++ ++let print_specific_operation printreg op ppf arg = ++ match op with ++ | Imultaddf false -> ++ fprintf ppf "%a *f %a +f %a" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultaddf true -> ++ fprintf ppf "-f (%a *f %a +f %a)" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultsubf false -> ++ fprintf ppf "%a *f %a -f %a" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultsubf true -> ++ fprintf ppf "-f (%a *f %a -f %a)" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +new file mode 100644 +index 000000000..dc652de42 +--- /dev/null ++++ b/asmcomp/riscv/emit.mlp +@@ -0,0 +1,684 @@ ++# 2 "asmcomp/riscv/emit.mlp" ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* Emission of RISC-V assembly code *) ++ ++open Cmm ++open Arch ++open Proc ++open Reg ++open Mach ++open Linear ++open Emitaux ++ ++(* Layout of the stack. The stack is kept 16-aligned. *) ++ ++let stack_offset = ref 0 ++ ++let num_stack_slots = Array.make Proc.num_register_classes 0 ++ ++let prologue_required = ref false ++ ++let contains_calls = ref false ++ ++let frame_size () = ++ let size = ++ !stack_offset + (* Trap frame, outgoing parameters *) ++ size_int * num_stack_slots.(0) + (* Local int variables *) ++ size_float * num_stack_slots.(1) + (* Local float variables *) ++ (if !contains_calls then size_addr else 0) in (* The return address *) ++ Misc.align size 16 ++ ++let slot_offset loc cls = ++ match loc with ++ | Local n -> ++ if cls = 0 ++ then !stack_offset + num_stack_slots.(1) * size_float + n * size_int ++ else !stack_offset + n * size_float ++ | Incoming n -> frame_size() + n ++ | Outgoing n -> n ++ ++(* Output a symbol *) ++ ++let emit_symbol s = ++ emit_symbol '$' s ++ ++let emit_jump op s = ++ if !Clflags.dlcode || !Clflags.pic_code ++ then `{emit_string op} {emit_symbol s}@plt` ++ else `{emit_string op} {emit_symbol s}` ++ ++let emit_call = emit_jump "call" ++let emit_tail = emit_jump "tail" ++ ++(* Output a label *) ++ ++let emit_label lbl = ++ emit_string ".L"; emit_int lbl ++ ++(* Section switching *) ++ ++let data_space = ++ ".section .data" ++ ++let code_space = ++ ".section .text" ++ ++let rodata_space = ++ ".section .rodata" ++ ++(* Names for special regs *) ++ ++let reg_tmp = phys_reg 22 ++let reg_t2 = phys_reg 16 ++let reg_domain_state_ptr = phys_reg 23 ++let reg_trap = phys_reg 24 ++let reg_alloc_ptr = phys_reg 25 ++let reg_alloc_lim = phys_reg 26 ++ ++(* Output a pseudo-register *) ++ ++let reg_name = function ++ | {loc = Reg r} -> register_name r ++ | _ -> Misc.fatal_error "Emit.reg_name" ++ ++let emit_reg r = ++ emit_string (reg_name r) ++ ++(* Adjust sp by the given byte amount *) ++ ++let emit_stack_adjustment = function ++ | 0 -> () ++ | n when is_immediate n -> ++ ` addi sp, sp, {emit_int n}\n` ++ | n -> ++ ` li {emit_reg reg_tmp}, {emit_int n}\n`; ++ ` add sp, sp, {emit_reg reg_tmp}\n` ++ ++let emit_mem_op op src ofs = ++ if is_immediate ofs then ++ ` {emit_string op} {emit_string src}, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp}, sp, {emit_reg reg_tmp}\n`; ++ ` {emit_string op} {emit_string src}, 0({emit_reg reg_tmp})\n` ++ end ++ ++let emit_store src ofs = ++ emit_mem_op "sd" src ofs ++ ++let emit_load dst ofs = ++ emit_mem_op "ld" dst ofs ++ ++let reload_ra n = ++ emit_load "ra" (n - size_addr) ++ ++let store_ra n = ++ emit_store "ra" (n - size_addr) ++ ++let emit_store src ofs = ++ emit_store (reg_name src) ofs ++ ++let emit_load dst ofs = ++ emit_load (reg_name dst) ofs ++ ++let emit_float_load dst ofs = ++ emit_mem_op "fld" (reg_name dst) ofs ++ ++let emit_float_store src ofs = ++ emit_mem_op "fsd" (reg_name src) ofs ++ ++(* Record live pointers at call points *) ++ ++let record_frame_label ?label live dbg = ++ let lbl = ++ match label with ++ | None -> new_label() ++ | Some label -> label ++ in ++ let live_offset = ref [] in ++ Reg.Set.iter ++ (function ++ {typ = Val; loc = Reg r} -> ++ live_offset := (r lsl 1) + 1 :: !live_offset ++ | {typ = Val; loc = Stack s} as reg -> ++ live_offset := slot_offset s (register_class reg) :: !live_offset ++ | {typ = Addr} as r -> ++ Misc.fatal_error ("bad GC root " ^ Reg.name r) ++ | _ -> () ++ ) ++ live; ++ record_frame_descr ~label:lbl ~frame_size:(frame_size()) ++ ~live_offset:!live_offset dbg; ++ lbl ++ ++let record_frame ?label live dbg = ++ let lbl = record_frame_label ?label live dbg in ++ `{emit_label lbl}:\n` ++ ++(* Record calls to the GC -- we've moved them out of the way *) ++ ++type gc_call = ++ { gc_lbl: label; (* Entry label *) ++ gc_return_lbl: label; (* Where to branch after GC *) ++ gc_frame_lbl: label } (* Label of frame descriptor *) ++ ++let call_gc_sites = ref ([] : gc_call list) ++ ++let emit_call_gc gc = ++ `{emit_label gc.gc_lbl}:\n`; ++ ` {emit_call "caml_call_gc"}\n`; ++ `{emit_label gc.gc_frame_lbl}:\n`; ++ ` j {emit_label gc.gc_return_lbl}\n` ++ ++(* Record calls to caml_ml_array_bound_error. ++ In debug mode, we maintain one call to caml_ml_array_bound_error ++ per bound check site. Otherwise, we can share a single call. *) ++ ++type bound_error_call = ++ { bd_lbl: label; (* Entry label *) ++ bd_frame_lbl: label } (* Label of frame descriptor *) ++ ++let bound_error_sites = ref ([] : bound_error_call list) ++ ++let bound_error_label ?label dbg = ++ if !Clflags.debug || !bound_error_sites = [] then begin ++ let lbl_bound_error = new_label() in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in ++ bound_error_sites := ++ { bd_lbl = lbl_bound_error; ++ bd_frame_lbl = lbl_frame } :: !bound_error_sites; ++ lbl_bound_error ++ end else ++ let bd = List.hd !bound_error_sites in ++ bd.bd_lbl ++ ++let emit_call_bound_error bd = ++ `{emit_label bd.bd_lbl}:\n`; ++ ` {emit_call "caml_ml_array_bound_error"}\n`; ++ `{emit_label bd.bd_frame_lbl}:\n` ++ ++(* Record floating-point literals *) ++ ++let float_literals = ref ([] : (int64 * int) list) ++ ++(* Names for various instructions *) ++ ++let name_for_intop = function ++ | Iadd -> "add" ++ | Isub -> "sub" ++ | Imul -> "mul" ++ | Imulh -> "mulh" ++ | Idiv -> "div" ++ | Iand -> "and" ++ | Ior -> "or" ++ | Ixor -> "xor" ++ | Ilsl -> "sll" ++ | Ilsr -> "srl" ++ | Iasr -> "sra" ++ | Imod -> "rem" ++ | _ -> Misc.fatal_error "Emit.Intop" ++ ++let name_for_intop_imm = function ++ | Iadd -> "addi" ++ | Iand -> "andi" ++ | Ior -> "ori" ++ | Ixor -> "xori" ++ | Ilsl -> "slli" ++ | Ilsr -> "srli" ++ | Iasr -> "srai" ++ | _ -> Misc.fatal_error "Emit.Intop_imm" ++ ++let name_for_floatop1 = function ++ | Inegf -> "fneg.d" ++ | Iabsf -> "fabs.d" ++ | _ -> Misc.fatal_error "Emit.Iopf1" ++ ++let name_for_floatop2 = function ++ | Iaddf -> "fadd.d" ++ | Isubf -> "fsub.d" ++ | Imulf -> "fmul.d" ++ | Idivf -> "fdiv.d" ++ | _ -> Misc.fatal_error "Emit.Iopf2" ++ ++let name_for_specific = function ++ | Imultaddf false -> "fmadd.d" ++ | Imultaddf true -> "fnmadd.d" ++ | Imultsubf false -> "fmsub.d" ++ | Imultsubf true -> "fnmsub.d" ++ ++(* Name of current function *) ++let function_name = ref "" ++ ++(* Entry point for tail recursive calls *) ++let tailrec_entry_point = ref 0 ++ ++(* Output the assembly code for an instruction *) ++ ++let emit_instr i = ++ emit_debug_info i.dbg; ++ match i.desc with ++ Lend -> () ++ | Lprologue -> ++ assert (!prologue_required); ++ let n = frame_size() in ++ emit_stack_adjustment (-n); ++ if !contains_calls then store_ra n ++ | Lop(Imove | Ispill | Ireload) -> ++ let src = i.arg.(0) and dst = i.res.(0) in ++ if src.loc <> dst.loc then begin ++ match (src, dst) with ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> ++ ` mv {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = Float}, {loc = Reg _} -> ++ ` fmv.d {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> ++ let ofs = slot_offset s (register_class dst) in ++ emit_store src ofs ++ | {loc = Reg _; typ = Float}, {loc = Stack s} -> ++ let ofs = slot_offset s (register_class dst) in ++ emit_float_store src ofs ++ | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> ++ let ofs = slot_offset s (register_class src) in ++ emit_load dst ofs ++ | {loc = Stack s; typ = Float}, {loc = Reg _} -> ++ let ofs = slot_offset s (register_class src) in ++ emit_float_load dst ofs ++ | {loc = Stack _}, {loc = Stack _} ++ | {loc = Unknown}, _ | _, {loc = Unknown} -> ++ Misc.fatal_error "Emit: Imove" ++ end ++ | Lop(Iconst_int n) -> ++ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` ++ | Lop(Iconst_float f) -> ++ let lbl = new_label() in ++ float_literals := (f, lbl) :: !float_literals; ++ ` fld {emit_reg i.res.(0)}, {emit_label lbl}, {emit_reg reg_tmp}\n` ++ | Lop(Iconst_symbol s) -> ++ ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` ++ | Lop(Icall_ind {label_after = label}) -> ++ ` jalr {emit_reg i.arg.(0)}\n`; ++ record_frame ~label i.live (Dbg_other i.dbg) ++ | Lop(Icall_imm {func; label_after = label}) -> ++ ` {emit_call func}\n`; ++ record_frame ~label i.live (Dbg_other i.dbg) ++ | Lop(Itailcall_ind {label_after = _}) -> ++ let n = frame_size() in ++ if !contains_calls then reload_ra n; ++ emit_stack_adjustment n; ++ ` jr {emit_reg i.arg.(0)}\n` ++ | Lop(Itailcall_imm {func; label_after = _}) -> ++ if func = !function_name then begin ++ ` j {emit_label !tailrec_entry_point}\n` ++ end else begin ++ let n = frame_size() in ++ if !contains_calls then reload_ra n; ++ emit_stack_adjustment n; ++ ` {emit_tail func}\n` ++ end ++ | Lop(Iextcall{func; alloc = true; label_after = label}) -> ++ ` la {emit_reg reg_t2}, {emit_symbol func}\n`; ++ ` {emit_call "caml_c_call"}\n`; ++ record_frame ~label i.live (Dbg_other i.dbg) ++ | Lop(Iextcall{func; alloc = false; label_after = _}) -> ++ ` {emit_call func}\n` ++ | Lop(Istackoffset n) -> ++ assert (n mod 16 = 0); ++ emit_stack_adjustment (-n); ++ stack_offset := !stack_offset + n ++ | Lop(Iload(Single, Iindexed ofs)) -> ++ ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; ++ ` fcvt.d.s {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Lop(Iload(chunk, Iindexed ofs)) -> ++ let instr = ++ match chunk with ++ | Byte_unsigned -> "lbu" ++ | Byte_signed -> "lb" ++ | Sixteen_unsigned -> "lhu" ++ | Sixteen_signed -> "lh" ++ | Thirtytwo_unsigned -> "lwu" ++ | Thirtytwo_signed -> "lw" ++ | Word_int | Word_val -> "ld" ++ | Single -> assert false ++ | Double | Double_u -> "fld" ++ in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n` ++ | Lop(Istore(Single, Iindexed ofs, _)) -> ++ (* ft0 is marked as destroyed for this operation *) ++ ` fcvt.s.d ft0, {emit_reg i.arg.(0)}\n`; ++ ` fsw ft0, {emit_int ofs}({emit_reg i.arg.(1)})\n` ++ | Lop(Istore(chunk, Iindexed ofs, _)) -> ++ let instr = ++ match chunk with ++ | Byte_unsigned | Byte_signed -> "sb" ++ | Sixteen_unsigned | Sixteen_signed -> "sh" ++ | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" ++ | Word_int | Word_val -> "sd" ++ | Single -> assert false ++ | Double | Double_u -> "fsd" ++ in ++ ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` ++ | Lop(Ialloc {bytes; label_after_call_gc = label; dbginfo}) -> ++ let lbl_frame_lbl = record_frame_label ?label i.live (Dbg_alloc dbginfo) in ++ let lbl_after_alloc = new_label () in ++ let lbl_call_gc = new_label () in ++ let n = -bytes in ++ if is_immediate n then ++ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_int n}\n` ++ else begin ++ ` li {emit_reg reg_tmp}, {emit_int n}\n`; ++ ` add {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_reg reg_tmp}\n` ++ end; ++ ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; ++ `{emit_label lbl_after_alloc}:\n`; ++ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; ++ call_gc_sites := ++ { gc_lbl = lbl_call_gc; ++ gc_return_lbl = lbl_after_alloc; ++ gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites ++ | Lop(Iintop(Icomp cmp)) -> ++ begin match cmp with ++ | Isigned Clt -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Isigned Cge -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Isigned Cgt -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | Isigned Cle -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Isigned Ceq | Iunsigned Ceq -> ++ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` seqz {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Isigned Cne | Iunsigned Cne -> ++ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` snez {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Iunsigned Clt -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Iunsigned Cge -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Iunsigned Cgt -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | Iunsigned Cle -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ end ++ | Lop(Iintop (Icheckbound {label_after_error = label; _})) -> ++ let lbl = bound_error_label ?label i.dbg in ++ ` bleu {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` ++ | Lop(Iintop op) -> ++ let instr = name_for_intop op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Lop(Iintop_imm(Isub, n)) -> ++ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` ++ | Lop(Iintop_imm(Icomp _, _)) -> ++ Misc.fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" ++ | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> ++ let lbl = bound_error_label ?label i.dbg in ++ ` li {emit_reg reg_tmp}, {emit_int n}\n`; ++ ` bleu {emit_reg i.arg.(0)}, {emit_reg reg_tmp}, {emit_label lbl}\n` ++ | Lop(Iintop_imm(op, n)) -> ++ let instr = name_for_intop_imm op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` ++ | Lop(Inegf | Iabsf as op) -> ++ let instr = name_for_floatop1 op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> ++ let instr = name_for_floatop2 op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Lop(Ifloatofint) -> ++ ` fcvt.d.l {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Iintoffloat) -> ++ ` fcvt.l.d {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, rtz\n` ++ | Lop(Ispecific sop) -> ++ let instr = name_for_specific sop in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` ++ | Lop (Iname_for_debugger _) -> ++ () ++ | Lreloadretaddr -> ++ let n = frame_size () in ++ reload_ra n ++ | Lreturn -> ++ let n = frame_size() in ++ emit_stack_adjustment n; ++ ` ret\n` ++ | Llabel lbl -> ++ `{emit_label lbl}:\n` ++ | Lbranch lbl -> ++ ` j {emit_label lbl}\n` ++ | Lcondbranch(tst, lbl) -> ++ begin match tst with ++ | Itruetest -> ++ ` bnez {emit_reg i.arg.(0)}, {emit_label lbl}\n` ++ | Ifalsetest -> ++ ` beqz {emit_reg i.arg.(0)}, {emit_label lbl}\n` ++ | Iinttest cmp -> ++ let name = match cmp with ++ | Iunsigned Ceq | Isigned Ceq -> "beq" ++ | Iunsigned Cne | Isigned Cne -> "bne" ++ | Iunsigned Cle -> "bleu" | Isigned Cle -> "ble" ++ | Iunsigned Cge -> "bgeu" | Isigned Cge -> "bge" ++ | Iunsigned Clt -> "bltu" | Isigned Clt -> "blt" ++ | Iunsigned Cgt -> "bgtu" | Isigned Cgt -> "bgt" ++ in ++ ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` ++ | Iinttest_imm _ -> ++ Misc.fatal_error "Emit.emit_instr (Iinttest_imm _)" ++ | Ifloattest cmp -> ++ let branch = ++ match cmp with ++ | CFneq | CFnlt | CFngt | CFnle | CFnge -> "beqz" ++ | CFeq | CFlt | CFgt | CFle | CFge -> "bnez" ++ in ++ begin match cmp with ++ | CFeq | CFneq -> ` feq.d {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | CFlt | CFnlt -> ` flt.d {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | CFgt | CFngt -> ` flt.d {emit_reg reg_tmp}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | CFle | CFnle -> ` fle.d {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | CFge | CFnge -> ` fle.d {emit_reg reg_tmp}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ end; ++ ` {emit_string branch} {emit_reg reg_tmp}, {emit_label lbl}\n` ++ | Ioddtest -> ++ ` andi {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, 1\n`; ++ ` bnez {emit_reg reg_tmp}, {emit_label lbl}\n` ++ | Ieventest -> ++ ` andi {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, 1\n`; ++ ` beqz {emit_reg reg_tmp}, {emit_label lbl}\n` ++ end ++ | Lcondbranch3(lbl0, lbl1, lbl2) -> ++ ` addi {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, -1\n`; ++ begin match lbl0 with ++ | None -> () ++ | Some lbl -> ` bltz {emit_reg reg_tmp}, {emit_label lbl}\n` ++ end; ++ begin match lbl1 with ++ | None -> () ++ | Some lbl -> ` beqz {emit_reg reg_tmp}, {emit_label lbl}\n` ++ end; ++ begin match lbl2 with ++ | None -> () ++ | Some lbl -> ` bgtz {emit_reg reg_tmp}, {emit_label lbl}\n` ++ end ++ | Lswitch jumptbl -> ++ (* t0 is marked as destroyed for this operation *) ++ let lbl = new_label() in ++ ` la {emit_reg reg_tmp}, {emit_label lbl}\n`; ++ ` slli t0, {emit_reg i.arg.(0)}, 2\n`; ++ ` add {emit_reg reg_tmp}, {emit_reg reg_tmp}, t0\n`; ++ ` jr {emit_reg reg_tmp}\n`; ++ `{emit_label lbl}:\n`; ++ for i = 0 to Array.length jumptbl - 1 do ++ ` j {emit_label jumptbl.(i)}\n` ++ done ++ | Lentertrap -> ++ () ++ | Ladjust_trap_depth { delta_traps } -> ++ (* each trap occupes 16 bytes on the stack *) ++ let delta = 16 * delta_traps in ++ stack_offset := !stack_offset + delta ++ | Lpushtrap {lbl_handler} -> ++ ` la {emit_reg reg_tmp}, {emit_label lbl_handler}\n`; ++ ` addi sp, sp, -16\n`; ++ stack_offset := !stack_offset + 16; ++ emit_store reg_tmp size_addr; ++ emit_store reg_trap 0; ++ ` mv {emit_reg reg_trap}, sp\n` ++ | Lpoptrap -> ++ emit_load reg_trap 0; ++ ` addi sp, sp, 16\n`; ++ stack_offset := !stack_offset - 16 ++ | Lraise k -> ++ begin match k with ++ | Lambda.Raise_regular -> ++ let offset = Domainstate.(idx_of_field Domain_backtrace_pos) * 8 in ++ ` sd zero, {emit_int offset}({emit_reg reg_domain_state_ptr})\n`; ++ ` {emit_call "caml_raise_exn"}\n`; ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) ++ | Lambda.Raise_reraise -> ++ ` {emit_call "caml_raise_exn"}\n`; ++ record_frame Reg.Set.empty (Dbg_raise i.dbg) ++ | Lambda.Raise_notrace -> ++ ` mv sp, {emit_reg reg_trap}\n`; ++ emit_load reg_tmp size_addr; ++ emit_load reg_trap 0; ++ ` addi sp, sp, 16\n`; ++ ` jr {emit_reg reg_tmp}\n` ++ end ++ ++(* Emit a sequence of instructions *) ++ ++let rec emit_all = function ++ | {desc = Lend} -> () | i -> emit_instr i; emit_all i.next ++ ++(* Emission of a function declaration *) ++ ++let fundecl fundecl = ++ function_name := fundecl.fun_name; ++ tailrec_entry_point := fundecl.fun_tailrec_entry_point_label; ++ stack_offset := 0; ++ call_gc_sites := []; ++ bound_error_sites := []; ++ for i = 0 to Proc.num_register_classes - 1 do ++ num_stack_slots.(i) <- fundecl.fun_num_stack_slots.(i); ++ done; ++ prologue_required := fundecl.fun_prologue_required; ++ contains_calls := fundecl.fun_contains_calls; ++ float_literals := []; ++ ` .globl {emit_symbol fundecl.fun_name}\n`; ++ ` .type {emit_symbol fundecl.fun_name}, @function\n`; ++ ` {emit_string code_space}\n`; ++ ` .align 2\n`; ++ `{emit_symbol fundecl.fun_name}:\n`; ++ emit_debug_info fundecl.fun_dbg; ++ emit_all fundecl.fun_body; ++ List.iter emit_call_gc !call_gc_sites; ++ List.iter emit_call_bound_error !bound_error_sites; ++ ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; ++ (* Emit the float literals *) ++ if !float_literals <> [] then begin ++ ` {emit_string rodata_space}\n`; ++ ` .align 3\n`; ++ List.iter ++ (fun (f, lbl) -> ++ `{emit_label lbl}:\n`; ++ emit_float64_directive ".quad" f) ++ !float_literals; ++ end ++ ++(* Emission of data *) ++ ++let declare_global_data s = ++ ` .globl {emit_symbol s}\n`; ++ ` .type {emit_symbol s}, @object\n` ++ ++let emit_item = function ++ | Cglobal_symbol s -> ++ declare_global_data s ++ | Cdefine_symbol s -> ++ `{emit_symbol s}:\n`; ++ | Cint8 n -> ++ ` .byte {emit_int n}\n` ++ | Cint16 n -> ++ ` .short {emit_int n}\n` ++ | Cint32 n -> ++ ` .long {emit_nativeint n}\n` ++ | Cint n -> ++ ` .quad {emit_nativeint n}\n` ++ | Csingle f -> ++ emit_float32_directive ".long" (Int32.bits_of_float f) ++ | Cdouble f -> ++ emit_float64_directive ".quad" (Int64.bits_of_float f) ++ | Csymbol_address s -> ++ ` .quad {emit_symbol s}\n` ++ | Cstring s -> ++ emit_bytes_directive " .byte " s ++ | Cskip n -> ++ if n > 0 then ` .space {emit_int n}\n` ++ | Calign n -> ++ ` .align {emit_int (Misc.log2 n)}\n` ++ ++let data l = ++ ` {emit_string data_space}\n`; ++ List.iter emit_item l ++ ++(* Beginning / end of an assembly file *) ++ ++let begin_assembly() = ++ if !Clflags.dlcode || !Clflags.pic_code then ` .option pic\n`; ++ ` .file \"\"\n`; (* PR#7073 *) ++ reset_debug_info (); ++ (* Emit the beginning of the segments *) ++ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in ++ ` {emit_string data_space}\n`; ++ declare_global_data lbl_begin; ++ `{emit_symbol lbl_begin}:\n`; ++ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in ++ ` {emit_string code_space}\n`; ++ declare_global_data lbl_begin; ++ `{emit_symbol lbl_begin}:\n` ++ ++let end_assembly() = ++ ` {emit_string code_space}\n`; ++ let lbl_end = Compilenv.make_symbol (Some "code_end") in ++ declare_global_data lbl_end; ++ `{emit_symbol lbl_end}:\n`; ++ ` .long 0\n`; ++ ` {emit_string data_space}\n`; ++ let lbl_end = Compilenv.make_symbol (Some "data_end") in ++ declare_global_data lbl_end; ++ ` .quad 0\n`; (* PR#6329 *) ++ `{emit_symbol lbl_end}:\n`; ++ ` .quad 0\n`; ++ (* Emit the frame descriptors *) ++ ` {emit_string rodata_space}\n`; ++ let lbl = Compilenv.make_symbol (Some "frametable") in ++ declare_global_data lbl; ++ `{emit_symbol lbl}:\n`; ++ emit_frames ++ { efa_code_label = (fun l -> ` .quad {emit_label l}\n`); ++ efa_data_label = (fun l -> ` .quad {emit_label l}\n`); ++ efa_8 = (fun n -> ` .byte {emit_int n}\n`); ++ efa_16 = (fun n -> ` .short {emit_int n}\n`); ++ efa_32 = (fun n -> ` .long {emit_int32 n}\n`); ++ efa_word = (fun n -> ` .quad {emit_int n}\n`); ++ efa_align = (fun n -> ` .align {emit_int (Misc.log2 n)}\n`); ++ efa_label_rel = (fun lbl ofs -> ++ ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); ++ efa_def_label = (fun l -> `{emit_label l}:\n`); ++ efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) ++ } +diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml +new file mode 100644 +index 000000000..70909cd83 +--- /dev/null ++++ b/asmcomp/riscv/proc.ml +@@ -0,0 +1,334 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* Description of the RISC-V *) ++ ++open Misc ++open Cmm ++open Reg ++open Arch ++open Mach ++ ++(* Instruction selection *) ++ ++let word_addressed = false ++ ++(* Registers available for register allocation *) ++ ++(* Integer register map ++ -------------------- ++ ++ zero always zero ++ ra return address ++ sp, gp, tp stack pointer, global pointer, thread pointer ++ a0-a7 0-7 arguments/results ++ s2-s9 8-15 arguments/results (preserved by C) ++ t2-t6 16-20 temporary ++ t0-t1 21-22 temporary (used by code generator) ++ s0 23 domain pointer (preserved by C) ++ s1 24 trap pointer (preserved by C) ++ s10 25 allocation pointer (preserved by C) ++ s11 26 allocation limit (preserved by C) ++ ++ Floating-point register map ++ --------------------------- ++ ++ ft0-ft7 100-107 temporary ++ fs0-fs1 108-109 general purpose (preserved by C) ++ fa0-fa7 110-117 arguments/results ++ fs2-fs9 118-125 arguments/results (preserved by C) ++ fs10-fs11 126-127 general purpose (preserved by C) ++ ft8-ft11 128-131 temporary ++ ++ Additional notes ++ ---------------- ++ ++ - t0-t1 are used by the assembler and code generator, so ++ not available for register allocation. ++ ++ - t0-t6 may be used by PLT stubs, so should not be used to pass ++ arguments and may be clobbered by [Ialloc] in the presence of dynamic ++ linking. ++*) ++ ++let int_reg_name = ++ [| "a0"; "a1"; "a2"; "a3"; "a4"; "a5"; "a6"; "a7"; ++ "s2"; "s3"; "s4"; "s5"; "s6"; "s7"; "s8"; "s9"; ++ "t2"; "t3"; "t4"; "t5"; "t6"; ++ "t0"; "t1"; ++ "s0"; "s1"; "s10"; "s11" |] ++ ++let float_reg_name = ++ [| "ft0"; "ft1"; "ft2"; "ft3"; "ft4"; "ft5"; "ft6"; "ft7"; ++ "fs0"; "fs1"; ++ "fa0"; "fa1"; "fa2"; "fa3"; "fa4"; "fa5"; "fa6"; "fa7"; ++ "fs2"; "fs3"; "fs4"; "fs5"; "fs6"; "fs7"; "fs8"; "fs9"; "fs10"; "fs11"; ++ "ft8"; "ft9"; "ft10"; "ft11" |] ++ ++let num_register_classes = 2 ++ ++let register_class r = ++ match r.typ with ++ | Val | Int | Addr -> 0 ++ | Float -> 1 ++ ++let num_available_registers = [| 22; 32 |] ++ ++let first_available_register = [| 0; 100 |] ++ ++let register_name r = ++ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) ++ ++let rotate_registers = true ++ ++(* Representation of hard registers by pseudo-registers *) ++ ++let hard_int_reg = ++ let v = Array.make 27 Reg.dummy in ++ for i = 0 to 26 do ++ v.(i) <- Reg.at_location Int (Reg i) ++ done; ++ v ++ ++let hard_float_reg = ++ let v = Array.make 32 Reg.dummy in ++ for i = 0 to 31 do ++ v.(i) <- Reg.at_location Float (Reg(100 + i)) ++ done; ++ v ++ ++let all_phys_regs = ++ Array.append hard_int_reg hard_float_reg ++ ++let phys_reg n = ++ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) ++ ++let stack_slot slot ty = ++ Reg.at_location ty (Stack slot) ++ ++(* Calling conventions *) ++ ++let calling_conventions ++ first_int last_int first_float last_float make_stack arg = ++ let loc = Array.make (Array.length arg) Reg.dummy in ++ let int = ref first_int in ++ let float = ref first_float in ++ let ofs = ref 0 in ++ for i = 0 to Array.length arg - 1 do ++ match arg.(i).typ with ++ | Val | Int | Addr as ty -> ++ if !int <= last_int then begin ++ loc.(i) <- phys_reg !int; ++ incr int ++ end else begin ++ loc.(i) <- stack_slot (make_stack !ofs) ty; ++ ofs := !ofs + size_int ++ end ++ | Float -> ++ if !float <= last_float then begin ++ loc.(i) <- phys_reg !float; ++ incr float ++ end else begin ++ loc.(i) <- stack_slot (make_stack !ofs) Float; ++ ofs := !ofs + size_float ++ end ++ done; ++ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) ++ ++let incoming ofs = Incoming ofs ++let outgoing ofs = Outgoing ofs ++let not_supported _ = fatal_error "Proc.loc_results: cannot call" ++ ++let max_arguments_for_tailcalls = 16 ++ ++let loc_spacetime_node_hole = Reg.dummy (* Spacetime unsupported *) ++ ++(* OCaml calling convention: ++ first integer args in a0 .. a7, s2 .. s9 ++ first float args in fa0 .. fa7, fs2 .. fs9 ++ remaining args on stack. ++ Return values in a0 .. a7, s2 .. s9 or fa0 .. fa7, fs2 .. fs9. *) ++ ++let single_regs arg = Array.map (fun arg -> [| arg |]) arg ++let ensure_single_regs res = ++ Array.map (function ++ | [| res |] -> res ++ | _ -> failwith "proc.ensure_single_regs" ++ ) res ++ ++let loc_arguments arg = ++ calling_conventions 0 15 110 125 outgoing arg ++ ++let loc_parameters arg = ++ let (loc, _ofs) = ++ calling_conventions 0 15 110 125 incoming arg ++ in ++ loc ++ ++let loc_results res = ++ let (loc, _ofs) = ++ calling_conventions 0 15 110 125 not_supported res ++ in ++ loc ++ ++(* C calling convention: ++ first integer args in a0 .. a7 ++ first float args in fa0 .. fa7 ++ remaining args on stack. ++ Return values in a0 .. a1 or fa0 .. fa1. *) ++ ++let external_calling_conventions ++ first_int last_int first_float last_float make_stack arg = ++ let loc = Array.make (Array.length arg) [| Reg.dummy |] in ++ let int = ref first_int in ++ let float = ref first_float in ++ let ofs = ref 0 in ++ for i = 0 to Array.length arg - 1 do ++ match arg.(i) with ++ | [| arg |] -> ++ begin match arg.typ with ++ | Val | Int | Addr as ty -> ++ if !int <= last_int then begin ++ loc.(i) <- [| phys_reg !int |]; ++ incr int; ++ incr float; ++ end else begin ++ loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; ++ ofs := !ofs + size_int ++ end ++ | Float -> ++ if !float <= last_float then begin ++ loc.(i) <- [| phys_reg !float |]; ++ incr float; ++ incr int; ++ end else begin ++ loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; ++ ofs := !ofs + size_float ++ end ++ end ++ | _ -> ++ fatal_error "Proc.calling_conventions: bad number of register for \ ++ multi-register argument" ++ done; ++ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) ++ ++let loc_external_arguments arg = ++ external_calling_conventions 0 7 110 117 outgoing arg ++ ++let loc_external_results res = ++ let (loc, _ofs) = ++ external_calling_conventions 0 1 110 111 not_supported (single_regs res) ++ in ++ ensure_single_regs loc ++ ++(* Exceptions are in a0 *) ++ ++let loc_exn_bucket = phys_reg 0 ++ ++(* Volatile registers: none *) ++ ++let regs_are_volatile _ = false ++ ++(* Registers destroyed by operations *) ++ ++let destroyed_at_c_call = ++ (* s0-s11 and fs0-fs11 are callee-save *) ++ Array.of_list(List.map phys_reg ++ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; 21; ++ 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; ++ 117; 128; 129; 130; 131]) ++ ++let destroyed_at_alloc = ++ (* t0-t3 are used for PLT stubs *) ++ if !Clflags.dlcode then Array.map phys_reg [|16; 17; 18; 19; 20; 21|] ++ else [| |] ++ ++let destroyed_at_oper = function ++ | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs ++ | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call ++ | Iop(Ialloc _) -> destroyed_at_alloc ++ | Iop(Istore(Single, _, _)) -> [| phys_reg 100 |] ++ | Iswitch _ -> [| phys_reg 21 |] ++ | _ -> [||] ++ ++let destroyed_at_raise = all_phys_regs ++ ++let destroyed_at_reloadretaddr = [| |] ++ ++(* Maximal register pressure *) ++ ++let safe_register_pressure = function ++ | Iextcall _ -> 15 ++ | _ -> 22 ++ ++let max_register_pressure = function ++ | Iextcall _ -> [| 15; 18 |] ++ | _ -> [| 22; 30 |] ++ ++(* Pure operations (without any side effect besides updating their result ++ registers). *) ++ ++let op_is_pure = function ++ | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ ++ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ ++ | Iintop(Icheckbound _) | Iintop_imm(Icheckbound _, _) -> false ++ | Ispecific(Imultaddf _ | Imultsubf _) -> true ++ | _ -> true ++ ++(* Layout of the stack *) ++ ++let frame_required fd = ++ fd.fun_contains_calls ++ || fd.fun_num_stack_slots.(0) > 0 ++ || fd.fun_num_stack_slots.(1) > 0 ++ ++let prologue_required fd = ++ frame_required fd ++ ++(* See ++ https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md *) ++ ++let int_dwarf_reg_numbers = ++ [| 10; 11; 12; 13; 14; 15; 16; 17; ++ 18; 19; 20; 21; 22; 23; 24; 25; ++ 7; 28; 29; 30; 31; ++ 5; 6; ++ 8; 9; 26; 27; ++ |] ++ ++let float_dwarf_reg_numbers = ++ [| 32; 33; 34; 35; 36; 37; 38; 39; ++ 40; 41; ++ 42; 43; 44; 45; 46; 47; 48; 49; ++ 50; 51; 52; 53; 54; 55; 56; 57; ++ 58; 59; ++ 60; 61; 62; 63; ++ |] ++ ++let dwarf_register_numbers ~reg_class = ++ match reg_class with ++ | 0 -> int_dwarf_reg_numbers ++ | 1 -> float_dwarf_reg_numbers ++ | _ -> Misc.fatal_errorf "Bad register class %d" reg_class ++ ++let stack_ptr_dwarf_register_number = 2 ++ ++(* Calling the assembler *) ++ ++let assemble_file infile outfile = ++ Ccomp.command ++ (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) ++ ++let init () = () +diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml +new file mode 100644 +index 000000000..be18cbd7f +--- /dev/null ++++ b/asmcomp/riscv/reload.ml +@@ -0,0 +1,19 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* Reloading for the RISC-V *) ++ ++let fundecl f = ++ (new Reloadgen.reload_generic)#fundecl f +diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml +new file mode 100644 +index 000000000..e56b723c5 +--- /dev/null ++++ b/asmcomp/riscv/scheduling.ml +@@ -0,0 +1,22 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* Instruction scheduling for the RISC-V *) ++ ++open! Schedgen (* to create a dependency *) ++ ++(* Scheduling is turned off. *) ++ ++let fundecl f = f +diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml +new file mode 100644 +index 000000000..87d3355de +--- /dev/null ++++ b/asmcomp/riscv/selection.ml +@@ -0,0 +1,75 @@ ++(**************************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. *) ++(* *) ++(* All rights reserved. This file is distributed under the terms of *) ++(* the GNU Lesser General Public License version 2.1, with the *) ++(* special exception on linking described in the file LICENSE. *) ++(* *) ++(**************************************************************************) ++ ++(* Instruction selection for the RISC-V processor *) ++ ++open Cmm ++open Arch ++open Mach ++ ++(* Instruction selection *) ++ ++class selector = object (self) ++ ++inherit Selectgen.selector_generic as super ++ ++method is_immediate n = is_immediate n ++ ++method select_addressing _ = function ++ | Cop(Cadda, [arg; Cconst_int (n, _)], _) when self#is_immediate n -> ++ (Iindexed n, arg) ++ | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int (n, _)], _)], dbg) ++ when self#is_immediate n -> ++ (Iindexed n, Cop(Caddi, [arg1; arg2], dbg)) ++ | arg -> ++ (Iindexed 0, arg) ++ ++method! select_operation op args dbg = ++ match (op, args) with ++ (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) ++ | (Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3]) ++ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2], _)]) -> ++ (Ispecific (Imultaddf false), [arg1; arg2; arg3]) ++ | (Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -> ++ (Ispecific (Imultsubf false), [arg1; arg2; arg3]) ++ | (Cnegf, [Cop(Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> ++ (Ispecific (Imultsubf true), [arg1; arg2; arg3]) ++ | (Cnegf, [Cop(Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> ++ (Ispecific (Imultaddf true), [arg1; arg2; arg3]) ++ (* RISC-V does not support immediate operands for comparison operators *) ++ | (Ccmpi comp, args) -> (Iintop(Icomp (Isigned comp)), args) ++ | (Ccmpa comp, args) -> (Iintop(Icomp (Iunsigned comp)), args) ++ (* RISC-V does not support immediate operands for multiply/multiply high *) ++ | (Cmuli, _) -> (Iintop Imul, args) ++ | (Cmulhi, _) -> (Iintop Imulh, args) ++ | _ -> ++ super#select_operation op args dbg ++ ++(* Instruction selection for conditionals *) ++ ++method! select_condition = function ++ Cop(Ccmpi cmp, args, _) -> ++ (Iinttest(Isigned cmp), Ctuple args) ++ | Cop(Ccmpa cmp, args, _) -> ++ (Iinttest(Iunsigned cmp), Ctuple args) ++ | Cop(Ccmpf cmp, args, _) -> ++ (Ifloattest cmp, Ctuple args) ++ | Cop(Cand, [arg; Cconst_int (1, _)], _) -> ++ (Ioddtest, arg) ++ | arg -> ++ (Itruetest, arg) ++end ++ ++let fundecl f = (new selector)#emit_fundecl f +diff --git a/configure b/configure +index 32cb19b3b..12e08bba2 100755 +--- a/configure ++++ b/configure +@@ -13578,6 +13578,8 @@ if test x"$enable_shared" != "xno"; then : + natdynlink=true ;; #( + aarch64-*-freebsd*) : + natdynlink=true ;; #( ++ riscv*-*-linux*) : ++ natdynlink=true ;; #( + *) : + ;; + esac +@@ -13718,7 +13720,9 @@ fi; system=elf ;; #( + aarch64-*-freebsd*) : + arch=arm64; system=freebsd ;; #( + x86_64-*-cygwin*) : +- arch=amd64; system=cygwin ++ arch=amd64; system=cygwin ;; #( ++ riscv64-*-linux*) : ++ arch=riscv; model=riscv64; system=linux + ;; #( + *) : + ;; +@@ -13952,7 +13956,7 @@ esac ;; #( + *,dragonfly) : + default_as="${toolpref}as" + default_aspp="${toolpref}cc -c" ;; #( +- amd64,*|arm,*|arm64,*|i386,*) : ++ amd64,*|arm,*|arm64,*|i386,*|riscv,*) : + case $ocaml_cv_cc_vendor in #( + clang-*) : + default_as="${toolpref}clang -c -Wno-trigraphs" +diff --git a/configure.ac b/configure.ac +index 4c9358897..b7e0731e0 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -868,7 +868,8 @@ AS_IF([test x"$enable_shared" != "xno"], + [arm*-*-freebsd*], [natdynlink=true], + [earm*-*-netbsd*], [natdynlink=true], + [aarch64-*-linux*], [natdynlink=true], +- [aarch64-*-freebsd*], [natdynlink=true])]) ++ [aarch64-*-freebsd*], [natdynlink=true], ++ [riscv*-*-linux*], [natdynlink=true])]) + + # Try to work around the Skylake/Kaby Lake processor bug. + AS_CASE(["$CC,$host"], +@@ -961,7 +962,9 @@ AS_CASE([$host], + [aarch64-*-freebsd*], + [arch=arm64; system=freebsd], + [x86_64-*-cygwin*], +- [arch=amd64; system=cygwin] ++ [arch=amd64; system=cygwin], ++ [riscv64-*-linux*], ++ [arch=riscv; model=riscv64; system=linux] + ) + + AS_IF([test x"$enable_native_compiler" = "xno"], +@@ -1065,7 +1068,7 @@ AS_CASE(["$arch,$system"], + [*,dragonfly], + [default_as="${toolpref}as" + default_aspp="${toolpref}cc -c"], +- [amd64,*|arm,*|arm64,*|i386,*], ++ [amd64,*|arm,*|arm64,*|i386,*|riscv,*], + [AS_CASE([$ocaml_cv_cc_vendor], + [clang-*], [default_as="${toolpref}clang -c -Wno-trigraphs" + default_aspp="${toolpref}clang -c -Wno-trigraphs"], +diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h +index df0424683..6b7df0e67 100644 +--- a/runtime/caml/stack.h ++++ b/runtime/caml/stack.h +@@ -70,6 +70,11 @@ + #define Callback_link(sp) ((struct caml_context *)((sp) + 16)) + #endif + ++#ifdef TARGET_riscv ++#define Saved_return_address(sp) *((intnat *)((sp) - 8)) ++#define Callback_link(sp) ((struct caml_context *)((sp) + 16)) ++#endif ++ + /* Structure of OCaml callback contexts */ + + struct caml_context { +diff --git a/runtime/riscv.S b/runtime/riscv.S +new file mode 100644 +index 000000000..48e690e44 +--- /dev/null ++++ b/runtime/riscv.S +@@ -0,0 +1,423 @@ ++/**************************************************************************/ ++/* */ ++/* OCaml */ ++/* */ ++/* Nicolas Ojeda Bar */ ++/* */ ++/* Copyright 2016 Institut National de Recherche en Informatique et */ ++/* en Automatique. */ ++/* */ ++/* All rights reserved. This file is distributed under the terms of */ ++/* the GNU Lesser General Public License version 2.1, with the */ ++/* special exception on linking described in the file LICENSE. */ ++/* */ ++/**************************************************************************/ ++ ++/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ ++/* Must be preprocessed by cpp */ ++ ++#define ARG_DOMAIN_STATE_PTR t0 ++#define DOMAIN_STATE_PTR s0 ++#define TRAP_PTR s1 ++#define ALLOC_PTR s10 ++#define ALLOC_LIMIT s11 ++#define TMP t1 ++#define ARG t2 ++ ++#define STORE sd ++#define LOAD ld ++ ++ .set domain_curr_field, 0 ++#define DOMAIN_STATE(c_type, name) \ ++ .equ domain_field_caml_##name, domain_curr_field ; \ ++ .set domain_curr_field, domain_curr_field + 1 ++#include "../runtime/caml/domain_state.tbl" ++#undef DOMAIN_STATE ++ ++#define Caml_state(var) (8*domain_field_caml_##var)(s0) ++ ++#define FUNCTION(name) \ ++ .align 2; \ ++ .globl name; \ ++ .type name, @function; \ ++name: ++ ++#if defined(__PIC__) ++ .option pic ++#define PLT(r) r@plt ++#else ++ .option nopic ++#define PLT(r) r ++#endif ++ ++ .section .text ++/* Invoke the garbage collector. */ ++ ++ .globl caml_system__code_begin ++caml_system__code_begin: ++ ++FUNCTION(caml_call_gc) ++.Lcaml_call_gc: ++ /* Record return address */ ++ STORE ra, Caml_state(last_return_address) ++ /* Record lowest stack address */ ++ STORE sp, Caml_state(bottom_of_stack) ++ /* Set up stack space, saving return address */ ++ /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, ++ 20 caller-save float regs) * 8 */ ++ /* + 1 for alignment */ ++ addi sp, sp, -0x160 ++ STORE ra, 0x8(sp) ++ STORE s0, 0x0(sp) ++ /* Save allocatable integer registers on the stack, ++ in the order given in proc.ml */ ++ STORE a0, 0x10(sp) ++ STORE a1, 0x18(sp) ++ STORE a2, 0x20(sp) ++ STORE a3, 0x28(sp) ++ STORE a4, 0x30(sp) ++ STORE a5, 0x38(sp) ++ STORE a6, 0x40(sp) ++ STORE a7, 0x48(sp) ++ STORE s2, 0x50(sp) ++ STORE s3, 0x58(sp) ++ STORE s4, 0x60(sp) ++ STORE s5, 0x68(sp) ++ STORE s6, 0x70(sp) ++ STORE s7, 0x78(sp) ++ STORE s8, 0x80(sp) ++ STORE s9, 0x88(sp) ++ STORE t2, 0x90(sp) ++ STORE t3, 0x98(sp) ++ STORE t4, 0xa0(sp) ++ STORE t5, 0xa8(sp) ++ STORE t6, 0xb0(sp) ++ /* Save caller-save floating-point registers on the stack ++ (callee-saves are preserved by caml_garbage_collection) */ ++ fsd ft0, 0xb8(sp) ++ fsd ft1, 0xc0(sp) ++ fsd ft2, 0xc8(sp) ++ fsd ft3, 0xd0(sp) ++ fsd ft4, 0xd8(sp) ++ fsd ft5, 0xe0(sp) ++ fsd ft6, 0xe8(sp) ++ fsd ft7, 0xf0(sp) ++ fsd fa0, 0xf8(sp) ++ fsd fa1, 0x100(sp) ++ fsd fa2, 0x108(sp) ++ fsd fa3, 0x110(sp) ++ fsd fa4, 0x118(sp) ++ fsd fa5, 0x120(sp) ++ fsd fa6, 0x128(sp) ++ fsd fa7, 0x130(sp) ++ fsd ft8, 0x138(sp) ++ fsd ft9, 0x140(sp) ++ fsd ft9, 0x148(sp) ++ fsd ft10, 0x150(sp) ++ fsd ft11, 0x158(sp) ++ /* Store pointer to saved integer registers in caml_gc_regs */ ++ addi TMP, sp, 0x10 ++ STORE TMP, Caml_state(gc_regs) ++ /* Save current allocation pointer for debugging purposes */ ++ STORE ALLOC_PTR, Caml_state(young_ptr) ++ /* Save trap pointer in case an exception is raised during GC */ ++ STORE TRAP_PTR, Caml_state(exception_pointer) ++ /* Call the garbage collector */ ++ call PLT(caml_garbage_collection) ++ /* Restore registers */ ++ LOAD a0, 0x10(sp) ++ LOAD a1, 0x18(sp) ++ LOAD a2, 0x20(sp) ++ LOAD a3, 0x28(sp) ++ LOAD a4, 0x30(sp) ++ LOAD a5, 0x38(sp) ++ LOAD a6, 0x40(sp) ++ LOAD a7, 0x48(sp) ++ LOAD s2, 0x50(sp) ++ LOAD s3, 0x58(sp) ++ LOAD s4, 0x60(sp) ++ LOAD s5, 0x68(sp) ++ LOAD s6, 0x70(sp) ++ LOAD s7, 0x78(sp) ++ LOAD s8, 0x80(sp) ++ LOAD s9, 0x88(sp) ++ LOAD t2, 0x90(sp) ++ LOAD t3, 0x98(sp) ++ LOAD t4, 0xa0(sp) ++ LOAD t5, 0xa8(sp) ++ LOAD t6, 0xb0(sp) ++ fld ft0, 0xb8(sp) ++ fld ft1, 0xc0(sp) ++ fld ft2, 0xc8(sp) ++ fld ft3, 0xd0(sp) ++ fld ft4, 0xd8(sp) ++ fld ft5, 0xe0(sp) ++ fld ft6, 0xe8(sp) ++ fld ft7, 0xf0(sp) ++ fld fa0, 0xf8(sp) ++ fld fa1, 0x100(sp) ++ fld fa2, 0x108(sp) ++ fld fa3, 0x110(sp) ++ fld fa4, 0x118(sp) ++ fld fa5, 0x120(sp) ++ fld fa6, 0x128(sp) ++ fld fa7, 0x130(sp) ++ fld ft8, 0x138(sp) ++ fld ft9, 0x140(sp) ++ fld ft9, 0x148(sp) ++ fld ft10, 0x150(sp) ++ fld ft11, 0x158(sp) ++ /* Reload new allocation pointer and allocation limit */ ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) ++ /* Free stack space and return to caller */ ++ LOAD ra, 0x8(sp) ++ LOAD s0, 0x0(sp) ++ addi sp, sp, 0x160 ++ ret ++ .size caml_call_gc, .-caml_call_gc ++ ++/* Call a C function from OCaml */ ++/* Function to call is in ARG */ ++ ++FUNCTION(caml_c_call) ++ /* Preserve return address in callee-save register s2 */ ++ mv s2, ra ++ /* Record lowest stack address and return address */ ++ STORE ra, Caml_state(last_return_address) ++ STORE sp, Caml_state(bottom_of_stack) ++ /* Make the exception handler alloc ptr available to the C code */ ++ STORE ALLOC_PTR, Caml_state(young_ptr) ++ STORE TRAP_PTR, Caml_state(exception_pointer) ++ /* Call the function */ ++ jalr ARG ++ /* Reload alloc ptr and alloc limit */ ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) ++ /* Return */ ++ jr s2 ++ .size caml_c_call, .-caml_c_call ++ ++/* Raise an exception from OCaml */ ++FUNCTION(caml_raise_exn) ++ /* Test if backtrace is active */ ++ LOAD TMP, Caml_state(backtrace_active) ++ bnez TMP, 2f ++1: /* Cut stack at current trap handler */ ++ mv sp, TRAP_PTR ++ /* Pop previous handler and jump to it */ ++ LOAD TMP, 8(sp) ++ LOAD TRAP_PTR, 0(sp) ++ addi sp, sp, 16 ++ jr TMP ++2: /* Preserve exception bucket in callee-save register s2 */ ++ mv s2, a0 ++ /* Stash the backtrace */ ++ mv a1, ra ++ mv a2, sp ++ mv a3, TRAP_PTR ++ call PLT(caml_stash_backtrace) ++ /* Restore exception bucket and raise */ ++ mv a0, s2 ++ j 1b ++ .size caml_raise_exn, .-caml_raise_exn ++ ++ .globl caml_reraise_exn ++ .type caml_reraise_exn, @function ++ ++/* Raise an exception from C */ ++ ++FUNCTION(caml_raise_exception) ++ mv DOMAIN_STATE_PTR, a0 ++ mv a0, a1 ++ LOAD TRAP_PTR, Caml_state(exception_pointer) ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) ++ LOAD TMP, Caml_state(backtrace_active) ++ bnez TMP, 2f ++1: /* Cut stack at current trap handler */ ++ mv sp, TRAP_PTR ++ LOAD TMP, 8(sp) ++ LOAD TRAP_PTR, 0(sp) ++ addi sp, sp, 16 ++ jr TMP ++2: /* Preserve exception bucket in callee-save register s2 */ ++ mv s2, a0 ++ LOAD a1, Caml_state(last_return_address) ++ LOAD a2, Caml_state(bottom_of_stack) ++ mv a3, TRAP_PTR ++ call PLT(caml_stash_backtrace) ++ mv a0, s2 ++ j 1b ++ .size caml_raise_exception, .-caml_raise_exception ++ ++/* Start the OCaml program */ ++ ++FUNCTION(caml_start_program) ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ la ARG, caml_program ++ /* Code shared with caml_callback* */ ++ /* Address of OCaml code to call is in ARG */ ++ /* Arguments to the OCaml code are in a0 ... a7 */ ++.Ljump_to_caml: ++ /* Set up stack frame and save callee-save registers */ ++ addi sp, sp, -0xd0 ++ STORE ra, 0xc0(sp) ++ STORE s0, 0x0(sp) ++ STORE s1, 0x8(sp) ++ STORE s2, 0x10(sp) ++ STORE s3, 0x18(sp) ++ STORE s4, 0x20(sp) ++ STORE s5, 0x28(sp) ++ STORE s6, 0x30(sp) ++ STORE s7, 0x38(sp) ++ STORE s8, 0x40(sp) ++ STORE s9, 0x48(sp) ++ STORE s10, 0x50(sp) ++ STORE s11, 0x58(sp) ++ fsd fs0, 0x60(sp) ++ fsd fs1, 0x68(sp) ++ fsd fs2, 0x70(sp) ++ fsd fs3, 0x78(sp) ++ fsd fs4, 0x80(sp) ++ fsd fs5, 0x88(sp) ++ fsd fs6, 0x90(sp) ++ fsd fs7, 0x98(sp) ++ fsd fs8, 0xa0(sp) ++ fsd fs9, 0xa8(sp) ++ fsd fs10, 0xb0(sp) ++ fsd fs11, 0xb8(sp) ++ addi sp, sp, -32 ++ /* Load domain state pointer from argument */ ++ mv DOMAIN_STATE_PTR, ARG_DOMAIN_STATE_PTR ++ /* Setup a callback link on the stack */ ++ LOAD TMP, Caml_state(bottom_of_stack) ++ STORE TMP, 0(sp) ++ LOAD TMP, Caml_state(last_return_address) ++ STORE TMP, 8(sp) ++ LOAD TMP, Caml_state(gc_regs) ++ STORE TMP, 16(sp) ++ /* set up a trap frame */ ++ addi sp, sp, -16 ++ LOAD TMP, Caml_state(exception_pointer) ++ STORE TMP, 0(sp) ++ lla TMP, .Ltrap_handler ++ STORE TMP, 8(sp) ++ mv TRAP_PTR, sp ++ LOAD ALLOC_PTR, Caml_state(young_ptr) ++ LOAD ALLOC_LIMIT, Caml_state(young_limit) ++ STORE x0, Caml_state(last_return_address) ++ jalr ARG ++.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ ++ LOAD TMP, 0(sp) ++ STORE TMP, Caml_state(exception_pointer) ++ addi sp, sp, 16 ++.Lreturn_result: /* pop callback link, restoring global variables */ ++ LOAD TMP, 0(sp) ++ STORE TMP, Caml_state(bottom_of_stack) ++ LOAD TMP, 8(sp) ++ STORE TMP, Caml_state(last_return_address) ++ LOAD TMP, 16(sp) ++ STORE TMP, Caml_state(gc_regs) ++ addi sp, sp, 32 ++ /* Update allocation pointer */ ++ STORE ALLOC_PTR, Caml_state(young_ptr) ++ /* reload callee-save registers and return */ ++ LOAD ra, 0xc0(sp) ++ LOAD s0, 0x0(sp) ++ LOAD s1, 0x8(sp) ++ LOAD s2, 0x10(sp) ++ LOAD s3, 0x18(sp) ++ LOAD s4, 0x20(sp) ++ LOAD s5, 0x28(sp) ++ LOAD s6, 0x30(sp) ++ LOAD s7, 0x38(sp) ++ LOAD s8, 0x40(sp) ++ LOAD s9, 0x48(sp) ++ LOAD s10, 0x50(sp) ++ LOAD s11, 0x58(sp) ++ fld fs0, 0x60(sp) ++ fld fs1, 0x68(sp) ++ fld fs2, 0x70(sp) ++ fld fs3, 0x78(sp) ++ fld fs4, 0x80(sp) ++ fld fs5, 0x88(sp) ++ fld fs6, 0x90(sp) ++ fld fs7, 0x98(sp) ++ fld fs8, 0xa0(sp) ++ fld fs9, 0xa8(sp) ++ fld fs10, 0xb0(sp) ++ fld fs11, 0xb8(sp) ++ addi sp, sp, 0xd0 ++ ret ++ .type .Lcaml_retaddr, @function ++ .size .Lcaml_retaddr, .-.Lcaml_retaddr ++ .size caml_start_program, .-caml_start_program ++ ++ .align 2 ++.Ltrap_handler: ++ STORE TRAP_PTR, Caml_state(exception_pointer) ++ ori a0, a0, 2 ++ j .Lreturn_result ++ .type .Ltrap_handler, @function ++ .size .Ltrap_handler, .-.Ltrap_handler ++ ++/* Callback from C to OCaml */ ++ ++FUNCTION(caml_callback_asm) ++ /* Initial shuffling of arguments */ ++ /* a0 = Caml_state, a1 = closure, (a2) = args */ ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ LOAD a0, 0(a2) /* a0 = first arg */ ++ /* a1 = closure environment */ ++ LOAD ARG, 0(a1) /* code pointer */ ++ j .Ljump_to_caml ++ .size caml_callback_asm, .-caml_callback_asm ++ ++FUNCTION(caml_callback2_asm) ++ /* Initial shuffling of arguments */ ++ /* a0 = Caml_state, a1 = closure, (a2) = args */ ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ mv TMP, a1 ++ LOAD a0, 0(a2) ++ LOAD a1, 8(a2) ++ mv a2, TMP ++ la ARG, caml_apply2 ++ j .Ljump_to_caml ++ .size caml_callback2_asm, .-caml_callback2_asm ++ ++FUNCTION(caml_callback3_asm) ++ /* Initial shuffling of arguments */ ++ /* a0 = Caml_state, a1 = closure, (a2) = args */ ++ mv ARG_DOMAIN_STATE_PTR, a0 ++ mv a3, a1 ++ LOAD a0, 0(a2) ++ LOAD a1, 8(a2) ++ LOAD a2, 16(a2) ++ la ARG, caml_apply3 ++ j .Ljump_to_caml ++ .size caml_callback3_asm, .-caml_callback3_asm ++ ++FUNCTION(caml_ml_array_bound_error) ++ /* Load address of [caml_array_bound_error] in ARG */ ++ la ARG, caml_array_bound_error ++ /* Call that function */ ++ tail caml_c_call ++ .size caml_ml_array_bound_error, .-caml_ml_array_bound_error ++ ++ .globl caml_system__code_end ++caml_system__code_end: ++ ++/* GC roots for callback */ ++ ++ .section .data ++ .align 3 ++ .globl caml_system__frametable ++ .type caml_system__frametable, @object ++caml_system__frametable: ++ .quad 1 /* one descriptor */ ++ .quad .Lcaml_retaddr /* return address into callback */ ++ .short -1 /* negative frame size => use callback link */ ++ .short 0 /* no roots */ ++ .align 3 ++ .size caml_system__frametable, .-caml_system__frametable +diff --git a/testsuite/tools/asmgen_riscv.S b/testsuite/tools/asmgen_riscv.S +new file mode 100644 +index 000000000..efb30a80f +--- /dev/null ++++ b/testsuite/tools/asmgen_riscv.S +@@ -0,0 +1,89 @@ ++/**************************************************************************/ ++/* */ ++/* OCaml */ ++/* */ ++/* Nicolas Ojeda Bar */ ++/* */ ++/* Copyright 2019 Institut National de Recherche en Informatique et */ ++/* en Automatique. */ ++/* */ ++/* All rights reserved. This file is distributed under the terms of */ ++/* the GNU Lesser General Public License version 2.1, with the */ ++/* special exception on linking described in the file LICENSE. */ ++/* */ ++/**************************************************************************/ ++ ++#define STORE sd ++#define LOAD ld ++ ++ .globl call_gen_code ++ .align 2 ++call_gen_code: ++ /* Set up stack frame and save callee-save registers */ ++ ADDI sp, sp, -208 ++ STORE ra, 192(sp) ++ STORE s0, 0(sp) ++ STORE s1, 8(sp) ++ STORE s2, 16(sp) ++ STORE s3, 24(sp) ++ STORE s4, 32(sp) ++ STORE s5, 40(sp) ++ STORE s6, 48(sp) ++ STORE s7, 56(sp) ++ STORE s8, 64(sp) ++ STORE s9, 72(sp) ++ STORE s10, 80(sp) ++ STORE s11, 88(sp) ++ fsd fs0, 96(sp) ++ fsd fs1, 104(sp) ++ fsd fs2, 112(sp) ++ fsd fs3, 120(sp) ++ fsd fs4, 128(sp) ++ fsd fs5, 136(sp) ++ fsd fs6, 144(sp) ++ fsd fs7, 152(sp) ++ fsd fs8, 160(sp) ++ fsd fs9, 168(sp) ++ fsd fs10, 176(sp) ++ fsd fs11, 184(sp) ++ /* Shuffle arguments */ ++ mv t0, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, a3 ++ mv a3, a4 ++ /* Call generated asm */ ++ jalr t0 ++ /* Reload callee-save registers and return address */ ++ LOAD ra, 192(sp) ++ LOAD s0, 0(sp) ++ LOAD s1, 8(sp) ++ LOAD s2, 16(sp) ++ LOAD s3, 24(sp) ++ LOAD s4, 32(sp) ++ LOAD s5, 40(sp) ++ LOAD s6, 48(sp) ++ LOAD s7, 56(sp) ++ LOAD s8, 64(sp) ++ LOAD s9, 72(sp) ++ LOAD s10, 80(sp) ++ LOAD s11, 88(sp) ++ fld fs0, 96(sp) ++ fld fs1, 104(sp) ++ fld fs2, 112(sp) ++ fld fs3, 120(sp) ++ fld fs4, 128(sp) ++ fld fs5, 136(sp) ++ fld fs6, 144(sp) ++ fld fs7, 152(sp) ++ fld fs8, 160(sp) ++ fld fs9, 168(sp) ++ fld fs10, 176(sp) ++ fld fs11, 184(sp) ++ addi sp, sp, 208 ++ ret ++ ++ .globl caml_c_call ++ .align 2 ++caml_c_call: ++ jr t2 +-- +2.24.1 + diff --git a/0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch b/0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch deleted file mode 100644 index e2c4d9b..0000000 --- a/0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch +++ /dev/null @@ -1,174 +0,0 @@ -From 2e40ed7452896a5ad043ca1297112d2a5bf6189b Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Mon, 20 Apr 2020 16:13:26 +0100 -Subject: [PATCH 5/7] Merge pull request #9457 from dra27/fix-mod_use - -Fix #mod_use in toplevel - -(cherry picked from commit f4dc3003d579e45f6ddeb6ffceb4c283a9e15bc7) ---- - Changes | 2 +- - testsuite/tests/tool-toplevel/mod.ml | 1 + - testsuite/tests/tool-toplevel/mod_use.ml | 9 +++++++++ - toplevel/opttoploop.ml | 19 +++++++++++-------- - toplevel/toploop.ml | 19 +++++++++++-------- - 5 files changed, 33 insertions(+), 17 deletions(-) - create mode 100644 testsuite/tests/tool-toplevel/mod.ml - create mode 100644 testsuite/tests/tool-toplevel/mod_use.ml - -diff --git a/Changes b/Changes -index f16158f12..a65573604 100644 ---- a/Changes -+++ b/Changes -@@ -164,7 +164,7 @@ Working version - points to the grammar. - (Andreas Abel, review by Xavier Leroy) - --- #9283: add a new toplevel directive `#use_output ""` to -+- #9283, #9455, #9457: add a new toplevel directive `#use_output ""` to - run a command and evaluate its output. - (Jérémie Dimino, review by David Allsopp) - -diff --git a/testsuite/tests/tool-toplevel/mod.ml b/testsuite/tests/tool-toplevel/mod.ml -new file mode 100644 -index 000000000..cd298427b ---- /dev/null -+++ b/testsuite/tests/tool-toplevel/mod.ml -@@ -0,0 +1 @@ -+let answer = 42 -diff --git a/testsuite/tests/tool-toplevel/mod_use.ml b/testsuite/tests/tool-toplevel/mod_use.ml -new file mode 100644 -index 000000000..e068ffc3a ---- /dev/null -+++ b/testsuite/tests/tool-toplevel/mod_use.ml -@@ -0,0 +1,9 @@ -+(* TEST -+ files = "mod.ml" -+ * expect -+*) -+ -+#mod_use "mod.ml" -+[%%expect {| -+module Mod : sig val answer : int end -+|}];; -diff --git a/toplevel/opttoploop.ml b/toplevel/opttoploop.ml -index cd4210bbe..ad9a2569e 100644 ---- a/toplevel/opttoploop.ml -+++ b/toplevel/opttoploop.ml -@@ -449,7 +449,7 @@ let preprocess_phrase ppf phr = - if !Clflags.dump_source then Pprintast.top_phrase ppf phr; - phr - --let use_channel ppf wrap_mod ic name filename = -+let use_channel ppf ~wrap_in_module ic name filename = - let lb = Lexing.from_channel ic in - Location.init lb filename; - (* Skip initial #! line if any *) -@@ -461,7 +461,7 @@ let use_channel ppf wrap_mod ic name filename = - (fun ph -> - let ph = preprocess_phrase ppf ph in - if not (execute_phrase !use_print_results ppf ph) then raise Exit) -- (if wrap_mod then -+ (if wrap_in_module then - parse_mod_use_file name lb - else - !parse_use_file lb); -@@ -485,27 +485,30 @@ let use_output ppf command = - | 0 -> - let ic = open_in_bin fn in - Misc.try_finally ~always:(fun () -> close_in ic) -- (fun () -> use_channel ppf false ic "" "(command-output)") -+ (fun () -> -+ use_channel ppf ~wrap_in_module:false ic "" "(command-output)") - | n -> - fprintf ppf "Command exited with code %d.@." n; - false) - --let use_file ppf wrap_mode name = -+let use_file ppf ~wrap_in_module name = - match name with - | "" -> -- use_channel ppf wrap_mode stdin name "(stdin)" -+ use_channel ppf ~wrap_in_module stdin name "(stdin)" - | _ -> - match Load_path.find name with - | filename -> - let ic = open_in_bin filename in - Misc.try_finally ~always:(fun () -> close_in ic) -- (fun () -> use_channel ppf false ic name filename) -+ (fun () -> use_channel ppf ~wrap_in_module ic name filename) - | exception Not_found -> - fprintf ppf "Cannot find file %s.@." name; - false - --let mod_use_file ppf name = use_file ppf true name --let use_file ppf name = use_file ppf false name -+let mod_use_file ppf name = -+ use_file ppf ~wrap_in_module:true name -+let use_file ppf name = -+ use_file ppf ~wrap_in_module:false name - - let use_silently ppf name = - protect_refs [ R (use_print_results, false) ] (fun () -> use_file ppf name) -diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml -index 02f629f9d..09e550796 100644 ---- a/toplevel/toploop.ml -+++ b/toplevel/toploop.ml -@@ -394,7 +394,7 @@ let preprocess_phrase ppf phr = - if !Clflags.dump_source then Pprintast.top_phrase ppf phr; - phr - --let use_channel ppf wrap_mod ic name filename = -+let use_channel ppf ~wrap_in_module ic name filename = - let lb = Lexing.from_channel ic in - Warnings.reset_fatal (); - Location.init lb filename; -@@ -408,7 +408,7 @@ let use_channel ppf wrap_mod ic name filename = - (fun ph -> - let ph = preprocess_phrase ppf ph in - if not (execute_phrase !use_print_results ppf ph) then raise Exit) -- (if wrap_mod then -+ (if wrap_in_module then - parse_mod_use_file name lb - else - !parse_use_file lb); -@@ -431,27 +431,30 @@ let use_output ppf command = - | 0 -> - let ic = open_in_bin fn in - Misc.try_finally ~always:(fun () -> close_in ic) -- (fun () -> use_channel ppf false ic "" "(command-output)") -+ (fun () -> -+ use_channel ppf ~wrap_in_module:false ic "" "(command-output)") - | n -> - fprintf ppf "Command exited with code %d.@." n; - false) - --let use_file ppf wrap_mode name = -+let use_file ppf ~wrap_in_module name = - match name with - | "" -> -- use_channel ppf wrap_mode stdin name "(stdin)" -+ use_channel ppf ~wrap_in_module stdin name "(stdin)" - | _ -> - match Load_path.find name with - | filename -> - let ic = open_in_bin filename in - Misc.try_finally ~always:(fun () -> close_in ic) -- (fun () -> use_channel ppf false ic name filename) -+ (fun () -> use_channel ppf ~wrap_in_module ic name filename) - | exception Not_found -> - fprintf ppf "Cannot find file %s.@." name; - false - --let mod_use_file ppf name = use_file ppf true name --let use_file ppf name = use_file ppf false name -+let mod_use_file ppf name = -+ use_file ppf ~wrap_in_module:true name -+let use_file ppf name = -+ use_file ppf ~wrap_in_module:false name - - let use_silently ppf name = - protect_refs [ R (use_print_results, false) ] (fun () -> use_file ppf name) --- -2.24.1 - diff --git a/0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch b/0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch deleted file mode 100644 index 96e74b2..0000000 --- a/0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 13bec130864d682032f3b3086764487c26076093 Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Mon, 20 Apr 2020 11:34:15 +0200 -Subject: [PATCH 6/7] Merge pull request #9463 from lthls/fix_int64_cmm_typ - -Fix Cmm type of unboxed integers in Clet_mut - -(cherry picked from commit 702e34fbe56f6f03db086efe42148395c5e395ff) ---- - Changes | 6 ++- - asmcomp/cmmgen.ml | 15 ++++---- - testsuite/tests/lib-int64/issue9460.ml | 37 +++++++++++++++++++ - testsuite/tests/lib-int64/issue9460.reference | 1 + - 4 files changed, 49 insertions(+), 10 deletions(-) - create mode 100644 testsuite/tests/lib-int64/issue9460.ml - create mode 100644 testsuite/tests/lib-int64/issue9460.reference - -diff --git a/Changes b/Changes -index a65573604..5f92e00c1 100644 ---- a/Changes -+++ b/Changes -@@ -66,8 +66,10 @@ Working version - - #9280: Micro-optimise allocations on amd64 to save a register. - (Stephen Dolan, review by Xavier Leroy) - --- #9316: Use typing information from Clambda for mutable Cmm variables. -- (Stephen Dolan, review by Vincent Laviron, Guillaume Bury and Xavier Leroy) -+- #9316, #9443, #9463: Use typing information from Clambda -+ for mutable Cmm variables. -+ (Stephen Dolan, review by Vincent Laviron, Guillaume Bury, Xavier Leroy, -+ and Gabriel Scherer; temporary bug report by Richard Jones) - - - #9426: build the Mingw ports with higher levels of GCC optimization - (Xavier Leroy, review by Sébastien Hinderer) -diff --git a/asmcomp/cmmgen.ml b/asmcomp/cmmgen.ml -index 6e1c924dc..ec9697177 100644 ---- a/asmcomp/cmmgen.ml -+++ b/asmcomp/cmmgen.ml -@@ -247,6 +247,11 @@ let box_int dbg bi arg = - - (* Boxed numbers *) - -+let typ_of_boxed_number = function -+ | Boxed_float _ -> Cmm.typ_float -+ | Boxed_integer (Pint64, _) when size_int = 4 -> [|Int;Int|] -+ | Boxed_integer _ -> Cmm.typ_int -+ - let equal_unboxed_integer ui1 ui2 = - match ui1, ui2 with - | Pnativeint, Pnativeint -> true -@@ -687,11 +692,6 @@ and transl_catch env nfail ids body handler dbg = - in - let env_body = add_notify_catch nfail report env in - let body = transl env_body body in -- let typ_of_bn = function -- | Boxed_float _ -> Cmm.typ_float -- | Boxed_integer (Pint64, _) when size_int = 4 -> [|Int;Int|] -- | Boxed_integer _ -> Cmm.typ_int -- in - let new_env, rewrite, ids = - List.fold_right - (fun (id, _kind, u) (env, rewrite, ids) -> -@@ -704,7 +704,7 @@ and transl_catch env nfail ids body handler dbg = - let unboxed_id = V.create_local (VP.name id) in - add_unboxed_id (VP.var id) unboxed_id bn env, - (unbox_number Debuginfo.none bn) :: rewrite, -- (VP.create unboxed_id, typ_of_bn bn) :: ids -+ (VP.create unboxed_id, typ_of_boxed_number bn) :: ids - ) - ids (env, [], []) - in -@@ -1165,8 +1165,7 @@ and transl_let env str kind id exp body = - transl (add_unboxed_id (VP.var id) unboxed_id boxed_number env) body in - begin match str, boxed_number with - | Immutable, _ -> Clet (v, cexp, body) -- | Mutable, Boxed_float _ -> Clet_mut (v, typ_float, cexp, body) -- | Mutable, Boxed_integer _ -> Clet_mut (v, typ_int, cexp, body) -+ | Mutable, bn -> Clet_mut (v, typ_of_boxed_number bn, cexp, body) - end - - and make_catch ncatch body handler dbg = match body with -diff --git a/testsuite/tests/lib-int64/issue9460.ml b/testsuite/tests/lib-int64/issue9460.ml -new file mode 100644 -index 000000000..aacbe6189 ---- /dev/null -+++ b/testsuite/tests/lib-int64/issue9460.ml -@@ -0,0 +1,37 @@ -+(* TEST -+*) -+ -+(* See https://github.com/ocaml/ocaml/issues/9460 -+ This test comes from Richard Jones -+ at -+ https://github.com/libguestfs/libnbd/blob/0475bfe04a527051c0a37af59a733c4c8554e427/ocaml/tests/test_400_pread.ml#L21-L36 -+*) -+let test_result = -+ let b = Bytes.create 16 in -+ for i = 0 to 16/8-1 do -+ let i64 = ref (Int64.of_int (i*8)) in -+ for j = 0 to 7 do -+ let c = Int64.shift_right_logical !i64 56 in -+ let c = Int64.to_int c in -+ let c = Char.chr c in -+ Bytes.unsafe_set b (i*8+j) c; -+ i64 := Int64.shift_left !i64 8 -+ done -+ done; -+ (Bytes.to_string b) ;; -+ -+let expected = -+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\008" -+ -+let () = -+ assert (test_result = expected) -+ -+(* Reproduction case by Jeremy Yallop in -+ https://github.com/ocaml/ocaml/pull/9463#issuecomment-615831765 -+*) -+let () = -+ let x = ref Int64.max_int in -+ assert (!x = Int64.max_int) -+ -+let () = -+ print_endline "OK" -diff --git a/testsuite/tests/lib-int64/issue9460.reference b/testsuite/tests/lib-int64/issue9460.reference -new file mode 100644 -index 000000000..d86bac9de ---- /dev/null -+++ b/testsuite/tests/lib-int64/issue9460.reference -@@ -0,0 +1 @@ -+OK --- -2.24.1 - diff --git a/0006-Support-FP-reg-int-reg-moves.patch b/0006-Support-FP-reg-int-reg-moves.patch new file mode 100644 index 0000000..1a0f343 --- /dev/null +++ b/0006-Support-FP-reg-int-reg-moves.patch @@ -0,0 +1,34 @@ +From d26a313ae92bb515b04865b6a71a63701dd1fe41 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Thu, 30 Apr 2020 16:18:06 +0200 +Subject: [PATCH 6/7] Support FP reg -> int reg moves + +Using instruction fmv.x.d. + +This is necessary to implement the ELF psABI calling conventions, +whereas some FP arguments may have to be passed in integer registers. + +(cherry picked from commit 16794b940555315c723411077a2902fc85a33c45) +--- + asmcomp/riscv/emit.mlp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +index dc652de42..dbfdc2d40 100644 +--- a/asmcomp/riscv/emit.mlp ++++ b/asmcomp/riscv/emit.mlp +@@ -283,8 +283,10 @@ let emit_instr i = + match (src, dst) with + | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> + ` mv {emit_reg dst}, {emit_reg src}\n` +- | {loc = Reg _; typ = Float}, {loc = Reg _} -> ++ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> + ` fmv.d {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = (Val | Int | Addr)} -> ++ ` fmv.x.d {emit_reg dst}, {emit_reg src}\n` + | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> + let ofs = slot_offset s (register_class dst) in + emit_store src ofs +-- +2.24.1 + diff --git a/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch b/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch new file mode 100644 index 0000000..8160e82 --- /dev/null +++ b/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch @@ -0,0 +1,59 @@ +From 5bc92d0cdb5cb26b8d8d517f30914c2b18e85f2b Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Thu, 30 Apr 2020 16:19:16 +0200 +Subject: [PATCH 7/7] Update C calling conventions to the RISC-V ELF psABI + +The original implementation of loc_external_arguments and +loc_external_results was following an older ABI, +where an FP argument passed in an FP register "burns" an integer register. + +In the ELF psABI, integer registers and FP registers are used independently, +as in the OCaml calling convention. Plus, if all FP registers are used +but an integer register remains, the integer register is used to pass +the next FP argument. + +Fixes: #9515 +(cherry picked from commit ea6896f9f184305cc455d3af18cd1cb75cdcd93d) +--- + asmcomp/riscv/proc.ml | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml +index 70909cd83..4c7b58612 100644 +--- a/asmcomp/riscv/proc.ml ++++ b/asmcomp/riscv/proc.ml +@@ -187,6 +187,8 @@ let loc_results res = + first integer args in a0 .. a7 + first float args in fa0 .. fa7 + remaining args on stack. ++ A FP argument can be passed in an integer register if all FP registers ++ are exhausted but integer registers remain. + Return values in a0 .. a1 or fa0 .. fa1. *) + + let external_calling_conventions +@@ -202,8 +204,7 @@ let external_calling_conventions + | Val | Int | Addr as ty -> + if !int <= last_int then begin + loc.(i) <- [| phys_reg !int |]; +- incr int; +- incr float; ++ incr int + end else begin + loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; + ofs := !ofs + size_int +@@ -211,8 +212,10 @@ let external_calling_conventions + | Float -> + if !float <= last_float then begin + loc.(i) <- [| phys_reg !float |]; +- incr float; +- incr int; ++ incr float ++ end else if !int <= last_int then begin ++ loc.(i) <- [| phys_reg !int |]; ++ incr int + end else begin + loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; + ofs := !ofs + size_float +-- +2.24.1 + diff --git a/0007-x86-asm-handle-unit-names-with-special-characters-94.patch b/0007-x86-asm-handle-unit-names-with-special-characters-94.patch deleted file mode 100644 index 9ecfab9..0000000 --- a/0007-x86-asm-handle-unit-names-with-special-characters-94.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 946b5c2563dbf7d8969781e6b05d9fc531cd65a2 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= -Date: Sun, 19 Apr 2020 11:17:00 +0200 -Subject: [PATCH 7/7] x86 asm: handle unit names with special characters - (#9465) - -(cherry picked from commit ec6690fb53b6caced797e1a7a083a787ff8bd97c) ---- - asmcomp/amd64/emit.mlp | 2 +- - testsuite/tests/asmcomp/0-!@#%.compilers.reference | 2 ++ - testsuite/tests/asmcomp/0-!@#%.ml | 10 ++++++++++ - 3 files changed, 13 insertions(+), 1 deletion(-) - create mode 100644 testsuite/tests/asmcomp/0-!@#%.compilers.reference - create mode 100644 testsuite/tests/asmcomp/0-!@#%.ml - -diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp -index 2e9e3a86d..d9c5eb6e6 100644 ---- a/asmcomp/amd64/emit.mlp -+++ b/asmcomp/amd64/emit.mlp -@@ -1146,7 +1146,7 @@ let end_assembly() = - }; - - if system = S_linux then begin -- let frametable = Compilenv.make_symbol (Some "frametable") in -+ let frametable = emit_symbol (Compilenv.make_symbol (Some "frametable")) in - D.size frametable (ConstSub (ConstThis, ConstLabel frametable)) - end; - -diff --git a/testsuite/tests/asmcomp/0-!@#%.compilers.reference b/testsuite/tests/asmcomp/0-!@#%.compilers.reference -new file mode 100644 -index 000000000..7df9a5456 ---- /dev/null -+++ b/testsuite/tests/asmcomp/0-!@#%.compilers.reference -@@ -0,0 +1,2 @@ -+File "0-!@#%.ml", line 1: -+Warning 24: bad source file name: "0-!@#%" is not a valid module name. -diff --git a/testsuite/tests/asmcomp/0-!@#%.ml b/testsuite/tests/asmcomp/0-!@#%.ml -new file mode 100644 -index 000000000..9f24bc382 ---- /dev/null -+++ b/testsuite/tests/asmcomp/0-!@#%.ml -@@ -0,0 +1,10 @@ -+(* TEST *) -+ -+(* We could not include the following characters the file name: -+ -+ - '$' : this character is interpreted specially by [ocamltest] (as it uses -+ [Buffer.add_substitute] on the filenames). -+ -+ - '^' : this character causes problems under Windows if not properly -+ quoted. In particular, flexlink needed to be adapted. -+*) --- -2.24.1 - diff --git a/ocaml.spec b/ocaml.spec index 34175e6..344936b 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -17,7 +17,7 @@ # 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 aarch64 %{power64} 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 @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.3.pre%{?dist} +Release: 0.4.dev2%{?dist} Summary: OCaml compiler and programming environment @@ -40,9 +40,8 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org #Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rcver}.tar.xz -# This is a pre-release of OCaml 4.11.0 with addition of the RISC-V -# patches. See: -# https://pagure.io/fedora-ocaml/commits/fedora-33-4.11.0-pre +# This is a pre-release of OCaml 4.11.0. See: +# https://pagure.io/fedora-ocaml/commits/fedora-33-4.11.0-dev2 Source0: ocaml-4.11.0.tar.gz # IMPORTANT NOTE: @@ -54,22 +53,21 @@ Source0: ocaml-4.11.0.tar.gz # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-33-4.11.0-pre +# Current branch: fedora-33-4.11.0-dev2 # # 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. -# Fedora-specific downstream patches. Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch Patch0004: 0004-Remove-configure-from-.gitattributes.patch -# All of these fixes are upstream in 4.11. -Patch0005: 0005-Merge-pull-request-9457-from-dra27-fix-mod_use.patch -Patch0006: 0006-Merge-pull-request-9463-from-lthls-fix_int64_cmm_typ.patch -Patch0007: 0007-x86-asm-handle-unit-names-with-special-characters-94.patch +# Add RISC-V backend. This is upstream in 4.12 (not 4.11). +Patch0005: 0005-Add-RISC-V-native-code-backend-9441.patch +Patch0006: 0006-Support-FP-reg-int-reg-moves.patch +Patch0007: 0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch BuildRequires: git BuildRequires: gcc @@ -242,6 +240,10 @@ find $RPM_BUILD_ROOT -name .ignore -delete # See also: http://www.ocamlpro.com/blog/2012/08/20/ocamlpro-and-4.00.0.html find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete +# 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 %doc LICENSE @@ -249,8 +251,10 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %{_bindir}/ocamlcmt %{_bindir}/ocamldebug +%ifnarch riscv64 %{_bindir}/ocaml-instr-graph %{_bindir}/ocaml-instr-report +%endif %{_bindir}/ocamlyacc # symlink to either .byte or .opt version @@ -373,6 +377,12 @@ find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete %changelog +* Mon May 04 2020 Richard W.M. Jones - 4.11.0-0.4.dev2.fc33 +- Move to OCaml 4.11.0+dev2-2020-04-22. +- Backport upstream RISC-V backend from 4.12 + fixes. +- Enable tests on riscv64. +- Disable ocaml-instr-* tools on riscv64. + * Tue Apr 21 2020 Richard W.M. Jones - 4.11.0-0.3.pre.fc33 - Add fixes for various issues found in the previous build. diff --git a/sources b/sources index 582776a..9c55304 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.11.0.tar.gz) = 3d41e50b73981af1f6d5e51cf1878a2fd54b52a4da434298a48159d48ea66166689c2fb30a8fe6a9e8dd6f4a483009af24e550fb03fa6dc736b6bf37c4534645 +SHA512 (ocaml-4.11.0.tar.gz) = b07208b8679ef285f30b2da4070a3cf894cb881b79330e1ee50839fff634e58be1b7c378690658d146d2565ddbfa40aaa12ecec9558d7eab501b1863f50bfc88 From 80474fcdea5589e4d2f63741ae8fa981ed1a77ba Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 4 May 2020 17:38:24 +0100 Subject: [PATCH 30/91] Disable ocaml-instr-* on all arches. --- ocaml.spec | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 344936b..f945893 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -251,10 +251,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlcmt %{_bindir}/ocamldebug -%ifnarch riscv64 -%{_bindir}/ocaml-instr-graph -%{_bindir}/ocaml-instr-report -%endif +#{_bindir}/ocaml-instr-graph +#{_bindir}/ocaml-instr-report %{_bindir}/ocamlyacc # symlink to either .byte or .opt version From 9efe171b211bfdddc06adab55c02c1838ee88302 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 1 Jul 2020 15:28:31 -0600 Subject: [PATCH 31/91] Disable LTO --- ocaml.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index f945893..ee6865a 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.4.dev2%{?dist} +Release: 0.5.dev2%{?dist} Summary: OCaml compiler and programming environment @@ -174,6 +174,12 @@ autoconf --force %build +# This package fails to build with LTO due to undefined symbols. LTO +# was disabled in OpenSuSE as well, but with no real explanation why +# beyond the undefined symbols. It really shold be investigated further. +# Disable LTO +%define _lto_cflags %{nil} + %ifnarch %{no_parallel_build_arches} make="make %{?_smp_mflags}" %else @@ -375,6 +381,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Wed Jul 01 2020 Jeff Law - 4.11.0-0.5.dev2.fc33 +- Disable LTO + * Mon May 04 2020 Richard W.M. Jones - 4.11.0-0.4.dev2.fc33 - Move to OCaml 4.11.0+dev2-2020-04-22. - Backport upstream RISC-V backend from 4.12 + fixes. From ae20e034217fe9dbbb0c025f877d3b65c346bf96 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 14 Jul 2020 02:17:44 +0000 Subject: [PATCH 32/91] Use make macros https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro --- ocaml.spec | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index ee6865a..0f040ee 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.5.dev2%{?dist} +Release: 0.6.dev2%{?dist} Summary: OCaml compiler and programming environment @@ -181,7 +181,7 @@ autoconf --force %define _lto_cflags %{nil} %ifnarch %{no_parallel_build_arches} -make="make %{?_smp_mflags}" +make="%make_build" %else unset MAKEFLAGS make=make @@ -232,7 +232,7 @@ make -j1 all ||: %install -make install DESTDIR=$RPM_BUILD_ROOT +%make_install perl -pi -e "s|^$RPM_BUILD_ROOT||" $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf echo %{version} > $RPM_BUILD_ROOT%{_libdir}/ocaml/fedora-ocaml-release @@ -381,6 +381,10 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Tue Jul 14 2020 Tom Stellard - 4.11.0-0.6.dev2 +- Use make macros +- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro + * Wed Jul 01 2020 Jeff Law - 4.11.0-0.5.dev2.fc33 - Disable LTO From 713b4232306e125bc8b802317ad72182a865deec Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 28 Jul 2020 12:04:21 +0000 Subject: [PATCH 33/91] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 0f040ee..07e32f8 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.6.dev2%{?dist} +Release: 0.7.dev2%{?dist} Summary: OCaml compiler and programming environment @@ -381,6 +381,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Tue Jul 28 2020 Fedora Release Engineering - 4.11.0-0.7.dev2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Tue Jul 14 2020 Tom Stellard - 4.11.0-0.6.dev2 - Use make macros - https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro From 493a29c31571538e32522b254c41026a106be798 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 4 Aug 2020 10:47:25 +0100 Subject: [PATCH 34/91] Bump and rebuild to fix DWARF versioning issues. https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/43RRYPGUVX65GZ5SM3NMTBEZW42NP7BN/ --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 07e32f8..9d62c2c 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.7.dev2%{?dist} +Release: 0.8.dev2%{?dist} Summary: OCaml compiler and programming environment @@ -381,6 +381,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Tue Aug 04 2020 Richard W.M. Jones - 4.11.0-0.8.dev2 +- Bump and rebuild to fix DWARF versioning issues. + * Tue Jul 28 2020 Fedora Release Engineering - 4.11.0-0.7.dev2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From cf41d3d77da265d633dc5344d90ce7e1dc4fef7d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 4 Aug 2020 12:29:58 +0100 Subject: [PATCH 35/91] Enable LTO again. NOTE: I did not build this in Rawhide, because building it appears to change some of the ocamlx() dependencies, which would require everything in Rawhide to be rebuilt. I will build all OCaml packages in Rawhide once OCaml 4.11.0 has been released which should be in a week or two. --- 0001-Don-t-add-rpaths-to-libraries.patch | 4 +- ...-Allow-user-defined-C-compiler-flags.patch | 4 +- ...-incorrect-assumption-about-cross-co.patch | 4 +- ...Remove-configure-from-.gitattributes.patch | 4 +- ...-Add-RISC-V-native-code-backend-9441.patch | 4 +- 0006-Support-FP-reg-int-reg-moves.patch | 4 +- ...-conventions-to-the-RISC-V-ELF-psABI.patch | 4 +- ....c-Declare-caml_fl_merge-with-proper.patch | 49 +++++++++++++++++++ ocaml.spec | 14 +++--- 9 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 281cb7c..2149b6d 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 1b1a2ad3294327e5bbbc753f306d1199b0a2a583 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/7] Don't add rpaths to libraries. +Subject: [PATCH 1/8] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- @@ -23,5 +23,5 @@ index 96a4244cc..076411a91 100644 > ocamlmklibconfig.ml -- -2.24.1 +2.28.0.rc2 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 3ffd213..1ce4168 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From 8ea0bc7713a89cd6340e35b4dae048be63c50aec Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/7] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/8] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ @@ -23,5 +23,5 @@ index fbd49c1ee..a35da2040 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.24.1 +2.28.0.rc2 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 2b6d384..d41e1b2 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ From 39df379f1aa139a073d7b436bb9bd33ef2f70caf Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/7] configure: Remove incorrect assumption about +Subject: [PATCH 3/8] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -39,5 +39,5 @@ index a35da2040..4c9358897 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.24.1 +2.28.0.rc2 diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index eb562e5..881c81d 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,7 +1,7 @@ From e829051c3b35920db3c5e0dd913026f556448675 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 -Subject: [PATCH 4/7] Remove configure from .gitattributes. +Subject: [PATCH 4/8] Remove configure from .gitattributes. It's not a binary file. --- @@ -24,5 +24,5 @@ index 200eb49c6..d871764de 100644 # http://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/ /.mailmap merge=union -- -2.24.1 +2.28.0.rc2 diff --git a/0005-Add-RISC-V-native-code-backend-9441.patch b/0005-Add-RISC-V-native-code-backend-9441.patch index f466fdd..1e2904f 100644 --- a/0005-Add-RISC-V-native-code-backend-9441.patch +++ b/0005-Add-RISC-V-native-code-backend-9441.patch @@ -1,7 +1,7 @@ From 1a0ca036e40cbd701cbe3f0e5cf5e2a6b6d4c804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Fri, 24 Apr 2020 16:04:50 +0200 -Subject: [PATCH 5/7] Add RISC-V native-code backend (#9441) +Subject: [PATCH 5/8] Add RISC-V native-code backend (#9441) This is a port of ocamlopt for the RISC-V processor in 64-bit mode. @@ -2008,5 +2008,5 @@ index 000000000..efb30a80f +caml_c_call: + jr t2 -- -2.24.1 +2.28.0.rc2 diff --git a/0006-Support-FP-reg-int-reg-moves.patch b/0006-Support-FP-reg-int-reg-moves.patch index 1a0f343..1138515 100644 --- a/0006-Support-FP-reg-int-reg-moves.patch +++ b/0006-Support-FP-reg-int-reg-moves.patch @@ -1,7 +1,7 @@ From d26a313ae92bb515b04865b6a71a63701dd1fe41 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Thu, 30 Apr 2020 16:18:06 +0200 -Subject: [PATCH 6/7] Support FP reg -> int reg moves +Subject: [PATCH 6/8] Support FP reg -> int reg moves Using instruction fmv.x.d. @@ -30,5 +30,5 @@ index dc652de42..dbfdc2d40 100644 let ofs = slot_offset s (register_class dst) in emit_store src ofs -- -2.24.1 +2.28.0.rc2 diff --git a/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch b/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch index 8160e82..e60f1ef 100644 --- a/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch +++ b/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch @@ -1,7 +1,7 @@ From 5bc92d0cdb5cb26b8d8d517f30914c2b18e85f2b Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Thu, 30 Apr 2020 16:19:16 +0200 -Subject: [PATCH 7/7] Update C calling conventions to the RISC-V ELF psABI +Subject: [PATCH 7/8] Update C calling conventions to the RISC-V ELF psABI The original implementation of loc_external_arguments and loc_external_results was following an older ABI, @@ -55,5 +55,5 @@ index 70909cd83..4c7b58612 100644 loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; ofs := !ofs + size_float -- -2.24.1 +2.28.0.rc2 diff --git a/0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch b/0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch new file mode 100644 index 0000000..aafe0c0 --- /dev/null +++ b/0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch @@ -0,0 +1,49 @@ +From 7364f5081851fe306802883d9a8069da559d4973 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 4 Aug 2020 12:26:12 +0100 +Subject: [PATCH 8/8] runtime/major_gc.c: Declare caml_fl_merge with proper + type. + +When compiling OCaml with LTO enabled (as is now done routinely in +Fedora and OpenSUSE) we got a failure because the caml_fl_merge symbol +is not declared identically across compilation units. The simple fix +is to make sure the declarations are identical, although probably +moving the definition to a common header file would be a better +long-term fix. + +major_gc.c:66:14: warning: type of 'caml_fl_merge' does not match original declaration [-Wlto-type-mismatch] + 66 | extern char *caml_fl_merge; /* Defined in freelist.c. */ + | ^ +freelist.c:47:7: note: 'caml_fl_merge' was previously declared here + 47 | value caml_fl_merge = Val_NULL; /* Current insertion pointer. Managed + | ^ +freelist.c:47:7: note: code may be misoptimized unless '-fno-strict-aliasing' is used +--- + runtime/major_gc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/runtime/major_gc.c b/runtime/major_gc.c +index 5e4f06bce..c8f5a3281 100644 +--- a/runtime/major_gc.c ++++ b/runtime/major_gc.c +@@ -63,7 +63,7 @@ uintnat caml_dependent_size, caml_dependent_allocated; + double caml_extra_heap_resources; + uintnat caml_fl_wsz_at_phase_change = 0; + +-extern char *caml_fl_merge; /* Defined in freelist.c. */ ++extern value caml_fl_merge; /* Defined in freelist.c. */ + + static char *markhp, *chunk, *limit; + static double p_backlog = 0.0; /* backlog for the gc speedup parameter */ +@@ -570,7 +570,7 @@ static void sweep_slice (intnat work) + break; + case Caml_blue: + /* Only the blocks of the free-list are blue. See [freelist.c]. */ +- caml_fl_merge = Bp_hp (hp); ++ caml_fl_merge = (value) Bp_hp (hp); + break; + default: /* gray or black */ + CAMLassert (Color_hd (hd) == Caml_black); +-- +2.28.0.rc2 + diff --git a/ocaml.spec b/ocaml.spec index 9d62c2c..928b035 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.8.dev2%{?dist} +Release: 0.9.dev2%{?dist} Summary: OCaml compiler and programming environment @@ -69,6 +69,9 @@ Patch0005: 0005-Add-RISC-V-native-code-backend-9441.patch Patch0006: 0006-Support-FP-reg-int-reg-moves.patch Patch0007: 0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch +# Fix compilation with LTO (sent upstream 2020-08-04). +Patch0008: 0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch + BuildRequires: git BuildRequires: gcc BuildRequires: autoconf @@ -174,12 +177,6 @@ autoconf --force %build -# This package fails to build with LTO due to undefined symbols. LTO -# was disabled in OpenSuSE as well, but with no real explanation why -# beyond the undefined symbols. It really shold be investigated further. -# Disable LTO -%define _lto_cflags %{nil} - %ifnarch %{no_parallel_build_arches} make="%make_build" %else @@ -381,8 +378,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog -* Tue Aug 04 2020 Richard W.M. Jones - 4.11.0-0.8.dev2 +* Tue Aug 04 2020 Richard W.M. Jones - 4.11.0-0.9.dev2 - Bump and rebuild to fix DWARF versioning issues. +- Enable LTO again. * Tue Jul 28 2020 Fedora Release Engineering - 4.11.0-0.7.dev2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From 1018e3aa3a8ded0d9ae8745dfd0e78893a74a499 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 21 Aug 2020 08:55:06 +0100 Subject: [PATCH 36/91] OCaml 4.11.0 release (RHBZ#1870368). --- .gitignore | 1 + 0001-Don-t-add-rpaths-to-libraries.patch | 8 +- ...-Allow-user-defined-C-compiler-flags.patch | 6 +- ...-incorrect-assumption-about-cross-co.patch | 8 +- ...Remove-configure-from-.gitattributes.patch | 4 +- ...-Add-RISC-V-native-code-backend-9441.patch | 2012 ----------------- ...hes-between-definition-and-declarati.patch | 69 + 0006-Support-FP-reg-int-reg-moves.patch | 34 - ...-conventions-to-the-RISC-V-ELF-psABI.patch | 59 - ....c-Declare-caml_fl_merge-with-proper.patch | 49 - ocaml.spec | 23 +- sources | 2 +- 12 files changed, 95 insertions(+), 2180 deletions(-) delete mode 100644 0005-Add-RISC-V-native-code-backend-9441.patch create mode 100644 0005-Fix-type-mismatches-between-definition-and-declarati.patch delete mode 100644 0006-Support-FP-reg-int-reg-moves.patch delete mode 100644 0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch delete mode 100644 0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch diff --git a/.gitignore b/.gitignore index 3505209..0244410 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /ocaml-*.tar.gz /ocaml-*.tar.xz /ocaml-*-refman.pdf +/4.11.0.tar.gz diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 2149b6d..d20dc05 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,17 +1,17 @@ -From 1b1a2ad3294327e5bbbc753f306d1199b0a2a583 Mon Sep 17 00:00:00 2001 +From 455187f2528a6dd987a8add6e7db055978c9b5c4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/8] Don't add rpaths to libraries. +Subject: [PATCH 1/5] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile -index 96a4244cc..076411a91 100644 +index dbad0b74f..c920a5337 100644 --- a/tools/Makefile +++ b/tools/Makefile -@@ -153,8 +153,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ +@@ -154,8 +154,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ ocamlmklibconfig.ml: $(ROOTDIR)/Makefile.config Makefile (echo 'let bindir = "$(BINDIR)"'; \ echo 'let supports_shared_libraries = $(SUPPORTS_SHARED_LIBRARIES)';\ diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 1ce4168..566f096 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,14 +1,14 @@ -From 8ea0bc7713a89cd6340e35b4dae048be63c50aec Mon Sep 17 00:00:00 2001 +From 183e55d0a61a9e50db1b861d1e3918ee2fecc544 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/8] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index fbd49c1ee..a35da2040 100644 +index aa5f26f28..5153853b7 100644 --- a/configure.ac +++ b/configure.ac @@ -609,6 +609,10 @@ AS_CASE([$host], diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index d41e1b2..95ceec1 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From 39df379f1aa139a073d7b436bb9bd33ef2f70caf Mon Sep 17 00:00:00 2001 +From 89bd3487c135b4ff51b97e1fde67a45485be4af8 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/8] configure: Remove incorrect assumption about +Subject: [PATCH 3/5] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -10,7 +10,7 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index a35da2040..4c9358897 100644 +index 5153853b7..4e97474a2 100644 --- a/configure.ac +++ b/configure.ac @@ -511,10 +511,11 @@ AS_IF( @@ -29,7 +29,7 @@ index a35da2040..4c9358897 100644 # Checks for programs -@@ -1018,7 +1019,7 @@ AS_CASE([$arch], +@@ -1021,7 +1022,7 @@ AS_CASE([$arch], # Assembler diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index 881c81d..ead8e9a 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,7 +1,7 @@ -From e829051c3b35920db3c5e0dd913026f556448675 Mon Sep 17 00:00:00 2001 +From 38d51966a2f35cc411ceda2d61946edfb62ee8fc Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 -Subject: [PATCH 4/8] Remove configure from .gitattributes. +Subject: [PATCH 4/5] Remove configure from .gitattributes. It's not a binary file. --- diff --git a/0005-Add-RISC-V-native-code-backend-9441.patch b/0005-Add-RISC-V-native-code-backend-9441.patch deleted file mode 100644 index 1e2904f..0000000 --- a/0005-Add-RISC-V-native-code-backend-9441.patch +++ /dev/null @@ -1,2012 +0,0 @@ -From 1a0ca036e40cbd701cbe3f0e5cf5e2a6b6d4c804 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= -Date: Fri, 24 Apr 2020 16:04:50 +0200 -Subject: [PATCH 5/8] Add RISC-V native-code backend (#9441) - -This is a port of ocamlopt for the RISC-V processor in 64-bit mode. - -(cherry picked from commit 8f3833c4d0ef656c826359f4137c1eb3d46ea0ef) ---- - Changes | 3 + - Makefile | 2 +- - README.adoc | 1 + - asmcomp/riscv/CSE.ml | 39 ++ - asmcomp/riscv/NOTES.md | 18 + - asmcomp/riscv/arch.ml | 87 +++++ - asmcomp/riscv/emit.mlp | 684 +++++++++++++++++++++++++++++++++ - asmcomp/riscv/proc.ml | 334 ++++++++++++++++ - asmcomp/riscv/reload.ml | 19 + - asmcomp/riscv/scheduling.ml | 22 ++ - asmcomp/riscv/selection.ml | 75 ++++ - configure | 8 +- - configure.ac | 9 +- - runtime/caml/stack.h | 5 + - runtime/riscv.S | 423 ++++++++++++++++++++ - testsuite/tools/asmgen_riscv.S | 89 +++++ - 16 files changed, 1812 insertions(+), 6 deletions(-) - create mode 100644 asmcomp/riscv/CSE.ml - create mode 100644 asmcomp/riscv/NOTES.md - create mode 100644 asmcomp/riscv/arch.ml - create mode 100644 asmcomp/riscv/emit.mlp - create mode 100644 asmcomp/riscv/proc.ml - create mode 100644 asmcomp/riscv/reload.ml - create mode 100644 asmcomp/riscv/scheduling.ml - create mode 100644 asmcomp/riscv/selection.ml - create mode 100644 runtime/riscv.S - create mode 100644 testsuite/tools/asmgen_riscv.S - -diff --git a/Changes b/Changes -index d92ade2df..b7336c154 100644 ---- a/Changes -+++ b/Changes -@@ -121,6 +121,9 @@ OCaml 4.11 - - #9392: Visit registers at most once in Coloring.iter_preferred. - (Stephen Dolan, review by Pierre Chambart and Xavier Leroy) - -+- #9441: Add RISC-V RV64G native-code backend. -+ (Nicolás Ojeda Bär, review by Xavier Leroy and Gabriel Scherer) -+ - ### Standard library: - - - #9077: Add Seq.cons and Seq.append -diff --git a/Makefile b/Makefile -index fc9b179a4..2984178a8 100644 ---- a/Makefile -+++ b/Makefile -@@ -51,7 +51,7 @@ include stdlib/StdlibModules - - CAMLC=$(BOOT_OCAMLC) -g -nostdlib -I boot -use-prims runtime/primitives - CAMLOPT=$(CAMLRUN) ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink --ARCHES=amd64 i386 arm arm64 power s390x -+ARCHES=amd64 i386 arm arm64 power s390x riscv - INCLUDES=-I utils -I parsing -I typing -I bytecomp -I file_formats \ - -I lambda -I middle_end -I middle_end/closure \ - -I middle_end/flambda -I middle_end/flambda/base_types \ -diff --git a/README.adoc b/README.adoc -index 84eb169b2..4365c2f12 100644 ---- a/README.adoc -+++ b/README.adoc -@@ -62,6 +62,7 @@ compiler currently runs on the following platforms: - | ARM 32 bits | Linux | FreeBSD, NetBSD, OpenBSD - | Power 64 bits | Linux | - | Power 32 bits | | Linux -+| RISC-V 64 bits | Linux | - | IBM Z (s390x) | Linux | - |==== - -diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml -new file mode 100644 -index 000000000..6aed1c07f ---- /dev/null -+++ b/asmcomp/riscv/CSE.ml -@@ -0,0 +1,39 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* CSE for the RISC-V *) -+ -+open Arch -+open Mach -+open CSEgen -+ -+class cse = object (_self) -+ -+inherit cse_generic as super -+ -+method! class_of_operation op = -+ match op with -+ | Ispecific(Imultaddf _ | Imultsubf _) -> Op_pure -+ | _ -> super#class_of_operation op -+ -+method! is_cheap_operation op = -+ match op with -+ | Iconst_int n -> n <= 0x7FFn && n >= -0x800n -+ | _ -> false -+ -+end -+ -+let fundecl f = -+ (new cse)#fundecl f -diff --git a/asmcomp/riscv/NOTES.md b/asmcomp/riscv/NOTES.md -new file mode 100644 -index 000000000..3b00d08ec ---- /dev/null -+++ b/asmcomp/riscv/NOTES.md -@@ -0,0 +1,18 @@ -+# Supported platforms -+ -+RISC-V in 64-bit mode, general variant, a.k.a `RV64G`. -+ -+Debian architecture name: `riscv64` -+ -+# Reference documents -+ -+* Instruction set specification: -+ - https://riscv.org/specifications/isa-spec-pdf/ -+ - https://rv8.io/isa -+ -+* ELF ABI specification: -+ - https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md -+ -+* Assembly language manual -+ - https://github.com/riscv/riscv-asm-manual/blob/master/riscv-asm.md -+ - https://rv8.io/asm -diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml -new file mode 100644 -index 000000000..c6ade5279 ---- /dev/null -+++ b/asmcomp/riscv/arch.ml -@@ -0,0 +1,87 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Specific operations for the RISC-V processor *) -+ -+open Format -+ -+(* Machine-specific command-line options *) -+ -+let command_line_options = [] -+ -+(* Specific operations *) -+ -+type specific_operation = -+ | Imultaddf of bool (* multiply, optionally negate, and add *) -+ | Imultsubf of bool (* multiply, optionally negate, and subtract *) -+ -+let spacetime_node_hole_pointer_is_live_before = function -+ | Imultaddf _ | Imultsubf _ -> false -+ -+(* Addressing modes *) -+ -+type addressing_mode = -+ | Iindexed of int (* reg + displ *) -+ -+let is_immediate n = -+ (n <= 0x7FF) && (n >= -0x800) -+ -+(* Sizes, endianness *) -+ -+let big_endian = false -+ -+let size_addr = 8 -+let size_int = size_addr -+let size_float = 8 -+ -+let allow_unaligned_access = false -+ -+(* Behavior of division *) -+ -+let division_crashes_on_overflow = false -+ -+(* Operations on addressing modes *) -+ -+let identity_addressing = Iindexed 0 -+ -+let offset_addressing addr delta = -+ match addr with -+ | Iindexed n -> Iindexed(n + delta) -+ -+let num_args_addressing = function -+ | Iindexed _ -> 1 -+ -+(* Printing operations and addressing modes *) -+ -+let print_addressing printreg addr ppf arg = -+ match addr with -+ | Iindexed n -> -+ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in -+ fprintf ppf "%a%s" printreg arg.(0) idx -+ -+let print_specific_operation printreg op ppf arg = -+ match op with -+ | Imultaddf false -> -+ fprintf ppf "%a *f %a +f %a" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultaddf true -> -+ fprintf ppf "-f (%a *f %a +f %a)" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultsubf false -> -+ fprintf ppf "%a *f %a -f %a" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -+ | Imultsubf true -> -+ fprintf ppf "-f (%a *f %a -f %a)" -+ printreg arg.(0) printreg arg.(1) printreg arg.(2) -diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp -new file mode 100644 -index 000000000..dc652de42 ---- /dev/null -+++ b/asmcomp/riscv/emit.mlp -@@ -0,0 +1,684 @@ -+# 2 "asmcomp/riscv/emit.mlp" -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Emission of RISC-V assembly code *) -+ -+open Cmm -+open Arch -+open Proc -+open Reg -+open Mach -+open Linear -+open Emitaux -+ -+(* Layout of the stack. The stack is kept 16-aligned. *) -+ -+let stack_offset = ref 0 -+ -+let num_stack_slots = Array.make Proc.num_register_classes 0 -+ -+let prologue_required = ref false -+ -+let contains_calls = ref false -+ -+let frame_size () = -+ let size = -+ !stack_offset + (* Trap frame, outgoing parameters *) -+ size_int * num_stack_slots.(0) + (* Local int variables *) -+ size_float * num_stack_slots.(1) + (* Local float variables *) -+ (if !contains_calls then size_addr else 0) in (* The return address *) -+ Misc.align size 16 -+ -+let slot_offset loc cls = -+ match loc with -+ | Local n -> -+ if cls = 0 -+ then !stack_offset + num_stack_slots.(1) * size_float + n * size_int -+ else !stack_offset + n * size_float -+ | Incoming n -> frame_size() + n -+ | Outgoing n -> n -+ -+(* Output a symbol *) -+ -+let emit_symbol s = -+ emit_symbol '$' s -+ -+let emit_jump op s = -+ if !Clflags.dlcode || !Clflags.pic_code -+ then `{emit_string op} {emit_symbol s}@plt` -+ else `{emit_string op} {emit_symbol s}` -+ -+let emit_call = emit_jump "call" -+let emit_tail = emit_jump "tail" -+ -+(* Output a label *) -+ -+let emit_label lbl = -+ emit_string ".L"; emit_int lbl -+ -+(* Section switching *) -+ -+let data_space = -+ ".section .data" -+ -+let code_space = -+ ".section .text" -+ -+let rodata_space = -+ ".section .rodata" -+ -+(* Names for special regs *) -+ -+let reg_tmp = phys_reg 22 -+let reg_t2 = phys_reg 16 -+let reg_domain_state_ptr = phys_reg 23 -+let reg_trap = phys_reg 24 -+let reg_alloc_ptr = phys_reg 25 -+let reg_alloc_lim = phys_reg 26 -+ -+(* Output a pseudo-register *) -+ -+let reg_name = function -+ | {loc = Reg r} -> register_name r -+ | _ -> Misc.fatal_error "Emit.reg_name" -+ -+let emit_reg r = -+ emit_string (reg_name r) -+ -+(* Adjust sp by the given byte amount *) -+ -+let emit_stack_adjustment = function -+ | 0 -> () -+ | n when is_immediate n -> -+ ` addi sp, sp, {emit_int n}\n` -+ | n -> -+ ` li {emit_reg reg_tmp}, {emit_int n}\n`; -+ ` add sp, sp, {emit_reg reg_tmp}\n` -+ -+let emit_mem_op op src ofs = -+ if is_immediate ofs then -+ ` {emit_string op} {emit_string src}, {emit_int ofs}(sp)\n` -+ else begin -+ ` li {emit_reg reg_tmp}, {emit_int ofs}\n`; -+ ` add {emit_reg reg_tmp}, sp, {emit_reg reg_tmp}\n`; -+ ` {emit_string op} {emit_string src}, 0({emit_reg reg_tmp})\n` -+ end -+ -+let emit_store src ofs = -+ emit_mem_op "sd" src ofs -+ -+let emit_load dst ofs = -+ emit_mem_op "ld" dst ofs -+ -+let reload_ra n = -+ emit_load "ra" (n - size_addr) -+ -+let store_ra n = -+ emit_store "ra" (n - size_addr) -+ -+let emit_store src ofs = -+ emit_store (reg_name src) ofs -+ -+let emit_load dst ofs = -+ emit_load (reg_name dst) ofs -+ -+let emit_float_load dst ofs = -+ emit_mem_op "fld" (reg_name dst) ofs -+ -+let emit_float_store src ofs = -+ emit_mem_op "fsd" (reg_name src) ofs -+ -+(* Record live pointers at call points *) -+ -+let record_frame_label ?label live dbg = -+ let lbl = -+ match label with -+ | None -> new_label() -+ | Some label -> label -+ in -+ let live_offset = ref [] in -+ Reg.Set.iter -+ (function -+ {typ = Val; loc = Reg r} -> -+ live_offset := (r lsl 1) + 1 :: !live_offset -+ | {typ = Val; loc = Stack s} as reg -> -+ live_offset := slot_offset s (register_class reg) :: !live_offset -+ | {typ = Addr} as r -> -+ Misc.fatal_error ("bad GC root " ^ Reg.name r) -+ | _ -> () -+ ) -+ live; -+ record_frame_descr ~label:lbl ~frame_size:(frame_size()) -+ ~live_offset:!live_offset dbg; -+ lbl -+ -+let record_frame ?label live dbg = -+ let lbl = record_frame_label ?label live dbg in -+ `{emit_label lbl}:\n` -+ -+(* Record calls to the GC -- we've moved them out of the way *) -+ -+type gc_call = -+ { gc_lbl: label; (* Entry label *) -+ gc_return_lbl: label; (* Where to branch after GC *) -+ gc_frame_lbl: label } (* Label of frame descriptor *) -+ -+let call_gc_sites = ref ([] : gc_call list) -+ -+let emit_call_gc gc = -+ `{emit_label gc.gc_lbl}:\n`; -+ ` {emit_call "caml_call_gc"}\n`; -+ `{emit_label gc.gc_frame_lbl}:\n`; -+ ` j {emit_label gc.gc_return_lbl}\n` -+ -+(* Record calls to caml_ml_array_bound_error. -+ In debug mode, we maintain one call to caml_ml_array_bound_error -+ per bound check site. Otherwise, we can share a single call. *) -+ -+type bound_error_call = -+ { bd_lbl: label; (* Entry label *) -+ bd_frame_lbl: label } (* Label of frame descriptor *) -+ -+let bound_error_sites = ref ([] : bound_error_call list) -+ -+let bound_error_label ?label dbg = -+ if !Clflags.debug || !bound_error_sites = [] then begin -+ let lbl_bound_error = new_label() in -+ let lbl_frame = record_frame_label ?label Reg.Set.empty (Dbg_other dbg) in -+ bound_error_sites := -+ { bd_lbl = lbl_bound_error; -+ bd_frame_lbl = lbl_frame } :: !bound_error_sites; -+ lbl_bound_error -+ end else -+ let bd = List.hd !bound_error_sites in -+ bd.bd_lbl -+ -+let emit_call_bound_error bd = -+ `{emit_label bd.bd_lbl}:\n`; -+ ` {emit_call "caml_ml_array_bound_error"}\n`; -+ `{emit_label bd.bd_frame_lbl}:\n` -+ -+(* Record floating-point literals *) -+ -+let float_literals = ref ([] : (int64 * int) list) -+ -+(* Names for various instructions *) -+ -+let name_for_intop = function -+ | Iadd -> "add" -+ | Isub -> "sub" -+ | Imul -> "mul" -+ | Imulh -> "mulh" -+ | Idiv -> "div" -+ | Iand -> "and" -+ | Ior -> "or" -+ | Ixor -> "xor" -+ | Ilsl -> "sll" -+ | Ilsr -> "srl" -+ | Iasr -> "sra" -+ | Imod -> "rem" -+ | _ -> Misc.fatal_error "Emit.Intop" -+ -+let name_for_intop_imm = function -+ | Iadd -> "addi" -+ | Iand -> "andi" -+ | Ior -> "ori" -+ | Ixor -> "xori" -+ | Ilsl -> "slli" -+ | Ilsr -> "srli" -+ | Iasr -> "srai" -+ | _ -> Misc.fatal_error "Emit.Intop_imm" -+ -+let name_for_floatop1 = function -+ | Inegf -> "fneg.d" -+ | Iabsf -> "fabs.d" -+ | _ -> Misc.fatal_error "Emit.Iopf1" -+ -+let name_for_floatop2 = function -+ | Iaddf -> "fadd.d" -+ | Isubf -> "fsub.d" -+ | Imulf -> "fmul.d" -+ | Idivf -> "fdiv.d" -+ | _ -> Misc.fatal_error "Emit.Iopf2" -+ -+let name_for_specific = function -+ | Imultaddf false -> "fmadd.d" -+ | Imultaddf true -> "fnmadd.d" -+ | Imultsubf false -> "fmsub.d" -+ | Imultsubf true -> "fnmsub.d" -+ -+(* Name of current function *) -+let function_name = ref "" -+ -+(* Entry point for tail recursive calls *) -+let tailrec_entry_point = ref 0 -+ -+(* Output the assembly code for an instruction *) -+ -+let emit_instr i = -+ emit_debug_info i.dbg; -+ match i.desc with -+ Lend -> () -+ | Lprologue -> -+ assert (!prologue_required); -+ let n = frame_size() in -+ emit_stack_adjustment (-n); -+ if !contains_calls then store_ra n -+ | Lop(Imove | Ispill | Ireload) -> -+ let src = i.arg.(0) and dst = i.res.(0) in -+ if src.loc <> dst.loc then begin -+ match (src, dst) with -+ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> -+ ` mv {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = Float}, {loc = Reg _} -> -+ ` fmv.d {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> -+ let ofs = slot_offset s (register_class dst) in -+ emit_store src ofs -+ | {loc = Reg _; typ = Float}, {loc = Stack s} -> -+ let ofs = slot_offset s (register_class dst) in -+ emit_float_store src ofs -+ | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> -+ let ofs = slot_offset s (register_class src) in -+ emit_load dst ofs -+ | {loc = Stack s; typ = Float}, {loc = Reg _} -> -+ let ofs = slot_offset s (register_class src) in -+ emit_float_load dst ofs -+ | {loc = Stack _}, {loc = Stack _} -+ | {loc = Unknown}, _ | _, {loc = Unknown} -> -+ Misc.fatal_error "Emit: Imove" -+ end -+ | Lop(Iconst_int n) -> -+ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` -+ | Lop(Iconst_float f) -> -+ let lbl = new_label() in -+ float_literals := (f, lbl) :: !float_literals; -+ ` fld {emit_reg i.res.(0)}, {emit_label lbl}, {emit_reg reg_tmp}\n` -+ | Lop(Iconst_symbol s) -> -+ ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` -+ | Lop(Icall_ind {label_after = label}) -> -+ ` jalr {emit_reg i.arg.(0)}\n`; -+ record_frame ~label i.live (Dbg_other i.dbg) -+ | Lop(Icall_imm {func; label_after = label}) -> -+ ` {emit_call func}\n`; -+ record_frame ~label i.live (Dbg_other i.dbg) -+ | Lop(Itailcall_ind {label_after = _}) -> -+ let n = frame_size() in -+ if !contains_calls then reload_ra n; -+ emit_stack_adjustment n; -+ ` jr {emit_reg i.arg.(0)}\n` -+ | Lop(Itailcall_imm {func; label_after = _}) -> -+ if func = !function_name then begin -+ ` j {emit_label !tailrec_entry_point}\n` -+ end else begin -+ let n = frame_size() in -+ if !contains_calls then reload_ra n; -+ emit_stack_adjustment n; -+ ` {emit_tail func}\n` -+ end -+ | Lop(Iextcall{func; alloc = true; label_after = label}) -> -+ ` la {emit_reg reg_t2}, {emit_symbol func}\n`; -+ ` {emit_call "caml_c_call"}\n`; -+ record_frame ~label i.live (Dbg_other i.dbg) -+ | Lop(Iextcall{func; alloc = false; label_after = _}) -> -+ ` {emit_call func}\n` -+ | Lop(Istackoffset n) -> -+ assert (n mod 16 = 0); -+ emit_stack_adjustment (-n); -+ stack_offset := !stack_offset + n -+ | Lop(Iload(Single, Iindexed ofs)) -> -+ ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; -+ ` fcvt.d.s {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Lop(Iload(chunk, Iindexed ofs)) -> -+ let instr = -+ match chunk with -+ | Byte_unsigned -> "lbu" -+ | Byte_signed -> "lb" -+ | Sixteen_unsigned -> "lhu" -+ | Sixteen_signed -> "lh" -+ | Thirtytwo_unsigned -> "lwu" -+ | Thirtytwo_signed -> "lw" -+ | Word_int | Word_val -> "ld" -+ | Single -> assert false -+ | Double | Double_u -> "fld" -+ in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n` -+ | Lop(Istore(Single, Iindexed ofs, _)) -> -+ (* ft0 is marked as destroyed for this operation *) -+ ` fcvt.s.d ft0, {emit_reg i.arg.(0)}\n`; -+ ` fsw ft0, {emit_int ofs}({emit_reg i.arg.(1)})\n` -+ | Lop(Istore(chunk, Iindexed ofs, _)) -> -+ let instr = -+ match chunk with -+ | Byte_unsigned | Byte_signed -> "sb" -+ | Sixteen_unsigned | Sixteen_signed -> "sh" -+ | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" -+ | Word_int | Word_val -> "sd" -+ | Single -> assert false -+ | Double | Double_u -> "fsd" -+ in -+ ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` -+ | Lop(Ialloc {bytes; label_after_call_gc = label; dbginfo}) -> -+ let lbl_frame_lbl = record_frame_label ?label i.live (Dbg_alloc dbginfo) in -+ let lbl_after_alloc = new_label () in -+ let lbl_call_gc = new_label () in -+ let n = -bytes in -+ if is_immediate n then -+ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_int n}\n` -+ else begin -+ ` li {emit_reg reg_tmp}, {emit_int n}\n`; -+ ` add {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, {emit_reg reg_tmp}\n` -+ end; -+ ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; -+ `{emit_label lbl_after_alloc}:\n`; -+ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; -+ call_gc_sites := -+ { gc_lbl = lbl_call_gc; -+ gc_return_lbl = lbl_after_alloc; -+ gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites -+ | Lop(Iintop(Icomp cmp)) -> -+ begin match cmp with -+ | Isigned Clt -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Isigned Cge -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Isigned Cgt -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | Isigned Cle -> -+ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Isigned Ceq | Iunsigned Ceq -> -+ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` seqz {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Isigned Cne | Iunsigned Cne -> -+ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` snez {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` -+ | Iunsigned Clt -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Iunsigned Cge -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ | Iunsigned Cgt -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | Iunsigned Cle -> -+ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; -+ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; -+ end -+ | Lop(Iintop (Icheckbound {label_after_error = label; _})) -> -+ let lbl = bound_error_label ?label i.dbg in -+ ` bleu {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` -+ | Lop(Iintop op) -> -+ let instr = name_for_intop op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Lop(Iintop_imm(Isub, n)) -> -+ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` -+ | Lop(Iintop_imm(Icomp _, _)) -> -+ Misc.fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" -+ | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> -+ let lbl = bound_error_label ?label i.dbg in -+ ` li {emit_reg reg_tmp}, {emit_int n}\n`; -+ ` bleu {emit_reg i.arg.(0)}, {emit_reg reg_tmp}, {emit_label lbl}\n` -+ | Lop(Iintop_imm(op, n)) -> -+ let instr = name_for_intop_imm op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` -+ | Lop(Inegf | Iabsf as op) -> -+ let instr = name_for_floatop1 op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> -+ let instr = name_for_floatop2 op in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | Lop(Ifloatofint) -> -+ ` fcvt.d.l {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` -+ | Lop(Iintoffloat) -> -+ ` fcvt.l.d {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, rtz\n` -+ | Lop(Ispecific sop) -> -+ let instr = name_for_specific sop in -+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` -+ | Lop (Iname_for_debugger _) -> -+ () -+ | Lreloadretaddr -> -+ let n = frame_size () in -+ reload_ra n -+ | Lreturn -> -+ let n = frame_size() in -+ emit_stack_adjustment n; -+ ` ret\n` -+ | Llabel lbl -> -+ `{emit_label lbl}:\n` -+ | Lbranch lbl -> -+ ` j {emit_label lbl}\n` -+ | Lcondbranch(tst, lbl) -> -+ begin match tst with -+ | Itruetest -> -+ ` bnez {emit_reg i.arg.(0)}, {emit_label lbl}\n` -+ | Ifalsetest -> -+ ` beqz {emit_reg i.arg.(0)}, {emit_label lbl}\n` -+ | Iinttest cmp -> -+ let name = match cmp with -+ | Iunsigned Ceq | Isigned Ceq -> "beq" -+ | Iunsigned Cne | Isigned Cne -> "bne" -+ | Iunsigned Cle -> "bleu" | Isigned Cle -> "ble" -+ | Iunsigned Cge -> "bgeu" | Isigned Cge -> "bge" -+ | Iunsigned Clt -> "bltu" | Isigned Clt -> "blt" -+ | Iunsigned Cgt -> "bgtu" | Isigned Cgt -> "bgt" -+ in -+ ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` -+ | Iinttest_imm _ -> -+ Misc.fatal_error "Emit.emit_instr (Iinttest_imm _)" -+ | Ifloattest cmp -> -+ let branch = -+ match cmp with -+ | CFneq | CFnlt | CFngt | CFnle | CFnge -> "beqz" -+ | CFeq | CFlt | CFgt | CFle | CFge -> "bnez" -+ in -+ begin match cmp with -+ | CFeq | CFneq -> ` feq.d {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFlt | CFnlt -> ` flt.d {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFgt | CFngt -> ` flt.d {emit_reg reg_tmp}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ | CFle | CFnle -> ` fle.d {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` -+ | CFge | CFnge -> ` fle.d {emit_reg reg_tmp}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` -+ end; -+ ` {emit_string branch} {emit_reg reg_tmp}, {emit_label lbl}\n` -+ | Ioddtest -> -+ ` andi {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, 1\n`; -+ ` bnez {emit_reg reg_tmp}, {emit_label lbl}\n` -+ | Ieventest -> -+ ` andi {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, 1\n`; -+ ` beqz {emit_reg reg_tmp}, {emit_label lbl}\n` -+ end -+ | Lcondbranch3(lbl0, lbl1, lbl2) -> -+ ` addi {emit_reg reg_tmp}, {emit_reg i.arg.(0)}, -1\n`; -+ begin match lbl0 with -+ | None -> () -+ | Some lbl -> ` bltz {emit_reg reg_tmp}, {emit_label lbl}\n` -+ end; -+ begin match lbl1 with -+ | None -> () -+ | Some lbl -> ` beqz {emit_reg reg_tmp}, {emit_label lbl}\n` -+ end; -+ begin match lbl2 with -+ | None -> () -+ | Some lbl -> ` bgtz {emit_reg reg_tmp}, {emit_label lbl}\n` -+ end -+ | Lswitch jumptbl -> -+ (* t0 is marked as destroyed for this operation *) -+ let lbl = new_label() in -+ ` la {emit_reg reg_tmp}, {emit_label lbl}\n`; -+ ` slli t0, {emit_reg i.arg.(0)}, 2\n`; -+ ` add {emit_reg reg_tmp}, {emit_reg reg_tmp}, t0\n`; -+ ` jr {emit_reg reg_tmp}\n`; -+ `{emit_label lbl}:\n`; -+ for i = 0 to Array.length jumptbl - 1 do -+ ` j {emit_label jumptbl.(i)}\n` -+ done -+ | Lentertrap -> -+ () -+ | Ladjust_trap_depth { delta_traps } -> -+ (* each trap occupes 16 bytes on the stack *) -+ let delta = 16 * delta_traps in -+ stack_offset := !stack_offset + delta -+ | Lpushtrap {lbl_handler} -> -+ ` la {emit_reg reg_tmp}, {emit_label lbl_handler}\n`; -+ ` addi sp, sp, -16\n`; -+ stack_offset := !stack_offset + 16; -+ emit_store reg_tmp size_addr; -+ emit_store reg_trap 0; -+ ` mv {emit_reg reg_trap}, sp\n` -+ | Lpoptrap -> -+ emit_load reg_trap 0; -+ ` addi sp, sp, 16\n`; -+ stack_offset := !stack_offset - 16 -+ | Lraise k -> -+ begin match k with -+ | Lambda.Raise_regular -> -+ let offset = Domainstate.(idx_of_field Domain_backtrace_pos) * 8 in -+ ` sd zero, {emit_int offset}({emit_reg reg_domain_state_ptr})\n`; -+ ` {emit_call "caml_raise_exn"}\n`; -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) -+ | Lambda.Raise_reraise -> -+ ` {emit_call "caml_raise_exn"}\n`; -+ record_frame Reg.Set.empty (Dbg_raise i.dbg) -+ | Lambda.Raise_notrace -> -+ ` mv sp, {emit_reg reg_trap}\n`; -+ emit_load reg_tmp size_addr; -+ emit_load reg_trap 0; -+ ` addi sp, sp, 16\n`; -+ ` jr {emit_reg reg_tmp}\n` -+ end -+ -+(* Emit a sequence of instructions *) -+ -+let rec emit_all = function -+ | {desc = Lend} -> () | i -> emit_instr i; emit_all i.next -+ -+(* Emission of a function declaration *) -+ -+let fundecl fundecl = -+ function_name := fundecl.fun_name; -+ tailrec_entry_point := fundecl.fun_tailrec_entry_point_label; -+ stack_offset := 0; -+ call_gc_sites := []; -+ bound_error_sites := []; -+ for i = 0 to Proc.num_register_classes - 1 do -+ num_stack_slots.(i) <- fundecl.fun_num_stack_slots.(i); -+ done; -+ prologue_required := fundecl.fun_prologue_required; -+ contains_calls := fundecl.fun_contains_calls; -+ float_literals := []; -+ ` .globl {emit_symbol fundecl.fun_name}\n`; -+ ` .type {emit_symbol fundecl.fun_name}, @function\n`; -+ ` {emit_string code_space}\n`; -+ ` .align 2\n`; -+ `{emit_symbol fundecl.fun_name}:\n`; -+ emit_debug_info fundecl.fun_dbg; -+ emit_all fundecl.fun_body; -+ List.iter emit_call_gc !call_gc_sites; -+ List.iter emit_call_bound_error !bound_error_sites; -+ ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; -+ (* Emit the float literals *) -+ if !float_literals <> [] then begin -+ ` {emit_string rodata_space}\n`; -+ ` .align 3\n`; -+ List.iter -+ (fun (f, lbl) -> -+ `{emit_label lbl}:\n`; -+ emit_float64_directive ".quad" f) -+ !float_literals; -+ end -+ -+(* Emission of data *) -+ -+let declare_global_data s = -+ ` .globl {emit_symbol s}\n`; -+ ` .type {emit_symbol s}, @object\n` -+ -+let emit_item = function -+ | Cglobal_symbol s -> -+ declare_global_data s -+ | Cdefine_symbol s -> -+ `{emit_symbol s}:\n`; -+ | Cint8 n -> -+ ` .byte {emit_int n}\n` -+ | Cint16 n -> -+ ` .short {emit_int n}\n` -+ | Cint32 n -> -+ ` .long {emit_nativeint n}\n` -+ | Cint n -> -+ ` .quad {emit_nativeint n}\n` -+ | Csingle f -> -+ emit_float32_directive ".long" (Int32.bits_of_float f) -+ | Cdouble f -> -+ emit_float64_directive ".quad" (Int64.bits_of_float f) -+ | Csymbol_address s -> -+ ` .quad {emit_symbol s}\n` -+ | Cstring s -> -+ emit_bytes_directive " .byte " s -+ | Cskip n -> -+ if n > 0 then ` .space {emit_int n}\n` -+ | Calign n -> -+ ` .align {emit_int (Misc.log2 n)}\n` -+ -+let data l = -+ ` {emit_string data_space}\n`; -+ List.iter emit_item l -+ -+(* Beginning / end of an assembly file *) -+ -+let begin_assembly() = -+ if !Clflags.dlcode || !Clflags.pic_code then ` .option pic\n`; -+ ` .file \"\"\n`; (* PR#7073 *) -+ reset_debug_info (); -+ (* Emit the beginning of the segments *) -+ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in -+ ` {emit_string data_space}\n`; -+ declare_global_data lbl_begin; -+ `{emit_symbol lbl_begin}:\n`; -+ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in -+ ` {emit_string code_space}\n`; -+ declare_global_data lbl_begin; -+ `{emit_symbol lbl_begin}:\n` -+ -+let end_assembly() = -+ ` {emit_string code_space}\n`; -+ let lbl_end = Compilenv.make_symbol (Some "code_end") in -+ declare_global_data lbl_end; -+ `{emit_symbol lbl_end}:\n`; -+ ` .long 0\n`; -+ ` {emit_string data_space}\n`; -+ let lbl_end = Compilenv.make_symbol (Some "data_end") in -+ declare_global_data lbl_end; -+ ` .quad 0\n`; (* PR#6329 *) -+ `{emit_symbol lbl_end}:\n`; -+ ` .quad 0\n`; -+ (* Emit the frame descriptors *) -+ ` {emit_string rodata_space}\n`; -+ let lbl = Compilenv.make_symbol (Some "frametable") in -+ declare_global_data lbl; -+ `{emit_symbol lbl}:\n`; -+ emit_frames -+ { efa_code_label = (fun l -> ` .quad {emit_label l}\n`); -+ efa_data_label = (fun l -> ` .quad {emit_label l}\n`); -+ efa_8 = (fun n -> ` .byte {emit_int n}\n`); -+ efa_16 = (fun n -> ` .short {emit_int n}\n`); -+ efa_32 = (fun n -> ` .long {emit_int32 n}\n`); -+ efa_word = (fun n -> ` .quad {emit_int n}\n`); -+ efa_align = (fun n -> ` .align {emit_int (Misc.log2 n)}\n`); -+ efa_label_rel = (fun lbl ofs -> -+ ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); -+ efa_def_label = (fun l -> `{emit_label l}:\n`); -+ efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) -+ } -diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml -new file mode 100644 -index 000000000..70909cd83 ---- /dev/null -+++ b/asmcomp/riscv/proc.ml -@@ -0,0 +1,334 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Description of the RISC-V *) -+ -+open Misc -+open Cmm -+open Reg -+open Arch -+open Mach -+ -+(* Instruction selection *) -+ -+let word_addressed = false -+ -+(* Registers available for register allocation *) -+ -+(* Integer register map -+ -------------------- -+ -+ zero always zero -+ ra return address -+ sp, gp, tp stack pointer, global pointer, thread pointer -+ a0-a7 0-7 arguments/results -+ s2-s9 8-15 arguments/results (preserved by C) -+ t2-t6 16-20 temporary -+ t0-t1 21-22 temporary (used by code generator) -+ s0 23 domain pointer (preserved by C) -+ s1 24 trap pointer (preserved by C) -+ s10 25 allocation pointer (preserved by C) -+ s11 26 allocation limit (preserved by C) -+ -+ Floating-point register map -+ --------------------------- -+ -+ ft0-ft7 100-107 temporary -+ fs0-fs1 108-109 general purpose (preserved by C) -+ fa0-fa7 110-117 arguments/results -+ fs2-fs9 118-125 arguments/results (preserved by C) -+ fs10-fs11 126-127 general purpose (preserved by C) -+ ft8-ft11 128-131 temporary -+ -+ Additional notes -+ ---------------- -+ -+ - t0-t1 are used by the assembler and code generator, so -+ not available for register allocation. -+ -+ - t0-t6 may be used by PLT stubs, so should not be used to pass -+ arguments and may be clobbered by [Ialloc] in the presence of dynamic -+ linking. -+*) -+ -+let int_reg_name = -+ [| "a0"; "a1"; "a2"; "a3"; "a4"; "a5"; "a6"; "a7"; -+ "s2"; "s3"; "s4"; "s5"; "s6"; "s7"; "s8"; "s9"; -+ "t2"; "t3"; "t4"; "t5"; "t6"; -+ "t0"; "t1"; -+ "s0"; "s1"; "s10"; "s11" |] -+ -+let float_reg_name = -+ [| "ft0"; "ft1"; "ft2"; "ft3"; "ft4"; "ft5"; "ft6"; "ft7"; -+ "fs0"; "fs1"; -+ "fa0"; "fa1"; "fa2"; "fa3"; "fa4"; "fa5"; "fa6"; "fa7"; -+ "fs2"; "fs3"; "fs4"; "fs5"; "fs6"; "fs7"; "fs8"; "fs9"; "fs10"; "fs11"; -+ "ft8"; "ft9"; "ft10"; "ft11" |] -+ -+let num_register_classes = 2 -+ -+let register_class r = -+ match r.typ with -+ | Val | Int | Addr -> 0 -+ | Float -> 1 -+ -+let num_available_registers = [| 22; 32 |] -+ -+let first_available_register = [| 0; 100 |] -+ -+let register_name r = -+ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) -+ -+let rotate_registers = true -+ -+(* Representation of hard registers by pseudo-registers *) -+ -+let hard_int_reg = -+ let v = Array.make 27 Reg.dummy in -+ for i = 0 to 26 do -+ v.(i) <- Reg.at_location Int (Reg i) -+ done; -+ v -+ -+let hard_float_reg = -+ let v = Array.make 32 Reg.dummy in -+ for i = 0 to 31 do -+ v.(i) <- Reg.at_location Float (Reg(100 + i)) -+ done; -+ v -+ -+let all_phys_regs = -+ Array.append hard_int_reg hard_float_reg -+ -+let phys_reg n = -+ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) -+ -+let stack_slot slot ty = -+ Reg.at_location ty (Stack slot) -+ -+(* Calling conventions *) -+ -+let calling_conventions -+ first_int last_int first_float last_float make_stack arg = -+ let loc = Array.make (Array.length arg) Reg.dummy in -+ let int = ref first_int in -+ let float = ref first_float in -+ let ofs = ref 0 in -+ for i = 0 to Array.length arg - 1 do -+ match arg.(i).typ with -+ | Val | Int | Addr as ty -> -+ if !int <= last_int then begin -+ loc.(i) <- phys_reg !int; -+ incr int -+ end else begin -+ loc.(i) <- stack_slot (make_stack !ofs) ty; -+ ofs := !ofs + size_int -+ end -+ | Float -> -+ if !float <= last_float then begin -+ loc.(i) <- phys_reg !float; -+ incr float -+ end else begin -+ loc.(i) <- stack_slot (make_stack !ofs) Float; -+ ofs := !ofs + size_float -+ end -+ done; -+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) -+ -+let incoming ofs = Incoming ofs -+let outgoing ofs = Outgoing ofs -+let not_supported _ = fatal_error "Proc.loc_results: cannot call" -+ -+let max_arguments_for_tailcalls = 16 -+ -+let loc_spacetime_node_hole = Reg.dummy (* Spacetime unsupported *) -+ -+(* OCaml calling convention: -+ first integer args in a0 .. a7, s2 .. s9 -+ first float args in fa0 .. fa7, fs2 .. fs9 -+ remaining args on stack. -+ Return values in a0 .. a7, s2 .. s9 or fa0 .. fa7, fs2 .. fs9. *) -+ -+let single_regs arg = Array.map (fun arg -> [| arg |]) arg -+let ensure_single_regs res = -+ Array.map (function -+ | [| res |] -> res -+ | _ -> failwith "proc.ensure_single_regs" -+ ) res -+ -+let loc_arguments arg = -+ calling_conventions 0 15 110 125 outgoing arg -+ -+let loc_parameters arg = -+ let (loc, _ofs) = -+ calling_conventions 0 15 110 125 incoming arg -+ in -+ loc -+ -+let loc_results res = -+ let (loc, _ofs) = -+ calling_conventions 0 15 110 125 not_supported res -+ in -+ loc -+ -+(* C calling convention: -+ first integer args in a0 .. a7 -+ first float args in fa0 .. fa7 -+ remaining args on stack. -+ Return values in a0 .. a1 or fa0 .. fa1. *) -+ -+let external_calling_conventions -+ first_int last_int first_float last_float make_stack arg = -+ let loc = Array.make (Array.length arg) [| Reg.dummy |] in -+ let int = ref first_int in -+ let float = ref first_float in -+ let ofs = ref 0 in -+ for i = 0 to Array.length arg - 1 do -+ match arg.(i) with -+ | [| arg |] -> -+ begin match arg.typ with -+ | Val | Int | Addr as ty -> -+ if !int <= last_int then begin -+ loc.(i) <- [| phys_reg !int |]; -+ incr int; -+ incr float; -+ end else begin -+ loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; -+ ofs := !ofs + size_int -+ end -+ | Float -> -+ if !float <= last_float then begin -+ loc.(i) <- [| phys_reg !float |]; -+ incr float; -+ incr int; -+ end else begin -+ loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; -+ ofs := !ofs + size_float -+ end -+ end -+ | _ -> -+ fatal_error "Proc.calling_conventions: bad number of register for \ -+ multi-register argument" -+ done; -+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) -+ -+let loc_external_arguments arg = -+ external_calling_conventions 0 7 110 117 outgoing arg -+ -+let loc_external_results res = -+ let (loc, _ofs) = -+ external_calling_conventions 0 1 110 111 not_supported (single_regs res) -+ in -+ ensure_single_regs loc -+ -+(* Exceptions are in a0 *) -+ -+let loc_exn_bucket = phys_reg 0 -+ -+(* Volatile registers: none *) -+ -+let regs_are_volatile _ = false -+ -+(* Registers destroyed by operations *) -+ -+let destroyed_at_c_call = -+ (* s0-s11 and fs0-fs11 are callee-save *) -+ Array.of_list(List.map phys_reg -+ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; 21; -+ 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; -+ 117; 128; 129; 130; 131]) -+ -+let destroyed_at_alloc = -+ (* t0-t3 are used for PLT stubs *) -+ if !Clflags.dlcode then Array.map phys_reg [|16; 17; 18; 19; 20; 21|] -+ else [| |] -+ -+let destroyed_at_oper = function -+ | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs -+ | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call -+ | Iop(Ialloc _) -> destroyed_at_alloc -+ | Iop(Istore(Single, _, _)) -> [| phys_reg 100 |] -+ | Iswitch _ -> [| phys_reg 21 |] -+ | _ -> [||] -+ -+let destroyed_at_raise = all_phys_regs -+ -+let destroyed_at_reloadretaddr = [| |] -+ -+(* Maximal register pressure *) -+ -+let safe_register_pressure = function -+ | Iextcall _ -> 15 -+ | _ -> 22 -+ -+let max_register_pressure = function -+ | Iextcall _ -> [| 15; 18 |] -+ | _ -> [| 22; 30 |] -+ -+(* Pure operations (without any side effect besides updating their result -+ registers). *) -+ -+let op_is_pure = function -+ | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ -+ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ -+ | Iintop(Icheckbound _) | Iintop_imm(Icheckbound _, _) -> false -+ | Ispecific(Imultaddf _ | Imultsubf _) -> true -+ | _ -> true -+ -+(* Layout of the stack *) -+ -+let frame_required fd = -+ fd.fun_contains_calls -+ || fd.fun_num_stack_slots.(0) > 0 -+ || fd.fun_num_stack_slots.(1) > 0 -+ -+let prologue_required fd = -+ frame_required fd -+ -+(* See -+ https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md *) -+ -+let int_dwarf_reg_numbers = -+ [| 10; 11; 12; 13; 14; 15; 16; 17; -+ 18; 19; 20; 21; 22; 23; 24; 25; -+ 7; 28; 29; 30; 31; -+ 5; 6; -+ 8; 9; 26; 27; -+ |] -+ -+let float_dwarf_reg_numbers = -+ [| 32; 33; 34; 35; 36; 37; 38; 39; -+ 40; 41; -+ 42; 43; 44; 45; 46; 47; 48; 49; -+ 50; 51; 52; 53; 54; 55; 56; 57; -+ 58; 59; -+ 60; 61; 62; 63; -+ |] -+ -+let dwarf_register_numbers ~reg_class = -+ match reg_class with -+ | 0 -> int_dwarf_reg_numbers -+ | 1 -> float_dwarf_reg_numbers -+ | _ -> Misc.fatal_errorf "Bad register class %d" reg_class -+ -+let stack_ptr_dwarf_register_number = 2 -+ -+(* Calling the assembler *) -+ -+let assemble_file infile outfile = -+ Ccomp.command -+ (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) -+ -+let init () = () -diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml -new file mode 100644 -index 000000000..be18cbd7f ---- /dev/null -+++ b/asmcomp/riscv/reload.ml -@@ -0,0 +1,19 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Reloading for the RISC-V *) -+ -+let fundecl f = -+ (new Reloadgen.reload_generic)#fundecl f -diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml -new file mode 100644 -index 000000000..e56b723c5 ---- /dev/null -+++ b/asmcomp/riscv/scheduling.ml -@@ -0,0 +1,22 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Instruction scheduling for the RISC-V *) -+ -+open! Schedgen (* to create a dependency *) -+ -+(* Scheduling is turned off. *) -+ -+let fundecl f = f -diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml -new file mode 100644 -index 000000000..87d3355de ---- /dev/null -+++ b/asmcomp/riscv/selection.ml -@@ -0,0 +1,75 @@ -+(**************************************************************************) -+(* *) -+(* OCaml *) -+(* *) -+(* Nicolas Ojeda Bar *) -+(* *) -+(* Copyright 2016 Institut National de Recherche en Informatique et *) -+(* en Automatique. *) -+(* *) -+(* All rights reserved. This file is distributed under the terms of *) -+(* the GNU Lesser General Public License version 2.1, with the *) -+(* special exception on linking described in the file LICENSE. *) -+(* *) -+(**************************************************************************) -+ -+(* Instruction selection for the RISC-V processor *) -+ -+open Cmm -+open Arch -+open Mach -+ -+(* Instruction selection *) -+ -+class selector = object (self) -+ -+inherit Selectgen.selector_generic as super -+ -+method is_immediate n = is_immediate n -+ -+method select_addressing _ = function -+ | Cop(Cadda, [arg; Cconst_int (n, _)], _) when self#is_immediate n -> -+ (Iindexed n, arg) -+ | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int (n, _)], _)], dbg) -+ when self#is_immediate n -> -+ (Iindexed n, Cop(Caddi, [arg1; arg2], dbg)) -+ | arg -> -+ (Iindexed 0, arg) -+ -+method! select_operation op args dbg = -+ match (op, args) with -+ (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) -+ | (Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -+ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2], _)]) -> -+ (Ispecific (Imultaddf false), [arg1; arg2; arg3]) -+ | (Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3]) -> -+ (Ispecific (Imultsubf false), [arg1; arg2; arg3]) -+ | (Cnegf, [Cop(Csubf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> -+ (Ispecific (Imultsubf true), [arg1; arg2; arg3]) -+ | (Cnegf, [Cop(Caddf, [Cop(Cmulf, [arg1; arg2], _); arg3], _)]) -> -+ (Ispecific (Imultaddf true), [arg1; arg2; arg3]) -+ (* RISC-V does not support immediate operands for comparison operators *) -+ | (Ccmpi comp, args) -> (Iintop(Icomp (Isigned comp)), args) -+ | (Ccmpa comp, args) -> (Iintop(Icomp (Iunsigned comp)), args) -+ (* RISC-V does not support immediate operands for multiply/multiply high *) -+ | (Cmuli, _) -> (Iintop Imul, args) -+ | (Cmulhi, _) -> (Iintop Imulh, args) -+ | _ -> -+ super#select_operation op args dbg -+ -+(* Instruction selection for conditionals *) -+ -+method! select_condition = function -+ Cop(Ccmpi cmp, args, _) -> -+ (Iinttest(Isigned cmp), Ctuple args) -+ | Cop(Ccmpa cmp, args, _) -> -+ (Iinttest(Iunsigned cmp), Ctuple args) -+ | Cop(Ccmpf cmp, args, _) -> -+ (Ifloattest cmp, Ctuple args) -+ | Cop(Cand, [arg; Cconst_int (1, _)], _) -> -+ (Ioddtest, arg) -+ | arg -> -+ (Itruetest, arg) -+end -+ -+let fundecl f = (new selector)#emit_fundecl f -diff --git a/configure b/configure -index 32cb19b3b..12e08bba2 100755 ---- a/configure -+++ b/configure -@@ -13578,6 +13578,8 @@ if test x"$enable_shared" != "xno"; then : - natdynlink=true ;; #( - aarch64-*-freebsd*) : - natdynlink=true ;; #( -+ riscv*-*-linux*) : -+ natdynlink=true ;; #( - *) : - ;; - esac -@@ -13718,7 +13720,9 @@ fi; system=elf ;; #( - aarch64-*-freebsd*) : - arch=arm64; system=freebsd ;; #( - x86_64-*-cygwin*) : -- arch=amd64; system=cygwin -+ arch=amd64; system=cygwin ;; #( -+ riscv64-*-linux*) : -+ arch=riscv; model=riscv64; system=linux - ;; #( - *) : - ;; -@@ -13952,7 +13956,7 @@ esac ;; #( - *,dragonfly) : - default_as="${toolpref}as" - default_aspp="${toolpref}cc -c" ;; #( -- amd64,*|arm,*|arm64,*|i386,*) : -+ amd64,*|arm,*|arm64,*|i386,*|riscv,*) : - case $ocaml_cv_cc_vendor in #( - clang-*) : - default_as="${toolpref}clang -c -Wno-trigraphs" -diff --git a/configure.ac b/configure.ac -index 4c9358897..b7e0731e0 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -868,7 +868,8 @@ AS_IF([test x"$enable_shared" != "xno"], - [arm*-*-freebsd*], [natdynlink=true], - [earm*-*-netbsd*], [natdynlink=true], - [aarch64-*-linux*], [natdynlink=true], -- [aarch64-*-freebsd*], [natdynlink=true])]) -+ [aarch64-*-freebsd*], [natdynlink=true], -+ [riscv*-*-linux*], [natdynlink=true])]) - - # Try to work around the Skylake/Kaby Lake processor bug. - AS_CASE(["$CC,$host"], -@@ -961,7 +962,9 @@ AS_CASE([$host], - [aarch64-*-freebsd*], - [arch=arm64; system=freebsd], - [x86_64-*-cygwin*], -- [arch=amd64; system=cygwin] -+ [arch=amd64; system=cygwin], -+ [riscv64-*-linux*], -+ [arch=riscv; model=riscv64; system=linux] - ) - - AS_IF([test x"$enable_native_compiler" = "xno"], -@@ -1065,7 +1068,7 @@ AS_CASE(["$arch,$system"], - [*,dragonfly], - [default_as="${toolpref}as" - default_aspp="${toolpref}cc -c"], -- [amd64,*|arm,*|arm64,*|i386,*], -+ [amd64,*|arm,*|arm64,*|i386,*|riscv,*], - [AS_CASE([$ocaml_cv_cc_vendor], - [clang-*], [default_as="${toolpref}clang -c -Wno-trigraphs" - default_aspp="${toolpref}clang -c -Wno-trigraphs"], -diff --git a/runtime/caml/stack.h b/runtime/caml/stack.h -index df0424683..6b7df0e67 100644 ---- a/runtime/caml/stack.h -+++ b/runtime/caml/stack.h -@@ -70,6 +70,11 @@ - #define Callback_link(sp) ((struct caml_context *)((sp) + 16)) - #endif - -+#ifdef TARGET_riscv -+#define Saved_return_address(sp) *((intnat *)((sp) - 8)) -+#define Callback_link(sp) ((struct caml_context *)((sp) + 16)) -+#endif -+ - /* Structure of OCaml callback contexts */ - - struct caml_context { -diff --git a/runtime/riscv.S b/runtime/riscv.S -new file mode 100644 -index 000000000..48e690e44 ---- /dev/null -+++ b/runtime/riscv.S -@@ -0,0 +1,423 @@ -+/**************************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2016 Institut National de Recherche en Informatique et */ -+/* en Automatique. */ -+/* */ -+/* All rights reserved. This file is distributed under the terms of */ -+/* the GNU Lesser General Public License version 2.1, with the */ -+/* special exception on linking described in the file LICENSE. */ -+/* */ -+/**************************************************************************/ -+ -+/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ -+/* Must be preprocessed by cpp */ -+ -+#define ARG_DOMAIN_STATE_PTR t0 -+#define DOMAIN_STATE_PTR s0 -+#define TRAP_PTR s1 -+#define ALLOC_PTR s10 -+#define ALLOC_LIMIT s11 -+#define TMP t1 -+#define ARG t2 -+ -+#define STORE sd -+#define LOAD ld -+ -+ .set domain_curr_field, 0 -+#define DOMAIN_STATE(c_type, name) \ -+ .equ domain_field_caml_##name, domain_curr_field ; \ -+ .set domain_curr_field, domain_curr_field + 1 -+#include "../runtime/caml/domain_state.tbl" -+#undef DOMAIN_STATE -+ -+#define Caml_state(var) (8*domain_field_caml_##var)(s0) -+ -+#define FUNCTION(name) \ -+ .align 2; \ -+ .globl name; \ -+ .type name, @function; \ -+name: -+ -+#if defined(__PIC__) -+ .option pic -+#define PLT(r) r@plt -+#else -+ .option nopic -+#define PLT(r) r -+#endif -+ -+ .section .text -+/* Invoke the garbage collector. */ -+ -+ .globl caml_system__code_begin -+caml_system__code_begin: -+ -+FUNCTION(caml_call_gc) -+.Lcaml_call_gc: -+ /* Record return address */ -+ STORE ra, Caml_state(last_return_address) -+ /* Record lowest stack address */ -+ STORE sp, Caml_state(bottom_of_stack) -+ /* Set up stack space, saving return address */ -+ /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, -+ 20 caller-save float regs) * 8 */ -+ /* + 1 for alignment */ -+ addi sp, sp, -0x160 -+ STORE ra, 0x8(sp) -+ STORE s0, 0x0(sp) -+ /* Save allocatable integer registers on the stack, -+ in the order given in proc.ml */ -+ STORE a0, 0x10(sp) -+ STORE a1, 0x18(sp) -+ STORE a2, 0x20(sp) -+ STORE a3, 0x28(sp) -+ STORE a4, 0x30(sp) -+ STORE a5, 0x38(sp) -+ STORE a6, 0x40(sp) -+ STORE a7, 0x48(sp) -+ STORE s2, 0x50(sp) -+ STORE s3, 0x58(sp) -+ STORE s4, 0x60(sp) -+ STORE s5, 0x68(sp) -+ STORE s6, 0x70(sp) -+ STORE s7, 0x78(sp) -+ STORE s8, 0x80(sp) -+ STORE s9, 0x88(sp) -+ STORE t2, 0x90(sp) -+ STORE t3, 0x98(sp) -+ STORE t4, 0xa0(sp) -+ STORE t5, 0xa8(sp) -+ STORE t6, 0xb0(sp) -+ /* Save caller-save floating-point registers on the stack -+ (callee-saves are preserved by caml_garbage_collection) */ -+ fsd ft0, 0xb8(sp) -+ fsd ft1, 0xc0(sp) -+ fsd ft2, 0xc8(sp) -+ fsd ft3, 0xd0(sp) -+ fsd ft4, 0xd8(sp) -+ fsd ft5, 0xe0(sp) -+ fsd ft6, 0xe8(sp) -+ fsd ft7, 0xf0(sp) -+ fsd fa0, 0xf8(sp) -+ fsd fa1, 0x100(sp) -+ fsd fa2, 0x108(sp) -+ fsd fa3, 0x110(sp) -+ fsd fa4, 0x118(sp) -+ fsd fa5, 0x120(sp) -+ fsd fa6, 0x128(sp) -+ fsd fa7, 0x130(sp) -+ fsd ft8, 0x138(sp) -+ fsd ft9, 0x140(sp) -+ fsd ft9, 0x148(sp) -+ fsd ft10, 0x150(sp) -+ fsd ft11, 0x158(sp) -+ /* Store pointer to saved integer registers in caml_gc_regs */ -+ addi TMP, sp, 0x10 -+ STORE TMP, Caml_state(gc_regs) -+ /* Save current allocation pointer for debugging purposes */ -+ STORE ALLOC_PTR, Caml_state(young_ptr) -+ /* Save trap pointer in case an exception is raised during GC */ -+ STORE TRAP_PTR, Caml_state(exception_pointer) -+ /* Call the garbage collector */ -+ call PLT(caml_garbage_collection) -+ /* Restore registers */ -+ LOAD a0, 0x10(sp) -+ LOAD a1, 0x18(sp) -+ LOAD a2, 0x20(sp) -+ LOAD a3, 0x28(sp) -+ LOAD a4, 0x30(sp) -+ LOAD a5, 0x38(sp) -+ LOAD a6, 0x40(sp) -+ LOAD a7, 0x48(sp) -+ LOAD s2, 0x50(sp) -+ LOAD s3, 0x58(sp) -+ LOAD s4, 0x60(sp) -+ LOAD s5, 0x68(sp) -+ LOAD s6, 0x70(sp) -+ LOAD s7, 0x78(sp) -+ LOAD s8, 0x80(sp) -+ LOAD s9, 0x88(sp) -+ LOAD t2, 0x90(sp) -+ LOAD t3, 0x98(sp) -+ LOAD t4, 0xa0(sp) -+ LOAD t5, 0xa8(sp) -+ LOAD t6, 0xb0(sp) -+ fld ft0, 0xb8(sp) -+ fld ft1, 0xc0(sp) -+ fld ft2, 0xc8(sp) -+ fld ft3, 0xd0(sp) -+ fld ft4, 0xd8(sp) -+ fld ft5, 0xe0(sp) -+ fld ft6, 0xe8(sp) -+ fld ft7, 0xf0(sp) -+ fld fa0, 0xf8(sp) -+ fld fa1, 0x100(sp) -+ fld fa2, 0x108(sp) -+ fld fa3, 0x110(sp) -+ fld fa4, 0x118(sp) -+ fld fa5, 0x120(sp) -+ fld fa6, 0x128(sp) -+ fld fa7, 0x130(sp) -+ fld ft8, 0x138(sp) -+ fld ft9, 0x140(sp) -+ fld ft9, 0x148(sp) -+ fld ft10, 0x150(sp) -+ fld ft11, 0x158(sp) -+ /* Reload new allocation pointer and allocation limit */ -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ /* Free stack space and return to caller */ -+ LOAD ra, 0x8(sp) -+ LOAD s0, 0x0(sp) -+ addi sp, sp, 0x160 -+ ret -+ .size caml_call_gc, .-caml_call_gc -+ -+/* Call a C function from OCaml */ -+/* Function to call is in ARG */ -+ -+FUNCTION(caml_c_call) -+ /* Preserve return address in callee-save register s2 */ -+ mv s2, ra -+ /* Record lowest stack address and return address */ -+ STORE ra, Caml_state(last_return_address) -+ STORE sp, Caml_state(bottom_of_stack) -+ /* Make the exception handler alloc ptr available to the C code */ -+ STORE ALLOC_PTR, Caml_state(young_ptr) -+ STORE TRAP_PTR, Caml_state(exception_pointer) -+ /* Call the function */ -+ jalr ARG -+ /* Reload alloc ptr and alloc limit */ -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ /* Return */ -+ jr s2 -+ .size caml_c_call, .-caml_c_call -+ -+/* Raise an exception from OCaml */ -+FUNCTION(caml_raise_exn) -+ /* Test if backtrace is active */ -+ LOAD TMP, Caml_state(backtrace_active) -+ bnez TMP, 2f -+1: /* Cut stack at current trap handler */ -+ mv sp, TRAP_PTR -+ /* Pop previous handler and jump to it */ -+ LOAD TMP, 8(sp) -+ LOAD TRAP_PTR, 0(sp) -+ addi sp, sp, 16 -+ jr TMP -+2: /* Preserve exception bucket in callee-save register s2 */ -+ mv s2, a0 -+ /* Stash the backtrace */ -+ mv a1, ra -+ mv a2, sp -+ mv a3, TRAP_PTR -+ call PLT(caml_stash_backtrace) -+ /* Restore exception bucket and raise */ -+ mv a0, s2 -+ j 1b -+ .size caml_raise_exn, .-caml_raise_exn -+ -+ .globl caml_reraise_exn -+ .type caml_reraise_exn, @function -+ -+/* Raise an exception from C */ -+ -+FUNCTION(caml_raise_exception) -+ mv DOMAIN_STATE_PTR, a0 -+ mv a0, a1 -+ LOAD TRAP_PTR, Caml_state(exception_pointer) -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ LOAD TMP, Caml_state(backtrace_active) -+ bnez TMP, 2f -+1: /* Cut stack at current trap handler */ -+ mv sp, TRAP_PTR -+ LOAD TMP, 8(sp) -+ LOAD TRAP_PTR, 0(sp) -+ addi sp, sp, 16 -+ jr TMP -+2: /* Preserve exception bucket in callee-save register s2 */ -+ mv s2, a0 -+ LOAD a1, Caml_state(last_return_address) -+ LOAD a2, Caml_state(bottom_of_stack) -+ mv a3, TRAP_PTR -+ call PLT(caml_stash_backtrace) -+ mv a0, s2 -+ j 1b -+ .size caml_raise_exception, .-caml_raise_exception -+ -+/* Start the OCaml program */ -+ -+FUNCTION(caml_start_program) -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ la ARG, caml_program -+ /* Code shared with caml_callback* */ -+ /* Address of OCaml code to call is in ARG */ -+ /* Arguments to the OCaml code are in a0 ... a7 */ -+.Ljump_to_caml: -+ /* Set up stack frame and save callee-save registers */ -+ addi sp, sp, -0xd0 -+ STORE ra, 0xc0(sp) -+ STORE s0, 0x0(sp) -+ STORE s1, 0x8(sp) -+ STORE s2, 0x10(sp) -+ STORE s3, 0x18(sp) -+ STORE s4, 0x20(sp) -+ STORE s5, 0x28(sp) -+ STORE s6, 0x30(sp) -+ STORE s7, 0x38(sp) -+ STORE s8, 0x40(sp) -+ STORE s9, 0x48(sp) -+ STORE s10, 0x50(sp) -+ STORE s11, 0x58(sp) -+ fsd fs0, 0x60(sp) -+ fsd fs1, 0x68(sp) -+ fsd fs2, 0x70(sp) -+ fsd fs3, 0x78(sp) -+ fsd fs4, 0x80(sp) -+ fsd fs5, 0x88(sp) -+ fsd fs6, 0x90(sp) -+ fsd fs7, 0x98(sp) -+ fsd fs8, 0xa0(sp) -+ fsd fs9, 0xa8(sp) -+ fsd fs10, 0xb0(sp) -+ fsd fs11, 0xb8(sp) -+ addi sp, sp, -32 -+ /* Load domain state pointer from argument */ -+ mv DOMAIN_STATE_PTR, ARG_DOMAIN_STATE_PTR -+ /* Setup a callback link on the stack */ -+ LOAD TMP, Caml_state(bottom_of_stack) -+ STORE TMP, 0(sp) -+ LOAD TMP, Caml_state(last_return_address) -+ STORE TMP, 8(sp) -+ LOAD TMP, Caml_state(gc_regs) -+ STORE TMP, 16(sp) -+ /* set up a trap frame */ -+ addi sp, sp, -16 -+ LOAD TMP, Caml_state(exception_pointer) -+ STORE TMP, 0(sp) -+ lla TMP, .Ltrap_handler -+ STORE TMP, 8(sp) -+ mv TRAP_PTR, sp -+ LOAD ALLOC_PTR, Caml_state(young_ptr) -+ LOAD ALLOC_LIMIT, Caml_state(young_limit) -+ STORE x0, Caml_state(last_return_address) -+ jalr ARG -+.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ -+ LOAD TMP, 0(sp) -+ STORE TMP, Caml_state(exception_pointer) -+ addi sp, sp, 16 -+.Lreturn_result: /* pop callback link, restoring global variables */ -+ LOAD TMP, 0(sp) -+ STORE TMP, Caml_state(bottom_of_stack) -+ LOAD TMP, 8(sp) -+ STORE TMP, Caml_state(last_return_address) -+ LOAD TMP, 16(sp) -+ STORE TMP, Caml_state(gc_regs) -+ addi sp, sp, 32 -+ /* Update allocation pointer */ -+ STORE ALLOC_PTR, Caml_state(young_ptr) -+ /* reload callee-save registers and return */ -+ LOAD ra, 0xc0(sp) -+ LOAD s0, 0x0(sp) -+ LOAD s1, 0x8(sp) -+ LOAD s2, 0x10(sp) -+ LOAD s3, 0x18(sp) -+ LOAD s4, 0x20(sp) -+ LOAD s5, 0x28(sp) -+ LOAD s6, 0x30(sp) -+ LOAD s7, 0x38(sp) -+ LOAD s8, 0x40(sp) -+ LOAD s9, 0x48(sp) -+ LOAD s10, 0x50(sp) -+ LOAD s11, 0x58(sp) -+ fld fs0, 0x60(sp) -+ fld fs1, 0x68(sp) -+ fld fs2, 0x70(sp) -+ fld fs3, 0x78(sp) -+ fld fs4, 0x80(sp) -+ fld fs5, 0x88(sp) -+ fld fs6, 0x90(sp) -+ fld fs7, 0x98(sp) -+ fld fs8, 0xa0(sp) -+ fld fs9, 0xa8(sp) -+ fld fs10, 0xb0(sp) -+ fld fs11, 0xb8(sp) -+ addi sp, sp, 0xd0 -+ ret -+ .type .Lcaml_retaddr, @function -+ .size .Lcaml_retaddr, .-.Lcaml_retaddr -+ .size caml_start_program, .-caml_start_program -+ -+ .align 2 -+.Ltrap_handler: -+ STORE TRAP_PTR, Caml_state(exception_pointer) -+ ori a0, a0, 2 -+ j .Lreturn_result -+ .type .Ltrap_handler, @function -+ .size .Ltrap_handler, .-.Ltrap_handler -+ -+/* Callback from C to OCaml */ -+ -+FUNCTION(caml_callback_asm) -+ /* Initial shuffling of arguments */ -+ /* a0 = Caml_state, a1 = closure, (a2) = args */ -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ LOAD a0, 0(a2) /* a0 = first arg */ -+ /* a1 = closure environment */ -+ LOAD ARG, 0(a1) /* code pointer */ -+ j .Ljump_to_caml -+ .size caml_callback_asm, .-caml_callback_asm -+ -+FUNCTION(caml_callback2_asm) -+ /* Initial shuffling of arguments */ -+ /* a0 = Caml_state, a1 = closure, (a2) = args */ -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ mv TMP, a1 -+ LOAD a0, 0(a2) -+ LOAD a1, 8(a2) -+ mv a2, TMP -+ la ARG, caml_apply2 -+ j .Ljump_to_caml -+ .size caml_callback2_asm, .-caml_callback2_asm -+ -+FUNCTION(caml_callback3_asm) -+ /* Initial shuffling of arguments */ -+ /* a0 = Caml_state, a1 = closure, (a2) = args */ -+ mv ARG_DOMAIN_STATE_PTR, a0 -+ mv a3, a1 -+ LOAD a0, 0(a2) -+ LOAD a1, 8(a2) -+ LOAD a2, 16(a2) -+ la ARG, caml_apply3 -+ j .Ljump_to_caml -+ .size caml_callback3_asm, .-caml_callback3_asm -+ -+FUNCTION(caml_ml_array_bound_error) -+ /* Load address of [caml_array_bound_error] in ARG */ -+ la ARG, caml_array_bound_error -+ /* Call that function */ -+ tail caml_c_call -+ .size caml_ml_array_bound_error, .-caml_ml_array_bound_error -+ -+ .globl caml_system__code_end -+caml_system__code_end: -+ -+/* GC roots for callback */ -+ -+ .section .data -+ .align 3 -+ .globl caml_system__frametable -+ .type caml_system__frametable, @object -+caml_system__frametable: -+ .quad 1 /* one descriptor */ -+ .quad .Lcaml_retaddr /* return address into callback */ -+ .short -1 /* negative frame size => use callback link */ -+ .short 0 /* no roots */ -+ .align 3 -+ .size caml_system__frametable, .-caml_system__frametable -diff --git a/testsuite/tools/asmgen_riscv.S b/testsuite/tools/asmgen_riscv.S -new file mode 100644 -index 000000000..efb30a80f ---- /dev/null -+++ b/testsuite/tools/asmgen_riscv.S -@@ -0,0 +1,89 @@ -+/**************************************************************************/ -+/* */ -+/* OCaml */ -+/* */ -+/* Nicolas Ojeda Bar */ -+/* */ -+/* Copyright 2019 Institut National de Recherche en Informatique et */ -+/* en Automatique. */ -+/* */ -+/* All rights reserved. This file is distributed under the terms of */ -+/* the GNU Lesser General Public License version 2.1, with the */ -+/* special exception on linking described in the file LICENSE. */ -+/* */ -+/**************************************************************************/ -+ -+#define STORE sd -+#define LOAD ld -+ -+ .globl call_gen_code -+ .align 2 -+call_gen_code: -+ /* Set up stack frame and save callee-save registers */ -+ ADDI sp, sp, -208 -+ STORE ra, 192(sp) -+ STORE s0, 0(sp) -+ STORE s1, 8(sp) -+ STORE s2, 16(sp) -+ STORE s3, 24(sp) -+ STORE s4, 32(sp) -+ STORE s5, 40(sp) -+ STORE s6, 48(sp) -+ STORE s7, 56(sp) -+ STORE s8, 64(sp) -+ STORE s9, 72(sp) -+ STORE s10, 80(sp) -+ STORE s11, 88(sp) -+ fsd fs0, 96(sp) -+ fsd fs1, 104(sp) -+ fsd fs2, 112(sp) -+ fsd fs3, 120(sp) -+ fsd fs4, 128(sp) -+ fsd fs5, 136(sp) -+ fsd fs6, 144(sp) -+ fsd fs7, 152(sp) -+ fsd fs8, 160(sp) -+ fsd fs9, 168(sp) -+ fsd fs10, 176(sp) -+ fsd fs11, 184(sp) -+ /* Shuffle arguments */ -+ mv t0, a0 -+ mv a0, a1 -+ mv a1, a2 -+ mv a2, a3 -+ mv a3, a4 -+ /* Call generated asm */ -+ jalr t0 -+ /* Reload callee-save registers and return address */ -+ LOAD ra, 192(sp) -+ LOAD s0, 0(sp) -+ LOAD s1, 8(sp) -+ LOAD s2, 16(sp) -+ LOAD s3, 24(sp) -+ LOAD s4, 32(sp) -+ LOAD s5, 40(sp) -+ LOAD s6, 48(sp) -+ LOAD s7, 56(sp) -+ LOAD s8, 64(sp) -+ LOAD s9, 72(sp) -+ LOAD s10, 80(sp) -+ LOAD s11, 88(sp) -+ fld fs0, 96(sp) -+ fld fs1, 104(sp) -+ fld fs2, 112(sp) -+ fld fs3, 120(sp) -+ fld fs4, 128(sp) -+ fld fs5, 136(sp) -+ fld fs6, 144(sp) -+ fld fs7, 152(sp) -+ fld fs8, 160(sp) -+ fld fs9, 168(sp) -+ fld fs10, 176(sp) -+ fld fs11, 184(sp) -+ addi sp, sp, 208 -+ ret -+ -+ .globl caml_c_call -+ .align 2 -+caml_c_call: -+ jr t2 --- -2.28.0.rc2 - diff --git a/0005-Fix-type-mismatches-between-definition-and-declarati.patch b/0005-Fix-type-mismatches-between-definition-and-declarati.patch new file mode 100644 index 0000000..c05ac0b --- /dev/null +++ b/0005-Fix-type-mismatches-between-definition-and-declarati.patch @@ -0,0 +1,69 @@ +From bfde1055d3f945d975092f718952b4764d6a9eb9 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Wed, 5 Aug 2020 11:17:52 +0200 +Subject: [PATCH 5/5] Fix type mismatches between definition and declaration + (#9830) + +The C global variable caml_fl_merge and the C function +caml_spacetime_my_profinfo (bytecode version) were declared and +defined with different types. This is undefined behavior and +can cause link-time errors with link-time optimization (LTO). + +Closes: #9825 +--- + runtime/major_gc.c | 4 ++-- + runtime/spacetime_byt.c | 7 ++++++- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/runtime/major_gc.c b/runtime/major_gc.c +index 5e4f06bce..c8f5a3281 100644 +--- a/runtime/major_gc.c ++++ b/runtime/major_gc.c +@@ -63,7 +63,7 @@ uintnat caml_dependent_size, caml_dependent_allocated; + double caml_extra_heap_resources; + uintnat caml_fl_wsz_at_phase_change = 0; + +-extern char *caml_fl_merge; /* Defined in freelist.c. */ ++extern value caml_fl_merge; /* Defined in freelist.c. */ + + static char *markhp, *chunk, *limit; + static double p_backlog = 0.0; /* backlog for the gc speedup parameter */ +@@ -570,7 +570,7 @@ static void sweep_slice (intnat work) + break; + case Caml_blue: + /* Only the blocks of the free-list are blue. See [freelist.c]. */ +- caml_fl_merge = Bp_hp (hp); ++ caml_fl_merge = (value) Bp_hp (hp); + break; + default: /* gray or black */ + CAMLassert (Color_hd (hd) == Caml_black); +diff --git a/runtime/spacetime_byt.c b/runtime/spacetime_byt.c +index 2b0bf1dc2..b75fb0980 100644 +--- a/runtime/spacetime_byt.c ++++ b/runtime/spacetime_byt.c +@@ -12,8 +12,12 @@ + /* */ + /**************************************************************************/ + ++#define CAML_INTERNALS ++ + #include "caml/fail.h" + #include "caml/mlvalues.h" ++#include "caml/io.h" ++#include "caml/spacetime.h" + + int caml_ensure_spacetime_dot_o_is_included = 42; + +@@ -22,7 +26,8 @@ CAMLprim value caml_spacetime_only_works_for_native_code(value foo, ...) + caml_failwith("Spacetime profiling only works for native code"); + } + +-uintnat caml_spacetime_my_profinfo (void) ++uintnat caml_spacetime_my_profinfo (spacetime_unwind_info_cache * cached, ++ uintnat wosize) + { + return 0; + } +-- +2.28.0.rc2 + diff --git a/0006-Support-FP-reg-int-reg-moves.patch b/0006-Support-FP-reg-int-reg-moves.patch deleted file mode 100644 index 1138515..0000000 --- a/0006-Support-FP-reg-int-reg-moves.patch +++ /dev/null @@ -1,34 +0,0 @@ -From d26a313ae92bb515b04865b6a71a63701dd1fe41 Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Thu, 30 Apr 2020 16:18:06 +0200 -Subject: [PATCH 6/8] Support FP reg -> int reg moves - -Using instruction fmv.x.d. - -This is necessary to implement the ELF psABI calling conventions, -whereas some FP arguments may have to be passed in integer registers. - -(cherry picked from commit 16794b940555315c723411077a2902fc85a33c45) ---- - asmcomp/riscv/emit.mlp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp -index dc652de42..dbfdc2d40 100644 ---- a/asmcomp/riscv/emit.mlp -+++ b/asmcomp/riscv/emit.mlp -@@ -283,8 +283,10 @@ let emit_instr i = - match (src, dst) with - | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> - ` mv {emit_reg dst}, {emit_reg src}\n` -- | {loc = Reg _; typ = Float}, {loc = Reg _} -> -+ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> - ` fmv.d {emit_reg dst}, {emit_reg src}\n` -+ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = (Val | Int | Addr)} -> -+ ` fmv.x.d {emit_reg dst}, {emit_reg src}\n` - | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> - let ofs = slot_offset s (register_class dst) in - emit_store src ofs --- -2.28.0.rc2 - diff --git a/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch b/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch deleted file mode 100644 index e60f1ef..0000000 --- a/0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 5bc92d0cdb5cb26b8d8d517f30914c2b18e85f2b Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Thu, 30 Apr 2020 16:19:16 +0200 -Subject: [PATCH 7/8] Update C calling conventions to the RISC-V ELF psABI - -The original implementation of loc_external_arguments and -loc_external_results was following an older ABI, -where an FP argument passed in an FP register "burns" an integer register. - -In the ELF psABI, integer registers and FP registers are used independently, -as in the OCaml calling convention. Plus, if all FP registers are used -but an integer register remains, the integer register is used to pass -the next FP argument. - -Fixes: #9515 -(cherry picked from commit ea6896f9f184305cc455d3af18cd1cb75cdcd93d) ---- - asmcomp/riscv/proc.ml | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml -index 70909cd83..4c7b58612 100644 ---- a/asmcomp/riscv/proc.ml -+++ b/asmcomp/riscv/proc.ml -@@ -187,6 +187,8 @@ let loc_results res = - first integer args in a0 .. a7 - first float args in fa0 .. fa7 - remaining args on stack. -+ A FP argument can be passed in an integer register if all FP registers -+ are exhausted but integer registers remain. - Return values in a0 .. a1 or fa0 .. fa1. *) - - let external_calling_conventions -@@ -202,8 +204,7 @@ let external_calling_conventions - | Val | Int | Addr as ty -> - if !int <= last_int then begin - loc.(i) <- [| phys_reg !int |]; -- incr int; -- incr float; -+ incr int - end else begin - loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; - ofs := !ofs + size_int -@@ -211,8 +212,10 @@ let external_calling_conventions - | Float -> - if !float <= last_float then begin - loc.(i) <- [| phys_reg !float |]; -- incr float; -- incr int; -+ incr float -+ end else if !int <= last_int then begin -+ loc.(i) <- [| phys_reg !int |]; -+ incr int - end else begin - loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; - ofs := !ofs + size_float --- -2.28.0.rc2 - diff --git a/0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch b/0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch deleted file mode 100644 index aafe0c0..0000000 --- a/0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 7364f5081851fe306802883d9a8069da559d4973 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 4 Aug 2020 12:26:12 +0100 -Subject: [PATCH 8/8] runtime/major_gc.c: Declare caml_fl_merge with proper - type. - -When compiling OCaml with LTO enabled (as is now done routinely in -Fedora and OpenSUSE) we got a failure because the caml_fl_merge symbol -is not declared identically across compilation units. The simple fix -is to make sure the declarations are identical, although probably -moving the definition to a common header file would be a better -long-term fix. - -major_gc.c:66:14: warning: type of 'caml_fl_merge' does not match original declaration [-Wlto-type-mismatch] - 66 | extern char *caml_fl_merge; /* Defined in freelist.c. */ - | ^ -freelist.c:47:7: note: 'caml_fl_merge' was previously declared here - 47 | value caml_fl_merge = Val_NULL; /* Current insertion pointer. Managed - | ^ -freelist.c:47:7: note: code may be misoptimized unless '-fno-strict-aliasing' is used ---- - runtime/major_gc.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/runtime/major_gc.c b/runtime/major_gc.c -index 5e4f06bce..c8f5a3281 100644 ---- a/runtime/major_gc.c -+++ b/runtime/major_gc.c -@@ -63,7 +63,7 @@ uintnat caml_dependent_size, caml_dependent_allocated; - double caml_extra_heap_resources; - uintnat caml_fl_wsz_at_phase_change = 0; - --extern char *caml_fl_merge; /* Defined in freelist.c. */ -+extern value caml_fl_merge; /* Defined in freelist.c. */ - - static char *markhp, *chunk, *limit; - static double p_backlog = 0.0; /* backlog for the gc speedup parameter */ -@@ -570,7 +570,7 @@ static void sweep_slice (intnat work) - break; - case Caml_blue: - /* Only the blocks of the free-list are blue. See [freelist.c]. */ -- caml_fl_merge = Bp_hp (hp); -+ caml_fl_merge = (value) Bp_hp (hp); - break; - default: /* gray or black */ - CAMLassert (Color_hd (hd) == Caml_black); --- -2.28.0.rc2 - diff --git a/ocaml.spec b/ocaml.spec index 928b035..5a7e4ad 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.0 -Release: 0.9.dev2%{?dist} +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -40,9 +40,7 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org #Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rcver}.tar.xz -# This is a pre-release of OCaml 4.11.0. See: -# https://pagure.io/fedora-ocaml/commits/fedora-33-4.11.0-dev2 -Source0: ocaml-4.11.0.tar.gz +Source0: https://github.com/ocaml/ocaml/archive/%{version}.tar.gz # IMPORTANT NOTE: # @@ -53,7 +51,7 @@ Source0: ocaml-4.11.0.tar.gz # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-33-4.11.0-dev2 +# Current branch: fedora-34-4.11.0 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -64,13 +62,8 @@ Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch Patch0004: 0004-Remove-configure-from-.gitattributes.patch -# Add RISC-V backend. This is upstream in 4.12 (not 4.11). -Patch0005: 0005-Add-RISC-V-native-code-backend-9441.patch -Patch0006: 0006-Support-FP-reg-int-reg-moves.patch -Patch0007: 0007-Update-C-calling-conventions-to-the-RISC-V-ELF-psABI.patch - -# Fix compilation with LTO (sent upstream 2020-08-04). -Patch0008: 0008-runtime-major_gc.c-Declare-caml_fl_merge-with-proper.patch +# Fix compilation with LTO (upstream, but not in 4.11 branch). +Patch0005: 0005-Fix-type-mismatches-between-definition-and-declarati.patch BuildRequires: git BuildRequires: gcc @@ -266,6 +259,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlmklib %{_bindir}/ocamlmktop %{_bindir}/ocamlobjinfo +%{_bindir}/ocamloptp %{_bindir}/ocamlprof # bytecode versions @@ -276,6 +270,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlmklib.byte %{_bindir}/ocamlmktop.byte %{_bindir}/ocamlobjinfo.byte +%{_bindir}/ocamloptp.byte %{_bindir}/ocamlprof.byte %if %{native_compiler} @@ -287,6 +282,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlmklib.opt %{_bindir}/ocamlmktop.opt %{_bindir}/ocamlobjinfo.opt +%{_bindir}/ocamloptp.opt %{_bindir}/ocamlprof.opt %endif @@ -378,6 +374,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Fri Aug 21 2020 Richard W.M. Jones - 4.11.0-1 +- OCaml 4.11.0 release (RHBZ#1870368). + * Tue Aug 04 2020 Richard W.M. Jones - 4.11.0-0.9.dev2 - Bump and rebuild to fix DWARF versioning issues. - Enable LTO again. diff --git a/sources b/sources index 9c55304..146fecb 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.11.0.tar.gz) = b07208b8679ef285f30b2da4070a3cf894cb881b79330e1ee50839fff634e58be1b7c378690658d146d2565ddbfa40aaa12ecec9558d7eab501b1863f50bfc88 +SHA512 (4.11.0.tar.gz) = 9cb1025d009adff7b6fff247ec53998401919833784bb668cea56980082a60aa51d01c067bebe6afefb52a574a2b8e242a79e62d410f78fb68af1b27fe5b6166 From 709f14be774a8df9dbf5d4162f3121313bb50a5a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 1 Sep 2020 17:30:45 +0100 Subject: [PATCH 37/91] OCaml 4.11.1 release (RHBZ#1870368#c26). --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...onfigure-Allow-user-defined-C-compiler-flags.patch | 2 +- ...e-Remove-incorrect-assumption-about-cross-co.patch | 2 +- 0004-Remove-configure-from-.gitattributes.patch | 2 +- ...-mismatches-between-definition-and-declarati.patch | 2 +- ocaml.spec | 11 +++++++---- sources | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index d20dc05..9c8df31 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,4 +1,4 @@ -From 455187f2528a6dd987a8add6e7db055978c9b5c4 Mon Sep 17 00:00:00 2001 +From 4c7732daae8f0d2a622f91f5ff3add5c2248a2e3 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 Subject: [PATCH 1/5] Don't add rpaths to libraries. diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 566f096..8516bb4 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,4 +1,4 @@ -From 183e55d0a61a9e50db1b861d1e3918ee2fecc544 Mon Sep 17 00:00:00 2001 +From 441ad77a0c89f4abdf104c668d579607f338a052 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 95ceec1..1423b0d 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,4 +1,4 @@ -From 89bd3487c135b4ff51b97e1fde67a45485be4af8 Mon Sep 17 00:00:00 2001 +From 3318c5b805d8d6ae1d571f18f682c9f701b712e2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 Subject: [PATCH 3/5] configure: Remove incorrect assumption about diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch index ead8e9a..b9003f7 100644 --- a/0004-Remove-configure-from-.gitattributes.patch +++ b/0004-Remove-configure-from-.gitattributes.patch @@ -1,4 +1,4 @@ -From 38d51966a2f35cc411ceda2d61946edfb62ee8fc Mon Sep 17 00:00:00 2001 +From 01d8e3f82adb382fb90af15879f722e824834c84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jan 2020 11:31:27 +0000 Subject: [PATCH 4/5] Remove configure from .gitattributes. diff --git a/0005-Fix-type-mismatches-between-definition-and-declarati.patch b/0005-Fix-type-mismatches-between-definition-and-declarati.patch index c05ac0b..587f5a6 100644 --- a/0005-Fix-type-mismatches-between-definition-and-declarati.patch +++ b/0005-Fix-type-mismatches-between-definition-and-declarati.patch @@ -1,4 +1,4 @@ -From bfde1055d3f945d975092f718952b4764d6a9eb9 Mon Sep 17 00:00:00 2001 +From 122db7141d292d63cfbe2c7d7a4280cc73194ece Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Wed, 5 Aug 2020 11:17:52 +0200 Subject: [PATCH 5/5] Fix type mismatches between definition and declaration diff --git a/ocaml.spec b/ocaml.spec index 5a7e4ad..944a6c2 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -30,7 +30,7 @@ %global rcver %{nil} Name: ocaml -Version: 4.11.0 +Version: 4.11.1 Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -39,8 +39,8 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org -#Source0: http://caml.inria.fr/pub/distrib/ocaml-4.10/ocaml-%{version}%{rcver}.tar.xz -Source0: https://github.com/ocaml/ocaml/archive/%{version}.tar.gz +Source0: https://caml.inria.fr/pub/distrib/ocaml-4.11/ocaml-%{version}.tar.xz +#Source0: https://github.com/ocaml/ocaml/archive/%%{version}.tar.gz # IMPORTANT NOTE: # @@ -51,7 +51,7 @@ Source0: https://github.com/ocaml/ocaml/archive/%{version}.tar.gz # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-34-4.11.0 +# Current branch: fedora-34-4.11.1 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -374,6 +374,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Tue Sep 01 2020 Richard W.M. Jones - 4.11.1-1 +- OCaml 4.11.1 release (RHBZ#1870368#c26). + * Fri Aug 21 2020 Richard W.M. Jones - 4.11.0-1 - OCaml 4.11.0 release (RHBZ#1870368). diff --git a/sources b/sources index 146fecb..1e5a596 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (4.11.0.tar.gz) = 9cb1025d009adff7b6fff247ec53998401919833784bb668cea56980082a60aa51d01c067bebe6afefb52a574a2b8e242a79e62d410f78fb68af1b27fe5b6166 +SHA512 (ocaml-4.11.1.tar.xz) = ca34655dc22257aa48aeb48a9cf56bde177aa0f0e7f3965f334939934801a206ed5667b7ab0cc291df9e6bf1bb3251f7384f078ea5562e647fde93167ecb1e84 From 06d6e508a6c43bae22b96793b2f502171b203daa Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 7 Jan 2021 06:09:29 +0000 Subject: [PATCH 38/91] Add BuildRequires: make https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot --- ocaml.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/ocaml.spec b/ocaml.spec index 944a6c2..a0c419f 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -65,6 +65,7 @@ Patch0004: 0004-Remove-configure-from-.gitattributes.patch # Fix compilation with LTO (upstream, but not in 4.11 branch). Patch0005: 0005-Fix-type-mismatches-between-definition-and-declarati.patch +BuildRequires: make BuildRequires: git BuildRequires: gcc BuildRequires: autoconf From 2dec79cc2e026c5ccadc721f906f8b593457bb44 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 26 Jan 2021 21:52:06 +0000 Subject: [PATCH 39/91] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index a0c419f..69cb928 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.11.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -375,6 +375,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Tue Jan 26 2021 Fedora Release Engineering - 4.11.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Tue Sep 01 2020 Richard W.M. Jones - 4.11.1-1 - OCaml 4.11.1 release (RHBZ#1870368#c26). From b8653f50ff7bc66cac91dcf67a45317c557f8a27 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 28 Feb 2021 20:53:29 +0000 Subject: [PATCH 40/91] OCaml 4.12.0 release (RHBZ#1893381). Workaround for glibc non-constant SIGSTKSZ (https://github.com/ocaml/ocaml/issues/10250) --- 0001-Don-t-add-rpaths-to-libraries.patch | 10 +-- ...-Allow-user-defined-C-compiler-flags.patch | 12 ++-- ...-incorrect-assumption-about-cross-co.patch | 12 ++-- ...Remove-configure-from-.gitattributes.patch | 28 -------- ...ound-for-glibc-non-constant-SIGSTKSZ.patch | 39 +++++++++++ ...hes-between-definition-and-declarati.patch | 69 ------------------- ocaml.spec | 34 ++++----- sources | 2 +- 8 files changed, 75 insertions(+), 131 deletions(-) delete mode 100644 0004-Remove-configure-from-.gitattributes.patch create mode 100644 0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch delete mode 100644 0005-Fix-type-mismatches-between-definition-and-declarati.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 9c8df31..855b634 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,17 +1,17 @@ -From 4c7732daae8f0d2a622f91f5ff3add5c2248a2e3 Mon Sep 17 00:00:00 2001 +From db7d6fd991dc43f392c895ee857f7948f5b4fe5e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/5] Don't add rpaths to libraries. +Subject: [PATCH 1/4] Don't add rpaths to libraries. --- tools/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Makefile b/tools/Makefile -index dbad0b74f..c920a5337 100644 +index 07e2eda1a..340508a60 100644 --- a/tools/Makefile +++ b/tools/Makefile -@@ -154,8 +154,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ +@@ -146,8 +146,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ ocamlmklibconfig.ml: $(ROOTDIR)/Makefile.config Makefile (echo 'let bindir = "$(BINDIR)"'; \ echo 'let supports_shared_libraries = $(SUPPORTS_SHARED_LIBRARIES)';\ @@ -23,5 +23,5 @@ index dbad0b74f..c920a5337 100644 > ocamlmklibconfig.ml -- -2.28.0.rc2 +2.29.0.rc2 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 8516bb4..8c7c0d1 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,18 +1,18 @@ -From 441ad77a0c89f4abdf104c668d579607f338a052 Mon Sep 17 00:00:00 2001 +From bf42dba499e053196b9235aae9987f395c4a4b7e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/5] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index aa5f26f28..5153853b7 100644 +index 83455a3b6..213392b25 100644 --- a/configure.ac +++ b/configure.ac -@@ -609,6 +609,10 @@ AS_CASE([$host], - internal_cflags="$gcc_warnings"], +@@ -638,6 +638,10 @@ AS_CASE([$host], + internal_cflags="$cc_warnings"], [common_cflags="-O"])]) +# Allow CFLAGS and LDFLAGS to be added. @@ -23,5 +23,5 @@ index aa5f26f28..5153853b7 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.28.0.rc2 +2.29.0.rc2 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 1423b0d..9324e15 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From 3318c5b805d8d6ae1d571f18f682c9f701b712e2 Mon Sep 17 00:00:00 2001 +From 5cc71dbb0f25d4c5b444f099965b93149577ee8f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/5] configure: Remove incorrect assumption about +Subject: [PATCH 3/4] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -10,10 +10,10 @@ See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 5153853b7..4e97474a2 100644 +index 213392b25..c7e594b5d 100644 --- a/configure.ac +++ b/configure.ac -@@ -511,10 +511,11 @@ AS_IF( +@@ -529,10 +529,11 @@ AS_IF( # Are we building a cross-compiler @@ -29,7 +29,7 @@ index 5153853b7..4e97474a2 100644 # Checks for programs -@@ -1021,7 +1022,7 @@ AS_CASE([$arch], +@@ -1072,7 +1073,7 @@ AS_CASE([$arch], # Assembler @@ -39,5 +39,5 @@ index 5153853b7..4e97474a2 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.28.0.rc2 +2.29.0.rc2 diff --git a/0004-Remove-configure-from-.gitattributes.patch b/0004-Remove-configure-from-.gitattributes.patch deleted file mode 100644 index b9003f7..0000000 --- a/0004-Remove-configure-from-.gitattributes.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 01d8e3f82adb382fb90af15879f722e824834c84 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sat, 18 Jan 2020 11:31:27 +0000 -Subject: [PATCH 4/5] Remove configure from .gitattributes. - -It's not a binary file. ---- - .gitattributes | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/.gitattributes b/.gitattributes -index 200eb49c6..d871764de 100644 ---- a/.gitattributes -+++ b/.gitattributes -@@ -29,10 +29,6 @@ - - /boot/menhir/parser.ml* -diff - --# configure is declared as binary so that it doesn't get included in diffs. --# This also means it will have the correct Unix line-endings, even on Windows. --/configure binary -- - # 'union' merge driver just unions textual content in case of conflict - # http://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/ - /.mailmap merge=union --- -2.28.0.rc2 - diff --git a/0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch b/0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch new file mode 100644 index 0000000..b672f08 --- /dev/null +++ b/0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch @@ -0,0 +1,39 @@ +From dfb5e954a04f59b0456cc4c0ddf3acaf22e0ff07 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sun, 28 Feb 2021 20:45:47 +0000 +Subject: [PATCH 4/4] Workaround for glibc non-constant SIGSTKSZ + +https://github.com/ocaml/ocaml/issues/10250 + +Signed-off-by: Richard W.M. Jones +--- + runtime/signals_nat.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c +index 8b64ab452..7f0a97513 100644 +--- a/runtime/signals_nat.c ++++ b/runtime/signals_nat.c +@@ -181,7 +181,19 @@ DECLARE_SIGNAL_HANDLER(trap_handler) + #error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined" + #endif + ++#ifndef __GLIBC__ + static char sig_alt_stack[SIGSTKSZ]; ++#else ++/* glibc 2.34 has non-constant SIGSTKSZ */ ++static char *sig_alt_stack; ++ ++static void allocate_sig_alt_stack(void) __attribute__((constructor)); ++static void ++allocate_sig_alt_stack(void) ++{ ++ sig_alt_stack = malloc(SIGSTKSZ); ++} ++#endif + + /* Code compiled with ocamlopt never accesses more than + EXTRA_STACK bytes below the stack pointer. */ +-- +2.29.0.rc2 + diff --git a/0005-Fix-type-mismatches-between-definition-and-declarati.patch b/0005-Fix-type-mismatches-between-definition-and-declarati.patch deleted file mode 100644 index 587f5a6..0000000 --- a/0005-Fix-type-mismatches-between-definition-and-declarati.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 122db7141d292d63cfbe2c7d7a4280cc73194ece Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Wed, 5 Aug 2020 11:17:52 +0200 -Subject: [PATCH 5/5] Fix type mismatches between definition and declaration - (#9830) - -The C global variable caml_fl_merge and the C function -caml_spacetime_my_profinfo (bytecode version) were declared and -defined with different types. This is undefined behavior and -can cause link-time errors with link-time optimization (LTO). - -Closes: #9825 ---- - runtime/major_gc.c | 4 ++-- - runtime/spacetime_byt.c | 7 ++++++- - 2 files changed, 8 insertions(+), 3 deletions(-) - -diff --git a/runtime/major_gc.c b/runtime/major_gc.c -index 5e4f06bce..c8f5a3281 100644 ---- a/runtime/major_gc.c -+++ b/runtime/major_gc.c -@@ -63,7 +63,7 @@ uintnat caml_dependent_size, caml_dependent_allocated; - double caml_extra_heap_resources; - uintnat caml_fl_wsz_at_phase_change = 0; - --extern char *caml_fl_merge; /* Defined in freelist.c. */ -+extern value caml_fl_merge; /* Defined in freelist.c. */ - - static char *markhp, *chunk, *limit; - static double p_backlog = 0.0; /* backlog for the gc speedup parameter */ -@@ -570,7 +570,7 @@ static void sweep_slice (intnat work) - break; - case Caml_blue: - /* Only the blocks of the free-list are blue. See [freelist.c]. */ -- caml_fl_merge = Bp_hp (hp); -+ caml_fl_merge = (value) Bp_hp (hp); - break; - default: /* gray or black */ - CAMLassert (Color_hd (hd) == Caml_black); -diff --git a/runtime/spacetime_byt.c b/runtime/spacetime_byt.c -index 2b0bf1dc2..b75fb0980 100644 ---- a/runtime/spacetime_byt.c -+++ b/runtime/spacetime_byt.c -@@ -12,8 +12,12 @@ - /* */ - /**************************************************************************/ - -+#define CAML_INTERNALS -+ - #include "caml/fail.h" - #include "caml/mlvalues.h" -+#include "caml/io.h" -+#include "caml/spacetime.h" - - int caml_ensure_spacetime_dot_o_is_included = 42; - -@@ -22,7 +26,8 @@ CAMLprim value caml_spacetime_only_works_for_native_code(value foo, ...) - caml_failwith("Spacetime profiling only works for native code"); - } - --uintnat caml_spacetime_my_profinfo (void) -+uintnat caml_spacetime_my_profinfo (spacetime_unwind_info_cache * cached, -+ uintnat wosize) - { - return 0; - } --- -2.28.0.rc2 - diff --git a/ocaml.spec b/ocaml.spec index 69cb928..6c0c101 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -30,8 +30,8 @@ %global rcver %{nil} Name: ocaml -Version: 4.11.1 -Release: 2%{?dist} +Version: 4.12.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -39,7 +39,7 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org -Source0: https://caml.inria.fr/pub/distrib/ocaml-4.11/ocaml-%{version}.tar.xz +Source0: https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-%{version}.tar.xz #Source0: https://github.com/ocaml/ocaml/archive/%%{version}.tar.gz # IMPORTANT NOTE: @@ -51,7 +51,7 @@ Source0: https://caml.inria.fr/pub/distrib/ocaml-4.11/ocaml-%{version}.ta # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-34-4.11.1 +# Current branch: fedora-35-4.12.0 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -60,10 +60,7 @@ Source0: https://caml.inria.fr/pub/distrib/ocaml-4.11/ocaml-%{version}.ta Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch -Patch0004: 0004-Remove-configure-from-.gitattributes.patch - -# Fix compilation with LTO (upstream, but not in 4.11 branch). -Patch0005: 0005-Fix-type-mismatches-between-definition-and-declarati.patch +Patch0004: 0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch BuildRequires: make BuildRequires: git @@ -233,10 +230,6 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs/*.so find $RPM_BUILD_ROOT -name .ignore -delete -# Remove .cmt and .cmti files, for now. We could package them later. -# See also: http://www.ocamlpro.com/blog/2012/08/20/ocamlpro-and-4.00.0.html -find $RPM_BUILD_ROOT \( -name '*.cmt' -o -name '*.cmti' \) -a -delete - # 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 @@ -293,8 +286,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlopt.opt %endif -#%{_libdir}/ocaml/addlabels -#%{_libdir}/ocaml/scrapelabels +#%%{_libdir}/ocaml/addlabels +#%%{_libdir}/ocaml/scrapelabels %{_libdir}/ocaml/camlheader %{_libdir}/ocaml/camlheader_ur %{_libdir}/ocaml/expunge @@ -313,7 +306,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %endif %{_libdir}/ocaml/*.mli %{_libdir}/ocaml/libcamlrun_shared.so -%{_libdir}/ocaml/objinfo_helper +#%%{_libdir}/ocaml/objinfo_helper %{_libdir}/ocaml/threads/*.mli %if %{native_compiler} %{_libdir}/ocaml/threads/*.a @@ -329,7 +322,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlrund %{_bindir}/ocamlruni %dir %{_libdir}/ocaml -%{_libdir}/ocaml/VERSION +#%%{_libdir}/ocaml/VERSION %{_libdir}/ocaml/*.cmo %{_libdir}/ocaml/*.cmi %{_libdir}/ocaml/*.cma @@ -345,6 +338,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files source %doc LICENSE %{_libdir}/ocaml/*.ml +%{_libdir}/ocaml/*.cmt* +%{_libdir}/ocaml/*/*.cmt* %files ocamldoc @@ -375,6 +370,13 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Sun Feb 28 2021 Richard W.M. Jones - 4.12.0-1 +- OCaml 4.12.0 release (RHBZ#1893381). +- Workaround for glibc non-constant SIGSTKSZ + (https://github.com/ocaml/ocaml/issues/10250) +- Package *.cmt and *.cmti files. +- Remove objinfo_helper since it is no longer built. + * Tue Jan 26 2021 Fedora Release Engineering - 4.11.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild diff --git a/sources b/sources index 1e5a596..71e302d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.11.1.tar.xz) = ca34655dc22257aa48aeb48a9cf56bde177aa0f0e7f3965f334939934801a206ed5667b7ab0cc291df9e6bf1bb3251f7384f078ea5562e647fde93167ecb1e84 +SHA512 (ocaml-4.12.0.tar.xz) = fff347398300097e32dcdd0fabfa158693e3d27d4b0fef23a564be4993950be374e3e436205e621485f4188ab007e489c50b1294e1999dac36312e56ec5b52c9 From 129153b85109944bf0b2922949f77ef8f32b39a1 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 23 Jun 2021 11:37:37 +0100 Subject: [PATCH 41/91] Move to final version of upstream patch for non-constant SIGSTKSZ NOTE: I did not build this package because it will cause dependency problems (requiring every other OCaml package in F35 to be rebuilt). If there is a mass rebuild of Rawhide then that would be a good time to rebuild it. --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...-incorrect-assumption-about-cross-co.patch | 2 +- ...cate-the-alternate-signal-stack-1026.patch | 103 ++++++++++++++++++ ...ound-for-glibc-non-constant-SIGSTKSZ.patch | 39 ------- ocaml.spec | 7 +- 6 files changed, 111 insertions(+), 44 deletions(-) create mode 100644 0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch delete mode 100644 0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 855b634..0b3908e 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -23,5 +23,5 @@ index 07e2eda1a..340508a60 100644 > ocamlmklibconfig.ml -- -2.29.0.rc2 +2.32.0 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 8c7c0d1..b1c45b3 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -23,5 +23,5 @@ index 83455a3b6..213392b25 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.29.0.rc2 +2.32.0 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 9324e15..0a4567f 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -39,5 +39,5 @@ index 213392b25..c7e594b5d 100644 # We first compute default values for as and aspp # If values have been given by the user then they take precedence over -- -2.29.0.rc2 +2.32.0 diff --git a/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch b/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch new file mode 100644 index 0000000..15ca240 --- /dev/null +++ b/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch @@ -0,0 +1,103 @@ +From 3104d92743614f8f52039e0520116af4179880a5 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Fri, 5 Mar 2021 19:14:07 +0100 +Subject: [PATCH 4/4] Dynamically allocate the alternate signal stack (#10266) + +In Glibc 2.34 and later, SIGSTKSZ may not be a compile-time constant. +It is no longer possible to statically allocate the alternate signal +stack for the main thread, as we've been doing for the last 25 years. + +This commit implements dynamic allocation of the alternate signal stack +even for the main thread. It reuses the code already in place to allocate +the alternate signal stack for other threads. + +Fixes: #10250. +(cherry picked from commit fc9534746bf5d08a4c109f22e344cf49d5d46d54) +--- + runtime/caml/signals.h | 2 +- + runtime/signals_byt.c | 2 +- + runtime/signals_nat.c | 25 ++++++++++++++----------- + 3 files changed, 16 insertions(+), 13 deletions(-) + +diff --git a/runtime/caml/signals.h b/runtime/caml/signals.h +index 3ff152c26..285dbd7fe 100644 +--- a/runtime/caml/signals.h ++++ b/runtime/caml/signals.h +@@ -87,7 +87,7 @@ 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 void caml_setup_stack_overflow_detection(void); ++CAMLextern int caml_setup_stack_overflow_detection(void); + + CAMLextern void (*caml_enter_blocking_section_hook)(void); + CAMLextern void (*caml_leave_blocking_section_hook)(void); +diff --git a/runtime/signals_byt.c b/runtime/signals_byt.c +index 2183142da..38eb5e3a4 100644 +--- a/runtime/signals_byt.c ++++ b/runtime/signals_byt.c +@@ -81,4 +81,4 @@ int caml_set_signal_action(int signo, int action) + return 0; + } + +-CAMLexport void caml_setup_stack_overflow_detection(void) {} ++CAMLexport int caml_setup_stack_overflow_detection(void) { return 0; } +diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c +index 8b64ab452..2b4004860 100644 +--- a/runtime/signals_nat.c ++++ b/runtime/signals_nat.c +@@ -181,8 +181,6 @@ DECLARE_SIGNAL_HANDLER(trap_handler) + #error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined" + #endif + +-static char sig_alt_stack[SIGSTKSZ]; +- + /* Code compiled with ocamlopt never accesses more than + EXTRA_STACK bytes below the stack pointer. */ + #define EXTRA_STACK 256 +@@ -276,28 +274,33 @@ void caml_init_signals(void) + #endif + + #ifdef HAS_STACK_OVERFLOW_DETECTION +- { +- stack_t stk; ++ if (caml_setup_stack_overflow_detection() != -1) { + struct sigaction act; +- stk.ss_sp = sig_alt_stack; +- stk.ss_size = SIGSTKSZ; +- stk.ss_flags = 0; + SET_SIGACT(act, segv_handler); + act.sa_flags |= SA_ONSTACK | SA_NODEFER; + sigemptyset(&act.sa_mask); +- if (sigaltstack(&stk, NULL) == 0) { sigaction(SIGSEGV, &act, NULL); } ++ sigaction(SIGSEGV, &act, NULL); + } + #endif + } + +-CAMLexport void caml_setup_stack_overflow_detection(void) ++/* Allocate and select an alternate stack for handling signals, ++ especially SIGSEGV signals. ++ 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). */ ++ ++CAMLexport int 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_flags = 0; +- if (stk.ss_sp) +- sigaltstack(&stk, NULL); ++ return sigaltstack(&stk, NULL); ++#else ++ return 0; + #endif + } +-- +2.32.0 + diff --git a/0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch b/0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch deleted file mode 100644 index b672f08..0000000 --- a/0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch +++ /dev/null @@ -1,39 +0,0 @@ -From dfb5e954a04f59b0456cc4c0ddf3acaf22e0ff07 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sun, 28 Feb 2021 20:45:47 +0000 -Subject: [PATCH 4/4] Workaround for glibc non-constant SIGSTKSZ - -https://github.com/ocaml/ocaml/issues/10250 - -Signed-off-by: Richard W.M. Jones ---- - runtime/signals_nat.c | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c -index 8b64ab452..7f0a97513 100644 ---- a/runtime/signals_nat.c -+++ b/runtime/signals_nat.c -@@ -181,7 +181,19 @@ DECLARE_SIGNAL_HANDLER(trap_handler) - #error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined" - #endif - -+#ifndef __GLIBC__ - static char sig_alt_stack[SIGSTKSZ]; -+#else -+/* glibc 2.34 has non-constant SIGSTKSZ */ -+static char *sig_alt_stack; -+ -+static void allocate_sig_alt_stack(void) __attribute__((constructor)); -+static void -+allocate_sig_alt_stack(void) -+{ -+ sig_alt_stack = malloc(SIGSTKSZ); -+} -+#endif - - /* Code compiled with ocamlopt never accesses more than - EXTRA_STACK bytes below the stack pointer. */ --- -2.29.0.rc2 - diff --git a/ocaml.spec b/ocaml.spec index 6c0c101..b25c756 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.12.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -60,7 +60,7 @@ Source0: https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-%{version}.ta Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch -Patch0004: 0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch +Patch0004: 0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch BuildRequires: make BuildRequires: git @@ -370,6 +370,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Wed Jun 23 2021 Richard W.M. Jones - 4.12.0-2 +- Move to final version of upstream patch for non-constant SIGSTKSZ + * Sun Feb 28 2021 Richard W.M. Jones - 4.12.0-1 - OCaml 4.12.0 release (RHBZ#1893381). - Workaround for glibc non-constant SIGSTKSZ From 95d7ecd59bfa5d442aa4f8e9728811efee3bd73a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 22 Jul 2021 16:31:11 +0000 Subject: [PATCH 42/91] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index b25c756..95a2794 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.12.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -370,6 +370,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Thu Jul 22 2021 Fedora Release Engineering - 4.12.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + * Wed Jun 23 2021 Richard W.M. Jones - 4.12.0-2 - Move to final version of upstream patch for non-constant SIGSTKSZ From edfb35d8754e3ec08ca17381cb95361f81f6f0aa Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 4 Oct 2021 12:43:33 +0100 Subject: [PATCH 43/91] New upstream version 4.13.1 --- .gitignore | 1 + 0001-Don-t-add-rpaths-to-libraries.patch | 36 +++--- ...-Allow-user-defined-C-compiler-flags.patch | 8 +- ...-incorrect-assumption-about-cross-co.patch | 46 ++++++-- ...cate-the-alternate-signal-stack-1026.patch | 103 ------------------ ocaml.spec | 15 +-- sources | 2 +- 7 files changed, 67 insertions(+), 144 deletions(-) delete mode 100644 0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch diff --git a/.gitignore b/.gitignore index 0244410..33b0bdd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /ocaml-*.tar.xz /ocaml-*-refman.pdf /4.11.0.tar.gz +/4.13.1.tar.gz diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 0b3908e..fd84790 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,27 +1,27 @@ -From db7d6fd991dc43f392c895ee857f7948f5b4fe5e Mon Sep 17 00:00:00 2001 +From 23f2e84d360208759c7d82b7ff795770ce6cf0b2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/4] Don't add rpaths to libraries. +Subject: [PATCH 1/3] Don't add rpaths to libraries. --- - tools/Makefile | 4 ++-- + utils/config.mlp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -diff --git a/tools/Makefile b/tools/Makefile -index 07e2eda1a..340508a60 100644 ---- a/tools/Makefile -+++ b/tools/Makefile -@@ -146,8 +146,8 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ - ocamlmklibconfig.ml: $(ROOTDIR)/Makefile.config Makefile - (echo 'let bindir = "$(BINDIR)"'; \ - echo 'let supports_shared_libraries = $(SUPPORTS_SHARED_LIBRARIES)';\ -- echo 'let default_rpath = "$(RPATH)"'; \ -- echo 'let mksharedlibrpath = "$(MKSHAREDLIBRPATH)"'; \ -+ echo 'let default_rpath = ""'; \ -+ echo 'let mksharedlibrpath = ""'; \ - echo 'let toolpref = "$(TOOLPREF)"';) \ - > ocamlmklibconfig.ml - +diff --git a/utils/config.mlp b/utils/config.mlp +index bbb3c5694..57d509cd0 100644 +--- a/utils/config.mlp ++++ b/utils/config.mlp +@@ -55,8 +55,8 @@ let native_c_compiler = + let native_c_libraries = "%%NATIVECCLIBS%%" + let native_pack_linker = "%%PACKLD%%" + let ranlib = "%%RANLIBCMD%%" +-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.32.0 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index b1c45b3..2e5813a 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From bf42dba499e053196b9235aae9987f395c4a4b7e Mon Sep 17 00:00:00 2001 +From 9966786a7389dc6621f2bc2dce7c690c5a38b67d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/3] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index 83455a3b6..213392b25 100644 +index 3698c7cbf..e2a3cbea0 100644 --- a/configure.ac +++ b/configure.ac -@@ -638,6 +638,10 @@ AS_CASE([$host], +@@ -669,6 +669,10 @@ AS_CASE([$host], internal_cflags="$cc_warnings"], [common_cflags="-O"])]) diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 0a4567f..6f7cd50 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,19 +1,23 @@ -From 5cc71dbb0f25d4c5b444f099965b93149577ee8f Mon Sep 17 00:00:00 2001 +From 5eff09224929f8fa1a2e19f9a15befd3a4a395ea Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/4] configure: Remove incorrect assumption about +Subject: [PATCH 3/3] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 + +The error seen without this patch is: + +sh: line 1: x86_64-pc-linux-gnu-as: command not found --- - configure.ac | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) + configure.ac | 31 ++++++++++++++++--------------- + 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac -index 213392b25..c7e594b5d 100644 +index e2a3cbea0..07c005f09 100644 --- a/configure.ac +++ b/configure.ac -@@ -529,10 +529,11 @@ AS_IF( +@@ -560,10 +560,11 @@ AS_IF( # Are we building a cross-compiler @@ -29,15 +33,35 @@ index 213392b25..c7e594b5d 100644 # Checks for programs -@@ -1072,7 +1073,7 @@ AS_CASE([$arch], +@@ -1186,17 +1187,17 @@ AS_CASE([$arch], # Assembler --AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""]) -+#AS_IF([test -n "$host_alias"], [toolpref="${host_alias}-"], [toolpref=""]) +-AS_IF([test -n "$target_alias"], +- [toolpref="${target_alias}-" +- as_target="$target" +- as_cpu="$target_cpu"], +- [AS_IF([test -n "$host_alias"], +- [toolpref="${host_alias}-" +- as_target="$host" +- as_cpu="$host_cpu"], +- [toolpref="" +- as_target="$build" +- as_cpu="$build_cpu"])]) ++dnl AS_IF([test -n "$target_alias"], ++dnl [toolpref="${target_alias}-" ++dnl as_target="$target" ++dnl as_cpu="$target_cpu"], ++dnl [AS_IF([test -n "$host_alias"], ++dnl [toolpref="${host_alias}-" ++dnl as_target="$host" ++dnl as_cpu="$host_cpu"], ++dnl [toolpref="" ++dnl as_target="$build" ++dnl as_cpu="$build_cpu"])]) - # We first compute default values for as and aspp - # If values have been given by the user then they take precedence over + # Finding the assembler + # The OCaml build system distinguishes two different assemblers: -- 2.32.0 diff --git a/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch b/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch deleted file mode 100644 index 15ca240..0000000 --- a/0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 3104d92743614f8f52039e0520116af4179880a5 Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Fri, 5 Mar 2021 19:14:07 +0100 -Subject: [PATCH 4/4] Dynamically allocate the alternate signal stack (#10266) - -In Glibc 2.34 and later, SIGSTKSZ may not be a compile-time constant. -It is no longer possible to statically allocate the alternate signal -stack for the main thread, as we've been doing for the last 25 years. - -This commit implements dynamic allocation of the alternate signal stack -even for the main thread. It reuses the code already in place to allocate -the alternate signal stack for other threads. - -Fixes: #10250. -(cherry picked from commit fc9534746bf5d08a4c109f22e344cf49d5d46d54) ---- - runtime/caml/signals.h | 2 +- - runtime/signals_byt.c | 2 +- - runtime/signals_nat.c | 25 ++++++++++++++----------- - 3 files changed, 16 insertions(+), 13 deletions(-) - -diff --git a/runtime/caml/signals.h b/runtime/caml/signals.h -index 3ff152c26..285dbd7fe 100644 ---- a/runtime/caml/signals.h -+++ b/runtime/caml/signals.h -@@ -87,7 +87,7 @@ 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 void caml_setup_stack_overflow_detection(void); -+CAMLextern int caml_setup_stack_overflow_detection(void); - - CAMLextern void (*caml_enter_blocking_section_hook)(void); - CAMLextern void (*caml_leave_blocking_section_hook)(void); -diff --git a/runtime/signals_byt.c b/runtime/signals_byt.c -index 2183142da..38eb5e3a4 100644 ---- a/runtime/signals_byt.c -+++ b/runtime/signals_byt.c -@@ -81,4 +81,4 @@ int caml_set_signal_action(int signo, int action) - return 0; - } - --CAMLexport void caml_setup_stack_overflow_detection(void) {} -+CAMLexport int caml_setup_stack_overflow_detection(void) { return 0; } -diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c -index 8b64ab452..2b4004860 100644 ---- a/runtime/signals_nat.c -+++ b/runtime/signals_nat.c -@@ -181,8 +181,6 @@ DECLARE_SIGNAL_HANDLER(trap_handler) - #error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined" - #endif - --static char sig_alt_stack[SIGSTKSZ]; -- - /* Code compiled with ocamlopt never accesses more than - EXTRA_STACK bytes below the stack pointer. */ - #define EXTRA_STACK 256 -@@ -276,28 +274,33 @@ void caml_init_signals(void) - #endif - - #ifdef HAS_STACK_OVERFLOW_DETECTION -- { -- stack_t stk; -+ if (caml_setup_stack_overflow_detection() != -1) { - struct sigaction act; -- stk.ss_sp = sig_alt_stack; -- stk.ss_size = SIGSTKSZ; -- stk.ss_flags = 0; - SET_SIGACT(act, segv_handler); - act.sa_flags |= SA_ONSTACK | SA_NODEFER; - sigemptyset(&act.sa_mask); -- if (sigaltstack(&stk, NULL) == 0) { sigaction(SIGSEGV, &act, NULL); } -+ sigaction(SIGSEGV, &act, NULL); - } - #endif - } - --CAMLexport void caml_setup_stack_overflow_detection(void) -+/* Allocate and select an alternate stack for handling signals, -+ especially SIGSEGV signals. -+ 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). */ -+ -+CAMLexport int 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_flags = 0; -- if (stk.ss_sp) -- sigaltstack(&stk, NULL); -+ return sigaltstack(&stk, NULL); -+#else -+ return 0; - #endif - } --- -2.32.0 - diff --git a/ocaml.spec b/ocaml.spec index 95a2794..b52b56c 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -30,8 +30,8 @@ %global rcver %{nil} Name: ocaml -Version: 4.12.0 -Release: 3%{?dist} +Version: 4.13.1 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -39,8 +39,7 @@ License: QPL and (LGPLv2+ with exceptions) URL: http://www.ocaml.org -Source0: https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-%{version}.tar.xz -#Source0: https://github.com/ocaml/ocaml/archive/%%{version}.tar.gz +Source0: https://github.com/ocaml/ocaml/archive/%%{version}.tar.gz # IMPORTANT NOTE: # @@ -51,7 +50,7 @@ Source0: https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-%{version}.ta # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-35-4.12.0 +# Current branch: fedora-36-4.13.1 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -60,9 +59,8 @@ Source0: https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-%{version}.ta Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch -Patch0004: 0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch -BuildRequires: make +BuildRequires: make BuildRequires: git BuildRequires: gcc BuildRequires: autoconf @@ -370,6 +368,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Mon Oct 04 2021 Richard W.M. Jones - 4.13.1-1 +- New upstream version 4.13.1 + * Thu Jul 22 2021 Fedora Release Engineering - 4.12.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild diff --git a/sources b/sources index 71e302d..e1aeb8a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.12.0.tar.xz) = fff347398300097e32dcdd0fabfa158693e3d27d4b0fef23a564be4993950be374e3e436205e621485f4188ab007e489c50b1294e1999dac36312e56ec5b52c9 +SHA512 (4.13.1.tar.gz) = da3434177438c852da53c0fda7bc2519adcda6384d97d45e44137ed0fd384ffb3da61958a7b51296edb3f88f5a5310ca71b6862f6d756aaa4012d1f54e5955f6 From 999a7e734e97281674caaa3e985c0f48f7eadb21 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jan 2022 21:37:12 +0000 Subject: [PATCH 44/91] - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index b52b56c..7ddabff 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -31,7 +31,7 @@ Name: ocaml Version: 4.13.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -368,6 +368,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Thu Jan 20 2022 Fedora Release Engineering - 4.13.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + * Mon Oct 04 2021 Richard W.M. Jones - 4.13.1-1 - New upstream version 4.13.1 From b249a82b37c15a17b69cda88445bdc753a19203c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 26 Jan 2022 16:29:56 +0000 Subject: [PATCH 45/91] Disable package note misfeature --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...-incorrect-assumption-about-cross-co.patch | 2 +- ...nly-use-OC_-for-building-executables.patch | 31 +++++++++++++++++++ ocaml.spec | 10 +++++- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 0004-configure-Only-use-OC_-for-building-executables.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index fd84790..eb6794d 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 23f2e84d360208759c7d82b7ff795770ce6cf0b2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/3] Don't add rpaths to libraries. +Subject: [PATCH 1/4] Don't add rpaths to libraries. --- utils/config.mlp | 4 ++-- diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 2e5813a..389f09b 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From 9966786a7389dc6621f2bc2dce7c690c5a38b67d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/3] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch index 6f7cd50..e101809 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0003-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ From 5eff09224929f8fa1a2e19f9a15befd3a4a395ea Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/3] configure: Remove incorrect assumption about +Subject: [PATCH 3/4] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 diff --git a/0004-configure-Only-use-OC_-for-building-executables.patch b/0004-configure-Only-use-OC_-for-building-executables.patch new file mode 100644 index 0000000..1f21b0f --- /dev/null +++ b/0004-configure-Only-use-OC_-for-building-executables.patch @@ -0,0 +1,31 @@ +From acb5dbaa8f8ece825a48814024404a1a6c5ba7b2 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 26 Jan 2022 15:47:02 +0000 +Subject: [PATCH 4/4] 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 07c005f09..19fe3fd1b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -43,7 +43,7 @@ libraries_man_section=3 + # 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.32.0 + diff --git a/ocaml.spec b/ocaml.spec index 7ddabff..64b3036 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -1,3 +1,6 @@ +# Don't add -Wl,-dT, +%undefine _package_note_flags + # OCaml has a bytecode backend that works on anything with a C # compiler, and a native code backend available on a subset of # architectures. A further subset of architectures support native @@ -31,7 +34,7 @@ Name: ocaml Version: 4.13.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -59,6 +62,7 @@ Source0: https://github.com/ocaml/ocaml/archive/%%{version}.tar.gz Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch +Patch0004: 0004-configure-Only-use-OC_-for-building-executables.patch BuildRequires: make BuildRequires: git @@ -368,6 +372,10 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Wed Jan 26 2022 Richard W.M. Jones - 4.13.1-3 +- Disable package note misfeature +- Remove duplicate flags from mkexe + * Thu Jan 20 2022 Fedora Release Engineering - 4.13.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild From 37422916a0f4d46663ffff8b54cea5f921414d16 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 4 Feb 2022 10:22:30 +0000 Subject: [PATCH 46/91] Rebuild 4.13.1 to remove package notes --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 64b3036..59efada 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -34,7 +34,7 @@ Name: ocaml Version: 4.13.1 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -372,6 +372,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Fri Feb 04 2022 Richard W.M. Jones - 4.13.1-4 +- Rebuild 4.13.1 to remove package notes + * Wed Jan 26 2022 Richard W.M. Jones - 4.13.1-3 - Disable package note misfeature - Remove duplicate flags from mkexe From 3eca5f5ac733c20aaed5c4f29dd7d1f7f743ac56 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Thu, 9 Jun 2022 14:42:27 -0600 Subject: [PATCH 47/91] Fix the Source0 URL - chrpath is no longer needed - Use the %license macro - Build the test binaries so the tests will run --- ocaml.spec | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 59efada..8728970 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -40,9 +40,9 @@ Summary: OCaml compiler and programming environment License: QPL and (LGPLv2+ with exceptions) -URL: http://www.ocaml.org +URL: https://www.ocaml.org -Source0: https://github.com/ocaml/ocaml/archive/%%{version}.tar.gz +Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{version}.tar.gz # IMPORTANT NOTE: # @@ -75,7 +75,6 @@ BuildRequires: gawk BuildRequires: perl-interpreter BuildRequires: util-linux BuildRequires: /usr/bin/annocheck -BuildRequires: chrpath # ocamlopt runs gcc to link binaries. Because Fedora includes # hardening flags automatically, redhat-rpm-config is also required. @@ -85,9 +84,9 @@ Requires: redhat-rpm-config # 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 = %{version}-%{release} +Requires: ocaml-runtime%{?_isa} = %{version}-%{release} -# Bundles an MD5 implementation in byterun/md5.{c,h} +# Bundles an MD5 implementation in runtime/caml/md5.h and runtime/md5.c Provides: bundled(md5-plumb) Provides: ocaml(compiler) = %{version} @@ -121,7 +120,7 @@ bytecode. %package source Summary: Source code for OCaml libraries -Requires: ocaml = %{version}-%{release} +Requires: ocaml%{?_isa} = %{version}-%{release} %description source Source code for OCaml libraries. @@ -129,8 +128,8 @@ Source code for OCaml libraries. %package ocamldoc Summary: Documentation generator for OCaml -Requires: ocaml = %{version}-%{release} -Provides: ocamldoc +Requires: ocaml%{?_isa} = %{version}-%{release} +Provides: ocamldoc = %{version} %description ocamldoc Documentation generator for OCaml. @@ -150,7 +149,7 @@ This package contains man pages. %package compiler-libs Summary: Compiler libraries for OCaml -Requires: ocaml = %{version}-%{release} +Requires: ocaml%{?_isa} = %{version}-%{release} %description compiler-libs @@ -211,12 +210,14 @@ annocheck -v hello ||: %endif %ifarch %{test_arches} -cd testsuite - +make ocamltest +%ifarch %{ocaml_native_compiler} +make ocamltest.opt +%endif %ifarch %{test_arches_required} -make -j1 all +make -j1 tests %else -make -j1 all ||: +make -j1 tests ||: %endif %endif @@ -227,9 +228,6 @@ 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 rpaths from stublibs .so files. -chrpath --delete $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs/*.so - find $RPM_BUILD_ROOT -name .ignore -delete # Remove this file. It's only created in certain situations and it's @@ -238,7 +236,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files -%doc LICENSE +%license LICENSE %{_bindir}/ocaml %{_bindir}/ocamlcmt @@ -319,7 +317,8 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files runtime -%doc README.adoc LICENSE Changes +%doc README.adoc Changes +%license LICENSE %{_bindir}/ocamlrun %{_bindir}/ocamlrund %{_bindir}/ocamlruni @@ -338,14 +337,14 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files source -%doc LICENSE +%license LICENSE %{_libdir}/ocaml/*.ml %{_libdir}/ocaml/*.cmt* %{_libdir}/ocaml/*/*.cmt* %files ocamldoc -%doc LICENSE +%license LICENSE %doc ocamldoc/Changes.txt %{_bindir}/ocamldoc* %{_libdir}/ocaml/ocamldoc @@ -357,7 +356,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files compiler-libs -%doc LICENSE +%license LICENSE %dir %{_libdir}/ocaml/compiler-libs %{_libdir}/ocaml/compiler-libs/*.mli %{_libdir}/ocaml/compiler-libs/*.cmi @@ -372,6 +371,12 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Thu Jun 9 2022 Jerry James - 4.13.1-4 +- Fix the Source0 URL +- chrpath is no longer needed +- Use the %%license macro +- Build the test binaries so the tests will run + * Fri Feb 04 2022 Richard W.M. Jones - 4.13.1-4 - Rebuild 4.13.1 to remove package notes From 4bb2864cc2fa26a34f802021d80711815f8f0361 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 9 Jun 2022 22:37:55 +0100 Subject: [PATCH 48/91] Upload renamed sources file --- sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources b/sources index e1aeb8a..ee936bc 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (4.13.1.tar.gz) = da3434177438c852da53c0fda7bc2519adcda6384d97d45e44137ed0fd384ffb3da61958a7b51296edb3f88f5a5310ca71b6862f6d756aaa4012d1f54e5955f6 +SHA512 (ocaml-4.13.1.tar.gz) = da3434177438c852da53c0fda7bc2519adcda6384d97d45e44137ed0fd384ffb3da61958a7b51296edb3f88f5a5310ca71b6862f6d756aaa4012d1f54e5955f6 From 73c8e3d782f067e77102686a0f3e5b2f67e7b18a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Jun 2022 12:02:39 +0100 Subject: [PATCH 49/91] New upstream version 4.14.0 --- ...arning-when-calling-virtual-methods-.patch | 192 ++++++++++++++++++ ...st-11236-from-Nymphium-missing-since.patch | 43 ++++ ...preprocessor-conditional-on-_MSC_VER.patch | 26 +++ 0004-Changes.patch | 28 +++ ...more-instances-of-undefined-_MSC_VER.patch | 93 +++++++++ ...> 0006-Don-t-add-rpaths-to-libraries.patch | 8 +- ...-Allow-user-defined-C-compiler-flags.patch | 10 +- ...-incorrect-assumption-about-cross-co.patch | 12 +- ...nly-use-OC_-for-building-executables.patch | 10 +- ocaml.spec | 28 ++- sources | 2 +- 11 files changed, 422 insertions(+), 30 deletions(-) create mode 100644 0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch create mode 100644 0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch create mode 100644 0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch create mode 100644 0004-Changes.patch create mode 100644 0005-Guard-more-instances-of-undefined-_MSC_VER.patch rename 0001-Don-t-add-rpaths-to-libraries.patch => 0006-Don-t-add-rpaths-to-libraries.patch (80%) rename 0002-configure-Allow-user-defined-C-compiler-flags.patch => 0007-configure-Allow-user-defined-C-compiler-flags.patch (72%) rename 0003-configure-Remove-incorrect-assumption-about-cross-co.patch => 0008-configure-Remove-incorrect-assumption-about-cross-co.patch (86%) rename 0004-configure-Only-use-OC_-for-building-executables.patch => 0009-configure-Only-use-OC_-for-building-executables.patch (80%) 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..d89a4ac --- /dev/null +++ b/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch @@ -0,0 +1,192 @@ +From 3f6a90f1ac47c480522a009d6ea56e2acfb7112f 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 1/9] 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.36.1 + 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..3e043a5 --- /dev/null +++ b/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch @@ -0,0 +1,43 @@ +From 538cb5217642b36a8eab1ae027767c344e880b4b Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Thu, 5 May 2022 20:01:44 +0100 +Subject: [PATCH 2/9] 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.36.1 + 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..2484e29 --- /dev/null +++ b/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch @@ -0,0 +1,26 @@ +From c06ca224780f005b625ef406a817ead3eb9a8665 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 3/9] 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.36.1 + diff --git a/0004-Changes.patch b/0004-Changes.patch new file mode 100644 index 0000000..fa96bd5 --- /dev/null +++ b/0004-Changes.patch @@ -0,0 +1,28 @@ +From bfb9a2157c50c1b4a9cb8dc0319fe375b5e80b1d 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 4/9] 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.36.1 + 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..da39f67 --- /dev/null +++ b/0005-Guard-more-instances-of-undefined-_MSC_VER.patch @@ -0,0 +1,93 @@ +From 53ce1f582e37faabfd616a0b09521497e2e7ef14 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Wed, 18 May 2022 12:48:33 +0100 +Subject: [PATCH 5/9] 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.36.1 + diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0006-Don-t-add-rpaths-to-libraries.patch similarity index 80% rename from 0001-Don-t-add-rpaths-to-libraries.patch rename to 0006-Don-t-add-rpaths-to-libraries.patch index eb6794d..e776416 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0006-Don-t-add-rpaths-to-libraries.patch @@ -1,14 +1,14 @@ -From 23f2e84d360208759c7d82b7ff795770ce6cf0b2 Mon Sep 17 00:00:00 2001 +From fc7eb8e75bee1b8bf12dcbb7787781169b260558 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/4] Don't add rpaths to libraries. +Subject: [PATCH 6/9] 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 bbb3c5694..57d509cd0 100644 +index 44c6ff8fa5..a12c31a2bd 100644 --- a/utils/config.mlp +++ b/utils/config.mlp @@ -55,8 +55,8 @@ let native_c_compiler = @@ -23,5 +23,5 @@ index bbb3c5694..57d509cd0 100644 let supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%% let mkdll, mkexe, mkmaindll = -- -2.32.0 +2.36.1 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0007-configure-Allow-user-defined-C-compiler-flags.patch similarity index 72% rename from 0002-configure-Allow-user-defined-C-compiler-flags.patch rename to 0007-configure-Allow-user-defined-C-compiler-flags.patch index 389f09b..77a031b 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0007-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From 9966786a7389dc6621f2bc2dce7c690c5a38b67d Mon Sep 17 00:00:00 2001 +From b91178cc8fdf657933c26d54a0c67fd69eb67427 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. +Subject: [PATCH 7/9] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac -index 3698c7cbf..e2a3cbea0 100644 +index 2f4ebf9b30..5ccfe8fb01 100644 --- a/configure.ac +++ b/configure.ac -@@ -669,6 +669,10 @@ AS_CASE([$host], +@@ -690,6 +690,10 @@ AS_CASE([$host], internal_cflags="$cc_warnings"], [common_cflags="-O"])]) @@ -23,5 +23,5 @@ index 3698c7cbf..e2a3cbea0 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.32.0 +2.36.1 diff --git a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch b/0008-configure-Remove-incorrect-assumption-about-cross-co.patch similarity index 86% rename from 0003-configure-Remove-incorrect-assumption-about-cross-co.patch rename to 0008-configure-Remove-incorrect-assumption-about-cross-co.patch index e101809..3536a98 100644 --- a/0003-configure-Remove-incorrect-assumption-about-cross-co.patch +++ b/0008-configure-Remove-incorrect-assumption-about-cross-co.patch @@ -1,7 +1,7 @@ -From 5eff09224929f8fa1a2e19f9a15befd3a4a395ea Mon Sep 17 00:00:00 2001 +From 41d5e2db7a4667560d6aedda11a3c6a80c8f1b83 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 3/4] configure: Remove incorrect assumption about +Subject: [PATCH 8/9] configure: Remove incorrect assumption about cross-compiling. See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 @@ -14,10 +14,10 @@ sh: line 1: x86_64-pc-linux-gnu-as: command not found 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac -index e2a3cbea0..07c005f09 100644 +index 5ccfe8fb01..c763310acb 100644 --- a/configure.ac +++ b/configure.ac -@@ -560,10 +560,11 @@ AS_IF( +@@ -578,10 +578,11 @@ AS_IF( # Are we building a cross-compiler @@ -33,7 +33,7 @@ index e2a3cbea0..07c005f09 100644 # Checks for programs -@@ -1186,17 +1187,17 @@ AS_CASE([$arch], +@@ -1212,17 +1213,17 @@ AS_CASE([$arch], # Assembler @@ -63,5 +63,5 @@ index e2a3cbea0..07c005f09 100644 # Finding the assembler # The OCaml build system distinguishes two different assemblers: -- -2.32.0 +2.36.1 diff --git a/0004-configure-Only-use-OC_-for-building-executables.patch b/0009-configure-Only-use-OC_-for-building-executables.patch similarity index 80% rename from 0004-configure-Only-use-OC_-for-building-executables.patch rename to 0009-configure-Only-use-OC_-for-building-executables.patch index 1f21b0f..8432e41 100644 --- a/0004-configure-Only-use-OC_-for-building-executables.patch +++ b/0009-configure-Only-use-OC_-for-building-executables.patch @@ -1,7 +1,7 @@ -From acb5dbaa8f8ece825a48814024404a1a6c5ba7b2 Mon Sep 17 00:00:00 2001 +From 05b882737e0daecb86a6ef54e192508c60efcd88 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 26 Jan 2022 15:47:02 +0000 -Subject: [PATCH 4/4] configure: Only use OC_* for building executables +Subject: [PATCH 9/9] 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. @@ -14,10 +14,10 @@ ocamlopt uses. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 07c005f09..19fe3fd1b 100644 +index c763310acb..9cce5ea47a 100644 --- a/configure.ac +++ b/configure.ac -@@ -43,7 +43,7 @@ libraries_man_section=3 +@@ -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. @@ -27,5 +27,5 @@ index 07c005f09..19fe3fd1b 100644 # Flags for building executable files with debugging symbols mkexedebugflag="-g" -- -2.32.0 +2.36.1 diff --git a/ocaml.spec b/ocaml.spec index 8728970..7b348b6 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -33,8 +33,8 @@ %global rcver %{nil} Name: ocaml -Version: 4.13.1 -Release: 4%{?dist} +Version: 4.14.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -53,16 +53,23 @@ Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{vers # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-36-4.13.1 +# Current branch: fedora-37-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. -Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch -Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch -Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch -Patch0004: 0004-configure-Only-use-OC_-for-building-executables.patch +# 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 +# Fedora-specific patches +Patch0006: 0006-Don-t-add-rpaths-to-libraries.patch +Patch0007: 0007-configure-Allow-user-defined-C-compiler-flags.patch +Patch0008: 0008-configure-Remove-incorrect-assumption-about-cross-co.patch +Patch0009: 0009-configure-Only-use-OC_-for-building-executables.patch BuildRequires: make BuildRequires: git @@ -228,7 +235,8 @@ perl -pi -e "s|^$RPM_BUILD_ROOT||" $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf echo %{version} > $RPM_BUILD_ROOT%{_libdir}/ocaml/fedora-ocaml-release -find $RPM_BUILD_ROOT -name .ignore -delete +# Remove the installed documentation. We will install it using %%doc +rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml # Remove this file. It's only created in certain situations and it's # unclear why it is created at all. @@ -291,7 +299,6 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_libdir}/ocaml/camlheader %{_libdir}/ocaml/camlheader_ur %{_libdir}/ocaml/expunge -%{_libdir}/ocaml/extract_crc %{_libdir}/ocaml/ld.conf %{_libdir}/ocaml/Makefile.config %{_libdir}/ocaml/*.a @@ -371,6 +378,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Sat Jun 18 2022 Richard W.M. Jones - 4.14.0-1 +- New upstream version 4.14.0 + * Thu Jun 9 2022 Jerry James - 4.13.1-4 - Fix the Source0 URL - chrpath is no longer needed diff --git a/sources b/sources index ee936bc..6de827b 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.13.1.tar.gz) = da3434177438c852da53c0fda7bc2519adcda6384d97d45e44137ed0fd384ffb3da61958a7b51296edb3f88f5a5310ca71b6862f6d756aaa4012d1f54e5955f6 +SHA512 (ocaml-4.14.0.tar.gz) = 3c5e5b9f00bb109dd99b5f7b0078cf8663d4247e548f3e601d6b2a55582e04bb20f6de85005c4cf2f78ae9aaa449f5ca6f2bab2f6ce83eeb3aeb386e3f2fcc32 From 38e7f9a43c4b921acc0967ebb85c5a566a94aeb3 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 22 Jul 2022 01:04:51 +0000 Subject: [PATCH 50/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 7b348b6..d538213 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -34,7 +34,7 @@ Name: ocaml Version: 4.14.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -378,6 +378,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Fri Jul 22 2022 Fedora Release Engineering - 4.14.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + * Sat Jun 18 2022 Richard W.M. Jones - 4.14.0-1 - New upstream version 4.14.0 From 6fbb4db452cad948a903b0124d1c75f6b06a6833 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 5 Sep 2022 16:21:34 +0100 Subject: [PATCH 51/91] Include more upstream patches from 4.14 branch Don't use %configure macro because that breaks on riscv64. https://bugzilla.redhat.com/2124272 --- ...arning-when-calling-virtual-methods-.patch | 6 +- ...st-11236-from-Nymphium-missing-since.patch | 6 +- ...preprocessor-conditional-on-_MSC_VER.patch | 6 +- 0004-Changes.patch | 6 +- ...more-instances-of-undefined-_MSC_VER.patch | 6 +- ...entation-for-string_of_float-.-11353.patch | 95 +++++ ...st-11380-from-damiendoligez-fix-fort.patch | 30 ++ ...tialization-of-bytecode-threading-11.patch | 101 ++++++ ...-incorrect-assumption-about-cross-co.patch | 67 ---- ...st-11397-from-Octachron-tast_mapper_.patch | 49 +++ ...l-request-11396-from-gasche-fix11392.patch | 85 +++++ ...t-limitation-on-caml_callbackN-11409.patch | 53 +++ ...lib-on-created-installed-libraries-1.patch | 327 ++++++++++++++++++ ...ay-2-has-gfortran.sh-don-t-print-any.patch | 27 ++ ...st-11417-from-lpw25-fix-virtual-clas.patch | 147 ++++++++ ...-whole-module-type-error-message-114.patch | 154 +++++++++ ...est-11373-from-dra27-flexlink-detect.patch | 57 +++ ...est-11468-from-dra27-i686-mingw-ipv6.patch | 55 +++ ...llocation-of-alternate-signal-stack-.patch | 194 +++++++++++ ...st-11487-from-purplearmadillo77-fma_.patch | 54 +++ 0020-Fixup-Changes.patch | 36 ++ ...utable-which-couldn-t-be-triggered.-.patch | 90 +++++ ...> 0022-Don-t-add-rpaths-to-libraries.patch | 12 +- ...-Allow-user-defined-C-compiler-flags.patch | 10 +- ...nly-use-OC_-for-building-executables.patch | 8 +- ocaml.spec | 51 ++- 26 files changed, 1622 insertions(+), 110 deletions(-) create mode 100644 0006-Better-documentation-for-string_of_float-.-11353.patch create mode 100644 0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch create mode 100644 0008-Refactor-the-initialization-of-bytecode-threading-11.patch delete mode 100644 0008-configure-Remove-incorrect-assumption-about-cross-co.patch create mode 100644 0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch create mode 100644 0010-Merge-pull-request-11396-from-gasche-fix11392.patch create mode 100644 0011-Document-limitation-on-caml_callbackN-11409.patch create mode 100644 0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch create mode 100644 0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch create mode 100644 0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch create mode 100644 0015-Do-not-elide-the-whole-module-type-error-message-114.patch create mode 100644 0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch create mode 100644 0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch create mode 100644 0018-More-prudent-deallocation-of-alternate-signal-stack-.patch create mode 100644 0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch create mode 100644 0020-Fixup-Changes.patch create mode 100644 0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch rename 0006-Don-t-add-rpaths-to-libraries.patch => 0022-Don-t-add-rpaths-to-libraries.patch (69%) rename 0007-configure-Allow-user-defined-C-compiler-flags.patch => 0023-configure-Allow-user-defined-C-compiler-flags.patch (71%) rename 0009-configure-Only-use-OC_-for-building-executables.patch => 0024-configure-Only-use-OC_-for-building-executables.patch (83%) diff --git a/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch b/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch index d89a4ac..166e69a 100644 --- a/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch +++ b/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch @@ -1,7 +1,7 @@ -From 3f6a90f1ac47c480522a009d6ea56e2acfb7112f Mon Sep 17 00:00:00 2001 +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 1/9] Do not trigger warning when calling virtual methods +Subject: [PATCH 01/24] Do not trigger warning when calling virtual methods introduced by constraining "self" (#11204) (cherry picked from commit 1e7af3f6261502bb384dc9e23a74ad0990bfd854) @@ -188,5 +188,5 @@ index 048ee998b0..fedbc0e025 100644 begin match final with | Not_final -> () -- -2.36.1 +2.37.0.rc2 diff --git a/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch b/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch index 3e043a5..9c75989 100644 --- a/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch +++ b/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch @@ -1,7 +1,7 @@ -From 538cb5217642b36a8eab1ae027767c344e880b4b Mon Sep 17 00:00:00 2001 +From 623258a6517c8ec1d9e5f41cbdc05205a0e6ee1d Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Thu, 5 May 2022 20:01:44 +0100 -Subject: [PATCH 2/9] Merge pull request #11236 from Nymphium/missing-since2 +Subject: [PATCH 02/24] Merge pull request #11236 from Nymphium/missing-since2 Add missing @since annotation to Gc.eventlog_pause @@ -39,5 +39,5 @@ index b211197fd4..8031eeb8df 100644 (** [Memprof] is a sampling engine for allocated memory words. Every -- -2.36.1 +2.37.0.rc2 diff --git a/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch b/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch index 2484e29..3854e05 100644 --- a/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch +++ b/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch @@ -1,7 +1,7 @@ -From c06ca224780f005b625ef406a817ead3eb9a8665 Mon Sep 17 00:00:00 2001 +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 3/9] misc.h: fix preprocessor conditional on _MSC_VER +Subject: [PATCH 03/24] misc.h: fix preprocessor conditional on _MSC_VER (cherry picked from commit 253d605e10865371aed45967a94caed0642b7583) --- @@ -22,5 +22,5 @@ index 5915c30a7b..494d45e8f8 100644 #define CAMLdeprecated_typedef(name, type) \ typedef __declspec(deprecated) type name -- -2.36.1 +2.37.0.rc2 diff --git a/0004-Changes.patch b/0004-Changes.patch index fa96bd5..214e89e 100644 --- a/0004-Changes.patch +++ b/0004-Changes.patch @@ -1,7 +1,7 @@ -From bfb9a2157c50c1b4a9cb8dc0319fe375b5e80b1d Mon Sep 17 00:00:00 2001 +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 4/9] Changes +Subject: [PATCH 04/24] Changes (cherry picked from commit 9a157026f115364635f8fe0ae5805e15ef071de0) --- @@ -24,5 +24,5 @@ index 931a74b8d1..fdfffd78bb 100644 ---------------------------- -- -2.36.1 +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 index da39f67..d9f81d7 100644 --- a/0005-Guard-more-instances-of-undefined-_MSC_VER.patch +++ b/0005-Guard-more-instances-of-undefined-_MSC_VER.patch @@ -1,7 +1,7 @@ -From 53ce1f582e37faabfd616a0b09521497e2e7ef14 Mon Sep 17 00:00:00 2001 +From 513164232d897c39c4e571a7a8f167dee5c146b3 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 18 May 2022 12:48:33 +0100 -Subject: [PATCH 5/9] Guard more instances of undefined _MSC_VER +Subject: [PATCH 05/24] Guard more instances of undefined _MSC_VER --- Changes | 8 +++++--- @@ -89,5 +89,5 @@ index 494d45e8f8..c605f8711e 100644 __pragma( warning (disable:4189 ) ) #define CAMLunused_end __pragma( warning (pop)) -- -2.36.1 +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/0008-configure-Remove-incorrect-assumption-about-cross-co.patch b/0008-configure-Remove-incorrect-assumption-about-cross-co.patch deleted file mode 100644 index 3536a98..0000000 --- a/0008-configure-Remove-incorrect-assumption-about-cross-co.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 41d5e2db7a4667560d6aedda11a3c6a80c8f1b83 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Fri, 26 Apr 2019 16:16:29 +0100 -Subject: [PATCH 8/9] configure: Remove incorrect assumption about - cross-compiling. - -See https://github.com/ocaml/ocaml/issues/8647#issuecomment-487094390 - -The error seen without this patch is: - -sh: line 1: x86_64-pc-linux-gnu-as: command not found ---- - configure.ac | 31 ++++++++++++++++--------------- - 1 file changed, 16 insertions(+), 15 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 5ccfe8fb01..c763310acb 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -578,10 +578,11 @@ AS_IF( - - # Are we building a cross-compiler - --AS_IF( -- [test x"$host" = x"$target"], -- [cross_compiler=false], -- [cross_compiler=true]) -+#AS_IF( -+# [test x"$host" = x"$target"], -+# [cross_compiler=false], -+# [cross_compiler=true]) -+cross_compiler=false - - # Checks for programs - -@@ -1212,17 +1213,17 @@ AS_CASE([$arch], - - # Assembler - --AS_IF([test -n "$target_alias"], -- [toolpref="${target_alias}-" -- as_target="$target" -- as_cpu="$target_cpu"], -- [AS_IF([test -n "$host_alias"], -- [toolpref="${host_alias}-" -- as_target="$host" -- as_cpu="$host_cpu"], -- [toolpref="" -- as_target="$build" -- as_cpu="$build_cpu"])]) -+dnl AS_IF([test -n "$target_alias"], -+dnl [toolpref="${target_alias}-" -+dnl as_target="$target" -+dnl as_cpu="$target_cpu"], -+dnl [AS_IF([test -n "$host_alias"], -+dnl [toolpref="${host_alias}-" -+dnl as_target="$host" -+dnl as_cpu="$host_cpu"], -+dnl [toolpref="" -+dnl as_target="$build" -+dnl as_cpu="$build_cpu"])]) - - # Finding the assembler - # The OCaml build system distinguishes two different assemblers: --- -2.36.1 - 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/0006-Don-t-add-rpaths-to-libraries.patch b/0022-Don-t-add-rpaths-to-libraries.patch similarity index 69% rename from 0006-Don-t-add-rpaths-to-libraries.patch rename to 0022-Don-t-add-rpaths-to-libraries.patch index e776416..52b102b 100644 --- a/0006-Don-t-add-rpaths-to-libraries.patch +++ b/0022-Don-t-add-rpaths-to-libraries.patch @@ -1,20 +1,20 @@ -From fc7eb8e75bee1b8bf12dcbb7787781169b260558 Mon Sep 17 00:00:00 2001 +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 6/9] Don't add rpaths to libraries. +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 44c6ff8fa5..a12c31a2bd 100644 +index f758a9b483..ee17a737dc 100644 --- a/utils/config.mlp +++ b/utils/config.mlp -@@ -55,8 +55,8 @@ let native_c_compiler = +@@ -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 ranlib = "%%RANLIBCMD%%" -let default_rpath = "%%RPATH%%" -let mksharedlibrpath = "%%MKSHAREDLIBRPATH%%" +let default_rpath = "" @@ -23,5 +23,5 @@ index 44c6ff8fa5..a12c31a2bd 100644 let supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%% let mkdll, mkexe, mkmaindll = -- -2.36.1 +2.37.0.rc2 diff --git a/0007-configure-Allow-user-defined-C-compiler-flags.patch b/0023-configure-Allow-user-defined-C-compiler-flags.patch similarity index 71% rename from 0007-configure-Allow-user-defined-C-compiler-flags.patch rename to 0023-configure-Allow-user-defined-C-compiler-flags.patch index 77a031b..fc715f8 100644 --- a/0007-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0023-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From b91178cc8fdf657933c26d54a0c67fd69eb67427 Mon Sep 17 00:00:00 2001 +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 7/9] configure: Allow user defined C compiler flags. +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 2f4ebf9b30..5ccfe8fb01 100644 +index ebb8bbdb80..9e6c0b9745 100644 --- a/configure.ac +++ b/configure.ac -@@ -690,6 +690,10 @@ AS_CASE([$host], +@@ -680,6 +680,10 @@ AS_CASE([$host], internal_cflags="$cc_warnings"], [common_cflags="-O"])]) @@ -23,5 +23,5 @@ index 2f4ebf9b30..5ccfe8fb01 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. -- -2.36.1 +2.37.0.rc2 diff --git a/0009-configure-Only-use-OC_-for-building-executables.patch b/0024-configure-Only-use-OC_-for-building-executables.patch similarity index 83% rename from 0009-configure-Only-use-OC_-for-building-executables.patch rename to 0024-configure-Only-use-OC_-for-building-executables.patch index 8432e41..1dbe2f2 100644 --- a/0009-configure-Only-use-OC_-for-building-executables.patch +++ b/0024-configure-Only-use-OC_-for-building-executables.patch @@ -1,7 +1,7 @@ -From 05b882737e0daecb86a6ef54e192508c60efcd88 Mon Sep 17 00:00:00 2001 +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 9/9] configure: Only use OC_* for building executables +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. @@ -14,7 +14,7 @@ ocamlopt uses. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index c763310acb..9cce5ea47a 100644 +index 9e6c0b9745..cab4cbd579 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ CONFIGURE_ARGS="$*" @@ -27,5 +27,5 @@ index c763310acb..9cce5ea47a 100644 # Flags for building executable files with debugging symbols mkexedebugflag="-g" -- -2.36.1 +2.37.0.rc2 diff --git a/ocaml.spec b/ocaml.spec index d538213..3f03c76 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -34,7 +34,7 @@ Name: ocaml Version: 4.14.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -53,7 +53,7 @@ Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{vers # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-37-4.14.0 +# 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 @@ -65,11 +65,27 @@ 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 -Patch0006: 0006-Don-t-add-rpaths-to-libraries.patch -Patch0007: 0007-configure-Allow-user-defined-C-compiler-flags.patch -Patch0008: 0008-configure-Remove-incorrect-assumption-about-cross-co.patch -Patch0009: 0009-configure-Only-use-OC_-for-building-executables.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 @@ -183,22 +199,28 @@ unset MAKEFLAGS make=make %endif +# Don't use %%configure macro because it sets --build, --host which +# breaks some incorrect assumptions made by OCaml's configure.ac +# +# See also: +# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/2O4HBOK6PTQZAFAVIRDVMZGG2PYB2QHM/ +# https://github.com/ocaml/ocaml/issues/8647 +# # We set --libdir to the unusual directory because we want OCaml to # install its libraries and other files into a subdirectory. # -# Force --host because of: -# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/2O4HBOK6PTQZAFAVIRDVMZGG2PYB2QHM/ -# (see also https://github.com/ocaml/ocaml/issues/8647) -# # OC_CFLAGS/OC_LDFLAGS control what flags OCaml passes to the linker # when doing final linking of OCaml binaries. Setting these is # necessary to ensure that generated binaries have Fedora hardening # features. -%configure \ +./configure \ + --prefix=%{_prefix} \ + --sysconfdir=%{_sysconfdir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir}/ocaml \ OC_CFLAGS="$CFLAGS" \ OC_LDFLAGS="$LDFLAGS" \ - --libdir=%{_libdir}/ocaml \ - --host=`./build-aux/config.guess` + %{nil} $make world %if %{native_compiler} $make opt @@ -378,6 +400,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* Mon Sep 5 2022 Richard W.M. Jones - 4.14.0-3 +- Include more upstream patches from 4.14 branch + * Fri Jul 22 2022 Fedora Release Engineering - 4.14.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild From c4c11c263c80bbe44ed7f12b933b78a0fbe75e86 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 19 Jan 2023 22:00:44 +0000 Subject: [PATCH 52/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 3f03c76..d7bca45 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -34,7 +34,7 @@ Name: ocaml Version: 4.14.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -400,6 +400,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* 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 From c5a44d336b8f199b6e714764b7e96af4ca49b028 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 23 Jan 2023 21:44:47 +0000 Subject: [PATCH 53/91] Rebuild OCaml packages for F38 --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index d7bca45..a720f83 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -34,7 +34,7 @@ Name: ocaml Version: 4.14.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: OCaml compiler and programming environment @@ -400,6 +400,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %changelog +* 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 From 68671b2fe60212917008546228091c2ce8c2e771 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 10 Jul 2023 21:41:36 +0100 Subject: [PATCH 54/91] OCaml 5.0 --- ...arning-when-calling-virtual-methods-.patch | 192 ---------- ...t-version-number-after-tagging-5.0.0.patch | 86 +++++ ...st-11236-from-Nymphium-missing-since.patch | 43 --- ...st-11814-from-gasche-clarify-DLS.new.patch | 66 ++++ 0003-Add-KC-Sivaramakrishnan-as-author.patch | 31 ++ ...preprocessor-conditional-on-_MSC_VER.patch | 26 -- 0004-Changes.patch | 28 -- ...unused-variables-in-yacc-reader.c-11.patch | 39 +++ ...more-instances-of-undefined-_MSC_VER.patch | 93 ----- ...st-11860-from-Octachron-index_for_st.patch | 68 ++++ ...g-in-folder-with-space-in-name-11590.patch | 42 +++ ...entation-for-string_of_float-.-11353.patch | 95 ----- ...nused-Makefile-variables-in-workflow.patch | 45 +++ ...st-11380-from-damiendoligez-fix-fort.patch | 30 -- ...variable-from-runtime-Makefile-merge.patch | 33 ++ ...tialization-of-bytecode-threading-11.patch | 101 ------ ...st-11397-from-Octachron-tast_mapper_.patch | 49 --- ...-Provide-a-default-for-OCAMLDEPFLAGS.patch | 24 ++ ...l-request-11396-from-gasche-fix11392.patch | 85 ----- 0010-Report-all-post-build-failures.patch | 41 +++ ...t-limitation-on-caml_callbackN-11409.patch | 53 --- ...emoval-of-FORCE_INSTRUMENTED_RUNTIME.patch | 24 ++ ...lib-on-created-installed-libraries-1.patch | 327 ------------------ ...s-alert-when-compiling-stdlib-docume.patch | 27 ++ ...st-12285-from-smorimoto-update-depre.patch | 70 ++++ ...ay-2-has-gfortran.sh-don-t-print-any.patch | 27 -- ...st-11417-from-lpw25-fix-virtual-clas.patch | 147 -------- ...st-12286-from-smorimoto-replace-set-.patch | 40 +++ ...-whole-module-type-error-message-114.patch | 154 --------- ...> 0015-Don-t-add-rpaths-to-libraries.patch | 10 +- ...est-11373-from-dra27-flexlink-detect.patch | 57 --- ...-Allow-user-defined-C-compiler-flags.patch | 14 +- ...est-11468-from-dra27-i686-mingw-ipv6.patch | 55 --- ...nly-use-OC_-for-building-executables.patch | 40 +++ 0018-Fix-skiplist-test-failure-12346.patch | 39 +++ ...llocation-of-alternate-signal-stack-.patch | 194 ----------- ...st-11487-from-purplearmadillo77-fma_.patch | 54 --- 0020-Fixup-Changes.patch | 36 -- ...utable-which-couldn-t-be-triggered.-.patch | 90 ----- ...nly-use-OC_-for-building-executables.patch | 31 -- ocaml.spec | 168 +++++---- sources | 2 +- 42 files changed, 833 insertions(+), 2043 deletions(-) delete mode 100644 0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch create mode 100644 0001-increment-version-number-after-tagging-5.0.0.patch delete mode 100644 0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch create mode 100644 0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch create mode 100644 0003-Add-KC-Sivaramakrishnan-as-author.patch delete mode 100644 0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch delete mode 100644 0004-Changes.patch create mode 100644 0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch delete mode 100644 0005-Guard-more-instances-of-undefined-_MSC_VER.patch create mode 100644 0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch create mode 100644 0006-Allow-installing-in-folder-with-space-in-name-11590.patch delete mode 100644 0006-Better-documentation-for-string_of_float-.-11353.patch create mode 100644 0007-Detect-unused-Makefile-variables-in-workflow.patch delete mode 100644 0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch create mode 100644 0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch delete mode 100644 0008-Refactor-the-initialization-of-bytecode-threading-11.patch delete mode 100644 0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch create mode 100644 0009-Provide-a-default-for-OCAMLDEPFLAGS.patch delete mode 100644 0010-Merge-pull-request-11396-from-gasche-fix11392.patch create mode 100644 0010-Report-all-post-build-failures.patch delete mode 100644 0011-Document-limitation-on-caml_callbackN-11409.patch create mode 100644 0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch delete mode 100644 0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch create mode 100644 0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch create mode 100644 0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch delete mode 100644 0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch delete mode 100644 0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch create mode 100644 0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch delete mode 100644 0015-Do-not-elide-the-whole-module-type-error-message-114.patch rename 0022-Don-t-add-rpaths-to-libraries.patch => 0015-Don-t-add-rpaths-to-libraries.patch (76%) delete mode 100644 0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch rename 0023-configure-Allow-user-defined-C-compiler-flags.patch => 0016-configure-Allow-user-defined-C-compiler-flags.patch (64%) delete mode 100644 0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch create mode 100644 0017-configure-Only-use-OC_-for-building-executables.patch create mode 100644 0018-Fix-skiplist-test-failure-12346.patch delete mode 100644 0018-More-prudent-deallocation-of-alternate-signal-stack-.patch delete mode 100644 0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch delete mode 100644 0020-Fixup-Changes.patch delete mode 100644 0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch delete mode 100644 0024-configure-Only-use-OC_-for-building-executables.patch diff --git a/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch b/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch deleted file mode 100644 index 166e69a..0000000 --- a/0001-Do-not-trigger-warning-when-calling-virtual-methods-.patch +++ /dev/null @@ -1,192 +0,0 @@ -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-increment-version-number-after-tagging-5.0.0.patch b/0001-increment-version-number-after-tagging-5.0.0.patch new file mode 100644 index 0000000..7583a57 --- /dev/null +++ b/0001-increment-version-number-after-tagging-5.0.0.patch @@ -0,0 +1,86 @@ +From 8741f4d88801e478e0ab7f871dc7dbcf9d7cc8f4 Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Thu, 15 Dec 2022 14:28:32 +0100 +Subject: [PATCH 01/18] increment version number after tagging 5.0.0 + +--- + VERSION | 2 +- + build-aux/ocaml_version.m4 | 6 +++--- + configure | Bin 617024 -> 617302 bytes + ocaml-variants.opam | 6 +++--- + 4 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/VERSION b/VERSION +index fc40ac52d7..314f8ec760 100644 +--- a/VERSION ++++ b/VERSION +@@ -1,4 +1,4 @@ +-5.0.0 ++5.0.1+dev0-2022-12-15 + + # Starting with OCaml 4.14, although the version string that appears above is + # still correct and this file can thus still be used to figure it out, +diff --git a/build-aux/ocaml_version.m4 b/build-aux/ocaml_version.m4 +index ba48c00277..78049eaab0 100644 +--- a/build-aux/ocaml_version.m4 ++++ b/build-aux/ocaml_version.m4 +@@ -25,7 +25,7 @@ + # The following macro, OCAML__DEVELOPMENT_VERSION, should be either + # [true] of [false]. + +-m4_define([OCAML__DEVELOPMENT_VERSION], [false]) ++m4_define([OCAML__DEVELOPMENT_VERSION], [true]) + + # The three following components (major, minor and patch level) MUST be + # integers. They MUST NOT be left-padded with zeros and all of them, +@@ -33,10 +33,10 @@ m4_define([OCAML__DEVELOPMENT_VERSION], [false]) + + m4_define([OCAML__VERSION_MAJOR], [5]) + m4_define([OCAML__VERSION_MINOR], [0]) +-m4_define([OCAML__VERSION_PATCHLEVEL], [0]) ++m4_define([OCAML__VERSION_PATCHLEVEL], [1]) + # Note that the OCAML__VERSION_EXTRA string defined below is always empty + # for officially-released versions of OCaml. +-m4_define([OCAML__VERSION_EXTRA], []) ++m4_define([OCAML__VERSION_EXTRA], [dev0-2022-12-15]) + + # The OCAML__VERSION_EXTRA_PREFIX macro defined below should be a + # single character: +diff --git a/configure b/configure +index 19764d19a9b8fb1a9f01868f8f7863733a4c4ecd..f54df41388272a49e583ca20f325508c5b814eff 100755 +GIT binary patch +delta 558 +zcmX?bMfKV>)eSNnf`-~DsbvPbMg~Skx`sexx>=UvgA=CkWIk^hOwrBS-boQyg!>lT +z^I#D^w|=RVFoum>>61UO%Wj^0>LnI?x7YGA-j2jHYkHy%qwMsubVfN$x$RTa8SPkv +zFfE!a6)I(ITT)b-%EjgH?C9$gALQ!e>KN=A?-~&jgcdML +zn(EW}a~M6D47nz63=t8qMU&s2pTqc^h0$<&pcn(`ObkI${VGs4{AT +zl=Ds(C}Lzq($6>DyNHn&(|gk&sxgYT=M^ymF%u9o12N0?ydu`PGG?IP+Aq9d1!A`C +q7hbSOxPU~a14U%Fd+Kt$%*A3FFo1ow*U#pd&5kL#U3xKx>Tv-4Xq`R) + +delta 271 +zcmcb1P4&PP)eSNnj0T%^IX*Zs8cf#nmH~32y^|t<)Vam>JU~ir!%`_`1FrPRAJ}C# +ze?IjRsBZgPUdG#zj0V#$>M+Vq|CY`u2NYAyV6m!Fq9{ZtO4CrI(b5D`Y(?UuQW&sl)xDHbt0O)n~9be#S` +zl~Hqge<33;n}VqU5P+mi`GP}&JpJ4iVw6nv4D<}z1B)4fmcP84Jkj +x_Tw*EftYRk@t5ooE?}YQKq1-f_IeyIbAdJiec-dbbq>dDcA(P@mvE>a2LKy+Taf?& + +diff --git a/ocaml-variants.opam b/ocaml-variants.opam +index 5928f357f2..a0876e02c9 100644 +--- a/ocaml-variants.opam ++++ b/ocaml-variants.opam +@@ -1,9 +1,9 @@ + opam-version: "2.0" +-version: "5.0.0" ++version: "5.0.1+trunk" + license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" +-synopsis: "Official release of OCaml 5.0.0" ++synopsis: "OCaml development version" + depends: [ +- "ocaml" {= "5.0.0" & post} ++ "ocaml" {= "5.0.1" & post} + "base-unix" {post} + "base-bigarray" {post} + "base-threads" {post} +-- +2.41.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 deleted file mode 100644 index 9c75989..0000000 --- a/0002-Merge-pull-request-11236-from-Nymphium-missing-since.patch +++ /dev/null @@ -1,43 +0,0 @@ -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-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch b/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch new file mode 100644 index 0000000..e25154a --- /dev/null +++ b/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch @@ -0,0 +1,66 @@ +From 925bf9a6d828d7548751f9a21892cad6209fc950 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Fri, 16 Dec 2022 09:41:13 +0100 +Subject: [PATCH 02/18] Merge pull request #11814 from + gasche/clarify-DLS.new_key-doc + +clarify the doc of Domain.DLS.new_key + +(cherry picked from commit be210179503c4a82b72dd4762560e13c408d37b7) +--- + stdlib/domain.mli | 37 ++++++++++++++++++++++++++++++------- + 1 file changed, 30 insertions(+), 7 deletions(-) + +diff --git a/stdlib/domain.mli b/stdlib/domain.mli +index 7763043aa5..2d79b3b0c3 100644 +--- a/stdlib/domain.mli ++++ b/stdlib/domain.mli +@@ -96,15 +96,38 @@ module DLS : sig + + val new_key : ?split_from_parent:('a -> 'a) -> (unit -> 'a) -> 'a key + (** [new_key f] returns a new key bound to initialiser [f] for accessing +- domain-local variables. ++, domain-local variables. + +- If [split_from_parent] is provided, spawning a domain will derive the +- child value (for this key) from the parent value. ++ If [split_from_parent] is not provided, the value for a new ++ domain will be computed on-demand by the new domain: the first ++ [get] call will call the initializer [f] and store that value. + +- Note that the [split_from_parent] call is computed in the parent +- domain, and is always computed regardless of whether the child domain +- will use it. If the splitting function is expensive or requires +- client-side computation, consider using ['a Lazy.t key]. ++ If [split_from_parent] is provided, spawning a domain will ++ derive the child value (for this key) from the parent ++ value. This computation happens in the parent domain and it ++ always happens, regardless of whether the child domain will ++ use it. ++ If the splitting function is expensive or requires ++ child-side computation, consider using ['a Lazy.t key]: ++ ++ {[ ++ let init () = ... ++ ++ let split_from_parent parent_value = ++ ... parent-side computation ...; ++ lazy ( ++ ... child-side computation ... ++ ) ++ ++ let key = Domain.DLS.new_key ~split_from_parent init ++ ++ let get () = Lazy.force (Domain.DLS.get key) ++ ]} ++ ++ In this case a part of the computation happens on the child ++ domain; in particular, it can access [parent_value] ++ concurrently with the parent domain, which may require ++ explicit synchronization to avoid data races. + *) + + val get : 'a key -> 'a +-- +2.41.0 + diff --git a/0003-Add-KC-Sivaramakrishnan-as-author.patch b/0003-Add-KC-Sivaramakrishnan-as-author.patch new file mode 100644 index 0000000..0a60404 --- /dev/null +++ b/0003-Add-KC-Sivaramakrishnan-as-author.patch @@ -0,0 +1,31 @@ +From 83ef99f67fda11b268098a271f56b990e295bbc2 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Tue, 20 Dec 2022 10:48:41 +0100 +Subject: [PATCH 03/18] Add KC Sivaramakrishnan as author + +For the two new chapters "Parallel programming" and "Memory model". + +Follow-up to #11280. + +(cherry picked from commit e6340ced8ca1d46f11eaea8e0474d1eb2142fe1c) +--- + manual/src/allfiles.etex | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/manual/src/allfiles.etex b/manual/src/allfiles.etex +index 6600943f54..3e07555b85 100644 +--- a/manual/src/allfiles.etex ++++ b/manual/src/allfiles.etex +@@ -12,7 +12,8 @@ + release \ocamlversion \\[1cm] + \Large Documentation and user's manual \\[1cm] + \large Xavier Leroy, \\ +- Damien Doligez, Alain Frisch, Jacques Garrigue, Didier Rémy and Jérôme Vouillon \\[1cm] ++ Damien Doligez, Alain Frisch, Jacques Garrigue, \\ ++ Didier Rémy, KC Sivaramakrishnan and Jérôme Vouillon \\[1cm] + \today \\ + ~ + \vfill +-- +2.41.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 deleted file mode 100644 index 3854e05..0000000 --- a/0003-misc.h-fix-preprocessor-conditional-on-_MSC_VER.patch +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 214e89e..0000000 --- a/0004-Changes.patch +++ /dev/null @@ -1,28 +0,0 @@ -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/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch b/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch new file mode 100644 index 0000000..d49f709 --- /dev/null +++ b/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch @@ -0,0 +1,39 @@ +From ea8b79eda165722d04b369f1811a5aa80ab5acc6 Mon Sep 17 00:00:00 2001 +From: SSHz +Date: Sun, 27 Nov 2022 14:46:16 +0000 +Subject: [PATCH 04/18] removed set but unused variables in yacc/reader.c + (#11758) + +(cherry picked from commit 0114f62d3ed056254ac25192f724e92a2ff6c448) +--- + yacc/reader.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/yacc/reader.c b/yacc/reader.c +index 7377967994..7a0b888961 100644 +--- a/yacc/reader.c ++++ b/yacc/reader.c +@@ -1049,12 +1049,10 @@ void read_declarations(void) + void output_token_type(void) + { + bucket * bp; +- int n; + + fprintf(interface_file, "type token =\n"); + if (!rflag) ++outline; + fprintf(output_file, "type token =\n"); +- n = 0; + for (bp = first_symbol; bp; bp = bp->next) { + if (bp->class == TERM && bp->true_token) { + fprintf(interface_file, " | %s", bp->name); +@@ -1068,7 +1066,6 @@ void output_token_type(void) + fprintf(interface_file, "\n"); + if (!rflag) ++outline; + fprintf(output_file, "\n"); +- n++; + } + } + fprintf(interface_file, "\n"); +-- +2.41.0 + diff --git a/0005-Guard-more-instances-of-undefined-_MSC_VER.patch b/0005-Guard-more-instances-of-undefined-_MSC_VER.patch deleted file mode 100644 index d9f81d7..0000000 --- a/0005-Guard-more-instances-of-undefined-_MSC_VER.patch +++ /dev/null @@ -1,93 +0,0 @@ -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/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch b/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch new file mode 100644 index 0000000..c3e9555 --- /dev/null +++ b/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch @@ -0,0 +1,68 @@ +From 848e28fc6f3f3c9802b23c00f2d77f568c761667 Mon Sep 17 00:00:00 2001 +From: Gabriel Scherer +Date: Tue, 3 Jan 2023 17:41:12 +0100 +Subject: [PATCH 05/18] Merge pull request #11860 from + Octachron/index_for_stdlib + +documentation: sort modules alphabetically + +fixes #11857 + +(cherry picked from commit 14004c6d4bedadb7215ded2c77230270e52307ff) +--- + api_docgen/Makefile.docfiles | 24 +++++++++++++++--------- + 1 file changed, 15 insertions(+), 9 deletions(-) + +diff --git a/api_docgen/Makefile.docfiles b/api_docgen/Makefile.docfiles +index 0c2412b192..f12830b1ec 100644 +--- a/api_docgen/Makefile.docfiles ++++ b/api_docgen/Makefile.docfiles +@@ -26,10 +26,6 @@ define capitalize + $(foreach m,$(1),$(call capitalize_one,$m)) + endef + +-define sort +-$(shell $(OCAMLDEP) -sort $(1)) +-endef +- + runtime_events_MLIS := runtime_events.mli + str_MLIS := str.mli + unix_MLIS := unix.mli unixLabels.mli +@@ -62,10 +58,8 @@ endif + libref_TEXT=Ocaml_operators Format_tutorial + libref_C=$(call capitalize,$(libref)) + +-PARSING_MLIS := $(call sort, \ +- $(notdir $(wildcard $(ROOTDIR)/parsing/*.mli))\ +-) +-UTILS_MLIS := $(call sort,$(notdir $(wildcard $(ROOTDIR)/utils/*.mli))) ++PARSING_MLIS := $(notdir $(wildcard $(ROOTDIR)/parsing/*.mli)) ++UTILS_MLIS := $(notdir $(wildcard $(ROOTDIR)/utils/*.mli)) + DRIVER_MLIS := pparse.mli + + compilerlibref_MLIS= \ +@@ -76,8 +70,20 @@ compilerlibref=$(compilerlibref_MLIS:%.mli=%) + compilerlibref_TEXT=Compiler_libs + compilerlibref_C=$(call capitalize,$(compilerlibref)) + +-ALL_LIBREF= $(libref_TEXT:%=libref/%) $(libref:%=libref/%) ++ALL_LIBREF= \ ++ $(sort $(libref_TEXT:%=libref/%)) \ ++ $(sort $(filter-out libref/camlinternal%, $(libref:%=libref/%))) \ ++ $(sort $(filter libref/camlinternal%, $(libref:%=libref/%))) ++ + ALL_COMPILERLIBREF= \ + $(compilerlibref_TEXT:%=compilerlibref/%) \ + $(compilerlibref:%=compilerlibref/%) ++# Note that the output of $(wildcard ...) is sorted alphabetically. ++# The compilerlibs index will be thus be sorted first by category: ++# - text documentation ++# - parsing modules ++# - utils modules ++# - driver modules ++# And then alphabetically inside each category. ++ + ALL_DOC= $(ALL_LIBREF) $(ALL_COMPILERLIBREF) +-- +2.41.0 + diff --git a/0006-Allow-installing-in-folder-with-space-in-name-11590.patch b/0006-Allow-installing-in-folder-with-space-in-name-11590.patch new file mode 100644 index 0000000..2831ec8 --- /dev/null +++ b/0006-Allow-installing-in-folder-with-space-in-name-11590.patch @@ -0,0 +1,42 @@ +From a3cd42bc03ed0fc706bb7364fdb14b29b1925600 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Wed, 4 Jan 2023 16:33:28 +0000 +Subject: [PATCH 06/18] Allow installing in folder with space in name (#11590) + +- fix(build): Repair make install (in man/Makefile) +--- + Changes | 8 ++++++++ + man/Makefile | 4 ++-- + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/Changes b/Changes +index 776f6e7a45..438c0f3ec2 100644 +--- a/Changes ++++ b/Changes +@@ -1,3 +1,11 @@ ++OCaml 5.0 maintenance version ++----------------------------- ++ ++### Build system: ++ ++- #11590: Allow installing to a destination path containing spaces. ++ (Élie Brami, review by Sébastien Hinderer and David Allsopp) ++ + OCaml 5.0 (16 December 2022) + ---------------------------- + +diff --git a/man/Makefile b/man/Makefile +index 36d3126563..10cc8bbe41 100644 +--- a/man/Makefile ++++ b/man/Makefile +@@ -22,5 +22,5 @@ MANPAGES = $(addsuffix .1,\ + + .PHONY: install + install: +- $(MKDIR) $(INSTALL_PROGRAMS_MAN_DIR) +- $(INSTALL_DATA) $(MANPAGES) $(INSTALL_PROGRAMS_MAN_DIR) ++ $(MKDIR) '$(INSTALL_PROGRAMS_MAN_DIR)' ++ $(INSTALL_DATA) $(MANPAGES) '$(INSTALL_PROGRAMS_MAN_DIR)' +-- +2.41.0 + diff --git a/0006-Better-documentation-for-string_of_float-.-11353.patch b/0006-Better-documentation-for-string_of_float-.-11353.patch deleted file mode 100644 index 935a992..0000000 --- a/0006-Better-documentation-for-string_of_float-.-11353.patch +++ /dev/null @@ -1,95 +0,0 @@ -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-Detect-unused-Makefile-variables-in-workflow.patch b/0007-Detect-unused-Makefile-variables-in-workflow.patch new file mode 100644 index 0000000..e13b225 --- /dev/null +++ b/0007-Detect-unused-Makefile-variables-in-workflow.patch @@ -0,0 +1,45 @@ +From 44f4015f9a649e164b332e6ab1302139191d4a4f Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Wed, 3 Mar 2021 12:24:36 +0000 +Subject: [PATCH 07/18] Detect unused Makefile variables in workflow + +--- + tools/ci/actions/runner.sh | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh +index ede27f710a..26123b40d1 100755 +--- a/tools/ci/actions/runner.sh ++++ b/tools/ci/actions/runner.sh +@@ -21,6 +21,8 @@ PREFIX=~/local + MAKE="make $MAKE_ARG" + SHELL=dash + ++MAKE_WARN="$MAKE --warn-undefined-variables" ++ + export PATH=$PREFIX/bin:$PATH + + Configure () { +@@ -60,9 +62,18 @@ EOF + } + + Build () { +- $MAKE world.opt ++ if [ "$(uname)" = 'Darwin' ]; then ++ script -q build.log $MAKE_WARN ++ else ++ script --return --command "$MAKE_WARN" build.log ++ fi + echo Ensuring that all names are prefixed in the runtime + ./tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a ++ if grep -Fq ' warning: undefined variable ' build.log; then ++ echo Undefined Makefile variables detected ++ exit 1 ++ fi ++ rm build.log + } + + Test () { +-- +2.41.0 + diff --git a/0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch b/0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch deleted file mode 100644 index b57c6ba..0000000 --- a/0007-Merge-pull-request-11380-from-damiendoligez-fix-fort.patch +++ /dev/null @@ -1,30 +0,0 @@ -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-Fix-incorrect-variable-from-runtime-Makefile-merge.patch b/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch new file mode 100644 index 0000000..f57e2bd --- /dev/null +++ b/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch @@ -0,0 +1,33 @@ +From 2eccdd3cd78624b0f2664d6152afbcae167f6f8b Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Mon, 20 Feb 2023 20:27:58 +0000 +Subject: [PATCH 08/18] Fix incorrect variable from runtime/Makefile merge + +Wrong CPPFLAGS used when assembling with ASPP. +--- + Makefile | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/Makefile b/Makefile +index bb2c245eab..3ea3296c7f 100644 +--- a/Makefile ++++ b/Makefile +@@ -952,6 +952,15 @@ ASPP_ERROR = \ + runtime/%.o: runtime/%.S + $(ASPP) $(OC_ASPPFLAGS) -o $@ $< || $(ASPP_ERROR) + ++# $(OC_DEBUG_CPPFLAGS) and $(OC_INSTR_CPPFLAGS) are still used in the two ++# recipes just below instead of the correct $(ocamlrund_CPPFLAGS) and ++# $(ocamlruni_CPPFLAGS). This has been fixed on trunk, but in the ++# 5.0 maintenance branch here we just define default values for those OC_* ++# variables to avoid an undefined-variable warning, preserving exactly the ++# (somewhat strange) behaviour of the 5.0.0 release. ++OC_DEBUG_CPPFLAGS ?= ++OC_INSTR_CPPFLAGS ?= ++ + runtime/%.d.o: runtime/%.S + $(ASPP) $(OC_ASPPFLAGS) $(OC_DEBUG_CPPFLAGS) -o $@ $< || $(ASPP_ERROR) + +-- +2.41.0 + diff --git a/0008-Refactor-the-initialization-of-bytecode-threading-11.patch b/0008-Refactor-the-initialization-of-bytecode-threading-11.patch deleted file mode 100644 index d6b3510..0000000 --- a/0008-Refactor-the-initialization-of-bytecode-threading-11.patch +++ /dev/null @@ -1,101 +0,0 @@ -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 deleted file mode 100644 index 7f1ef7e..0000000 --- a/0009-Merge-pull-request-11397-from-Octachron-tast_mapper_.patch +++ /dev/null @@ -1,49 +0,0 @@ -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/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch b/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch new file mode 100644 index 0000000..0c10ff5 --- /dev/null +++ b/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch @@ -0,0 +1,24 @@ +From 5f3f8bf734bdc02adc69cf92f066547bd71e8a25 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Mon, 20 Feb 2023 20:31:31 +0000 +Subject: [PATCH 09/18] Provide a default for $(OCAMLDEPFLAGS) + +--- + Makefile.common | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makefile.common b/Makefile.common +index 536e2a28ca..e2a9176a5c 100644 +--- a/Makefile.common ++++ b/Makefile.common +@@ -169,6 +169,7 @@ endef # PROGRAM_SYNONYM + # should take place *before* Makefile.common is included. + + OCAMLDEP ?= $(BEST_OCAMLDEP) ++OCAMLDEPFLAGS ?= + OC_OCAMLDEPFLAGS = -slash + OC_OCAMLDEPDIRS = + OCAMLDEP_CMD = $(OCAMLDEP) $(OC_OCAMLDEPFLAGS) \ +-- +2.41.0 + diff --git a/0010-Merge-pull-request-11396-from-gasche-fix11392.patch b/0010-Merge-pull-request-11396-from-gasche-fix11392.patch deleted file mode 100644 index 0b9cbd6..0000000 --- a/0010-Merge-pull-request-11396-from-gasche-fix11392.patch +++ /dev/null @@ -1,85 +0,0 @@ -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/0010-Report-all-post-build-failures.patch b/0010-Report-all-post-build-failures.patch new file mode 100644 index 0000000..bf8f6e2 --- /dev/null +++ b/0010-Report-all-post-build-failures.patch @@ -0,0 +1,41 @@ +From 7f4569e22c2a19d51324c44a2954b10427df2cd8 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Tue, 21 Feb 2023 14:44:21 +0000 +Subject: [PATCH 10/18] Report all post-build failures + +Rather than just reporting un-prefixed symbol names, also report +undefined variables. +--- + tools/ci/actions/runner.sh | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh +index 26123b40d1..6e5a30f73a 100755 +--- a/tools/ci/actions/runner.sh ++++ b/tools/ci/actions/runner.sh +@@ -67,13 +67,19 @@ Build () { + else + script --return --command "$MAKE_WARN" build.log + fi +- echo Ensuring that all names are prefixed in the runtime +- ./tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a ++ failed=0 + if grep -Fq ' warning: undefined variable ' build.log; then + echo Undefined Makefile variables detected +- exit 1 ++ failed=1 + fi + rm build.log ++ echo Ensuring that all names are prefixed in the runtime ++ if ! ./tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a ; then ++ failed=1 ++ fi ++ if ((failed)); then ++ exit 1 ++ fi + } + + Test () { +-- +2.41.0 + diff --git a/0011-Document-limitation-on-caml_callbackN-11409.patch b/0011-Document-limitation-on-caml_callbackN-11409.patch deleted file mode 100644 index bf09575..0000000 --- a/0011-Document-limitation-on-caml_callbackN-11409.patch +++ /dev/null @@ -1,53 +0,0 @@ -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/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch b/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch new file mode 100644 index 0000000..5ffca5f --- /dev/null +++ b/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch @@ -0,0 +1,24 @@ +From 0f6dc503bf3814e5547ffb4e9d6ea0a75ffd1ec0 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Wed, 22 Feb 2023 10:47:00 +0000 +Subject: [PATCH 11/18] Finish off removal of FORCE_INSTRUMENTED_RUNTIME + +--- + utils/Makefile | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/utils/Makefile b/utils/Makefile +index 0fcbc59ce5..efd8574fa5 100644 +--- a/utils/Makefile ++++ b/utils/Makefile +@@ -90,7 +90,6 @@ config_main.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile config.common.ml + $(call SUBST,FUNCTION_SECTIONS) \ + $(call SUBST,CC_HAS_DEBUG_PREFIX_MAP) \ + $(call SUBST,AS_HAS_DEBUG_PREFIX_MAP) \ +- $(call SUBST,FORCE_INSTRUMENTED_RUNTIME) \ + $< > $@ + cat config.common.ml >> $@ + +-- +2.41.0 + diff --git a/0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch b/0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch deleted file mode 100644 index 739914c..0000000 --- a/0012-Stop-calling-ranlib-on-created-installed-libraries-1.patch +++ /dev/null @@ -1,327 +0,0 @@ -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/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch b/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch new file mode 100644 index 0000000..5d87237 --- /dev/null +++ b/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch @@ -0,0 +1,27 @@ +From ffb2022797986324213891a59c02af46269b5c17 Mon Sep 17 00:00:00 2001 +From: Damien Doligez +Date: Mon, 17 Apr 2023 11:36:32 +0200 +Subject: [PATCH 12/18] suppress spurious alert when compiling stdlib + documentation + +(cherry picked from commit 5c0fb8e23865fdbf151bdbe15d91176903c284d3) +--- + api_docgen/ocamldoc/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/api_docgen/ocamldoc/Makefile b/api_docgen/ocamldoc/Makefile +index 1b3d5f57f7..b6419ae50d 100644 +--- a/api_docgen/ocamldoc/Makefile ++++ b/api_docgen/ocamldoc/Makefile +@@ -44,7 +44,7 @@ $(libref:%=build/libref/%.odoc): build/libref/%.odoc: %.mli | build/libref + $(OCAMLDOC_RUN) -nostdlib -hide Stdlib -lib Stdlib \ + -pp \ + "$(AWK) -v ocamldoc=true -f ../../stdlib/expand_module_aliases.awk" \ +- $(DOC_STDLIB_INCLUDES) -hide-warnings $< -dump $@ ++ $(DOC_STDLIB_INCLUDES) -hide-warnings -alert -all $< -dump $@ + + $(compilerlibref:%=build/compilerlibref/%.odoc):\ + build/compilerlibref/%.odoc: %.mli | build/compilerlibref +-- +2.41.0 + diff --git a/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch b/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch new file mode 100644 index 0000000..ed6f114 --- /dev/null +++ b/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch @@ -0,0 +1,70 @@ +From 4cc4eb8b0d71c64c5252d6764f4c4b0aa6020995 Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Sat, 3 Jun 2023 18:02:24 +0100 +Subject: [PATCH 13/18] Merge pull request #12285 from + smorimoto/update-deprecated-actions + +Update deprecated GitHub Actions + +(cherry picked from commit eadb05a504e0738f246a7dc846a442793005a27a) +--- + .github/workflows/build.yml | 8 ++++---- + .github/workflows/hygiene.yml | 2 +- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml +index ae0fcace20..933c14a926 100644 +--- a/.github/workflows/build.yml ++++ b/.github/workflows/build.yml +@@ -18,7 +18,7 @@ jobs: + manual_changed: ${{ steps.manual.outputs.manual_changed }} + steps: + - name: Checkout +- uses: actions/checkout@v2 ++ uses: actions/checkout@v3 + - name: Check for manual changes + id: manual + run: >- +@@ -45,7 +45,7 @@ jobs: + git config --local --unset http.https://github.com/.extraheader + tar --zstd -cf /tmp/sources.tar.zstd . + - name: Upload Artifact +- uses: actions/upload-artifact@v2 ++ uses: actions/upload-artifact@v3 + with: + name: compiler + path: /tmp/sources.tar.zstd +@@ -57,7 +57,7 @@ jobs: + runs-on: ubuntu-latest + steps: + - name: Download Artifact +- uses: actions/download-artifact@v2 ++ uses: actions/download-artifact@v3 + with: + name: compiler + - name: Unpack Artifact +@@ -137,7 +137,7 @@ jobs: + - debug-s4096 + steps: + - name: Download artifact +- uses: actions/download-artifact@v2 ++ uses: actions/download-artifact@v3 + with: + name: compiler + - name: Unpack Artifact +diff --git a/.github/workflows/hygiene.yml b/.github/workflows/hygiene.yml +index e89efd2f47..3b2e10795f 100644 +--- a/.github/workflows/hygiene.yml ++++ b/.github/workflows/hygiene.yml +@@ -17,7 +17,7 @@ jobs: + # context variable. + if: failure() + +- - uses: actions/checkout@v2 ++ - uses: actions/checkout@v3 + with: + fetch-depth: 50 + +-- +2.41.0 + 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 deleted file mode 100644 index 7d5b111..0000000 --- a/0013-tests-lib-bigarray-2-has-gfortran.sh-don-t-print-any.patch +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 5a53fad..0000000 --- a/0014-Merge-pull-request-11417-from-lpw25-fix-virtual-clas.patch +++ /dev/null @@ -1,147 +0,0 @@ -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/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch b/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch new file mode 100644 index 0000000..cf8c766 --- /dev/null +++ b/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch @@ -0,0 +1,40 @@ +From af3a67cd06e07825c63b70a038cf90481039b1ed Mon Sep 17 00:00:00 2001 +From: David Allsopp +Date: Fri, 9 Jun 2023 21:47:51 +0100 +Subject: [PATCH 14/18] Merge pull request #12286 from + smorimoto/replace-set-output + +Replace the set-output command with the GITHUB_OUTPUT environment file + +(cherry picked from commit 50054a632a5ac3bb4199276617d358e3fa4a108b) +--- + tools/ci/actions/check-manual-modified.sh | 2 +- + tools/ci/actions/runner.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tools/ci/actions/check-manual-modified.sh b/tools/ci/actions/check-manual-modified.sh +index dc8b6bd809..c5826c1fd0 100755 +--- a/tools/ci/actions/check-manual-modified.sh ++++ b/tools/ci/actions/check-manual-modified.sh +@@ -32,4 +32,4 @@ else + fi + + echo "Manual altered: $result" +-echo "::set-output name=manual_changed::$result" ++echo "manual_changed=$result" >>"$GITHUB_OUTPUT" +diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh +index 6e5a30f73a..295e58a83e 100755 +--- a/tools/ci/actions/runner.sh ++++ b/tools/ci/actions/runner.sh +@@ -159,7 +159,7 @@ ReportBuildStatus () { + else + STATUS='success' + fi +- echo "::set-output name=build-status::$STATUS" ++ echo "build-status=$STATUS" >>"$GITHUB_OUTPUT" + exit $CODE + } + +-- +2.41.0 + 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 deleted file mode 100644 index 2922112..0000000 --- a/0015-Do-not-elide-the-whole-module-type-error-message-114.patch +++ /dev/null @@ -1,154 +0,0 @@ -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/0022-Don-t-add-rpaths-to-libraries.patch b/0015-Don-t-add-rpaths-to-libraries.patch similarity index 76% rename from 0022-Don-t-add-rpaths-to-libraries.patch rename to 0015-Don-t-add-rpaths-to-libraries.patch index 52b102b..9d3092b 100644 --- a/0022-Don-t-add-rpaths-to-libraries.patch +++ b/0015-Don-t-add-rpaths-to-libraries.patch @@ -1,17 +1,17 @@ -From e5312a9c481f91f2ca2cae1dc4176a78baaebf40 Mon Sep 17 00:00:00 2001 +From 0e07dfdb530734ef4db351ecc24c6363e36916ec 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. +Subject: [PATCH 15/18] 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 +index 7e1848f433..811d9134dd 100644 --- a/utils/config.mlp +++ b/utils/config.mlp -@@ -54,8 +54,8 @@ let native_c_compiler = +@@ -42,8 +42,8 @@ let native_c_compiler = c_compiler ^ " " ^ ocamlopt_cflags ^ " " ^ ocamlopt_cppflags let native_c_libraries = "%%NATIVECCLIBS%%" let native_pack_linker = "%%PACKLD%%" @@ -23,5 +23,5 @@ index f758a9b483..ee17a737dc 100644 let supports_shared_libraries = %%SUPPORTS_SHARED_LIBRARIES%% let mkdll, mkexe, mkmaindll = -- -2.37.0.rc2 +2.41.0 diff --git a/0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch b/0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch deleted file mode 100644 index 059fc99..0000000 --- a/0016-Merge-pull-request-11373-from-dra27-flexlink-detect.patch +++ /dev/null @@ -1,57 +0,0 @@ -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/0023-configure-Allow-user-defined-C-compiler-flags.patch b/0016-configure-Allow-user-defined-C-compiler-flags.patch similarity index 64% rename from 0023-configure-Allow-user-defined-C-compiler-flags.patch rename to 0016-configure-Allow-user-defined-C-compiler-flags.patch index fc715f8..f618d37 100644 --- a/0023-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0016-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From 2501cd8b3c40188e5eb6dd2158d61cfa023236c2 Mon Sep 17 00:00:00 2001 +From 9d3722c87ab15dfbc4e1a934e09ddc8253712d9c 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. +Subject: [PATCH 16/18] 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 +index a7974b0426..8068de3cfc 100644 --- a/configure.ac +++ b/configure.ac -@@ -680,6 +680,10 @@ AS_CASE([$host], +@@ -670,6 +670,10 @@ AS_CASE([$host], internal_cflags="$cc_warnings"], [common_cflags="-O"])]) @@ -19,9 +19,9 @@ index ebb8bbdb80..9e6c0b9745 100644 +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. + AS_CASE([$host], + [i686-*-mingw32], -- -2.37.0.rc2 +2.41.0 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 deleted file mode 100644 index 433fda9..0000000 --- a/0017-Merge-pull-request-11468-from-dra27-i686-mingw-ipv6.patch +++ /dev/null @@ -1,55 +0,0 @@ -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: Wed, 26 Jan 2022 15:47:02 +0000 +Subject: [PATCH 17/18] 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 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 8068de3cfc..19b23f9400 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -36,7 +36,7 @@ CONFIGURE_ARGS="$*" + # rely on $CFLAGS because these cannot be processed by flexlink (and are not + # passed) + mkexe_cmd='$(CC)' +-mkexe_cflags='$(OC_CFLAGS) $(CFLAGS)' ++mkexe_cflags='$(OC_CFLAGS)' + mkexe_extra_flags='' + mkexe_via_cc_extra_cmd='' + mkexe_ldflags_prefix='' +@@ -2208,7 +2208,7 @@ ${mkdll_ldflags}" + ],[ + mkdll_ldflags='$(OC_DLL_LDFLAGS) $(LDFLAGS)' + mkdll_ldflags_exp="${oc_dll_ldflags} ${LDFLAGS}" +- mkexe="${mkexe} \$(OC_LDFLAGS) \$(LDFLAGS)" ++ mkexe="${mkexe} \$(OC_LDFLAGS)" + mkexe_exp="${mkexe_exp} ${oc_ldflags} ${LDFLAGS}" + ]) + mkdll="$mkdll $mkdll_ldflags" +-- +2.41.0 + diff --git a/0018-Fix-skiplist-test-failure-12346.patch b/0018-Fix-skiplist-test-failure-12346.patch new file mode 100644 index 0000000..1668adc --- /dev/null +++ b/0018-Fix-skiplist-test-failure-12346.patch @@ -0,0 +1,39 @@ +From 69fdedd5c7747370879abbdc2beb5d7a1bd72194 Mon Sep 17 00:00:00 2001 +From: Jerry James +Date: Fri, 7 Jul 2023 07:07:09 -0600 +Subject: [PATCH 18/18] Fix skiplist test failure (#12346) + +Fix -Wmaybe-uninitialized warning in skiplist test +Fix -Wunused-variable warning in skiplist test + +Co-authored-by: Xavier Leroy +(cherry picked from commit 3027e3308d685af03caf4f605b4bec55b04ed28e) +(cherry picked from commit 9aa7761060a7c40d11237599382b892dbcb79cb5) +--- + testsuite/tests/lf_skiplist/stubs.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/testsuite/tests/lf_skiplist/stubs.c b/testsuite/tests/lf_skiplist/stubs.c +index 991483e408..acc0eaf9cf 100644 +--- a/testsuite/tests/lf_skiplist/stubs.c ++++ b/testsuite/tests/lf_skiplist/stubs.c +@@ -64,7 +64,7 @@ static int get_len(struct lf_skipcell *p, struct lf_skipcell *end) { + static uintnat count_marks(struct lf_skiplist *sk) { + uintnat r = 0; + struct lf_skipcell *p = sk->head; +- uintptr_t succ; ++ uintptr_t succ = 0; + + while (p) { + for (int k = p->top_level; k >= 0; k--) { +@@ -135,7 +135,6 @@ inline static uintnat calc_right(uintnat id,uintnat turn,uintnat ndoms) { return + CAMLprim value insert_skiplist(value turn_val,value ndoms_val,value domain_id_val) { + CAMLparam3(turn_val,ndoms_val,domain_id_val); + uintnat domain_id = Long_val(domain_id_val); +- uintnat ndoms = Long_val(ndoms_val); + uintnat turn = Long_val(turn_val); + uintnat k = calc_key(domain_id,turn) ; + uintnat v = calc_value(domain_id) ; +-- +2.41.0 + diff --git a/0018-More-prudent-deallocation-of-alternate-signal-stack-.patch b/0018-More-prudent-deallocation-of-alternate-signal-stack-.patch deleted file mode 100644 index 20b430f..0000000 --- a/0018-More-prudent-deallocation-of-alternate-signal-stack-.patch +++ /dev/null @@ -1,194 +0,0 @@ -From 1c4df0352d5f75464acdb27377ccd10d1e0ba10a Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -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 deleted file mode 100644 index 67376f4..0000000 --- a/0019-Merge-pull-request-11487-from-purplearmadillo77-fma_.patch +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index 1301d95..0000000 --- a/0020-Fixup-Changes.patch +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index 913074d..0000000 --- a/0021-Fix-deprecated_mutable-which-couldn-t-be-triggered.-.patch +++ /dev/null @@ -1,90 +0,0 @@ -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/0024-configure-Only-use-OC_-for-building-executables.patch b/0024-configure-Only-use-OC_-for-building-executables.patch deleted file mode 100644 index 1dbe2f2..0000000 --- a/0024-configure-Only-use-OC_-for-building-executables.patch +++ /dev/null @@ -1,31 +0,0 @@ -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/ocaml.spec b/ocaml.spec index a720f83..544a857 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -18,6 +18,9 @@ %global natdynlink 0 %endif +# 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 aarch64 %{power64} riscv64 x86_64 @@ -33,12 +36,12 @@ %global rcver %{nil} Name: ocaml -Version: 4.14.0 -Release: 5%{?dist} +Version: 5.0.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment -License: QPL and (LGPLv2+ with exceptions) +License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception URL: https://www.ocaml.org @@ -53,52 +56,50 @@ Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{vers # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-38-4.14.0 +# Current branch: fedora-39-5.0.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 +# Patches added after 5.0.0 was released. +Patch: 0001-increment-version-number-after-tagging-5.0.0.patch +Patch: 0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch +Patch: 0003-Add-KC-Sivaramakrishnan-as-author.patch +Patch: 0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch +Patch: 0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch +Patch: 0006-Allow-installing-in-folder-with-space-in-name-11590.patch +Patch: 0007-Detect-unused-Makefile-variables-in-workflow.patch +Patch: 0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch +Patch: 0009-Provide-a-default-for-OCAMLDEPFLAGS.patch +Patch: 0010-Report-all-post-build-failures.patch +Patch: 0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch +Patch: 0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch +Patch: 0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch +Patch: 0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch # Fedora-specific patches -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 +Patch: 0015-Don-t-add-rpaths-to-libraries.patch +Patch: 0016-configure-Allow-user-defined-C-compiler-flags.patch +Patch: 0017-configure-Only-use-OC_-for-building-executables.patch + +# Fix skiplist test failure +# https://github.com/ocaml/ocaml/pull/12346 +Patch: 0018-Fix-skiplist-test-failure-12346.patch BuildRequires: make BuildRequires: git BuildRequires: gcc BuildRequires: autoconf -BuildRequires: binutils-devel -BuildRequires: ncurses-devel -BuildRequires: gdbm-devel BuildRequires: gawk BuildRequires: perl-interpreter BuildRequires: util-linux BuildRequires: /usr/bin/annocheck +# Documentation requirements +BuildRequires: asciidoc +BuildRequires: python3-pygments + # ocamlopt runs gcc to link binaries. Because Fedora includes # hardening flags automatically, redhat-rpm-config is also required. Requires: gcc @@ -150,6 +151,9 @@ 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} @@ -160,6 +164,7 @@ Documentation generator for OCaml. %package docs Summary: Documentation for OCaml +BuildArch: noarch Requires: ocaml = %{version}-%{release} @@ -199,6 +204,9 @@ unset MAKEFLAGS make=make %endif +# Set ocamlmklib default flags to include Fedora linker flags +sed -i '/ld_opts/s|\[\]|["%{build_ldflags}"]|' tools/ocamlmklib.ml + # Don't use %%configure macro because it sets --build, --host which # breaks some incorrect assumptions made by OCaml's configure.ac # @@ -218,8 +226,15 @@ make=make --sysconfdir=%{_sysconfdir} \ --mandir=%{_mandir} \ --libdir=%{_libdir}/ocaml \ - OC_CFLAGS="$CFLAGS" \ - OC_LDFLAGS="$LDFLAGS" \ + --enable-flambda \ +%if %{native_compiler} + --enable-native-toplevel \ +%endif +%if 0%{?_include_frame_pointers} + --enable-frame-pointers \ +%endif + OC_CFLAGS='%{build_cflags}' \ + OC_LDFLAGS='%{build_ldflags}' \ %{nil} $make world %if %{native_compiler} @@ -227,6 +242,13 @@ $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} @@ -260,10 +282,6 @@ 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 -# 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 %license LICENSE @@ -271,8 +289,6 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlcmt %{_bindir}/ocamldebug -#{_bindir}/ocaml-instr-graph -#{_bindir}/ocaml-instr-report %{_bindir}/ocamlyacc # symlink to either .byte or .opt version @@ -316,17 +332,17 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_bindir}/ocamlopt.opt %endif -#%%{_libdir}/ocaml/addlabels -#%%{_libdir}/ocaml/scrapelabels +%if %{native_compiler} +%{_bindir}/ocamlnat +%endif + %{_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 @@ -334,34 +350,64 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %{_libdir}/ocaml/libasmrun_shared.so %endif %{_libdir}/ocaml/*.mli +%{_libdir}/ocaml/sys.ml.in %{_libdir}/ocaml/libcamlrun_shared.so -#%%{_libdir}/ocaml/objinfo_helper -%{_libdir}/ocaml/threads/*.mli + +%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.a +%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.mli %if %{native_compiler} -%{_libdir}/ocaml/threads/*.a -%{_libdir}/ocaml/threads/*.cmxa -%{_libdir}/ocaml/threads/*.cmx +%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.cmxa +%{_libdir}/ocaml/{dynlink,profiling,runtime_events,str,threads,unix}/*.cmx +%{_libdir}/ocaml/profiling/*.o %endif +%if %{natdynlink} +%{_libdir}/ocaml/{runtime_events,str,unix}/*.cmxs +%endif + +# headers %{_libdir}/ocaml/caml %files runtime -%doc README.adoc Changes +%doc README.html Changes %license LICENSE %{_bindir}/ocamlrun %{_bindir}/ocamlrund %{_bindir}/ocamlruni %dir %{_libdir}/ocaml -#%%{_libdir}/ocaml/VERSION %{_libdir}/ocaml/*.cmo %{_libdir}/ocaml/*.cmi %{_libdir}/ocaml/*.cma %{_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/ocamlmktop +%{_libdir}/ocaml/ocamlmktop/*.cmo +%{_libdir}/ocaml/ocamlmktop/*.cmi +%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/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 @@ -386,20 +432,16 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata %files compiler-libs %license LICENSE -%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 +%{_libdir}/ocaml/compiler-libs %changelog +* Wed Jun 14 2023 Jerry James - 5.0.0-1 +- 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 + * Mon Jan 23 2023 Richard W.M. Jones - 4.14.0-5 - Rebuild OCaml packages for F38 diff --git a/sources b/sources index 6de827b..3a87a72 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-4.14.0.tar.gz) = 3c5e5b9f00bb109dd99b5f7b0078cf8663d4247e548f3e601d6b2a55582e04bb20f6de85005c4cf2f78ae9aaa449f5ca6f2bab2f6ce83eeb3aeb386e3f2fcc32 +SHA512 (ocaml-5.0.0.tar.gz) = c0cd445bdc2de5d45aae9aea78aab116807cc6782efbcb624a5843e2c0821ccb1e307cc23724f9636918495305cadc75abf04395cd9ede28597774ab60948167 From cec11e3cd81f1139491d7d4242dbf97eb5f45127 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 10 Jul 2023 22:43:58 +0100 Subject: [PATCH 55/91] --enable-frame-pointers only works on x86-64 --- ocaml.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ocaml.spec b/ocaml.spec index 544a857..4efd357 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -230,8 +230,10 @@ sed -i '/ld_opts/s|\[\]|["%{build_ldflags}"]|' tools/ocamlmklib.ml %if %{native_compiler} --enable-native-toplevel \ %endif +%ifarch x86_64 %if 0%{?_include_frame_pointers} --enable-frame-pointers \ +%endif %endif OC_CFLAGS='%{build_cflags}' \ OC_LDFLAGS='%{build_ldflags}' \ From be2dfe04dbe0e6111899a07a18afb0004b8a4507 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 11 Jul 2023 08:31:48 +0100 Subject: [PATCH 56/91] Fix compilation on bytecode-only arches File not found: /builddir/build/BUILDROOT/ocaml-5.0.0-1.fc39.ppc64le/usr/lib64/ocaml/{dynlink,runtime_events,str,threads,unix}/*.a --- ocaml.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 4efd357..0de2e66 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -355,9 +355,9 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml %{_libdir}/ocaml/sys.ml.in %{_libdir}/ocaml/libcamlrun_shared.so -%{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.a %{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.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 From 772b17b6662dc7fdeeaa750e3225a5e8d2274f3f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 11 Jul 2023 17:46:39 +0100 Subject: [PATCH 57/91] Drop downstream 0017-configure-Only-use-OC_-for-building-executables.patch This is no longer needed now we found another way to work around build notes breakage. --- ...t-version-number-after-tagging-5.0.0.patch | 2 +- ...st-11814-from-gasche-clarify-DLS.new.patch | 2 +- 0003-Add-KC-Sivaramakrishnan-as-author.patch | 2 +- ...unused-variables-in-yacc-reader.c-11.patch | 2 +- ...st-11860-from-Octachron-index_for_st.patch | 2 +- ...g-in-folder-with-space-in-name-11590.patch | 2 +- ...nused-Makefile-variables-in-workflow.patch | 2 +- ...variable-from-runtime-Makefile-merge.patch | 2 +- ...-Provide-a-default-for-OCAMLDEPFLAGS.patch | 2 +- 0010-Report-all-post-build-failures.patch | 2 +- ...emoval-of-FORCE_INSTRUMENTED_RUNTIME.patch | 2 +- ...s-alert-when-compiling-stdlib-docume.patch | 2 +- ...st-12285-from-smorimoto-update-depre.patch | 2 +- ...st-12286-from-smorimoto-replace-set-.patch | 2 +- 0015-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...0017-Fix-skiplist-test-failure-12346.patch | 4 +- ...nly-use-OC_-for-building-executables.patch | 40 ------------------- ocaml.spec | 7 ++-- 19 files changed, 21 insertions(+), 62 deletions(-) rename 0018-Fix-skiplist-test-failure-12346.patch => 0017-Fix-skiplist-test-failure-12346.patch (92%) delete mode 100644 0017-configure-Only-use-OC_-for-building-executables.patch diff --git a/0001-increment-version-number-after-tagging-5.0.0.patch b/0001-increment-version-number-after-tagging-5.0.0.patch index 7583a57..8103ef0 100644 --- a/0001-increment-version-number-after-tagging-5.0.0.patch +++ b/0001-increment-version-number-after-tagging-5.0.0.patch @@ -1,7 +1,7 @@ From 8741f4d88801e478e0ab7f871dc7dbcf9d7cc8f4 Mon Sep 17 00:00:00 2001 From: Florian Angeletti Date: Thu, 15 Dec 2022 14:28:32 +0100 -Subject: [PATCH 01/18] increment version number after tagging 5.0.0 +Subject: [PATCH 01/17] increment version number after tagging 5.0.0 --- VERSION | 2 +- diff --git a/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch b/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch index e25154a..6a68fc4 100644 --- a/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch +++ b/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch @@ -1,7 +1,7 @@ From 925bf9a6d828d7548751f9a21892cad6209fc950 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Fri, 16 Dec 2022 09:41:13 +0100 -Subject: [PATCH 02/18] Merge pull request #11814 from +Subject: [PATCH 02/17] Merge pull request #11814 from gasche/clarify-DLS.new_key-doc clarify the doc of Domain.DLS.new_key diff --git a/0003-Add-KC-Sivaramakrishnan-as-author.patch b/0003-Add-KC-Sivaramakrishnan-as-author.patch index 0a60404..3186f31 100644 --- a/0003-Add-KC-Sivaramakrishnan-as-author.patch +++ b/0003-Add-KC-Sivaramakrishnan-as-author.patch @@ -1,7 +1,7 @@ From 83ef99f67fda11b268098a271f56b990e295bbc2 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 20 Dec 2022 10:48:41 +0100 -Subject: [PATCH 03/18] Add KC Sivaramakrishnan as author +Subject: [PATCH 03/17] Add KC Sivaramakrishnan as author For the two new chapters "Parallel programming" and "Memory model". diff --git a/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch b/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch index d49f709..846f0be 100644 --- a/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch +++ b/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch @@ -1,7 +1,7 @@ From ea8b79eda165722d04b369f1811a5aa80ab5acc6 Mon Sep 17 00:00:00 2001 From: SSHz Date: Sun, 27 Nov 2022 14:46:16 +0000 -Subject: [PATCH 04/18] removed set but unused variables in yacc/reader.c +Subject: [PATCH 04/17] removed set but unused variables in yacc/reader.c (#11758) (cherry picked from commit 0114f62d3ed056254ac25192f724e92a2ff6c448) diff --git a/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch b/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch index c3e9555..8421941 100644 --- a/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch +++ b/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch @@ -1,7 +1,7 @@ From 848e28fc6f3f3c9802b23c00f2d77f568c761667 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Tue, 3 Jan 2023 17:41:12 +0100 -Subject: [PATCH 05/18] Merge pull request #11860 from +Subject: [PATCH 05/17] Merge pull request #11860 from Octachron/index_for_stdlib documentation: sort modules alphabetically diff --git a/0006-Allow-installing-in-folder-with-space-in-name-11590.patch b/0006-Allow-installing-in-folder-with-space-in-name-11590.patch index 2831ec8..ed6c490 100644 --- a/0006-Allow-installing-in-folder-with-space-in-name-11590.patch +++ b/0006-Allow-installing-in-folder-with-space-in-name-11590.patch @@ -1,7 +1,7 @@ From a3cd42bc03ed0fc706bb7364fdb14b29b1925600 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 4 Jan 2023 16:33:28 +0000 -Subject: [PATCH 06/18] Allow installing in folder with space in name (#11590) +Subject: [PATCH 06/17] Allow installing in folder with space in name (#11590) - fix(build): Repair make install (in man/Makefile) --- diff --git a/0007-Detect-unused-Makefile-variables-in-workflow.patch b/0007-Detect-unused-Makefile-variables-in-workflow.patch index e13b225..0af534d 100644 --- a/0007-Detect-unused-Makefile-variables-in-workflow.patch +++ b/0007-Detect-unused-Makefile-variables-in-workflow.patch @@ -1,7 +1,7 @@ From 44f4015f9a649e164b332e6ab1302139191d4a4f Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 3 Mar 2021 12:24:36 +0000 -Subject: [PATCH 07/18] Detect unused Makefile variables in workflow +Subject: [PATCH 07/17] Detect unused Makefile variables in workflow --- tools/ci/actions/runner.sh | 13 ++++++++++++- diff --git a/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch b/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch index f57e2bd..504a5fd 100644 --- a/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch +++ b/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch @@ -1,7 +1,7 @@ From 2eccdd3cd78624b0f2664d6152afbcae167f6f8b Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Mon, 20 Feb 2023 20:27:58 +0000 -Subject: [PATCH 08/18] Fix incorrect variable from runtime/Makefile merge +Subject: [PATCH 08/17] Fix incorrect variable from runtime/Makefile merge Wrong CPPFLAGS used when assembling with ASPP. --- diff --git a/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch b/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch index 0c10ff5..cdb8e60 100644 --- a/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch +++ b/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch @@ -1,7 +1,7 @@ From 5f3f8bf734bdc02adc69cf92f066547bd71e8a25 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Mon, 20 Feb 2023 20:31:31 +0000 -Subject: [PATCH 09/18] Provide a default for $(OCAMLDEPFLAGS) +Subject: [PATCH 09/17] Provide a default for $(OCAMLDEPFLAGS) --- Makefile.common | 1 + diff --git a/0010-Report-all-post-build-failures.patch b/0010-Report-all-post-build-failures.patch index bf8f6e2..952529f 100644 --- a/0010-Report-all-post-build-failures.patch +++ b/0010-Report-all-post-build-failures.patch @@ -1,7 +1,7 @@ From 7f4569e22c2a19d51324c44a2954b10427df2cd8 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Tue, 21 Feb 2023 14:44:21 +0000 -Subject: [PATCH 10/18] Report all post-build failures +Subject: [PATCH 10/17] Report all post-build failures Rather than just reporting un-prefixed symbol names, also report undefined variables. diff --git a/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch b/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch index 5ffca5f..543afca 100644 --- a/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch +++ b/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch @@ -1,7 +1,7 @@ From 0f6dc503bf3814e5547ffb4e9d6ea0a75ffd1ec0 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 22 Feb 2023 10:47:00 +0000 -Subject: [PATCH 11/18] Finish off removal of FORCE_INSTRUMENTED_RUNTIME +Subject: [PATCH 11/17] Finish off removal of FORCE_INSTRUMENTED_RUNTIME --- utils/Makefile | 1 - diff --git a/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch b/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch index 5d87237..d0416ba 100644 --- a/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch +++ b/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch @@ -1,7 +1,7 @@ From ffb2022797986324213891a59c02af46269b5c17 Mon Sep 17 00:00:00 2001 From: Damien Doligez Date: Mon, 17 Apr 2023 11:36:32 +0200 -Subject: [PATCH 12/18] suppress spurious alert when compiling stdlib +Subject: [PATCH 12/17] suppress spurious alert when compiling stdlib documentation (cherry picked from commit 5c0fb8e23865fdbf151bdbe15d91176903c284d3) diff --git a/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch b/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch index ed6f114..519c245 100644 --- a/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch +++ b/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch @@ -1,7 +1,7 @@ From 4cc4eb8b0d71c64c5252d6764f4c4b0aa6020995 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sat, 3 Jun 2023 18:02:24 +0100 -Subject: [PATCH 13/18] Merge pull request #12285 from +Subject: [PATCH 13/17] Merge pull request #12285 from smorimoto/update-deprecated-actions Update deprecated GitHub Actions diff --git a/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch b/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch index cf8c766..c29b0c7 100644 --- a/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch +++ b/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch @@ -1,7 +1,7 @@ From af3a67cd06e07825c63b70a038cf90481039b1ed Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Fri, 9 Jun 2023 21:47:51 +0100 -Subject: [PATCH 14/18] Merge pull request #12286 from +Subject: [PATCH 14/17] Merge pull request #12286 from smorimoto/replace-set-output Replace the set-output command with the GITHUB_OUTPUT environment file diff --git a/0015-Don-t-add-rpaths-to-libraries.patch b/0015-Don-t-add-rpaths-to-libraries.patch index 9d3092b..74c6dfa 100644 --- a/0015-Don-t-add-rpaths-to-libraries.patch +++ b/0015-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 0e07dfdb530734ef4db351ecc24c6363e36916ec Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 15/18] Don't add rpaths to libraries. +Subject: [PATCH 15/17] Don't add rpaths to libraries. --- utils/config.mlp | 4 ++-- diff --git a/0016-configure-Allow-user-defined-C-compiler-flags.patch b/0016-configure-Allow-user-defined-C-compiler-flags.patch index f618d37..a3d322a 100644 --- a/0016-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0016-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From 9d3722c87ab15dfbc4e1a934e09ddc8253712d9c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 16/18] configure: Allow user defined C compiler flags. +Subject: [PATCH 16/17] configure: Allow user defined C compiler flags. --- configure.ac | 4 ++++ diff --git a/0018-Fix-skiplist-test-failure-12346.patch b/0017-Fix-skiplist-test-failure-12346.patch similarity index 92% rename from 0018-Fix-skiplist-test-failure-12346.patch rename to 0017-Fix-skiplist-test-failure-12346.patch index 1668adc..87219e7 100644 --- a/0018-Fix-skiplist-test-failure-12346.patch +++ b/0017-Fix-skiplist-test-failure-12346.patch @@ -1,7 +1,7 @@ -From 69fdedd5c7747370879abbdc2beb5d7a1bd72194 Mon Sep 17 00:00:00 2001 +From 74b0eee42f616cb05c640c0ceac0cc391e4a7ef1 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Fri, 7 Jul 2023 07:07:09 -0600 -Subject: [PATCH 18/18] Fix skiplist test failure (#12346) +Subject: [PATCH 17/17] Fix skiplist test failure (#12346) Fix -Wmaybe-uninitialized warning in skiplist test Fix -Wunused-variable warning in skiplist test diff --git a/0017-configure-Only-use-OC_-for-building-executables.patch b/0017-configure-Only-use-OC_-for-building-executables.patch deleted file mode 100644 index ff1e02b..0000000 --- a/0017-configure-Only-use-OC_-for-building-executables.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 1c908c961738067dd52a5ba4515cc35abd35b96b Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Wed, 26 Jan 2022 15:47:02 +0000 -Subject: [PATCH 17/18] 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 | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 8068de3cfc..19b23f9400 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -36,7 +36,7 @@ CONFIGURE_ARGS="$*" - # rely on $CFLAGS because these cannot be processed by flexlink (and are not - # passed) - mkexe_cmd='$(CC)' --mkexe_cflags='$(OC_CFLAGS) $(CFLAGS)' -+mkexe_cflags='$(OC_CFLAGS)' - mkexe_extra_flags='' - mkexe_via_cc_extra_cmd='' - mkexe_ldflags_prefix='' -@@ -2208,7 +2208,7 @@ ${mkdll_ldflags}" - ],[ - mkdll_ldflags='$(OC_DLL_LDFLAGS) $(LDFLAGS)' - mkdll_ldflags_exp="${oc_dll_ldflags} ${LDFLAGS}" -- mkexe="${mkexe} \$(OC_LDFLAGS) \$(LDFLAGS)" -+ mkexe="${mkexe} \$(OC_LDFLAGS)" - mkexe_exp="${mkexe_exp} ${oc_ldflags} ${LDFLAGS}" - ]) - mkdll="$mkdll $mkdll_ldflags" --- -2.41.0 - diff --git a/ocaml.spec b/ocaml.spec index 0de2e66..55f3e50 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -37,7 +37,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.0.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -81,11 +81,10 @@ Patch: 0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch # Fedora-specific patches Patch: 0015-Don-t-add-rpaths-to-libraries.patch Patch: 0016-configure-Allow-user-defined-C-compiler-flags.patch -Patch: 0017-configure-Only-use-OC_-for-building-executables.patch # Fix skiplist test failure # https://github.com/ocaml/ocaml/pull/12346 -Patch: 0018-Fix-skiplist-test-failure-12346.patch +Patch: 0017-Fix-skiplist-test-failure-12346.patch BuildRequires: make BuildRequires: git @@ -438,7 +437,7 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml %changelog -* Wed Jun 14 2023 Jerry James - 5.0.0-1 +* 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 From 5ebc943f989aa6a54499f540b04a87a4ea9f3b0a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 11 Jul 2023 17:49:54 +0100 Subject: [PATCH 58/91] Add all further differences with jjames's OCaml 5 package --- ocaml.spec | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ocaml.spec b/ocaml.spec index 55f3e50..860c653 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -114,7 +114,11 @@ Provides: bundled(md5-plumb) Provides: ocaml(compiler) = %{version} +%if %{native_compiler} %global __ocaml_requires_opts -c -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' +%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_provides_opts -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' @@ -227,7 +231,11 @@ sed -i '/ld_opts/s|\[\]|["%{build_ldflags}"]|' tools/ocamlmklib.ml --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 %if 0%{?_include_frame_pointers} @@ -442,6 +450,7 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml - 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 From 64f662b9c585a90232c8b172bceff6dc9ba3e620 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 12 Jul 2023 11:28:00 +0100 Subject: [PATCH 59/91] Force ocaml-srpm-macros to be the latest version. --- ocaml.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 860c653..0658ebd 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -37,7 +37,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.0.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -109,6 +109,10 @@ Requires: redhat-rpm-config # of ocaml-runtime. Requires: ocaml-runtime%{?_isa} = %{version}-%{release} +# Force ocaml-srpm-macros to be at the latest version, since OCaml 5.0 +# has a different set of native code generators than previous versions. +Requires: ocaml-srpm-macros >= 8 + # Bundles an MD5 implementation in runtime/caml/md5.h and runtime/md5.c Provides: bundled(md5-plumb) @@ -445,6 +449,9 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml %changelog +* 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 From 4a09b96d7b6c97f47d2824aab1d942aee0daa7a7 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jul 2023 17:09:37 +0000 Subject: [PATCH 60/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 0658ebd..78683d0 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -37,7 +37,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.0.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -449,6 +449,9 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml %changelog +* 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. From a433439c107b2c295d22003187a95935db16aeee Mon Sep 17 00:00:00 2001 From: Jerry James Date: Wed, 4 Oct 2023 20:56:33 -0600 Subject: [PATCH 61/91] Version 5.1.0 Other changes: - Add LicenseRef-Fedora-Public-Domain to the runtime License field - New ocaml-rpm-macros subpackage - Depend on libzstd-devel for compressed marshaling - Disable LTO --- 0001-Don-t-add-rpaths-to-libraries.patch | 25 + ...t-version-number-after-tagging-5.0.0.patch | 86 --- ...st-11814-from-gasche-clarify-DLS.new.patch | 66 -- ...-Allow-user-defined-C-compiler-flags.patch | 45 ++ 0003-Add-KC-Sivaramakrishnan-as-author.patch | 31 - ...elivery-of-effect-related-exceptions.patch | 34 + ...ters-tests-to-avoid-false-positive-w.patch | 696 ++++++++++++++++++ ...unused-variables-in-yacc-reader.c-11.patch | 39 - ...st-11860-from-Octachron-index_for_st.patch | 68 -- ...g-in-folder-with-space-in-name-11590.patch | 42 -- ...nused-Makefile-variables-in-workflow.patch | 45 -- ...variable-from-runtime-Makefile-merge.patch | 33 - ...-Provide-a-default-for-OCAMLDEPFLAGS.patch | 24 - 0010-Report-all-post-build-failures.patch | 41 -- ...emoval-of-FORCE_INSTRUMENTED_RUNTIME.patch | 24 - ...s-alert-when-compiling-stdlib-docume.patch | 27 - ...st-12285-from-smorimoto-update-depre.patch | 70 -- ...st-12286-from-smorimoto-replace-set-.patch | 40 - 0015-Don-t-add-rpaths-to-libraries.patch | 27 - ...-Allow-user-defined-C-compiler-flags.patch | 27 - 0017-Fix-skiplist-test-failure-12346.patch | 39 - macros.ocaml-rpm | 69 ++ ocaml.spec | 127 ++-- ocaml_files.py | 451 ++++++++++++ sources | 2 +- 25 files changed, 1397 insertions(+), 781 deletions(-) create mode 100644 0001-Don-t-add-rpaths-to-libraries.patch delete mode 100644 0001-increment-version-number-after-tagging-5.0.0.patch delete mode 100644 0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch create mode 100644 0002-configure-Allow-user-defined-C-compiler-flags.patch delete mode 100644 0003-Add-KC-Sivaramakrishnan-as-author.patch create mode 100644 0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch create mode 100644 0004-Update-framepointers-tests-to-avoid-false-positive-w.patch delete mode 100644 0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch delete mode 100644 0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch delete mode 100644 0006-Allow-installing-in-folder-with-space-in-name-11590.patch delete mode 100644 0007-Detect-unused-Makefile-variables-in-workflow.patch delete mode 100644 0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch delete mode 100644 0009-Provide-a-default-for-OCAMLDEPFLAGS.patch delete mode 100644 0010-Report-all-post-build-failures.patch delete mode 100644 0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch delete mode 100644 0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch delete mode 100644 0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch delete mode 100644 0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch delete mode 100644 0015-Don-t-add-rpaths-to-libraries.patch delete mode 100644 0016-configure-Allow-user-defined-C-compiler-flags.patch delete mode 100644 0017-Fix-skiplist-test-failure-12346.patch create mode 100644 macros.ocaml-rpm create mode 100644 ocaml_files.py diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch new file mode 100644 index 0000000..344a528 --- /dev/null +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -0,0 +1,25 @@ +From 03435cc789bfb783c1d5566e8abd387eea1b9155 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 24 Jun 2014 10:00:15 +0100 +Subject: [PATCH 1/4] Don't add rpaths to libraries. + +--- + configure.ac | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 7c7d9a814c..d5040c279c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1106,8 +1106,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.41.0 + diff --git a/0001-increment-version-number-after-tagging-5.0.0.patch b/0001-increment-version-number-after-tagging-5.0.0.patch deleted file mode 100644 index 8103ef0..0000000 --- a/0001-increment-version-number-after-tagging-5.0.0.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 8741f4d88801e478e0ab7f871dc7dbcf9d7cc8f4 Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Thu, 15 Dec 2022 14:28:32 +0100 -Subject: [PATCH 01/17] increment version number after tagging 5.0.0 - ---- - VERSION | 2 +- - build-aux/ocaml_version.m4 | 6 +++--- - configure | Bin 617024 -> 617302 bytes - ocaml-variants.opam | 6 +++--- - 4 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/VERSION b/VERSION -index fc40ac52d7..314f8ec760 100644 ---- a/VERSION -+++ b/VERSION -@@ -1,4 +1,4 @@ --5.0.0 -+5.0.1+dev0-2022-12-15 - - # Starting with OCaml 4.14, although the version string that appears above is - # still correct and this file can thus still be used to figure it out, -diff --git a/build-aux/ocaml_version.m4 b/build-aux/ocaml_version.m4 -index ba48c00277..78049eaab0 100644 ---- a/build-aux/ocaml_version.m4 -+++ b/build-aux/ocaml_version.m4 -@@ -25,7 +25,7 @@ - # The following macro, OCAML__DEVELOPMENT_VERSION, should be either - # [true] of [false]. - --m4_define([OCAML__DEVELOPMENT_VERSION], [false]) -+m4_define([OCAML__DEVELOPMENT_VERSION], [true]) - - # The three following components (major, minor and patch level) MUST be - # integers. They MUST NOT be left-padded with zeros and all of them, -@@ -33,10 +33,10 @@ m4_define([OCAML__DEVELOPMENT_VERSION], [false]) - - m4_define([OCAML__VERSION_MAJOR], [5]) - m4_define([OCAML__VERSION_MINOR], [0]) --m4_define([OCAML__VERSION_PATCHLEVEL], [0]) -+m4_define([OCAML__VERSION_PATCHLEVEL], [1]) - # Note that the OCAML__VERSION_EXTRA string defined below is always empty - # for officially-released versions of OCaml. --m4_define([OCAML__VERSION_EXTRA], []) -+m4_define([OCAML__VERSION_EXTRA], [dev0-2022-12-15]) - - # The OCAML__VERSION_EXTRA_PREFIX macro defined below should be a - # single character: -diff --git a/configure b/configure -index 19764d19a9b8fb1a9f01868f8f7863733a4c4ecd..f54df41388272a49e583ca20f325508c5b814eff 100755 -GIT binary patch -delta 558 -zcmX?bMfKV>)eSNnf`-~DsbvPbMg~Skx`sexx>=UvgA=CkWIk^hOwrBS-boQyg!>lT -z^I#D^w|=RVFoum>>61UO%Wj^0>LnI?x7YGA-j2jHYkHy%qwMsubVfN$x$RTa8SPkv -zFfE!a6)I(ITT)b-%EjgH?C9$gALQ!e>KN=A?-~&jgcdML -zn(EW}a~M6D47nz63=t8qMU&s2pTqc^h0$<&pcn(`ObkI${VGs4{AT -zl=Ds(C}Lzq($6>DyNHn&(|gk&sxgYT=M^ymF%u9o12N0?ydu`PGG?IP+Aq9d1!A`C -q7hbSOxPU~a14U%Fd+Kt$%*A3FFo1ow*U#pd&5kL#U3xKx>Tv-4Xq`R) - -delta 271 -zcmcb1P4&PP)eSNnj0T%^IX*Zs8cf#nmH~32y^|t<)Vam>JU~ir!%`_`1FrPRAJ}C# -ze?IjRsBZgPUdG#zj0V#$>M+Vq|CY`u2NYAyV6m!Fq9{ZtO4CrI(b5D`Y(?UuQW&sl)xDHbt0O)n~9be#S` -zl~Hqge<33;n}VqU5P+mi`GP}&JpJ4iVw6nv4D<}z1B)4fmcP84Jkj -x_Tw*EftYRk@t5ooE?}YQKq1-f_IeyIbAdJiec-dbbq>dDcA(P@mvE>a2LKy+Taf?& - -diff --git a/ocaml-variants.opam b/ocaml-variants.opam -index 5928f357f2..a0876e02c9 100644 ---- a/ocaml-variants.opam -+++ b/ocaml-variants.opam -@@ -1,9 +1,9 @@ - opam-version: "2.0" --version: "5.0.0" -+version: "5.0.1+trunk" - license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" --synopsis: "Official release of OCaml 5.0.0" -+synopsis: "OCaml development version" - depends: [ -- "ocaml" {= "5.0.0" & post} -+ "ocaml" {= "5.0.1" & post} - "base-unix" {post} - "base-bigarray" {post} - "base-threads" {post} --- -2.41.0 - diff --git a/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch b/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch deleted file mode 100644 index 6a68fc4..0000000 --- a/0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 925bf9a6d828d7548751f9a21892cad6209fc950 Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Fri, 16 Dec 2022 09:41:13 +0100 -Subject: [PATCH 02/17] Merge pull request #11814 from - gasche/clarify-DLS.new_key-doc - -clarify the doc of Domain.DLS.new_key - -(cherry picked from commit be210179503c4a82b72dd4762560e13c408d37b7) ---- - stdlib/domain.mli | 37 ++++++++++++++++++++++++++++++------- - 1 file changed, 30 insertions(+), 7 deletions(-) - -diff --git a/stdlib/domain.mli b/stdlib/domain.mli -index 7763043aa5..2d79b3b0c3 100644 ---- a/stdlib/domain.mli -+++ b/stdlib/domain.mli -@@ -96,15 +96,38 @@ module DLS : sig - - val new_key : ?split_from_parent:('a -> 'a) -> (unit -> 'a) -> 'a key - (** [new_key f] returns a new key bound to initialiser [f] for accessing -- domain-local variables. -+, domain-local variables. - -- If [split_from_parent] is provided, spawning a domain will derive the -- child value (for this key) from the parent value. -+ If [split_from_parent] is not provided, the value for a new -+ domain will be computed on-demand by the new domain: the first -+ [get] call will call the initializer [f] and store that value. - -- Note that the [split_from_parent] call is computed in the parent -- domain, and is always computed regardless of whether the child domain -- will use it. If the splitting function is expensive or requires -- client-side computation, consider using ['a Lazy.t key]. -+ If [split_from_parent] is provided, spawning a domain will -+ derive the child value (for this key) from the parent -+ value. This computation happens in the parent domain and it -+ always happens, regardless of whether the child domain will -+ use it. -+ If the splitting function is expensive or requires -+ child-side computation, consider using ['a Lazy.t key]: -+ -+ {[ -+ let init () = ... -+ -+ let split_from_parent parent_value = -+ ... parent-side computation ...; -+ lazy ( -+ ... child-side computation ... -+ ) -+ -+ let key = Domain.DLS.new_key ~split_from_parent init -+ -+ let get () = Lazy.force (Domain.DLS.get key) -+ ]} -+ -+ In this case a part of the computation happens on the child -+ domain; in particular, it can access [parent_value] -+ concurrently with the parent domain, which may require -+ explicit synchronization to avoid data races. - *) - - val get : 'a key -> 'a --- -2.41.0 - diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch new file mode 100644 index 0000000..0d70a04 --- /dev/null +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -0,0 +1,45 @@ +From d9bcdb9d0a27e10350b1ca90df43b401656324f1 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 29 May 2012 20:44:18 +0100 +Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. + +--- + configure.ac | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index d5040c279c..4cbba04557 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -759,6 +759,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" ++ + # Enable SSE2 on x86 mingw to avoid using 80-bit registers. + AS_CASE([$host], + [i686-*-mingw32*], +@@ -2325,7 +2329,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"]) +@@ -2351,7 +2355,7 @@ ${mkdll_ldflags}" + ],[ + mkdll_ldflags='$(OC_DLL_LDFLAGS) $(LDFLAGS)' + mkdll_ldflags_exp="${oc_dll_ldflags}" +- AS_IF([test -n ${LDFLAGS}], ++ AS_IF([test -n "${LDFLAGS}"], + [mkdll_ldflags_exp="$mkdll_ldflags_exp $LDFLAGS"]) + mkexe_ldflags="\$(OC_LDFLAGS) \$(LDFLAGS)" + mkexe_ldflags_exp="${oc_ldflags} ${LDFLAGS}" +-- +2.41.0 + diff --git a/0003-Add-KC-Sivaramakrishnan-as-author.patch b/0003-Add-KC-Sivaramakrishnan-as-author.patch deleted file mode 100644 index 3186f31..0000000 --- a/0003-Add-KC-Sivaramakrishnan-as-author.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 83ef99f67fda11b268098a271f56b990e295bbc2 Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Tue, 20 Dec 2022 10:48:41 +0100 -Subject: [PATCH 03/17] Add KC Sivaramakrishnan as author - -For the two new chapters "Parallel programming" and "Memory model". - -Follow-up to #11280. - -(cherry picked from commit e6340ced8ca1d46f11eaea8e0474d1eb2142fe1c) ---- - manual/src/allfiles.etex | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/manual/src/allfiles.etex b/manual/src/allfiles.etex -index 6600943f54..3e07555b85 100644 ---- a/manual/src/allfiles.etex -+++ b/manual/src/allfiles.etex -@@ -12,7 +12,8 @@ - release \ocamlversion \\[1cm] - \Large Documentation and user's manual \\[1cm] - \large Xavier Leroy, \\ -- Damien Doligez, Alain Frisch, Jacques Garrigue, Didier Rémy and Jérôme Vouillon \\[1cm] -+ Damien Doligez, Alain Frisch, Jacques Garrigue, \\ -+ Didier Rémy, KC Sivaramakrishnan and Jérôme Vouillon \\[1cm] - \today \\ - ~ - \vfill --- -2.41.0 - diff --git a/0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch b/0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch new file mode 100644 index 0000000..6d40ec0 --- /dev/null +++ b/0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch @@ -0,0 +1,34 @@ +From 352789925e44f012fbddc5dfae63abd15a447577 Mon Sep 17 00:00:00 2001 +From: Miod Vallat +Date: Mon, 4 Sep 2023 13:50:30 -0600 +Subject: [PATCH 3/4] Fix x86_64 delivery of effect-related exceptions + +--- + runtime/amd64.S | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/runtime/amd64.S b/runtime/amd64.S +index 7e6f95c680..24dfa7111b 100644 +--- a/runtime/amd64.S ++++ b/runtime/amd64.S +@@ -902,6 +902,7 @@ LBL(112): + movq Caml_state(current_stack), %rsi + SWITCH_OCAML_STACKS + /* No parent stack. Raise Effect.Unhandled. */ ++ ENTER_FUNCTION + movq %rax, C_ARG_1 + LEA_VAR(caml_raise_unhandled_effect, %rax) + jmp LBL(caml_c_call) +@@ -946,7 +947,8 @@ CFI_STARTPROC + UPDATE_BASE_POINTER(%rcx) + SWITCH_OCAML_STACKS + jmp *(%rbx) +-2: LEA_VAR(caml_raise_continuation_already_resumed, %rax) ++2: ENTER_FUNCTION ++ LEA_VAR(caml_raise_continuation_already_resumed, %rax) + jmp LBL(caml_c_call) + CFI_ENDPROC + ENDFUNCTION(G(caml_resume)) +-- +2.41.0 + diff --git a/0004-Update-framepointers-tests-to-avoid-false-positive-w.patch b/0004-Update-framepointers-tests-to-avoid-false-positive-w.patch new file mode 100644 index 0000000..2025d57 --- /dev/null +++ b/0004-Update-framepointers-tests-to-avoid-false-positive-w.patch @@ -0,0 +1,696 @@ +From 210f9b439b264fb6ab16802f468992086a4af58c Mon Sep 17 00:00:00 2001 +From: Fabrice Buoro +Date: Fri, 10 Mar 2023 09:36:22 -0700 +Subject: [PATCH 4/4] Update framepointers tests to avoid false positive with + inlined C functions + +--- + testsuite/tests/frame-pointers/c_call.ml | 14 +- + .../tests/frame-pointers/c_call.reference | 9 - + testsuite/tests/frame-pointers/c_call.run | 4 - + testsuite/tests/frame-pointers/c_call_.c | 14 +- + testsuite/tests/frame-pointers/effects.ml | 12 +- + .../tests/frame-pointers/effects.reference | 15 -- + testsuite/tests/frame-pointers/effects.run | 4 - + .../tests/frame-pointers/exception_handler.ml | 4 +- + .../exception_handler.reference | 12 -- + .../frame-pointers/exception_handler.run | 4 - + .../tests/frame-pointers/filter-locations.sh | 23 --- + testsuite/tests/frame-pointers/fp_backtrace.c | 186 +++++++++++------- + testsuite/tests/frame-pointers/reperform.ml | 4 +- + .../tests/frame-pointers/reperform.reference | 3 - + testsuite/tests/frame-pointers/reperform.run | 4 - + .../tests/frame-pointers/stack_realloc.ml | 4 +- + .../frame-pointers/stack_realloc.reference | 3 - + .../tests/frame-pointers/stack_realloc.run | 4 - + .../tests/frame-pointers/stack_realloc2.ml | 4 +- + .../frame-pointers/stack_realloc2.reference | 3 - + .../tests/frame-pointers/stack_realloc2.run | 4 - + 21 files changed, 144 insertions(+), 190 deletions(-) + delete mode 100644 testsuite/tests/frame-pointers/c_call.run + delete mode 100644 testsuite/tests/frame-pointers/effects.run + delete mode 100644 testsuite/tests/frame-pointers/exception_handler.run + delete mode 100755 testsuite/tests/frame-pointers/filter-locations.sh + delete mode 100644 testsuite/tests/frame-pointers/reperform.run + delete mode 100644 testsuite/tests/frame-pointers/stack_realloc.run + delete mode 100644 testsuite/tests/frame-pointers/stack_realloc2.run + +diff --git a/testsuite/tests/frame-pointers/c_call.ml b/testsuite/tests/frame-pointers/c_call.ml +index 7d48b4947d..f552b0df8f 100644 +--- a/testsuite/tests/frame-pointers/c_call.ml ++++ b/testsuite/tests/frame-pointers/c_call.ml +@@ -7,20 +7,20 @@ all_modules = "${readonly_files} c_call. + + *) + +-external fp_backtrace : unit -> unit = "fp_backtrace" +-external fp_backtrace_no_alloc : unit -> unit = "fp_backtrace" [@@noalloc] +-external fp_backtrace_many_args : int -> int -> int -> int -> int -> int -> int +- -> int -> int -> int -> int -> unit = ++external fp_backtrace : string -> unit = "fp_backtrace" ++external fp_backtrace_no_alloc : string -> unit = "fp_backtrace" [@@noalloc] ++external fp_backtrace_many_args : string -> int -> int -> int -> int -> int ++ -> int -> int -> int -> int -> int -> int -> unit = + "fp_backtrace_many_args_argv" "fp_backtrace_many_args" + + let[@inline never] f () = + (* Check backtrace through caml_c_call_stack_args *) +- fp_backtrace_many_args 1 2 3 4 5 6 7 8 9 10 11; ++ fp_backtrace_many_args Sys.argv.(0) 1 2 3 4 5 6 7 8 9 10 11; + (* Check backtrace through caml_c_call. + * Also check that caml_c_call_stack_args correctly restores rbp register *) +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + (* Check caml_c_call correctly restores rbp register *) +- fp_backtrace_no_alloc (); ++ fp_backtrace_no_alloc Sys.argv.(0); + 42 + + let () = ignore (f ()) +diff --git a/testsuite/tests/frame-pointers/c_call.reference b/testsuite/tests/frame-pointers/c_call.reference +index 92fb40a238..23095e7431 100644 +--- a/testsuite/tests/frame-pointers/c_call.reference ++++ b/testsuite/tests/frame-pointers/c_call.reference +@@ -3,19 +3,10 @@ caml_c_call_stack_args + camlC_call.f + camlC_call.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + caml_c_call + camlC_call.f + camlC_call.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + camlC_call.f + camlC_call.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main +diff --git a/testsuite/tests/frame-pointers/c_call.run b/testsuite/tests/frame-pointers/c_call.run +deleted file mode 100644 +index e96b5ea13a..0000000000 +--- a/testsuite/tests/frame-pointers/c_call.run ++++ /dev/null +@@ -1,4 +0,0 @@ +-#!/bin/sh +- +-${program} 2>&1 \ +- | ${test_source_directory}/filter-locations.sh ${program} >${output} +diff --git a/testsuite/tests/frame-pointers/c_call_.c b/testsuite/tests/frame-pointers/c_call_.c +index 634c4dd937..a75100b213 100644 +--- a/testsuite/tests/frame-pointers/c_call_.c ++++ b/testsuite/tests/frame-pointers/c_call_.c +@@ -16,10 +16,10 @@ + #include + #include "caml/mlvalues.h" + +-void fp_backtrace(void); ++void fp_backtrace(value); + +-value fp_backtrace_many_args(value a, value b, value c, value d, value e, +- value f, value g, value h, value i, value j, value k) ++value fp_backtrace_many_args(value argv0, value a, value b, value c, ++ value d, value e, value f, value g, value h, value i, value j, value k) + { + assert(Int_val(a) == 1); + assert(Int_val(b) == 2); +@@ -33,15 +33,15 @@ value fp_backtrace_many_args(value a, value b, value c, value d, value e, + assert(Int_val(j) == 10); + assert(Int_val(k) == 11); + +- fp_backtrace(); ++ fp_backtrace(argv0); + + return Val_unit; + } + +-value fp_bactrace_many_args_argv(value *argv, int argc) ++value fp_bactrace_many_args_argv(value argv0, value *argv, int argc) + { + assert(argc == 11); + +- return fp_backtrace_many_args(argv[0], argv[1], argv[2], argv[3], argv[4], +- argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); ++ return fp_backtrace_many_args(argv0, argv[0], argv[1], argv[2], argv[3], ++ argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); + } +diff --git a/testsuite/tests/frame-pointers/effects.ml b/testsuite/tests/frame-pointers/effects.ml +index 2aa7012606..ac304683fe 100644 +--- a/testsuite/tests/frame-pointers/effects.ml ++++ b/testsuite/tests/frame-pointers/effects.ml +@@ -11,26 +11,26 @@ open Printf + open Effect + open Effect.Deep + +-external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] ++external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] + + type _ t += E : int -> int t + + let[@inline never] f () = + printf "# computation f\n%!"; +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + printf "# perform effect (E 0)\n%!"; + let v = perform (E 0) in + printf "# perform returns %d\n%!" v; +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + v + 1 + + let h (type a) (eff : a t) : ((a, 'b) continuation -> 'b) option = + let[@inline never] h_effect_e v k = + printf "# caught effect (E %d). continuing...\n%!" v; +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + let v = continue k (v + 1) in + printf "# continue returns %d\n%!" v; +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + v + 1 + in + match eff with +@@ -41,7 +41,7 @@ let h (type a) (eff : a t) : ((a, 'b) continuation -> 'b) option = + let v = + let[@inline never] v_retc v = + printf "# done %d\n%!" v; +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + v + 1 + in + match_with f () +diff --git a/testsuite/tests/frame-pointers/effects.reference b/testsuite/tests/frame-pointers/effects.reference +index c8bd0a391a..8ae3fc26df 100644 +--- a/testsuite/tests/frame-pointers/effects.reference ++++ b/testsuite/tests/frame-pointers/effects.reference +@@ -3,39 +3,24 @@ camlEffects.f + caml_runstack + camlEffects.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + # perform effect (E 0) + # caught effect (E 0). continuing... + camlEffects.h_effect_e + camlEffects.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + # perform returns 1 + camlEffects.f + caml_runstack + camlEffects.h_effect_e + camlEffects.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + # done 2 + camlEffects.v_retc + camlEffects.h_effect_e + camlEffects.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + # continue returns 3 + camlEffects.h_effect_e + camlEffects.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + # result=4 +diff --git a/testsuite/tests/frame-pointers/effects.run b/testsuite/tests/frame-pointers/effects.run +deleted file mode 100644 +index e96b5ea13a..0000000000 +--- a/testsuite/tests/frame-pointers/effects.run ++++ /dev/null +@@ -1,4 +0,0 @@ +-#!/bin/sh +- +-${program} 2>&1 \ +- | ${test_source_directory}/filter-locations.sh ${program} >${output} +diff --git a/testsuite/tests/frame-pointers/exception_handler.ml b/testsuite/tests/frame-pointers/exception_handler.ml +index 6bf5bf470d..19773f78de 100644 +--- a/testsuite/tests/frame-pointers/exception_handler.ml ++++ b/testsuite/tests/frame-pointers/exception_handler.ml +@@ -8,7 +8,7 @@ + *) + + (* https://github.com/ocaml/ocaml/pull/11031 *) +-external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] ++external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] + + exception Exn1 + exception Exn2 +@@ -38,7 +38,7 @@ let[@inline never] handler () = + let _ = Sys.opaque_identity x0 in + let _ = Sys.opaque_identity x1 in + let _ = Sys.opaque_identity x2 in +- fp_backtrace () ++ fp_backtrace Sys.argv.(0) + + let[@inline never] nested i = + begin +diff --git a/testsuite/tests/frame-pointers/exception_handler.reference b/testsuite/tests/frame-pointers/exception_handler.reference +index 513ca488b9..e012fb6d4f 100644 +--- a/testsuite/tests/frame-pointers/exception_handler.reference ++++ b/testsuite/tests/frame-pointers/exception_handler.reference +@@ -2,27 +2,15 @@ camlException_handler.handler + camlException_handler.bare + camlException_handler.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + camlException_handler.handler + camlException_handler.bare + camlException_handler.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + camlException_handler.handler + camlException_handler.nested + camlException_handler.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main + camlException_handler.handler + camlException_handler.nested + camlException_handler.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main +diff --git a/testsuite/tests/frame-pointers/exception_handler.run b/testsuite/tests/frame-pointers/exception_handler.run +deleted file mode 100644 +index e96b5ea13a..0000000000 +--- a/testsuite/tests/frame-pointers/exception_handler.run ++++ /dev/null +@@ -1,4 +0,0 @@ +-#!/bin/sh +- +-${program} 2>&1 \ +- | ${test_source_directory}/filter-locations.sh ${program} >${output} +diff --git a/testsuite/tests/frame-pointers/filter-locations.sh b/testsuite/tests/frame-pointers/filter-locations.sh +deleted file mode 100755 +index 31c7fc3189..0000000000 +--- a/testsuite/tests/frame-pointers/filter-locations.sh ++++ /dev/null +@@ -1,23 +0,0 @@ +-#!/bin/sh +- +-set -eu +- +-program="${1}" +-# https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed/29626460#29626460 +-program_escaped=$(echo ${program} | sed 's/[^^\\]/[&]/g; s/\^/\\^/g; s/\\/\\\\/g') +-regex_backtrace='^.*(\(.*\)+0x[[:xdigit:]]*)[0x[[:xdigit:]]*]$' +-regex_trim_fun='^\(caml.*\)_[[:digit:]]*$' +- +-# - Ignore backtrace not coming from the program binary +-# - Discard the number suffix from OCaml function name +-# - Remove strange '[0x.....]' entries inserted by some implementation +-# of backtrace_symbols_fd +-# - Keep the other lines +-sed -e \ +- "/${regex_backtrace}/ { +- /^${program_escaped}/ ! d +- s/${regex_backtrace}/\1/ +- s/${regex_trim_fun}/\1/ +- s;caml_\(main\|startup\);caml_main/caml_startup; +- }" \ +- -e '/^\[0x/d' +diff --git a/testsuite/tests/frame-pointers/fp_backtrace.c b/testsuite/tests/frame-pointers/fp_backtrace.c +index a521218a38..cef7ccd9f2 100644 +--- a/testsuite/tests/frame-pointers/fp_backtrace.c ++++ b/testsuite/tests/frame-pointers/fp_backtrace.c +@@ -1,10 +1,17 @@ + #include +-#include +-#include +-#include ++#include ++#include + #include ++#include ++#include + +-#define ARRSIZE(a) (sizeof(a) / sizeof(*(a))) ++#include "caml/mlvalues.h" ++ ++#define ARR_SIZE(a) (sizeof(a) / sizeof(*(a))) ++ ++#define RE_FUNC_NAME "^.*\\((.+)\\+0x[[:xdigit:]]+\\) \\[0x[[:xdigit:]]+\\]$" ++#define RE_TRIM_FUNC "(caml.*)_[[:digit:]]+" ++#define CAML_ENTRY "caml_program" + + typedef struct frame_info + { +@@ -12,99 +19,138 @@ typedef struct frame_info + void* retaddr; /* rip */ + } frame_info; + +-jmp_buf resume_buf; + ++/* ++ * A backtrace symbol looks like: ++ * ./path/to/binary(camlModule_fn_123+0xAABBCC) [0xAABBCCDDEE] ++ */ ++static const char* backtrace_symbol(const struct frame_info* fi) ++{ ++ char** symbols = backtrace_symbols(&fi->retaddr, 1); ++ if (!symbols) { ++ perror("backtrace_symbols"); ++ return NULL; ++ } ++ ++ const char* symbol = strdup(symbols[0]); ++ free(symbols); ++ return symbol; ++} + +-static void signal_handler(int signum) ++static bool is_from_executable(const char* symbol, const char* execname) + { +- /* Should be safe to be called from a signal handler. +- * See 21.2.1 "Performing a nonlocal goto from a signal handler" from +- * The Linux Programming Interface, Michael Kerrisk */ +- siglongjmp(resume_buf, 1); ++ return strncmp(symbol, execname, strlen(execname)) == 0; + } + +-static int install_signal_handlers(const int signals[], struct sigaction +- handlers[], int count) ++static regmatch_t func_name_from_symbol(const char* symbol) + { +- for (int i = 0; i < count; i++) { +- struct sigaction action = { 0 }; +- action.sa_handler = signal_handler; +- sigemptyset(&action.sa_mask); +- action.sa_flags = 0; +- +- if (sigaction(signals[i], &action, &handlers[i]) != 0) { +- perror("sigaction"); +- return -1; +- } ++ regex_t regex; ++ regmatch_t match[2] = { {-1, -1}, {-1, -1}}; ++ char errbuf[128]; ++ int err; ++ ++ err = regcomp(®ex, RE_FUNC_NAME, REG_EXTENDED); ++ if (err) { ++ regerror(err, ®ex, errbuf, ARR_SIZE(errbuf)); ++ fprintf(stderr, "regcomp: %s\n", errbuf); ++ return match[0]; + } +- return 0; ++ ++ err = regexec(®ex, symbol, ARR_SIZE(match), match, 0); ++ if (err == REG_NOMATCH) ++ return match[0]; ++ ++ return match[1]; + } + +-static int restore_signal_handlers(const int signals[], struct sigaction +- handlers[], int count) ++static bool is_caml_entry(const char* symbol, const regmatch_t* funcname) + { +- for (int i = 0; i < count; i++) { +- if (sigaction(signals[i], &handlers[i], NULL) != 0) { +- perror("sigaction"); +- return -1; +- } +- } +- return 0; ++ //regoff_t len = funcname->rm_eo - funcname->rm_so; ++ //return strnstr(symbol + funcname->rm_so, CAML_ENTRY, len) == 0; ++ return strstr(symbol + funcname->rm_so, CAML_ENTRY) != NULL; + } + +-static int safe_read(const struct frame_info* fi, struct frame_info** prev, +- void** retaddr) ++static regmatch_t trim_func_name(const char* symbol, const regmatch_t* funcname) + { +- /* Signals to ignore while attempting to read frame_info members */ +- const int signals[] = { SIGSEGV, SIGBUS }; +- /* Store original signal handers */ +- struct sigaction handlers[ARRSIZE(signals)] = { 0 }; +- int ret = 0; +- +- if (install_signal_handlers(signals, handlers, ARRSIZE(signals)) != 0) +- return -1; +- +- if (!sigsetjmp(resume_buf, 1)) { +- *prev = fi->prev; +- *retaddr = fi->retaddr; +- } else { +- ret = -1; ++ regex_t regex; ++ regmatch_t match[2] = { {-1, -1}, {-1, -1}}; ++ char errbuf[128]; ++ int err; ++ ++ err = regcomp(®ex, RE_TRIM_FUNC, REG_EXTENDED); ++ if (err) { ++ regerror(err, ®ex, errbuf, ARR_SIZE(errbuf)); ++ fprintf(stderr, "regcomp: %s\n", errbuf); ++ return match[0]; + } + +- if (restore_signal_handlers(signals, handlers, ARRSIZE(signals)) != 0) +- return -1; ++ match[0] = *funcname; ++ err = regexec(®ex, symbol, ARR_SIZE(match), match, REG_STARTEND); ++ if (err == REG_NOMATCH) { ++ /* match[0] has already been overwritten to hold the function full name for ++ regexec */ ++ return match[1]; ++ } + +- return ret; ++ return match[1]; + } + +-static void print_location(void* addr) ++static void print_symbol(const char* symbol, const regmatch_t* match) + { +- if (!addr) +- return; ++ regoff_t off = match->rm_so; ++ regoff_t len = match->rm_eo - match->rm_so; + +- /* This requires the binary to be linked with '-rdynamic' */ +- backtrace_symbols_fd(&addr, 1, STDOUT_FILENO); ++ fprintf(stdout, "%.*s\n", len, symbol + off); ++ fflush(stdout); + } + +-void fp_backtrace(void) ++void fp_backtrace(value argv0) + { +- struct frame_info *fi; +- struct frame_info* next; +- void* retaddr; ++ const char* execname = String_val(argv0); ++ struct frame_info* next = NULL; ++ const char* symbol = NULL; + +- fi = __builtin_frame_address(0); +- retaddr = __builtin_extract_return_addr(__builtin_return_address(0)); +- +- for (; fi; fi = next) { +- if (safe_read(fi, &next, &retaddr) != 0) +- return; +- +- print_location(retaddr); ++ for (struct frame_info* fi = __builtin_frame_address(0); fi; fi = next) { ++ next = fi->prev; + + /* Detect the simplest kind of infinite loop */ + if (fi == next) { +- printf("fp_backtrace: loop detected\n"); +- return; ++ fprintf(stderr, "fp_backtrace: loop detected\n"); ++ break; + } ++ ++ symbol = backtrace_symbol(fi); ++ if (!symbol) ++ continue; ++ ++ /* Skip entries not from the test */ ++ if (!is_from_executable(symbol, execname)) ++ goto skip; ++ ++ /* Exctract the full function name */ ++ regmatch_t funcname = func_name_from_symbol(symbol); ++ if (funcname.rm_so == -1) ++ goto skip; ++ ++ /* Trim numeric suffix from caml functions */ ++ regmatch_t functrimmed = trim_func_name(symbol, &funcname); ++ ++ /* Use the trimmed caml name if available, otherwise use the full function ++ name */ ++ const regmatch_t* match = (functrimmed.rm_so != -1) ? ++ &functrimmed : &funcname; ++ ++ print_symbol(symbol, match); ++ ++ /* Stop the backtrace at caml_program */ ++ if (is_caml_entry(symbol, &funcname)) ++ break; ++ ++skip: ++ free((void*)symbol); ++ symbol = NULL; + } ++ ++ if (symbol) ++ free((void*)symbol); + } +diff --git a/testsuite/tests/frame-pointers/reperform.ml b/testsuite/tests/frame-pointers/reperform.ml +index ec5393907c..7a3b09162b 100644 +--- a/testsuite/tests/frame-pointers/reperform.ml ++++ b/testsuite/tests/frame-pointers/reperform.ml +@@ -11,7 +11,7 @@ + open Effect + open Effect.Deep + +-external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] ++external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] + + type _ Effect.t += E : unit t + | F : unit t +@@ -22,7 +22,7 @@ let rec foo n = + if n = 5 then begin + perform E; + print_endline "# resumed..."; +- fp_backtrace () ++ fp_backtrace Sys.argv.(0) + end; + foo (n + 1) + n + end +diff --git a/testsuite/tests/frame-pointers/reperform.reference b/testsuite/tests/frame-pointers/reperform.reference +index 9ac6681d4b..e215f77169 100644 +--- a/testsuite/tests/frame-pointers/reperform.reference ++++ b/testsuite/tests/frame-pointers/reperform.reference +@@ -15,6 +15,3 @@ camlReperform.bar + caml_runstack + camlReperform.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main +diff --git a/testsuite/tests/frame-pointers/reperform.run b/testsuite/tests/frame-pointers/reperform.run +deleted file mode 100644 +index e96b5ea13a..0000000000 +--- a/testsuite/tests/frame-pointers/reperform.run ++++ /dev/null +@@ -1,4 +0,0 @@ +-#!/bin/sh +- +-${program} 2>&1 \ +- | ${test_source_directory}/filter-locations.sh ${program} >${output} +diff --git a/testsuite/tests/frame-pointers/stack_realloc.ml b/testsuite/tests/frame-pointers/stack_realloc.ml +index fc4e9e9d3b..cacc43c216 100644 +--- a/testsuite/tests/frame-pointers/stack_realloc.ml ++++ b/testsuite/tests/frame-pointers/stack_realloc.ml +@@ -13,7 +13,7 @@ open Effect.Deep + + type _ t += E : int -> int t + +-external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] ++external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] + external c_fun : unit -> int = "c_fun" + + let[@inline never][@local never] f x = x +@@ -42,7 +42,7 @@ let[@inline never] consume_stack () = + + let[@inline never] callback () = + consume_stack (); +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + 0 + + let _ = Callback.register "callback" callback +diff --git a/testsuite/tests/frame-pointers/stack_realloc.reference b/testsuite/tests/frame-pointers/stack_realloc.reference +index 016a03550a..e61d4104e0 100644 +--- a/testsuite/tests/frame-pointers/stack_realloc.reference ++++ b/testsuite/tests/frame-pointers/stack_realloc.reference +@@ -7,6 +7,3 @@ camlStack_realloc.f_comp + caml_runstack + camlStack_realloc.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main +diff --git a/testsuite/tests/frame-pointers/stack_realloc.run b/testsuite/tests/frame-pointers/stack_realloc.run +deleted file mode 100644 +index e96b5ea13a..0000000000 +--- a/testsuite/tests/frame-pointers/stack_realloc.run ++++ /dev/null +@@ -1,4 +0,0 @@ +-#!/bin/sh +- +-${program} 2>&1 \ +- | ${test_source_directory}/filter-locations.sh ${program} >${output} +diff --git a/testsuite/tests/frame-pointers/stack_realloc2.ml b/testsuite/tests/frame-pointers/stack_realloc2.ml +index a4aea249ea..b2a602fa4a 100644 +--- a/testsuite/tests/frame-pointers/stack_realloc2.ml ++++ b/testsuite/tests/frame-pointers/stack_realloc2.ml +@@ -13,7 +13,7 @@ open Effect.Deep + + type _ t += E : int -> int t + +-external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] ++external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] + external c_fun : unit -> int = "c_fun" + + let[@inline never][@local never] f x = x +@@ -41,7 +41,7 @@ let[@inline never] consume_stack () = + ignore (gobbler count) + + let[@inline never] callback () = +- fp_backtrace (); ++ fp_backtrace Sys.argv.(0); + 0 + + let _ = Callback.register "callback" callback +diff --git a/testsuite/tests/frame-pointers/stack_realloc2.reference b/testsuite/tests/frame-pointers/stack_realloc2.reference +index ae492abd88..0051f3bad0 100644 +--- a/testsuite/tests/frame-pointers/stack_realloc2.reference ++++ b/testsuite/tests/frame-pointers/stack_realloc2.reference +@@ -7,6 +7,3 @@ camlStack_realloc2.f_comp + caml_runstack + camlStack_realloc2.entry + caml_program +-caml_start_program +-caml_main/caml_startup +-main +diff --git a/testsuite/tests/frame-pointers/stack_realloc2.run b/testsuite/tests/frame-pointers/stack_realloc2.run +deleted file mode 100644 +index e96b5ea13a..0000000000 +--- a/testsuite/tests/frame-pointers/stack_realloc2.run ++++ /dev/null +@@ -1,4 +0,0 @@ +-#!/bin/sh +- +-${program} 2>&1 \ +- | ${test_source_directory}/filter-locations.sh ${program} >${output} +-- +2.41.0 + diff --git a/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch b/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch deleted file mode 100644 index 846f0be..0000000 --- a/0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch +++ /dev/null @@ -1,39 +0,0 @@ -From ea8b79eda165722d04b369f1811a5aa80ab5acc6 Mon Sep 17 00:00:00 2001 -From: SSHz -Date: Sun, 27 Nov 2022 14:46:16 +0000 -Subject: [PATCH 04/17] removed set but unused variables in yacc/reader.c - (#11758) - -(cherry picked from commit 0114f62d3ed056254ac25192f724e92a2ff6c448) ---- - yacc/reader.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/yacc/reader.c b/yacc/reader.c -index 7377967994..7a0b888961 100644 ---- a/yacc/reader.c -+++ b/yacc/reader.c -@@ -1049,12 +1049,10 @@ void read_declarations(void) - void output_token_type(void) - { - bucket * bp; -- int n; - - fprintf(interface_file, "type token =\n"); - if (!rflag) ++outline; - fprintf(output_file, "type token =\n"); -- n = 0; - for (bp = first_symbol; bp; bp = bp->next) { - if (bp->class == TERM && bp->true_token) { - fprintf(interface_file, " | %s", bp->name); -@@ -1068,7 +1066,6 @@ void output_token_type(void) - fprintf(interface_file, "\n"); - if (!rflag) ++outline; - fprintf(output_file, "\n"); -- n++; - } - } - fprintf(interface_file, "\n"); --- -2.41.0 - diff --git a/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch b/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch deleted file mode 100644 index 8421941..0000000 --- a/0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 848e28fc6f3f3c9802b23c00f2d77f568c761667 Mon Sep 17 00:00:00 2001 -From: Gabriel Scherer -Date: Tue, 3 Jan 2023 17:41:12 +0100 -Subject: [PATCH 05/17] Merge pull request #11860 from - Octachron/index_for_stdlib - -documentation: sort modules alphabetically - -fixes #11857 - -(cherry picked from commit 14004c6d4bedadb7215ded2c77230270e52307ff) ---- - api_docgen/Makefile.docfiles | 24 +++++++++++++++--------- - 1 file changed, 15 insertions(+), 9 deletions(-) - -diff --git a/api_docgen/Makefile.docfiles b/api_docgen/Makefile.docfiles -index 0c2412b192..f12830b1ec 100644 ---- a/api_docgen/Makefile.docfiles -+++ b/api_docgen/Makefile.docfiles -@@ -26,10 +26,6 @@ define capitalize - $(foreach m,$(1),$(call capitalize_one,$m)) - endef - --define sort --$(shell $(OCAMLDEP) -sort $(1)) --endef -- - runtime_events_MLIS := runtime_events.mli - str_MLIS := str.mli - unix_MLIS := unix.mli unixLabels.mli -@@ -62,10 +58,8 @@ endif - libref_TEXT=Ocaml_operators Format_tutorial - libref_C=$(call capitalize,$(libref)) - --PARSING_MLIS := $(call sort, \ -- $(notdir $(wildcard $(ROOTDIR)/parsing/*.mli))\ --) --UTILS_MLIS := $(call sort,$(notdir $(wildcard $(ROOTDIR)/utils/*.mli))) -+PARSING_MLIS := $(notdir $(wildcard $(ROOTDIR)/parsing/*.mli)) -+UTILS_MLIS := $(notdir $(wildcard $(ROOTDIR)/utils/*.mli)) - DRIVER_MLIS := pparse.mli - - compilerlibref_MLIS= \ -@@ -76,8 +70,20 @@ compilerlibref=$(compilerlibref_MLIS:%.mli=%) - compilerlibref_TEXT=Compiler_libs - compilerlibref_C=$(call capitalize,$(compilerlibref)) - --ALL_LIBREF= $(libref_TEXT:%=libref/%) $(libref:%=libref/%) -+ALL_LIBREF= \ -+ $(sort $(libref_TEXT:%=libref/%)) \ -+ $(sort $(filter-out libref/camlinternal%, $(libref:%=libref/%))) \ -+ $(sort $(filter libref/camlinternal%, $(libref:%=libref/%))) -+ - ALL_COMPILERLIBREF= \ - $(compilerlibref_TEXT:%=compilerlibref/%) \ - $(compilerlibref:%=compilerlibref/%) -+# Note that the output of $(wildcard ...) is sorted alphabetically. -+# The compilerlibs index will be thus be sorted first by category: -+# - text documentation -+# - parsing modules -+# - utils modules -+# - driver modules -+# And then alphabetically inside each category. -+ - ALL_DOC= $(ALL_LIBREF) $(ALL_COMPILERLIBREF) --- -2.41.0 - diff --git a/0006-Allow-installing-in-folder-with-space-in-name-11590.patch b/0006-Allow-installing-in-folder-with-space-in-name-11590.patch deleted file mode 100644 index ed6c490..0000000 --- a/0006-Allow-installing-in-folder-with-space-in-name-11590.patch +++ /dev/null @@ -1,42 +0,0 @@ -From a3cd42bc03ed0fc706bb7364fdb14b29b1925600 Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Wed, 4 Jan 2023 16:33:28 +0000 -Subject: [PATCH 06/17] Allow installing in folder with space in name (#11590) - -- fix(build): Repair make install (in man/Makefile) ---- - Changes | 8 ++++++++ - man/Makefile | 4 ++-- - 2 files changed, 10 insertions(+), 2 deletions(-) - -diff --git a/Changes b/Changes -index 776f6e7a45..438c0f3ec2 100644 ---- a/Changes -+++ b/Changes -@@ -1,3 +1,11 @@ -+OCaml 5.0 maintenance version -+----------------------------- -+ -+### Build system: -+ -+- #11590: Allow installing to a destination path containing spaces. -+ (Élie Brami, review by Sébastien Hinderer and David Allsopp) -+ - OCaml 5.0 (16 December 2022) - ---------------------------- - -diff --git a/man/Makefile b/man/Makefile -index 36d3126563..10cc8bbe41 100644 ---- a/man/Makefile -+++ b/man/Makefile -@@ -22,5 +22,5 @@ MANPAGES = $(addsuffix .1,\ - - .PHONY: install - install: -- $(MKDIR) $(INSTALL_PROGRAMS_MAN_DIR) -- $(INSTALL_DATA) $(MANPAGES) $(INSTALL_PROGRAMS_MAN_DIR) -+ $(MKDIR) '$(INSTALL_PROGRAMS_MAN_DIR)' -+ $(INSTALL_DATA) $(MANPAGES) '$(INSTALL_PROGRAMS_MAN_DIR)' --- -2.41.0 - diff --git a/0007-Detect-unused-Makefile-variables-in-workflow.patch b/0007-Detect-unused-Makefile-variables-in-workflow.patch deleted file mode 100644 index 0af534d..0000000 --- a/0007-Detect-unused-Makefile-variables-in-workflow.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 44f4015f9a649e164b332e6ab1302139191d4a4f Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Wed, 3 Mar 2021 12:24:36 +0000 -Subject: [PATCH 07/17] Detect unused Makefile variables in workflow - ---- - tools/ci/actions/runner.sh | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh -index ede27f710a..26123b40d1 100755 ---- a/tools/ci/actions/runner.sh -+++ b/tools/ci/actions/runner.sh -@@ -21,6 +21,8 @@ PREFIX=~/local - MAKE="make $MAKE_ARG" - SHELL=dash - -+MAKE_WARN="$MAKE --warn-undefined-variables" -+ - export PATH=$PREFIX/bin:$PATH - - Configure () { -@@ -60,9 +62,18 @@ EOF - } - - Build () { -- $MAKE world.opt -+ if [ "$(uname)" = 'Darwin' ]; then -+ script -q build.log $MAKE_WARN -+ else -+ script --return --command "$MAKE_WARN" build.log -+ fi - echo Ensuring that all names are prefixed in the runtime - ./tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a -+ if grep -Fq ' warning: undefined variable ' build.log; then -+ echo Undefined Makefile variables detected -+ exit 1 -+ fi -+ rm build.log - } - - Test () { --- -2.41.0 - diff --git a/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch b/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch deleted file mode 100644 index 504a5fd..0000000 --- a/0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 2eccdd3cd78624b0f2664d6152afbcae167f6f8b Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Mon, 20 Feb 2023 20:27:58 +0000 -Subject: [PATCH 08/17] Fix incorrect variable from runtime/Makefile merge - -Wrong CPPFLAGS used when assembling with ASPP. ---- - Makefile | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/Makefile b/Makefile -index bb2c245eab..3ea3296c7f 100644 ---- a/Makefile -+++ b/Makefile -@@ -952,6 +952,15 @@ ASPP_ERROR = \ - runtime/%.o: runtime/%.S - $(ASPP) $(OC_ASPPFLAGS) -o $@ $< || $(ASPP_ERROR) - -+# $(OC_DEBUG_CPPFLAGS) and $(OC_INSTR_CPPFLAGS) are still used in the two -+# recipes just below instead of the correct $(ocamlrund_CPPFLAGS) and -+# $(ocamlruni_CPPFLAGS). This has been fixed on trunk, but in the -+# 5.0 maintenance branch here we just define default values for those OC_* -+# variables to avoid an undefined-variable warning, preserving exactly the -+# (somewhat strange) behaviour of the 5.0.0 release. -+OC_DEBUG_CPPFLAGS ?= -+OC_INSTR_CPPFLAGS ?= -+ - runtime/%.d.o: runtime/%.S - $(ASPP) $(OC_ASPPFLAGS) $(OC_DEBUG_CPPFLAGS) -o $@ $< || $(ASPP_ERROR) - --- -2.41.0 - diff --git a/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch b/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch deleted file mode 100644 index cdb8e60..0000000 --- a/0009-Provide-a-default-for-OCAMLDEPFLAGS.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 5f3f8bf734bdc02adc69cf92f066547bd71e8a25 Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Mon, 20 Feb 2023 20:31:31 +0000 -Subject: [PATCH 09/17] Provide a default for $(OCAMLDEPFLAGS) - ---- - Makefile.common | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Makefile.common b/Makefile.common -index 536e2a28ca..e2a9176a5c 100644 ---- a/Makefile.common -+++ b/Makefile.common -@@ -169,6 +169,7 @@ endef # PROGRAM_SYNONYM - # should take place *before* Makefile.common is included. - - OCAMLDEP ?= $(BEST_OCAMLDEP) -+OCAMLDEPFLAGS ?= - OC_OCAMLDEPFLAGS = -slash - OC_OCAMLDEPDIRS = - OCAMLDEP_CMD = $(OCAMLDEP) $(OC_OCAMLDEPFLAGS) \ --- -2.41.0 - diff --git a/0010-Report-all-post-build-failures.patch b/0010-Report-all-post-build-failures.patch deleted file mode 100644 index 952529f..0000000 --- a/0010-Report-all-post-build-failures.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 7f4569e22c2a19d51324c44a2954b10427df2cd8 Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Tue, 21 Feb 2023 14:44:21 +0000 -Subject: [PATCH 10/17] Report all post-build failures - -Rather than just reporting un-prefixed symbol names, also report -undefined variables. ---- - tools/ci/actions/runner.sh | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh -index 26123b40d1..6e5a30f73a 100755 ---- a/tools/ci/actions/runner.sh -+++ b/tools/ci/actions/runner.sh -@@ -67,13 +67,19 @@ Build () { - else - script --return --command "$MAKE_WARN" build.log - fi -- echo Ensuring that all names are prefixed in the runtime -- ./tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a -+ failed=0 - if grep -Fq ' warning: undefined variable ' build.log; then - echo Undefined Makefile variables detected -- exit 1 -+ failed=1 - fi - rm build.log -+ echo Ensuring that all names are prefixed in the runtime -+ if ! ./tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a ; then -+ failed=1 -+ fi -+ if ((failed)); then -+ exit 1 -+ fi - } - - Test () { --- -2.41.0 - diff --git a/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch b/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch deleted file mode 100644 index 543afca..0000000 --- a/0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0f6dc503bf3814e5547ffb4e9d6ea0a75ffd1ec0 Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Wed, 22 Feb 2023 10:47:00 +0000 -Subject: [PATCH 11/17] Finish off removal of FORCE_INSTRUMENTED_RUNTIME - ---- - utils/Makefile | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/utils/Makefile b/utils/Makefile -index 0fcbc59ce5..efd8574fa5 100644 ---- a/utils/Makefile -+++ b/utils/Makefile -@@ -90,7 +90,6 @@ config_main.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile config.common.ml - $(call SUBST,FUNCTION_SECTIONS) \ - $(call SUBST,CC_HAS_DEBUG_PREFIX_MAP) \ - $(call SUBST,AS_HAS_DEBUG_PREFIX_MAP) \ -- $(call SUBST,FORCE_INSTRUMENTED_RUNTIME) \ - $< > $@ - cat config.common.ml >> $@ - --- -2.41.0 - diff --git a/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch b/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch deleted file mode 100644 index d0416ba..0000000 --- a/0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch +++ /dev/null @@ -1,27 +0,0 @@ -From ffb2022797986324213891a59c02af46269b5c17 Mon Sep 17 00:00:00 2001 -From: Damien Doligez -Date: Mon, 17 Apr 2023 11:36:32 +0200 -Subject: [PATCH 12/17] suppress spurious alert when compiling stdlib - documentation - -(cherry picked from commit 5c0fb8e23865fdbf151bdbe15d91176903c284d3) ---- - api_docgen/ocamldoc/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/api_docgen/ocamldoc/Makefile b/api_docgen/ocamldoc/Makefile -index 1b3d5f57f7..b6419ae50d 100644 ---- a/api_docgen/ocamldoc/Makefile -+++ b/api_docgen/ocamldoc/Makefile -@@ -44,7 +44,7 @@ $(libref:%=build/libref/%.odoc): build/libref/%.odoc: %.mli | build/libref - $(OCAMLDOC_RUN) -nostdlib -hide Stdlib -lib Stdlib \ - -pp \ - "$(AWK) -v ocamldoc=true -f ../../stdlib/expand_module_aliases.awk" \ -- $(DOC_STDLIB_INCLUDES) -hide-warnings $< -dump $@ -+ $(DOC_STDLIB_INCLUDES) -hide-warnings -alert -all $< -dump $@ - - $(compilerlibref:%=build/compilerlibref/%.odoc):\ - build/compilerlibref/%.odoc: %.mli | build/compilerlibref --- -2.41.0 - diff --git a/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch b/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch deleted file mode 100644 index 519c245..0000000 --- a/0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 4cc4eb8b0d71c64c5252d6764f4c4b0aa6020995 Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Sat, 3 Jun 2023 18:02:24 +0100 -Subject: [PATCH 13/17] Merge pull request #12285 from - smorimoto/update-deprecated-actions - -Update deprecated GitHub Actions - -(cherry picked from commit eadb05a504e0738f246a7dc846a442793005a27a) ---- - .github/workflows/build.yml | 8 ++++---- - .github/workflows/hygiene.yml | 2 +- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml -index ae0fcace20..933c14a926 100644 ---- a/.github/workflows/build.yml -+++ b/.github/workflows/build.yml -@@ -18,7 +18,7 @@ jobs: - manual_changed: ${{ steps.manual.outputs.manual_changed }} - steps: - - name: Checkout -- uses: actions/checkout@v2 -+ uses: actions/checkout@v3 - - name: Check for manual changes - id: manual - run: >- -@@ -45,7 +45,7 @@ jobs: - git config --local --unset http.https://github.com/.extraheader - tar --zstd -cf /tmp/sources.tar.zstd . - - name: Upload Artifact -- uses: actions/upload-artifact@v2 -+ uses: actions/upload-artifact@v3 - with: - name: compiler - path: /tmp/sources.tar.zstd -@@ -57,7 +57,7 @@ jobs: - runs-on: ubuntu-latest - steps: - - name: Download Artifact -- uses: actions/download-artifact@v2 -+ uses: actions/download-artifact@v3 - with: - name: compiler - - name: Unpack Artifact -@@ -137,7 +137,7 @@ jobs: - - debug-s4096 - steps: - - name: Download artifact -- uses: actions/download-artifact@v2 -+ uses: actions/download-artifact@v3 - with: - name: compiler - - name: Unpack Artifact -diff --git a/.github/workflows/hygiene.yml b/.github/workflows/hygiene.yml -index e89efd2f47..3b2e10795f 100644 ---- a/.github/workflows/hygiene.yml -+++ b/.github/workflows/hygiene.yml -@@ -17,7 +17,7 @@ jobs: - # context variable. - if: failure() - -- - uses: actions/checkout@v2 -+ - uses: actions/checkout@v3 - with: - fetch-depth: 50 - --- -2.41.0 - diff --git a/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch b/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch deleted file mode 100644 index c29b0c7..0000000 --- a/0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch +++ /dev/null @@ -1,40 +0,0 @@ -From af3a67cd06e07825c63b70a038cf90481039b1ed Mon Sep 17 00:00:00 2001 -From: David Allsopp -Date: Fri, 9 Jun 2023 21:47:51 +0100 -Subject: [PATCH 14/17] Merge pull request #12286 from - smorimoto/replace-set-output - -Replace the set-output command with the GITHUB_OUTPUT environment file - -(cherry picked from commit 50054a632a5ac3bb4199276617d358e3fa4a108b) ---- - tools/ci/actions/check-manual-modified.sh | 2 +- - tools/ci/actions/runner.sh | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tools/ci/actions/check-manual-modified.sh b/tools/ci/actions/check-manual-modified.sh -index dc8b6bd809..c5826c1fd0 100755 ---- a/tools/ci/actions/check-manual-modified.sh -+++ b/tools/ci/actions/check-manual-modified.sh -@@ -32,4 +32,4 @@ else - fi - - echo "Manual altered: $result" --echo "::set-output name=manual_changed::$result" -+echo "manual_changed=$result" >>"$GITHUB_OUTPUT" -diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh -index 6e5a30f73a..295e58a83e 100755 ---- a/tools/ci/actions/runner.sh -+++ b/tools/ci/actions/runner.sh -@@ -159,7 +159,7 @@ ReportBuildStatus () { - else - STATUS='success' - fi -- echo "::set-output name=build-status::$STATUS" -+ echo "build-status=$STATUS" >>"$GITHUB_OUTPUT" - exit $CODE - } - --- -2.41.0 - diff --git a/0015-Don-t-add-rpaths-to-libraries.patch b/0015-Don-t-add-rpaths-to-libraries.patch deleted file mode 100644 index 74c6dfa..0000000 --- a/0015-Don-t-add-rpaths-to-libraries.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0e07dfdb530734ef4db351ecc24c6363e36916ec Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 15/17] 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 7e1848f433..811d9134dd 100644 ---- a/utils/config.mlp -+++ b/utils/config.mlp -@@ -42,8 +42,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.41.0 - diff --git a/0016-configure-Allow-user-defined-C-compiler-flags.patch b/0016-configure-Allow-user-defined-C-compiler-flags.patch deleted file mode 100644 index a3d322a..0000000 --- a/0016-configure-Allow-user-defined-C-compiler-flags.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 9d3722c87ab15dfbc4e1a934e09ddc8253712d9c Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 16/17] configure: Allow user defined C compiler flags. - ---- - configure.ac | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/configure.ac b/configure.ac -index a7974b0426..8068de3cfc 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -670,6 +670,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" -+ - # Enable SSE2 on x86 mingw to avoid using 80-bit registers. - AS_CASE([$host], - [i686-*-mingw32], --- -2.41.0 - diff --git a/0017-Fix-skiplist-test-failure-12346.patch b/0017-Fix-skiplist-test-failure-12346.patch deleted file mode 100644 index 87219e7..0000000 --- a/0017-Fix-skiplist-test-failure-12346.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 74b0eee42f616cb05c640c0ceac0cc391e4a7ef1 Mon Sep 17 00:00:00 2001 -From: Jerry James -Date: Fri, 7 Jul 2023 07:07:09 -0600 -Subject: [PATCH 17/17] Fix skiplist test failure (#12346) - -Fix -Wmaybe-uninitialized warning in skiplist test -Fix -Wunused-variable warning in skiplist test - -Co-authored-by: Xavier Leroy -(cherry picked from commit 3027e3308d685af03caf4f605b4bec55b04ed28e) -(cherry picked from commit 9aa7761060a7c40d11237599382b892dbcb79cb5) ---- - testsuite/tests/lf_skiplist/stubs.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/testsuite/tests/lf_skiplist/stubs.c b/testsuite/tests/lf_skiplist/stubs.c -index 991483e408..acc0eaf9cf 100644 ---- a/testsuite/tests/lf_skiplist/stubs.c -+++ b/testsuite/tests/lf_skiplist/stubs.c -@@ -64,7 +64,7 @@ static int get_len(struct lf_skipcell *p, struct lf_skipcell *end) { - static uintnat count_marks(struct lf_skiplist *sk) { - uintnat r = 0; - struct lf_skipcell *p = sk->head; -- uintptr_t succ; -+ uintptr_t succ = 0; - - while (p) { - for (int k = p->top_level; k >= 0; k--) { -@@ -135,7 +135,6 @@ inline static uintnat calc_right(uintnat id,uintnat turn,uintnat ndoms) { return - CAMLprim value insert_skiplist(value turn_val,value ndoms_val,value domain_id_val) { - CAMLparam3(turn_val,ndoms_val,domain_id_val); - uintnat domain_id = Long_val(domain_id_val); -- uintnat ndoms = Long_val(ndoms_val); - uintnat turn = Long_val(turn_val); - uintnat k = calc_key(domain_id,turn) ; - uintnat v = calc_value(domain_id) ; --- -2.41.0 - diff --git a/macros.ocaml-rpm b/macros.ocaml-rpm new file mode 100644 index 0000000..ac94c48 --- /dev/null +++ b/macros.ocaml-rpm @@ -0,0 +1,69 @@ +# 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 78683d0..2669eac 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -1,6 +1,12 @@ # Don't add -Wl,-dT, %undefine _package_note_flags +# OCaml 5.1 broke building with LTO. A file prims.c is generated with primitive +# function declarations, all with "void" for their parameter list. This does +# not match the real definitions, leading to lots of -Wlto-type-mismatch +# warnings. These change the output of the tests, leading to many failed tests. +%global _lto_cflags %{nil} + # OCaml has a bytecode backend that works on anything with a C # compiler, and a native code backend available on a subset of # architectures. A further subset of architectures support native @@ -23,7 +29,7 @@ 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 aarch64 %{power64} riscv64 x86_64 +%global test_arches aarch64 %{power64} riscv64 s390x 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 @@ -36,8 +42,8 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.0.0 -Release: 4%{?dist} +Version: 5.1.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -46,6 +52,8 @@ License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception URL: https://www.ocaml.org Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{version}.tar.gz +Source1: macros.ocaml-rpm +Source2: ocaml_files.py # IMPORTANT NOTE: # @@ -56,44 +64,33 @@ Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{vers # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-39-5.0.0 +# Current branch: fedora-40-5.1.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 5.0.0 was released. -Patch: 0001-increment-version-number-after-tagging-5.0.0.patch -Patch: 0002-Merge-pull-request-11814-from-gasche-clarify-DLS.new.patch -Patch: 0003-Add-KC-Sivaramakrishnan-as-author.patch -Patch: 0004-removed-set-but-unused-variables-in-yacc-reader.c-11.patch -Patch: 0005-Merge-pull-request-11860-from-Octachron-index_for_st.patch -Patch: 0006-Allow-installing-in-folder-with-space-in-name-11590.patch -Patch: 0007-Detect-unused-Makefile-variables-in-workflow.patch -Patch: 0008-Fix-incorrect-variable-from-runtime-Makefile-merge.patch -Patch: 0009-Provide-a-default-for-OCAMLDEPFLAGS.patch -Patch: 0010-Report-all-post-build-failures.patch -Patch: 0011-Finish-off-removal-of-FORCE_INSTRUMENTED_RUNTIME.patch -Patch: 0012-suppress-spurious-alert-when-compiling-stdlib-docume.patch -Patch: 0013-Merge-pull-request-12285-from-smorimoto-update-depre.patch -Patch: 0014-Merge-pull-request-12286-from-smorimoto-replace-set-.patch +# Patches added after 5.1.0 was released. # Fedora-specific patches -Patch: 0015-Don-t-add-rpaths-to-libraries.patch -Patch: 0016-configure-Allow-user-defined-C-compiler-flags.patch - -# Fix skiplist test failure -# https://github.com/ocaml/ocaml/pull/12346 -Patch: 0017-Fix-skiplist-test-failure-12346.patch +Patch: 0001-Don-t-add-rpaths-to-libraries.patch +Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch +# https://github.com/ocaml/ocaml/pull/12530 +Patch: 0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch +# https://github.com/ocaml/ocaml/pull/11594 +Patch: 0004-Update-framepointers-tests-to-avoid-false-positive-w.patch BuildRequires: make BuildRequires: git BuildRequires: gcc BuildRequires: autoconf BuildRequires: gawk +BuildRequires: hardlink +BuildRequires: parallel BuildRequires: perl-interpreter BuildRequires: util-linux BuildRequires: /usr/bin/annocheck +BuildRequires: pkgconfig(libzstd) # Documentation requirements BuildRequires: asciidoc @@ -101,17 +98,19 @@ BuildRequires: python3-pygments # 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, since OCaml 5.0 +# Force ocaml-srpm-macros to be at the latest version, since OCaml 5.1 # has a different set of native code generators than previous versions. -Requires: ocaml-srpm-macros >= 8 +Requires: ocaml-srpm-macros >= 9 # Bundles an MD5 implementation in runtime/caml/md5.h and runtime/md5.c Provides: bundled(md5-plumb) @@ -137,6 +136,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} @@ -197,6 +200,20 @@ 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: @@ -214,6 +231,9 @@ make=make # 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 # @@ -295,58 +315,54 @@ 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 + +# Link, rather than copy, identical binaries +hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs + %files %license LICENSE %{_bindir}/ocaml %{_bindir}/ocamlcmt +%{_bindir}/ocamlcp %{_bindir}/ocamldebug +%{_bindir}/ocamlmklib +%{_bindir}/ocamlmktop +%{_bindir}/ocamlprof %{_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}/ocamlopt -%{_bindir}/ocamlopt.byte -%{_bindir}/ocamlopt.opt %endif %if %{native_compiler} %{_bindir}/ocamlnat +%{_bindir}/ocamlopt +%{_bindir}/ocamlopt.byte +%{_bindir}/ocamlopt.opt +%{_bindir}/ocamloptp %endif %{_libdir}/ocaml/camlheader @@ -398,9 +414,6 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml %{_libdir}/ocaml/dynlink/META %{_libdir}/ocaml/dynlink/*.cmi %{_libdir}/ocaml/dynlink/*.cma -%dir %{_libdir}/ocaml/ocamlmktop -%{_libdir}/ocaml/ocamlmktop/*.cmo -%{_libdir}/ocaml/ocamlmktop/*.cmi %dir %{_libdir}/ocaml/profiling %{_libdir}/ocaml/profiling/*.cmo %{_libdir}/ocaml/profiling/*.cmi @@ -448,7 +461,19 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ocaml %{_libdir}/ocaml/compiler-libs +%files rpm-macros +%{rpmmacrodir}/macros.ocaml-rpm +%{_rpmconfigdir}/redhat/ocaml_files.py + + %changelog +* 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 diff --git a/ocaml_files.py b/ocaml_files.py new file mode 100644 index 0000000..cf4afd1 --- /dev/null +++ b/ocaml_files.py @@ -0,0 +1,451 @@ +# 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 3a87a72..1da2f82 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.0.0.tar.gz) = c0cd445bdc2de5d45aae9aea78aab116807cc6782efbcb624a5843e2c0821ccb1e307cc23724f9636918495305cadc75abf04395cd9ede28597774ab60948167 +SHA512 (ocaml-5.1.0.tar.gz) = 814ea71de656eadc59a658ad3b6c4d786815c348ab883b1cdb22d5d0f99d11768f5646f03725f6b44c3b8f4ffeb71e89dadaea157711a7afbe86f23846fc5b52 From c37874e2662370f4998145cbc1a39eb7bcfb809e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Oct 2023 09:58:44 +0100 Subject: [PATCH 62/91] Add upstream patch added after 5.1.0 --- 0001-Fix-variance-composition-12623.patch | 176 ++++++++++++++++++ ...> 0002-Don-t-add-rpaths-to-libraries.patch | 6 +- ...-Allow-user-defined-C-compiler-flags.patch | 6 +- ...elivery-of-effect-related-exceptions.patch | 6 +- ...ters-tests-to-avoid-false-positive-w.patch | 38 ++-- ocaml.spec | 14 +- 6 files changed, 213 insertions(+), 33 deletions(-) create mode 100644 0001-Fix-variance-composition-12623.patch rename 0001-Don-t-add-rpaths-to-libraries.patch => 0002-Don-t-add-rpaths-to-libraries.patch (79%) rename 0002-configure-Allow-user-defined-C-compiler-flags.patch => 0003-configure-Allow-user-defined-C-compiler-flags.patch (89%) rename 0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch => 0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch (84%) rename 0004-Update-framepointers-tests-to-avoid-false-positive-w.patch => 0005-Update-framepointers-tests-to-avoid-false-positive-w.patch (97%) diff --git a/0001-Fix-variance-composition-12623.patch b/0001-Fix-variance-composition-12623.patch new file mode 100644 index 0000000..34db2ab --- /dev/null +++ b/0001-Fix-variance-composition-12623.patch @@ -0,0 +1,176 @@ +From 4c03e721b4c53240a9091790acb401b27e72dce0 Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Wed, 4 Oct 2023 10:05:44 +0200 +Subject: [PATCH 1/5] Fix variance composition (#12623) + +Possible positive occurrence under possible negative occurrence were +forgotten, making the typechecker accepts the absurd statement + + type -'a n + type +'a p + type +'a ko = 'a p n + +(cherry picked from commit 1a9c45317b2c6c9ca9b4cb95fe4891f9f1a2820e) +--- + Changes | 8 +++ + boot/ocamlc | Bin 3051798 -> 3051796 bytes + boot/ocamllex | Bin 391863 -> 391861 bytes + testsuite/tests/typing-misc/variance.ml | 87 ++++++++++++++++++++++++ + typing/types.ml | 2 +- + 5 files changed, 96 insertions(+), 1 deletion(-) + +diff --git a/Changes b/Changes +index 20b7b8ee22..dccdc9baba 100644 +--- a/Changes ++++ b/Changes +@@ -1,3 +1,11 @@ ++OCaml 5.1.1 ++----------- ++ ++### Bug fixes: ++ ++- #12623, fix the computation of variance composition ++ (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer) ++ + OCaml 5.1.0 (14 September 2023) + ------------------------------- + +diff --git a/boot/ocamlc b/boot/ocamlc +index f3b2cba8df84a5f1326c7fe7bdf12b85159f65b3..4db4d848dbc3c2411a9e6160e9d932dd7ba35a34 100755 +GIT binary patch +delta 244 +zcmZ9=y)pw)7zW@yD_A75h=~7x4sq6QNTHKLLz5Y;l1i^m@y)Byq%e*dP4>M3jS*A| +zH=r=XOm0DACarO5#nU`Dd{Ng71+*IApk>g1RMp&zydf97QqRy1Wtle;50Y`&VqB`Jh%WZf=l2sxB{+% +zYvB4LHS4)A&pSWz{Q8@xo}b$HKl;!&)oPSPN%{2bA~uz{vSZ>slkC18)N0Mv{`SAV +Z)LrdtIGaw{*=p;q`M6Wx_O}_8{s6iiTe|=N + +delta 266 +zcmbQTXcyx&AZ}=3Y+-6)ZeeL*ZDDI+Z{cX+Y~gC*ZsBR+ZQ*O--y(2h;q(<<0zA`W +z77B1oUvN>3W%_}I0zB=17775dAP@@yu`m#e0I?_#ivh7X5K92DBoIphu{03N0I@6( +z%K@=G5Gw$&A`mM9u`&>=0I@0%s{yh4_CE_XmId(MW?;znW?%|9%D}jD=l1oVG`yJf +z%}n(S^$fIAQp*fYb&U*+jCBnxbq!1pxH>vaSm0oQF5a&8RRf4MfmjQOwSib?yV_UX +OtFsy3PyaJPPXYiZJ96a! + +diff --git a/boot/ocamllex b/boot/ocamllex +index cfdfbe8b4541516ef49c895ea691ea534706de67..b2b5404e69f35a1eb7d0a74fe687a4f4508a7149 100755 +GIT binary patch +delta 98 +zcmdn~RebAL@rD-07N!>F7M3lnT~@qO3=Hgl7#JKo7#Or4Zl7+&>cymMYN}_bXQ-W$ +qT4tbYWME{hYhbBsXmY^S(Q(282Yoc*?EF7M3lnT~@p@3=Hgl7#JKo85p!5ZJ%z%>cymQW~yhXXP}*u +rT4rdfYh++#tZQJYYhZf7)zM+X0tW+h@$G!JtbKbK4W`fi#VP>+{6`&d + +diff --git a/testsuite/tests/typing-misc/variance.ml b/testsuite/tests/typing-misc/variance.ml +index d0f754f716..419e348f48 100644 +--- a/testsuite/tests/typing-misc/variance.ml ++++ b/testsuite/tests/typing-misc/variance.ml +@@ -36,3 +36,90 @@ type !'a t = (module s with type t = 'a);; + module type s = sig type t end + type 'a t = (module s with type t = 'a) + |}] ++ ++(* Composition *) ++type -'a n ++type +'a p ++type !'a i ++ ++type +'a error_np = 'a n p;; ++[%%expect{| ++type -'a n ++type +'a p ++type !'a i ++Line 5, characters 0-26: ++5 | type +'a error_np = 'a n p;; ++ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be covariant, ++ but it is contravariant. ++|}] ++ ++ ++type +'a error_pn = 'a p n;; ++[%%expect{| ++Line 1, characters 0-26: ++1 | type +'a error_pn = 'a p n;; ++ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be covariant, ++ but it is contravariant. ++|}] ++ ++type -'a error_pp = 'a p p;; ++[%%expect{| ++Line 1, characters 0-26: ++1 | type -'a error_pp = 'a p p;; ++ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be contravariant, ++ but it is covariant. ++|}] ++ ++type -'a error_nn = 'a n n;; ++[%%expect{| ++Line 1, characters 0-26: ++1 | type -'a error_nn = 'a n n;; ++ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be contravariant, ++ but it is covariant. ++|}] ++ ++type !'a inj_in = 'a i n ++[%%expect{| ++Line 1, characters 0-24: ++1 | type !'a inj_in = 'a i n ++ ^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be injective invariant, ++ but it is invariant. ++|}] ++ ++type !'a inj_in = 'a n i ++[%%expect{| ++Line 1, characters 0-24: ++1 | type !'a inj_in = 'a n i ++ ^^^^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be injective invariant, ++ but it is invariant. ++|}] ++ ++module Make_covariant(M: sig type 'a t end): sig ++ type 'a i = 'a ++ type +'a t = 'a i M.t ++end = struct ++ type 'a i = 'a ++ type +'a t = 'a i M.t ++end ++ ++module Positive_ref = Make_covariant(struct type 'a t = 'a ref end) ++[%%expect {| ++Line 6, characters 2-23: ++6 | type +'a t = 'a i M.t ++ ^^^^^^^^^^^^^^^^^^^^^ ++Error: In this definition, expected parameter variances are not satisfied. ++ The 1st type parameter was expected to be covariant, ++ but it is invariant. ++|}] +diff --git a/typing/types.ml b/typing/types.ml +index 45a4f896d6..c1dbdb6895 100644 +--- a/typing/types.ml ++++ b/typing/types.ml +@@ -186,7 +186,7 @@ module Variance = struct + let mp = + mem May_pos v1 && mem May_pos v2 || mem May_neg v1 && mem May_neg v2 + and mn = +- mem May_pos v1 && mem May_neg v2 || mem May_pos v1 && mem May_neg v2 ++ mem May_pos v1 && mem May_neg v2 || mem May_neg v1 && mem May_pos v2 + and mw = mem May_weak v1 && v2 <> null || v1 <> null && mem May_weak v2 + and inj = mem Inj v1 && mem Inj v2 + and pos = mem Pos v1 && mem Pos v2 || mem Neg v1 && mem Neg v2 +-- +2.41.0 + diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0002-Don-t-add-rpaths-to-libraries.patch similarity index 79% rename from 0001-Don-t-add-rpaths-to-libraries.patch rename to 0002-Don-t-add-rpaths-to-libraries.patch index 344a528..d1362a5 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0002-Don-t-add-rpaths-to-libraries.patch @@ -1,14 +1,14 @@ -From 03435cc789bfb783c1d5566e8abd387eea1b9155 Mon Sep 17 00:00:00 2001 +From 56fafd588484ceb9b8e998b5e569d7df27deae3b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/4] Don't add rpaths to libraries. +Subject: [PATCH 2/5] Don't add rpaths to libraries. --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac -index 7c7d9a814c..d5040c279c 100644 +index aba3569f7c..6c50ba6c71 100644 --- a/configure.ac +++ b/configure.ac @@ -1106,8 +1106,6 @@ AS_IF([test x"$enable_shared" != "xno"], diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0003-configure-Allow-user-defined-C-compiler-flags.patch similarity index 89% rename from 0002-configure-Allow-user-defined-C-compiler-flags.patch rename to 0003-configure-Allow-user-defined-C-compiler-flags.patch index 0d70a04..8c64262 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0003-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,14 +1,14 @@ -From d9bcdb9d0a27e10350b1ca90df43b401656324f1 Mon Sep 17 00:00:00 2001 +From e8170e71efb93f10c27935acc95093eb3f53ab6c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. +Subject: [PATCH 3/5] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac -index d5040c279c..4cbba04557 100644 +index 6c50ba6c71..db6ea8a8d1 100644 --- a/configure.ac +++ b/configure.ac @@ -759,6 +759,10 @@ AS_CASE([$host], diff --git a/0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch b/0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch similarity index 84% rename from 0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch rename to 0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch index 6d40ec0..2a90a81 100644 --- a/0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch +++ b/0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch @@ -1,14 +1,14 @@ -From 352789925e44f012fbddc5dfae63abd15a447577 Mon Sep 17 00:00:00 2001 +From 8d0e4af8141f6ba925c1de426a9600a96816c86b Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Mon, 4 Sep 2023 13:50:30 -0600 -Subject: [PATCH 3/4] Fix x86_64 delivery of effect-related exceptions +Subject: [PATCH 4/5] Fix x86_64 delivery of effect-related exceptions --- runtime/amd64.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/amd64.S b/runtime/amd64.S -index 7e6f95c680..24dfa7111b 100644 +index 8dc9f81ec6..72d96f502d 100644 --- a/runtime/amd64.S +++ b/runtime/amd64.S @@ -902,6 +902,7 @@ LBL(112): diff --git a/0004-Update-framepointers-tests-to-avoid-false-positive-w.patch b/0005-Update-framepointers-tests-to-avoid-false-positive-w.patch similarity index 97% rename from 0004-Update-framepointers-tests-to-avoid-false-positive-w.patch rename to 0005-Update-framepointers-tests-to-avoid-false-positive-w.patch index 2025d57..a160acb 100644 --- a/0004-Update-framepointers-tests-to-avoid-false-positive-w.patch +++ b/0005-Update-framepointers-tests-to-avoid-false-positive-w.patch @@ -1,7 +1,7 @@ -From 210f9b439b264fb6ab16802f468992086a4af58c Mon Sep 17 00:00:00 2001 +From e1ee698f482664237bfb693966987cd167c22b68 Mon Sep 17 00:00:00 2001 From: Fabrice Buoro Date: Fri, 10 Mar 2023 09:36:22 -0700 -Subject: [PATCH 4/4] Update framepointers tests to avoid false positive with +Subject: [PATCH 5/5] Update framepointers tests to avoid false positive with inlined C functions --- @@ -36,10 +36,10 @@ Subject: [PATCH 4/4] Update framepointers tests to avoid false positive with delete mode 100644 testsuite/tests/frame-pointers/stack_realloc2.run diff --git a/testsuite/tests/frame-pointers/c_call.ml b/testsuite/tests/frame-pointers/c_call.ml -index 7d48b4947d..f552b0df8f 100644 +index c2493b3a99..9b98e86520 100644 --- a/testsuite/tests/frame-pointers/c_call.ml +++ b/testsuite/tests/frame-pointers/c_call.ml -@@ -7,20 +7,20 @@ all_modules = "${readonly_files} c_call. +@@ -7,20 +7,20 @@ all_modules = "${readonly_files} c_call.ml" *) @@ -140,7 +140,7 @@ index 634c4dd937..a75100b213 100644 + argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); } diff --git a/testsuite/tests/frame-pointers/effects.ml b/testsuite/tests/frame-pointers/effects.ml -index 2aa7012606..ac304683fe 100644 +index e14633a374..4d14190320 100644 --- a/testsuite/tests/frame-pointers/effects.ml +++ b/testsuite/tests/frame-pointers/effects.ml @@ -11,26 +11,26 @@ open Printf @@ -239,10 +239,10 @@ index e96b5ea13a..0000000000 -${program} 2>&1 \ - | ${test_source_directory}/filter-locations.sh ${program} >${output} diff --git a/testsuite/tests/frame-pointers/exception_handler.ml b/testsuite/tests/frame-pointers/exception_handler.ml -index 6bf5bf470d..19773f78de 100644 +index 575f7329bf..95a4f0d75c 100644 --- a/testsuite/tests/frame-pointers/exception_handler.ml +++ b/testsuite/tests/frame-pointers/exception_handler.ml -@@ -8,7 +8,7 @@ +@@ -8,7 +8,7 @@ all_modules = "${readonly_files} exception_handler.ml" *) (* https://github.com/ocaml/ocaml/pull/11031 *) @@ -374,13 +374,13 @@ index a521218a38..cef7ccd9f2 100644 + perror("backtrace_symbols"); + return NULL; + } -+ + +-static void signal_handler(int signum) + const char* symbol = strdup(symbols[0]); + free(symbols); + return symbol; +} - --static void signal_handler(int signum) ++ +static bool is_from_executable(const char* symbol, const char* execname) { - /* Should be safe to be called from a signal handler. @@ -504,17 +504,17 @@ index a521218a38..cef7ccd9f2 100644 - struct frame_info *fi; - struct frame_info* next; - void* retaddr; -+ const char* execname = String_val(argv0); -+ struct frame_info* next = NULL; -+ const char* symbol = NULL; - +- - fi = __builtin_frame_address(0); - retaddr = __builtin_extract_return_addr(__builtin_return_address(0)); - - for (; fi; fi = next) { - if (safe_read(fi, &next, &retaddr) != 0) - return; -- ++ const char* execname = String_val(argv0); ++ struct frame_info* next = NULL; ++ const char* symbol = NULL; + - print_location(retaddr); + for (struct frame_info* fi = __builtin_frame_address(0); fi; fi = next) { + next = fi->prev; @@ -563,10 +563,10 @@ index a521218a38..cef7ccd9f2 100644 + free((void*)symbol); } diff --git a/testsuite/tests/frame-pointers/reperform.ml b/testsuite/tests/frame-pointers/reperform.ml -index ec5393907c..7a3b09162b 100644 +index 1af8452e5f..da251c98a7 100644 --- a/testsuite/tests/frame-pointers/reperform.ml +++ b/testsuite/tests/frame-pointers/reperform.ml -@@ -11,7 +11,7 @@ +@@ -11,7 +11,7 @@ all_modules = "${readonly_files} reperform.ml" open Effect open Effect.Deep @@ -606,7 +606,7 @@ index e96b5ea13a..0000000000 -${program} 2>&1 \ - | ${test_source_directory}/filter-locations.sh ${program} >${output} diff --git a/testsuite/tests/frame-pointers/stack_realloc.ml b/testsuite/tests/frame-pointers/stack_realloc.ml -index fc4e9e9d3b..cacc43c216 100644 +index 79e70c2add..f24e4795d5 100644 --- a/testsuite/tests/frame-pointers/stack_realloc.ml +++ b/testsuite/tests/frame-pointers/stack_realloc.ml @@ -13,7 +13,7 @@ open Effect.Deep @@ -649,7 +649,7 @@ index e96b5ea13a..0000000000 -${program} 2>&1 \ - | ${test_source_directory}/filter-locations.sh ${program} >${output} diff --git a/testsuite/tests/frame-pointers/stack_realloc2.ml b/testsuite/tests/frame-pointers/stack_realloc2.ml -index a4aea249ea..b2a602fa4a 100644 +index a3d21bf2bf..218dd6a1c3 100644 --- a/testsuite/tests/frame-pointers/stack_realloc2.ml +++ b/testsuite/tests/frame-pointers/stack_realloc2.ml @@ -13,7 +13,7 @@ open Effect.Deep diff --git a/ocaml.spec b/ocaml.spec index 2669eac..8382b01 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -71,14 +71,15 @@ Source2: ocaml_files.py # be incorporated into the git repo at a later time. # Patches added after 5.1.0 was released. +Patch: 0001-Fix-variance-composition-12623.patch # Fedora-specific patches -Patch: 0001-Don-t-add-rpaths-to-libraries.patch -Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch +Patch: 0002-Don-t-add-rpaths-to-libraries.patch +Patch: 0003-configure-Allow-user-defined-C-compiler-flags.patch # https://github.com/ocaml/ocaml/pull/12530 -Patch: 0003-Fix-x86_64-delivery-of-effect-related-exceptions.patch +Patch: 0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch # https://github.com/ocaml/ocaml/pull/11594 -Patch: 0004-Update-framepointers-tests-to-avoid-false-positive-w.patch +Patch: 0005-Update-framepointers-tests-to-avoid-false-positive-w.patch BuildRequires: make BuildRequires: git @@ -467,6 +468,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From a8e366538adc5550add1d3840372022e090f03c0 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Oct 2023 10:53:11 +0100 Subject: [PATCH 63/91] Rebuild against updated ocaml-srpm-macros I managed to build it against the old ocaml-srpm-macros, thus native compilation was disabled still on s390x. Hopefully bump and rebuild after adding ocaml-srpm-macros to the side tag will fix this. --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 8382b01..e6d1c1a 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -468,6 +468,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From 2ec55e949b92244d2b119f71e83c38a5ea878efc Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 6 Oct 2023 12:40:21 +0100 Subject: [PATCH 64/91] Use BR ocaml-srpm-macros to force latest to be built against --- ocaml.spec | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index e6d1c1a..6aa019b 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -109,8 +109,10 @@ Requires: libzstd-devel%{?_isa} # of ocaml-runtime. Requires: ocaml-runtime%{?_isa} = %{version}-%{release} -# Force ocaml-srpm-macros to be at the latest version, since OCaml 5.1 -# has a different set of native code generators than previous versions. +# Force ocaml-srpm-macros to be at the latest version, both for builds +# and installs, since OCaml 5.1 has a different set of native code +# generators than previous versions. +BuildRequires: ocaml-srpm-macros >= 9 Requires: ocaml-srpm-macros >= 9 # Bundles an MD5 implementation in runtime/caml/md5.h and runtime/md5.c @@ -468,6 +470,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From ebbf4c122f2f8804a6da5b29c56cfeacc425b49e Mon Sep 17 00:00:00 2001 From: Jerry James Date: Thu, 12 Oct 2023 12:34:40 -0600 Subject: [PATCH 65/91] Configure with --enable-ocamltest on test_arches --- ocaml.spec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 6aa019b..8fbbb76 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -268,6 +268,11 @@ sed -i '/^EXTRACAMLFLAGS=/aLINKOPTS=-cclib -lm' otherlibs/unix/Makefile %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}' \ @@ -297,10 +302,6 @@ 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 From 48b6d0088d09695a373cbd10e7ad045de477bb56 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Mon, 13 Nov 2023 22:14:13 -0500 Subject: [PATCH 66/91] Drop unused BR parallel GNU parallel is only used by make parallel in the testsuite directory; the toplevel make tests calls make all in testsuite. --- ocaml.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index 8fbbb76..7984dc4 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: OCaml compiler and programming environment @@ -87,7 +87,6 @@ BuildRequires: gcc BuildRequires: autoconf BuildRequires: gawk BuildRequires: hardlink -BuildRequires: parallel BuildRequires: perl-interpreter BuildRequires: util-linux BuildRequires: /usr/bin/annocheck @@ -471,6 +470,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From b40114b0c94016adf6340b67be20f49fde56e211 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 11 Dec 2023 22:33:21 +0000 Subject: [PATCH 67/91] New upstream version 5.1.1 (RHBZ#2239227) --- ...> 0001-Don-t-add-rpaths-to-libraries.patch | 10 +- 0001-Fix-variance-composition-12623.patch | 176 ------------------ ...-Allow-user-defined-C-compiler-flags.patch | 14 +- ...ters-tests-to-avoid-false-positive-w.patch | 6 +- ...elivery-of-effect-related-exceptions.patch | 34 ---- ocaml.spec | 21 +-- sources | 2 +- 7 files changed, 26 insertions(+), 237 deletions(-) rename 0002-Don-t-add-rpaths-to-libraries.patch => 0001-Don-t-add-rpaths-to-libraries.patch (72%) delete mode 100644 0001-Fix-variance-composition-12623.patch rename 0003-configure-Allow-user-defined-C-compiler-flags.patch => 0002-configure-Allow-user-defined-C-compiler-flags.patch (80%) rename 0005-Update-framepointers-tests-to-avoid-false-positive-w.patch => 0003-Update-framepointers-tests-to-avoid-false-positive-w.patch (99%) delete mode 100644 0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch diff --git a/0002-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch similarity index 72% rename from 0002-Don-t-add-rpaths-to-libraries.patch rename to 0001-Don-t-add-rpaths-to-libraries.patch index d1362a5..92f75dd 100644 --- a/0002-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,17 +1,17 @@ -From 56fafd588484ceb9b8e998b5e569d7df27deae3b Mon Sep 17 00:00:00 2001 +From 799bf9088c131fc71626a48e9987e4d44a2f0194 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 2/5] Don't add rpaths to libraries. +Subject: [PATCH 1/3] Don't add rpaths to libraries. --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac -index aba3569f7c..6c50ba6c71 100644 +index b81da53c42..892a2a894f 100644 --- a/configure.ac +++ b/configure.ac -@@ -1106,8 +1106,6 @@ AS_IF([test x"$enable_shared" != "xno"], +@@ -1107,8 +1107,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" @@ -21,5 +21,5 @@ index aba3569f7c..6c50ba6c71 100644 supports_shared_libraries=true], [mkdll='shared-libs-not-available']) -- -2.41.0 +2.43.0 diff --git a/0001-Fix-variance-composition-12623.patch b/0001-Fix-variance-composition-12623.patch deleted file mode 100644 index 34db2ab..0000000 --- a/0001-Fix-variance-composition-12623.patch +++ /dev/null @@ -1,176 +0,0 @@ -From 4c03e721b4c53240a9091790acb401b27e72dce0 Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Wed, 4 Oct 2023 10:05:44 +0200 -Subject: [PATCH 1/5] Fix variance composition (#12623) - -Possible positive occurrence under possible negative occurrence were -forgotten, making the typechecker accepts the absurd statement - - type -'a n - type +'a p - type +'a ko = 'a p n - -(cherry picked from commit 1a9c45317b2c6c9ca9b4cb95fe4891f9f1a2820e) ---- - Changes | 8 +++ - boot/ocamlc | Bin 3051798 -> 3051796 bytes - boot/ocamllex | Bin 391863 -> 391861 bytes - testsuite/tests/typing-misc/variance.ml | 87 ++++++++++++++++++++++++ - typing/types.ml | 2 +- - 5 files changed, 96 insertions(+), 1 deletion(-) - -diff --git a/Changes b/Changes -index 20b7b8ee22..dccdc9baba 100644 ---- a/Changes -+++ b/Changes -@@ -1,3 +1,11 @@ -+OCaml 5.1.1 -+----------- -+ -+### Bug fixes: -+ -+- #12623, fix the computation of variance composition -+ (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer) -+ - OCaml 5.1.0 (14 September 2023) - ------------------------------- - -diff --git a/boot/ocamlc b/boot/ocamlc -index f3b2cba8df84a5f1326c7fe7bdf12b85159f65b3..4db4d848dbc3c2411a9e6160e9d932dd7ba35a34 100755 -GIT binary patch -delta 244 -zcmZ9=y)pw)7zW@yD_A75h=~7x4sq6QNTHKLLz5Y;l1i^m@y)Byq%e*dP4>M3jS*A| -zH=r=XOm0DACarO5#nU`Dd{Ng71+*IApk>g1RMp&zydf97QqRy1Wtle;50Y`&VqB`Jh%WZf=l2sxB{+% -zYvB4LHS4)A&pSWz{Q8@xo}b$HKl;!&)oPSPN%{2bA~uz{vSZ>slkC18)N0Mv{`SAV -Z)LrdtIGaw{*=p;q`M6Wx_O}_8{s6iiTe|=N - -delta 266 -zcmbQTXcyx&AZ}=3Y+-6)ZeeL*ZDDI+Z{cX+Y~gC*ZsBR+ZQ*O--y(2h;q(<<0zA`W -z77B1oUvN>3W%_}I0zB=17775dAP@@yu`m#e0I?_#ivh7X5K92DBoIphu{03N0I@6( -z%K@=G5Gw$&A`mM9u`&>=0I@0%s{yh4_CE_XmId(MW?;znW?%|9%D}jD=l1oVG`yJf -z%}n(S^$fIAQp*fYb&U*+jCBnxbq!1pxH>vaSm0oQF5a&8RRf4MfmjQOwSib?yV_UX -OtFsy3PyaJPPXYiZJ96a! - -diff --git a/boot/ocamllex b/boot/ocamllex -index cfdfbe8b4541516ef49c895ea691ea534706de67..b2b5404e69f35a1eb7d0a74fe687a4f4508a7149 100755 -GIT binary patch -delta 98 -zcmdn~RebAL@rD-07N!>F7M3lnT~@qO3=Hgl7#JKo7#Or4Zl7+&>cymMYN}_bXQ-W$ -qT4tbYWME{hYhbBsXmY^S(Q(282Yoc*?EF7M3lnT~@p@3=Hgl7#JKo85p!5ZJ%z%>cymQW~yhXXP}*u -rT4rdfYh++#tZQJYYhZf7)zM+X0tW+h@$G!JtbKbK4W`fi#VP>+{6`&d - -diff --git a/testsuite/tests/typing-misc/variance.ml b/testsuite/tests/typing-misc/variance.ml -index d0f754f716..419e348f48 100644 ---- a/testsuite/tests/typing-misc/variance.ml -+++ b/testsuite/tests/typing-misc/variance.ml -@@ -36,3 +36,90 @@ type !'a t = (module s with type t = 'a);; - module type s = sig type t end - type 'a t = (module s with type t = 'a) - |}] -+ -+(* Composition *) -+type -'a n -+type +'a p -+type !'a i -+ -+type +'a error_np = 'a n p;; -+[%%expect{| -+type -'a n -+type +'a p -+type !'a i -+Line 5, characters 0-26: -+5 | type +'a error_np = 'a n p;; -+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be covariant, -+ but it is contravariant. -+|}] -+ -+ -+type +'a error_pn = 'a p n;; -+[%%expect{| -+Line 1, characters 0-26: -+1 | type +'a error_pn = 'a p n;; -+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be covariant, -+ but it is contravariant. -+|}] -+ -+type -'a error_pp = 'a p p;; -+[%%expect{| -+Line 1, characters 0-26: -+1 | type -'a error_pp = 'a p p;; -+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be contravariant, -+ but it is covariant. -+|}] -+ -+type -'a error_nn = 'a n n;; -+[%%expect{| -+Line 1, characters 0-26: -+1 | type -'a error_nn = 'a n n;; -+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be contravariant, -+ but it is covariant. -+|}] -+ -+type !'a inj_in = 'a i n -+[%%expect{| -+Line 1, characters 0-24: -+1 | type !'a inj_in = 'a i n -+ ^^^^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be injective invariant, -+ but it is invariant. -+|}] -+ -+type !'a inj_in = 'a n i -+[%%expect{| -+Line 1, characters 0-24: -+1 | type !'a inj_in = 'a n i -+ ^^^^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be injective invariant, -+ but it is invariant. -+|}] -+ -+module Make_covariant(M: sig type 'a t end): sig -+ type 'a i = 'a -+ type +'a t = 'a i M.t -+end = struct -+ type 'a i = 'a -+ type +'a t = 'a i M.t -+end -+ -+module Positive_ref = Make_covariant(struct type 'a t = 'a ref end) -+[%%expect {| -+Line 6, characters 2-23: -+6 | type +'a t = 'a i M.t -+ ^^^^^^^^^^^^^^^^^^^^^ -+Error: In this definition, expected parameter variances are not satisfied. -+ The 1st type parameter was expected to be covariant, -+ but it is invariant. -+|}] -diff --git a/typing/types.ml b/typing/types.ml -index 45a4f896d6..c1dbdb6895 100644 ---- a/typing/types.ml -+++ b/typing/types.ml -@@ -186,7 +186,7 @@ module Variance = struct - let mp = - mem May_pos v1 && mem May_pos v2 || mem May_neg v1 && mem May_neg v2 - and mn = -- mem May_pos v1 && mem May_neg v2 || mem May_pos v1 && mem May_neg v2 -+ mem May_pos v1 && mem May_neg v2 || mem May_neg v1 && mem May_pos v2 - and mw = mem May_weak v1 && v2 <> null || v1 <> null && mem May_weak v2 - and inj = mem Inj v1 && mem Inj v2 - and pos = mem Pos v1 && mem Pos v2 || mem Neg v1 && mem Neg v2 --- -2.41.0 - diff --git a/0003-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch similarity index 80% rename from 0003-configure-Allow-user-defined-C-compiler-flags.patch rename to 0002-configure-Allow-user-defined-C-compiler-flags.patch index 8c64262..d2d6a4b 100644 --- a/0003-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From e8170e71efb93f10c27935acc95093eb3f53ab6c Mon Sep 17 00:00:00 2001 +From f2b875e8201efed22267136096b1e5df97f99f84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 3/5] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/3] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac -index 6c50ba6c71..db6ea8a8d1 100644 +index 892a2a894f..e8f6cbc863 100644 --- a/configure.ac +++ b/configure.ac -@@ -759,6 +759,10 @@ AS_CASE([$host], +@@ -760,6 +760,10 @@ AS_CASE([$host], internal_cflags="$cc_warnings"], [common_cflags="-O"])]) @@ -22,7 +22,7 @@ index 6c50ba6c71..db6ea8a8d1 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. AS_CASE([$host], [i686-*-mingw32*], -@@ -2325,7 +2329,7 @@ AC_CONFIG_COMMANDS_PRE([ +@@ -2327,7 +2331,7 @@ AC_CONFIG_COMMANDS_PRE([ [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) mkdll_ldflags="" AS_IF([test -n "${LDFLAGS}"], @@ -31,7 +31,7 @@ index 6c50ba6c71..db6ea8a8d1 100644 mkdll_ldflags="${mkdll_ldflags} ${mkexe_ldflags_prefix}${flag}" done mkdll_ldflags_exp="$mkdll_ldflags"]) -@@ -2351,7 +2355,7 @@ ${mkdll_ldflags}" +@@ -2353,7 +2357,7 @@ ${mkdll_ldflags}" ],[ mkdll_ldflags='$(OC_DLL_LDFLAGS) $(LDFLAGS)' mkdll_ldflags_exp="${oc_dll_ldflags}" @@ -41,5 +41,5 @@ index 6c50ba6c71..db6ea8a8d1 100644 mkexe_ldflags="\$(OC_LDFLAGS) \$(LDFLAGS)" mkexe_ldflags_exp="${oc_ldflags} ${LDFLAGS}" -- -2.41.0 +2.43.0 diff --git a/0005-Update-framepointers-tests-to-avoid-false-positive-w.patch b/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch similarity index 99% rename from 0005-Update-framepointers-tests-to-avoid-false-positive-w.patch rename to 0003-Update-framepointers-tests-to-avoid-false-positive-w.patch index a160acb..80e51e0 100644 --- a/0005-Update-framepointers-tests-to-avoid-false-positive-w.patch +++ b/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch @@ -1,7 +1,7 @@ -From e1ee698f482664237bfb693966987cd167c22b68 Mon Sep 17 00:00:00 2001 +From ba44a9c29771aacf44222a2ff63e7bd6034dd92c Mon Sep 17 00:00:00 2001 From: Fabrice Buoro Date: Fri, 10 Mar 2023 09:36:22 -0700 -Subject: [PATCH 5/5] Update framepointers tests to avoid false positive with +Subject: [PATCH 3/3] Update framepointers tests to avoid false positive with inlined C functions --- @@ -692,5 +692,5 @@ index e96b5ea13a..0000000000 -${program} 2>&1 \ - | ${test_source_directory}/filter-locations.sh ${program} >${output} -- -2.41.0 +2.43.0 diff --git a/0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch b/0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch deleted file mode 100644 index 2a90a81..0000000 --- a/0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 8d0e4af8141f6ba925c1de426a9600a96816c86b Mon Sep 17 00:00:00 2001 -From: Miod Vallat -Date: Mon, 4 Sep 2023 13:50:30 -0600 -Subject: [PATCH 4/5] Fix x86_64 delivery of effect-related exceptions - ---- - runtime/amd64.S | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/runtime/amd64.S b/runtime/amd64.S -index 8dc9f81ec6..72d96f502d 100644 ---- a/runtime/amd64.S -+++ b/runtime/amd64.S -@@ -902,6 +902,7 @@ LBL(112): - movq Caml_state(current_stack), %rsi - SWITCH_OCAML_STACKS - /* No parent stack. Raise Effect.Unhandled. */ -+ ENTER_FUNCTION - movq %rax, C_ARG_1 - LEA_VAR(caml_raise_unhandled_effect, %rax) - jmp LBL(caml_c_call) -@@ -946,7 +947,8 @@ CFI_STARTPROC - UPDATE_BASE_POINTER(%rcx) - SWITCH_OCAML_STACKS - jmp *(%rbx) --2: LEA_VAR(caml_raise_continuation_already_resumed, %rax) -+2: ENTER_FUNCTION -+ LEA_VAR(caml_raise_continuation_already_resumed, %rax) - jmp LBL(caml_c_call) - CFI_ENDPROC - ENDFUNCTION(G(caml_resume)) --- -2.41.0 - diff --git a/ocaml.spec b/ocaml.spec index 7984dc4..92dcff1 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -42,8 +42,8 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.1.0 -Release: 5%{?dist} +Version: 5.1.1 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -64,22 +64,18 @@ Source2: ocaml_files.py # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-40-5.1.0 +# Current branch: fedora-40-5.1.1 # # 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 5.1.0 was released. -Patch: 0001-Fix-variance-composition-12623.patch - # Fedora-specific patches -Patch: 0002-Don-t-add-rpaths-to-libraries.patch -Patch: 0003-configure-Allow-user-defined-C-compiler-flags.patch -# https://github.com/ocaml/ocaml/pull/12530 -Patch: 0004-Fix-x86_64-delivery-of-effect-related-exceptions.patch +Patch: 0001-Don-t-add-rpaths-to-libraries.patch +Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch + # https://github.com/ocaml/ocaml/pull/11594 -Patch: 0005-Update-framepointers-tests-to-avoid-false-positive-w.patch +Patch: 0003-Update-framepointers-tests-to-avoid-false-positive-w.patch BuildRequires: make BuildRequires: git @@ -470,6 +466,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 diff --git a/sources b/sources index 1da2f82..f4deb78 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.1.0.tar.gz) = 814ea71de656eadc59a658ad3b6c4d786815c348ab883b1cdb22d5d0f99d11768f5646f03725f6b44c3b8f4ffeb71e89dadaea157711a7afbe86f23846fc5b52 +SHA512 (ocaml-5.1.1.tar.gz) = e4aa78afc9a59f604881f14093f4298ebcb005daeb8132a076fe6d24fdf8b59132cbfa2cfe677f1db1891351d3d637c621f24077e531cac6753c264fc7f5fbea From 4f34985ad8b10ed92e98b7115d7fedff1948bee9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 18 Dec 2023 11:07:28 +0000 Subject: [PATCH 68/91] Add s390x code generation fix https://github.com/ocaml/ocaml/issues/12829 --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...ters-tests-to-avoid-false-positive-w.patch | 2 +- ...-stack-reallocation-code-in-PIC-mode.patch | 26 +++++++++++++++++++ ocaml.spec | 10 ++++++- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 92f75dd..b0cb61b 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 799bf9088c131fc71626a48e9987e4d44a2f0194 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/3] Don't add rpaths to libraries. +Subject: [PATCH 1/4] Don't add rpaths to libraries. --- configure.ac | 2 -- diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index d2d6a4b..d3d927d 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From f2b875e8201efed22267136096b1e5df97f99f84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/3] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- diff --git a/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch b/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch index 80e51e0..4ee59a8 100644 --- a/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch +++ b/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch @@ -1,7 +1,7 @@ From ba44a9c29771aacf44222a2ff63e7bd6034dd92c Mon Sep 17 00:00:00 2001 From: Fabrice Buoro Date: Fri, 10 Mar 2023 09:36:22 -0700 -Subject: [PATCH 3/3] Update framepointers tests to avoid false positive with +Subject: [PATCH 3/4] Update framepointers tests to avoid false positive with inlined C functions --- diff --git a/0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch b/0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch new file mode 100644 index 0000000..16c63f9 --- /dev/null +++ b/0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch @@ -0,0 +1,26 @@ +From 81d3fb3e20afede32298e4d3e78bcebf6a22858a Mon Sep 17 00:00:00 2001 +From: Vincent Laviron +Date: Fri, 15 Dec 2023 10:00:52 +0100 +Subject: [PATCH 4/4] Fix s390x stack reallocation code in PIC mode + +(cherry picked from commit c40a955c029a203d0d7f05718e297e66987ec87f) +--- + asmcomp/s390x/emit.mlp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp +index 35ade079f6..0212cf3b00 100644 +--- a/asmcomp/s390x/emit.mlp ++++ b/asmcomp/s390x/emit.mlp +@@ -751,7 +751,7 @@ let fundecl fundecl = + ` lay %r15, -8(%r15)\n`; + ` stg %r14, 0(%r15)\n`; + ` lgfi %r12, {emit_int s}\n`; +- ` brasl %r14, {emit_symbol "caml_call_realloc_stack"}\n`; ++ emit_call "caml_call_realloc_stack"; + ` lg %r14, 0(%r15)\n`; + ` la %r15, 8(%r15)\n`; + ` brcl 15, {emit_label ret}\n` +-- +2.43.0 + diff --git a/ocaml.spec b/ocaml.spec index 92dcff1..4de70ea 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -77,6 +77,10 @@ Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch # https://github.com/ocaml/ocaml/pull/11594 Patch: 0003-Update-framepointers-tests-to-avoid-false-positive-w.patch +# https://github.com/ocaml/ocaml/issues/12829 +# https://github.com/ocaml/ocaml/pull/12831 +Patch: 0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch + BuildRequires: make BuildRequires: git BuildRequires: gcc @@ -466,6 +470,10 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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) From 2883f28bbd9754bd0762c0c9e52cefd7d3883ffa Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sun, 21 Jan 2024 10:09:11 +0000 Subject: [PATCH 69/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 4de70ea..b410c4c 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -470,6 +470,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From a3771460e1e6d494c130fcddd9f0d92b9b3225e4 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 25 Jan 2024 09:45:15 +0000 Subject: [PATCH 70/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index b410c4c..d8d069b 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -43,7 +43,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.1.1 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -470,6 +470,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From f299c84c6ddf24babb331a6128d5993c2e99c1b5 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Thu, 23 May 2024 09:00:25 -0600 Subject: [PATCH 71/91] Version 5.2.0 - Drop upstreamed frame pointer and s390x patches --- 0001-Don-t-add-rpaths-to-libraries.patch | 6 +- ...-Allow-user-defined-C-compiler-flags.patch | 12 +- ...ters-tests-to-avoid-false-positive-w.patch | 696 ------------------ ...-stack-reallocation-code-in-PIC-mode.patch | 26 - ocaml.spec | 27 +- sources | 2 +- 6 files changed, 21 insertions(+), 748 deletions(-) delete mode 100644 0003-Update-framepointers-tests-to-avoid-false-positive-w.patch delete mode 100644 0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index b0cb61b..04773ec 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 799bf9088c131fc71626a48e9987e4d44a2f0194 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 1/4] Don't add rpaths to libraries. +Subject: [PATCH 1/2] Don't add rpaths to libraries. --- configure.ac | 2 -- @@ -11,8 +11,8 @@ diff --git a/configure.ac b/configure.ac index b81da53c42..892a2a894f 100644 --- a/configure.ac +++ b/configure.ac -@@ -1107,8 +1107,6 @@ AS_IF([test x"$enable_shared" != "xno"], - [[*-*-openbsd7.[3-9]|*-*-openbsd[89].*]], +@@ -1221,8 +1221,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," diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index d3d927d..569b4a1 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From f2b875e8201efed22267136096b1e5df97f99f84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 2/4] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/2] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- @@ -11,9 +11,9 @@ diff --git a/configure.ac b/configure.ac index 892a2a894f..e8f6cbc863 100644 --- a/configure.ac +++ b/configure.ac -@@ -760,6 +760,10 @@ AS_CASE([$host], - internal_cflags="$cc_warnings"], - [common_cflags="-O"])]) +@@ -869,6 +869,10 @@ AS_CASE([$ocaml_cc_vendor], + internal_cflags="$cc_warnings"], + [common_cflags="-O"]) +# Allow CFLAGS and LDFLAGS to be added. +common_cflags="$common_cflags $CFLAGS" @@ -22,7 +22,7 @@ index 892a2a894f..e8f6cbc863 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. AS_CASE([$host], [i686-*-mingw32*], -@@ -2327,7 +2331,7 @@ AC_CONFIG_COMMANDS_PRE([ +@@ -2648,7 +2652,7 @@ AC_CONFIG_COMMANDS_PRE([ [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) mkdll_ldflags="" AS_IF([test -n "${LDFLAGS}"], @@ -31,7 +31,7 @@ index 892a2a894f..e8f6cbc863 100644 mkdll_ldflags="${mkdll_ldflags} ${mkexe_ldflags_prefix}${flag}" done mkdll_ldflags_exp="$mkdll_ldflags"]) -@@ -2353,7 +2357,7 @@ ${mkdll_ldflags}" +@@ -2674,7 +2678,7 @@ ${mkdll_ldflags}" ],[ mkdll_ldflags='$(OC_DLL_LDFLAGS) $(LDFLAGS)' mkdll_ldflags_exp="${oc_dll_ldflags}" diff --git a/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch b/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch deleted file mode 100644 index 4ee59a8..0000000 --- a/0003-Update-framepointers-tests-to-avoid-false-positive-w.patch +++ /dev/null @@ -1,696 +0,0 @@ -From ba44a9c29771aacf44222a2ff63e7bd6034dd92c Mon Sep 17 00:00:00 2001 -From: Fabrice Buoro -Date: Fri, 10 Mar 2023 09:36:22 -0700 -Subject: [PATCH 3/4] Update framepointers tests to avoid false positive with - inlined C functions - ---- - testsuite/tests/frame-pointers/c_call.ml | 14 +- - .../tests/frame-pointers/c_call.reference | 9 - - testsuite/tests/frame-pointers/c_call.run | 4 - - testsuite/tests/frame-pointers/c_call_.c | 14 +- - testsuite/tests/frame-pointers/effects.ml | 12 +- - .../tests/frame-pointers/effects.reference | 15 -- - testsuite/tests/frame-pointers/effects.run | 4 - - .../tests/frame-pointers/exception_handler.ml | 4 +- - .../exception_handler.reference | 12 -- - .../frame-pointers/exception_handler.run | 4 - - .../tests/frame-pointers/filter-locations.sh | 23 --- - testsuite/tests/frame-pointers/fp_backtrace.c | 186 +++++++++++------- - testsuite/tests/frame-pointers/reperform.ml | 4 +- - .../tests/frame-pointers/reperform.reference | 3 - - testsuite/tests/frame-pointers/reperform.run | 4 - - .../tests/frame-pointers/stack_realloc.ml | 4 +- - .../frame-pointers/stack_realloc.reference | 3 - - .../tests/frame-pointers/stack_realloc.run | 4 - - .../tests/frame-pointers/stack_realloc2.ml | 4 +- - .../frame-pointers/stack_realloc2.reference | 3 - - .../tests/frame-pointers/stack_realloc2.run | 4 - - 21 files changed, 144 insertions(+), 190 deletions(-) - delete mode 100644 testsuite/tests/frame-pointers/c_call.run - delete mode 100644 testsuite/tests/frame-pointers/effects.run - delete mode 100644 testsuite/tests/frame-pointers/exception_handler.run - delete mode 100755 testsuite/tests/frame-pointers/filter-locations.sh - delete mode 100644 testsuite/tests/frame-pointers/reperform.run - delete mode 100644 testsuite/tests/frame-pointers/stack_realloc.run - delete mode 100644 testsuite/tests/frame-pointers/stack_realloc2.run - -diff --git a/testsuite/tests/frame-pointers/c_call.ml b/testsuite/tests/frame-pointers/c_call.ml -index c2493b3a99..9b98e86520 100644 ---- a/testsuite/tests/frame-pointers/c_call.ml -+++ b/testsuite/tests/frame-pointers/c_call.ml -@@ -7,20 +7,20 @@ all_modules = "${readonly_files} c_call.ml" - - *) - --external fp_backtrace : unit -> unit = "fp_backtrace" --external fp_backtrace_no_alloc : unit -> unit = "fp_backtrace" [@@noalloc] --external fp_backtrace_many_args : int -> int -> int -> int -> int -> int -> int -- -> int -> int -> int -> int -> unit = -+external fp_backtrace : string -> unit = "fp_backtrace" -+external fp_backtrace_no_alloc : string -> unit = "fp_backtrace" [@@noalloc] -+external fp_backtrace_many_args : string -> int -> int -> int -> int -> int -+ -> int -> int -> int -> int -> int -> int -> unit = - "fp_backtrace_many_args_argv" "fp_backtrace_many_args" - - let[@inline never] f () = - (* Check backtrace through caml_c_call_stack_args *) -- fp_backtrace_many_args 1 2 3 4 5 6 7 8 9 10 11; -+ fp_backtrace_many_args Sys.argv.(0) 1 2 3 4 5 6 7 8 9 10 11; - (* Check backtrace through caml_c_call. - * Also check that caml_c_call_stack_args correctly restores rbp register *) -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - (* Check caml_c_call correctly restores rbp register *) -- fp_backtrace_no_alloc (); -+ fp_backtrace_no_alloc Sys.argv.(0); - 42 - - let () = ignore (f ()) -diff --git a/testsuite/tests/frame-pointers/c_call.reference b/testsuite/tests/frame-pointers/c_call.reference -index 92fb40a238..23095e7431 100644 ---- a/testsuite/tests/frame-pointers/c_call.reference -+++ b/testsuite/tests/frame-pointers/c_call.reference -@@ -3,19 +3,10 @@ caml_c_call_stack_args - camlC_call.f - camlC_call.entry - caml_program --caml_start_program --caml_main/caml_startup --main - caml_c_call - camlC_call.f - camlC_call.entry - caml_program --caml_start_program --caml_main/caml_startup --main - camlC_call.f - camlC_call.entry - caml_program --caml_start_program --caml_main/caml_startup --main -diff --git a/testsuite/tests/frame-pointers/c_call.run b/testsuite/tests/frame-pointers/c_call.run -deleted file mode 100644 -index e96b5ea13a..0000000000 ---- a/testsuite/tests/frame-pointers/c_call.run -+++ /dev/null -@@ -1,4 +0,0 @@ --#!/bin/sh -- --${program} 2>&1 \ -- | ${test_source_directory}/filter-locations.sh ${program} >${output} -diff --git a/testsuite/tests/frame-pointers/c_call_.c b/testsuite/tests/frame-pointers/c_call_.c -index 634c4dd937..a75100b213 100644 ---- a/testsuite/tests/frame-pointers/c_call_.c -+++ b/testsuite/tests/frame-pointers/c_call_.c -@@ -16,10 +16,10 @@ - #include - #include "caml/mlvalues.h" - --void fp_backtrace(void); -+void fp_backtrace(value); - --value fp_backtrace_many_args(value a, value b, value c, value d, value e, -- value f, value g, value h, value i, value j, value k) -+value fp_backtrace_many_args(value argv0, value a, value b, value c, -+ value d, value e, value f, value g, value h, value i, value j, value k) - { - assert(Int_val(a) == 1); - assert(Int_val(b) == 2); -@@ -33,15 +33,15 @@ value fp_backtrace_many_args(value a, value b, value c, value d, value e, - assert(Int_val(j) == 10); - assert(Int_val(k) == 11); - -- fp_backtrace(); -+ fp_backtrace(argv0); - - return Val_unit; - } - --value fp_bactrace_many_args_argv(value *argv, int argc) -+value fp_bactrace_many_args_argv(value argv0, value *argv, int argc) - { - assert(argc == 11); - -- return fp_backtrace_many_args(argv[0], argv[1], argv[2], argv[3], argv[4], -- argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); -+ return fp_backtrace_many_args(argv0, argv[0], argv[1], argv[2], argv[3], -+ argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); - } -diff --git a/testsuite/tests/frame-pointers/effects.ml b/testsuite/tests/frame-pointers/effects.ml -index e14633a374..4d14190320 100644 ---- a/testsuite/tests/frame-pointers/effects.ml -+++ b/testsuite/tests/frame-pointers/effects.ml -@@ -11,26 +11,26 @@ open Printf - open Effect - open Effect.Deep - --external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] -+external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] - - type _ t += E : int -> int t - - let[@inline never] f () = - printf "# computation f\n%!"; -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - printf "# perform effect (E 0)\n%!"; - let v = perform (E 0) in - printf "# perform returns %d\n%!" v; -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - v + 1 - - let h (type a) (eff : a t) : ((a, 'b) continuation -> 'b) option = - let[@inline never] h_effect_e v k = - printf "# caught effect (E %d). continuing...\n%!" v; -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - let v = continue k (v + 1) in - printf "# continue returns %d\n%!" v; -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - v + 1 - in - match eff with -@@ -41,7 +41,7 @@ let h (type a) (eff : a t) : ((a, 'b) continuation -> 'b) option = - let v = - let[@inline never] v_retc v = - printf "# done %d\n%!" v; -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - v + 1 - in - match_with f () -diff --git a/testsuite/tests/frame-pointers/effects.reference b/testsuite/tests/frame-pointers/effects.reference -index c8bd0a391a..8ae3fc26df 100644 ---- a/testsuite/tests/frame-pointers/effects.reference -+++ b/testsuite/tests/frame-pointers/effects.reference -@@ -3,39 +3,24 @@ camlEffects.f - caml_runstack - camlEffects.entry - caml_program --caml_start_program --caml_main/caml_startup --main - # perform effect (E 0) - # caught effect (E 0). continuing... - camlEffects.h_effect_e - camlEffects.entry - caml_program --caml_start_program --caml_main/caml_startup --main - # perform returns 1 - camlEffects.f - caml_runstack - camlEffects.h_effect_e - camlEffects.entry - caml_program --caml_start_program --caml_main/caml_startup --main - # done 2 - camlEffects.v_retc - camlEffects.h_effect_e - camlEffects.entry - caml_program --caml_start_program --caml_main/caml_startup --main - # continue returns 3 - camlEffects.h_effect_e - camlEffects.entry - caml_program --caml_start_program --caml_main/caml_startup --main - # result=4 -diff --git a/testsuite/tests/frame-pointers/effects.run b/testsuite/tests/frame-pointers/effects.run -deleted file mode 100644 -index e96b5ea13a..0000000000 ---- a/testsuite/tests/frame-pointers/effects.run -+++ /dev/null -@@ -1,4 +0,0 @@ --#!/bin/sh -- --${program} 2>&1 \ -- | ${test_source_directory}/filter-locations.sh ${program} >${output} -diff --git a/testsuite/tests/frame-pointers/exception_handler.ml b/testsuite/tests/frame-pointers/exception_handler.ml -index 575f7329bf..95a4f0d75c 100644 ---- a/testsuite/tests/frame-pointers/exception_handler.ml -+++ b/testsuite/tests/frame-pointers/exception_handler.ml -@@ -8,7 +8,7 @@ all_modules = "${readonly_files} exception_handler.ml" - *) - - (* https://github.com/ocaml/ocaml/pull/11031 *) --external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] -+external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] - - exception Exn1 - exception Exn2 -@@ -38,7 +38,7 @@ let[@inline never] handler () = - let _ = Sys.opaque_identity x0 in - let _ = Sys.opaque_identity x1 in - let _ = Sys.opaque_identity x2 in -- fp_backtrace () -+ fp_backtrace Sys.argv.(0) - - let[@inline never] nested i = - begin -diff --git a/testsuite/tests/frame-pointers/exception_handler.reference b/testsuite/tests/frame-pointers/exception_handler.reference -index 513ca488b9..e012fb6d4f 100644 ---- a/testsuite/tests/frame-pointers/exception_handler.reference -+++ b/testsuite/tests/frame-pointers/exception_handler.reference -@@ -2,27 +2,15 @@ camlException_handler.handler - camlException_handler.bare - camlException_handler.entry - caml_program --caml_start_program --caml_main/caml_startup --main - camlException_handler.handler - camlException_handler.bare - camlException_handler.entry - caml_program --caml_start_program --caml_main/caml_startup --main - camlException_handler.handler - camlException_handler.nested - camlException_handler.entry - caml_program --caml_start_program --caml_main/caml_startup --main - camlException_handler.handler - camlException_handler.nested - camlException_handler.entry - caml_program --caml_start_program --caml_main/caml_startup --main -diff --git a/testsuite/tests/frame-pointers/exception_handler.run b/testsuite/tests/frame-pointers/exception_handler.run -deleted file mode 100644 -index e96b5ea13a..0000000000 ---- a/testsuite/tests/frame-pointers/exception_handler.run -+++ /dev/null -@@ -1,4 +0,0 @@ --#!/bin/sh -- --${program} 2>&1 \ -- | ${test_source_directory}/filter-locations.sh ${program} >${output} -diff --git a/testsuite/tests/frame-pointers/filter-locations.sh b/testsuite/tests/frame-pointers/filter-locations.sh -deleted file mode 100755 -index 31c7fc3189..0000000000 ---- a/testsuite/tests/frame-pointers/filter-locations.sh -+++ /dev/null -@@ -1,23 +0,0 @@ --#!/bin/sh -- --set -eu -- --program="${1}" --# https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed/29626460#29626460 --program_escaped=$(echo ${program} | sed 's/[^^\\]/[&]/g; s/\^/\\^/g; s/\\/\\\\/g') --regex_backtrace='^.*(\(.*\)+0x[[:xdigit:]]*)[0x[[:xdigit:]]*]$' --regex_trim_fun='^\(caml.*\)_[[:digit:]]*$' -- --# - Ignore backtrace not coming from the program binary --# - Discard the number suffix from OCaml function name --# - Remove strange '[0x.....]' entries inserted by some implementation --# of backtrace_symbols_fd --# - Keep the other lines --sed -e \ -- "/${regex_backtrace}/ { -- /^${program_escaped}/ ! d -- s/${regex_backtrace}/\1/ -- s/${regex_trim_fun}/\1/ -- s;caml_\(main\|startup\);caml_main/caml_startup; -- }" \ -- -e '/^\[0x/d' -diff --git a/testsuite/tests/frame-pointers/fp_backtrace.c b/testsuite/tests/frame-pointers/fp_backtrace.c -index a521218a38..cef7ccd9f2 100644 ---- a/testsuite/tests/frame-pointers/fp_backtrace.c -+++ b/testsuite/tests/frame-pointers/fp_backtrace.c -@@ -1,10 +1,17 @@ - #include --#include --#include --#include -+#include -+#include - #include -+#include -+#include - --#define ARRSIZE(a) (sizeof(a) / sizeof(*(a))) -+#include "caml/mlvalues.h" -+ -+#define ARR_SIZE(a) (sizeof(a) / sizeof(*(a))) -+ -+#define RE_FUNC_NAME "^.*\\((.+)\\+0x[[:xdigit:]]+\\) \\[0x[[:xdigit:]]+\\]$" -+#define RE_TRIM_FUNC "(caml.*)_[[:digit:]]+" -+#define CAML_ENTRY "caml_program" - - typedef struct frame_info - { -@@ -12,99 +19,138 @@ typedef struct frame_info - void* retaddr; /* rip */ - } frame_info; - --jmp_buf resume_buf; - -+/* -+ * A backtrace symbol looks like: -+ * ./path/to/binary(camlModule_fn_123+0xAABBCC) [0xAABBCCDDEE] -+ */ -+static const char* backtrace_symbol(const struct frame_info* fi) -+{ -+ char** symbols = backtrace_symbols(&fi->retaddr, 1); -+ if (!symbols) { -+ perror("backtrace_symbols"); -+ return NULL; -+ } - --static void signal_handler(int signum) -+ const char* symbol = strdup(symbols[0]); -+ free(symbols); -+ return symbol; -+} -+ -+static bool is_from_executable(const char* symbol, const char* execname) - { -- /* Should be safe to be called from a signal handler. -- * See 21.2.1 "Performing a nonlocal goto from a signal handler" from -- * The Linux Programming Interface, Michael Kerrisk */ -- siglongjmp(resume_buf, 1); -+ return strncmp(symbol, execname, strlen(execname)) == 0; - } - --static int install_signal_handlers(const int signals[], struct sigaction -- handlers[], int count) -+static regmatch_t func_name_from_symbol(const char* symbol) - { -- for (int i = 0; i < count; i++) { -- struct sigaction action = { 0 }; -- action.sa_handler = signal_handler; -- sigemptyset(&action.sa_mask); -- action.sa_flags = 0; -- -- if (sigaction(signals[i], &action, &handlers[i]) != 0) { -- perror("sigaction"); -- return -1; -- } -+ regex_t regex; -+ regmatch_t match[2] = { {-1, -1}, {-1, -1}}; -+ char errbuf[128]; -+ int err; -+ -+ err = regcomp(®ex, RE_FUNC_NAME, REG_EXTENDED); -+ if (err) { -+ regerror(err, ®ex, errbuf, ARR_SIZE(errbuf)); -+ fprintf(stderr, "regcomp: %s\n", errbuf); -+ return match[0]; - } -- return 0; -+ -+ err = regexec(®ex, symbol, ARR_SIZE(match), match, 0); -+ if (err == REG_NOMATCH) -+ return match[0]; -+ -+ return match[1]; - } - --static int restore_signal_handlers(const int signals[], struct sigaction -- handlers[], int count) -+static bool is_caml_entry(const char* symbol, const regmatch_t* funcname) - { -- for (int i = 0; i < count; i++) { -- if (sigaction(signals[i], &handlers[i], NULL) != 0) { -- perror("sigaction"); -- return -1; -- } -- } -- return 0; -+ //regoff_t len = funcname->rm_eo - funcname->rm_so; -+ //return strnstr(symbol + funcname->rm_so, CAML_ENTRY, len) == 0; -+ return strstr(symbol + funcname->rm_so, CAML_ENTRY) != NULL; - } - --static int safe_read(const struct frame_info* fi, struct frame_info** prev, -- void** retaddr) -+static regmatch_t trim_func_name(const char* symbol, const regmatch_t* funcname) - { -- /* Signals to ignore while attempting to read frame_info members */ -- const int signals[] = { SIGSEGV, SIGBUS }; -- /* Store original signal handers */ -- struct sigaction handlers[ARRSIZE(signals)] = { 0 }; -- int ret = 0; -- -- if (install_signal_handlers(signals, handlers, ARRSIZE(signals)) != 0) -- return -1; -- -- if (!sigsetjmp(resume_buf, 1)) { -- *prev = fi->prev; -- *retaddr = fi->retaddr; -- } else { -- ret = -1; -+ regex_t regex; -+ regmatch_t match[2] = { {-1, -1}, {-1, -1}}; -+ char errbuf[128]; -+ int err; -+ -+ err = regcomp(®ex, RE_TRIM_FUNC, REG_EXTENDED); -+ if (err) { -+ regerror(err, ®ex, errbuf, ARR_SIZE(errbuf)); -+ fprintf(stderr, "regcomp: %s\n", errbuf); -+ return match[0]; - } - -- if (restore_signal_handlers(signals, handlers, ARRSIZE(signals)) != 0) -- return -1; -+ match[0] = *funcname; -+ err = regexec(®ex, symbol, ARR_SIZE(match), match, REG_STARTEND); -+ if (err == REG_NOMATCH) { -+ /* match[0] has already been overwritten to hold the function full name for -+ regexec */ -+ return match[1]; -+ } - -- return ret; -+ return match[1]; - } - --static void print_location(void* addr) -+static void print_symbol(const char* symbol, const regmatch_t* match) - { -- if (!addr) -- return; -+ regoff_t off = match->rm_so; -+ regoff_t len = match->rm_eo - match->rm_so; - -- /* This requires the binary to be linked with '-rdynamic' */ -- backtrace_symbols_fd(&addr, 1, STDOUT_FILENO); -+ fprintf(stdout, "%.*s\n", len, symbol + off); -+ fflush(stdout); - } - --void fp_backtrace(void) -+void fp_backtrace(value argv0) - { -- struct frame_info *fi; -- struct frame_info* next; -- void* retaddr; -- -- fi = __builtin_frame_address(0); -- retaddr = __builtin_extract_return_addr(__builtin_return_address(0)); -- -- for (; fi; fi = next) { -- if (safe_read(fi, &next, &retaddr) != 0) -- return; -+ const char* execname = String_val(argv0); -+ struct frame_info* next = NULL; -+ const char* symbol = NULL; - -- print_location(retaddr); -+ for (struct frame_info* fi = __builtin_frame_address(0); fi; fi = next) { -+ next = fi->prev; - - /* Detect the simplest kind of infinite loop */ - if (fi == next) { -- printf("fp_backtrace: loop detected\n"); -- return; -+ fprintf(stderr, "fp_backtrace: loop detected\n"); -+ break; - } -+ -+ symbol = backtrace_symbol(fi); -+ if (!symbol) -+ continue; -+ -+ /* Skip entries not from the test */ -+ if (!is_from_executable(symbol, execname)) -+ goto skip; -+ -+ /* Exctract the full function name */ -+ regmatch_t funcname = func_name_from_symbol(symbol); -+ if (funcname.rm_so == -1) -+ goto skip; -+ -+ /* Trim numeric suffix from caml functions */ -+ regmatch_t functrimmed = trim_func_name(symbol, &funcname); -+ -+ /* Use the trimmed caml name if available, otherwise use the full function -+ name */ -+ const regmatch_t* match = (functrimmed.rm_so != -1) ? -+ &functrimmed : &funcname; -+ -+ print_symbol(symbol, match); -+ -+ /* Stop the backtrace at caml_program */ -+ if (is_caml_entry(symbol, &funcname)) -+ break; -+ -+skip: -+ free((void*)symbol); -+ symbol = NULL; - } -+ -+ if (symbol) -+ free((void*)symbol); - } -diff --git a/testsuite/tests/frame-pointers/reperform.ml b/testsuite/tests/frame-pointers/reperform.ml -index 1af8452e5f..da251c98a7 100644 ---- a/testsuite/tests/frame-pointers/reperform.ml -+++ b/testsuite/tests/frame-pointers/reperform.ml -@@ -11,7 +11,7 @@ all_modules = "${readonly_files} reperform.ml" - open Effect - open Effect.Deep - --external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] -+external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] - - type _ Effect.t += E : unit t - | F : unit t -@@ -22,7 +22,7 @@ let rec foo n = - if n = 5 then begin - perform E; - print_endline "# resumed..."; -- fp_backtrace () -+ fp_backtrace Sys.argv.(0) - end; - foo (n + 1) + n - end -diff --git a/testsuite/tests/frame-pointers/reperform.reference b/testsuite/tests/frame-pointers/reperform.reference -index 9ac6681d4b..e215f77169 100644 ---- a/testsuite/tests/frame-pointers/reperform.reference -+++ b/testsuite/tests/frame-pointers/reperform.reference -@@ -15,6 +15,3 @@ camlReperform.bar - caml_runstack - camlReperform.entry - caml_program --caml_start_program --caml_main/caml_startup --main -diff --git a/testsuite/tests/frame-pointers/reperform.run b/testsuite/tests/frame-pointers/reperform.run -deleted file mode 100644 -index e96b5ea13a..0000000000 ---- a/testsuite/tests/frame-pointers/reperform.run -+++ /dev/null -@@ -1,4 +0,0 @@ --#!/bin/sh -- --${program} 2>&1 \ -- | ${test_source_directory}/filter-locations.sh ${program} >${output} -diff --git a/testsuite/tests/frame-pointers/stack_realloc.ml b/testsuite/tests/frame-pointers/stack_realloc.ml -index 79e70c2add..f24e4795d5 100644 ---- a/testsuite/tests/frame-pointers/stack_realloc.ml -+++ b/testsuite/tests/frame-pointers/stack_realloc.ml -@@ -13,7 +13,7 @@ open Effect.Deep - - type _ t += E : int -> int t - --external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] -+external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] - external c_fun : unit -> int = "c_fun" - - let[@inline never][@local never] f x = x -@@ -42,7 +42,7 @@ let[@inline never] consume_stack () = - - let[@inline never] callback () = - consume_stack (); -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - 0 - - let _ = Callback.register "callback" callback -diff --git a/testsuite/tests/frame-pointers/stack_realloc.reference b/testsuite/tests/frame-pointers/stack_realloc.reference -index 016a03550a..e61d4104e0 100644 ---- a/testsuite/tests/frame-pointers/stack_realloc.reference -+++ b/testsuite/tests/frame-pointers/stack_realloc.reference -@@ -7,6 +7,3 @@ camlStack_realloc.f_comp - caml_runstack - camlStack_realloc.entry - caml_program --caml_start_program --caml_main/caml_startup --main -diff --git a/testsuite/tests/frame-pointers/stack_realloc.run b/testsuite/tests/frame-pointers/stack_realloc.run -deleted file mode 100644 -index e96b5ea13a..0000000000 ---- a/testsuite/tests/frame-pointers/stack_realloc.run -+++ /dev/null -@@ -1,4 +0,0 @@ --#!/bin/sh -- --${program} 2>&1 \ -- | ${test_source_directory}/filter-locations.sh ${program} >${output} -diff --git a/testsuite/tests/frame-pointers/stack_realloc2.ml b/testsuite/tests/frame-pointers/stack_realloc2.ml -index a3d21bf2bf..218dd6a1c3 100644 ---- a/testsuite/tests/frame-pointers/stack_realloc2.ml -+++ b/testsuite/tests/frame-pointers/stack_realloc2.ml -@@ -13,7 +13,7 @@ open Effect.Deep - - type _ t += E : int -> int t - --external fp_backtrace : unit -> unit = "fp_backtrace" [@@noalloc] -+external fp_backtrace : string -> unit = "fp_backtrace" [@@noalloc] - external c_fun : unit -> int = "c_fun" - - let[@inline never][@local never] f x = x -@@ -41,7 +41,7 @@ let[@inline never] consume_stack () = - ignore (gobbler count) - - let[@inline never] callback () = -- fp_backtrace (); -+ fp_backtrace Sys.argv.(0); - 0 - - let _ = Callback.register "callback" callback -diff --git a/testsuite/tests/frame-pointers/stack_realloc2.reference b/testsuite/tests/frame-pointers/stack_realloc2.reference -index ae492abd88..0051f3bad0 100644 ---- a/testsuite/tests/frame-pointers/stack_realloc2.reference -+++ b/testsuite/tests/frame-pointers/stack_realloc2.reference -@@ -7,6 +7,3 @@ camlStack_realloc2.f_comp - caml_runstack - camlStack_realloc2.entry - caml_program --caml_start_program --caml_main/caml_startup --main -diff --git a/testsuite/tests/frame-pointers/stack_realloc2.run b/testsuite/tests/frame-pointers/stack_realloc2.run -deleted file mode 100644 -index e96b5ea13a..0000000000 ---- a/testsuite/tests/frame-pointers/stack_realloc2.run -+++ /dev/null -@@ -1,4 +0,0 @@ --#!/bin/sh -- --${program} 2>&1 \ -- | ${test_source_directory}/filter-locations.sh ${program} >${output} --- -2.43.0 - diff --git a/0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch b/0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch deleted file mode 100644 index 16c63f9..0000000 --- a/0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 81d3fb3e20afede32298e4d3e78bcebf6a22858a Mon Sep 17 00:00:00 2001 -From: Vincent Laviron -Date: Fri, 15 Dec 2023 10:00:52 +0100 -Subject: [PATCH 4/4] Fix s390x stack reallocation code in PIC mode - -(cherry picked from commit c40a955c029a203d0d7f05718e297e66987ec87f) ---- - asmcomp/s390x/emit.mlp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp -index 35ade079f6..0212cf3b00 100644 ---- a/asmcomp/s390x/emit.mlp -+++ b/asmcomp/s390x/emit.mlp -@@ -751,7 +751,7 @@ let fundecl fundecl = - ` lay %r15, -8(%r15)\n`; - ` stg %r14, 0(%r15)\n`; - ` lgfi %r12, {emit_int s}\n`; -- ` brasl %r14, {emit_symbol "caml_call_realloc_stack"}\n`; -+ emit_call "caml_call_realloc_stack"; - ` lg %r14, 0(%r15)\n`; - ` la %r15, 8(%r15)\n`; - ` brcl 15, {emit_label ret}\n` --- -2.43.0 - diff --git a/ocaml.spec b/ocaml.spec index d8d069b..64db332 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -42,16 +42,17 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.1.1 -Release: 4%{?dist} +Version: 5.2.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception URL: https://www.ocaml.org +VCS: https://github.com/ocaml/ocaml -Source0: https://github.com/ocaml/ocaml/archive/%{version}/%{name}-%{version}.tar.gz +Source0: %{vcs}/archive/%{version}%{rcver}/%{name}-%{version}%{rcver}.tar.gz Source1: macros.ocaml-rpm Source2: ocaml_files.py @@ -74,13 +75,6 @@ Source2: ocaml_files.py Patch: 0001-Don-t-add-rpaths-to-libraries.patch Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch -# https://github.com/ocaml/ocaml/pull/11594 -Patch: 0003-Update-framepointers-tests-to-avoid-false-positive-w.patch - -# https://github.com/ocaml/ocaml/issues/12829 -# https://github.com/ocaml/ocaml/pull/12831 -Patch: 0004-Fix-s390x-stack-reallocation-code-in-PIC-mode.patch - BuildRequires: make BuildRequires: git BuildRequires: gcc @@ -111,8 +105,8 @@ Requires: ocaml-runtime%{?_isa} = %{version}-%{release} # Force ocaml-srpm-macros to be at the latest version, both for builds # and installs, since OCaml 5.1 has a different set of native code # generators than previous versions. -BuildRequires: ocaml-srpm-macros >= 9 -Requires: ocaml-srpm-macros >= 9 +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) @@ -368,8 +362,6 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %{_bindir}/ocamloptp %endif -%{_libdir}/ocaml/camlheader -%{_libdir}/ocaml/camlheader_ur %{_libdir}/ocaml/expunge %{_libdir}/ocaml/ld.conf %{_libdir}/ocaml/Makefile.config @@ -410,8 +402,6 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %{_libdir}/ocaml/*.cmo %{_libdir}/ocaml/*.cmi %{_libdir}/ocaml/*.cma -%{_libdir}/ocaml/camlheaderd -%{_libdir}/ocaml/camlheaderi %{_libdir}/ocaml/stublibs %dir %{_libdir}/ocaml/dynlink %{_libdir}/ocaml/dynlink/META @@ -424,6 +414,7 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %{_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 @@ -470,6 +461,10 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* Thu May 23 2024 Jerry James - 5.2.0-1 +- Version 5.2.0 +- 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 diff --git a/sources b/sources index f4deb78..c8a1b16 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.1.1.tar.gz) = e4aa78afc9a59f604881f14093f4298ebcb005daeb8132a076fe6d24fdf8b59132cbfa2cfe677f1db1891351d3d637c621f24077e531cac6753c264fc7f5fbea +SHA512 (ocaml-5.2.0.tar.gz) = 78115690186c13c1f2480e4812a9fe34cce2c28bf8a89d5c9810bca0391f930cecd9cee2b53daca8a32da1815628b33be68f3948f1ad03fa50b72b14e3ea84f2 From 7f5edb92c01292a25db532cf468fbc8894fdcd9e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 29 May 2024 10:48:49 +0100 Subject: [PATCH 72/91] New upstream version 5.2.0 (RHBZ#2269805) --- ...onisation-and-consistency-with-trunk.patch | 90 +++ 0002-Changes-copy-editing.patch | 515 ++++++++++++++++++ ...> 0003-Don-t-add-rpaths-to-libraries.patch | 8 +- ...-Allow-user-defined-C-compiler-flags.patch | 8 +- ...transitive-closure-in-invariant_para.patch | 114 ++++ ocaml.spec | 29 +- 6 files changed, 747 insertions(+), 17 deletions(-) create mode 100644 0001-Changes-synchronisation-and-consistency-with-trunk.patch create mode 100644 0002-Changes-copy-editing.patch rename 0001-Don-t-add-rpaths-to-libraries.patch => 0003-Don-t-add-rpaths-to-libraries.patch (79%) rename 0002-configure-Allow-user-defined-C-compiler-flags.patch => 0004-configure-Allow-user-defined-C-compiler-flags.patch (88%) create mode 100644 0005-flambda-Improve-transitive-closure-in-invariant_para.patch diff --git a/0001-Changes-synchronisation-and-consistency-with-trunk.patch b/0001-Changes-synchronisation-and-consistency-with-trunk.patch new file mode 100644 index 0000000..5f865d0 --- /dev/null +++ b/0001-Changes-synchronisation-and-consistency-with-trunk.patch @@ -0,0 +1,90 @@ +From 5538fa66e94fad3d2b4f110d23bef3b4d2d6342c Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Mon, 13 May 2024 11:39:37 +0200 +Subject: [PATCH 1/5] Changes: synchronisation and consistency with trunk + +--- + Changes | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +diff --git a/Changes b/Changes +index 208d5e8697..1af198ba77 100644 +--- a/Changes ++++ b/Changes +@@ -140,9 +140,6 @@ OCaml 5.2.0 + (Guillaume Munch-Maccagnoni, bug reports and suggestion by Mark + Shinwell, review by Nick Barnes and Stephen Dolan) + +-- #12876: Port ThreadSanitizer support to Linux on POWER +- (Miod Vallat, review by Tim McGilchrist) +- + - #12408: `Domain.spawn` no longer leaks its functional argument for + the whole duration of the children domain lifetime. + (Guillaume Munch-Maccagnoni, review by Gabriel Scherer) +@@ -156,8 +153,10 @@ OCaml 5.2.0 + review by Damien Doligez, Sébastien Hinderer, Jacques-Henri Jourdan, Luc + Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer) + +-- #11911, #12381: Restore statmemprof functionality in part +- (API changes in Gc.Memprof). (Nick Barnes) ++- #11911, #12381: Restore statmemprof functionality in part, with ++ some API changes in Gc.Memprof. ++ (Nick Barnes, review by Jacques-Henri Jourdan ++ and Guillaume Munch-Maccagnoni). + + - #12430: Simplify dynamic bytecode loading in Meta.reify_bytecode + (Stephen Dolan, review by Sébastien Hinderer, Vincent Laviron and Xavier +@@ -216,9 +215,10 @@ OCaml 5.2.0 + Ojeda Bar) + + - #11911, #12382, #12383: Restore statmemprof functionality in part +- (backtrace buffers, per-thread and per-domain data structures). +- (Nick Barnes, review by Gabriel Scherer, Fabrice Buoro, Sadiq +- Jaffer, and Guillaume Munch-Maccagnoni). ++ (backtrace buffers, per-thread and per-domain data structures, ++ GC/allocation interface). (Nick Barnes, review by Gabriel Scherer, ++ Fabrice Buoro, Sadiq Jaffer, Guillaume Munch-Maccagnoni, and ++ Jacques-Henri Jourdan). + + - #12735: Store both ends of the stack chain in continuations + (Leo White, review by Miod Vallat and KC Sivaramakrishnan) +@@ -248,6 +248,9 @@ OCaml 5.2.0 + Hari Hara Naveen S, reviewed by Fabrice Buoro, Gabriel Scherer and + Miod Vallat) + ++- #12876: Port ThreadSanitizer support to Linux on POWER ++ (Miod Vallat, review by Tim McGilchrist) ++ + - #12886: Reinitialize IO mutexes after fork + (Max Slater, review by Guillaume Munch-Maccagnoni and Xavier Leroy) + +@@ -990,7 +993,7 @@ OCaml 5.1.0 (14 September 2023) + `Seq.find_mapi`, `Seq.find_index`, `Array.find_mapi`, `Array.find_index`, + `Float.Array.find_opt`, `Float.Array.find_index`, `Float.Array.find_map`, + `Float.Array.find_mapi`. +- (Sima Kinsart, review by Daniel Bünzli and Nicolás Ojeda Bär) ++ (Tima Kinsart, review by Daniel Bünzli and Nicolás Ojeda Bär) + + - #11410: Add Set.to_list, Map.to_list, Map.of_list, + `Map.add_to_list: key -> 'a -> 'a list t -> 'a list t`. +@@ -1771,7 +1774,7 @@ Some of those changes will benefit all OCaml packages. + + - #11846: Mark rbx as destroyed at C call for Win64 (mingw-w64 and Cygwin64). + Reserve the shadow store for the ABI in the c_stack_link struct instead of +- explictly when calling C functions. This simultaneously reduces the number of ++ explicitly when calling C functions. This simultaneously reduces the number of + stack pointer manipulations and also fixes a bug when calling noalloc + functions where the shadow store was not being reserved. + (David Allsopp, report by Vesa Karvonen, review by Xavier Leroy and +@@ -2791,7 +2794,7 @@ OCaml 4.14.0 (28 March 2022) + - #8516: Change representation of class signatures + (Leo White, review by Thomas Refis) + +-- #9444: -dtypedtree, print more explictly extra nodes in pattern ast. ++- #9444: -dtypedtree, print more explicitly extra nodes in pattern ast. + (Frédéric Bour, review by Gabriel Scherer) + + - #10337: Normalize type_expr nodes on access +-- +2.44.0 + diff --git a/0002-Changes-copy-editing.patch b/0002-Changes-copy-editing.patch new file mode 100644 index 0000000..05f48ac --- /dev/null +++ b/0002-Changes-copy-editing.patch @@ -0,0 +1,515 @@ +From 7a20c9322f827923baa6a9907998f670463ce447 Mon Sep 17 00:00:00 2001 +From: Florian Angeletti +Date: Mon, 13 May 2024 14:28:08 +0200 +Subject: [PATCH 2/5] Changes copy-editing + +--- + Changes | 398 ++++++++++++++++++++++++++++---------------------------- + 1 file changed, 201 insertions(+), 197 deletions(-) + +diff --git a/Changes b/Changes +index 1af198ba77..75842fc216 100644 +--- a/Changes ++++ b/Changes +@@ -1,5 +1,5 @@ +-OCaml 5.2.0 +------------- ++OCaml 5.2.0 (13 May 2024) ++------------------------- + + (Changes that can break existing programs are marked with a "*") + +@@ -12,60 +12,6 @@ OCaml 5.2.0 + - #12667: extend the latter to POWER 64 bits, big-endian, ELFv2 ABI + (A. Wilcox, review by Xavier Leroy) + +-### Language features: +- +-- #12295, #12568: Give `while true' a polymorphic type, similarly to +- `assert false' +- (Jeremy Yallop, review by Nicolás Ojeda Bär and Gabriel Scherer, +- suggestion by Rodolphe Lepigre and John Whitington) +- +-- #12315: Use type annotations from arguments in let rec +- (Stephen Dolan, review by Gabriel Scherer) +- +-- #11252, RFC 27: Support raw identifier syntax \#foo +- (Stephen Dolan, review by David Allsopp, Gabriel Scherer and Olivier Nicole) +- +-- #12044: Add local module open syntax for types. +- ``` +- module A = struct +- type t = int +- type r = unit +- type s = string +- end +- +- type example = A.(t * r * s) +- ``` +- (Alistair O'Brien, review by Gabriel Scherer, Nicolás Ojeda Bär +- and Florian Angeletti) +- +-- #12456: Document the incompatibility between effects on the one +- hand, and `caml_callback` and asynchronous callbacks (signal +- handlers, finalisers, memprof callbacks...) on the other hand. +- (Guillaume Munch-Maccagnoni, review by KC Sivaramakrishnan) +- +-- #12375: allow use of [@untagged] for all immediate types like char, bool, +- and variant with only constant constructors. +- (Christophe Raffalli, review by Gabriel Scherer) +- +-* #12502: the compiler now normalizes the newline sequence \r\n to +- a single \n character during lexing, to guarantee that the semantics +- of newlines in string literals is not modified by Windows tools +- transforming \n into \r\n in source files. +- Warning 29 [eol-in-string] is not emitted anymore, as the normalization +- gives a more robust semantics to newlines in string literals. +- (Gabriel Scherer and Damien Doligez, review by Daniel Bünzli, David +- Allsopp, Andreas Rossberg, Xavier Leroy, report by Andreas Rossberg) +- +-- #13130: minor fixes to pprintast for raw identifiers and local module open +- syntax for types. +- (Chet Murthy, review by Gabriel Scherer) +- +-### Type system: +- +-- #12313, #11799: Do not re-build as-pattern type when a ground type annotation +- is given. This allows to work around problems with GADTs in as-patterns. +- (Jacques Garrigue, report by Leo White, review by Gabriel Scherer) +- + ### Runtime system: + + - #12193: Re-introduce GC compaction for shared pools +@@ -76,6 +22,12 @@ OCaml 5.2.0 + David Allsopp, Miod Vallat, Artem Pianykh, Stephen Dolan, Mark Shinwell + and KC Sivaramakrishnan) + ++- #12114: Add ThreadSanitizer support ++ (Fabrice Buoro and Olivier Nicole, based on an initial work by Anmol Sahoo, ++ review by Damien Doligez, Sébastien Hinderer, Jacques-Henri Jourdan, Luc ++ Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer) ++ ++ + - #12850: Update Gc.quick_stat data at the end of major cycles and compaction + This PR adds an additional caml_collect_gc_stats_sample_stw to the major heap + cycling stw. This means that Gc.quick_stat now actually reflects the state of +@@ -148,11 +100,6 @@ OCaml 5.2.0 + arise at specific locations during domain creation and shutdown. + (Guillaume Munch-Maccagnoni, review by Gabriel Scherer) + +-- #12114: Add ThreadSanitizer support +- (Fabrice Buoro and Olivier Nicole, based on an initial work by Anmol Sahoo, +- review by Damien Doligez, Sébastien Hinderer, Jacques-Henri Jourdan, Luc +- Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer) +- + - #11911, #12381: Restore statmemprof functionality in part, with + some API changes in Gc.Memprof. + (Nick Barnes, review by Jacques-Henri Jourdan +@@ -264,34 +211,48 @@ OCaml 5.2.0 + (Olivier Nicole, suggested by Stephen Dolan, review by Gabriel Scherer, + Miod Vallat and Damien Doligez) + +-### Code generation and optimizations: ++### Language features: + +-- #11239: on x86-64 and RISC-V, reduce alignment of OCaml stacks from 16 to 8. +- This reduces stack usage. It's only C stacks that require 16-alignment. +- (Xavier Leroy, review by Gabriel Scherer and Stephen Dolan) ++- #12295, #12568: Give `while true' a polymorphic type, similarly to ++ `assert false' ++ (Jeremy Yallop, review by Nicolás Ojeda Bär and Gabriel Scherer, ++ suggestion by Rodolphe Lepigre and John Whitington) + +-- #12311: on POWER, 32-bit FP numbers stored in memory (e.g. in bigarrays) +- were not correctly rounded sometimes. +- (Xavier Leroy, review by Anil Madhavapeddy and Tim McGilchrist) ++- #12044: Add local module open syntax for types. ++ ``` ++ module A = struct ++ type t = int ++ type r = unit ++ type s = string ++ end + +-- #12551, #12608, #12782, #12596: Overhaul of recursive value compilation. +- Non-function recursive bindings are now forbidden from Lambda onwards, +- and compiled using a new Value_rec_compiler module. +- (Vincent Laviron and Lunia Ayanides, review by Gabriel Scherer, +- Stefan Muenzel and Nathanaëlle Courant) ++ type example = A.(t * r * s) ++ ``` ++ (Alistair O'Brien, review by Gabriel Scherer, Nicolás Ojeda Bär ++ and Florian Angeletti) + +-- #1809, #12181: rewrite `compare x y op 0` to `x op y` when values are integers +- (Xavier Clerc, Stefan Muenzel, review by Gabriel Scherer and Vincent Laviron) ++- #11252, RFC 27: Support raw identifier syntax \#foo ++ (Stephen Dolan, review by David Allsopp, Gabriel Scherer and Olivier Nicole) + +-- #12825: disable common subexpression elimination for atomic loads... again. +- (Gabriel Scherer, review by KC Sivaramakrishnan, Xavier Leroy +- and Vincent Laviron, report by Vesa Karvonen) ++ ++- #12315: Use type annotations from arguments in let rec ++ (Stephen Dolan, review by Gabriel Scherer) ++ ++- #12375: allow use of [@untagged] for all immediate types like char, bool, ++ and variant with only constant constructors. ++ (Christophe Raffalli, review by Gabriel Scherer) ++ ++* #12502: the compiler now normalizes the newline sequence \r\n to ++ a single \n character during lexing, to guarantee that the semantics ++ of newlines in string literals is not modified by Windows tools ++ transforming \n into \r\n in source files. ++ Warning 29 [eol-in-string] is not emitted anymore, as the normalization ++ gives a more robust semantics to newlines in string literals. ++ (Gabriel Scherer and Damien Doligez, review by Daniel Bünzli, David ++ Allsopp, Andreas Rossberg, Xavier Leroy, report by Andreas Rossberg) + + ### Standard library: + +-- #12716: Add `Format.pp_print_nothing` function. +- (Léo Andrès, review by Gabriel Scherer and Nicolás Ojeda Bär) +- + - #11563: Add the Dynarray module to the stdlib. Dynamic arrays are + arrays whose length can be changed by adding or removing elements at + the end, similar to 'vectors' in C++ or Rust. +@@ -299,6 +260,10 @@ OCaml 5.2.0 + Daniel Bünzli, Guillaume Munch-Maccagnoni, Clément Allain, + Damien Doligez, Wiktor Kuchta and Pieter Goetschalckx) + ++ ++- #12716: Add `Format.pp_print_nothing` function. ++ (Léo Andrès, review by Gabriel Scherer and Nicolás Ojeda Bär) ++ + * #6732, #12423: Make Buffer.add_substitute surjective and fix its + documentation. + (Damien Doligez, review by Antonin Décimo) +@@ -380,6 +345,35 @@ OCaml 5.2.0 + C API. + (David Allsopp, review by Nicolás Ojeda Bär and Xavier Leroy) + ++### Type system: ++ ++- #12313, #11799: Do not re-build as-pattern type when a ground type annotation ++ is given. This allows to work around problems with GADTs in as-patterns. ++ (Jacques Garrigue, report by Leo White, review by Gabriel Scherer) ++ ++### Code generation and optimizations: ++ ++- #11239: on x86-64 and RISC-V, reduce alignment of OCaml stacks from 16 to 8. ++ This reduces stack usage. It's only C stacks that require 16-alignment. ++ (Xavier Leroy, review by Gabriel Scherer and Stephen Dolan) ++ ++- #12311: on POWER, 32-bit FP numbers stored in memory (e.g. in bigarrays) ++ were not correctly rounded sometimes. ++ (Xavier Leroy, review by Anil Madhavapeddy and Tim McGilchrist) ++ ++- #12551, #12608, #12782, #12596: Overhaul of recursive value compilation. ++ Non-function recursive bindings are now forbidden from Lambda onwards, ++ and compiled using a new Value_rec_compiler module. ++ (Vincent Laviron and Lunia Ayanides, review by Gabriel Scherer, ++ Stefan Muenzel and Nathanaëlle Courant) ++ ++- #1809, #12181: rewrite `compare x y op 0` to `x op y` when values are integers ++ (Xavier Clerc, Stefan Muenzel, review by Gabriel Scherer and Vincent Laviron) ++ ++- #12825: disable common subexpression elimination for atomic loads... again. ++ (Gabriel Scherer, review by KC Sivaramakrishnan, Xavier Leroy ++ and Vincent Laviron, report by Vesa Karvonen) ++ + ### Other libraries: + + - #12213: Dynlink library, improve legibility of error messages +@@ -390,98 +384,14 @@ OCaml 5.2.0 + instead of `value`. + (Xavier Leroy, review by David Allsopp) + +-### Tools: +- +-- #12340: testsuite: collect known issues with current -short-paths +- implementation for existential types +- (Florian Angeletti, Samuel Hym, review by Florian Angeletti and Thomas Refis) +- +-- #12147: ocamllex: Allow carriage returns at the end of line directives. +- (SeungCheol Jung, review by Nicolás Ojeda Bär) +- +-- #12260: Fix invalid_argument on some external or module aliases in ocamlnat +- (Fabian Hemmer, review by Vincent Laviron) +- +-- #12185: New script language for ocamltest. +- (Damien Doligez with Florian Angeletti, Sébastien Hinderer, Gabriel Scherer, +- review by Sébastien Hinderer and Gabriel Scherer) +- +-- #12371: ocamltest: fix recursive expansion of variables. +- (Antonin Décimo, Damien Doligez, review by Sébastien Hinderer, +- Damien Doligez, Gabriel Scherer, and Xavier Leroy) +- +-* #12497, #12613: Make ocamlc/ocamlopt fail with an error when no +- input files are specified to build an executable. +- (Antonin Décimo, review by Sébastien Hinderer) +- +-- #12576: ocamldep: various refactors. +- (Antonin Décimo, review by Florian Angeletti, Gabriel Scherer, and Léo Andrès) +- +-- #12615: ocamldoc: get rid of the odoc_literate and odoc_todo generators. +- (Sébaistien Hinderer, review by Gabriel Scherer and Florian Angeletti) +- +-- #12624: Use $XDG_CONFIG_DIRS in addition to $XDG_CONFIG_HOME when searching +- for init.ml and use this to extend init.ml support to the toplevel when +- running on Windows. +- (David Allsopp, report by Jonah Beckford, review by Nicolás Ojeda Bär and +- Antonin Décimo) +- +-- #12688: Setting the env variable `NO_COLOR` with an empty value no longer +- has effects. Previously, setting `NO_COLOR` with any value, including +- the empty value, would disable colors (unless `OCAML_COLOR` is also set). +- After this change, the user must set `NO_COLOR` with an non-empty value +- to disable colors. This reflects a specification clarification/change +- from the upstream website at https://no-color.org. +- (Favonia, review by Gabriel Scherer) +- +-- #12744: ocamltest: run tests in recursive subdirs more eagerly +- (Nick Roberts, review by Nicolás Ojeda Bär) +- +-- #12901, 12908: ocamllex: add overflow checks to prevent generating incorrect +- lexers; use unsigned numbers in the table encoding when possible. +- (Vincent Laviron, report by Edwin Török, review by Xavier Leroy) +- +-### Manual and documentation: +- +-- #12338: clarification of the documentation of process related function in +- the unix module regarding the first element of args and shell's pid. +- (Christophe Raffalli, review by Florian Angeletti) +- +-- #12473: Document in runtime/memory.c our current understanding of +- accesses to the OCaml heap from the C runtime code -- the problem +- of hybrid programs mixing two memory models. +- (Gabriel Scherer and Guillaume Munch-Maccagnoni, review by Olivier +- Nicole and Xavier Leroy) +- +-- #12694: Document in runtime/tsan.c the TSan instrumentation choices and the +- consequences with regard to the memory model. +- (Olivier Nicole, review by Miod Vallat, Gabriel Scherer, Guillaume +- Munch-Maccagnoni and Fabrice Buoro) +- +-- #12802: Add manual chapter about ThreadSanitizer support +- (Olivier Nicole, review by Miod Vallat, Sebastien Hinderer, Fabrice Buoro, +- Gabriel Scherer and KC Sivaramakrishnan) +- +-- #12819: Clarify which runtime interactions are allowed in custom ops +- (Basile Clément, review by Guillaume Munch-Maccagnoni and Xavier Leroy) +- +-- #12840: manual: update runtime tracing chapter for custom events (ex #12335) +- (Lucas Pluvinage, Sadiq Jaffer and Olivier Nicole, review by Gabriel Scherer, +- David Allsopp, Tim McGilchrist and Thomas Leonard) +- +-- #13066, update OCAMLRUNPARAM documentation for the stack size parameter l +- (Florian Angeletti, review by Nicolás Ojeda Bär, Tim McGilchrist, and +- Miod Vallat) +- +-- #13078: update Format tutorial on structural boxes to mention alignment +- questions. +- (Edwin Török, review by Florian Angeletti) +- +-- #13092: document the existence of the `[@@poll error]` built-in attribute +- (Florian Angeletti, review by Gabriel Scherer) +- + ### Compiler user-interface and warnings: + ++- #11989, #12246, RFC 31: New flag, -H, to allow for transitive dependencies ++ without including them in the initial environment. ++ (Chris Casinghino, François Bobot, and Gabriel Scherer, review by Leo White ++ and Stefan Muenzel, RFC by François Bobot) ++ ++ + * #10613, #12405: Simplify the values used for the system variable (`system:` in + `ocamlopt -config` or the `Config.system` constant). In particular, s390x and + ppc64 now report "linux" instead of "elf"; all variants of 32-bit ARM on Linux +@@ -493,11 +403,6 @@ OCaml 5.2.0 + (David Allsopp, request by Kate Deplaix, review by Sébastien Hinderer and + Xavier Leroy) + +-- #11989, #12246, RFC 31: New flag, -H, to allow for transitive dependencies +- without including them in the initial environment. +- (Chris Casinghino, François Bobot, and Gabriel Scherer, review by Leo White +- and Stefan Muenzel, RFC by François Bobot) +- + - #12247: configure: --disable-ocamldebug can now be used instead + of --disable-debugger (which remains available for compatibility) + (Gabriel Scherer, review by Damien Doligez and Sébastien Hinderer) +@@ -546,9 +451,125 @@ OCaml 5.2.0 + + * #12942: Fix an line ordering in some module inclusion error messages + (Nick Roberts, review by Florian Angeletti, report by Carl Eastlund) ++### Manual and documentation: ++ ++- #12338: clarification of the documentation of process related function in ++ the unix module regarding the first element of args and shell's pid. ++ (Christophe Raffalli, review by Florian Angeletti) ++ ++- #12473: Document in runtime/memory.c our current understanding of ++ accesses to the OCaml heap from the C runtime code -- the problem ++ of hybrid programs mixing two memory models. ++ (Gabriel Scherer and Guillaume Munch-Maccagnoni, review by Olivier ++ Nicole and Xavier Leroy) ++ ++- #12456: Document the incompatibility between effects on the one ++ hand, and `caml_callback` and asynchronous callbacks (signal ++ handlers, finalisers, memprof callbacks...) on the other hand. ++ (Guillaume Munch-Maccagnoni, review by KC Sivaramakrishnan) ++ ++- #12694: Document in runtime/tsan.c the TSan instrumentation choices and the ++ consequences with regard to the memory model. ++ (Olivier Nicole, review by Miod Vallat, Gabriel Scherer, Guillaume ++ Munch-Maccagnoni and Fabrice Buoro) ++ ++- #12802: Add manual chapter about ThreadSanitizer support ++ (Olivier Nicole, review by Miod Vallat, Sebastien Hinderer, Fabrice Buoro, ++ Gabriel Scherer and KC Sivaramakrishnan) ++ ++- #12819: Clarify which runtime interactions are allowed in custom ops ++ (Basile Clément, review by Guillaume Munch-Maccagnoni and Xavier Leroy) ++ ++- #12840: manual: update runtime tracing chapter for custom events (ex #12335) ++ (Lucas Pluvinage, Sadiq Jaffer and Olivier Nicole, review by Gabriel Scherer, ++ David Allsopp, Tim McGilchrist and Thomas Leonard) ++ ++- #13066, update OCAMLRUNPARAM documentation for the stack size parameter l ++ (Florian Angeletti, review by Nicolás Ojeda Bär, Tim McGilchrist, and ++ Miod Vallat) ++ ++- #13078: update Format tutorial on structural boxes to mention alignment ++ questions. ++ (Edwin Török, review by Florian Angeletti) ++ ++- #13092: document the existence of the `[@@poll error]` built-in attribute ++ (Florian Angeletti, review by Gabriel Scherer) ++ ++### Tools: ++ ++- #12340: testsuite: collect known issues with current -short-paths ++ implementation for existential types ++ (Florian Angeletti, Samuel Hym, review by Florian Angeletti and Thomas Refis) ++ ++- #12147: ocamllex: Allow carriage returns at the end of line directives. ++ (SeungCheol Jung, review by Nicolás Ojeda Bär) ++ ++- #12260: Fix invalid_argument on some external or module aliases in ocamlnat ++ (Fabian Hemmer, review by Vincent Laviron) ++ ++- #12185: New script language for ocamltest. ++ (Damien Doligez with Florian Angeletti, Sébastien Hinderer, Gabriel Scherer, ++ review by Sébastien Hinderer and Gabriel Scherer) ++ ++- #12371: ocamltest: fix recursive expansion of variables. ++ (Antonin Décimo, Damien Doligez, review by Sébastien Hinderer, ++ Damien Doligez, Gabriel Scherer, and Xavier Leroy) ++ ++* #12497, #12613: Make ocamlc/ocamlopt fail with an error when no ++ input files are specified to build an executable. ++ (Antonin Décimo, review by Sébastien Hinderer) ++ ++- #12576: ocamldep: various refactors. ++ (Antonin Décimo, review by Florian Angeletti, Gabriel Scherer, and Léo Andrès) ++ ++- #12615: ocamldoc: get rid of the odoc_literate and odoc_todo generators. ++ (Sébaistien Hinderer, review by Gabriel Scherer and Florian Angeletti) ++ ++- #12624: Use $XDG_CONFIG_DIRS in addition to $XDG_CONFIG_HOME when searching ++ for init.ml and use this to extend init.ml support to the toplevel when ++ running on Windows. ++ (David Allsopp, report by Jonah Beckford, review by Nicolás Ojeda Bär and ++ Antonin Décimo) ++ ++- #12688: Setting the env variable `NO_COLOR` with an empty value no longer ++ has effects. Previously, setting `NO_COLOR` with any value, including ++ the empty value, would disable colors (unless `OCAML_COLOR` is also set). ++ After this change, the user must set `NO_COLOR` with an non-empty value ++ to disable colors. This reflects a specification clarification/change ++ from the upstream website at https://no-color.org. ++ (Favonia, review by Gabriel Scherer) ++ ++- #12744: ocamltest: run tests in recursive subdirs more eagerly ++ (Nick Roberts, review by Nicolás Ojeda Bär) ++ ++- #12901, 12908: ocamllex: add overflow checks to prevent generating incorrect ++ lexers; use unsigned numbers in the table encoding when possible. ++ (Vincent Laviron, report by Edwin Török, review by Xavier Leroy) + + ### Internal/compiler-libs changes: + ++- #12508 : Add compiler-side support for project-wide occurrences in Merlin, by ++ generating index tables of all identifier occurrences. This extra data in .cmt ++ files is only added when the new flag -bin-annot-occurrences is passed. ++ (Ulysse Gérard, Nathanaëlle Courant, suggestions by Gabriel Scherer and Thomas ++ Refis, review by Florian Angeletti, Gabriel Scherer and Thomas Refis) ++ ++- #12236, #12386, #12391, #12496, #12673: Use syntax as sole determiner of arity ++ This changes function arity to be based solely on the source program's ++ parsetree. Previously, the heuristic for arity had more subtle heuristics ++ that involved type information about patterns. Function arity is important ++ because it determines when a pattern match's effects run and is an input ++ into the fast path for function application. ++ ++ This change affects tooling: it changes the function constructs in parsetree ++ and typedtree. ++ ++ See https://github.com/ocaml/RFCs/pull/32 for the original RFC. ++ ++ (Nick Roberts; review by Richard Eisenberg, Leo White, and Gabriel Scherer; ++ RFC by Stephen Dolan) ++ ++ + - #12639: parsing: Attach a location to the RHS of Ptyp_alias + and improve the 'alias type mismatch' error message. + (Jules Aguillon, review by Florian Angeletti) +@@ -583,21 +604,6 @@ OCaml 5.2.0 + in Typecore in favor of local mutable state. + (Nick Roberts, review by Takafumi Saikawa) + +-- #12236, #12386, #12391, #12496, #12673: Use syntax as sole determiner of arity +- This changes function arity to be based solely on the source program's +- parsetree. Previously, the heuristic for arity had more subtle heuristics +- that involved type information about patterns. Function arity is important +- because it determines when a pattern match's effects run and is an input +- into the fast path for function application. +- +- This change affects tooling: it changes the function constructs in parsetree +- and typedtree. +- +- See https://github.com/ocaml/RFCs/pull/32 for the original RFC. +- +- (Nick Roberts; review by Richard Eisenberg, Leo White, and Gabriel Scherer; +- RFC by Stephen Dolan) +- + - #12542: Minor bugfix to #12236: restore dropped call to `instance` + (Nick Roberts, review by Jacques Garrigue) + +@@ -650,12 +656,6 @@ OCaml 5.2.0 + - #12764: Move all installable headers in `caml/` sub-directories. + (Antonin Décimo, review by Gabriel Scherer and David Allsopp) + +-- #12508 : Add compiler-side support for project-wide occurrences in Merlin, by +- generating index tables of all identifier occurrences. This extra data in .cmt +- files is only added when the new flag -bin-annot-occurrences is passed. +- (Ulysse Gérard, Nathanaëlle Courant, suggestions by Gabriel Scherer and Thomas +- Refis, review by Florian Angeletti, Gabriel Scherer and Thomas Refis) +- + - #12914: Slightly change the s390x assembly dialect in order to build with + Clang's integrated assembler. + (Miod Vallat, review by Gabriel Scherer) +@@ -888,6 +888,10 @@ OCaml 5.2.0 + - #13094: Fix undefined behavior of left-shifting a negative number. + (Antonin Décimo, review by Miod Vallat and Nicolás Ojeda Bär) + ++- #13130: minor fixes to pprintast for raw identifiers and local module open ++ syntax for types. ++ (Chet Murthy, review by Gabriel Scherer) ++ + OCaml 5.1.1 (8 December 2023) + ---------------------------- + +-- +2.44.0 + diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0003-Don-t-add-rpaths-to-libraries.patch similarity index 79% rename from 0001-Don-t-add-rpaths-to-libraries.patch rename to 0003-Don-t-add-rpaths-to-libraries.patch index 04773ec..c3c1373 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0003-Don-t-add-rpaths-to-libraries.patch @@ -1,14 +1,14 @@ -From 799bf9088c131fc71626a48e9987e4d44a2f0194 Mon Sep 17 00:00:00 2001 +From 507a1382cb82160c2a6cfc0ea5bcb3e33ece7307 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. +Subject: [PATCH 3/5] Don't add rpaths to libraries. --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac -index b81da53c42..892a2a894f 100644 +index 0c9d63859a..48aa9f0a29 100644 --- a/configure.ac +++ b/configure.ac @@ -1221,8 +1221,6 @@ AS_IF([test x"$enable_shared" != "xno"], @@ -21,5 +21,5 @@ index b81da53c42..892a2a894f 100644 supports_shared_libraries=true], [mkdll='shared-libs-not-available']) -- -2.43.0 +2.44.0 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0004-configure-Allow-user-defined-C-compiler-flags.patch similarity index 88% rename from 0002-configure-Allow-user-defined-C-compiler-flags.patch rename to 0004-configure-Allow-user-defined-C-compiler-flags.patch index 569b4a1..7c447ff 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0004-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,14 +1,14 @@ -From f2b875e8201efed22267136096b1e5df97f99f84 Mon Sep 17 00:00:00 2001 +From edd903fc73b98eb784b307a47110985967cb1d09 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. +Subject: [PATCH 4/5] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac -index 892a2a894f..e8f6cbc863 100644 +index 48aa9f0a29..fc29c88f50 100644 --- a/configure.ac +++ b/configure.ac @@ -869,6 +869,10 @@ AS_CASE([$ocaml_cc_vendor], @@ -41,5 +41,5 @@ index 892a2a894f..e8f6cbc863 100644 mkexe_ldflags="\$(OC_LDFLAGS) \$(LDFLAGS)" mkexe_ldflags_exp="${oc_ldflags} ${LDFLAGS}" -- -2.43.0 +2.44.0 diff --git a/0005-flambda-Improve-transitive-closure-in-invariant_para.patch b/0005-flambda-Improve-transitive-closure-in-invariant_para.patch new file mode 100644 index 0000000..808a96c --- /dev/null +++ b/0005-flambda-Improve-transitive-closure-in-invariant_para.patch @@ -0,0 +1,114 @@ +From acdc441ff1acb5390467e649bc9a9bfddd7df774 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Thu, 9 May 2024 10:03:23 +0200 +Subject: [PATCH 5/5] flambda: Improve transitive closure in + invariant_params_in_recursion (#13150) + +The old implementation did not really exploit the sparseness of the +graph because it used newly discovered edges in later iterations. +The new implementation processes each original relation only once +per starting node, and does not re-process newly discovered relations. + +(cherry picked from commit 787b4fbb5aaf3728de54ca240ba9ca0bf56ace60) +--- + Changes | 5 ++ + middle_end/flambda/invariant_params.ml | 66 ++++++++++---------------- + 2 files changed, 31 insertions(+), 40 deletions(-) + +diff --git a/Changes b/Changes +index 75842fc216..d26512067d 100644 +--- a/Changes ++++ b/Changes +@@ -1,6 +1,11 @@ + OCaml 5.2.0 (13 May 2024) + ------------------------- + ++- #13150: improve a transitive-closure computation algorithm in the flambda ++ middle-end to avoid a compilation time blowup on Menhir-generated code ++ (Florian Weimer, review by Gabriel Scherer and Pierre Chambart, ++ report by Richard Jones) ++ + (Changes that can break existing programs are marked with a "*") + + ### Restored and new backends: +diff --git a/middle_end/flambda/invariant_params.ml b/middle_end/flambda/invariant_params.ml +index 414d39310a..dba63970fd 100644 +--- a/middle_end/flambda/invariant_params.ml ++++ b/middle_end/flambda/invariant_params.ml +@@ -65,47 +65,33 @@ let implies relation from to_ = + relation + + let transitive_closure state = +- let union s1 s2 = +- match s1, s2 with +- | Top, _ | _, Top -> Top +- | Implication s1, Implication s2 -> +- Implication (Variable.Pair.Set.union s1 s2) ++ (* Depth-first search for all implications for one argument. ++ Arguments are moved from candidate to frontier, assuming ++ they are newly added to the result. *) ++ let rec loop candidate frontier result = ++ match (candidate, frontier) with ++ | ([], []) -> Implication result ++ | ([], frontier::fs) -> ++ (* Obtain fresh candidate for the frontier argument. *) ++ (match Variable.Pair.Map.find frontier state with ++ | exception Not_found -> loop [] fs result ++ | Top -> Top ++ | Implication candidate -> ++ loop (Variable.Pair.Set.elements candidate) fs result) ++ | (candidate::cs, frontier) -> ++ let result' = Variable.Pair.Set.add candidate result in ++ if result' != result then ++ (* Result change means candidate becomes part of frontier. *) ++ loop cs (candidate :: frontier) result' ++ else ++ loop cs frontier result + in +- let equal s1 s2 = +- match s1, s2 with +- | Top, Implication _ | Implication _, Top -> false +- | Top, Top -> true +- | Implication s1, Implication s2 -> Variable.Pair.Set.equal s1 s2 +- in +- let update arg state = +- let original_set = +- try Variable.Pair.Map.find arg state with +- | Not_found -> Implication Variable.Pair.Set.empty +- in +- match original_set with +- | Top -> state +- | Implication arguments -> +- let set = +- Variable.Pair.Set.fold +- (fun orig acc-> +- let set = +- try Variable.Pair.Map.find orig state with +- | Not_found -> Implication Variable.Pair.Set.empty in +- union set acc) +- arguments original_set +- in +- Variable.Pair.Map.add arg set state +- in +- let once state = +- Variable.Pair.Map.fold (fun arg _ state -> update arg state) state state +- in +- let rec fp state = +- let state' = once state in +- if Variable.Pair.Map.equal equal state state' +- then state +- else fp state' +- in +- fp state ++ Variable.Pair.Map.map ++ (fun set -> ++ match set with ++ | Top -> Top ++ | Implication set -> loop [] (Variable.Pair.Set.elements set) set) ++ state + + (* CR-soon pchambart: to move to Flambda_utils and document + mshinwell: I think this calculation is basically the same as +-- +2.44.0 + diff --git a/ocaml.spec b/ocaml.spec index 64db332..991fcc3 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -1,10 +1,11 @@ # Don't add -Wl,-dT, %undefine _package_note_flags -# OCaml 5.1 broke building with LTO. A file prims.c is generated with primitive -# function declarations, all with "void" for their parameter list. This does -# not match the real definitions, leading to lots of -Wlto-type-mismatch -# warnings. These change the output of the tests, leading to many failed tests. +# OCaml 5.1 broke building with LTO. A file prims.c is generated with +# primitive function declarations, all with "void" for their parameter +# list. This does not match the real definitions, leading to lots of +# -Wlto-type-mismatch warnings. These change the output of the tests, +# leading to many failed tests. This is still a problem in 5.2. %global _lto_cflags %{nil} # OCaml has a bytecode backend that works on anything with a C @@ -65,15 +66,25 @@ Source2: ocaml_files.py # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-40-5.1.1 +# Current branch: fedora-41-5.2.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. +# Upstream after 5.2.0: +Patch: 0001-Changes-synchronisation-and-consistency-with-trunk.patch +Patch: 0002-Changes-copy-editing.patch + # Fedora-specific patches -Patch: 0001-Don-t-add-rpaths-to-libraries.patch -Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch +Patch: 0003-Don-t-add-rpaths-to-libraries.patch +Patch: 0004-configure-Allow-user-defined-C-compiler-flags.patch + +# Improve performance of flambda optimizer in some cases. Required to +# compiler blow-up in coccinelle package. Upstream, but not included +# in 5.2 branch. +# https://github.com/ocaml/ocaml/pull/13150 +Patch: 0005-flambda-Improve-transitive-closure-in-invariant_para.patch BuildRequires: make BuildRequires: git @@ -103,7 +114,7 @@ Requires: libzstd-devel%{?_isa} Requires: ocaml-runtime%{?_isa} = %{version}-%{release} # Force ocaml-srpm-macros to be at the latest version, both for builds -# and installs, since OCaml 5.1 has a different set of native code +# 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 @@ -462,7 +473,7 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog * Thu May 23 2024 Jerry James - 5.2.0-1 -- Version 5.2.0 +- 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 From 13ff7d02443abd752b791a74c5089bf94685afff Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 19 Jun 2024 08:01:03 +0100 Subject: [PATCH 73/91] Add fix for ppc64le code generation issue found after 5.2.0 was released --- ...onisation-and-consistency-with-trunk.patch | 2 +- 0002-Changes-copy-editing.patch | 2 +- 0003-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...transitive-closure-in-invariant_para.patch | 2 +- ...tion-pointer-register-in-caml_c_call.patch | 165 ++++++++++++++++ ...urate-instruction-sizes-for-branch-r.patch | 178 ++++++++++++++++++ ocaml.spec | 13 +- 8 files changed, 360 insertions(+), 6 deletions(-) create mode 100644 0006-Reload-exception-pointer-register-in-caml_c_call.patch create mode 100644 0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch diff --git a/0001-Changes-synchronisation-and-consistency-with-trunk.patch b/0001-Changes-synchronisation-and-consistency-with-trunk.patch index 5f865d0..a1f33b7 100644 --- a/0001-Changes-synchronisation-and-consistency-with-trunk.patch +++ b/0001-Changes-synchronisation-and-consistency-with-trunk.patch @@ -1,7 +1,7 @@ From 5538fa66e94fad3d2b4f110d23bef3b4d2d6342c Mon Sep 17 00:00:00 2001 From: Florian Angeletti Date: Mon, 13 May 2024 11:39:37 +0200 -Subject: [PATCH 1/5] Changes: synchronisation and consistency with trunk +Subject: [PATCH 1/7] Changes: synchronisation and consistency with trunk --- Changes | 25 ++++++++++++++----------- diff --git a/0002-Changes-copy-editing.patch b/0002-Changes-copy-editing.patch index 05f48ac..7633e01 100644 --- a/0002-Changes-copy-editing.patch +++ b/0002-Changes-copy-editing.patch @@ -1,7 +1,7 @@ From 7a20c9322f827923baa6a9907998f670463ce447 Mon Sep 17 00:00:00 2001 From: Florian Angeletti Date: Mon, 13 May 2024 14:28:08 +0200 -Subject: [PATCH 2/5] Changes copy-editing +Subject: [PATCH 2/7] Changes copy-editing --- Changes | 398 ++++++++++++++++++++++++++++---------------------------- diff --git a/0003-Don-t-add-rpaths-to-libraries.patch b/0003-Don-t-add-rpaths-to-libraries.patch index c3c1373..3b3e9f9 100644 --- a/0003-Don-t-add-rpaths-to-libraries.patch +++ b/0003-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 507a1382cb82160c2a6cfc0ea5bcb3e33ece7307 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 3/5] Don't add rpaths to libraries. +Subject: [PATCH 3/7] Don't add rpaths to libraries. --- configure.ac | 2 -- diff --git a/0004-configure-Allow-user-defined-C-compiler-flags.patch b/0004-configure-Allow-user-defined-C-compiler-flags.patch index 7c447ff..3c14867 100644 --- a/0004-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0004-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From edd903fc73b98eb784b307a47110985967cb1d09 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 4/5] configure: Allow user defined C compiler flags. +Subject: [PATCH 4/7] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- diff --git a/0005-flambda-Improve-transitive-closure-in-invariant_para.patch b/0005-flambda-Improve-transitive-closure-in-invariant_para.patch index 808a96c..b0b347c 100644 --- a/0005-flambda-Improve-transitive-closure-in-invariant_para.patch +++ b/0005-flambda-Improve-transitive-closure-in-invariant_para.patch @@ -1,7 +1,7 @@ From acdc441ff1acb5390467e649bc9a9bfddd7df774 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 9 May 2024 10:03:23 +0200 -Subject: [PATCH 5/5] flambda: Improve transitive closure in +Subject: [PATCH 5/7] flambda: Improve transitive closure in invariant_params_in_recursion (#13150) The old implementation did not really exploit the sparseness of the diff --git a/0006-Reload-exception-pointer-register-in-caml_c_call.patch b/0006-Reload-exception-pointer-register-in-caml_c_call.patch new file mode 100644 index 0000000..4c20a85 --- /dev/null +++ b/0006-Reload-exception-pointer-register-in-caml_c_call.patch @@ -0,0 +1,165 @@ +From 8637cac022907501c3c0d941e07e436b70c9d4ac Mon Sep 17 00:00:00 2001 +From: Miod Vallat <118974489+dustanddreams@users.noreply.github.com> +Date: Thu, 30 May 2024 09:57:41 +0000 +Subject: [PATCH 6/7] Reload exception pointer register in caml_c_call* + +The invoked code may end up causing caml_try_realloc_stack() to be invoked, +which in turn may replace the stack TRAP_PTR points to, leading to +either crashes with the debug runtime (thanks to the old stack contents +being overwritten) or all kinds of memory or control flow corruption otherwise. + +Added test for stack reallocation in callback followed by exception raising. + +(cherry picked from commit 6964d3a90f84402ed6066fb1821679435e063067) +(cherry picked from commit 1e8a91d305f1fa4668444fb1cce97952dbc39810) +--- + Changes | 9 +++++++++ + runtime/arm64.S | 6 ++++-- + runtime/power.S | 6 ++++-- + runtime/riscv.S | 6 ++++-- + runtime/s390x.S | 5 +++-- + testsuite/tests/callback/test1.ml | 5 +++++ + 6 files changed, 29 insertions(+), 8 deletions(-) + +diff --git a/Changes b/Changes +index d26512067d..53bb5369b9 100644 +--- a/Changes ++++ b/Changes +@@ -1,3 +1,12 @@ ++OCaml 5.2 maintenance version ++----------------------------- ++ ++- #13207: Be sure to reload the register caching the exception handler in ++ caml_c_call and caml_c_call_stack_args, as its value may have been changed ++ if the OCaml stack is expanded during a callback. ++ (Miod Vallat, report by Vesa Karvonen, review by Gabriel Scherer and ++ Xavier Leroy) ++ + OCaml 5.2.0 (13 May 2024) + ------------------------- + +diff --git a/runtime/arm64.S b/runtime/arm64.S +index e71f25ebba..6c6495a0a8 100644 +--- a/runtime/arm64.S ++++ b/runtime/arm64.S +@@ -569,8 +569,9 @@ FUNCTION(caml_c_call) + str TRAP_PTR, Caml_state(exn_handler) + /* Call the function */ + blr ADDITIONAL_ARG +- /* Reload alloc ptr */ ++ /* Reload new allocation pointer & exn handler */ + ldr ALLOC_PTR, Caml_state(young_ptr) ++ ldr TRAP_PTR, Caml_state(exn_handler) + /* Load ocaml stack */ + SWITCH_C_TO_OCAML + #if defined(WITH_THREAD_SANITIZER) +@@ -625,8 +626,9 @@ FUNCTION(caml_c_call_stack_args) + blr ADDITIONAL_ARG + /* Restore stack */ + mov sp, x19 +- /* Reload alloc ptr */ ++ /* Reload new allocation pointer & exn handler */ + ldr ALLOC_PTR, Caml_state(young_ptr) ++ ldr TRAP_PTR, Caml_state(exn_handler) + /* Switch from C to OCaml */ + SWITCH_C_TO_OCAML + /* Return */ +diff --git a/runtime/power.S b/runtime/power.S +index bfb37fa989..257678100e 100644 +--- a/runtime/power.S ++++ b/runtime/power.S +@@ -445,8 +445,9 @@ FUNCTION caml_c_call + mr 2, C_CALL_TOC /* restore current TOC */ + /* Restore return address (in register C_CALL_RET_ADDR, preserved by C) */ + mtlr C_CALL_RET_ADDR +- /* Reload allocation pointer*/ ++ /* Reload new allocation pointer and exception pointer */ + ld ALLOC_PTR, Caml_state(young_ptr) ++ ld TRAP_PTR, Caml_state(exn_handler) + #if defined(WITH_THREAD_SANITIZER) + TSAN_SETUP_C_CALL 16 + /* Save return value registers. Since the called function could be anything, +@@ -497,8 +498,9 @@ FUNCTION caml_c_call_stack_args + add SP, SP, STACK_ARG_BYTES + /* Restore return address (in register C_CALL_RET_ADDR, preserved by C) */ + mtlr C_CALL_RET_ADDR +- /* Reload allocation pointer*/ ++ /* Reload new allocation pointer and exception pointer */ + ld ALLOC_PTR, Caml_state(young_ptr) ++ ld TRAP_PTR, Caml_state(exn_handler) + /* Switch from C to OCaml */ + SWITCH_C_TO_OCAML + /* Return to caller */ +diff --git a/runtime/riscv.S b/runtime/riscv.S +index a2eca7a315..8934db0bb3 100644 +--- a/runtime/riscv.S ++++ b/runtime/riscv.S +@@ -516,8 +516,9 @@ L(caml_c_call): + sd TRAP_PTR, Caml_state(exn_handler) + /* Call the function */ + jalr ADDITIONAL_ARG +- /* Reload alloc ptr */ ++ /* Reload new allocation pointer & exn handler */ + ld ALLOC_PTR, Caml_state(young_ptr) ++ ld TRAP_PTR, Caml_state(exn_handler) + /* Load ocaml stack */ + SWITCH_C_TO_OCAML + #if defined(WITH_THREAD_SANITIZER) +@@ -575,8 +576,9 @@ FUNCTION(caml_c_call_stack_args) + jalr ADDITIONAL_ARG + /* Restore stack */ + mv sp, s2 +- /* Reload alloc ptr */ ++ /* Reload new allocation pointer & exn handler */ + ld ALLOC_PTR, Caml_state(young_ptr) ++ ld TRAP_PTR, Caml_state(exn_handler) + /* Switch from C to OCaml */ + SWITCH_C_TO_OCAML + /* Return */ +diff --git a/runtime/s390x.S b/runtime/s390x.S +index b59822ce57..113831a376 100644 +--- a/runtime/s390x.S ++++ b/runtime/s390x.S +@@ -515,7 +515,7 @@ LBL(caml_c_call): + #endif + basr %r14, ADDITIONAL_ARG + CLEANUP_AFTER_C_CALL +- /* Reload alloc ptr */ ++ /* Reload new allocation pointer & exn handler */ + lg ALLOC_PTR, Caml_state(young_ptr) + lg TRAP_PTR, Caml_state(exn_handler) + /* Load ocaml stack and restore global variables */ +@@ -584,8 +584,9 @@ LBL(106): + CLEANUP_AFTER_C_CALL + /* Restore stack */ + lgr %r15, %r12 +- /* Reload alloc ptr */ ++ /* Reload new allocation pointer & exn handler */ + lg ALLOC_PTR, Caml_state(young_ptr) ++ lg TRAP_PTR, Caml_state(exn_handler) + /* Switch from C to OCaml */ + SWITCH_C_TO_OCAML + /* Return */ +diff --git a/testsuite/tests/callback/test1.ml b/testsuite/tests/callback/test1.ml +index c39be0c586..f6ad4356cf 100644 +--- a/testsuite/tests/callback/test1.ml ++++ b/testsuite/tests/callback/test1.ml +@@ -11,6 +11,9 @@ external mycallback3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd + external mycallback4 : + ('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e = "mycallback4" + ++let rec growstack n = ++ if n <= 0 then 0 else 1 + growstack (n - 1) ++ + let rec tak (x, y, z as _tuple) = + if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y)) + else z +@@ -46,3 +49,5 @@ let _ = + print_int(trapexit ()); print_newline(); + print_string(tripwire mypushroot); print_newline(); + print_string(tripwire mycamlparam); print_newline(); ++ begin try ignore (mycallback1 growstack 1_000); raise Exit ++ with Exit -> () end +-- +2.44.0 + diff --git a/0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch b/0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch new file mode 100644 index 0000000..e9dd879 --- /dev/null +++ b/0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch @@ -0,0 +1,178 @@ +From 4eb80b13779125fcd76a445ab0004ca064fab634 Mon Sep 17 00:00:00 2001 +From: Miod Vallat +Date: Fri, 7 Jun 2024 06:19:45 +0000 +Subject: [PATCH 7/7] Compute more accurate instruction sizes for branch + relaxation. + +(cherry picked from commit 114ddae2d4c85391a4f939dc6623424ae35a07aa) +--- + Changes | 4 ++ + asmcomp/power/emit.mlp | 87 ++++++++++++++++++++++++------------------ + 2 files changed, 53 insertions(+), 38 deletions(-) + +diff --git a/Changes b/Changes +index 53bb5369b9..1a81509247 100644 +--- a/Changes ++++ b/Changes +@@ -7,6 +7,10 @@ OCaml 5.2 maintenance version + (Miod Vallat, report by Vesa Karvonen, review by Gabriel Scherer and + Xavier Leroy) + ++- #13221: Compute more accurate instruction sizes for branch relocation on ++ POWER. ++ (Miod Vallat, review by Gabriel Scherer) ++ + OCaml 5.2.0 (13 May 2024) + ------------------------- + +diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp +index 47f5419a92..fdf22996fa 100644 +--- a/asmcomp/power/emit.mlp ++++ b/asmcomp/power/emit.mlp +@@ -177,6 +177,28 @@ let emit_tocload emit_dest dest entry = + + (* Output a load or store operation *) + ++let load_mnemonic = function ++ | Byte_unsigned -> "lbz" ++ | Byte_signed -> "lbz" ++ | Sixteen_unsigned -> "lhz" ++ | Sixteen_signed -> "lha" ++ | Thirtytwo_unsigned -> "lwz" ++ | Thirtytwo_signed -> "lwa" ++ | Word_int | Word_val -> "ld" ++ | Single -> "lfs" ++ | Double -> "lfd" ++ ++let store_mnemonic = function ++ | Byte_unsigned | Byte_signed -> "stb" ++ | Sixteen_unsigned | Sixteen_signed -> "sth" ++ | Thirtytwo_unsigned | Thirtytwo_signed -> "stw" ++ | Word_int | Word_val -> "std" ++ | Single -> "stfs" ++ | Double -> "stfd" ++ ++let store_needs_lwsync chunk assignment = ++ assignment && (chunk = Word_int || chunk = Word_val) ++ + let valid_offset instr ofs = + ofs land 3 = 0 || (instr <> "ld" && instr <> "std" && instr <> "lwa") + +@@ -383,11 +405,17 @@ module BR = Branch_relaxation.Make (struct + + let tocload_size = 2 + +- let load_store_size = function ++ let load_store_size instr = function + | Ibased(_s, d) -> +- let (_lo, hi) = low_high_s d in +- tocload_size + (if hi = 0 then 1 else 2) +- | Iindexed ofs -> if is_immediate ofs then 1 else 3 ++ let (lo, hi) = low_high_s d in ++ tocload_size + ++ (if hi <> 0 then 1 else 0) + ++ (if valid_offset instr lo then 1 else 2) ++ | Iindexed ofs -> ++ if is_immediate ofs && valid_offset instr ofs then 1 else begin ++ let (lo, _hi) = low_high_u ofs in ++ if lo <> 0 then 3 else 2 ++ end + | Iindexed2 -> 1 + + let instr_size f = function +@@ -415,16 +443,16 @@ module BR = Branch_relaxation.Make (struct + else if alloc then tocload_size + 2 + else 5 + | Lop(Istackoffset _) -> 1 +- | Lop(Iload {memory_chunk; addressing_mode; _ }) -> +- if memory_chunk = Byte_signed +- then load_store_size addressing_mode + 1 +- else load_store_size addressing_mode ++ | Lop(Iload {memory_chunk; addressing_mode; is_atomic }) -> ++ let loadinstr = load_mnemonic memory_chunk in ++ (if is_atomic then 4 else 0) + ++ (if memory_chunk = Byte_signed then 1 else 0) + ++ load_store_size loadinstr addressing_mode + | Lop(Istore(chunk, addr, assignment)) -> +- (match chunk with +- | Single -> 1 +- | Word_int | Word_val when assignment -> 1 +- | _ -> 0) +- + load_store_size addr ++ let storeinstr = store_mnemonic chunk in ++ (if chunk = Single then 1 else 0) + ++ (if store_needs_lwsync chunk assignment then 1 else 0) + ++ load_store_size storeinstr addr + | Lop(Ialloc _) -> 5 + | Lop(Ispecific(Ialloc_far _)) -> 6 + | Lop(Ipoll { return_label = Some(_) }) -> 5 +@@ -442,12 +470,12 @@ module BR = Branch_relaxation.Make (struct + | Lop(Ispecific(Icheckbound_imm_far _)) -> 3 + | Lop(Iintop_imm _) -> 1 + | Lop(Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf) -> 1 +- | Lop(Ifloatofint) -> 9 +- | Lop(Iintoffloat) -> 4 ++ | Lop(Ifloatofint) -> 3 ++ | Lop(Iintoffloat) -> 3 + | Lop(Iopaque) -> 0 + | Lop(Ispecific _) -> 1 +- | Lop (Idls_get) -> 1 +- | Lop (Ireturn_addr) -> 1 ++ | Lop(Idls_get) -> 1 ++ | Lop(Ireturn_addr) -> 1 + | Lreloadretaddr -> 2 + | Lreturn -> 2 + | Llabel _ -> 0 +@@ -457,7 +485,7 @@ module BR = Branch_relaxation.Make (struct + 1 + (if lbl0 = None then 0 else 1) + + (if lbl1 = None then 0 else 1) + + (if lbl2 = None then 0 else 1) +- | Lswitch _ -> 5 + tocload_size ++ | Lswitch _ -> 7 + tocload_size + | Lentertrap -> 1 + | Ladjust_trap_depth _ -> 0 + | Lpushtrap _ -> 4 + tocload_size +@@ -705,17 +733,7 @@ let emit_instr env i = + ` addi 1, 1, {emit_int (-n)}\n`; + adjust_stack_offset env n + | Lop(Iload { memory_chunk; addressing_mode; is_atomic }) -> +- let loadinstr = +- match memory_chunk with +- | Byte_unsigned -> "lbz" +- | Byte_signed -> "lbz" +- | Sixteen_unsigned -> "lhz" +- | Sixteen_signed -> "lha" +- | Thirtytwo_unsigned -> "lwz" +- | Thirtytwo_signed -> "lwa" +- | Word_int | Word_val -> "ld" +- | Single -> "lfs" +- | Double -> "lfd" in ++ let loadinstr = load_mnemonic memory_chunk in + if is_atomic then + ` sync\n`; + emit_load_store loadinstr addressing_mode i.arg 0 i.res.(0); +@@ -731,19 +749,12 @@ let emit_instr env i = + ` frsp {emit_reg tmp}, {emit_reg i.arg.(0)}\n`; + emit_load_store "stfs" addr i.arg 1 tmp + | Lop(Istore(chunk, addr, assignment)) -> +- let storeinstr = +- match chunk with +- | Byte_unsigned | Byte_signed -> "stb" +- | Sixteen_unsigned | Sixteen_signed -> "sth" +- | Thirtytwo_unsigned | Thirtytwo_signed -> "stw" +- | Word_int | Word_val -> "std" +- | Single -> assert false +- | Double -> "stfd" in ++ let storeinstr = store_mnemonic chunk in + (* Non-initializing stores need a memory barrier to follow the + Multicore OCaml memory model. Stores of size other than + Word_int and Word_val do not follow the memory model and therefore + do not need a barrier *) +- if assignment && (chunk = Word_int || chunk = Word_val) then ++ if store_needs_lwsync chunk assignment then + ` lwsync\n`; + emit_load_store storeinstr addr i.arg 1 i.arg.(0) + | Lop(Ialloc { bytes; dbginfo }) -> +-- +2.44.0 + diff --git a/ocaml.spec b/ocaml.spec index 991fcc3..a94c4fb 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -44,7 +44,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.2.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -86,6 +86,14 @@ Patch: 0004-configure-Allow-user-defined-C-compiler-flags.patch # https://github.com/ocaml/ocaml/pull/13150 Patch: 0005-flambda-Improve-transitive-closure-in-invariant_para.patch +# Upstream after 5.2.0: +Patch: 0006-Reload-exception-pointer-register-in-caml_c_call.patch + +# Fix for ppc64le code generation issue found after 5.2.0 was released. +# https://github.com/ocaml/ocaml/issues/13220 +# https://github.com/ocaml/ocaml/commit/114ddae2d4c85391a4f939dc6623424ae35a07aa +Patch: 0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch + BuildRequires: make BuildRequires: git BuildRequires: gcc @@ -472,6 +480,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From 561453cd2d96d239213926816ae8c1786e3931e9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 19 Jun 2024 08:25:18 +0100 Subject: [PATCH 74/91] Add RHEL 10 gating tests --- gating.yaml | 6 ++++++ tests/basic-test.sh | 10 ++++++++++ tests/tests.yml | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100755 gating.yaml create mode 100755 tests/basic-test.sh create mode 100755 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100755 index 0000000..2c7ed80 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-* +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/tests/basic-test.sh b/tests/basic-test.sh new file mode 100755 index 0000000..514bea0 --- /dev/null +++ b/tests/basic-test.sh @@ -0,0 +1,10 @@ +#!/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 new file mode 100755 index 0000000..b9ec89a --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,11 @@ +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + required_packages: + - ocaml + tests: + - simple: + dir: . + run: ./basic-test.sh From 0e1aab5f28895e613b3764513d98a41c317b75c3 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Wed, 17 Jul 2024 11:25:19 -0600 Subject: [PATCH 75/91] Fix the VCS field --- ocaml.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index a94c4fb..28b57d1 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -25,6 +25,8 @@ %global natdynlink 0 %endif +%global giturl https://github.com/ocaml/ocaml + # i686 support was dropped in OCaml 5 / Fedora 39. ExcludeArch: %{ix86} @@ -51,9 +53,9 @@ Summary: OCaml compiler and programming environment License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception URL: https://www.ocaml.org -VCS: https://github.com/ocaml/ocaml +VCS: git:%{giturl}.git -Source0: %{vcs}/archive/%{version}%{rcver}/%{name}-%{version}%{rcver}.tar.gz +Source0: %{giturl}/archive/%{version}%{rcver}/%{name}-%{version}%{rcver}.tar.gz Source1: macros.ocaml-rpm Source2: ocaml_files.py From a7c6be2f53b7e29619faa2a481bb3b3905293276 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 18 Jul 2024 19:59:15 +0000 Subject: [PATCH 76/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 28b57d1..c4b4035 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -46,7 +46,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.2.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -482,6 +482,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From 5018fa7019c262dbfb0402f9cc0f1e19b33d16d3 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Thu, 9 Jan 2025 08:24:42 -0700 Subject: [PATCH 77/91] New upstream version 5.3.0 - Drop upstreamed patches - BR git-core instead of git --- ...onisation-and-consistency-with-trunk.patch | 90 --- ...> 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- 0002-Changes-copy-editing.patch | 515 ------------------ ...-Allow-user-defined-C-compiler-flags.patch | 16 +- ...transitive-closure-in-invariant_para.patch | 114 ---- ...tion-pointer-register-in-caml_c_call.patch | 165 ------ ...urate-instruction-sizes-for-branch-r.patch | 178 ------ ocaml.spec | 38 +- sources | 2 +- 9 files changed, 17 insertions(+), 1103 deletions(-) delete mode 100644 0001-Changes-synchronisation-and-consistency-with-trunk.patch rename 0003-Don-t-add-rpaths-to-libraries.patch => 0001-Don-t-add-rpaths-to-libraries.patch (93%) delete mode 100644 0002-Changes-copy-editing.patch rename 0004-configure-Allow-user-defined-C-compiler-flags.patch => 0002-configure-Allow-user-defined-C-compiler-flags.patch (64%) delete mode 100644 0005-flambda-Improve-transitive-closure-in-invariant_para.patch delete mode 100644 0006-Reload-exception-pointer-register-in-caml_c_call.patch delete mode 100644 0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch diff --git a/0001-Changes-synchronisation-and-consistency-with-trunk.patch b/0001-Changes-synchronisation-and-consistency-with-trunk.patch deleted file mode 100644 index a1f33b7..0000000 --- a/0001-Changes-synchronisation-and-consistency-with-trunk.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 5538fa66e94fad3d2b4f110d23bef3b4d2d6342c Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Mon, 13 May 2024 11:39:37 +0200 -Subject: [PATCH 1/7] Changes: synchronisation and consistency with trunk - ---- - Changes | 25 ++++++++++++++----------- - 1 file changed, 14 insertions(+), 11 deletions(-) - -diff --git a/Changes b/Changes -index 208d5e8697..1af198ba77 100644 ---- a/Changes -+++ b/Changes -@@ -140,9 +140,6 @@ OCaml 5.2.0 - (Guillaume Munch-Maccagnoni, bug reports and suggestion by Mark - Shinwell, review by Nick Barnes and Stephen Dolan) - --- #12876: Port ThreadSanitizer support to Linux on POWER -- (Miod Vallat, review by Tim McGilchrist) -- - - #12408: `Domain.spawn` no longer leaks its functional argument for - the whole duration of the children domain lifetime. - (Guillaume Munch-Maccagnoni, review by Gabriel Scherer) -@@ -156,8 +153,10 @@ OCaml 5.2.0 - review by Damien Doligez, Sébastien Hinderer, Jacques-Henri Jourdan, Luc - Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer) - --- #11911, #12381: Restore statmemprof functionality in part -- (API changes in Gc.Memprof). (Nick Barnes) -+- #11911, #12381: Restore statmemprof functionality in part, with -+ some API changes in Gc.Memprof. -+ (Nick Barnes, review by Jacques-Henri Jourdan -+ and Guillaume Munch-Maccagnoni). - - - #12430: Simplify dynamic bytecode loading in Meta.reify_bytecode - (Stephen Dolan, review by Sébastien Hinderer, Vincent Laviron and Xavier -@@ -216,9 +215,10 @@ OCaml 5.2.0 - Ojeda Bar) - - - #11911, #12382, #12383: Restore statmemprof functionality in part -- (backtrace buffers, per-thread and per-domain data structures). -- (Nick Barnes, review by Gabriel Scherer, Fabrice Buoro, Sadiq -- Jaffer, and Guillaume Munch-Maccagnoni). -+ (backtrace buffers, per-thread and per-domain data structures, -+ GC/allocation interface). (Nick Barnes, review by Gabriel Scherer, -+ Fabrice Buoro, Sadiq Jaffer, Guillaume Munch-Maccagnoni, and -+ Jacques-Henri Jourdan). - - - #12735: Store both ends of the stack chain in continuations - (Leo White, review by Miod Vallat and KC Sivaramakrishnan) -@@ -248,6 +248,9 @@ OCaml 5.2.0 - Hari Hara Naveen S, reviewed by Fabrice Buoro, Gabriel Scherer and - Miod Vallat) - -+- #12876: Port ThreadSanitizer support to Linux on POWER -+ (Miod Vallat, review by Tim McGilchrist) -+ - - #12886: Reinitialize IO mutexes after fork - (Max Slater, review by Guillaume Munch-Maccagnoni and Xavier Leroy) - -@@ -990,7 +993,7 @@ OCaml 5.1.0 (14 September 2023) - `Seq.find_mapi`, `Seq.find_index`, `Array.find_mapi`, `Array.find_index`, - `Float.Array.find_opt`, `Float.Array.find_index`, `Float.Array.find_map`, - `Float.Array.find_mapi`. -- (Sima Kinsart, review by Daniel Bünzli and Nicolás Ojeda Bär) -+ (Tima Kinsart, review by Daniel Bünzli and Nicolás Ojeda Bär) - - - #11410: Add Set.to_list, Map.to_list, Map.of_list, - `Map.add_to_list: key -> 'a -> 'a list t -> 'a list t`. -@@ -1771,7 +1774,7 @@ Some of those changes will benefit all OCaml packages. - - - #11846: Mark rbx as destroyed at C call for Win64 (mingw-w64 and Cygwin64). - Reserve the shadow store for the ABI in the c_stack_link struct instead of -- explictly when calling C functions. This simultaneously reduces the number of -+ explicitly when calling C functions. This simultaneously reduces the number of - stack pointer manipulations and also fixes a bug when calling noalloc - functions where the shadow store was not being reserved. - (David Allsopp, report by Vesa Karvonen, review by Xavier Leroy and -@@ -2791,7 +2794,7 @@ OCaml 4.14.0 (28 March 2022) - - #8516: Change representation of class signatures - (Leo White, review by Thomas Refis) - --- #9444: -dtypedtree, print more explictly extra nodes in pattern ast. -+- #9444: -dtypedtree, print more explicitly extra nodes in pattern ast. - (Frédéric Bour, review by Gabriel Scherer) - - - #10337: Normalize type_expr nodes on access --- -2.44.0 - diff --git a/0003-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch similarity index 93% rename from 0003-Don-t-add-rpaths-to-libraries.patch rename to 0001-Don-t-add-rpaths-to-libraries.patch index 3b3e9f9..b5735bd 100644 --- a/0003-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ From 507a1382cb82160c2a6cfc0ea5bcb3e33ece7307 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 3/7] Don't add rpaths to libraries. +Subject: [PATCH 1/2] Don't add rpaths to libraries. --- configure.ac | 2 -- diff --git a/0002-Changes-copy-editing.patch b/0002-Changes-copy-editing.patch deleted file mode 100644 index 7633e01..0000000 --- a/0002-Changes-copy-editing.patch +++ /dev/null @@ -1,515 +0,0 @@ -From 7a20c9322f827923baa6a9907998f670463ce447 Mon Sep 17 00:00:00 2001 -From: Florian Angeletti -Date: Mon, 13 May 2024 14:28:08 +0200 -Subject: [PATCH 2/7] Changes copy-editing - ---- - Changes | 398 ++++++++++++++++++++++++++++---------------------------- - 1 file changed, 201 insertions(+), 197 deletions(-) - -diff --git a/Changes b/Changes -index 1af198ba77..75842fc216 100644 ---- a/Changes -+++ b/Changes -@@ -1,5 +1,5 @@ --OCaml 5.2.0 -------------- -+OCaml 5.2.0 (13 May 2024) -+------------------------- - - (Changes that can break existing programs are marked with a "*") - -@@ -12,60 +12,6 @@ OCaml 5.2.0 - - #12667: extend the latter to POWER 64 bits, big-endian, ELFv2 ABI - (A. Wilcox, review by Xavier Leroy) - --### Language features: -- --- #12295, #12568: Give `while true' a polymorphic type, similarly to -- `assert false' -- (Jeremy Yallop, review by Nicolás Ojeda Bär and Gabriel Scherer, -- suggestion by Rodolphe Lepigre and John Whitington) -- --- #12315: Use type annotations from arguments in let rec -- (Stephen Dolan, review by Gabriel Scherer) -- --- #11252, RFC 27: Support raw identifier syntax \#foo -- (Stephen Dolan, review by David Allsopp, Gabriel Scherer and Olivier Nicole) -- --- #12044: Add local module open syntax for types. -- ``` -- module A = struct -- type t = int -- type r = unit -- type s = string -- end -- -- type example = A.(t * r * s) -- ``` -- (Alistair O'Brien, review by Gabriel Scherer, Nicolás Ojeda Bär -- and Florian Angeletti) -- --- #12456: Document the incompatibility between effects on the one -- hand, and `caml_callback` and asynchronous callbacks (signal -- handlers, finalisers, memprof callbacks...) on the other hand. -- (Guillaume Munch-Maccagnoni, review by KC Sivaramakrishnan) -- --- #12375: allow use of [@untagged] for all immediate types like char, bool, -- and variant with only constant constructors. -- (Christophe Raffalli, review by Gabriel Scherer) -- --* #12502: the compiler now normalizes the newline sequence \r\n to -- a single \n character during lexing, to guarantee that the semantics -- of newlines in string literals is not modified by Windows tools -- transforming \n into \r\n in source files. -- Warning 29 [eol-in-string] is not emitted anymore, as the normalization -- gives a more robust semantics to newlines in string literals. -- (Gabriel Scherer and Damien Doligez, review by Daniel Bünzli, David -- Allsopp, Andreas Rossberg, Xavier Leroy, report by Andreas Rossberg) -- --- #13130: minor fixes to pprintast for raw identifiers and local module open -- syntax for types. -- (Chet Murthy, review by Gabriel Scherer) -- --### Type system: -- --- #12313, #11799: Do not re-build as-pattern type when a ground type annotation -- is given. This allows to work around problems with GADTs in as-patterns. -- (Jacques Garrigue, report by Leo White, review by Gabriel Scherer) -- - ### Runtime system: - - - #12193: Re-introduce GC compaction for shared pools -@@ -76,6 +22,12 @@ OCaml 5.2.0 - David Allsopp, Miod Vallat, Artem Pianykh, Stephen Dolan, Mark Shinwell - and KC Sivaramakrishnan) - -+- #12114: Add ThreadSanitizer support -+ (Fabrice Buoro and Olivier Nicole, based on an initial work by Anmol Sahoo, -+ review by Damien Doligez, Sébastien Hinderer, Jacques-Henri Jourdan, Luc -+ Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer) -+ -+ - - #12850: Update Gc.quick_stat data at the end of major cycles and compaction - This PR adds an additional caml_collect_gc_stats_sample_stw to the major heap - cycling stw. This means that Gc.quick_stat now actually reflects the state of -@@ -148,11 +100,6 @@ OCaml 5.2.0 - arise at specific locations during domain creation and shutdown. - (Guillaume Munch-Maccagnoni, review by Gabriel Scherer) - --- #12114: Add ThreadSanitizer support -- (Fabrice Buoro and Olivier Nicole, based on an initial work by Anmol Sahoo, -- review by Damien Doligez, Sébastien Hinderer, Jacques-Henri Jourdan, Luc -- Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer) -- - - #11911, #12381: Restore statmemprof functionality in part, with - some API changes in Gc.Memprof. - (Nick Barnes, review by Jacques-Henri Jourdan -@@ -264,34 +211,48 @@ OCaml 5.2.0 - (Olivier Nicole, suggested by Stephen Dolan, review by Gabriel Scherer, - Miod Vallat and Damien Doligez) - --### Code generation and optimizations: -+### Language features: - --- #11239: on x86-64 and RISC-V, reduce alignment of OCaml stacks from 16 to 8. -- This reduces stack usage. It's only C stacks that require 16-alignment. -- (Xavier Leroy, review by Gabriel Scherer and Stephen Dolan) -+- #12295, #12568: Give `while true' a polymorphic type, similarly to -+ `assert false' -+ (Jeremy Yallop, review by Nicolás Ojeda Bär and Gabriel Scherer, -+ suggestion by Rodolphe Lepigre and John Whitington) - --- #12311: on POWER, 32-bit FP numbers stored in memory (e.g. in bigarrays) -- were not correctly rounded sometimes. -- (Xavier Leroy, review by Anil Madhavapeddy and Tim McGilchrist) -+- #12044: Add local module open syntax for types. -+ ``` -+ module A = struct -+ type t = int -+ type r = unit -+ type s = string -+ end - --- #12551, #12608, #12782, #12596: Overhaul of recursive value compilation. -- Non-function recursive bindings are now forbidden from Lambda onwards, -- and compiled using a new Value_rec_compiler module. -- (Vincent Laviron and Lunia Ayanides, review by Gabriel Scherer, -- Stefan Muenzel and Nathanaëlle Courant) -+ type example = A.(t * r * s) -+ ``` -+ (Alistair O'Brien, review by Gabriel Scherer, Nicolás Ojeda Bär -+ and Florian Angeletti) - --- #1809, #12181: rewrite `compare x y op 0` to `x op y` when values are integers -- (Xavier Clerc, Stefan Muenzel, review by Gabriel Scherer and Vincent Laviron) -+- #11252, RFC 27: Support raw identifier syntax \#foo -+ (Stephen Dolan, review by David Allsopp, Gabriel Scherer and Olivier Nicole) - --- #12825: disable common subexpression elimination for atomic loads... again. -- (Gabriel Scherer, review by KC Sivaramakrishnan, Xavier Leroy -- and Vincent Laviron, report by Vesa Karvonen) -+ -+- #12315: Use type annotations from arguments in let rec -+ (Stephen Dolan, review by Gabriel Scherer) -+ -+- #12375: allow use of [@untagged] for all immediate types like char, bool, -+ and variant with only constant constructors. -+ (Christophe Raffalli, review by Gabriel Scherer) -+ -+* #12502: the compiler now normalizes the newline sequence \r\n to -+ a single \n character during lexing, to guarantee that the semantics -+ of newlines in string literals is not modified by Windows tools -+ transforming \n into \r\n in source files. -+ Warning 29 [eol-in-string] is not emitted anymore, as the normalization -+ gives a more robust semantics to newlines in string literals. -+ (Gabriel Scherer and Damien Doligez, review by Daniel Bünzli, David -+ Allsopp, Andreas Rossberg, Xavier Leroy, report by Andreas Rossberg) - - ### Standard library: - --- #12716: Add `Format.pp_print_nothing` function. -- (Léo Andrès, review by Gabriel Scherer and Nicolás Ojeda Bär) -- - - #11563: Add the Dynarray module to the stdlib. Dynamic arrays are - arrays whose length can be changed by adding or removing elements at - the end, similar to 'vectors' in C++ or Rust. -@@ -299,6 +260,10 @@ OCaml 5.2.0 - Daniel Bünzli, Guillaume Munch-Maccagnoni, Clément Allain, - Damien Doligez, Wiktor Kuchta and Pieter Goetschalckx) - -+ -+- #12716: Add `Format.pp_print_nothing` function. -+ (Léo Andrès, review by Gabriel Scherer and Nicolás Ojeda Bär) -+ - * #6732, #12423: Make Buffer.add_substitute surjective and fix its - documentation. - (Damien Doligez, review by Antonin Décimo) -@@ -380,6 +345,35 @@ OCaml 5.2.0 - C API. - (David Allsopp, review by Nicolás Ojeda Bär and Xavier Leroy) - -+### Type system: -+ -+- #12313, #11799: Do not re-build as-pattern type when a ground type annotation -+ is given. This allows to work around problems with GADTs in as-patterns. -+ (Jacques Garrigue, report by Leo White, review by Gabriel Scherer) -+ -+### Code generation and optimizations: -+ -+- #11239: on x86-64 and RISC-V, reduce alignment of OCaml stacks from 16 to 8. -+ This reduces stack usage. It's only C stacks that require 16-alignment. -+ (Xavier Leroy, review by Gabriel Scherer and Stephen Dolan) -+ -+- #12311: on POWER, 32-bit FP numbers stored in memory (e.g. in bigarrays) -+ were not correctly rounded sometimes. -+ (Xavier Leroy, review by Anil Madhavapeddy and Tim McGilchrist) -+ -+- #12551, #12608, #12782, #12596: Overhaul of recursive value compilation. -+ Non-function recursive bindings are now forbidden from Lambda onwards, -+ and compiled using a new Value_rec_compiler module. -+ (Vincent Laviron and Lunia Ayanides, review by Gabriel Scherer, -+ Stefan Muenzel and Nathanaëlle Courant) -+ -+- #1809, #12181: rewrite `compare x y op 0` to `x op y` when values are integers -+ (Xavier Clerc, Stefan Muenzel, review by Gabriel Scherer and Vincent Laviron) -+ -+- #12825: disable common subexpression elimination for atomic loads... again. -+ (Gabriel Scherer, review by KC Sivaramakrishnan, Xavier Leroy -+ and Vincent Laviron, report by Vesa Karvonen) -+ - ### Other libraries: - - - #12213: Dynlink library, improve legibility of error messages -@@ -390,98 +384,14 @@ OCaml 5.2.0 - instead of `value`. - (Xavier Leroy, review by David Allsopp) - --### Tools: -- --- #12340: testsuite: collect known issues with current -short-paths -- implementation for existential types -- (Florian Angeletti, Samuel Hym, review by Florian Angeletti and Thomas Refis) -- --- #12147: ocamllex: Allow carriage returns at the end of line directives. -- (SeungCheol Jung, review by Nicolás Ojeda Bär) -- --- #12260: Fix invalid_argument on some external or module aliases in ocamlnat -- (Fabian Hemmer, review by Vincent Laviron) -- --- #12185: New script language for ocamltest. -- (Damien Doligez with Florian Angeletti, Sébastien Hinderer, Gabriel Scherer, -- review by Sébastien Hinderer and Gabriel Scherer) -- --- #12371: ocamltest: fix recursive expansion of variables. -- (Antonin Décimo, Damien Doligez, review by Sébastien Hinderer, -- Damien Doligez, Gabriel Scherer, and Xavier Leroy) -- --* #12497, #12613: Make ocamlc/ocamlopt fail with an error when no -- input files are specified to build an executable. -- (Antonin Décimo, review by Sébastien Hinderer) -- --- #12576: ocamldep: various refactors. -- (Antonin Décimo, review by Florian Angeletti, Gabriel Scherer, and Léo Andrès) -- --- #12615: ocamldoc: get rid of the odoc_literate and odoc_todo generators. -- (Sébaistien Hinderer, review by Gabriel Scherer and Florian Angeletti) -- --- #12624: Use $XDG_CONFIG_DIRS in addition to $XDG_CONFIG_HOME when searching -- for init.ml and use this to extend init.ml support to the toplevel when -- running on Windows. -- (David Allsopp, report by Jonah Beckford, review by Nicolás Ojeda Bär and -- Antonin Décimo) -- --- #12688: Setting the env variable `NO_COLOR` with an empty value no longer -- has effects. Previously, setting `NO_COLOR` with any value, including -- the empty value, would disable colors (unless `OCAML_COLOR` is also set). -- After this change, the user must set `NO_COLOR` with an non-empty value -- to disable colors. This reflects a specification clarification/change -- from the upstream website at https://no-color.org. -- (Favonia, review by Gabriel Scherer) -- --- #12744: ocamltest: run tests in recursive subdirs more eagerly -- (Nick Roberts, review by Nicolás Ojeda Bär) -- --- #12901, 12908: ocamllex: add overflow checks to prevent generating incorrect -- lexers; use unsigned numbers in the table encoding when possible. -- (Vincent Laviron, report by Edwin Török, review by Xavier Leroy) -- --### Manual and documentation: -- --- #12338: clarification of the documentation of process related function in -- the unix module regarding the first element of args and shell's pid. -- (Christophe Raffalli, review by Florian Angeletti) -- --- #12473: Document in runtime/memory.c our current understanding of -- accesses to the OCaml heap from the C runtime code -- the problem -- of hybrid programs mixing two memory models. -- (Gabriel Scherer and Guillaume Munch-Maccagnoni, review by Olivier -- Nicole and Xavier Leroy) -- --- #12694: Document in runtime/tsan.c the TSan instrumentation choices and the -- consequences with regard to the memory model. -- (Olivier Nicole, review by Miod Vallat, Gabriel Scherer, Guillaume -- Munch-Maccagnoni and Fabrice Buoro) -- --- #12802: Add manual chapter about ThreadSanitizer support -- (Olivier Nicole, review by Miod Vallat, Sebastien Hinderer, Fabrice Buoro, -- Gabriel Scherer and KC Sivaramakrishnan) -- --- #12819: Clarify which runtime interactions are allowed in custom ops -- (Basile Clément, review by Guillaume Munch-Maccagnoni and Xavier Leroy) -- --- #12840: manual: update runtime tracing chapter for custom events (ex #12335) -- (Lucas Pluvinage, Sadiq Jaffer and Olivier Nicole, review by Gabriel Scherer, -- David Allsopp, Tim McGilchrist and Thomas Leonard) -- --- #13066, update OCAMLRUNPARAM documentation for the stack size parameter l -- (Florian Angeletti, review by Nicolás Ojeda Bär, Tim McGilchrist, and -- Miod Vallat) -- --- #13078: update Format tutorial on structural boxes to mention alignment -- questions. -- (Edwin Török, review by Florian Angeletti) -- --- #13092: document the existence of the `[@@poll error]` built-in attribute -- (Florian Angeletti, review by Gabriel Scherer) -- - ### Compiler user-interface and warnings: - -+- #11989, #12246, RFC 31: New flag, -H, to allow for transitive dependencies -+ without including them in the initial environment. -+ (Chris Casinghino, François Bobot, and Gabriel Scherer, review by Leo White -+ and Stefan Muenzel, RFC by François Bobot) -+ -+ - * #10613, #12405: Simplify the values used for the system variable (`system:` in - `ocamlopt -config` or the `Config.system` constant). In particular, s390x and - ppc64 now report "linux" instead of "elf"; all variants of 32-bit ARM on Linux -@@ -493,11 +403,6 @@ OCaml 5.2.0 - (David Allsopp, request by Kate Deplaix, review by Sébastien Hinderer and - Xavier Leroy) - --- #11989, #12246, RFC 31: New flag, -H, to allow for transitive dependencies -- without including them in the initial environment. -- (Chris Casinghino, François Bobot, and Gabriel Scherer, review by Leo White -- and Stefan Muenzel, RFC by François Bobot) -- - - #12247: configure: --disable-ocamldebug can now be used instead - of --disable-debugger (which remains available for compatibility) - (Gabriel Scherer, review by Damien Doligez and Sébastien Hinderer) -@@ -546,9 +451,125 @@ OCaml 5.2.0 - - * #12942: Fix an line ordering in some module inclusion error messages - (Nick Roberts, review by Florian Angeletti, report by Carl Eastlund) -+### Manual and documentation: -+ -+- #12338: clarification of the documentation of process related function in -+ the unix module regarding the first element of args and shell's pid. -+ (Christophe Raffalli, review by Florian Angeletti) -+ -+- #12473: Document in runtime/memory.c our current understanding of -+ accesses to the OCaml heap from the C runtime code -- the problem -+ of hybrid programs mixing two memory models. -+ (Gabriel Scherer and Guillaume Munch-Maccagnoni, review by Olivier -+ Nicole and Xavier Leroy) -+ -+- #12456: Document the incompatibility between effects on the one -+ hand, and `caml_callback` and asynchronous callbacks (signal -+ handlers, finalisers, memprof callbacks...) on the other hand. -+ (Guillaume Munch-Maccagnoni, review by KC Sivaramakrishnan) -+ -+- #12694: Document in runtime/tsan.c the TSan instrumentation choices and the -+ consequences with regard to the memory model. -+ (Olivier Nicole, review by Miod Vallat, Gabriel Scherer, Guillaume -+ Munch-Maccagnoni and Fabrice Buoro) -+ -+- #12802: Add manual chapter about ThreadSanitizer support -+ (Olivier Nicole, review by Miod Vallat, Sebastien Hinderer, Fabrice Buoro, -+ Gabriel Scherer and KC Sivaramakrishnan) -+ -+- #12819: Clarify which runtime interactions are allowed in custom ops -+ (Basile Clément, review by Guillaume Munch-Maccagnoni and Xavier Leroy) -+ -+- #12840: manual: update runtime tracing chapter for custom events (ex #12335) -+ (Lucas Pluvinage, Sadiq Jaffer and Olivier Nicole, review by Gabriel Scherer, -+ David Allsopp, Tim McGilchrist and Thomas Leonard) -+ -+- #13066, update OCAMLRUNPARAM documentation for the stack size parameter l -+ (Florian Angeletti, review by Nicolás Ojeda Bär, Tim McGilchrist, and -+ Miod Vallat) -+ -+- #13078: update Format tutorial on structural boxes to mention alignment -+ questions. -+ (Edwin Török, review by Florian Angeletti) -+ -+- #13092: document the existence of the `[@@poll error]` built-in attribute -+ (Florian Angeletti, review by Gabriel Scherer) -+ -+### Tools: -+ -+- #12340: testsuite: collect known issues with current -short-paths -+ implementation for existential types -+ (Florian Angeletti, Samuel Hym, review by Florian Angeletti and Thomas Refis) -+ -+- #12147: ocamllex: Allow carriage returns at the end of line directives. -+ (SeungCheol Jung, review by Nicolás Ojeda Bär) -+ -+- #12260: Fix invalid_argument on some external or module aliases in ocamlnat -+ (Fabian Hemmer, review by Vincent Laviron) -+ -+- #12185: New script language for ocamltest. -+ (Damien Doligez with Florian Angeletti, Sébastien Hinderer, Gabriel Scherer, -+ review by Sébastien Hinderer and Gabriel Scherer) -+ -+- #12371: ocamltest: fix recursive expansion of variables. -+ (Antonin Décimo, Damien Doligez, review by Sébastien Hinderer, -+ Damien Doligez, Gabriel Scherer, and Xavier Leroy) -+ -+* #12497, #12613: Make ocamlc/ocamlopt fail with an error when no -+ input files are specified to build an executable. -+ (Antonin Décimo, review by Sébastien Hinderer) -+ -+- #12576: ocamldep: various refactors. -+ (Antonin Décimo, review by Florian Angeletti, Gabriel Scherer, and Léo Andrès) -+ -+- #12615: ocamldoc: get rid of the odoc_literate and odoc_todo generators. -+ (Sébaistien Hinderer, review by Gabriel Scherer and Florian Angeletti) -+ -+- #12624: Use $XDG_CONFIG_DIRS in addition to $XDG_CONFIG_HOME when searching -+ for init.ml and use this to extend init.ml support to the toplevel when -+ running on Windows. -+ (David Allsopp, report by Jonah Beckford, review by Nicolás Ojeda Bär and -+ Antonin Décimo) -+ -+- #12688: Setting the env variable `NO_COLOR` with an empty value no longer -+ has effects. Previously, setting `NO_COLOR` with any value, including -+ the empty value, would disable colors (unless `OCAML_COLOR` is also set). -+ After this change, the user must set `NO_COLOR` with an non-empty value -+ to disable colors. This reflects a specification clarification/change -+ from the upstream website at https://no-color.org. -+ (Favonia, review by Gabriel Scherer) -+ -+- #12744: ocamltest: run tests in recursive subdirs more eagerly -+ (Nick Roberts, review by Nicolás Ojeda Bär) -+ -+- #12901, 12908: ocamllex: add overflow checks to prevent generating incorrect -+ lexers; use unsigned numbers in the table encoding when possible. -+ (Vincent Laviron, report by Edwin Török, review by Xavier Leroy) - - ### Internal/compiler-libs changes: - -+- #12508 : Add compiler-side support for project-wide occurrences in Merlin, by -+ generating index tables of all identifier occurrences. This extra data in .cmt -+ files is only added when the new flag -bin-annot-occurrences is passed. -+ (Ulysse Gérard, Nathanaëlle Courant, suggestions by Gabriel Scherer and Thomas -+ Refis, review by Florian Angeletti, Gabriel Scherer and Thomas Refis) -+ -+- #12236, #12386, #12391, #12496, #12673: Use syntax as sole determiner of arity -+ This changes function arity to be based solely on the source program's -+ parsetree. Previously, the heuristic for arity had more subtle heuristics -+ that involved type information about patterns. Function arity is important -+ because it determines when a pattern match's effects run and is an input -+ into the fast path for function application. -+ -+ This change affects tooling: it changes the function constructs in parsetree -+ and typedtree. -+ -+ See https://github.com/ocaml/RFCs/pull/32 for the original RFC. -+ -+ (Nick Roberts; review by Richard Eisenberg, Leo White, and Gabriel Scherer; -+ RFC by Stephen Dolan) -+ -+ - - #12639: parsing: Attach a location to the RHS of Ptyp_alias - and improve the 'alias type mismatch' error message. - (Jules Aguillon, review by Florian Angeletti) -@@ -583,21 +604,6 @@ OCaml 5.2.0 - in Typecore in favor of local mutable state. - (Nick Roberts, review by Takafumi Saikawa) - --- #12236, #12386, #12391, #12496, #12673: Use syntax as sole determiner of arity -- This changes function arity to be based solely on the source program's -- parsetree. Previously, the heuristic for arity had more subtle heuristics -- that involved type information about patterns. Function arity is important -- because it determines when a pattern match's effects run and is an input -- into the fast path for function application. -- -- This change affects tooling: it changes the function constructs in parsetree -- and typedtree. -- -- See https://github.com/ocaml/RFCs/pull/32 for the original RFC. -- -- (Nick Roberts; review by Richard Eisenberg, Leo White, and Gabriel Scherer; -- RFC by Stephen Dolan) -- - - #12542: Minor bugfix to #12236: restore dropped call to `instance` - (Nick Roberts, review by Jacques Garrigue) - -@@ -650,12 +656,6 @@ OCaml 5.2.0 - - #12764: Move all installable headers in `caml/` sub-directories. - (Antonin Décimo, review by Gabriel Scherer and David Allsopp) - --- #12508 : Add compiler-side support for project-wide occurrences in Merlin, by -- generating index tables of all identifier occurrences. This extra data in .cmt -- files is only added when the new flag -bin-annot-occurrences is passed. -- (Ulysse Gérard, Nathanaëlle Courant, suggestions by Gabriel Scherer and Thomas -- Refis, review by Florian Angeletti, Gabriel Scherer and Thomas Refis) -- - - #12914: Slightly change the s390x assembly dialect in order to build with - Clang's integrated assembler. - (Miod Vallat, review by Gabriel Scherer) -@@ -888,6 +888,10 @@ OCaml 5.2.0 - - #13094: Fix undefined behavior of left-shifting a negative number. - (Antonin Décimo, review by Miod Vallat and Nicolás Ojeda Bär) - -+- #13130: minor fixes to pprintast for raw identifiers and local module open -+ syntax for types. -+ (Chet Murthy, review by Gabriel Scherer) -+ - OCaml 5.1.1 (8 December 2023) - ---------------------------- - --- -2.44.0 - diff --git a/0004-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch similarity index 64% rename from 0004-configure-Allow-user-defined-C-compiler-flags.patch rename to 0002-configure-Allow-user-defined-C-compiler-flags.patch index 3c14867..9894bc3 100644 --- a/0004-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ From edd903fc73b98eb784b307a47110985967cb1d09 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 4/7] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/2] configure: Allow user defined C compiler flags. --- configure.ac | 8 ++++++-- @@ -11,7 +11,7 @@ diff --git a/configure.ac b/configure.ac index 48aa9f0a29..fc29c88f50 100644 --- a/configure.ac +++ b/configure.ac -@@ -869,6 +869,10 @@ AS_CASE([$ocaml_cc_vendor], +@@ -925,6 +925,10 @@ AS_CASE([$ocaml_cc_vendor], internal_cflags="$cc_warnings"], [common_cflags="-O"]) @@ -22,7 +22,7 @@ index 48aa9f0a29..fc29c88f50 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. AS_CASE([$host], [i686-*-mingw32*], -@@ -2648,7 +2652,7 @@ AC_CONFIG_COMMANDS_PRE([ +@@ -2708,7 +2712,7 @@ AC_CONFIG_COMMANDS_PRE([ [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) mkdll_ldflags="" AS_IF([test -n "${LDFLAGS}"], @@ -31,15 +31,5 @@ index 48aa9f0a29..fc29c88f50 100644 mkdll_ldflags="${mkdll_ldflags} ${mkexe_ldflags_prefix}${flag}" done mkdll_ldflags_exp="$mkdll_ldflags"]) -@@ -2674,7 +2678,7 @@ ${mkdll_ldflags}" - ],[ - mkdll_ldflags='$(OC_DLL_LDFLAGS) $(LDFLAGS)' - mkdll_ldflags_exp="${oc_dll_ldflags}" -- AS_IF([test -n ${LDFLAGS}], -+ AS_IF([test -n "${LDFLAGS}"], - [mkdll_ldflags_exp="$mkdll_ldflags_exp $LDFLAGS"]) - mkexe_ldflags="\$(OC_LDFLAGS) \$(LDFLAGS)" - mkexe_ldflags_exp="${oc_ldflags} ${LDFLAGS}" -- 2.44.0 - diff --git a/0005-flambda-Improve-transitive-closure-in-invariant_para.patch b/0005-flambda-Improve-transitive-closure-in-invariant_para.patch deleted file mode 100644 index b0b347c..0000000 --- a/0005-flambda-Improve-transitive-closure-in-invariant_para.patch +++ /dev/null @@ -1,114 +0,0 @@ -From acdc441ff1acb5390467e649bc9a9bfddd7df774 Mon Sep 17 00:00:00 2001 -From: Florian Weimer -Date: Thu, 9 May 2024 10:03:23 +0200 -Subject: [PATCH 5/7] flambda: Improve transitive closure in - invariant_params_in_recursion (#13150) - -The old implementation did not really exploit the sparseness of the -graph because it used newly discovered edges in later iterations. -The new implementation processes each original relation only once -per starting node, and does not re-process newly discovered relations. - -(cherry picked from commit 787b4fbb5aaf3728de54ca240ba9ca0bf56ace60) ---- - Changes | 5 ++ - middle_end/flambda/invariant_params.ml | 66 ++++++++++---------------- - 2 files changed, 31 insertions(+), 40 deletions(-) - -diff --git a/Changes b/Changes -index 75842fc216..d26512067d 100644 ---- a/Changes -+++ b/Changes -@@ -1,6 +1,11 @@ - OCaml 5.2.0 (13 May 2024) - ------------------------- - -+- #13150: improve a transitive-closure computation algorithm in the flambda -+ middle-end to avoid a compilation time blowup on Menhir-generated code -+ (Florian Weimer, review by Gabriel Scherer and Pierre Chambart, -+ report by Richard Jones) -+ - (Changes that can break existing programs are marked with a "*") - - ### Restored and new backends: -diff --git a/middle_end/flambda/invariant_params.ml b/middle_end/flambda/invariant_params.ml -index 414d39310a..dba63970fd 100644 ---- a/middle_end/flambda/invariant_params.ml -+++ b/middle_end/flambda/invariant_params.ml -@@ -65,47 +65,33 @@ let implies relation from to_ = - relation - - let transitive_closure state = -- let union s1 s2 = -- match s1, s2 with -- | Top, _ | _, Top -> Top -- | Implication s1, Implication s2 -> -- Implication (Variable.Pair.Set.union s1 s2) -+ (* Depth-first search for all implications for one argument. -+ Arguments are moved from candidate to frontier, assuming -+ they are newly added to the result. *) -+ let rec loop candidate frontier result = -+ match (candidate, frontier) with -+ | ([], []) -> Implication result -+ | ([], frontier::fs) -> -+ (* Obtain fresh candidate for the frontier argument. *) -+ (match Variable.Pair.Map.find frontier state with -+ | exception Not_found -> loop [] fs result -+ | Top -> Top -+ | Implication candidate -> -+ loop (Variable.Pair.Set.elements candidate) fs result) -+ | (candidate::cs, frontier) -> -+ let result' = Variable.Pair.Set.add candidate result in -+ if result' != result then -+ (* Result change means candidate becomes part of frontier. *) -+ loop cs (candidate :: frontier) result' -+ else -+ loop cs frontier result - in -- let equal s1 s2 = -- match s1, s2 with -- | Top, Implication _ | Implication _, Top -> false -- | Top, Top -> true -- | Implication s1, Implication s2 -> Variable.Pair.Set.equal s1 s2 -- in -- let update arg state = -- let original_set = -- try Variable.Pair.Map.find arg state with -- | Not_found -> Implication Variable.Pair.Set.empty -- in -- match original_set with -- | Top -> state -- | Implication arguments -> -- let set = -- Variable.Pair.Set.fold -- (fun orig acc-> -- let set = -- try Variable.Pair.Map.find orig state with -- | Not_found -> Implication Variable.Pair.Set.empty in -- union set acc) -- arguments original_set -- in -- Variable.Pair.Map.add arg set state -- in -- let once state = -- Variable.Pair.Map.fold (fun arg _ state -> update arg state) state state -- in -- let rec fp state = -- let state' = once state in -- if Variable.Pair.Map.equal equal state state' -- then state -- else fp state' -- in -- fp state -+ Variable.Pair.Map.map -+ (fun set -> -+ match set with -+ | Top -> Top -+ | Implication set -> loop [] (Variable.Pair.Set.elements set) set) -+ state - - (* CR-soon pchambart: to move to Flambda_utils and document - mshinwell: I think this calculation is basically the same as --- -2.44.0 - diff --git a/0006-Reload-exception-pointer-register-in-caml_c_call.patch b/0006-Reload-exception-pointer-register-in-caml_c_call.patch deleted file mode 100644 index 4c20a85..0000000 --- a/0006-Reload-exception-pointer-register-in-caml_c_call.patch +++ /dev/null @@ -1,165 +0,0 @@ -From 8637cac022907501c3c0d941e07e436b70c9d4ac Mon Sep 17 00:00:00 2001 -From: Miod Vallat <118974489+dustanddreams@users.noreply.github.com> -Date: Thu, 30 May 2024 09:57:41 +0000 -Subject: [PATCH 6/7] Reload exception pointer register in caml_c_call* - -The invoked code may end up causing caml_try_realloc_stack() to be invoked, -which in turn may replace the stack TRAP_PTR points to, leading to -either crashes with the debug runtime (thanks to the old stack contents -being overwritten) or all kinds of memory or control flow corruption otherwise. - -Added test for stack reallocation in callback followed by exception raising. - -(cherry picked from commit 6964d3a90f84402ed6066fb1821679435e063067) -(cherry picked from commit 1e8a91d305f1fa4668444fb1cce97952dbc39810) ---- - Changes | 9 +++++++++ - runtime/arm64.S | 6 ++++-- - runtime/power.S | 6 ++++-- - runtime/riscv.S | 6 ++++-- - runtime/s390x.S | 5 +++-- - testsuite/tests/callback/test1.ml | 5 +++++ - 6 files changed, 29 insertions(+), 8 deletions(-) - -diff --git a/Changes b/Changes -index d26512067d..53bb5369b9 100644 ---- a/Changes -+++ b/Changes -@@ -1,3 +1,12 @@ -+OCaml 5.2 maintenance version -+----------------------------- -+ -+- #13207: Be sure to reload the register caching the exception handler in -+ caml_c_call and caml_c_call_stack_args, as its value may have been changed -+ if the OCaml stack is expanded during a callback. -+ (Miod Vallat, report by Vesa Karvonen, review by Gabriel Scherer and -+ Xavier Leroy) -+ - OCaml 5.2.0 (13 May 2024) - ------------------------- - -diff --git a/runtime/arm64.S b/runtime/arm64.S -index e71f25ebba..6c6495a0a8 100644 ---- a/runtime/arm64.S -+++ b/runtime/arm64.S -@@ -569,8 +569,9 @@ FUNCTION(caml_c_call) - str TRAP_PTR, Caml_state(exn_handler) - /* Call the function */ - blr ADDITIONAL_ARG -- /* Reload alloc ptr */ -+ /* Reload new allocation pointer & exn handler */ - ldr ALLOC_PTR, Caml_state(young_ptr) -+ ldr TRAP_PTR, Caml_state(exn_handler) - /* Load ocaml stack */ - SWITCH_C_TO_OCAML - #if defined(WITH_THREAD_SANITIZER) -@@ -625,8 +626,9 @@ FUNCTION(caml_c_call_stack_args) - blr ADDITIONAL_ARG - /* Restore stack */ - mov sp, x19 -- /* Reload alloc ptr */ -+ /* Reload new allocation pointer & exn handler */ - ldr ALLOC_PTR, Caml_state(young_ptr) -+ ldr TRAP_PTR, Caml_state(exn_handler) - /* Switch from C to OCaml */ - SWITCH_C_TO_OCAML - /* Return */ -diff --git a/runtime/power.S b/runtime/power.S -index bfb37fa989..257678100e 100644 ---- a/runtime/power.S -+++ b/runtime/power.S -@@ -445,8 +445,9 @@ FUNCTION caml_c_call - mr 2, C_CALL_TOC /* restore current TOC */ - /* Restore return address (in register C_CALL_RET_ADDR, preserved by C) */ - mtlr C_CALL_RET_ADDR -- /* Reload allocation pointer*/ -+ /* Reload new allocation pointer and exception pointer */ - ld ALLOC_PTR, Caml_state(young_ptr) -+ ld TRAP_PTR, Caml_state(exn_handler) - #if defined(WITH_THREAD_SANITIZER) - TSAN_SETUP_C_CALL 16 - /* Save return value registers. Since the called function could be anything, -@@ -497,8 +498,9 @@ FUNCTION caml_c_call_stack_args - add SP, SP, STACK_ARG_BYTES - /* Restore return address (in register C_CALL_RET_ADDR, preserved by C) */ - mtlr C_CALL_RET_ADDR -- /* Reload allocation pointer*/ -+ /* Reload new allocation pointer and exception pointer */ - ld ALLOC_PTR, Caml_state(young_ptr) -+ ld TRAP_PTR, Caml_state(exn_handler) - /* Switch from C to OCaml */ - SWITCH_C_TO_OCAML - /* Return to caller */ -diff --git a/runtime/riscv.S b/runtime/riscv.S -index a2eca7a315..8934db0bb3 100644 ---- a/runtime/riscv.S -+++ b/runtime/riscv.S -@@ -516,8 +516,9 @@ L(caml_c_call): - sd TRAP_PTR, Caml_state(exn_handler) - /* Call the function */ - jalr ADDITIONAL_ARG -- /* Reload alloc ptr */ -+ /* Reload new allocation pointer & exn handler */ - ld ALLOC_PTR, Caml_state(young_ptr) -+ ld TRAP_PTR, Caml_state(exn_handler) - /* Load ocaml stack */ - SWITCH_C_TO_OCAML - #if defined(WITH_THREAD_SANITIZER) -@@ -575,8 +576,9 @@ FUNCTION(caml_c_call_stack_args) - jalr ADDITIONAL_ARG - /* Restore stack */ - mv sp, s2 -- /* Reload alloc ptr */ -+ /* Reload new allocation pointer & exn handler */ - ld ALLOC_PTR, Caml_state(young_ptr) -+ ld TRAP_PTR, Caml_state(exn_handler) - /* Switch from C to OCaml */ - SWITCH_C_TO_OCAML - /* Return */ -diff --git a/runtime/s390x.S b/runtime/s390x.S -index b59822ce57..113831a376 100644 ---- a/runtime/s390x.S -+++ b/runtime/s390x.S -@@ -515,7 +515,7 @@ LBL(caml_c_call): - #endif - basr %r14, ADDITIONAL_ARG - CLEANUP_AFTER_C_CALL -- /* Reload alloc ptr */ -+ /* Reload new allocation pointer & exn handler */ - lg ALLOC_PTR, Caml_state(young_ptr) - lg TRAP_PTR, Caml_state(exn_handler) - /* Load ocaml stack and restore global variables */ -@@ -584,8 +584,9 @@ LBL(106): - CLEANUP_AFTER_C_CALL - /* Restore stack */ - lgr %r15, %r12 -- /* Reload alloc ptr */ -+ /* Reload new allocation pointer & exn handler */ - lg ALLOC_PTR, Caml_state(young_ptr) -+ lg TRAP_PTR, Caml_state(exn_handler) - /* Switch from C to OCaml */ - SWITCH_C_TO_OCAML - /* Return */ -diff --git a/testsuite/tests/callback/test1.ml b/testsuite/tests/callback/test1.ml -index c39be0c586..f6ad4356cf 100644 ---- a/testsuite/tests/callback/test1.ml -+++ b/testsuite/tests/callback/test1.ml -@@ -11,6 +11,9 @@ external mycallback3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd - external mycallback4 : - ('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e = "mycallback4" - -+let rec growstack n = -+ if n <= 0 then 0 else 1 + growstack (n - 1) -+ - let rec tak (x, y, z as _tuple) = - if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y)) - else z -@@ -46,3 +49,5 @@ let _ = - print_int(trapexit ()); print_newline(); - print_string(tripwire mypushroot); print_newline(); - print_string(tripwire mycamlparam); print_newline(); -+ begin try ignore (mycallback1 growstack 1_000); raise Exit -+ with Exit -> () end --- -2.44.0 - diff --git a/0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch b/0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch deleted file mode 100644 index e9dd879..0000000 --- a/0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch +++ /dev/null @@ -1,178 +0,0 @@ -From 4eb80b13779125fcd76a445ab0004ca064fab634 Mon Sep 17 00:00:00 2001 -From: Miod Vallat -Date: Fri, 7 Jun 2024 06:19:45 +0000 -Subject: [PATCH 7/7] Compute more accurate instruction sizes for branch - relaxation. - -(cherry picked from commit 114ddae2d4c85391a4f939dc6623424ae35a07aa) ---- - Changes | 4 ++ - asmcomp/power/emit.mlp | 87 ++++++++++++++++++++++++------------------ - 2 files changed, 53 insertions(+), 38 deletions(-) - -diff --git a/Changes b/Changes -index 53bb5369b9..1a81509247 100644 ---- a/Changes -+++ b/Changes -@@ -7,6 +7,10 @@ OCaml 5.2 maintenance version - (Miod Vallat, report by Vesa Karvonen, review by Gabriel Scherer and - Xavier Leroy) - -+- #13221: Compute more accurate instruction sizes for branch relocation on -+ POWER. -+ (Miod Vallat, review by Gabriel Scherer) -+ - OCaml 5.2.0 (13 May 2024) - ------------------------- - -diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp -index 47f5419a92..fdf22996fa 100644 ---- a/asmcomp/power/emit.mlp -+++ b/asmcomp/power/emit.mlp -@@ -177,6 +177,28 @@ let emit_tocload emit_dest dest entry = - - (* Output a load or store operation *) - -+let load_mnemonic = function -+ | Byte_unsigned -> "lbz" -+ | Byte_signed -> "lbz" -+ | Sixteen_unsigned -> "lhz" -+ | Sixteen_signed -> "lha" -+ | Thirtytwo_unsigned -> "lwz" -+ | Thirtytwo_signed -> "lwa" -+ | Word_int | Word_val -> "ld" -+ | Single -> "lfs" -+ | Double -> "lfd" -+ -+let store_mnemonic = function -+ | Byte_unsigned | Byte_signed -> "stb" -+ | Sixteen_unsigned | Sixteen_signed -> "sth" -+ | Thirtytwo_unsigned | Thirtytwo_signed -> "stw" -+ | Word_int | Word_val -> "std" -+ | Single -> "stfs" -+ | Double -> "stfd" -+ -+let store_needs_lwsync chunk assignment = -+ assignment && (chunk = Word_int || chunk = Word_val) -+ - let valid_offset instr ofs = - ofs land 3 = 0 || (instr <> "ld" && instr <> "std" && instr <> "lwa") - -@@ -383,11 +405,17 @@ module BR = Branch_relaxation.Make (struct - - let tocload_size = 2 - -- let load_store_size = function -+ let load_store_size instr = function - | Ibased(_s, d) -> -- let (_lo, hi) = low_high_s d in -- tocload_size + (if hi = 0 then 1 else 2) -- | Iindexed ofs -> if is_immediate ofs then 1 else 3 -+ let (lo, hi) = low_high_s d in -+ tocload_size + -+ (if hi <> 0 then 1 else 0) + -+ (if valid_offset instr lo then 1 else 2) -+ | Iindexed ofs -> -+ if is_immediate ofs && valid_offset instr ofs then 1 else begin -+ let (lo, _hi) = low_high_u ofs in -+ if lo <> 0 then 3 else 2 -+ end - | Iindexed2 -> 1 - - let instr_size f = function -@@ -415,16 +443,16 @@ module BR = Branch_relaxation.Make (struct - else if alloc then tocload_size + 2 - else 5 - | Lop(Istackoffset _) -> 1 -- | Lop(Iload {memory_chunk; addressing_mode; _ }) -> -- if memory_chunk = Byte_signed -- then load_store_size addressing_mode + 1 -- else load_store_size addressing_mode -+ | Lop(Iload {memory_chunk; addressing_mode; is_atomic }) -> -+ let loadinstr = load_mnemonic memory_chunk in -+ (if is_atomic then 4 else 0) + -+ (if memory_chunk = Byte_signed then 1 else 0) + -+ load_store_size loadinstr addressing_mode - | Lop(Istore(chunk, addr, assignment)) -> -- (match chunk with -- | Single -> 1 -- | Word_int | Word_val when assignment -> 1 -- | _ -> 0) -- + load_store_size addr -+ let storeinstr = store_mnemonic chunk in -+ (if chunk = Single then 1 else 0) + -+ (if store_needs_lwsync chunk assignment then 1 else 0) + -+ load_store_size storeinstr addr - | Lop(Ialloc _) -> 5 - | Lop(Ispecific(Ialloc_far _)) -> 6 - | Lop(Ipoll { return_label = Some(_) }) -> 5 -@@ -442,12 +470,12 @@ module BR = Branch_relaxation.Make (struct - | Lop(Ispecific(Icheckbound_imm_far _)) -> 3 - | Lop(Iintop_imm _) -> 1 - | Lop(Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf) -> 1 -- | Lop(Ifloatofint) -> 9 -- | Lop(Iintoffloat) -> 4 -+ | Lop(Ifloatofint) -> 3 -+ | Lop(Iintoffloat) -> 3 - | Lop(Iopaque) -> 0 - | Lop(Ispecific _) -> 1 -- | Lop (Idls_get) -> 1 -- | Lop (Ireturn_addr) -> 1 -+ | Lop(Idls_get) -> 1 -+ | Lop(Ireturn_addr) -> 1 - | Lreloadretaddr -> 2 - | Lreturn -> 2 - | Llabel _ -> 0 -@@ -457,7 +485,7 @@ module BR = Branch_relaxation.Make (struct - 1 + (if lbl0 = None then 0 else 1) - + (if lbl1 = None then 0 else 1) - + (if lbl2 = None then 0 else 1) -- | Lswitch _ -> 5 + tocload_size -+ | Lswitch _ -> 7 + tocload_size - | Lentertrap -> 1 - | Ladjust_trap_depth _ -> 0 - | Lpushtrap _ -> 4 + tocload_size -@@ -705,17 +733,7 @@ let emit_instr env i = - ` addi 1, 1, {emit_int (-n)}\n`; - adjust_stack_offset env n - | Lop(Iload { memory_chunk; addressing_mode; is_atomic }) -> -- let loadinstr = -- match memory_chunk with -- | Byte_unsigned -> "lbz" -- | Byte_signed -> "lbz" -- | Sixteen_unsigned -> "lhz" -- | Sixteen_signed -> "lha" -- | Thirtytwo_unsigned -> "lwz" -- | Thirtytwo_signed -> "lwa" -- | Word_int | Word_val -> "ld" -- | Single -> "lfs" -- | Double -> "lfd" in -+ let loadinstr = load_mnemonic memory_chunk in - if is_atomic then - ` sync\n`; - emit_load_store loadinstr addressing_mode i.arg 0 i.res.(0); -@@ -731,19 +749,12 @@ let emit_instr env i = - ` frsp {emit_reg tmp}, {emit_reg i.arg.(0)}\n`; - emit_load_store "stfs" addr i.arg 1 tmp - | Lop(Istore(chunk, addr, assignment)) -> -- let storeinstr = -- match chunk with -- | Byte_unsigned | Byte_signed -> "stb" -- | Sixteen_unsigned | Sixteen_signed -> "sth" -- | Thirtytwo_unsigned | Thirtytwo_signed -> "stw" -- | Word_int | Word_val -> "std" -- | Single -> assert false -- | Double -> "stfd" in -+ let storeinstr = store_mnemonic chunk in - (* Non-initializing stores need a memory barrier to follow the - Multicore OCaml memory model. Stores of size other than - Word_int and Word_val do not follow the memory model and therefore - do not need a barrier *) -- if assignment && (chunk = Word_int || chunk = Word_val) then -+ if store_needs_lwsync chunk assignment then - ` lwsync\n`; - emit_load_store storeinstr addr i.arg 1 i.arg.(0) - | Lop(Ialloc { bytes; dbginfo }) -> --- -2.44.0 - diff --git a/ocaml.spec b/ocaml.spec index c4b4035..c5c0c05 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -5,7 +5,7 @@ # primitive function declarations, all with "void" for their parameter # list. This does not match the real definitions, leading to lots of # -Wlto-type-mismatch warnings. These change the output of the tests, -# leading to many failed tests. This is still a problem in 5.2. +# leading to many failed tests. This is still a problem in 5.3. %global _lto_cflags %{nil} # OCaml has a bytecode backend that works on anything with a C @@ -45,8 +45,8 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.2.0 -Release: 3%{?dist} +Version: 5.3.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -74,30 +74,12 @@ Source2: ocaml_files.py # existing patches unchanged) adding a comment to note that it should # be incorporated into the git repo at a later time. -# Upstream after 5.2.0: -Patch: 0001-Changes-synchronisation-and-consistency-with-trunk.patch -Patch: 0002-Changes-copy-editing.patch - # Fedora-specific patches -Patch: 0003-Don-t-add-rpaths-to-libraries.patch -Patch: 0004-configure-Allow-user-defined-C-compiler-flags.patch - -# Improve performance of flambda optimizer in some cases. Required to -# compiler blow-up in coccinelle package. Upstream, but not included -# in 5.2 branch. -# https://github.com/ocaml/ocaml/pull/13150 -Patch: 0005-flambda-Improve-transitive-closure-in-invariant_para.patch - -# Upstream after 5.2.0: -Patch: 0006-Reload-exception-pointer-register-in-caml_c_call.patch - -# Fix for ppc64le code generation issue found after 5.2.0 was released. -# https://github.com/ocaml/ocaml/issues/13220 -# https://github.com/ocaml/ocaml/commit/114ddae2d4c85391a4f939dc6623424ae35a07aa -Patch: 0007-Compute-more-accurate-instruction-sizes-for-branch-r.patch +Patch: 0001-Don-t-add-rpaths-to-libraries.patch +Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch BuildRequires: make -BuildRequires: git +BuildRequires: git-core BuildRequires: gcc BuildRequires: autoconf BuildRequires: gawk @@ -135,13 +117,12 @@ Provides: bundled(md5-plumb) Provides: ocaml(compiler) = %{version} %if %{native_compiler} -%global __ocaml_requires_opts -c -f '%{buildroot}%{_bindir}/ocamlrun %{buildroot}%{_bindir}/ocamlobjinfo.byte' +%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_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. @@ -482,6 +463,11 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 diff --git a/sources b/sources index c8a1b16..eb6f2b4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.2.0.tar.gz) = 78115690186c13c1f2480e4812a9fe34cce2c28bf8a89d5c9810bca0391f930cecd9cee2b53daca8a32da1815628b33be68f3948f1ad03fa50b72b14e3ea84f2 +SHA512 (ocaml-5.3.0.tar.gz) = 73817ada340bdf4091b3edd7b292bd0074c87b4836f202f48ecf0f620a00feaa70ebc9101b97155e8caa6907646dfdf21eff728fa0e14542df3b5e5436229d06 From 9d17af02a537cd24d13ba9241cbf05f98c0c75f6 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 17 Jan 2025 20:40:47 +0000 Subject: [PATCH 78/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index c5c0c05..f5bfcc2 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -46,7 +46,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.3.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -463,6 +463,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From 5b0d3a3f5da9b30d345541737d8f4f626e1b11cb Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Sun, 22 Jun 2025 15:52:30 -0400 Subject: [PATCH 79/91] Fix RPM macros for Python 3.14 A change to argparse in 3.14 is leading it to misinterpret the '%' in '%files' as an operator. Escaping it makes it compatible with both 3.14 and earlier versions. --- ocaml.spec | 5 ++++- ocaml_files.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index f5bfcc2..3d444bd 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -46,7 +46,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.3.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: OCaml compiler and programming environment @@ -463,6 +463,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 diff --git a/ocaml_files.py b/ocaml_files.py index cf4afd1..0e4658e 100644 --- a/ocaml_files.py +++ b/ocaml_files.py @@ -429,7 +429,7 @@ if __name__ == "__main__": parser.add_argument('-i', '--install', action='store_true', default=False, - help='install files instead of generating %files') + help='install files instead of generating %%files') parser.add_argument('-n', '--no-devel', action='store_true', default=False, From b9c837a4530b0d20fa88ba22e315745e00a7322a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 24 Jul 2025 23:06:40 +0000 Subject: [PATCH 80/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 3d444bd..8732a1b 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -46,7 +46,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.3.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -463,6 +463,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 From bc284a4d37653ed2dadb8885abdb85655306ccda Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 13 Oct 2025 11:02:01 +0100 Subject: [PATCH 81/91] New upstream version 5.4.0 (RHBZ#2368289) --- 0001-Don-t-add-rpaths-to-libraries.patch | 8 ++++---- ...-Allow-user-defined-C-compiler-flags.patch | 19 ++++++++++--------- ocaml.spec | 7 +++++-- sources | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index b5735bd..eb7b77e 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,4 +1,4 @@ -From 507a1382cb82160c2a6cfc0ea5bcb3e33ece7307 Mon Sep 17 00:00:00 2001 +From c8e378e67fc8fbd9ef177794d4ed831d5528bd0b 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. @@ -8,10 +8,10 @@ Subject: [PATCH 1/2] Don't add rpaths to libraries. 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac -index 0c9d63859a..48aa9f0a29 100644 +index 0535f404b0..085fba6626 100644 --- a/configure.ac +++ b/configure.ac -@@ -1221,8 +1221,6 @@ AS_IF([test x"$enable_shared" != "xno"], +@@ -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" @@ -21,5 +21,5 @@ index 0c9d63859a..48aa9f0a29 100644 supports_shared_libraries=true], [mkdll='shared-libs-not-available']) -- -2.44.0 +2.50.1 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 9894bc3..df04691 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,17 +1,17 @@ -From edd903fc73b98eb784b307a47110985967cb1d09 Mon Sep 17 00:00:00 2001 +From 8323a13546c138266c609be8aa12841982d3a125 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 | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) + configure.ac | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 48aa9f0a29..fc29c88f50 100644 +index 085fba6626..353e10c4fc 100644 --- a/configure.ac +++ b/configure.ac -@@ -925,6 +925,10 @@ AS_CASE([$ocaml_cc_vendor], +@@ -997,6 +997,10 @@ AS_CASE([$ocaml_cc_vendor], internal_cflags="$cc_warnings"], [common_cflags="-O"]) @@ -20,9 +20,9 @@ index 48aa9f0a29..fc29c88f50 100644 +cclibs="$cclibs $LDFLAGS" + # Enable SSE2 on x86 mingw to avoid using 80-bit registers. - AS_CASE([$host], - [i686-*-mingw32*], -@@ -2708,7 +2712,7 @@ AC_CONFIG_COMMANDS_PRE([ + AS_CASE([$target], + [i686-w64-mingw32*], +@@ -2847,7 +2851,7 @@ AC_CONFIG_COMMANDS_PRE([ [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) mkdll_ldflags="" AS_IF([test -n "${LDFLAGS}"], @@ -32,4 +32,5 @@ index 48aa9f0a29..fc29c88f50 100644 done mkdll_ldflags_exp="$mkdll_ldflags"]) -- -2.44.0 +2.50.1 + diff --git a/ocaml.spec b/ocaml.spec index 8732a1b..f31d5d3 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -45,8 +45,8 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.3.0 -Release: 4%{?dist} +Version: 5.4.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -463,6 +463,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 diff --git a/sources b/sources index eb6f2b4..3f99d7d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.3.0.tar.gz) = 73817ada340bdf4091b3edd7b292bd0074c87b4836f202f48ecf0f620a00feaa70ebc9101b97155e8caa6907646dfdf21eff728fa0e14542df3b5e5436229d06 +SHA512 (ocaml-5.4.0.tar.gz) = 3684468800f4528c9fd96ef3fdd6aa04f71b77180d3ae8045d429f96b32e23cb3a8a307762c7237b6c56c087f45b59b0dab672a31166e3de254bb0fb9b4eb588 From ebbc5125daaae76311284c2c54fe55886c39e0f4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 13 Oct 2025 11:17:54 +0100 Subject: [PATCH 82/91] Fix branch name in comment --- ocaml.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index f31d5d3..194bdcd 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -68,7 +68,7 @@ Source2: ocaml_files.py # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-41-5.2.0 +# Current branch: fedora-44-5.4.0 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should From aa50731ee38984c1d004c613e9552f79d05fceb7 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 16 Jan 2026 22:24:41 +0000 Subject: [PATCH 83/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 194bdcd..a6bbf74 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -46,7 +46,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.4.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -463,6 +463,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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) From c129230259bf77640aa6604ac7894aa6e5a32a5c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 18 Feb 2026 17:51:10 +0000 Subject: [PATCH 84/91] Move bundle to the -runtime subpackage Suggested-by: Jerry James --- ocaml.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ocaml.spec b/ocaml.spec index a6bbf74..b8e9c65 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -111,9 +111,6 @@ Requires: ocaml-runtime%{?_isa} = %{version}-%{release} 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} @@ -142,6 +139,9 @@ 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. From ee9df08052efbfbe77f0c08c8ba2f2b061251cdb Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 18 Feb 2026 17:52:32 +0000 Subject: [PATCH 85/91] Replace x86_64 with %{x86_64} On Rawhide this macro expands to: x86_64 x86_64_v2 x86_64_v3 x86_64_v4 amd64 em64t Suggested-by: Jerry James --- ocaml.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index b8e9c65..69ece26 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -259,7 +259,7 @@ sed -i '/^EXTRACAMLFLAGS=/aLINKOPTS=-cclib -lm' otherlibs/unix/Makefile --disable-native-compiler \ --disable-native-toplevel \ %endif -%ifarch x86_64 +%ifarch %{x86_64} %if 0%{?_include_frame_pointers} --enable-frame-pointers \ %endif From 360b98ce787a783a5085772b4392e8b46faf93fd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 18 Feb 2026 17:53:18 +0000 Subject: [PATCH 86/91] Enable frame pointers on aarch64 Suggested-by: Jerry James --- ocaml.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 69ece26..2876a52 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -259,7 +259,7 @@ sed -i '/^EXTRACAMLFLAGS=/aLINKOPTS=-cclib -lm' otherlibs/unix/Makefile --disable-native-compiler \ --disable-native-toplevel \ %endif -%ifarch %{x86_64} +%ifarch %{x86_64} %{arm64} %if 0%{?_include_frame_pointers} --enable-frame-pointers \ %endif From e3af15bd1127528f83a7db55a5b7396499b58d1b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 20 Feb 2026 11:20:03 +0000 Subject: [PATCH 87/91] New upstream version 5.4.0 (RHBZ#2440356) --- 0001-Don-t-add-rpaths-to-libraries.patch | 6 +++--- 0002-configure-Allow-user-defined-C-compiler-flags.patch | 8 ++++---- ocaml.spec | 9 ++++++--- sources | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index eb7b77e..6bf857a 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,4 +1,4 @@ -From c8e378e67fc8fbd9ef177794d4ed831d5528bd0b Mon Sep 17 00:00:00 2001 +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. @@ -8,7 +8,7 @@ Subject: [PATCH 1/2] Don't add rpaths to libraries. 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac -index 0535f404b0..085fba6626 100644 +index 3754ad8a39..fb60c7c14c 100644 --- a/configure.ac +++ b/configure.ac @@ -1422,8 +1422,6 @@ AS_IF([test x"$enable_shared" != "xno"], @@ -21,5 +21,5 @@ index 0535f404b0..085fba6626 100644 supports_shared_libraries=true], [mkdll='shared-libs-not-available']) -- -2.50.1 +2.52.0 diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index df04691..eddb8f3 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,4 +1,4 @@ -From 8323a13546c138266c609be8aa12841982d3a125 Mon Sep 17 00:00:00 2001 +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. @@ -8,7 +8,7 @@ Subject: [PATCH 2/2] configure: Allow user defined C compiler flags. 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 085fba6626..353e10c4fc 100644 +index fb60c7c14c..f6a493ccf5 100644 --- a/configure.ac +++ b/configure.ac @@ -997,6 +997,10 @@ AS_CASE([$ocaml_cc_vendor], @@ -22,7 +22,7 @@ index 085fba6626..353e10c4fc 100644 # Enable SSE2 on x86 mingw to avoid using 80-bit registers. AS_CASE([$target], [i686-w64-mingw32*], -@@ -2847,7 +2851,7 @@ AC_CONFIG_COMMANDS_PRE([ +@@ -2904,7 +2908,7 @@ AC_CONFIG_COMMANDS_PRE([ [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) mkdll_ldflags="" AS_IF([test -n "${LDFLAGS}"], @@ -32,5 +32,5 @@ index 085fba6626..353e10c4fc 100644 done mkdll_ldflags_exp="$mkdll_ldflags"]) -- -2.50.1 +2.52.0 diff --git a/ocaml.spec b/ocaml.spec index 2876a52..698904a 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -45,8 +45,8 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.4.0 -Release: 2%{?dist} +Version: 5.4.1 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -68,7 +68,7 @@ Source2: ocaml_files.py # # https://pagure.io/fedora-ocaml # -# Current branch: fedora-44-5.4.0 +# Current branch: fedora-45-5.4.1 # # ALTERNATIVELY add a patch to the end of the list (leaving the # existing patches unchanged) adding a comment to note that it should @@ -463,6 +463,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* Fri Feb 20 2026 Richard W.M. Jones - 5.4.1-1 +- New upstream version 5.4.0 (RHBZ#2440356) + * Fri Jan 16 2026 Fedora Release Engineering - 5.4.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild diff --git a/sources b/sources index 3f99d7d..d5a609d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.4.0.tar.gz) = 3684468800f4528c9fd96ef3fdd6aa04f71b77180d3ae8045d429f96b32e23cb3a8a307762c7237b6c56c087f45b59b0dab672a31166e3de254bb0fb9b4eb588 +SHA512 (ocaml-5.4.1.tar.gz) = c44bc429bee4a263b107e60a4ab3b0c9c082ba2d784f63704130551676ce5624061ae1aa280688e3222d9a522555b3cb749eef784ab2145d71c0f19cac773383 From 2e0cb1fe4445b6382103f439cfa421288bae31d6 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 26 Feb 2026 12:56:55 +0000 Subject: [PATCH 88/91] Fix version in changelog - current version is 5.4.1, not 5.4.0 Fixes: commit e3af15bd1127528f83a7db55a5b7396499b58d1b --- ocaml.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index 698904a..2f5430c 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -464,7 +464,7 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog * Fri Feb 20 2026 Richard W.M. Jones - 5.4.1-1 -- New upstream version 5.4.0 (RHBZ#2440356) +- 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 From 5a8dd543c6916f24f103be6ace06d70a205c92bb Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 26 Feb 2026 12:59:34 +0000 Subject: [PATCH 89/91] Backport fix for arm64 frame pointers --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 2 +- ...st-14589-from-xavierleroy-arm64-addi.patch | 207 ++++++++++++++++++ ocaml.spec | 11 +- 4 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 6bf857a..03c90a8 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ 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. +Subject: [PATCH 1/3] Don't add rpaths to libraries. --- configure.ac | 2 -- diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index eddb8f3..6a6b5f7 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ 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. +Subject: [PATCH 2/3] configure: Allow user defined C compiler flags. --- configure.ac | 6 +++++- diff --git a/0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch b/0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch new file mode 100644 index 0000000..887ddcd --- /dev/null +++ b/0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch @@ -0,0 +1,207 @@ +From c2923703d02c6389b6c4594541569bf628e706b1 Mon Sep 17 00:00:00 2001 +From: Xavier Leroy +Date: Thu, 26 Feb 2026 13:43:07 +0100 +Subject: [PATCH 3/3] Merge pull request #14589 from xavierleroy/arm64-addimm + +Fix arm64 additions with large immediates + +(cherry picked from commit 4fafb9669b9a5c898b2dda0ae851b2a0e6429c43) +(cherry picked from commit 6cda6d8a928ada5dd0f58de229d3cb193cfdff53) +--- + Changes | 6 +++ + asmcomp/arm64/emit.mlp | 84 ++++++++++++++++++++---------------------- + 2 files changed, 45 insertions(+), 45 deletions(-) + +diff --git a/Changes b/Changes +index be999a8cc4..4ad8737bb0 100644 +--- a/Changes ++++ b/Changes +@@ -1,3 +1,9 @@ ++### Bug fixes: ++ ++- #14574, #14577, #14589: Fix wrong assembly code generated for ARM64 ++ with frame pointer support. ++ (Xavier Leroy, review by Vincent Laviron, report by Richard Jones) ++ + OCaml 5.4.1 (17 February 2026) + ------------------------------ + +diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp +index c821310638..3f64eebc05 100644 +--- a/asmcomp/arm64/emit.mlp ++++ b/asmcomp/arm64/emit.mlp +@@ -54,9 +54,11 @@ let emit_label_type lbl ty = + + (* Output a pseudo-register *) + +-let emit_reg = function +- {loc = Reg r} -> emit_string (register_name r) +- | _ -> fatal_error "Emit.emit_reg" ++let reg_name = function ++ | {loc = Reg r} -> register_name r ++ | _ -> fatal_error "Emit.reg_name" ++ ++let emit_reg l = emit_string (reg_name l) + + (* Likewise, but with the 32-bit name of the register *) + +@@ -249,16 +251,28 @@ let is_immediate_float bits = + let mant = Int64.logand bits 0xF_FFFF_FFFF_FFFFL in + exp >= -3 && exp <= 4 && Int64.logand mant 0xF_0000_0000_0000L = mant + ++(* Set [rd] to [rs + n]. *) ++ ++let emit_addimm_gen rd rs n = ++ let insn = if n >= 0 then "add" else "sub" in ++ let n = abs n in ++ if n <= 0xFFF then ++ ` {emit_string insn} {emit_string rd}, {emit_string rs}, #{emit_int n}\n` ++ else begin ++ assert (n <= 0xFFF_FFF); ++ let nl = n land 0xFFF and nh = n land 0xFFF_000 in ++ ` {emit_string insn} {emit_string rd}, {emit_string rs}, #{emit_int nh}\n`; ++ if nl <> 0 then ++ ` {emit_string insn} {emit_string rd}, {emit_string rd}, #{emit_int nl}\n` ++ end ++ + (* Adjust sp (up or down) by the given byte amount *) + + let emit_stack_adjustment n = +- let instr = if n < 0 then "sub" else "add" in +- let m = abs n in +- assert (m < 0x1_000_000); +- let ml = m land 0xFFF and mh = m land 0xFFF_000 in +- if mh <> 0 then ` {emit_string instr} sp, sp, #{emit_int mh}\n`; +- if ml <> 0 then ` {emit_string instr} sp, sp, #{emit_int ml}\n`; +- if n <> 0 then cfi_adjust_cfa_offset (-n) ++ if n <> 0 then begin ++ emit_addimm_gen "sp" "sp" n; ++ cfi_adjust_cfa_offset (-n) ++ end + + (* Deallocate the stack frame and reload the return address + before a return or tail call *) +@@ -278,29 +292,11 @@ let output_epilogue env f = + + (* Output add-immediate / sub-immediate / cmp-immediate instructions *) + +-let rec emit_addimm rd rs n = +- if n < 0 then emit_subimm rd rs (-n) +- else if n <= 0xFFF then +- ` add {emit_reg rd}, {emit_reg rs}, #{emit_int n}\n` +- else begin +- assert (n <= 0xFFF_FFF); +- let nl = n land 0xFFF and nh = n land 0xFFF_000 in +- ` add {emit_reg rd}, {emit_reg rs}, #{emit_int nh}\n`; +- if nl <> 0 then +- ` add {emit_reg rd}, {emit_reg rd}, #{emit_int nl}\n` +- end ++let emit_addimm rd rs n = ++ emit_addimm_gen (reg_name rd) (reg_name rs) n + +-and emit_subimm rd rs n = +- if n < 0 then emit_addimm rd rs (-n) +- else if n <= 0xFFF then +- ` sub {emit_reg rd}, {emit_reg rs}, #{emit_int n}\n` +- else begin +- assert (n <= 0xFFF_FFF); +- let nl = n land 0xFFF and nh = n land 0xFFF_000 in +- ` sub {emit_reg rd}, {emit_reg rs}, #{emit_int nh}\n`; +- if nl <> 0 then +- ` sub {emit_reg rd}, {emit_reg rd}, #{emit_int nl}\n` +- end ++let emit_subimm rd rs n = ++ emit_addimm rd rs (-n) + + let emit_cmpimm rs n = + if n >= 0 +@@ -440,9 +436,7 @@ module Size = struct + let addsub_size n = + let m = abs n in + assert (m < 0x1_000_000); +- let ml = m land 0xFFF and mh = m land 0xFFF_000 in +- max 1 ((if mh <> 0 then 1 else 0) + +- (if ml <> 0 then 1 else 0)) ++ if m <= 0xFFF then 1 else if m land 0xFFF = 0 then 1 else 2 + + let stack_adj_size n = + (* see emit_stack_adjustment *) +@@ -451,7 +445,9 @@ module Size = struct + let prologue_size f = + let stk = initial_stack_offset f in + (if stk > 0 then stack_adj_size (-stk) else 0) +- + (if f.fun_frame_required then (if fp then 2 else 1) else 0) ++ + (if f.fun_frame_required ++ then if fp then 1 + addsub_size (stk - 16) else 1 ++ else 0) + + let epilogue_size f = + let stk = initial_stack_offset f in +@@ -491,7 +487,7 @@ module Size = struct + and pre_store = + match memory_chunk, assignment, macosx, addressing_mode with + | (Word_int | Word_val), true, true, Iindexed 0 -> 0 +- | (Word_int | Word_val), true, true, _ -> 1 (* Compute dest address *) ++ | (Word_int | Word_val), true, true, Iindexed n -> addsub_size n (* Compute dest address *) + | (Word_int | Word_val), true, false, _ -> 1 (* Barrier instruction *) + | _ -> 0 + and store = match memory_chunk with Single -> 2 | _ -> 1 in +@@ -553,7 +549,7 @@ module Size = struct + + begin match lbl1 with None -> 0 | Some _ -> 1 end + + begin match lbl2 with None -> 0 | Some _ -> 1 end + | Lswitch jumptbl -> 3 + Array.length jumptbl +- | Lentertrap -> if fp then 1 else 0 ++ | Lentertrap -> if fp then 2 (* over-approximation *) else 0 + | Ladjust_trap_depth _ -> 0 + | Lpushtrap _ -> 3 + | Lpoptrap -> 1 +@@ -694,9 +690,7 @@ let emit_stlr src base addr = + let dest_reg = + match addr with + | Iindexed 0 -> base +- | Iindexed ofs -> +- ` add {emit_reg reg_tmp1}, {emit_reg base}, #{emit_int ofs}\n`; +- reg_tmp1 ++ | Iindexed ofs -> emit_addimm reg_tmp1 base ofs; reg_tmp1 + | Ibased _ -> assert false (* Ibased is not emitted under macOS *) + in + ` stlr {emit_reg src}, [{emit_reg dest_reg}]\n` +@@ -721,7 +715,7 @@ let emit_instr env i = + if n > 0 then begin + emit_stack_adjustment (-n); + if env.f.fun_frame_required && fp then +- ` add x29, sp, #{emit_int (n-16)}\n`; ++ emit_addimm_gen "x29" "sp" (n - 16) + end + | Lop(Imove | Ispill | Ireload) -> + let src = i.arg.(0) and dst = i.res.(0) in +@@ -1080,7 +1074,7 @@ let emit_instr env i = + | Lentertrap -> + if fp then begin + let delta = (frame_size env) - 16 (* return address + frame pointer *) in +- ` add x29, sp, #{emit_int delta}\n` ++ emit_addimm_gen "x29" "sp" delta + end + | Ladjust_trap_depth { delta_traps } -> + (* each trap occupies 16 bytes on the stack *) +@@ -1119,7 +1113,7 @@ let emit_instr_debug env i = + `{emit_label lbl}:\n`; + emit_instr env i; + let sz = Size.instr_size env.f i.desc * 4 in +- ` .ifne (. - {emit_label lbl}) - {emit_int sz}\n`; ++ ` .ifgt (. - {emit_label lbl}) - {emit_int sz}\n`; + ` .error \"Emit.instr_size: instruction length mismatch\"\n`; + ` .endif\n` + +@@ -1130,7 +1124,7 @@ let rec emit_all env lbl_start acc i = + if debug then begin + (* acc measures in units of 32-bit instructions *) + let sz = acc * 4 in +- ` .ifne (. - {emit_label lbl_start}) - {emit_int sz}\n`; ++ ` .ifgt (. - {emit_label lbl_start}) - {emit_int sz}\n`; + ` .error \"Emit.instr_size: instruction length mismatch\"\n`; + ` .endif\n`; + end +-- +2.52.0 + diff --git a/ocaml.spec b/ocaml.spec index 2f5430c..65557d4 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -46,7 +46,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.4.1 -Release: 1%{?dist} +Release: 4%{?dist} Summary: OCaml compiler and programming environment @@ -78,6 +78,12 @@ Source2: ocaml_files.py Patch: 0001-Don-t-add-rpaths-to-libraries.patch Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch +# Fix for arm64 frame pointers +# https://github.com/ocaml/ocaml/issues/14574 +# https://github.com/ocaml/ocaml/pull/14589 +# Upstream 6cda6d8a928ada5dd0f58de229d3cb193cfdff53 +Patch: 0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch + BuildRequires: make BuildRequires: git-core BuildRequires: gcc @@ -463,6 +469,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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) From b015f12145879ed9da0317639500d50b601deedf Mon Sep 17 00:00:00 2001 From: Jerry James Date: Thu, 9 Jul 2026 08:36:23 -0600 Subject: [PATCH 90/91] 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 --- 0001-Don-t-add-rpaths-to-libraries.patch | 2 +- ...-Allow-user-defined-C-compiler-flags.patch | 15 +- ...st-14589-from-xavierleroy-arm64-addi.patch | 207 ------------------ ocaml.spec | 50 ++--- sources | 2 +- 5 files changed, 26 insertions(+), 250 deletions(-) delete mode 100644 0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch diff --git a/0001-Don-t-add-rpaths-to-libraries.patch b/0001-Don-t-add-rpaths-to-libraries.patch index 03c90a8..6bf857a 100644 --- a/0001-Don-t-add-rpaths-to-libraries.patch +++ b/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,7 +1,7 @@ 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/3] Don't add rpaths to libraries. +Subject: [PATCH 1/2] Don't add rpaths to libraries. --- configure.ac | 2 -- diff --git a/0002-configure-Allow-user-defined-C-compiler-flags.patch b/0002-configure-Allow-user-defined-C-compiler-flags.patch index 6a6b5f7..74de99b 100644 --- a/0002-configure-Allow-user-defined-C-compiler-flags.patch +++ b/0002-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,7 +1,7 @@ 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/3] configure: Allow user defined C compiler flags. +Subject: [PATCH 2/2] configure: Allow user defined C compiler flags. --- configure.ac | 6 +++++- @@ -11,18 +11,7 @@ diff --git a/configure.ac b/configure.ac index fb60c7c14c..f6a493ccf5 100644 --- a/configure.ac +++ b/configure.ac -@@ -997,6 +997,10 @@ AS_CASE([$ocaml_cc_vendor], - internal_cflags="$cc_warnings"], - [common_cflags="-O"]) - -+# Allow CFLAGS and LDFLAGS to be added. -+common_cflags="$common_cflags $CFLAGS" -+cclibs="$cclibs $LDFLAGS" -+ - # Enable SSE2 on x86 mingw to avoid using 80-bit registers. - AS_CASE([$target], - [i686-w64-mingw32*], -@@ -2904,7 +2908,7 @@ AC_CONFIG_COMMANDS_PRE([ +@@ -3243,7 +3243,7 @@ AC_CONFIG_COMMANDS_PRE([ [mkexedebugflag="${mkexe_ldflags_prefix}${mkexedebugflag}"]) mkdll_ldflags="" AS_IF([test -n "${LDFLAGS}"], diff --git a/0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch b/0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch deleted file mode 100644 index 887ddcd..0000000 --- a/0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch +++ /dev/null @@ -1,207 +0,0 @@ -From c2923703d02c6389b6c4594541569bf628e706b1 Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Thu, 26 Feb 2026 13:43:07 +0100 -Subject: [PATCH 3/3] Merge pull request #14589 from xavierleroy/arm64-addimm - -Fix arm64 additions with large immediates - -(cherry picked from commit 4fafb9669b9a5c898b2dda0ae851b2a0e6429c43) -(cherry picked from commit 6cda6d8a928ada5dd0f58de229d3cb193cfdff53) ---- - Changes | 6 +++ - asmcomp/arm64/emit.mlp | 84 ++++++++++++++++++++---------------------- - 2 files changed, 45 insertions(+), 45 deletions(-) - -diff --git a/Changes b/Changes -index be999a8cc4..4ad8737bb0 100644 ---- a/Changes -+++ b/Changes -@@ -1,3 +1,9 @@ -+### Bug fixes: -+ -+- #14574, #14577, #14589: Fix wrong assembly code generated for ARM64 -+ with frame pointer support. -+ (Xavier Leroy, review by Vincent Laviron, report by Richard Jones) -+ - OCaml 5.4.1 (17 February 2026) - ------------------------------ - -diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp -index c821310638..3f64eebc05 100644 ---- a/asmcomp/arm64/emit.mlp -+++ b/asmcomp/arm64/emit.mlp -@@ -54,9 +54,11 @@ let emit_label_type lbl ty = - - (* Output a pseudo-register *) - --let emit_reg = function -- {loc = Reg r} -> emit_string (register_name r) -- | _ -> fatal_error "Emit.emit_reg" -+let reg_name = function -+ | {loc = Reg r} -> register_name r -+ | _ -> fatal_error "Emit.reg_name" -+ -+let emit_reg l = emit_string (reg_name l) - - (* Likewise, but with the 32-bit name of the register *) - -@@ -249,16 +251,28 @@ let is_immediate_float bits = - let mant = Int64.logand bits 0xF_FFFF_FFFF_FFFFL in - exp >= -3 && exp <= 4 && Int64.logand mant 0xF_0000_0000_0000L = mant - -+(* Set [rd] to [rs + n]. *) -+ -+let emit_addimm_gen rd rs n = -+ let insn = if n >= 0 then "add" else "sub" in -+ let n = abs n in -+ if n <= 0xFFF then -+ ` {emit_string insn} {emit_string rd}, {emit_string rs}, #{emit_int n}\n` -+ else begin -+ assert (n <= 0xFFF_FFF); -+ let nl = n land 0xFFF and nh = n land 0xFFF_000 in -+ ` {emit_string insn} {emit_string rd}, {emit_string rs}, #{emit_int nh}\n`; -+ if nl <> 0 then -+ ` {emit_string insn} {emit_string rd}, {emit_string rd}, #{emit_int nl}\n` -+ end -+ - (* Adjust sp (up or down) by the given byte amount *) - - let emit_stack_adjustment n = -- let instr = if n < 0 then "sub" else "add" in -- let m = abs n in -- assert (m < 0x1_000_000); -- let ml = m land 0xFFF and mh = m land 0xFFF_000 in -- if mh <> 0 then ` {emit_string instr} sp, sp, #{emit_int mh}\n`; -- if ml <> 0 then ` {emit_string instr} sp, sp, #{emit_int ml}\n`; -- if n <> 0 then cfi_adjust_cfa_offset (-n) -+ if n <> 0 then begin -+ emit_addimm_gen "sp" "sp" n; -+ cfi_adjust_cfa_offset (-n) -+ end - - (* Deallocate the stack frame and reload the return address - before a return or tail call *) -@@ -278,29 +292,11 @@ let output_epilogue env f = - - (* Output add-immediate / sub-immediate / cmp-immediate instructions *) - --let rec emit_addimm rd rs n = -- if n < 0 then emit_subimm rd rs (-n) -- else if n <= 0xFFF then -- ` add {emit_reg rd}, {emit_reg rs}, #{emit_int n}\n` -- else begin -- assert (n <= 0xFFF_FFF); -- let nl = n land 0xFFF and nh = n land 0xFFF_000 in -- ` add {emit_reg rd}, {emit_reg rs}, #{emit_int nh}\n`; -- if nl <> 0 then -- ` add {emit_reg rd}, {emit_reg rd}, #{emit_int nl}\n` -- end -+let emit_addimm rd rs n = -+ emit_addimm_gen (reg_name rd) (reg_name rs) n - --and emit_subimm rd rs n = -- if n < 0 then emit_addimm rd rs (-n) -- else if n <= 0xFFF then -- ` sub {emit_reg rd}, {emit_reg rs}, #{emit_int n}\n` -- else begin -- assert (n <= 0xFFF_FFF); -- let nl = n land 0xFFF and nh = n land 0xFFF_000 in -- ` sub {emit_reg rd}, {emit_reg rs}, #{emit_int nh}\n`; -- if nl <> 0 then -- ` sub {emit_reg rd}, {emit_reg rd}, #{emit_int nl}\n` -- end -+let emit_subimm rd rs n = -+ emit_addimm rd rs (-n) - - let emit_cmpimm rs n = - if n >= 0 -@@ -440,9 +436,7 @@ module Size = struct - let addsub_size n = - let m = abs n in - assert (m < 0x1_000_000); -- let ml = m land 0xFFF and mh = m land 0xFFF_000 in -- max 1 ((if mh <> 0 then 1 else 0) + -- (if ml <> 0 then 1 else 0)) -+ if m <= 0xFFF then 1 else if m land 0xFFF = 0 then 1 else 2 - - let stack_adj_size n = - (* see emit_stack_adjustment *) -@@ -451,7 +445,9 @@ module Size = struct - let prologue_size f = - let stk = initial_stack_offset f in - (if stk > 0 then stack_adj_size (-stk) else 0) -- + (if f.fun_frame_required then (if fp then 2 else 1) else 0) -+ + (if f.fun_frame_required -+ then if fp then 1 + addsub_size (stk - 16) else 1 -+ else 0) - - let epilogue_size f = - let stk = initial_stack_offset f in -@@ -491,7 +487,7 @@ module Size = struct - and pre_store = - match memory_chunk, assignment, macosx, addressing_mode with - | (Word_int | Word_val), true, true, Iindexed 0 -> 0 -- | (Word_int | Word_val), true, true, _ -> 1 (* Compute dest address *) -+ | (Word_int | Word_val), true, true, Iindexed n -> addsub_size n (* Compute dest address *) - | (Word_int | Word_val), true, false, _ -> 1 (* Barrier instruction *) - | _ -> 0 - and store = match memory_chunk with Single -> 2 | _ -> 1 in -@@ -553,7 +549,7 @@ module Size = struct - + begin match lbl1 with None -> 0 | Some _ -> 1 end - + begin match lbl2 with None -> 0 | Some _ -> 1 end - | Lswitch jumptbl -> 3 + Array.length jumptbl -- | Lentertrap -> if fp then 1 else 0 -+ | Lentertrap -> if fp then 2 (* over-approximation *) else 0 - | Ladjust_trap_depth _ -> 0 - | Lpushtrap _ -> 3 - | Lpoptrap -> 1 -@@ -694,9 +690,7 @@ let emit_stlr src base addr = - let dest_reg = - match addr with - | Iindexed 0 -> base -- | Iindexed ofs -> -- ` add {emit_reg reg_tmp1}, {emit_reg base}, #{emit_int ofs}\n`; -- reg_tmp1 -+ | Iindexed ofs -> emit_addimm reg_tmp1 base ofs; reg_tmp1 - | Ibased _ -> assert false (* Ibased is not emitted under macOS *) - in - ` stlr {emit_reg src}, [{emit_reg dest_reg}]\n` -@@ -721,7 +715,7 @@ let emit_instr env i = - if n > 0 then begin - emit_stack_adjustment (-n); - if env.f.fun_frame_required && fp then -- ` add x29, sp, #{emit_int (n-16)}\n`; -+ emit_addimm_gen "x29" "sp" (n - 16) - end - | Lop(Imove | Ispill | Ireload) -> - let src = i.arg.(0) and dst = i.res.(0) in -@@ -1080,7 +1074,7 @@ let emit_instr env i = - | Lentertrap -> - if fp then begin - let delta = (frame_size env) - 16 (* return address + frame pointer *) in -- ` add x29, sp, #{emit_int delta}\n` -+ emit_addimm_gen "x29" "sp" delta - end - | Ladjust_trap_depth { delta_traps } -> - (* each trap occupies 16 bytes on the stack *) -@@ -1119,7 +1113,7 @@ let emit_instr_debug env i = - `{emit_label lbl}:\n`; - emit_instr env i; - let sz = Size.instr_size env.f i.desc * 4 in -- ` .ifne (. - {emit_label lbl}) - {emit_int sz}\n`; -+ ` .ifgt (. - {emit_label lbl}) - {emit_int sz}\n`; - ` .error \"Emit.instr_size: instruction length mismatch\"\n`; - ` .endif\n` - -@@ -1130,7 +1124,7 @@ let rec emit_all env lbl_start acc i = - if debug then begin - (* acc measures in units of 32-bit instructions *) - let sz = acc * 4 in -- ` .ifne (. - {emit_label lbl_start}) - {emit_int sz}\n`; -+ ` .ifgt (. - {emit_label lbl_start}) - {emit_int sz}\n`; - ` .error \"Emit.instr_size: instruction length mismatch\"\n`; - ` .endif\n`; - end --- -2.52.0 - diff --git a/ocaml.spec b/ocaml.spec index 65557d4..eabeb25 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -1,13 +1,6 @@ # Don't add -Wl,-dT, %undefine _package_note_flags -# OCaml 5.1 broke building with LTO. A file prims.c is generated with -# primitive function declarations, all with "void" for their parameter -# list. This does not match the real definitions, leading to lots of -# -Wlto-type-mismatch warnings. These change the output of the tests, -# leading to many failed tests. This is still a problem in 5.3. -%global _lto_cflags %{nil} - # OCaml has a bytecode backend that works on anything with a C # compiler, and a native code backend available on a subset of # architectures. A further subset of architectures support native @@ -32,7 +25,7 @@ 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 aarch64 %{power64} riscv64 s390x x86_64 +%global test_arches %{arm64} %{power64} %{riscv64} s390x %{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 @@ -45,8 +38,8 @@ ExcludeArch: %{ix86} %global rcver %{nil} Name: ocaml -Version: 5.4.1 -Release: 4%{?dist} +Version: 5.5.0 +Release: 1%{?dist} Summary: OCaml compiler and programming environment @@ -78,26 +71,17 @@ Source2: ocaml_files.py Patch: 0001-Don-t-add-rpaths-to-libraries.patch Patch: 0002-configure-Allow-user-defined-C-compiler-flags.patch -# Fix for arm64 frame pointers -# https://github.com/ocaml/ocaml/issues/14574 -# https://github.com/ocaml/ocaml/pull/14589 -# Upstream 6cda6d8a928ada5dd0f58de229d3cb193cfdff53 -Patch: 0003-Merge-pull-request-14589-from-xavierleroy-arm64-addi.patch - BuildRequires: make BuildRequires: git-core BuildRequires: gcc BuildRequires: autoconf BuildRequires: gawk -BuildRequires: hardlink BuildRequires: perl-interpreter -BuildRequires: util-linux -BuildRequires: /usr/bin/annocheck +BuildRequires: annobin-annocheck BuildRequires: pkgconfig(libzstd) # Documentation requirements BuildRequires: asciidoc -BuildRequires: python3-pygments # ocamlopt runs gcc to link binaries. Because Fedora includes # hardening flags automatically, redhat-rpm-config is also required. @@ -142,7 +126,6 @@ and a comprehensive library. # 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 @@ -313,7 +296,10 @@ make -j1 tests ||: %install %make_install -perl -pi -e "s|^$RPM_BUILD_ROOT||" $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf + +# 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 echo %{version} > $RPM_BUILD_ROOT%{_libdir}/ocaml/fedora-ocaml-release @@ -326,9 +312,6 @@ 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 -# Link, rather than copy, identical binaries -hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs - %files %license LICENSE @@ -371,7 +354,6 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %endif %{_libdir}/ocaml/expunge -%{_libdir}/ocaml/ld.conf %{_libdir}/ocaml/Makefile.config %{_libdir}/ocaml/*.a @@ -379,11 +361,9 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %{_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/libcamlrun_shared.so %{_libdir}/ocaml/{dynlink,runtime_events,str,threads,unix}/*.mli %if %{native_compiler} @@ -404,12 +384,18 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %doc README.html 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/*.cmo %{_libdir}/ocaml/*.cmi %{_libdir}/ocaml/*.cma +%{_libdir}/ocaml/ld.conf %{_libdir}/ocaml/stublibs %dir %{_libdir}/ocaml/dynlink %{_libdir}/ocaml/dynlink/META @@ -469,6 +455,14 @@ hardlink -t $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs %changelog +* 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 diff --git a/sources b/sources index d5a609d..7c0afd0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (ocaml-5.4.1.tar.gz) = c44bc429bee4a263b107e60a4ab3b0c9c082ba2d784f63704130551676ce5624061ae1aa280688e3222d9a522555b3cb749eef784ab2145d71c0f19cac773383 +SHA512 (ocaml-5.5.0.tar.gz) = bf13c18cd1fc7b2e5e9623024ea8623710f646ff2fbc0f59dab70e4d4318ed8623bdcc3ec59ce37af07af2b767f520dea23fb474c26297b3e858b6c8e080b4e6 From cba5f7abbea9ebc52cd0bbc5cf243f7147a79166 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 16 Jul 2026 09:52:03 +0000 Subject: [PATCH 91/91] Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild --- ocaml.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ocaml.spec b/ocaml.spec index eabeb25..3b39d37 100644 --- a/ocaml.spec +++ b/ocaml.spec @@ -39,7 +39,7 @@ ExcludeArch: %{ix86} Name: ocaml Version: 5.5.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: OCaml compiler and programming environment @@ -455,6 +455,9 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_rpmconfigdir}/redhat %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