Also... I just tried. It doesn't work with cabal v2-build, because you also have to install the libraries of the plugins first via cabal v2-install, but v2-install has different semantics than v2-build in the sense that it caches only by PVP version and flags, not tarball hashes (remember: v2-instaall does an sdist before compilation and also ignores cabal.project mostly, which is another problem). So you could get cache hits where you don't want them.
A way around that would be to set a clean store-dir, but that will increase build times a lot.
could be another alternative use a custom cabal.project.local with dynamic enabled and use it with ghcup compile hls --cabal-project-local=/path/to/cabal-dynamic.project.local?
A possible generic way to do it could be add some way to pass args to cabal:
with a dedicate cli option --build-options="--enable-executable-dynamic"
or take all args after -- as options to be passed to cabal
and run cabal configure <options> to create a cabal.project.local on the fly before doing the build
It could be extended to all tools compilable with ghcup.
It would be somewhat incompatible with --cabal-project-local as afaik cabal configure would overwrite it.
Thoughts @maerwald?
FWIW: Ran into this issue, would like to voice support for proposed changes.
It's easy enough to fix if you pass manual overrides, but it's effected enough people that IMO the explicit option should mostly serve as a warning sign for folks to catch this early before sinking time debugging.
If I see there's an option in ghcup to compile HLS dynamically, particularly if it has [RECOMMENDED] or similar and a description of what problems it can cause, then perhaps that avoids me filing issues and wasting other people's time.
See below for large list of open HLS issues returned with search: static OR dynamic OR linking (which should be an approximation, probably few false-positives):
@GavinRay97 hi! it seems to me the comment belongs more to the hls project issue tracker. ghcup distributes the prebuilt binaries generated in the hls repo (with ghcp install hls) and additionally it offers the option of build hls from source with ghcup compile hls. So ghcup itself does not decide how are built hls binaries (like it does not decide how ghc binaries are built)
This issue is requesting make slightly easier built hls dinamically linked with ghcup compile hls.
return to use cabal install for ghcup compile hls (it would fix #251 as well)
use a dedicated cabal store in a temp dir for building hls as proposed by @maerwald to workaround the cabal install bug related wih cache invalidation. But only when hls is building from a git checkout (not from hackage) as afaiu the bug will not be triggered in that case
investigate the cabal bug and identify an existing issue or create a new one, trying to fix it asap