travis haskell builds failing with linking error - haskell

for some time, the travis builds of my little haskell app are failing with a cryptic link error:
$ cabal configure --enable-tests && cabal build && cabal test
Resolving dependencies...
[1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
/usr/lib/ghc/unix-2.5.1.0/libHSunix-2.5.1.0.a(execvpe.o): In function `pPrPr_disableITimers':
(.text+0x320): multiple definition of `pPrPr_disableITimers'
/home/travis/.cabal/lib/x86_64-linux-ghc-7.4.1/unix-2.7.1.0/libHSunix-2.7.1.0.a(ghcrts.o):ghcrts.c:(.text+0x0): first defined here
collect2: ld returned 1 exit status
The command "cabal configure --enable-tests && cabal build && cabal test" exited with 1.
Done. Your build exited with 1.
The builds work fine on my machine. Is there anything I can tune in my .travis.yml file to fix the issue there?

In my experience, this is usually caused by having multiple versions of a library in your dependency tree, which cabal configure allows while cabal install will not. I don't see evidence of that in your build log, but it might theoretically be happening. You can try changing cabal configure to cabal install and see what happens.

So, first I'm on the legacy travis system, I guess I need to go on the new one. But that one requires much more thorough config I think. Second on the legacy system, ghc 7.10 is not supported: stackoverflow.com/questions/29516932/… I had configured 7.10 but didn't realize that didn't work, and since travis didn't recognize the ghc version, it just put me the oldest, 7.4. So I reverted to 7.8 for now, and the error is now different and more understandable.
So the root cause for weird error was being fallback to the relatively ancient ghc 7.4 due to my misconfiguration.

Related

GHC linker cannot find lHSsemigroups

I'm attempting to compile a Haskell project on Windows with profiling enabled, using the following command.
ghc --make -O -prof -fprof-auto game_dangerous.hs
I develop the project myself and the same source code compiled and linked fine without profiling. As expected (from previous experience) I ran into a number of errors of the form:
Could not find module `Data.Vector.Mutable'
Perhaps you haven't installed the profiling libraries for package `vector-0.12.0.2'?
I proceeded to iteratively reinstall packages based on the errors encountered using for example:
cabal install -p vector --reinstall
Cabal kept giving me warnings about possibly breaking packages with the reinstalls but I pressed on as (as far as I could see) every package that could be broken was going to get reinstalled itself as I moved through the tree of dependencies. Also, I've previously followed the same process on another machine and it worked fine. After reinstalling all the required packages my project now compiles but the linker fails with this error:
C://Program Files//Haskell Platform//8.6.3//mingw//bin/ld.exe: cannot find -lHSsemigroups-0.18.5-8pPnWqWrcWhEagTFf5Pnk2_p
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
However, the build does complete successfully without profiling enabled. Does anyone know what may have gone wrong and how to fix the issue? Thanks in advance.
Steven
I would try making a .cabal file for your program, where you explicitly specify the cabal packages your program depends on and use cabal v2-build to compile your program. It will warn you about missing dependencies of your program until you include them all in build-depends section of the .cabal file. You only need to include the dependencies of your program, not the dependencies of the dependencies. After that you can add cabal.project.local to enable profiling and maybe something else. It should be enough to run cabal v2-build to build your program and packages it depends on with profiling(and other options in the cabal.project.local) enabled.
You need to have profiling enabled in the packages used by your program to support profiling in it. Cabal v2 builds allows you to have multiple instances of the same package. Those instances are different because different flags and options have been used to build them.
It is possible to achieve the same result using a separate package database for your program. That is using ghc-pkg with --package-db option.
Another option is to use stack. It will solve the same issues, but differently at the cost of more space and some performance penalties in ghc(compared to ghc built from source which can be used with cabal).

Haskell cabal: C compiler cannot create executables

I'm trying to install ghc-mod for GHC 8.0.1 on windows/x64. When I try to install ghc-mod via cabal install ghc-mod I get an error saying my C compiler isn't working (it is using the c-compiler bundled with ghc).
Here is the output (of the second time I ran the command. Its basically what the first one says but reduced to the error message):
C:\Users\******>cabal install ghc-mod
Resolving dependencies...
Configuring old-time-1.1.0.3...
Failed to install old-time-1.1.0.3
Build log ( C:\Users\******\AppData\Roaming\cabal\logs\old-time-1.1.0.3.log ):
Configuring old-time-1.1.0.3...
bash.exe: warning: could not find /tmp, please create!
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... C:\PROGRA~1\Haskell Platform\8.0.1\mingw\bin\gcc.exe
^ I think the error lies here, as you can see the file path is corrupted but I wasn't able to locate the cause for this
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/******/AppData/Local/Temp/cabal-tmp-6084/old-time-1.1.0.3':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\Users\******\AppData\Local\Temp\cabal-tmp-6084\old-time-1.1.0.3'
cabal: Error: some packages failed to install:
cpphs-1.20.2 depends on old-time-1.1.0.3 which failed to install.
ghc-mod-5.6.0.0 depends on old-time-1.1.0.3 which failed to install.
haskell-src-exts-1.17.1 depends on old-time-1.1.0.3 which failed to install.
hlint-1.9.35 depends on old-time-1.1.0.3 which failed to install.
old-time-1.1.0.3 failed during the configure step. The exception was:
ExitFailure 77
Could you please help me to install ghc-mod or provide any other way of installing it.
I already trieded reinstalling Haskell since I'm just starting off but this didn't make any difference.
And YES I added the 3 lines provided on the haskell homepage.
I can't know for certain, but thought I'd write an answer with what I think is going on.
The old-time package contains a configure script, which is a Unix shell script used to (surprise!) configure the package. The Cabal build system allows packages to automatically integrate configure, and will run the script for them. On POSIX systems, there's always a shell easily available. However, on Windows, that's not the case. I believe that's the problem you're running into.
Now the tricky part: why don't you have a shell? In theory, the Haskell Platform ships a shell. Well, here are my guesses:
For Stack usage, there's a Haskell Platform bug where Stack cannot find the MSYS tools, which include the shell script. Newer versions of Stack work around this bug, but passing in --no-system-ghc tells Stack to ignore any installed toolchain and manage the installation itself, which is more reliable than using HP's copy.
For Cabal usage, I'm less certain. I think the HP team decided to require you to use a special batch program to set environment variables correctly, so if you just run cabal install foo from a normal command window, Cabal won't find MSYS and it will fail. However, without more information, I can't be certain this is the case.
My personal recommendation: uninstall Haskell Platform, and use the recommended Stack installation instructions. In your case, that's just downloading and running the 64-bit Windows installer.
Finally: your suspected problem is not actually a problem; on Windows, pathnames longer than 8 characters can be compressed in the way you see (with ~1 at the end). There's nothing buggy in that path display.

MacOSX - cabal install: built failed during the building phase. The exception was: ExitFailure 1 - dist/package.conf.inplace: inappropriate type

using cabal; came accross this error.
did cabal install and this happened.
failed during the building phase. The exception was:
ExitFailure 1
checked my log; it said:
dist/package.conf.inplace:
inappropriate type
I have 0 ideas what's going on. cabal build works though. #STRANGE
CURRENTLY:
CABAL version: 1.22.0.0. Glorious Glasgow Haskell Compilation version: 7.8.4
Possible explanation: you have upgraded GHC to 7.10, which does things a bit differently I gather, but not upgraded cabal-install. If this is the problem, running
cabal install cabal-install -w ghc-7.8.4 # or whatever other version of GHC you have
may fix the problem.
You can get this error if you previously built your package with an older (or newer) version of Cabal and now are building with a newer (or older) version.
Not enough information to determine whether this is the problem in your case.
If it is, I think cabal clean should fix it (though I usually just rm -rf dist).

How do I install dependencies when cross compiling haskell code?

I've successfully created a ghc cross compiler, that allows me to compile haskell code for armv6h (raspberry pi in my case) from my x64 linux machine.
I've successfully run a hello world program on the raspberry.
No I want to build my real app, which has a lot of dependencies on other haskell modules.
When I compile for x64 I simply do
cabal install dependenciy1 depenency2 ...
I know I could make my own programm a cabal-project an automate this step. But that's not the point here.
When I try to use the cross-compiler
arm-unknown-linux-gnueabi-ghc --make myapp.hs
It tells me about modules it could not find. Of course, they are not installed!
I read https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling
and according to that I tried
cabal --with-ghc=arm-unknown-linux-gnueabi-ghc --with-ghc-pkg=arm-unknown-linux-gnueabi-ghc-pkg --with-ld=arm-unknown-linux-gnueabi-ld install random
random is the depenency I'm trying to install here. I get the following error:
Resolving dependencies...
Configuring random-1.0.1.3...
Failed to install random-1.0.1.3
Last 10 lines of the build log ( /home/daniel/.cabal/logs/random-1.0.1.3.log ):
/home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804: /home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804: cannot execute binary file
cabal: Error: some packages failed to install:
random-1.0.1.3 failed during the configure step. The exception was:
ExitFailure 126
When I do
file /home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804
I get
/home/daniel/.cabal/setup-exe-cache/setup-Cabal-1.18.1.3-arm-linux-ghc-7.8.3.20140804: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.10.2, not stripped
No wonder it can't execute it. It's compiled for arm.
Am I missing something here?
My goal is to pull in all dependencies, then create a statically linked app that I can deploy on my raspberry.
To understand this error, you need to know how cabal install works internally. In essence, it will perform the following steps:
Download and unpack the source code
Compile Setup.hs (this file is used for customization of the build system, for example, you can implement some hooks to run additional haskell code in the configure phase).
Run setup configure <configure flags> && setup build && setup install
The problem is now that cabal install uses the GHC given by --with-ghc also for step 2, but the executable produced by that step must run on the host system!
A workaround is to do the steps manually, which means you have full control. First, get the source:
$ cabal get random
Downloading random-1.0.1.3...
Unpacking to random-1.0.1.3/
$ cd random-1.0.1.3
Then, compile Setup.hs, using the host ghc:
$ ghc ./Setup.hs -o setup
And finally, configure, build and install. As suggested by #Yuras in a comment, we also add the -x option for running hsc2hs:
$ ./setup configure ----with-ghc=arm-unknown-linux-gnueabi-ghc --with-ghc-pkg=arm-unknown-linux-gnueabi-ghc-pkg --with-ld=arm-unknown-linux-gnueabi-ld --hsc2hs-options=-x
$ ./setup build && ./setup install
There is already a cabal issue about this: https://github.com/haskell/cabal/issues/2085

haskell snap exitfailure 1

I am new to Haskell, and wanted to play around with snap framework. Unfortunately I just cant get the thing to compile. I've tried (all I know too), updating cabal and running sudo ghc-pkg recache but I still get the following when I run cabal install snap. Please help.
12 warnings and 1 error generated.
Failed to install binary-0.7.1.0
cabal: Error: some packages failed to install:
SHA-1.6.4 depends on binary-0.7.1.0 which faile
d to install.
binary-0.7.1.0 failed during the building phase
. The exception was:
ExitFailure 1
pwstore-fast-2.4.1 depends on binary-0.7.1.0 wh
ich failed to install.
snap-0.13.2.2 depends on binary-0.7.1.0 which f
ailed to install.
Solution:
I first install the 'real' gcc via homebrew like so:
brew update
brew install gcc47
This took a while to install (as in over an hour). Once it was done I updated the GHC settings to use the copy of gcc installed by homebrew.
GHC settings are located either here :
/Library/Frameworks/GHC.framework/Versions/Current/usr/lib/ghc-7.6.3/settings
or here if you installed ghc with homebrew (I did not).
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/settings
Update the line
("C compiler command", "/usr/bin/gcc")
to
("C compiler command", "/usr/local/Cellar/gcc47/4.7.3/bin/gcc-4.7")
Then just run
cabal update && cabal install snap
and all should be well. :)
Your problem is that the binary package has some C preprocessor constructs that are not strictly valid.
After looking around a bit, I found a similar problem somebody had when installing the Haskell platform. It seems the core issue is that the Clang C preprocessor is stricter than the GCC one most Haskellers use. I'm assuming that this is your problem: you're using Clang rather than GCC. If you're on OS X, this is the default choice.
The easiest solution seems to be to switch to using GCC for the preprocessing. Note that on OS X, /usr/bin/gcc actually points to Clang! You will need to point GHC to an actual install of GCC.
You can do this by editing GHC's configuration file. On my system it's found at
/usr/local/lib/ghc-7.6.3/settings
Yours is probably somewhere similar, although I'm on Linux rather than OS X. In the file, change
("C compiler command", "/usr/bin/gcc")
to point to an actual copy of gcc rather than Clang and try installing again.
In the long run, this feels like a bug with the package and probably needs to be addressed, although I don't really know enough about the issue or constraints package authors have to be sure.

Resources