yoriyuki / Camomile

A Unicode library for OCaml
Other
125 stars 26 forks source link

Fix parallel build: Delay toplevel database reads #75

Closed kit-ty-kate closed 5 years ago

kit-ty-kate commented 5 years ago

When compiling camomile using several cores it might fail with the following errors (with backtraces):

parse_allkeys Camomile/database/acset.mar,Camomile/database/allkeys.mar (exit 2)
(cd _build/default/Camomile && tools/parse_allkeys.exe database unidata/tr10/allkeys.txt)
Fatal error: exception Not_found
Raised at file "Camomile/internal/database.ml", line 50, characters 52-67
Called from file "Camomile/internal/unidata.ml" (inlined), line 187, characters 4-48
Called from file "Camomile/public/uCharInfo.ml", line 443, characters 34-50
Called from file "Camomile/toolslib/absCe.ml", line 40, characters 14-44
parse_specialcasing Camomile/database/special_casing.mar (exit 2)
(cd _build/default/Camomile && tools/parse_specialcasing.exe database unidata/SpecialCasing.txt)
Fatal error: exception Not_found
Raised at file "Camomile/internal/database.ml", line 50, characters 52-67
Called from file "Camomile/internal/unidata.ml" (inlined), line 187, characters 4-48
Called from file "Camomile/public/uCharInfo.ml", line 443, characters 34-50
Called from file "Camomile/tools/parse_specialcasing.ml", line 40, characters 19-49

This PR fixes the issue. One thing I don't understand is how the call to read_data "acset" in ColParser didn't make everything fail every time since it is included in the toolslib library and this library is used to create acset.mar itself..

Anyway, I think avoiding side-effects on toplevel (even inside functors) is a good practice in any case.

Related to https://github.com/ocaml/opam-repository/pull/13980