Fix --flag=arg patch (thanks: Anton Lavrik, Ignas Vyšniauskas).

This commit is contained in:
Richard W.M. Jones 2014-04-01 11:36:02 +01:00
parent 073715bf7d
commit 0db310c916
14 changed files with 189 additions and 152 deletions

View File

@ -1,7 +1,7 @@
From 07839dfc746ccee318601b9668aa094d4465bc6e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 7 Jun 2012 16:00:28 +0100
Subject: [PATCH 01/11] Add .gitignore file to ignore generated files.
Subject: [PATCH 01/12] Add .gitignore file to ignore generated files.
---
.gitignore | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -1,7 +1,7 @@
From 7756582741dc56070c03629a3b4640147723beda Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 7 Jun 2012 15:36:16 +0100
Subject: [PATCH 02/11] Ensure empty compilerlibs/ directory is created by git.
Subject: [PATCH 02/12] Ensure empty compilerlibs/ directory is created by git.
This directory exists in the OCaml tarball, but is empty. As a
result, git ignores it unless we put a dummy file in it.

View File

@ -1,7 +1,7 @@
From a6d87cd4bc62d3987835c1ac844f35cc06804294 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:40:36 +0100
Subject: [PATCH 03/11] ocamlbyteinfo, ocamlplugininfo: Useful utilities from
Subject: [PATCH 03/12] ocamlbyteinfo, ocamlplugininfo: Useful utilities from
Debian, sent upstream.
See:

View File

@ -1,7 +1,7 @@
From c3a733c10827896a6e3c217b383e874df303d50b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:43:34 +0100
Subject: [PATCH 04/11] Don't add rpaths to libraries.
Subject: [PATCH 04/12] Don't add rpaths to libraries.
---
tools/Makefile.shared | 3 ---

View File

@ -1,7 +1,7 @@
From 459e9550f174e11176a2ece013fc4dd2b08a06bb 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 05/11] configure: Allow user defined C compiler flags.
Subject: [PATCH 05/12] configure: Allow user defined C compiler flags.
---
configure | 4 ++++

View File

@ -1,7 +1,7 @@
From a85437a0d2ffdf7a340d379789500eb583ae4708 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:47:07 +0100
Subject: [PATCH 06/11] Add support for ppc64.
Subject: [PATCH 06/12] Add support for ppc64.
Note (1): This patch was rejected upstream because they don't have
appropriate hardware for testing.

View File

@ -1,7 +1,7 @@
From 761242718c3a7513d3b93ca96d24d1f61a4126f0 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 13 Sep 2013 21:29:58 +0100
Subject: [PATCH 07/11] yacc: Use mkstemp instead of mktemp.
Subject: [PATCH 07/12] yacc: Use mkstemp instead of mktemp.
---
yacc/main.c | 2 +-

View File

@ -1,7 +1,7 @@
From 10d852d542f4ecdc5efc5afbae2d42167df4539c Mon Sep 17 00:00:00 2001
From a1297100a7898223fd9cdf3d37c4136376ee8f88 Mon Sep 17 00:00:00 2001
From: Xavier Leroy <xavier.leroy@inria.fr>
Date: Thu, 18 Jul 2013 16:09:20 +0000
Subject: [PATCH 09/11] Port to the ARM 64-bits (AArch64) architecture
Subject: [PATCH 08/12] Port to the ARM 64-bits (AArch64) architecture
(experimental). Merge of branch branches/arm64.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13909 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

View File

@ -1,7 +1,7 @@
From d36a95566c96d93280bf1439acc65ce7d4d159d0 Mon Sep 17 00:00:00 2001
From 26114ba365c1ef63d9605efc719f6c220ad624eb Mon Sep 17 00:00:00 2001
From: Xavier Leroy <xavier.leroy@inria.fr>
Date: Thu, 18 Jul 2013 16:07:25 +0000
Subject: [PATCH 10/11] Updated with latest versions from FSF.
Subject: [PATCH 09/12] Updated with latest versions from FSF.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13907 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
(cherry picked from commit 24bb4caeb35e49126aa3a4c0101a412db1091213)

View File

@ -0,0 +1,38 @@
From 0ebe44d283e56056fec1691bdc052c92d70c892d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 30 Dec 2013 20:32:03 +0000
Subject: [PATCH 10/12] Disable ocamldoc and camlp4opt (aarch64 only)
---
Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 10c80d2..e0a7d9e 100644
--- a/Makefile
+++ b/Makefile
@@ -686,8 +686,8 @@ alldepend::
ocamldoc: ocamlc ocamlyacc ocamllex otherlibraries
cd ocamldoc && $(MAKE) all
-ocamldoc.opt: ocamlc.opt ocamlyacc ocamllex
- cd ocamldoc && $(MAKE) opt.opt
+#ocamldoc.opt: ocamlc.opt ocamlyacc ocamllex
+# cd ocamldoc && $(MAKE) opt.opt
partialclean::
cd ocamldoc && $(MAKE) clean
@@ -734,8 +734,8 @@ alldepend::
camlp4out: ocamlc ocamlbuild.byte
./build/camlp4-byte-only.sh
-camlp4opt: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot ocamlbuild.native
- ./build/camlp4-native-only.sh
+#camlp4opt: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot ocamlbuild.native
+# ./build/camlp4-native-only.sh
# Ocamlbuild
#ifeq ($(OCAMLBUILD_NOBOOT),"yes")
--
1.8.5.3

View File

@ -1,63 +1,36 @@
From 33962967111fbed55e93260b12cd65e372a0958a Mon Sep 17 00:00:00 2001
From 6a342793f40250c78931afa32961646f20bc5ba4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 9 Nov 2013 09:11:30 +0000
Subject: [PATCH 08/11] stdlib: arg: Allow flags such as --flag=arg as well as
--flag arg.
Date: Tue, 1 Apr 2014 11:17:07 +0100
Subject: [PATCH 11/12] arg: Add no_arg and get_arg helper functions.
Fix for the following issue:
http://caml.inria.fr/mantis/view.php?id=5197
The no_arg function in this patch is a no-op. It will do something
useful in the followups.
The get_arg function simple checks the next position on the command
line exists and returns that argument or raises a Arg.Missing.
This patch should introduce no functional change, it is simply code
refactoring.
In particular, this should not change the treatment of Arg.current
(see: http://caml.inria.fr/mantis/view.php?id=5197#c11147)
---
stdlib/arg.ml | 85 ++++++++++++++++++++++++++++++++++------------------------
stdlib/arg.mli | 3 ++-
2 files changed, 52 insertions(+), 36 deletions(-)
stdlib/arg.ml | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/stdlib/arg.ml b/stdlib/arg.ml
index 8b64236..d94b75f 100644
index 8b64236..c8b3d44 100644
--- a/stdlib/arg.ml
+++ b/stdlib/arg.ml
@@ -55,6 +55,12 @@ let rec assoc3 x l =
| _ :: t -> assoc3 x t
;;
+let split s =
+ let i = String.index s '=' in
+ let len = String.length s in
+ String.sub s 0 i, String.sub s (i+1) (len-(i+1))
+;;
+
let make_symlist prefix sep suffix l =
match l with
| [] -> "<none>"
@@ -130,73 +136,82 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg =
while !current < l do
let s = argv.(!current) in
if String.length s >= 1 && String.get s 0 = '-' then begin
- let action =
- try assoc3 s !speclist
- with Not_found -> stop (Unknown s)
+ let action, follow =
+ try assoc3 s !speclist, None
+ with Not_found ->
+ try
+ let keyword, arg = split s in
+ assoc3 keyword !speclist, Some arg
+ with Not_found -> stop (Unknown s)
+ in
+ let no_arg () =
+ match follow with
+ | None -> ()
+ | Some arg -> stop (Wrong (s, arg, "no argument"))
+ in
+ let get_arg () =
+ match follow with
+ | None ->
+ if !current + 1 < l then begin
+ incr current;
+ argv.(!current)
+ end
+ else stop (Missing s)
+ | Some arg -> arg
@@ -134,56 +134,62 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg =
try assoc3 s !speclist
with Not_found -> stop (Unknown s)
in
+ let no_arg () = () in
+ let get_arg () =
+ if !current + 1 < l then argv.(!current + 1)
+ else stop (Missing s)
+ in
begin try
let rec treat_action = function
- | Unit f -> f ();
@ -70,42 +43,43 @@ index 8b64236..d94b75f 100644
with Invalid_argument "bool_of_string" ->
raise (Stop (Wrong (s, arg, "a boolean")))
end;
- incr current;
incr current;
- | Set r -> r := true;
- | Clear r -> r := false;
- | String f when !current + 1 < l ->
- f argv.(!current + 1);
- incr current;
- | Symbol (symb, f) when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Set r -> no_arg (); r := true;
+ | Clear r -> no_arg (); r := false;
+ | String f ->
+ f (get_arg ());
+ let arg = get_arg () in
+ f arg;
incr current;
- | Symbol (symb, f) when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Symbol (symb, f) ->
+ let arg = get_arg () in
if List.mem arg symb then begin
- f argv.(!current + 1);
- incr current;
+ f arg;
incr current;
end else begin
raise (Stop (Wrong (s, arg, "one of: "
^ (make_symlist "" " " "" symb))))
end
- | Set_string r when !current + 1 < l ->
- r := argv.(!current + 1);
- incr current;
- | Int f when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Set_string r ->
+ r := get_arg ();
incr current;
- | Int f when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Int f ->
+ let arg = get_arg () in
begin try f (int_of_string arg)
with Failure "int_of_string" ->
raise (Stop (Wrong (s, arg, "an integer")))
end;
- incr current;
incr current;
- | Set_int r when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Set_int r ->
@ -114,7 +88,7 @@ index 8b64236..d94b75f 100644
with Failure "int_of_string" ->
raise (Stop (Wrong (s, arg, "an integer")))
end;
- incr current;
incr current;
- | Float f when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Float f ->
@ -123,7 +97,7 @@ index 8b64236..d94b75f 100644
with Failure "float_of_string" ->
raise (Stop (Wrong (s, arg, "a float")))
end;
- incr current;
incr current;
- | Set_float r when !current + 1 < l ->
- let arg = argv.(!current + 1) in
+ | Set_float r ->
@ -131,35 +105,14 @@ index 8b64236..d94b75f 100644
begin try r := (float_of_string arg);
with Failure "float_of_string" ->
raise (Stop (Wrong (s, arg, "a float")))
end;
- incr current;
| Tuple specs ->
List.iter treat_action specs;
| Rest f ->
while !current < l - 1 do
- f argv.(!current + 1);
- incr current;
- done;
@@ -196,7 +202,6 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg =
f argv.(!current + 1);
incr current;
done;
- | _ -> raise (Stop (Missing s))
+ f (get_arg ());
+ done
in
treat_action action
with Bad m -> stop (Message m);
diff --git a/stdlib/arg.mli b/stdlib/arg.mli
index 869d030..b8c6f11 100644
--- a/stdlib/arg.mli
+++ b/stdlib/arg.mli
@@ -25,7 +25,8 @@
[Unit], [Set] and [Clear] keywords take no argument. A [Rest]
keyword takes the remaining of the command line as arguments.
Every other keyword takes the following word on the command line
- as argument.
+ as argument. For compatibility with GNU getopt_long, [keyword=arg]
+ is also allowed.
Arguments not preceded by a keyword are called anonymous arguments.
Examples ([cmd] is assumed to be the command name):
--
1.8.5.3

View File

@ -1,41 +0,0 @@
From 260b93c0dda0075112623fc2533c07406d3c8278 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 24 Mar 2014 05:50:28 -0500
Subject: [PATCH 11/11] arm64: Align code and data to 8 bytes.
Insufficient alignment seems to be the cause of relocation errors when
linking large native code OCaml programs:
(.text+0xc): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `camlOdoc_type' defined in .data section in odoc_type.o
../stdlib/stdlib.a(listLabels.o): In function `camlListLabels__entry':
(.text+0x10): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `camlListLabels' defined in .data section in ../stdlib/stdlib.a(listLabels.o)
PR#6283 http://caml.inria.fr/mantis/view.php?id=6283
---
asmcomp/arm64/emit.mlp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp
index fc9649c..4e7c4b0 100644
--- a/asmcomp/arm64/emit.mlp
+++ b/asmcomp/arm64/emit.mlp
@@ -651,7 +651,7 @@ let fundecl fundecl =
call_gc_sites := [];
bound_error_sites := [];
` .text\n`;
- ` .align 2\n`;
+ ` .align 3\n`;
` .globl {emit_symbol fundecl.fun_name}\n`;
` .type {emit_symbol fundecl.fun_name}, %function\n`;
`{emit_symbol fundecl.fun_name}:\n`;
@@ -692,6 +692,7 @@ let emit_item = function
let data l =
` .data\n`;
+ ` .align 3\n`;
List.iter emit_item l
(* Beginning / end of an assembly file *)
--
1.8.5.3

View File

@ -0,0 +1,82 @@
From 0d0204c395b4015804d12bcd871b74dd0cb38bdb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 1 Apr 2014 11:21:40 +0100
Subject: [PATCH 12/12] arg: Allow flags such as --flag=arg as well as --flag
arg.
Allow flags to be followed directly by their argument, separated by an '='
sign. This is consistent with what GNU getopt_long and many other
command line parsing libraries allow.
Fix for the following issue:
http://caml.inria.fr/mantis/view.php?id=5197
---
stdlib/arg.ml | 28 ++++++++++++++++++++++------
stdlib/arg.mli | 3 ++-
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/stdlib/arg.ml b/stdlib/arg.ml
index c8b3d44..766de5f 100644
--- a/stdlib/arg.ml
+++ b/stdlib/arg.ml
@@ -55,6 +55,12 @@ let rec assoc3 x l =
| _ :: t -> assoc3 x t
;;
+let split s =
+ let i = String.index s '=' in
+ let len = String.length s in
+ String.sub s 0 i, String.sub s (i+1) (len-(i+1))
+;;
+
let make_symlist prefix sep suffix l =
match l with
| [] -> "<none>"
@@ -130,14 +136,24 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg =
while !current < l do
let s = argv.(!current) in
if String.length s >= 1 && String.get s 0 = '-' then begin
- let action =
- try assoc3 s !speclist
- with Not_found -> stop (Unknown s)
+ let action, follow =
+ try assoc3 s !speclist, None
+ with Not_found ->
+ try
+ let keyword, arg = split s in
+ assoc3 keyword !speclist, Some arg
+ with Not_found -> stop (Unknown s)
in
- let no_arg () = () in
+ let no_arg () =
+ match follow with
+ | None -> ()
+ | Some arg -> stop (Wrong (s, arg, "no argument")) in
let get_arg () =
- if !current + 1 < l then argv.(!current + 1)
- else stop (Missing s)
+ match follow with
+ | None ->
+ if !current + 1 < l then argv.(!current + 1)
+ else stop (Missing s)
+ | Some arg -> arg
in
begin try
let rec treat_action = function
diff --git a/stdlib/arg.mli b/stdlib/arg.mli
index 869d030..b8c6f11 100644
--- a/stdlib/arg.mli
+++ b/stdlib/arg.mli
@@ -25,7 +25,8 @@
[Unit], [Set] and [Clear] keywords take no argument. A [Rest]
keyword takes the remaining of the command line as arguments.
Every other keyword takes the following word on the command line
- as argument.
+ as argument. For compatibility with GNU getopt_long, [keyword=arg]
+ is also allowed.
Arguments not preceded by a keyword are called anonymous arguments.
Examples ([cmd] is assumed to be the command name):
--
1.8.5.3

View File

@ -1,6 +1,6 @@
Name: ocaml
Version: 4.01.0
Release: 10%{?dist}
Release: 11%{?dist}
Summary: OCaml compiler and programming environment
@ -34,13 +34,14 @@ Patch0005: 0005-configure-Allow-user-defined-C-compiler-flags.patch
Patch0006: 0006-Add-support-for-ppc64.patch
Patch0007: 0007-yacc-Use-mkstemp-instead-of-mktemp.patch
# NON-upstream patch to allow '--flag=arg' as an alternative to '--flag arg'.
Patch0008: 0008-stdlib-arg-Allow-flags-such-as-flag-arg-as-well-as-f.patch
# Aarch64 patches.
Patch0009: 0009-Port-to-the-ARM-64-bits-AArch64-architecture-experim.patch
Patch0010: 0010-Updated-with-latest-versions-from-FSF.patch
Patch0011: 0011-arm64-Align-code-and-data-to-8-bytes.patch
Patch0008: 0008-Port-to-the-ARM-64-bits-AArch64-architecture-experim.patch
Patch0009: 0009-Updated-with-latest-versions-from-FSF.patch
Patch0010: 0010-Disable-ocamldoc-and-camlp4opt-aarch64-only.patch
# NON-upstream patch to allow '--flag=arg' as an alternative to '--flag arg'.
Patch0011: 0011-arg-Add-no_arg-and-get_arg-helper-functions.patch
Patch0012: 0012-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch
BuildRequires: ncurses-devel
BuildRequires: gdbm-devel
@ -255,12 +256,13 @@ git am %{_sourcedir}/0004-Don-t-add-rpaths-to-libraries.patch </dev/null
git am %{_sourcedir}/0005-configure-Allow-user-defined-C-compiler-flags.patch </dev/null
git am %{_sourcedir}/0006-Add-support-for-ppc64.patch </dev/null
git am %{_sourcedir}/0007-yacc-Use-mkstemp-instead-of-mktemp.patch </dev/null
git am %{_sourcedir}/0008-stdlib-arg-Allow-flags-such-as-flag-arg-as-well-as-f.patch </dev/null
%ifarch aarch64
git am %{_sourcedir}/0009-Port-to-the-ARM-64-bits-AArch64-architecture-experim.patch </dev/null
git am %{_sourcedir}/0010-Updated-with-latest-versions-from-FSF.patch </dev/null
git am %{_sourcedir}/0011-arm64-Align-code-and-data-to-8-bytes.patch </dev/null
git am %{_sourcedir}/0008-Port-to-the-ARM-64-bits-AArch64-architecture-experim.patch
git am %{_sourcedir}/0009-Updated-with-latest-versions-from-FSF.patch
git am %{_sourcedir}/0010-Disable-ocamldoc-and-camlp4opt-aarch64-only.patch
%endif
git am %{_sourcedir}/0011-arg-Add-no_arg-and-get_arg-helper-functions.patch
git am %{_sourcedir}/0012-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch
%build
@ -557,6 +559,9 @@ fi
%changelog
* Tue Apr 1 2014 Richard W.M. Jones <rjones@redhat.com> - 4.01.0-11
- Fix --flag=arg patch (thanks: Anton Lavrik, Ignas Vyšniauskas).
* Mon Mar 24 2014 Richard W.M. Jones <rjones@redhat.com> - 4.01.0-10
- Include a fix for aarch64 relocation problems
http://caml.inria.fr/mantis/view.php?id=6283