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

Remove configuration options --disable-force-safe-string and DEFAULT_STRING=unsafe #10893

Merged
merged 15 commits into from
Feb 1, 2022

Conversation

kit-ty-kate
Copy link
Member

@kit-ty-kate kit-ty-kate commented Jan 13, 2022

Nice there seems to be a push to remove deprecated functions before OCaml 5.00 (e.g. #10867), here is a PR to remove the --disable-force-safe-string and DEFAULT_STRING=unsafe compiler options.

They have been disabled by default since OCaml 4.10 and I don’t think these options are used anywhere anymore. Incidently this removes the slightest bit of complexity in the type-checker, which is always valuable.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is a good idea and nice simplification.

utils/clflags.ml Outdated
if Config.safe_string then ref false
else ref (not Config.default_safe_string)
(* -safe-string / -unsafe-string *)
let unsafe_string = ref false (* -safe-string / -unsafe-string *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we still have the option here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. My reasoning was the same as for keeping Config.safe_string around but it doesn’t make much sense for this one in fact. I’ve also removed -unsafe-string from the compiler arguments at the same time

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My expectation was that the compiler could accept to parse -safe-string or -unsafe-string options, but that it should do nothing on -safe-string, and fail with an error on -unsafe-string¹. In either case we don't need a corresponding value in Config or Clflags, unless I am missing something. Am I missing something?

¹: we could have a proper error on -unsafe-string, or we could completely remove the option and have the standard "unknown option" message, but the proper error sounds nicer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking keeping the value in Config is useful for backward compatibility as it is used to for printing in ocamlc -config. However you are right, they might not be needed to be exposed, only kept internal to config.mlp.

I’ve removed them and removed the commit that removed -unsafe-string to keep the nicer error message.

@kit-ty-kate kit-ty-kate force-pushed the no-unsafe-string branch 2 times, most recently from 47bba2a to 0551306 Compare January 13, 2022 14:30
@dra27
Copy link
Member

dra27 commented Jan 13, 2022

Removing the options makes it very confusing if someone tries to run with them - it's better to simplify it down to a simple error message - see for example the vmthreads options, etc.

@dra27
Copy link
Member

dra27 commented Jan 13, 2022

(the changes in the compiler are great!)

@kit-ty-kate kit-ty-kate force-pushed the no-unsafe-string branch 2 times, most recently from bbf01df to 4100877 Compare January 13, 2022 16:47
@kit-ty-kate
Copy link
Member Author

Removing the options makes it very confusing if someone tries to run with them - it's better to simplify it down to a simple error message - see for example the vmthreads options, etc.

Done.

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a nice simplification. @dra27 @gasche are you happy with the current state of this PR?

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at this again and I like it. I commented on two parts of the PR (OCAMLPARAM parsing, and ppx cookies) where I think we should still provide/handle safe-string information. (Basically I think the compiler should behave, to external tools, as it did in previous version when safe-string was enabled.) The maintenance cost is neglectible (it's two lines of code, in addition to the configure.ac setting) and it helps people write scripts that robustly support several OCaml versions.

(I checked in particular that ocamlc -config-var safe_string should still return true, instead of failing. My understanding is that the current PR state already provides this behavior.)

driver/compenv.ml Show resolved Hide resolved
parsing/ast_mapper.ml Show resolved Hide resolved
@gasche
Copy link
Member

gasche commented Jan 30, 2022

@kit-ty-kate check-typo is now complaining. You can run it locally on your branch with ./tools/check-typo-since trunk.

@kit-ty-kate
Copy link
Member Author

All green now.

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few tweaks in configure.ac just to accept values which are still the defaults w.r.t. #10962. I don't mind if those changes get moved there instead - the main aim of this PR (removing unsafe string completely) shouldn't be held up by keeping the odd CI script more easily maintained!

configure.ac Outdated Show resolved Hide resolved
configure.ac Outdated Show resolved Hide resolved
configure.ac Outdated
AC_ARG_VAR([DEFAULT_STRING], [])
AS_IF([test x"$DEFAULT_STRING" != "x" ],
[AC_MSG_ERROR(
[The DEFAULT_STRING option variable was deleted in OCaml 5.00.])])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly w.r.t. the message above:

Suggested change
[The DEFAULT_STRING option variable was deleted in OCaml 5.00.])])
[OCaml 5.00 only supports immutable strings.])])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the message to Support for mutable strings was removed in OCaml 5.00. instead. Does that look ok?

configure.ac Outdated Show resolved Hide resolved
@kit-ty-kate
Copy link
Member Author

kit-ty-kate commented Jan 30, 2022

I don’t think configuration arguments such as --enable-force-string should be kept outside of making them an error for user-friendly errors messages, even if this is "the new default".

I don’t think anyone need the same configuration arguments given to several compiler version at once.

It makes sense to keep -safe-string for because people need the backward compatibility for the arguments to ocamlc/ocamlopt but for the compiler configuration I don’t think it’s worth the effort.

@dra27
Copy link
Member

dra27 commented Jan 30, 2022

It is strange - and actively irritating in at least one instance - to specify an option to configure and to be told that you can’t enable that option because it’s because it’s been removed when it’s actually the default!

@dra27
Copy link
Member

dra27 commented Jan 30, 2022

(another use case for configure ignoring these options is when bisecting)

@gasche
Copy link
Member

gasche commented Feb 1, 2022

@kit-ty-kate I'm eager to merge this PR, but I would weigh in the direction of going for @dra27's suggestion. @dra27 has a phenomenal amount of experience (writing and) running compiler configure scripts, so I would trust his gut feeling here.

@kit-ty-kate
Copy link
Member Author

I have no issues with the request. I just need more time, my current machine does not have the autoconf 2.69 (with ubuntu’s patch) that CI uses (I only have mainline autoconf 2.71 and 2.69) so that complicates my work setup. Plus I have to remember autoconf’s syntax/behaviour once more.. ^^"

@kit-ty-kate
Copy link
Member Author

my current machine does not have the autoconf 2.69 (with ubuntu’s patch) that CI uses (I only have mainline autoconf 2.71 and 2.69) so that complicates my work setup

Actually tools/autogen handles that automatically. That’s very nice! ^^

@kit-ty-kate
Copy link
Member Author

All green and ready to be reviewed once more

@dra27
Copy link
Member

dra27 commented Feb 1, 2022

Actually tools/autogen handles that automatically. That’s very nice! ^^

I try to keep these horrible things as usable as possible 🙂

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for those changes! There's just a few nits, and let's finally see the back of mutable strings 🙂 (Crucially no need to rebuild configure, via tools/autogen or otherwise.)

configure.ac Outdated Show resolved Hide resolved
configure.ac Outdated Show resolved Hide resolved
Makefile.config.in Show resolved Hide resolved
@gasche gasche merged commit 9453a90 into ocaml:trunk Feb 1, 2022
kit-ty-kate added a commit to ocaml-community/utop that referenced this pull request Mar 28, 2022
Remove -safe-string for OCaml 5. See ocaml/ocaml#10893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants