Closed theobat closed 4 years ago
Also, I forgot to precise, but I tried both with stack install and git clone && stack build in the cloned repo
So it seems to be narrower than I first thought, if you remove the if lines near line 248 (like I did in my fork: https://github.com/theobat/halive/commit/6e67493a3b4a420bae302625747dade2719e9e21), it seems to compile without problems, but trying to run the binary yield another error:
/app/.local/bin/halive: error while loading shared libraries: libHShalive-0.1.6-9VMAdJSePEBBqGa1oiSZTr-ghc8.6.5.so: cannot open shared object file: No such file or directory
This might be because I used a more recent version of GHC than the one used in this repo.
Now it works, simply use --ghcOptions=" -fPIC -fasm" (see this), the issue is with dynamic linking.
The reason why this specific #else fails at the parsing stage is beyond my understanding (-yet). It needs a deeper knowledge of stack/the cpp extension/ghc itself ...
Running stack build halive --ghc-options="-fPIC -fasm"
still fails for me:
halive> configure
halive> Configuring halive-0.1.6...
halive> build
halive> Preprocessing library for halive-0.1.6..
halive> Building library for halive-0.1.6..
halive> [1 of 8] Compiling Halive.Args
halive> [2 of 8] Compiling Halive.Concurrent
halive> [3 of 8] Compiling Halive.FileListener
halive> [4 of 8] Compiling Halive.FindPackageDBs
halive> [5 of 8] Compiling Halive.SubHalive
halive>
halive> /tmp/stack2801/halive-0.1.6/src/Halive/SubHalive.hs:248:17: error: parse error on input ‘#’
halive> |
halive> 248 | #else
halive> | ^
halive>
-- While building package halive-0.1.6 using:
/home/anton/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1 build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Yeah I stopped using this and just made a dummy bash file which kills & restart the stack build process in my docker container... (which is obviously worse performance wise) The CPP pre-processor is a hack so I forsake fixing the repo (+ lack of time to do it properly)
After doing some research I came upon this reddit post, which presents two solutions: ghcid and yesod-bin. I managed to get yesod-bin to work perfectly for me using this example, although your use-case may be different.
This very compilation error is also the reason that halive
is marked as broken on nixpkgs
:
nix-repl> :b haskellPackages.halive
builder for '/nix/store/mk13jiivs3a080zb085i8r7ld1y3rg7x-halive-0.1.6.drv' failed with exit code 1; last 10 log lines:
[2 of 8] Compiling Halive.Concurrent ( src/Halive/Concurrent.hs, dist/build/Halive/Concurrent.o )
[3 of 8] Compiling Halive.FileListener ( src/Halive/FileListener.hs, dist/build/Halive/FileListener.o )
[4 of 8] Compiling Halive.FindPackageDBs ( src/Halive/FindPackageDBs.hs, dist/build/Halive/FindPackageDBs.o )
[5 of 8] Compiling Halive.SubHalive ( src/Halive/SubHalive.hs, dist/build/Halive/SubHalive.o )
src/Halive/SubHalive.hs:248:17: error: parse error on input ‘#’
|
248 | #else
| ^
[8 of 8] Compiling Halive.Utils ( src/Halive/Utils.hs, dist/build/Halive/Utils.o )
[0 built (1 failed), 59 copied (702.4 MiB), 35.6 MiB DL]
error: build of '/nix/store/mk13jiivs3a080zb085i8r7ld1y3rg7x-halive-0.1.6.drv' failed
The resolution is just a 3 line fix. The indentation of the CPP is simply wrong. PR impending.
Here's the issue I'm struggling with right now:
And my cpp :
It makes absolutely no sense to me (I unerstand the preprocessor is not doing its job correctly, but is it the cpp preprocessor, or the ghc one ?) if somebody's got any direction I'll take it ...