Skip to content

loadArchive failed on .dll.a with Template Haskell #4908

@ruifengx

Description

@ruifengx

Your environment

Which OS do you use?
Windows 11 25H2 (internal version 26200.8246)

Which version of GHC do you use and how did you install it?
GHC 9.14.1 from GHCup

How is your project built (alternative: link to the project)?
Cabal 3.16

Which LSP client (editor/plugin) do you use?
VSCode + Haskell plugin

Which version of HLS do you use and how did you install it?
HLS 2.13.0.0 from GHCup

Have you configured HLS in any way (especially: a hie.yaml file)?
No

Steps to reproduce

  • Pull in a C library dependency (e.g., via pkg-config-depends: libclang)
  • Install mingw-w64-x86_64-clang-libs in MSYS2 and set PKG_CONFIG_PATH accordingly
  • Load any Haskell source file with a Template Haskell splice
  • Encounter the error loadArchive: failed for libclang.dll.a

Expected behaviour

No error should occur.

Actual behaviour

HLS reports an error loadArchive: failed for the library dependency libclang.dll.a.

Debug information

Removing libclang.dll.a from MSYS2 forces pkg-config (and in turn Cabal and GHC) to fall back to the static library libclang.a, and the error disappears. Therefore, I suspect that using -optl-static could also solve the problem, but I do want to link with the dynamic libraries for the application in this case. I guess the problem is that GHC cannot load import libraries like libclang.dll.a (or it cannot find the corresponding libclang.dll which provides the actual code).

I wonder if there is any option to proivide compiler/linker options (-optl-static in this case) to HLS only (and not Cabal/GHC at build time), because messing with MSYS2 library files seems a really fragile workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    os: windowstype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions