Skip to content

Handling of RTS ways with cabal-install #24

Open
@hsyl20

Description

@hsyl20

The RTS can be built using several ABI compatible ways. These are called RTS ways in the compiler and apparently flavours in Cabal. GHC can switch between them at program link time (so independently of any notion of a cabal package, so they shouldn't be represented as different installed packages to cabal afaict).

What happens with Hadrian:

  • It builds the RTS more than once, with different flags
  • It uses suffixes to identify the ways (e.g. "_thr" for the THREADED way) in the filenames of the rts libraries
  • These libraries are put alongside the normal ("vanilla") one in the rts lib dir

When we build with cabal-install, cabal-install has to do this... Luckily Cabal has some notion of ways called "flavours" which are even documented in the manual:

Image

Of course...

If we try to enable one (e.g. extra-library-flavours: _thr) and run the script in #3 we get:

Installing library in /home/hsyl20/.cabal/store/ghc-9.13-inplace/incoming/new-60663/home/hsyl20/.cabal/store/ghc-9.13-inplace/rts-1.0.3-6722ce6fbfa2d1ba89ce151d7d3f1c2c172ab3e37bf54cd952c07b60b3ca51bc/lib
/home/hsyl20/projects/ghc/stable/_build/stage1/cabal/tmp/src-60663/rts-1.0.3/dist/build/libHSrts-1.0.3-6722ce6fbfa2d1ba89ce151d7d3f1c2c172ab3e37bf54cd952c07b60b3ca51bc_thr.a: copyFile: does not exist (No such file or directory)

So apparently cabal doesn't build the different flavours but expect the resulting libraries to be present.

We probably need to design something in cabal to handle the flavours in a better way.

Currently the RTS contains:

      -- Here we declare several flavours to be available when passing the
      -- suitable (combination of) flag(s) when configuring the RTS from hadrian,
      -- using Cabal.
      if flag(threaded)
        extra-library-flavours: _thr
        if flag(dynamic)
          extra-dynamic-library-flavours: _thr

      if flag(profiling)
        extra-library-flavours: _p
        if flag(threaded)
          extra-library-flavours: _thr_p
        if flag(debug)
          extra-library-flavours: _debug_p
          if flag(threaded)
            extra-library-flavours: _thr_debug_p
        if flag(dynamic)
          extra-dynamic-library-flavours: _p
          if flag(threaded)
            extra-dynamic-library-flavours: _thr_p
          if flag(debug)
            extra-dynamic-library-flavours: _debug_p
            if flag(threaded)
              extra-dynamic-library-flavours: _thr_debug_p

      if flag(debug)
        extra-library-flavours: _debug
        if flag(dynamic)
          extra-dynamic-library-flavours: _debug
        if flag(threaded)
          extra-library-flavours: _thr_debug
          if flag(dynamic)
            extra-dynamic-library-flavours: _thr_debug

So I think we just need to add:

  1. Flavour specific options
if flavour(_debug) || (_thr_debug) || ...
  ghc-options: -DDEBUG
if flavour(_thr) || (_thr_debug) || ...
  ghc-options: -DTHREADED

It would make flavours just like flags but invisible at the package level.

  1. cabal-install feature to build libraries once per extra flavour

  2. Optional: allow disabling the default flavour ("vanilla")? E.g. on ArchLinux they don't want static linking.

  3. Optional: store the list of enabled flavours in the installed package config so that GHC can detect what is enabled (it can also detect which library files exist, so it's not mandatory).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions