camlp-streams
camlp-streams copied to clipboard
Fix the build for 4.02-4.04 on macOS and for 4.02-4.10 with MSVC on Windows
I recently discovered that one can correctly trick Dune into creating empty libraries for some versions of OCaml, which allows the removal of the dynamic dune file. This PR then changes the build to be an empty library for OCaml 4.13 and earlier. This was originally considered in #5, but it breaks the build on MSVC prior to 4.11, so instead an empty library was only built for OCaml 4.07 to limit the damage to 4.02-4.07 on MSVC. It turns out the damage included in 4.02-4.04 on macOS.
The solution proposed here is that for the offending versions of OCaml (that's 4.02-4.04 on macOS and 4.02-4.10 with MSVC on Windows), an empty module CamlinternalCamlp_streams is added to the library which works around the linker problems.
A solution such as this was considered for the same problem in stdlib-shims, however it was rejected there because this issue affects the current versions of OCaml (the solution adopted in stdlib-shims was to fix OCaml itself). I think it's OK to use this trick here because we know that there was no CamlinternalCamlp_streams module in 4.02-4.10 and programs and libraries are not supposed to use names beginning Camlinternal. Most importantly, the number of releases in which this trick is used is fixed, unlike in stdlib-shims.
I can confirm that this is working on MSVC 4.06-4.14 with only 4.06-4.10 having the dummy module in camlp_streams.cmxa. ~I'll double-check the macOS ones tomorrow when I'm near my old Macbook.~ It's also tested on macOS for 4.02-4.04.
Thanks for the fix @dra27, I confirm that it resolves the build failure on omd 😁