2

These are the linker errors I get:

happy-1.19.5: configure
cpphs-1.20.2: download
th-reify-many-0.1.6: download
time-qq-0.0.1.0: download
th-reify-many-0.1.6: configure
th-reify-many-0.1.6: build
time-qq-0.0.1.0: configure
time-qq-0.0.1.0: build
cpphs-1.20.2: configure
th-reify-many-0.1.6: copy/register
time-qq-0.0.1.0: copy/register
cpphs-1.20.2: build
cpphs-1.20.2: copy/register
Progress: 4/9
--  While building package happy-1.19.5 using:
      /usr/local/bin/ghc --make -odir /tmp/stack1466/happy-1.19.5/.stack-work/dist/x86_64-freebsd/Cabal-1.22.4.0/setup -hidir /tmp/stack1466/happy-1.19.5/.stack-work/dist/x86_64-freebsd/Cabal-1.22.4.0/setup
 -i -i. -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/pkgdb /tmp/stack1466/happy-1.19.5/Setup.lhs -o /tmp/stack1466/happy-1.1
9.5/.stack-work/dist/x86_64-freebsd/Cabal-1.22.4.0/setup/setup
    Process exited with code: ExitFailure 1
    Logs have been written to: /root/project-name/.stack-work/logs/happy-1.19.5.log

    [1 of 1] Compiling Main             ( /tmp/stack1466/happy-1.19.5/Setup.lhs, /tmp/stack1466/happy-1.19.5/.stack-work/dist/x86_64-freebsd/Cabal-1.22.4.0/setup/Main.o )

    /tmp/stack1466/happy-1.19.5/Setup.lhs:20:1: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:21:1: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:22:1: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:68:1: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:74:1: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:81:19: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:82:23: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:83:26: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:84:26: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:85:30: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:86:33: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:87:32: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:88:36: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:89:39: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:94:14: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:99:13: Warning: Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:100:17: Warning:
        Tab character

    /tmp/stack1466/happy-1.19.5/Setup.lhs:101:23: Warning:
        Tab character

    Linking /tmp/stack1466/happy-1.19.5/.stack-work/dist/x86_64-freebsd/Cabal-1.22.4.0/setup/setup ...
    /usr/local/lib/ghc-7.10.2/unix_A3WgcI5QiHK4PDo4jSYdwQ/libHSunix-2.7.1.0-A3WgcI5QiHK4PDo4jSYdwQ.a(HsUnix.o): In function `__hsunix_rtldNext':
    HsUnix.c:(.text+0x80): multiple definition of `__hsunix_rtldNext'
    /root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/lib/x86_64-freebsd-ghc-7.10.2/unix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS/libHSunix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS.a(HsUnix.o):(.text+0x0): first defined here
    /usr/local/lib/ghc-7.10.2/unix_A3WgcI5QiHK4PDo4jSYdwQ/libHSunix-2.7.1.0-A3WgcI5QiHK4PDo4jSYdwQ.a(HsUnix.o): In function `__hsunix_rtldDefault':
    HsUnix.c:(.text+0x90): multiple definition of `__hsunix_rtldDefault'
    /root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/lib/x86_64-freebsd-ghc-7.10.2/unix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS/libHSunix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS.a(HsUnix.o):(.text+0x10): first defined here
    /usr/local/lib/ghc-7.10.2/unix_A3WgcI5QiHK4PDo4jSYdwQ/libHSunix-2.7.1.0-A3WgcI5QiHK4PDo4jSYdwQ.a(HsUnix.o): In function `__hsunix_ptsname':
    HsUnix.c:(.text+0x130): multiple definition of `__hsunix_ptsname'
    /root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/lib/x86_64-freebsd-ghc-7.10.2/unix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS/libHSunix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS.a(HsUnix.o):(.text+0x20): first defined here
    /usr/local/lib/ghc-7.10.2/unix_A3WgcI5QiHK4PDo4jSYdwQ/libHSunix-2.7.1.0-A3WgcI5QiHK4PDo4jSYdwQ.a(HsUnix.o): In function `__hsunix_grantpt':
    HsUnix.c:(.text+0x140): multiple definition of `__hsunix_grantpt'
    /root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/lib/x86_64-freebsd-ghc-7.10.2/unix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS/libHSunix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS.a(HsUnix.o):(.text+0x30): first defined here
    /usr/local/lib/ghc-7.10.2/unix_A3WgcI5QiHK4PDo4jSYdwQ/libHSunix-2.7.1.0-A3WgcI5QiHK4PDo4jSYdwQ.a(HsUnix.o): In function `__hsunix_unlockpt':
    HsUnix.c:(.text+0x150): multiple definition of `__hsunix_unlockpt'
    /root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/lib/x86_64-freebsd-ghc-7.10.2/unix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS/libHSunix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS.a(HsUnix.o):(.text+0x40): first defined here
    /usr/local/lib/ghc-7.10.2/unix_A3WgcI5QiHK4PDo4jSYdwQ/libHSunix-2.7.1.0-A3WgcI5QiHK4PDo4jSYdwQ.a(HsUnix.o): In function `__hsunix_push_module':
    HsUnix.c:(.text+0x160): multiple definition of `__hsunix_push_module'
    /root/.stack/snapshots/x86_64-freebsd/lts-7.14/7.10.2/lib/x86_64-freebsd-ghc-7.10.2/unix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS/libHSunix-2.7.2.0-3psvMyG1UoBJLXj9bF7fFS.a(HsUnix.o):(.text+0x50): first defined here
    collect2: error: ld returned 1 exit status

Misc

  • ghc-7.10.2
  • FreeBSD 10.3-RELEASE-p18 in a VM
  • happy-1.19.5
  • Stack Version 1.0.1, Git revision e1c8e2c (3065 commits) x86_64

Options I'm considering:

  1. Figure out what the linker error is about. Maybe it is easy to fix. Perhaps ask on StackOverflow about it. ;) Any ideas what it is about?

  2. Try to find which dependency of my project is using Happy and see if I can do without it. I tried to go about this via stack list-dependencies --depth=100 and stack dot --external but neither of those helped me unfortunately.
    How could I find out which of my direct dependencies depend on it (likely indirectly)?

  3. Try to persuade stack to use the system-wide available happy binary that I was able to get via pkg install hs-happy. How could I go about this?

  4. Cross compile for FreeBSD from linux. Do I suspect correctly that this would likely not be an issue if I had a cross-compiler? And either way, would it be difficult to set up a linux->FreeBSD cross compiler? How could I go about doing that?

  5. Try to move away from needing FreeBSD. Unfortunately my hosting provider only supports FreeBSD at the moment, and I really like them for other reasons (value for price and their related philosophy). Perhaps, if all else fails, can you tell me what Linux hosting provider is your favorite for your Haskell projects?

I suspect option #1 or #3 might be the most painless.
Or would any of you have other ideas as well?

Wizek
  • 4,854
  • 2
  • 25
  • 52
  • 1
    1 is almost certainly your best bet. The problem is the linker finds two copies of `unix` and links against both (obviously this cannot work) - the one in `/usr/local/lib/ghc-7.10.2` should not be included. What stack command are you running? Do you by chance have a global installation of ghc (which is what the existence of the path `/usr/local/lib/ghc-7.10.2/` tells me)? That could interfere with the version used by stack. – user2407038 Jun 22 '17 at 12:00
  • I usually run `/root/.cabal/bin/stack build --system-ghc --compiler ghc-7.10.2`. I don't remember what exactly, but a few years ago when I first started using stack+FreeBSD for builds, IIRC stack didn't support non-system GHCs. So maybe I can try that again with `stack setUp --compiler ghc-7.10.2` – Wizek Jun 22 '17 at 12:16
  • 1
    Just a note: Your Stack version seems a little too old. – Sibi Jun 22 '17 at 12:21
  • @Wizek I think you could still potentially use your system ghc, but you need to clobber all the packages in the system ghc package database, otherwise you will get these issues. I suggest deleting the system ghc altogether. A few years is a long time for a tool like stack, which has only really existed for a 'few' years (5?) - I suggest updating. – user2407038 Jun 22 '17 at 12:23
  • @Wizek, here is [haskell-cafe thread](https://mail.haskell.org/pipermail/haskell-cafe/2017-June/127358.html) regarding happy 1.19.5. It seems to be a general issue. – palik Jun 23 '17 at 07:56
  • Thanks to the pointers in @user2407038 and @Sibi 's comments I managed to upgrade to stack 1.4.0 and `stack setup` a separate GHC. `happy` installed like a charm afterwards, and all is well now. Does either of you want to make your comment into an answer which I can mark accepted? – Wizek Jun 23 '17 at 21:06
  • 1
    As far as my comment goes, feel free to include any part of it in your own answer of your question. – user2407038 Jun 24 '17 at 00:09

1 Answers1

0

Thanks to the pointers in @user2407038 and @Sibi 's comments I managed to upgrade to stack 1.4.0 from 1.0.1 and stack setup an isolated GHC.

happy installed like a charm afterwards, and all is well now.

Wizek
  • 4,854
  • 2
  • 25
  • 52