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

Fix MSVC build for 4.07-4.09 #12

Merged
1 commit merged into from
Oct 8, 2019
Merged

Fix MSVC build for 4.07-4.09 #12

1 commit merged into from
Oct 8, 2019

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Oct 3, 2019

This should fix #11. Although with the library will be build with ocaml/dune#2693, OCaml 4.07-4.09 can't use the resulting stdlib_shims.cmxa file without ocaml/ocaml#9011 which will require at least OCaml 4.10.0, so a workaround is needed here too.

The workaround I've attempted is to duplicate the Pervasives module. This has the immediate effect of allowing the deprecation warning from 4.08.0 to be changed so that the stdlib-shims library is not recursively mentioned. On OCaml 4.07 this has no effect (cf. ocaml/ocaml#2041 in 4.08.0), so OCaml 4.07.0 doesn't gain the deprecation warning.

The purpose of this library is to provide compatibility with Stdlib for OCaml < 4.07.0. In those versions, it's virtually possible to define a module called Pervasives (that's the purpose of ocaml/ocaml#1010), so if a user uses stdlib-shims then they have already opted out of being able to shadow standard library modules, and the inclusion of our own pervasives.cmi is - I think - safe. It's also the case that if you're using this library, you're meant to be avoiding using Pervasives completely.

No modules are needed in the library for OCaml 4.07.0+, which is a
problem on MSVC since no .lib file is generated by ocamlopt -a when no
modules are given.

This is worked around by duplicating the Pervasives module.
@ghost
Copy link

ghost commented Oct 7, 2019

I get a bad feeling about adding a toplevel Pervasives module. In theory it should be fine but I can imagine it either being confusing for users or triggering some weird error. What about using something properly explicit, such as Temporary_workaround_to_empty_lib_bug_on_msvc?

@dra27
Copy link
Member Author

dra27 commented Oct 8, 2019

I debated that too - what I dislike about it is that if two libraries were to use that trick then you'd be unable to link with both of them, and that seemed the more likely of two very unlikely possibilities (the other being some weird kind of errror we've not considered). Given that the raison d'etre of this library is to stop using Pervasives completely, it seems really unlikely that you'd ever try to link with another library that was trying to define Pervasives too (and, the second you do that, you can't build it with OCaml < 4.08.0, so the use of stdlib-shims is already very strange). Perhaps that's an argument for keeping the redefinition in 4.10+ as well.

The fix if someone manages to find a convincing breaking pattern would also be really quick (that's not an argument in favour of either solution, just that if anything does break, we can fix it)

What do you think?

@ghost
Copy link

ghost commented Oct 8, 2019

Seems fine to me, let's get this merged and released!

@ghost ghost merged commit 93f81a5 into ocaml:master Oct 8, 2019
@dra27 dra27 deleted the fix-msvc-build branch October 9, 2019 09:04
dra27 added a commit to dra27/opam-repository that referenced this pull request Jan 21, 2021
CHANGES:

- Remove things accidentally included in 0.2.0 not listed below! (@dra27, ocaml/stdlib-shims#13)
- Extend the fix in ocaml/stdlib-shims#12 to OCaml 4.10.0, since PR#9011 wasn't merged until 4.11
This pull request was closed.
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

Successfully merging this pull request may close these issues.

Can't build with OCaml 4.07.1 Win32
1 participant