ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.63k stars 404 forks source link

[RFC] Name Mangling for Package Private Libraries #3864

Open rgrinberg opened 4 years ago

rgrinberg commented 4 years ago

This was supposed to be done as part of #3655, but since it turns out be a pretty large change, I decided to create a separate proposal for this.

Problem

Private libraries defined in different projects may collide. Consider these two private libraries defined in different dune projects:

(library
 (name helper)
 (package foo))

and

(library
 (name helper)
 (package bar))

While the two libraries can be installed, they cannot be used in the same library or executable.

Solution

Choose a compilation unit name that reflects that such private libraries are unique, and then use -open on libraries that users of such library to hide it. The scheme will look as follows:

Note that this proposal will also require package private libraries to be (wrapped true). I think that's a good idea regardless.

I'd like to see what @bobot and @aalekseyev think about this.

bobot commented 4 years ago

Is it $pkg__private__helper so it becomes bar__private__helper and foo__private__helper?

I believe it is your idea but just to precise:

I'm ok with it.

rgrinberg commented 4 years ago

Is it $pkgprivatehelper so it becomes barprivatehelper and fooprivatehelper?

That's right. The package should guarantee uniqueness in this case.

It must go before the flags of the users. So they could do -open Helper

Good point.

ghost commented 4 years ago

We discussed the proposal during the meeting and accepted it.