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

MacOS: stack fails to build "ghc-paths" when Macports is present #4504

Closed
mouse07410 opened this issue Jan 14, 2019 · 13 comments
Closed

MacOS: stack fails to build "ghc-paths" when Macports is present #4504

mouse07410 opened this issue Jan 14, 2019 · 13 comments

Comments

@mouse07410
Copy link

General summary/comments (optional)

It seems that stack fails to use either ghc-options: or extra-lib-dirs: when building ghc-paths.
Problem with passing parameters to the linker (stack->ghc->gcc->ld).

I'm looking for the ability to pass arguments to linker, specifically to tell it to search a given set of directories for libraries in the provided order, and starting with them rather than with something else. The ability to tell the linker "search /this/dir first before going to, e.g., /opt/local/lib", would be outstanding.

Steps to reproduce

  1. On a MacOS machine with Macports installed, install Haskell Platform.
  2. Create a directory /opt/local/lib/liconv and copy /usr/lib/libiconv.dylib to there.
  3. Configure cabal (~/.cabal/config) and stack (~/.stack/config.yaml) to use /opt/local/lib/liconv first, then add other lib directories (see config.yaml attached).
  4. Do stack unpack ghc-paths and cd to where it got unpacked.
  5. Do stack build and observe the failure.

Expected

Build succeeds.

Actual

Here's stack.yaml from ghc-paths-0.1.0.9:

resolver: lts-13.2

# User packages to be built.
packages:
- .

system-ghc: true
arch: x86_64

extra-include-dirs: [ /opt/local/lib/liconv, /opt/local/lib, /usr/local/lib, /usr/lib ]

compiler-check: newer-minor

ghc-options: 
  "$everything": -optl=/usr/lib/libiconv.dylib
  #"$everything": "-L/opt/local/lib/liconv -liconv"

Here's my ~/.stack/config.yaml:

system-ghc: true
skip-ghc-check: true

arch: x86_64

with-gcc: /usr/bin/gcc

extra-include-dirs: [ /opt/local/include, /usr/local/include ]
extra-lib-dirs: [ /opt/local/lib/liconv, /opt/local/lib, /usr/local/lib, /usr/lib ]

allow-newer: true

ghc-options: 
    "$everything": -O2 /usr/lib/libiconv.dylib
apply-ghc-options: everything

build:
  cabal-verbose: true

Here's the output of stack build: Gist

Stack version

$ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1

Method of installation

@dbaynard
Copy link
Contributor

Hi, have you seen http://blog.omega-prime.co.uk/2011/01/28/solving-ghc-iconv-problems-on-os-x-10-6/? Also NixOS/nixpkgs#46814 (comment) seems relevant.

What happens if you also pass -liconv to -optl?

@mouse07410
Copy link
Author

mouse07410 commented Jan 14, 2019

What happens if you also pass -liconv to -optl?

Alas, the same thing. I tried also

ghc-options:
  "$everything": -optl="-L/opt/local/lib/liconv -liconv"

with the same result. It does not go into /opt/local/lib/liconv first. And by the time it apparently gets there (if at all), it already found /opt/local/lib/libiconv.dylib with its mangled names.

Although I don't understand why - since /opt/local/lib/libiconv.dylib failed to resolve the required references - it did not keep looking and did not pick up /opt/local/lib/liconv/libiconv.dylib that does resolve them...

Yes I checked that blog. Unfortunately, it doesn't help:

  • I cannot uninstall or deactivate libiconv port, because there are other ports that need it (otherwise that port would not end up on my machine at all - it was a dependency of something else I needed);
  • Yes I'm very happy to link everything Haskell-related with the Apple's libiconv. And cabal ... thankfully works fine with that - but the IDE plugin IntelliJ-Haskell insists on doing things via stack. Currently, with extra-lib-dirs: play, cabal works 100% for me, and stack - about 95%. Alas, in that remaining 5% are ghc-paths and intero (which depends on ghc-paths) - and this plugin requires intero.
  • I cannot build GHC myself. In fact, I built it - but the plugin pulls an oder LTS, so no matter what GHC I run, the plugin invariably runs one that requires Apple's libiconv. Somehow, system-ghc: true and skip-ghc-check: true do not prevent stack from using the LTS-12 compiler.

Update

The "nixOS" comment might be relevant -though I'm not sure how to enforce passing/appending of -liconv to GHC invocation via stack flags/options.

@mouse07410
Copy link
Author

mouse07410 commented Jan 14, 2019

Here's an example that appears to work with other packages.

First, what showed to not work:

$ stack build --system-ghc --ghc-options -optl="-L/opt/local/lib -liconv" --verbose
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
2019-01-14 12:39:25.580312: [debug] Checking for project config at: /Users/ur20980/src/p-test/stack.yaml
2019-01-14 12:39:25.580601: [debug] Loading project config file stack.yaml
2019-01-14 12:39:25.581898: [debug] Decoding build plan from: /Users/ur20980/.stack/build-plan/lts-13.2.yaml
2019-01-14 12:39:25.581942: [debug] Trying to decode /Users/ur20980/.stack/build-plan-cache/lts-13.2.cache
2019-01-14 12:39:25.586207: [debug] Success decoding /Users/ur20980/.stack/build-plan-cache/lts-13.2.cache
2019-01-14 12:39:25.586282: [debug] Getting system compiler version
2019-01-14 12:39:25.586392: [debug] Run process: /usr/local/bin/ghc --info
2019-01-14 12:39:25.655107: [debug] Process finished in 69ms: /usr/local/bin/ghc --info
2019-01-14 12:39:25.656307: [debug] Getting global package database location
2019-01-14 12:39:25.656462: [debug] Run process: /usr/local/bin/ghc-pkg --no-user-package-db list --global
2019-01-14 12:39:25.656974: [debug] Asking GHC for its version
2019-01-14 12:39:25.657111: [debug] Getting Cabal package version
2019-01-14 12:39:25.657195: [debug] Run process: /usr/local/bin/ghc --numeric-version
2019-01-14 12:39:25.657570: [debug] Run process: /usr/local/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2019-01-14 12:39:25.708265: [debug] Process finished in 51ms: /usr/local/bin/ghc --numeric-version
2019-01-14 12:39:25.708364: [debug] GHC version is: ghc-8.4.3
2019-01-14 12:39:25.766936: [debug] Process finished in 110ms: /usr/local/bin/ghc-pkg --no-user-package-db list --global
2019-01-14 12:39:25.767139: [debug] Process finished in 109ms: /usr/local/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2019-01-14 12:39:25.767287: [debug] Resolving package entries
2019-01-14 12:39:25.767369: [debug] Trying to decode /Users/ur20980/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.4.3/lts-13.2.cache
2019-01-14 12:39:25.795632: [debug] Success decoding /Users/ur20980/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.4.3/lts-13.2.cache
2019-01-14 12:39:25.795993: [debug] Starting to execute command inside EnvConfig
2019-01-14 12:39:25.796036: [debug] Parsing the targets
2019-01-14 12:39:25.796147: [debug] Running hpack on /Users/ur20980/src/p-test/package.yaml
2019-01-14 12:39:25.798538: [debug] hpack output unchanged in /Users/ur20980/src/p-test/p-test.cabal
2019-01-14 12:39:25.810142: [debug] Start: getPackageFiles /Users/ur20980/src/p-test/p-test.cabal
2019-01-14 12:39:25.812502: [debug] Finished in 2ms: getPackageFiles /Users/ur20980/src/p-test/p-test.cabal
2019-01-14 12:39:25.813139: [debug] Finding out which packages are already installed
2019-01-14 12:39:25.813304: [debug] Run process: /usr/local/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2019-01-14 12:39:25.966604: [debug] Process finished in 153ms: /usr/local/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2019-01-14 12:39:25.966855: [debug] Ignoring package GLURaw due to wanting version 2.0.0.4 instead of 2.0.0.3
2019-01-14 12:39:25.966916: [debug] Ignoring package fgl due to wanting version 5.7.0.1 instead of 5.6.0.0
2019-01-14 12:39:25.967000: [debug] Ignoring package StateVar due to wanting version 1.1.1.1 instead of 1.1.0.4
2019-01-14 12:39:25.967041: [debug] Ignoring package text due to wanting version 1.2.3.1 instead of 1.2.3.0
2019-01-14 12:39:25.967126: [debug] Ignoring package OpenGLRaw due to wanting version 3.3.1.0 instead of 3.2.7.0
2019-01-14 12:39:25.967447: [debug] Ignoring package half due to wanting version 0.3 instead of 0.2.2.3
2019-01-14 12:39:25.967550: [debug] Ignoring package vector due to wanting version 0.12.0.2 instead of 0.12.0.1
2019-01-14 12:39:25.967658: [debug] Ignoring package case-insensitive due to wanting version 1.2.0.11 instead of 1.2.0.10
2019-01-14 12:39:25.967731: [debug] Ignoring package haskeline due to wanting version 0.7.4.3 instead of 0.7.4.2
2019-01-14 12:39:25.967787: [debug] Ignoring package integer-logarithms due to wanting version 1.0.2.2 instead of 1.0.2.1
2019-01-14 12:39:25.967819: [debug] Ignoring package QuickCheck due to wanting version 2.12.6.1 instead of 2.11.3
2019-01-14 12:39:25.967868: [debug] Ignoring package HTTP due to wanting version 4000.3.12 instead of 4000.3.11
2019-01-14 12:39:25.967912: [debug] Ignoring package Cabal due to wanting version 2.4.1.0 instead of 2.2.0.1
2019-01-14 12:39:25.967944: [debug] Ignoring package GLUT due to wanting version 2.7.0.14 instead of 2.7.0.12
2019-01-14 12:39:25.967984: [debug] Ignoring package scientific due to wanting version 0.3.6.2 instead of 0.3.5.2
2019-01-14 12:39:25.968032: [debug] Ignoring package parallel due to wanting version 3.2.2.0 instead of 3.2.1.1
2019-01-14 12:39:25.968061: [debug] Ignoring package stm due to wanting version 2.5.0.0 instead of 2.4.5.0
2019-01-14 12:39:25.968089: [debug] Ignoring package network due to wanting version 2.8.0.0 instead of 2.6.3.5
2019-01-14 12:39:25.968127: [debug] Ignoring package OpenGL due to wanting version 3.0.2.2 instead of 3.0.2.0
2019-01-14 12:39:25.968211: [debug] Run process: /usr/local/bin/ghc-pkg --user --no-user-package-db --package-db /Users/ur20980/.stack/snapshots/x86_64-osx/lts-13.2/8.4.3/pkgdb dump --expand-pkgroot
2019-01-14 12:39:26.066593: [debug] Process finished in 98ms: /usr/local/bin/ghc-pkg --user --no-user-package-db --package-db /Users/ur20980/.stack/snapshots/x86_64-osx/lts-13.2/8.4.3/pkgdb dump --expand-pkgroot
2019-01-14 12:39:26.066732: [debug] Run process: /usr/local/bin/ghc-pkg --user --no-user-package-db --package-db /Users/ur20980/src/p-test/.stack-work/install/x86_64-osx/lts-13.2/8.4.3/pkgdb dump --expand-pkgroot
2019-01-14 12:39:26.170819: [debug] Process finished in 104ms: /usr/local/bin/ghc-pkg --user --no-user-package-db --package-db /Users/ur20980/src/p-test/.stack-work/install/x86_64-osx/lts-13.2/8.4.3/pkgdb dump --expand-pkgroot
2019-01-14 12:39:26.171066: [debug] Constructing the build plan
2019-01-14 12:39:26.171623: [debug] Checking if we are going to build multiple executables with the same name
2019-01-14 12:39:26.171694: [debug] Executing the build plan
2019-01-14 12:39:26.172430: [debug] Getting global package database location
2019-01-14 12:39:26.172484: [debug] Run process: /usr/local/bin/ghc-pkg --no-user-package-db list --global
2019-01-14 12:39:26.284529: [debug] Process finished in 112ms: /usr/local/bin/ghc-pkg --no-user-package-db list --global
2019-01-14 12:39:26.285031: [info] Building all executables for `p-test' once. After a successful build of all of them, only specified executables will be rebuilt.
2019-01-14 12:39:26.285469: [debug] Encoding /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2019-01-14 12:39:26.285847: [debug] Finished writing /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2019-01-14 12:39:26.286113: [debug] Encoding /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-p-test-exe
2019-01-14 12:39:26.286385: [debug] Finished writing /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-p-test-exe
2019-01-14 12:39:26.286436: [info] p-test-0.1.0.0: build (lib + exe)
2019-01-14 12:39:26.286598: [debug] Run process within /Users/ur20980/src/p-test/: /Users/ur20980/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.2.0.1 build lib:p-test exe:p-test-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
2019-01-14 12:39:26.345054: [info] Preprocessing library for p-test-0.1.0.0..
2019-01-14 12:39:26.345153: [info] Building library for p-test-0.1.0.0..
2019-01-14 12:39:26.715034: [info] ignoring (possibly broken) abi-depends field for packages
2019-01-14 12:39:26.727476: [info] Preprocessing executable 'p-test-exe' for p-test-0.1.0.0..
2019-01-14 12:39:26.727602: [info] Building executable 'p-test-exe' for p-test-0.1.0.0..
2019-01-14 12:39:26.968943: [info] Linking .stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/p-test-exe/p-test-exe ...
2019-01-14 12:39:27.323340: [warn] Undefined symbols for architecture x86_64:
2019-01-14 12:39:27.323445: [warn]   "_iconv", referenced from:
2019-01-14 12:39:27.323553: [warn]       _hs_iconv in libHSbase-4.11.1.0.a(iconv.o)
2019-01-14 12:39:27.323790: [warn]      (maybe you meant: _base_GHCziIOziEncodingziIconv_iconvEncoding_info, _base_GHCziIOziEncodingziIconv_iconvEncoding7_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding14_info , _base_GHCziIOziEncodingziIconv_iconvEncoding1_info , _base_GHCziIOziEncodingziIconv_iconvEncoding17_bytes , _base_GHCziIOziEncodingziIconv_iconvEncoding16_info , _base_GHCziIOziEncodingziIconv_iconvEncoding11_info , _base_GHCziIOziEncodingziIconv_iconvEncoding12_info , _base_GHCziIOziEncodingziIconv_iconvEncoding11_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding3_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding4_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding10_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding18_info , _base_GHCziIOziEncodingziIconv_iconvEncoding4_info , _base_GHCziIOziEncodingziIconv_iconvEncoding10_info , _base_GHCziIOziEncodingziIconv_iconvEncoding6_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding6_info , _base_GHCziIOziEncodingziIconv_iconvEncoding8_bytes , _base_GHCziIOziEncodingziIconv_iconvEncoding7_info , _base_GHCziIOziEncodingziIconv_iconvEncoding12_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding13_bytes , _base_GHCziIOziEncodingziIconv_iconvEncoding18_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding1_closure , _hs_iconv_close , _base_GHCziIOziEncodingziIconv_iconvEncoding15_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding_closure , _hs_iconv , _base_GHCziIOziEncodingziIconv_iconvEncoding2_closure , _hs_iconv_open , _base_GHCziIOziEncodingziIconv_iconvEncoding15_info , _base_GHCziIOziEncodingziIconv_iconvEncoding9_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding2_info , _base_GHCziIOziEncodingziIconv_iconvEncoding5_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding14_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding16_closure )
2019-01-14 12:39:27.323873: [warn]   "_iconv_open", referenced from:
2019-01-14 12:39:27.323902: [warn]       _hs_iconv_open in libHSbase-4.11.1.0.a(iconv.o)
2019-01-14 12:39:27.323926: [warn]      (maybe you meant: _hs_iconv_open)
2019-01-14 12:39:27.323954: [warn]   "_iconv_close", referenced from:
2019-01-14 12:39:27.323976: [warn]       _hs_iconv_close in libHSbase-4.11.1.0.a(iconv.o)
2019-01-14 12:39:27.323997: [warn]      (maybe you meant: _hs_iconv_close)
2019-01-14 12:39:27.324020: [warn]   "_locale_charset", referenced from:
2019-01-14 12:39:27.324041: [warn]       _localeEncoding in libHSbase-4.11.1.0.a(PrelIOUtils.o)
2019-01-14 12:39:27.324062: [warn] ld: symbol(s) not found for architecture x86_64
2019-01-14 12:39:27.324089: [warn] collect2: error: ld returned 1 exit status
2019-01-14 12:39:27.325119: [warn] `gcc' failed in phase `Linker'. (Exit code: 1)
2019-01-14 12:39:27.356626: [debug] Start: getPackageFiles /Users/ur20980/src/p-test/p-test.cabal
2019-01-14 12:39:27.359096: [debug] Finished in 2ms: getPackageFiles /Users/ur20980/src/p-test/p-test.cabal
2019-01-14 12:39:27.359219: [debug] Encoding /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2019-01-14 12:39:27.359514: [debug] Finished writing /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2019-01-14 12:39:27.359568: [debug] Encoding /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-p-test-exe
2019-01-14 12:39:27.359787: [debug] Finished writing /Users/ur20980/src/p-test/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-p-test-exe

--  While building package p-test-0.1.0.0 using:
      /Users/ur20980/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.2.0.1 build lib:p-test exe:p-test-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
$ 

This appears to work, somehow:

$ stack build --system-ghc --ghc-options -optl=/usr/lib/libiconv.dylib
Building all executables for `p-test' once. After a successful build of all of them, only specified executables will be rebuilt.
p-test-0.1.0.0: configure (lib + exe)
Configuring p-test-0.1.0.0...
p-test-0.1.0.0: build (lib + exe)
Preprocessing library for p-test-0.1.0.0..
Building library for p-test-0.1.0.0..
ignoring (possibly broken) abi-depends field for packages
Preprocessing executable 'p-test-exe' for p-test-0.1.0.0..
Building executable 'p-test-exe' for p-test-0.1.0.0..
Linking .stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/p-test-exe/p-test-exe ...
p-test-0.1.0.0: copy/register
Installing library in /Users/ur20980/src/p-test/.stack-work/install/x86_64-osx/lts-13.2/8.4.3/lib/x86_64-osx-ghc-8.4.3/p-test-0.1.0.0-9A4CUMiUBZZKBbjbboKKFC
Installing executable p-test-exe in /Users/ur20980/src/p-test/.stack-work/install/x86_64-osx/lts-13.2/8.4.3/bin
Registering library for p-test-0.1.0.0..
$ stack run
someFunc
$

But, as I said in my previous post, for reasons I can't figure out, it does not work with ghc-paths (and therefore with intero, which depends on it). Here's how:

$ stack install ghc-paths --system-ghc --ghc-options -optl=/usr/lib/libiconv.dylib
text-1.2.3.1: download
text-1.2.3.1: configure
text-1.2.3.1: build
text-1.2.3.1: copy/register
parsec-3.1.13.0: download    
parsec-3.1.13.0: configure   
parsec-3.1.13.0: build       
parsec-3.1.13.0: copy/register
Cabal-2.4.1.0: configure     
Cabal-2.4.1.0: build       
Cabal-2.4.1.0: copy/register
ghc-paths-0.1.0.9: configure   
Completed 4 action(s).         

--  While building package ghc-paths-0.1.0.9 using:
      /usr/local/bin/ghc --make -odir /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup -hidir /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup -i -i. -clear-package-db -global-package-db -package-db=/Users/ur20980/.stack/snapshots/x86_64-osx/lts-13.2/8.4.3/pkgdb -package-db=/Users/ur20980/src/p-test/.stack-work/install/x86_64-osx/lts-13.2/8.4.3/pkgdb -hide-all-packages -package-id=Cabal-2.4.1.0-6wVwgVlOsfywItHLIHyLB -package-id=base-4.11.1.0 -package-id=directory-1.3.1.5 -optP-include -optP/private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup/setup_macros.h /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/Setup.hs /Users/ur20980/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup/setup -threaded
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/ur20980/src/p-test/.stack-work/logs/ghc-paths-0.1.0.9.log

    [1 of 2] Compiling Main             ( /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/Setup.hs, /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup/Main.o )
    
    /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/Setup.hs:29:18: warning: [-Wdeprecations]
        In the use of ‘rawSystemProgramStdoutConf’
        (imported from Distribution.Simple.Program):
        Deprecated: "use getDbProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)."
       |
    29 |       libdir_ <- rawSystemProgramStdoutConf (fromFlag (configVerbosity flags))
       |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
    [2 of 2] Compiling StackSetupShim   ( /Users/ur20980/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup/StackSetupShim.o )
    Linking /private/var/folders/c6/lnc_0m093ys8w16md_fm1mnxhtfnj8/T/stack52121/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/setup/setup ...
    Undefined symbols for architecture x86_64:
      "_iconv", referenced from:
          _hs_iconv in libHSbase-4.11.1.0.a(iconv.o)
         (maybe you meant: _base_GHCziIOziEncodingziIconv_iconvEncoding16_closure, _base_GHCziIOziEncodingziIconv_iconvEncoding1_info , _base_GHCziIOziEncodingziIconv_iconvEncoding4_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding10_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding18_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding18_info , _base_GHCziIOziEncodingziIconv_iconvEncoding10_info , _base_GHCziIOziEncodingziIconv_iconvEncoding6_info , _base_GHCziIOziEncodingziIconv_iconvEncoding5_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding8_bytes , _base_GHCziIOziEncodingziIconv_iconvEncoding7_info , _base_GHCziIOziEncodingziIconv_iconvEncoding17_bytes , _hs_iconv_open , _base_GHCziIOziEncodingziIconv_iconvEncoding14_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding11_info , _base_GHCziIOziEncodingziIconv_iconvEncoding12_info , _base_GHCziIOziEncodingziIconv_iconvEncoding14_info , _base_GHCziIOziEncodingziIconv_iconvEncoding16_info , _base_GHCziIOziEncodingziIconv_iconvEncoding15_info , _base_GHCziIOziEncodingziIconv_iconvEncoding9_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding6_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding_closure , _hs_iconv_close , _base_GHCziIOziEncodingziIconv_iconvEncoding2_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding2_info , _base_GHCziIOziEncodingziIconv_iconvEncoding11_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding3_closure , _hs_iconv , _base_GHCziIOziEncodingziIconv_iconvEncoding15_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding4_info , _base_GHCziIOziEncodingziIconv_iconvEncoding1_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding12_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding7_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding_info , _base_GHCziIOziEncodingziIconv_iconvEncoding13_bytes )
      "_iconv_open", referenced from:
          _hs_iconv_open in libHSbase-4.11.1.0.a(iconv.o)
         (maybe you meant: _hs_iconv_open)
      "_iconv_close", referenced from:
          _hs_iconv_close in libHSbase-4.11.1.0.a(iconv.o)
         (maybe you meant: _hs_iconv_close)
      "_locale_charset", referenced from:
          _localeEncoding in libHSbase-4.11.1.0.a(PrelIOUtils.o)
    ld: symbol(s) not found for architecture x86_64
    collect2: error: ld returned 1 exit status
    `gcc' failed in phase `Linker'. (Exit code: 1)
$

And here's the verbose log, in case it helps:
ghc-paths-build.txt

@dbaynard
Copy link
Contributor

Have you tried setting LD_LIBRARY_PATH? (I think that's the right variable)

@mouse07410
Copy link
Author

mouse07410 commented Jan 15, 2019

Have you tried setting LD_LIBRARY_PATH? (I think that's the right variable)

This would be the right variable for Linux. On MacOS it's DYLD_LIBRARY_PATH. Regardless, I tried it - and to my unpleasant surprise, it did not work. :-(
Needless to say, I've no idea why - because in theory and AFAIK, it should.

Update

Interestingly enough (for me, at least), other packages that appear to depend on libiconv.dylib, work - as you can see in my first post (i.e., they fail on linking without that --ghc-options ..., and link OK with it). But with ghc-paths it doesn't work. What makes ghc-paths different from them?

@dbaynard
Copy link
Contributor

I've forwarded the issue. Meanwhile, you might want to try system-ghc: false?

@mouse07410
Copy link
Author

Setting "system-ghc: false" changes nothing, because any GHC, either installed directly by me, or downloaded by "stack" itself, hits the same problem: "libiconv" library conflict. Those flags I'm trying to pass, are supposed to remedy that conflict - but they're ignored.

@dbaynard
Copy link
Contributor

OK, that's a shame. As I say, I've asked for people with MacOS experience to help.

@mouse07410
Copy link
Author

mouse07410 commented Jan 24, 2019

I think I have plenty of MacOS experience. It is my conclusion that the problem is stack-related, rather than MacOS-related. It is manifested in MacOS because Macports installs/requires it's own version of "libiconv", which mangles function names.

@mouse07410
Copy link
Author

mouse07410 commented Jan 24, 2019

Also, the original issue was about "ghc-paths", but I observe the same with "happy". stack did not pass all the necessary flags specified in the command line or in the main config file.

So, the majority of packages (local, or from Hackage) seem to take the arguments from command line and link correctly. Some packages (e.g., "ghc-paths" and "happy") for some reason fail to do so, and thus fail to install, with a linker error.

@dbaynard
Copy link
Contributor

That's helpful to know. I meant, I'll find a stack maintainer with MacOS experience.

It might be interesting that it's packages normally bundled with ghc. What else is affected?

@mouse07410
Copy link
Author

mouse07410 commented Jan 24, 2019

What's affected is everything that requires linking against libHSbase.a (but not against libHSbase.dylib or libHSbase.so).

However, for a large portion of the affected packages, the flags I'm trying to use are resolving the problem. But for some, they are ignored.

I talked to GHC people about abolishing libHSbase.a in favor of using only libHSbase.dylib in a new release, but got a solid justified No.

Also, it's only stack that's affected thusly. All of the above packages build nicely in my environment with Cabal. And I'd just stay with Cabal - except that the IDE plugin that I use, is stack-only. So I'm forced to get a fully-working stack - which so far I cannot.

@snoyberg
Copy link
Contributor

Resolved via #4651 and #4650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants