Add upstream patch added after 5.1.0

This commit is contained in:
Richard W.M. Jones 2023-10-05 09:58:44 +01:00
parent a433439c10
commit c37874e266
6 changed files with 213 additions and 33 deletions

View File

@ -0,0 +1,176 @@
From 4c03e721b4c53240a9091790acb401b27e72dce0 Mon Sep 17 00:00:00 2001
From: Florian Angeletti <florian.angeletti@inria.fr>
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{Ng<LzMW^BN^$HKIxZ024ql%Br7=?mi$BbncCYl%-WMQ
z3~cMYn6aH>71+*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*?E<!}eR~=8rqBPyDggk+ryT$Q
delta 100
zcmdn`Rebwb@rD-07N!>F7M3lnT~@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

View File

@ -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" <rjones@redhat.com>
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"],

View File

@ -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" <rjones@redhat.com>
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],

View File

@ -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 <miod@tarides.com>
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):

View File

@ -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 <fabrice@tarides.com>
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

View File

@ -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 <rjones@redhat.com> - 5.1.0-2
- Add upstream patch added after 5.1.0
* Wed Oct 4 2023 Jerry James <loganjerry@gmail.com> - 5.1.0-1
- Version 5.1.0
- Add LicenseRef-Fedora-Public-Domain to the runtime License field