kosmikus / lhs2tex

Preprocessor for typesetting Haskell sources with LaTeX
Other
99 stars 28 forks source link

Fail to link/install lhs2tex-1.24 #84

Closed mouse07410 closed 4 years ago

mouse07410 commented 4 years ago

MacOS 10.15.5, Xcode-11.5, GHC-8.8.3 and GHC-8.10.1, Cabal-3.2.0.0, lhs2tex-1.24.

I stumbled upon lhs2tex package in the process of installing Agda https://github.com/agda/Agda.git. It seemed to install fine - but during my fight with Agda (and some other packages) Cabal store apparently got damaged. After wiping it and re-installing whatever executables I needed, I'm trying to install lhs2tex, but now it fails to link:

$ cabal --config-file=/Users/ur20980/.cabal/static-config install lhs2tex -w ghc-8.10.1 --verbose 2>&1 | tee lhs-out.txt
. . . . .
creating dist/build/lhs2TeX/lhs2TeX-tmp
/Users/ur20980/.ghcup/bin/ghc-8.10.1 --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/lhs2TeX/lhs2TeX-tmp -odir dist/build/lhs2TeX/lhs2TeX-tmp -hidir dist/build/lhs2TeX/lhs2TeX-tmp -stubdir dist/build/lhs2TeX/lhs2TeX-tmp -i -idist/build/lhs2TeX/lhs2TeX-tmp -isrc -idist/build/lhs2TeX/autogen -idist/build/global-autogen -Idist/build/lhs2TeX/autogen -Idist/build/global-autogen -Idist/build/lhs2TeX/lhs2TeX-tmp -I/opt/local/include -I/usr/local/include -optP-include -optPdist/build/lhs2TeX/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /Users/ur20980/.cabal/store/ghc-8.10.1/package.db -package-db dist/package.conf.inplace -package-id base-4.14.0.0 -package-id directory-1.3.6.0 -package-id filepath-1.4.2.1 -package-id mtl-2.2.2 -package-id process-1.6.8.2 -package-id rgx-cmpt-0.95.2.0-bb9c9fa7 -XHaskell98 src/Main.lhs Auxiliaries Directives Document FileNameUtils FiniteMap HsLexer License MathCommon Math MathPoly NewCode Parser State StateT TeXCommands TeXParser Typewriter Value Verbatim Version -Wall -hide-all-packages
[ 1 of 21] Compiling Auxiliaries      ( src/Auxiliaries.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Auxiliaries.o )
[ 2 of 21] Compiling Document         ( src/Document.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Document.o )
[ 3 of 21] Compiling FileNameUtils    ( src/FileNameUtils.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/FileNameUtils.o )
[ 4 of 21] Compiling FiniteMap        ( src/FiniteMap.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/FiniteMap.o )
[ 5 of 21] Compiling Parser           ( src/Parser.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Parser.o )
[ 6 of 21] Compiling StateT           ( src/StateT.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/StateT.o )
[ 7 of 21] Compiling TeXCommands      ( src/TeXCommands.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/TeXCommands.o )
[ 8 of 21] Compiling HsLexer          ( src/HsLexer.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/HsLexer.o )
[ 9 of 21] Compiling TeXParser        ( src/TeXParser.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/TeXParser.o )
[10 of 21] Compiling Value            ( src/Value.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Value.o )
[11 of 21] Compiling Directives       ( src/Directives.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Directives.o )
[12 of 21] Compiling Verbatim         ( src/Verbatim.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Verbatim.o )
[13 of 21] Compiling Typewriter       ( src/Typewriter.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Typewriter.o )
[14 of 21] Compiling MathCommon       ( src/MathCommon.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/MathCommon.o )
[15 of 21] Compiling MathPoly         ( src/MathPoly.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/MathPoly.o )
[16 of 21] Compiling NewCode          ( src/NewCode.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/NewCode.o )
[17 of 21] Compiling Math             ( src/Math.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Math.o )
[18 of 21] Compiling Version          ( src/Version.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Version.o )
[19 of 21] Compiling State            ( src/State.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/State.o )
[20 of 21] Compiling License          ( src/License.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/License.o )
[21 of 21] Compiling Main             ( src/Main.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Main.o )
Linking...
/Users/ur20980/.ghcup/bin/ghc-8.10.1 --make -fbuilding-cabal-package -O -static -outputdir dist/build/lhs2TeX/lhs2TeX-tmp -odir dist/build/lhs2TeX/lhs2TeX-tmp -hidir dist/build/lhs2TeX/lhs2TeX-tmp -stubdir dist/build/lhs2TeX/lhs2TeX-tmp -i -idist/build/lhs2TeX/lhs2TeX-tmp -isrc -idist/build/lhs2TeX/autogen -idist/build/global-autogen -Idist/build/lhs2TeX/autogen -Idist/build/global-autogen -Idist/build/lhs2TeX/lhs2TeX-tmp -I/opt/local/include -I/usr/local/include -optP-include -optPdist/build/lhs2TeX/autogen/cabal_macros.h -L/opt/local/lib/liconv -L/opt/local/lib -L/usr/local/lib -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /Users/ur20980/.cabal/store/ghc-8.10.1/package.db -package-db dist/package.conf.inplace -package-id base-4.14.0.0 -package-id directory-1.3.6.0 -package-id filepath-1.4.2.1 -package-id mtl-2.2.2 -package-id process-1.6.8.2 -package-id rgx-cmpt-0.95.2.0-bb9c9fa7 -XHaskell98 src/Main.lhs Auxiliaries Directives Document FileNameUtils FiniteMap HsLexer License MathCommon Math MathPoly NewCode Parser State StateT TeXCommands TeXParser Typewriter Value Verbatim Version -o dist/build/lhs2TeX/lhs2TeX -Wall -hide-all-packages
Linking dist/build/lhs2TeX/lhs2TeX ...
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/lhs2TeX.sty --code lhs2TeX.sty.lit
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/lhs2TeX.fmt --code lhs2TeX.fmt.lit
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/HelloWorldInput.tex --verb -Pdoc: dist/build/lhs2TeX/doc/HelloWorldInput.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/HelloWorldDialogue.tex --verb -Pdoc: dist/build/lhs2TeX/doc/HelloWorldDialogue.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/HelloWorld.tex --poly -Pdoc: dist/build/lhs2TeX/doc/HelloWorld.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/HackageInstallation.tex --tt -Pdoc: dist/build/lhs2TeX/doc/HackageInstallation.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/CabalInstallation.tex --tt -Pdoc: dist/build/lhs2TeX/doc/CabalInstallation.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/InstallationInstructions.tex --tt -Pdoc: dist/build/lhs2TeX/doc/InstallationInstructions.lhs
. . . . .
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/CalcExample.tex --poly -Pdoc: dist/build/lhs2TeX/doc/CalcExample.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/InteractiveGhciIn.tex --verb -Pdoc: dist/build/lhs2TeX/doc/InteractiveGhciIn.lhs
dist/build/lhs2TeX/lhs2TeX -Pdist/build/lhs2TeX: -odist/build/lhs2TeX/doc/InteractiveGhci.tex --poly -Pdoc: dist/build/lhs2TeX/doc/InteractiveGhci.lhs
CallStack (from HasCallStack):
  die', called at ./Distribution/Client/ProjectOrchestration.hs:1041:55 in main:Distribution.Client.ProjectOrchestration
cabal: Failed to build lhs2tx-1.24-e7db739f.

Build log lhs2tx-1.24-e7db739f.log

This is with GHC-8.10.1, but I'm getting the same error with GHC-8.8.3.

Config file: static-config.txt Needless to say, attempt to build dynamic executable (as pretty much everything on my system is built) failed the same way.

kosmikus commented 4 years ago

Hmm, this looks like a cabal-install bug. What version of cabal-install is this?

One point worth noting is that at this point in the build process lhs2TeX is already successfully built. So you might just be able to manually copy dist/build/lhs2TeX/lhs2TeX to a bin directory. But then you probably need some other files (that lhs2TeX will be looking for) copied to the right directories as well ...

mouse07410 commented 4 years ago

What version of cabal-install is this?

$ cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library

at this point in the build process lhs2TeX is already successfully built...

Alas, I don't think so (see below).

you might just be able to manually copy dist/build/lhs2TeX/lhs2TeX to a bin directory

Ah... You mean - clone this repo, build it from there (so dist-newstyle subdir doesn't get destroyed when the build process finishes), and manually copy...?

Well, that did not go too well. Cloning the repo was fine, but there's nothing built, it appears - as there's no evidence in the log that the build actually completed:

$ cabal --config-file=/Users/ur20980/.cabal/static-config install -w ghc-8.10.1
Wrote tarball sdist to
/Users/ur20980/src/lhs2tex/dist-newstyle/sdist/lhs2tex-1.24.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
 - lhs2tex-1.24 (exe:lhs2TeX) (requires build)
Starting     lhs2tex-1.24 (all, legacy fallback)
Building     lhs2tex-1.24 (all, legacy fallback)

Failed to build lhs2tex-1.24.
Build log ( /Users/ur20980/.cabal/logs/ghc-8.10.1/lhs2tx-1.24-49799dd0.log ):
[1 of 1] Compiling Main             ( /var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/cabal-install.-39171/dist-newstyle/tmp/src-39171/lhs2tex-1.24/dist/setup/setup.hs, /var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/cabal-install.-39171/dist-newstyle/tmp/src-39171/lhs2tex-1.24/dist/setup/Main.o )
Linking /var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/cabal-install.-39171/dist-newstyle/tmp/src-39171/lhs2tex-1.24/dist/setup/setup ...
Configuring lhs2tex-1.24...
Preprocessing executable 'lhs2TeX' for lhs2tex-1.24..
Building executable 'lhs2TeX' for lhs2tex-1.24..
[ 1 of 21] Compiling Auxiliaries      ( src/Auxiliaries.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Auxiliaries.o )
[ 2 of 21] Compiling Document         ( src/Document.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Document.o )
[ 3 of 21] Compiling FileNameUtils    ( src/FileNameUtils.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/FileNameUtils.o )
[ 4 of 21] Compiling FiniteMap        ( src/FiniteMap.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/FiniteMap.o )
[ 5 of 21] Compiling Parser           ( src/Parser.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Parser.o )
[ 6 of 21] Compiling StateT           ( src/StateT.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/StateT.o )
[ 7 of 21] Compiling TeXCommands      ( src/TeXCommands.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/TeXCommands.o )
[ 8 of 21] Compiling HsLexer          ( src/HsLexer.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/HsLexer.o )
[ 9 of 21] Compiling TeXParser        ( src/TeXParser.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/TeXParser.o )
[10 of 21] Compiling Value            ( src/Value.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Value.o )
[11 of 21] Compiling Directives       ( src/Directives.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Directives.o )
[12 of 21] Compiling Verbatim         ( src/Verbatim.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Verbatim.o )
[13 of 21] Compiling Typewriter       ( src/Typewriter.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Typewriter.o )
[14 of 21] Compiling MathCommon       ( src/MathCommon.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/MathCommon.o )
[15 of 21] Compiling MathPoly         ( src/MathPoly.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/MathPoly.o )
[16 of 21] Compiling NewCode          ( src/NewCode.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/NewCode.o )
[17 of 21] Compiling Math             ( src/Math.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Math.o )
[18 of 21] Compiling Version          ( src/Version.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Version.o )
[19 of 21] Compiling State            ( src/State.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/State.o )
[20 of 21] Compiling License          ( src/License.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/License.o )
[21 of 21] Compiling Main             ( src/Main.lhs, dist/build/lhs2TeX/lhs2TeX-tmp/Main.o )
Linking dist/build/lhs2TeX/lhs2TeX ...
lhs2TeX: fd:7: hGetLine: end of file
cabal: Failed to build lhs2tex-1.24. See the build log above for details.

It tried to read some kind of file (neither the build process, not Cabal itself tell which one), some read fails before finding whatever it wanted from that file - and the build aborts without actually linking anything.

$ find dist-newstyle -name 'lhs2*' -print
dist-newstyle/sdist/lhs2tex-1.24.tar.gz
$ 

But then you probably need some other files (that lhs2TeX will be looking for) copied to the right directories as well

Yes, I'm sure that would be required. Any guidance wrt. what files I should copy, and where to (to use if/when the build succeeds)? Thanks!

mouse07410 commented 4 years ago

You wouldn't believe what helped building and installing lhs2TeX successfully! I had to set GHC_ENVIRONMENT=-, after which install succeeded.

I don't understand why a cloned repo still pulls sdist lhs2tex-1.24.tar.gz instead of using the current sources, but I don't really need to know, and I'm probably not at the level to be on the bleeding edge playing with the unreleased packages.

kosmikus commented 4 years ago

I'm glad you solved it. I must admit that there are many things about your setup I don't understand right now. Anyway, it currently seems to me that none of your problems are actually lhs2TeX-specific, so I'm going to close this. Feel free to reopen if you experience more problems.

mouse07410 commented 4 years ago

I must admit that there are many things about your setup I don't understand right now

Such as...? Please feel free to ask, e.g., here.

The main difference between my setup and what the majority is doing is that all of my builds are configured to be dynamic (several reasons for that), by setting in ~/.cabal/config:

shared: True
executable-dynamic: True

But when I suspect that something could be wrong with the build - I have a similar configuration that does not set shared and executable-dynamic, so I can have a "normal" ("traditional") build, similar to what most of the other people do. That's ~/.cabal/static-config file, reference to which you see in the above logs. There's a couple of executable I built on my system using static-config - but those are the exception, most of the stuff is dynamic.

And to address some incompatibilities between the installed libiconv libraries, I define

extra-lib-dirs: /opt/local/lib/liconv,/opt/local/lib,/usr/local/lib

to ensure that Haskell executables/libraries built by Cabal/GHC would link against the same libiconv.dylib that distributed binary libHSBase was linked against. This is the issue with using Macports or Brew on Mac - I think some package managers on Linux also cause this problem and necessitate this solution.

Feel free to reopen if you experience more problems

Sure, thanks. I hope I won't need to. ;-)