Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails due to syntax error on Set.Make(String) #55

Open
jordr opened this issue Nov 21, 2022 · 5 comments
Open

Build fails due to syntax error on Set.Make(String) #55

jordr opened this issue Nov 21, 2022 · 5 comments

Comments

@jordr
Copy link

jordr commented Nov 21, 2022

$ dune.build
File "frontc/cxml.ml", line 43, characters 19-20:
Error: Syntax error

This is because of this code bit:

FrontC/frontc/cxml.ml

Lines 42 to 59 in c95d785

let validate_identifiers toplevel =
let open Set.Make(String) in
let rec node ids x ~accept ~reject = match x with
| TEXT _ | COM _ | PI _ -> accept ids
| ELT (_,attrs,xs) as elt ->
match List.assoc_opt "id" attrs with
| None -> nodes ids xs ~accept ~reject
| Some "" -> reject elt
| Some id -> if mem id ids
then reject elt
else nodes (add id ids) xs ~reject ~accept
and nodes ids xs ~accept ~reject = match xs with
| [] -> accept ids
| x :: xs -> node ids x ~reject ~accept:(fun ids ->
nodes ids xs ~accept ~reject) in
node empty toplevel
~accept:(fun _ -> Ok toplevel)
~reject:(fun elt -> Error elt)

@jordr
Copy link
Author

jordr commented Nov 21, 2022

Note this also occurs when building from opam pin:

$ opam pin FrontC --dev-repo

[FrontC.3.4.3-1] synchronised (git+https://github.com/BinaryAnalysisPlatform/FrontC)
FrontC is now pinned to git+https://github.com/BinaryAnalysisPlatform/FrontC (version 4.1.0)

The following actions will be performed:
  ↗ upgrade FrontC 3.4.3-1 to 4.1.0*
Do you want to continue? [Y/n] Y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing  2/4: [FrontC: dune build]
[ERROR] The compilation of FrontC.4.1.0 failed at "dune build -p FrontC -j 4 @install".

#=== ERROR while compiling FrontC.4.1.0 =======================================#
# context     2.1.3 | linux/x86_64 | base-unix.base | pinned(git+https://github.com/BinaryAnalysisPlatform/FrontC#c95d785d)
# path        ~/.opam/system/.opam-switch/build/FrontC.4.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p FrontC -j 4 @install
# exit-code   1
# env-file    ~/.opam/log/FrontC-6095-7c6cd2.env
# output-file ~/.opam/log/FrontC-6095-7c6cd2.out
### output ###
# (cd _build/default && /usr/bin/ocamldep.opt -modules -impl frontc/cxml.ml) > _build/default/frontc/.FrontC.objs/cxml.ml.d
# File "frontc/cxml.ml", line 43, characters 19-20:
# Error: Syntax error
# (cd _build/default && /usr/bin/ocamlc.opt -w -40 -g -bin-annot -I frontc/.FrontC.objs/byte -intf-suffix .ml -no-alias-deps -o frontc/.FrontC.objs/byte/cparser.cmo -c -impl frontc/cparser.ml)
# File "frontc/cparser.mly", line 4, characters 14-19:
# Error: Multiple definition of the extension constructor name Error.
#        Names must be unique in a given structure or signature.
# (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -I frontc/.FrontC.objs/byte -I frontc/.FrontC.objs/native -intf-suffix .ml -no-alias-deps -o frontc/.FrontC.objs/native/cparser.cmx -c -impl frontc/cparser.ml)
# File "frontc/cparser.mly", line 4, characters 14-19:
# Error: Multiple definition of the extension constructor name Error.
#        Names must be unique in a given structure or signature.



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build FrontC 4.1.0
└─ 

@ivg
Copy link
Member

ivg commented Nov 23, 2022

I presume you're using a very old version of theOCaml compiler. We support 4.08 and upward, what is your version? Alternatively, it could be a very new version that is not yet in our CI. Anyways, what version of OCaml are you building with?

@jordr
Copy link
Author

jordr commented Nov 25, 2022

I am building with ocaml 4.04. I have upgraded to ocaml 4.07, the newest available using opam. I still get the error. This doesn't look like a version issue.

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing  2/4: [FrontC: dune build]
[ERROR] The compilation of FrontC.4.1.0 failed at "dune build -p FrontC -j 4 @install".

#=== ERROR while compiling FrontC.4.1.0 =======================================#
# context     2.1.3 | linux/x86_64 | base-unix.base | pinned(git+https://github.com/BinaryAnalysisPlatform/FrontC#c95d785d)
# path        ~/.opam/system/.opam-switch/build/FrontC.4.1.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p FrontC -j 4 @install
# exit-code   1
# env-file    ~/.opam/log/FrontC-15282-3ac299.env
# output-file ~/.opam/log/FrontC-15282-3ac299.out
### output ###
# (cd _build/default && /home/jruiz/.opam/system/bin/ocamldep.opt -modules -impl frontc/cxml.ml) > _build/default/frontc/.FrontC.objs/cxml.ml.d
# File "frontc/cxml.ml", line 43, characters 19-20:
# Error: Syntax error
# (cd _build/default && /home/jruiz/.opam/system/bin/ocamlc.opt -w -40 -g -bin-annot -I frontc/.FrontC.objs/byte -intf-suffix .ml -no-alias-deps -o frontc/.FrontC.objs/byte/cparser.cmo -c -impl frontc/cparser.ml)
# File "frontc/cparser.mly", line 4, characters 14-19:
# Error: Multiple definition of the extension constructor name Error.
#        Names must be unique in a given structure or signature.
# (cd _build/default && /home/jruiz/.opam/system/bin/ocamlopt.opt -w -40 -g -I frontc/.FrontC.objs/byte -I frontc/.FrontC.objs/native -intf-suffix .ml -no-alias-deps -o frontc/.FrontC.objs/native/cparser.cmx -c -impl frontc/cparser.ml)
# File "frontc/cparser.mly", line 4, characters 14-19:
# Error: Multiple definition of the extension constructor name Error.
#        Names must be unique in a given structure or signature.

By the way, if it really is a version issue this could be specified in the opam config with a FrontC → ocaml >= 4.08.0.
At the moment it only says "depends ocaml" :

❯ opam show FrontC

<><> FrontC: information on all versions ><><><><><><><><><><><><><><><><><><><>
name                   FrontC
all-installed-versions 3.4.3-1 [system]
all-versions           3.4  3.4.1  3.4.2  3.4.3  3.4.3-1  4.0.0  4.1.0

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version      3.4.3-1
repository   default
url.src      "https://github.com/BinaryAnalysisPlatform/FrontC/archive/refs/tags/v3.4.3.tar.gz"
url.checksum "md5=399f66735541ecf8e06220618eef5c98"
homepage     "https://github.com/BinaryAnalysisPlatform/FrontC"
bug-reports  "https://github.com/BinaryAnalysisPlatform/FrontC/issues"
dev-repo     "git+https://github.com/BinaryAnalysisPlatform/FrontC"
authors      "Hugues Cassé <[email protected]>"
maintainer   "Ivan Gotovchits <[email protected]>"
license      "LGPL-2.1-only"
depends      "ocaml"
synopsis     Library providing a C parser and lexer
description  FrontC is an OCAML library providing a C parser and lexer. The result
             is a syntactic tree easy to process with usual OCAML tree management.
             It provides support for ANSI C syntax, old-C K&R style syntax and the
             standard GNU CC attributes.
             It provides also a C pretty printer as an example of use.

@ivg
Copy link
Member

ivg commented Nov 28, 2022

I am building with ocaml 4.04. I have upgraded to ocaml 4.07, the newest available using opam. I still get the error. This doesn't look like a version issue.

Well, it is, we only support 4.08.1 and above. And you're right, we should update the meta information in opam-repository to reflect it.

@ivg
Copy link
Member

ivg commented Nov 28, 2022

In fact, it is already correctly specified. Your opam show FrontC printed the constraint for the old 3.4-2-1 version, which is successfully installed on your system switch.

I have upgraded to ocaml 4.07, the newest available using opam

The newest version of OCaml is 4.13.1. The 4.07 version is four years old. Try doing opam update to get your opam installation up to date. Also, make sure that you're using opam 2.x not opam 1.x, which is no longer supported or updated (so you could stuck in the old version of opam-repository)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants