From fae014b559845499b76a14511da8ff2363c7eb75 Mon Sep 17 00:00:00 2001 From: pad Date: Fri, 19 Apr 2024 13:49:20 +0200 Subject: [PATCH 1/4] Use stdcompat so we can compile with 3.10.0 test plan: wait for green CI checks --- .github/workflows/build-and-test.jsonnet | 2 +- .github/workflows/build-and-test.yml | 2 +- bootstrap-mk.sh | 6 +++++- changes.txt | 6 +++++- lib_core/commons/common2.ml | 1 + xix.opam | 26 ++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 xix.opam diff --git a/.github/workflows/build-and-test.jsonnet b/.github/workflows/build-and-test.jsonnet index 70ea5301..61c79f03 100644 --- a/.github/workflows/build-and-test.jsonnet +++ b/.github/workflows/build-and-test.jsonnet @@ -42,7 +42,7 @@ local job = { { name: 'Install dependencies', run: ||| - echo No dependencies! This is xix! It does not need anything! + opam install --deps-only . |||, }, { diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b8c66755..3c8fde1d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,7 +9,7 @@ jobs: ocaml-compiler: ${{ matrix.ocaml-compiler }} - name: Install dependencies run: | - echo No dependencies! This is xix! It does not need anything! + opam install --deps-only . - name: Build mk/rc run: | eval $(opam env) diff --git a/bootstrap-mk.sh b/bootstrap-mk.sh index bd7874c4..e9a324ab 100755 --- a/bootstrap-mk.sh +++ b/bootstrap-mk.sh @@ -6,6 +6,7 @@ # # Note that right now to boostrap Xix we still need: # - OCaml (which itself requires to bootstrap ocamllex, ocamlyacc and C) +# - the ocamlfind tool and stdcompat library # - a C compiler # - /bin/sh # @@ -20,8 +21,11 @@ set -e # for showing the executed commands (verbose) set -x +# Limit to just stdcompat! This is Xix! +EXTERNAL_LIB=`ocamlfind query stdcompat` + #TODO? -bin-annot -absname -dtypes -g -OCAMLCFLAGS= +OCAMLCFLAGS="-I $EXTERNAL_LIB" #TODO? for windows under cygwin might need -custom EXTRALINKFLAGS= diff --git a/changes.txt b/changes.txt index 1ecf28a4..842c8e34 100644 --- a/changes.txt +++ b/changes.txt @@ -1,9 +1,13 @@ # -*- org -*- -* 0.13 (Q2 2024) () +* 0.13 (Q2 2024) (GHA and semgrep checks (devops)) # resume after long hiatus (2019-2023) due to our move to Italy, # the birth of Nathalie, and especially my work for Semgrep. +** internals +Started to use stdcompat for backward compatibility with +old versions of OCaml. + ** devops Github actions (GHA) checks to make sure xix compiles. At least it compiles with 4.02.1 (use of |> so harder to compile diff --git a/lib_core/commons/common2.ml b/lib_core/commons/common2.ml index ef4d8ad5..175f5555 100644 --- a/lib_core/commons/common2.ml +++ b/lib_core/commons/common2.ml @@ -1,3 +1,4 @@ +open Stdcompat let rec join_gen a = function | [] -> [] diff --git a/xix.opam b/xix.opam new file mode 100644 index 00000000..baa6a468 --- /dev/null +++ b/xix.opam @@ -0,0 +1,26 @@ +opam-version: "2.0" +version: "0.13" +synopsis: + "Xix is Xix" +description: """ +Xix is Xix + +For more information see https://github.com/aryx/xix +""" +maintainer: ["Yoann Padioleau "] +authors: ["Yoann Padioleau "] +license: "LGPL-2.1" +homepage: "https://github.com/aryx/xix" +bug-reports: "https://github.com/aryx/xix/issues" +depends: [ + "ocaml" {>= "3.10.0"} + # Do not depend on anything except those 2! Xix should limit + # its external dependencies as much as possible, so it + # can boostrap itself more easily. + "stdcompat" + "ocamlfind" +] +build: [ + "echo todo" +] +dev-repo: "git+https://github.com/aryx/xix.git" From eb4a150e878fea1bc8b4930585c8051025b2ea5d Mon Sep 17 00:00:00 2001 From: pad Date: Fri, 19 Apr 2024 19:02:33 +0200 Subject: [PATCH 2/4] fix code to use stdcompat --- .github/workflows/build-and-test.jsonnet | 7 +++++-- .github/workflows/build-and-test.yml | 1 + bootstrap-mk.sh | 2 +- lib_core/commons/IO.ml | 1 + lib_core/commons/IO.mli | 1 + lib_core/commons/common.ml | 3 ++- lib_core/commons/common.mli | 2 +- lib_core/commons/ocaml.ml | 1 + mk/env.ml | 1 + mk/eval.ml | 1 + mk/graph.ml | 1 + mk/main.ml | 1 + mk/outofdate.ml | 1 + mk/parse.ml | 1 + mk/parser.mly | 1 + mk/percent.ml | 1 + mk/scheduler.ml | 1 + mk/shell.ml | 1 + mk/shellenv.ml | 1 + shell/compile.ml | 1 + shell/interpreter.ml | 1 + shell/main.ml | 1 + shell/op_process.ml | 1 + shell/parse.ml | 1 + shell/parser.mly | 1 + shell/process.ml | 1 + shell/runtime.ml | 1 + 27 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.jsonnet b/.github/workflows/build-and-test.jsonnet index 61c79f03..db283eda 100644 --- a/.github/workflows/build-and-test.jsonnet +++ b/.github/workflows/build-and-test.jsonnet @@ -22,11 +22,14 @@ local job = { //TODO: 'windows-latest' ], 'ocaml-compiler': [ - // Old version with |> builtin but ideally we would like even before + // Version that I ported ocamlrun to plan9 (need stdcompat + // so we can use |> and bytes type without issues) + '3.10.0', + // Old version with |> builtin '4.02.1', // first version with valid ocamlformat '4.04.1', - //TODO: 3.10.0, but pb with |> + //TODO: Ideally 4.14.1 and ocaml latest (5.2.0) ], } }, diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3c8fde1d..a44d9c8b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -20,6 +20,7 @@ jobs: strategy: matrix: ocaml-compiler: + - 3.10.0 - 4.02.1 - 4.04.1 os: diff --git a/bootstrap-mk.sh b/bootstrap-mk.sh index e9a324ab..fe4f9a5e 100755 --- a/bootstrap-mk.sh +++ b/bootstrap-mk.sh @@ -28,7 +28,7 @@ EXTERNAL_LIB=`ocamlfind query stdcompat` OCAMLCFLAGS="-I $EXTERNAL_LIB" #TODO? for windows under cygwin might need -custom -EXTRALINKFLAGS= +EXTRALINKFLAGS="-I $EXTERNAL_LIB stdcompat.cma" TOP=`pwd` diff --git a/lib_core/commons/IO.ml b/lib_core/commons/IO.ml index f3e9732f..51d18ba9 100644 --- a/lib_core/commons/IO.ml +++ b/lib_core/commons/IO.ml @@ -16,6 +16,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) +open Stdcompat (* for bytes *) (*****************************************************************************) (* Prelude *) diff --git a/lib_core/commons/IO.mli b/lib_core/commons/IO.mli index 0db9d387..7d0b86e1 100644 --- a/lib_core/commons/IO.mli +++ b/lib_core/commons/IO.mli @@ -17,6 +17,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *) +open Stdcompat (* for bytes type *) (** High-order abstract I/O. diff --git a/lib_core/commons/common.ml b/lib_core/commons/common.ml index ca4dfb98..ab48adf2 100644 --- a/lib_core/commons/common.ml +++ b/lib_core/commons/common.ml @@ -1,9 +1,10 @@ (* Copyright 2015, 2016, 2017 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) type byte = char -type bytes = string (* builtin since OCaml 4.02 (bytes are mutable strings) *) +(* type bytes = string *) type filename = string type dirname = string diff --git a/lib_core/commons/common.mli b/lib_core/commons/common.mli index 54544ad6..f67f737f 100644 --- a/lib_core/commons/common.mli +++ b/lib_core/commons/common.mli @@ -1,6 +1,6 @@ type byte = char -type bytes = string +(* type bytes = string *) type filename = string type dirname = string diff --git a/lib_core/commons/ocaml.ml b/lib_core/commons/ocaml.ml index 6025f147..7ce82875 100644 --- a/lib_core/commons/ocaml.ml +++ b/lib_core/commons/ocaml.ml @@ -20,6 +20,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) +open Stdcompat (* for |> *) open Common (*****************************************************************************) diff --git a/mk/env.ml b/mk/env.ml index 897bc63b..993c654f 100644 --- a/mk/env.ml +++ b/mk/env.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common (*****************************************************************************) diff --git a/mk/eval.ml b/mk/eval.ml index 12ce50fb..ee3e77a7 100644 --- a/mk/eval.ml +++ b/mk/eval.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module A = Ast diff --git a/mk/graph.ml b/mk/graph.ml index 8a672ed4..cf35d5e7 100644 --- a/mk/graph.ml +++ b/mk/graph.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module A = Ast diff --git a/mk/main.ml b/mk/main.ml index 2b957852..1aa524c0 100644 --- a/mk/main.ml +++ b/mk/main.ml @@ -1,4 +1,5 @@ (* Copyright 2016, 2018 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module G = Graph diff --git a/mk/outofdate.ml b/mk/outofdate.ml index d02a178e..61083e40 100644 --- a/mk/outofdate.ml +++ b/mk/outofdate.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module G = Graph diff --git a/mk/parse.ml b/mk/parse.ml index 62c90ce6..b892bec0 100644 --- a/mk/parse.ml +++ b/mk/parse.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common let parse file = diff --git a/mk/parser.mly b/mk/parser.mly index 96f39e16..d0319d35 100644 --- a/mk/parser.mly +++ b/mk/parser.mly @@ -1,5 +1,6 @@ %{ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common open Ast diff --git a/mk/percent.ml b/mk/percent.ml index fd6399b3..88c996e7 100644 --- a/mk/percent.ml +++ b/mk/percent.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common (*****************************************************************************) diff --git a/mk/scheduler.ml b/mk/scheduler.ml index 4acc1437..b763b848 100644 --- a/mk/scheduler.ml +++ b/mk/scheduler.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module J = Job diff --git a/mk/shell.ml b/mk/shell.ml index 8d52be62..43984b7b 100644 --- a/mk/shell.ml +++ b/mk/shell.ml @@ -1,4 +1,5 @@ (* Copyright 2016, 2018 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common (*****************************************************************************) diff --git a/mk/shellenv.ml b/mk/shellenv.ml index 23663829..c3a66f00 100644 --- a/mk/shellenv.ml +++ b/mk/shellenv.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common type t = (string * string list) list diff --git a/shell/compile.ml b/shell/compile.ml index 20285226..40293fff 100644 --- a/shell/compile.ml +++ b/shell/compile.ml @@ -1,3 +1,4 @@ +open Stdcompat (* for |> *) open Common module A = Ast diff --git a/shell/interpreter.ml b/shell/interpreter.ml index 255ef735..4840d8ac 100644 --- a/shell/interpreter.ml +++ b/shell/interpreter.ml @@ -1,3 +1,4 @@ +open Stdcompat (* for |> *) open Common module O = Opcode diff --git a/shell/main.ml b/shell/main.ml index 8582a0ea..2b0beb43 100644 --- a/shell/main.ml +++ b/shell/main.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module R = Runtime diff --git a/shell/op_process.ml b/shell/op_process.ml index b44bb7d5..f01344cc 100644 --- a/shell/op_process.ml +++ b/shell/op_process.ml @@ -1,3 +1,4 @@ +open Stdcompat (* for |> *) open Common module R = Runtime diff --git a/shell/parse.ml b/shell/parse.ml index 0cd32feb..15d1d9b7 100644 --- a/shell/parse.ml +++ b/shell/parse.ml @@ -1,4 +1,5 @@ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common module R = Runtime diff --git a/shell/parser.mly b/shell/parser.mly index f3d10af9..fa883a73 100644 --- a/shell/parser.mly +++ b/shell/parser.mly @@ -1,5 +1,6 @@ %{ (* Copyright 2016 Yoann Padioleau, see copyright.txt *) +open Stdcompat (* for |> *) open Common open Ast diff --git a/shell/process.ml b/shell/process.ml index 61ae6fed..0db4225a 100644 --- a/shell/process.ml +++ b/shell/process.ml @@ -1,3 +1,4 @@ +open Stdcompat (* for |> *) open Common module R = Runtime diff --git a/shell/runtime.ml b/shell/runtime.ml index fae02fb8..c1619e67 100644 --- a/shell/runtime.ml +++ b/shell/runtime.ml @@ -1,3 +1,4 @@ +open Stdcompat (* for |> *) open Common (*****************************************************************************) From 320de223a6aba390a14272867491227261c20d45 Mon Sep 17 00:00:00 2001 From: pad Date: Fri, 19 Apr 2024 19:37:14 +0200 Subject: [PATCH 3/4] use -custom and disable opam-depext --- .github/workflows/build-and-test.jsonnet | 2 ++ .github/workflows/build-and-test.yml | 1 + bootstrap-mk.sh | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.jsonnet b/.github/workflows/build-and-test.jsonnet index db283eda..2b123ca7 100644 --- a/.github/workflows/build-and-test.jsonnet +++ b/.github/workflows/build-and-test.jsonnet @@ -40,6 +40,8 @@ local job = { uses: "ocaml/setup-ocaml@v2", with: { 'ocaml-compiler': '${{ matrix.ocaml-compiler }}', + // available only for OCaml >= 4.0.0 and we want also 3.10.0 + 'opam-depext': false, } }, { diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a44d9c8b..5c76c373 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -7,6 +7,7 @@ jobs: - uses: ocaml/setup-ocaml@v2 with: ocaml-compiler: ${{ matrix.ocaml-compiler }} + opam-depext: false - name: Install dependencies run: | opam install --deps-only . diff --git a/bootstrap-mk.sh b/bootstrap-mk.sh index fe4f9a5e..ccd636c0 100755 --- a/bootstrap-mk.sh +++ b/bootstrap-mk.sh @@ -27,8 +27,12 @@ EXTERNAL_LIB=`ocamlfind query stdcompat` #TODO? -bin-annot -absname -dtypes -g OCAMLCFLAGS="-I $EXTERNAL_LIB" +# We need -custom below because of dllstdcompat__stubs, otherwise +# we would need to set CAML_LD_LIBRARY_PATH before running the programs. +# LATER: would be good to remove if one day we want to store +# a BOOTSTRAP/mk and we want a really portable bytecode across platforms. #TODO? for windows under cygwin might need -custom -EXTRALINKFLAGS="-I $EXTERNAL_LIB stdcompat.cma" +EXTRALINKFLAGS="-I $EXTERNAL_LIB stdcompat.cma -custom" TOP=`pwd` From ecd708f66bf188d58ad6dde6b32bcc05995136c8 Mon Sep 17 00:00:00 2001 From: pad Date: Fri, 19 Apr 2024 20:11:43 +0200 Subject: [PATCH 4/4] more --- .github/workflows/build-and-test.jsonnet | 10 +++++----- .github/workflows/build-and-test.yml | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.jsonnet b/.github/workflows/build-and-test.jsonnet index 2b123ca7..11d4b37f 100644 --- a/.github/workflows/build-and-test.jsonnet +++ b/.github/workflows/build-and-test.jsonnet @@ -22,12 +22,12 @@ local job = { //TODO: 'windows-latest' ], 'ocaml-compiler': [ - // Version that I ported ocamlrun to plan9 (need stdcompat - // so we can use |> and bytes type without issues) + // Old OCaml version where I ported ocamlrun to plan9 + // This needs stdcompat so we can use |> and bytes type without issues. + // The |> operator was introduced in 4.02.0, that we could add in + // the matrix, but stdcompat does not compile with it. '3.10.0', - // Old version with |> builtin - '4.02.1', - // first version with valid ocamlformat + // First OCaml version with a working ocamlformat OPAM package '4.04.1', //TODO: Ideally 4.14.1 and ocaml latest (5.2.0) ], diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5c76c373..8294057f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -22,7 +22,6 @@ jobs: matrix: ocaml-compiler: - 3.10.0 - - 4.02.1 - 4.04.1 os: - ubuntu-latest