What is the motivation?

D package management on Gentoo doesn't exist de facto. There
are spread out ebuilds (package manager scripts) for dmd and
ldc and that's it. Orthogonal to that are projects like Jacob
Carlborg's "dvm", which only handles dmd and Sönke Ludwig's
"dub" which don't integrate with the official package
managers.

When I decide to install a D application on Gentoo, I want it
to just work. For Gentoo that includes the choice of compiler
to build it and the used compilation flags.

The package manager should handle installing LLVM, the latest
stable LDC and required libraries on top of that and finally
the application. Just like it is for most other main stream
languages right now. If you think this is a good thing to
have, please read on...


---(The following is rather Gentoo specific)---

I tried to plot in my head what D support in Gentoo would
ideally look like. Some corners I have found are:

- The makefiles are still not typical, although I don't have
  to patch them anymore since 2.062, which is positive.
- Compiler and library are closely coupled and depend on each
  other.
- Each new D point release brings a new, generally
  incompatible standard library.
- All three major compiler backends are in good shape and use.
  But their generated code is not exchangeable (as far as
  I've heard due to ABI differences).
- Tools tend to expect that "dmd" is available as a command.

To deal with the complexity of package dependency management
in this scenario, we need to be able to install multiple
versions of D compilers in parallel (similar to what dvm does).
This can be accomplished by so called "slots" for each point
release. We can do this for all three compilers and will end
up with binaries like "dmd2.064" and "gdc2.063".

Next a symlink should be established to the current
implementation of dmd, e.g.: /bin/dmd -> /bin/ldmd2.
This symlink could be managed with an eselect plugin as it is
already done for other languages like Python or the Java
Runtime.

Since libraries for D depend not only on druntime/Phobos, but
also on the compiler the Gentoo user should be able to setup
globally and for each library which compilers it should work
with. Again there is prior work on Gentoo for supporting a
list of things (Apache modules, graphics cards, cameras, ...).
The environment variables that are used for that usually go
into /etc/make.conf: D_COMPILERS="dmd gdc ldc" and are mapped
to regular "Use-Flags" for packages, i.e. d_compilers_dmd,
d_compilers_gdc and d_compilers_ldc. (This step is already
automated.)

The libraries could depend directly on an installation of the
respective compilers, but I think it would be cleaner to have
a "virtual/phobos" package, that is sensitive to the list of D
compilers as mentioned above.
One question I haven't finally answered yet is how to handle
libraries when there are multiple versions of D available.
For some programming languages this is solved by installing
libraries into <language_name>-<version>/ prefixes.
This certainly requires a more thoughtful dmd configuration
process. E.g. multiple dmd.conf for each installed version, to
point to the correct library directory. (A small patch to the
compiler sources during installation.)

Thoughs?

-- 
Marco

Reply via email to