Skip to content

The ghc-options are not passed to the linker #9589

@alt-romes

Description

@alt-romes

While fixing a bug that turned out to be another case of #7339, I realized that the ghc-options field is not being passed to a linker invocation of ghc after having compiled the haskell modules and extra build sources (see buildOrReplLib).

You can see that the linker options e.g. start from mempty instead of baseOpts (where baseOpts has already added to ghcOptExtra the ghc-options specified in the cabal file or flags). This happens for ghcSharedOpts, however, the ghcOptExtra seems to be added in that case. I haven't further diagnosed.

      linkerOpts =
+      -- (Shouldn't this be `baseOpts` as well? If not,
+      -- then ghcOptsExtra is not being considered in the linker invocation.)
-      mempty
+      baseOpts
          { ghcOptLinkOptions =
              PD.ldOptions libBi
                ++ [ "-static"
                   | withFullyStaticExe lbi

The initial attempted fix (that turned out to be fixed by the patch that fixed #7339) was to add

ghc-options: -optc-Wl,-rpath,/path...

which did not work because, even though it gets passed to the ghc --make invocation that compiles haskell modules, it does not get passed on to the linker invocation that links them together.

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