Skip to content

pkgsUseSharedLibrary logic is incorrect #10050

@mpickering

Description

@mpickering

Consider the which determines whether we should build shared libraries.

      pkgsUseSharedLibrary :: Set PackageId
      pkgsUseSharedLibrary = 
        packagesWithLibDepsDownwardClosedProperty needsSharedLib
        where
          needsSharedLib pkg =
            fromMaybe
              compilerShouldUseSharedLibByDefault
              (liftM2 (||) pkgSharedLib pkgDynExe)
            where
              pkgid = packageId pkg
              pkgSharedLib = perPkgOptionMaybe pkgid packageConfigSharedLib
              pkgDynExe = perPkgOptionMaybe pkgid packageConfigDynExe

In English the intended logic is:

If we have enabled shared libraries or dynamic executables then we need shared libraries for all dependencies.

but, a common mistake:

(liftM2 (||) pkgSharedLib pkgDynExe)

instead says, if we explicitly request shared libraries and also explicitly configure whether we want dynamic executables then

It should instead use the monoid instance:

getMax <$> ((Max <$> pkgSharedLib) <> (Max <$> pkgDynExe))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions