switch to safe-string by default (related to MPR#7113)#1252
switch to safe-string by default (related to MPR#7113)#1252damiendoligez merged 3 commits intoocaml:trunkfrom
Conversation
|
If I remember correctly, if you configure with -safe-string, you are not allowed to compile with -unsafe-string anymore. This is to allow the compiler perform optimizations whose correctness depend on immutable strings. It would be useful to get an idea of the impact of the change on OPAM. I assume that this PR should make it easy. |
5df3f15 to
b28a918
Compare
|
@alainfrisch I just realized that and changed my patch to change only the command-line default when configured without |
|
As the maintainer of a library that is, as of yet, not fully -safe-string, I have come to believe that the changes will happen when maintainers cannot do without it, that is when ¹: this supports the idea of making the change early in the release cycle to give us more time. But we also need the tools to look at the opam ecosystem, the only tool I know how to use is |
|
As far as tools are concerned, I'm working on a new version of Preliminary version available at https://github.com/janestreet/opamcheck in src directory, but there is no documentation. |
|
Should we advertise this change starting now to give people more time to react ? |
|
Sure, as long as we have a story about how people would test their software to check whether they are fine. Maybe one thing we could do is to backport the change in an OCaml branch branched off 4.05.0 (or 4.04.3 for that matter), so that people can evaluate the impact on their software without having to also port their code to the trunk. |
|
I was thinking that the "4.05.0+safe-string" opam switch could cover most testing need. Am I missing something? |
No need to do any of that, just tell them to before compiling their code. It even does the right thing if they have the |
|
@Octachron you're missing the case where the fix consists in adding |
I was fortunate enough to be in the dependency cone of @jpdeplaix who was gently insistant and helpful about this. I believe I personally made the transition in my packages. He may have a qualitative assement of the situation to share. |
|
I'm super excited by this change ! :)
I found the rest pretty straightforward, and except for some packages, there is not much to change on average (2 or 3 lines here and there). Now, lots of packages are still not safe-string compatible but I think this PR will make a difference. It would be a great help if someone could relaunch the "opam builder" project (or do something like that specifically for this) to see which packages are to be fixed. |
One possibility would be: String.init 3
(function
| 0 -> f some_computation
| ...
)but in practice this is probably slower than going through Bytes (but perhaps faster than going though a list). |
|
@jpdeplaix Do you have suggestions of functions that could be added to the stdlib to make the migration easier? |
|
@alainfrisch yeah I though of this one. But we can't ensure that all cases are filled like an @damiendoligez well, not really because it would break backward compatibility. Aside from that, the migration is somewhat easy if you don't care about the "performances" (is some precise cases), you just have to be careful with backward compatibility, if the use of the |
b28a918 to
669db31
Compare
669db31 to
7892a70
Compare
|
How much breakage does this change cause in OPAM packages? Could we get a report from OCamlpro's OPAM builder tool? |
(cc @damiendoligez @lefessan) |
|
I just tried to install the more packages I could and here is the result: I tested this with OCaml 4.05. A lot of packages couldn't be tested because they are not yet compatible with 4.05 and a lot of packages could also not be tested because of missing system dependencies or missing dependencies in the opam package ( |
|
I tried it on trunk. The patch breaks 367 (versions of) packages. All of them can be "fixed" by building under So if we merge this now, we'll have to change at least 367 package description files before the 4.06.0 release. |
Another fix is to simply constrain the OCaml version (which might be actually easy to do in bulk with Also I'm not sure counting package versions is a very good metric. E.g. you have 4 versions of I think a more interesting number would be the number of packages whose last version breaks with this patch. |
|
@damiendoligez - the Windows Makefiles need amending. For your convenience, a rebased version is at https://github.com/dra27/ocaml/tree/safe-string-by-default which includes a commit making that change too. |
|
Oops - yes, indeed! My fervour to see the end of unsafe strings went too far. |
|
FWIW I'd be in strong favour to have I went through the 133 unique packages mentioned by @damiendoligez above, and 56 unique packages from that list already have newer versions in opam than mentioned (and thus should nicely work with |
Only the ones that fail on their own. Let me see if I can compute the transitive closure. |
|
120 dep-failures in 62 unique packages. An unknown number of them will become hard failures when their deps get fixed. |
7892a70 to
e574e2e
Compare
|
I'm going with @avsm's advice and merging this in 4.06. We'll see how the OPAM work goes... |
e574e2e to
0a2e00d
Compare
|
It is a bit frustrating that there exists no configure-level switch to revert the effect of this patch. I would like an Right now it seems to me that the number of broken opam package is fairly large. Users, or maintainers of a given package, may be able to update their own build scripts to sprinkle (Incidentally, this would also help triaging before the release, by making it easier to ignore the safe-string issue to find the other 4.06-related regressions. Right now, -safe-string apparently breaks |
|
@gasche
|
No,
I believe it is wrong to use OCAMLPARAM for this purpose. I'm preparing a proper configure-time solution, sending a PR later. |
Oh, right. Sorry. |
|
No problem; the choices here are a bit tricky, and it's good to discuss them more. |
…ing. This breaks the code that uses the string type as mutable strings. See ocaml/ocaml#1252
…uite PR ocaml#1252 has made the safe-string mode the default so passing -safe-string explicitly has become useless since this PR has been merged, even more useless since support for mutable strings was removed in OCaml 5.0.
…uite PR ocaml#1252 has made the safe-string mode the default so passing -safe-string explicitly has become useless since this PR has been merged, even more useless since support for mutable strings was removed in OCaml 5.0.
I think it's time to switch to safe-string mode by default, the last step before eliminating unsafe strings.
The default can still be overridden at compile time with the
-unsafe-stringflag.We should leave ample time for discussion (and changing OPAM packages) before we merge this.