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

Install to lib/stublibs in legacy mode as well #40

Merged
merged 4 commits into from
Jun 26, 2024

Conversation

Leonidas-from-XIV
Copy link
Contributor

This changes the Makefile slighty so that in the legacy mode the files will be installed into the package directory as well as into the stdlib.

This allows dune to install num outside of the compiler and still use num like a regular findlib package (with the cmi, cma etc in the package folder), while keeping it in the stdlib for packages that do not use findlib nor dune and just add nums.cma in their build.

@dra27 dra27 self-assigned this Jun 3, 2024
@dra27
Copy link
Member

dra27 commented Jun 3, 2024

This seems a reasonable compromise to me - I want to do some local testing just to be certain that there's nothing strange going on with .cmi shadowing, but otherwise this just needs a separate CI tweak (again sigh) and it should be good to go, thanks.

The switch will be configured to load dllnums.so from the switch
stublibs directory anyway and the compatibility is necessary for the cma
and cmxa to be in the stdlib directory, not for the stubs library.
@dra27
Copy link
Member

dra27 commented Jun 26, 2024

I pushed an extra commit to remove the duplicated dllnums.so. As well as helping Dune package management, this I think creates a better a story for how the library is packaged (as testified by the simplified META and .install files) - for all versions of OCaml, we install num as a findlib package, it's just that for < 5.0.0 we also install the core files to the OCaml stdlib directory for compatibility. i.e. the compatibility packaging is a strict superset of the "master/trunk" packaging, rather than being completely different.

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.

@nojb - could I trouble you for a second opinion, but I'm for merging this.

@dra27 dra27 requested a review from nojb June 26, 2024 18:01
@dra27
Copy link
Member

dra27 commented Jun 26, 2024

(for packaging reasons, it would be helpful if whoever merges this PR squashes it, please)

Copy link
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

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

LGTM

@nojb nojb merged commit f6e31b1 into ocaml:master Jun 26, 2024
12 checks passed
@Leonidas-from-XIV Leonidas-from-XIV deleted the install-to-pkg-dir branch June 27, 2024 07:43
Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-repository that referenced this pull request Jul 2, 2024
Num does a bit of an unusual thing for findlib packages as it installs
into (what it considers) the OCaml stdlib.

This works as long as the stdlib is in `%{lib_root}%/ocaml` and thus it
doesn't findlib to add it to the compiler search path. In the new dune
package management `%{lib_root}%/ocaml` will not point to the ocaml
compiler stdlib thus `num` will not be found unless its installation
directory is added to the search path (via findlib or dune or any other
mechanism that evaluates META files).

In OCaml 5.0 this is the default already, `num` is never installed in
the stdlib but always into its package folder.

This patch changes the behavior for OCaml 4.x where before `num` was
only installed into the stdlib folder (and didn't need to be stated as
dependency) but referencing it via findlib did not hurt to install it in
*both* the stdlib and the package folder.

This way if a package depends on num in the stdlib without referencing
num it will find num in the stdlib, but if `num` is referenced via
findlib it will add the package folder to the search path and find
either copy.

This patch has been merged upstream, see the discussion at
ocaml/num#40 for more details. This patch just
backports the change to the latest released `num` version as future
versions of `num` will come with this change. The next num release might
be some time off given `num` is mostly "done" therefore this patch is
meant to bridge the gap and a recommendation from @dra27 who is
maintaining `num` upstream.
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
Num does a bit of an unusual thing for findlib packages as it installs
into (what it considers) the OCaml stdlib.

This works as long as the stdlib is in `%{lib_root}%/ocaml` and thus it
doesn't findlib to add it to the compiler search path. In the new dune
package management `%{lib_root}%/ocaml` will not point to the ocaml
compiler stdlib thus `num` will not be found unless its installation
directory is added to the search path (via findlib or dune or any other
mechanism that evaluates META files).

In OCaml 5.0 this is the default already, `num` is never installed in
the stdlib but always into its package folder.

This patch changes the behavior for OCaml 4.x where before `num` was
only installed into the stdlib folder (and didn't need to be stated as
dependency) but referencing it via findlib did not hurt to install it in
*both* the stdlib and the package folder.

This way if a package depends on num in the stdlib without referencing
num it will find num in the stdlib, but if `num` is referenced via
findlib it will add the package folder to the search path and find
either copy.

This patch has been merged upstream, see the discussion at
ocaml/num#40 for more details. This patch just
backports the change to the latest released `num` version as future
versions of `num` will come with this change. The next num release might
be some time off given `num` is mostly "done" therefore this patch is
meant to bridge the gap and a recommendation from @dra27 who is
maintaining `num` upstream.
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.

3 participants