WeiDUorg / weidu

WeiDU is a program used to develop, distribute and install modifications for games based on the Infinity Engine.
http://www.weidu.org
GNU General Public License v2.0
90 stars 20 forks source link

-unsafe-string doesn't work with OCaml 4.10.0 that now enforces safe strings #197

Closed peterhoeg closed 3 years ago

peterhoeg commented 3 years ago

Here are the details in the ocaml release notes:

https://discuss.ocaml.org/t/ocaml-4-10-released/5194

And this is where the -unsafe-string parameter is used:

https://github.com/WeiDUorg/weidu/blob/devel/Makefile.ocaml#L170-L171

If -unsafe-string is removed, compilation blows up with:

File "./scripts/make_tph.ml", line 17, characters 18-22:                                    
17 |   my_read size fd buff name ;                                                                   
                       ^^^^                                                                          
Error: This expression has type string but an expression was expected of type
         bytes                     
FredrikLindgren commented 3 years ago

Yes, OCaml needs to be configured to not force safe-string (and cannot be more recent than 4.11, for other reasons). If you cannot get one such OCaml from where you normally get yours, you would need to compile it yourself (with the appropriate configuration).

peterhoeg commented 3 years ago

Fortunately on NixOS it's trivial to build a variant of ocaml that doesn't enforce safe strings, but are there any plans to have weidu support safe strings in the future?

FredrikLindgren commented 3 years ago

There are not, no. The mutable string is probably WeiDU's most used data type, but using Bytes (new mutable string type) is unmanageable because much/most of the standard library still uses String (now immutable) and there is no end to all the type conversions.

peterhoeg commented 3 years ago

Will you take a PR that adds a basic readme that outlines this?

FredrikLindgren commented 3 years ago

Thank you, but that won't be necessary. I have written compilation instructions, but embarrassingly, I have not made them available (there's an older revision on weidu.org, but it does not mention the unsafe-string bit).