Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS fails on complex project #3780

Closed
k355l3r-5yndr0m3 opened this issue Aug 28, 2023 · 8 comments
Closed

HLS fails on complex project #3780

k355l3r-5yndr0m3 opened this issue Aug 28, 2023 · 8 comments
Labels
status: needs info Not actionable, because there's missing information type: support User support tickets, questions, help with setup etc.

Comments

@k355l3r-5yndr0m3
Copy link

I have a project that I am working on that is quite complex. The build-type is custom, and Setup.hs uses the autoconfUserhooks so it also generate a .buildinfo file.
The configure build-type could not be used because I uses Setup.hs to generate the project's autogen modules.
There are two issues. The auto generated modules are not created and must be manually copied from dist-newstyle to the corresponding directory in hie-bios, and the buildinfo file appears to be ignored.
The project builds fine, but hls cannot be used.

@k355l3r-5yndr0m3 k355l3r-5yndr0m3 added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Aug 28, 2023
@fendor
Copy link
Collaborator

fendor commented Aug 28, 2023

Hi, thank you for your bug report!

Does cabal repl succeed in your project?

Can you reduce your project to a minimal reproducer and post it, so we can have a look at it?

@k355l3r-5yndr0m3
Copy link
Author

minimal.zip
The configure script generate a buildinfo file with the buildable flag set to false, yet hls is not aware of this. Adding buildable: False to the .cabal file produces the correct behavior. This apply to other flags too.
The Setup script create a module called Autogen, which hls cannot locate.

@fendor
Copy link
Collaborator

fendor commented Aug 29, 2023

I am not sure if we can help with the configure script, I don't know enough about Cabal to know what's going on here.

What behaviour would you expect?

Re the Setup.hs, iirc, preBuildHook is only run if you execute cabal build. However, HLS calls cabal repl to find the compilation options. If you manage to generate the module also on cabal repl, perhaps via the preReplHook, that could work.

@k355l3r-5yndr0m3
Copy link
Author

Generating the modules at preRepl does solve the autogenerated module issue.
As for the configure script issue, I use it to resolve the include paths and library paths. My project deals with a lot of C code. I've been adding the paths specific to my system to the cabal file as a workaround.
cabal build run without error, but cabal repl fails because it could not find the header files.

@michaelpj
Copy link
Collaborator

As Fendor says, we rely on cabal repl to find the build flags. If cabal repl doesn't work, HLS won't work. I'm not sure how to make cabal repl work for your project, but that's more of a cabal issue than a HLS issue.

@michaelpj michaelpj added type: support User support tickets, questions, help with setup etc. status: needs info Not actionable, because there's missing information and removed type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Aug 29, 2023
@michaelpj
Copy link
Collaborator

Meta-issue: ideally if someone gets a cradle failure it would be very clear that we ran cabal repl and that we need to do that in order to get the build flags, and they should try and fix it if it's broken.

@AleXoundOS
Copy link

AleXoundOS commented Nov 6, 2023

cabal build run without error, but cabal repl fails

This seems to be a cabal issue. I face the same issue with cabal 3.10.1.0.
1. `build-type: Configure`
2. `configure` script generates `PROJ.buildinfo` file with `cpp-options: -DMYDEF=1` contents
3. haskell code uses `CPP` extension to access `MYDEF`
4. `cabal build` successfully builds the project
5. `cabal repl` fails with `Data constructor not in scope` for `MYDEF`

@michaelpj
Copy link
Collaborator

Closing as mostly-expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs info Not actionable, because there's missing information type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

No branches or pull requests

4 participants