simonmar / ghc-paths

Knowledge of GHC's installation directories
Other
11 stars 19 forks source link

MacOS: stack fails to build ghc-paths package #16

Open mouse07410 opened 5 years ago

mouse07410 commented 5 years ago

Setup

MacOS Mojave 10.14.2, Xcode-10.1, current Macports with a lot of tools ("ports") installed, current Haskell Platform (ghc-8.6.3), current cabal and stack.

In short

stack fails to build intero because it fails to build ghc-paths. Which fails, because somehow ghc-paths is the only package (or one of the few) that does not accept (or doesn't make use of) parameters like ---ghc-options -optL=/usr/lib/libiconv.dylib.

This came up in https://github.com/rikvdkleij/intellij-haskell/issues/375

Log

Shown in the attempt to build intero: intero-build.txt

The long story

Problem: Macports provides it's own version of libiconv.dylib, and it mangles function names - so it cannot be used in place of the Apple-provided libiconv.dylib. Standard ghc (or rather, libHSbase.a, which is a part of the GHC binary package) is linked against the Apple-provided libiconv.dylib.

For most packages (of for everything other than ghc-paths), adding --ghc-options -optL=/usr/lib/libiconv.dylib to the stack invocation seems to suffice to force the linker to take the correct shared library (to use /usr/lib/libiconv.dylib instead of /opt/local/lib/libiconv.dylib that precedes it on the library search path - which it must for reasons I don't want to get into here). But with ghc-paths it does not work.

Since all of my stack config files add the options I listed, but I cannot find it in the actual log - I suspect that something in the ghc-paths forces certain build flags. If that's correct - it would have to be relaxed to fix this problem.

Executing `/usr/local/bin/stack build intero` failed: /usr/local/bin/stack build intero: ghc-paths-0.1.0.9: configure -- While building package ghc-paths-0.1.0.9 using: /usr/local/bin/ghc --make -odir /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup -hidir /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup -i -i. -clear-package-db -global-package-db -package-db=/Users/uri/.stack/snapshots/x86_64-osx/lts-13.3/8.6.3/pkgdb -package-db=/Users/uri/src/p-test2/.stack-work/install/x86_64-osx/lts-13.3/8.6.3/pkgdb -hide-all-packages -package-id=Cabal-2.4.1.0-Df4rkGuWEtO4aZs4eesJ3r -package-id=base-4.12.0.0 -package-id=directory-1.3.3.0 -optP-include -optP/private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup_macros.h /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/Setup.hs /Users/uri/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup -threaded Process exited with code: ExitFailure 1 Logs have been written to: /Users/uri/src/p-test2/.stack-work/logs/ghc-paths-0.1.0.9.log [1 of 2] Compiling Main ( /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/Setup.hs, /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/Main.o ) /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/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/uri/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/StackSetupShim.o ) Linking /private/var/folders/pd/mxn5kp_55jg23x7jjd10gtwm0000gn/T/stack57338/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup ... Undefined symbols for architecture x86_64: "_iconv", referenced from: _hs_iconv in libHSbase-4.12.0.0.a(iconv.o) (maybe you meant: _base_GHCziIOziEncodingziIconv_iconvEncoding_closure, _base_GHCziIOziEncodingziIconv_iconvEncoding1_info , _base_GHCziIOziEncodingziIconv_iconvEncoding3_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding4_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding7_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding15_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding4_info , _base_GHCziIOziEncodingziIconv_iconvEncoding6_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding6_info , _base_GHCziIOziEncodingziIconv_iconvEncoding5_closure , _hs_iconv_open , _base_GHCziIOziEncodingziIconv_iconvEncoding9_info , _base_GHCziIOziEncodingziIconv_iconvEncoding11_info , _base_GHCziIOziEncodingziIconv_iconvEncoding12_info , _base_GHCziIOziEncodingziIconv_iconvEncoding14_bytes , _hs_iconv_close , _base_GHCziIOziEncodingziIconv_iconvEncoding2_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding2_info , _base_GHCziIOziEncodingziIconv_iconvEncoding11_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding15_info , _base_GHCziIOziEncodingziIconv_iconvEncoding_info , _base_GHCziIOziEncodingziIconv_iconvEncoding12_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding8_info , _base_GHCziIOziEncodingziIconv_iconvEncoding7_info , _base_GHCziIOziEncodingziIconv_iconvEncoding1_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding8_closure , _hs_iconv , _base_GHCziIOziEncodingziIconv_iconvEncoding10_bytes , _base_GHCziIOziEncodingziIconv_iconvEncoding13_info , _base_GHCziIOziEncodingziIconv_iconvEncoding13_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding9_closure ) "_iconv_open", referenced from: _hs_iconv_open in libHSbase-4.12.0.0.a(iconv.o) (maybe you meant: _hs_iconv_open) "_iconv_close", referenced from: _hs_iconv_close in libHSbase-4.12.0.0.a(iconv.o) (maybe you meant: _hs_iconv_close) "_locale_charset", referenced from: _localeEncoding in libHSbase-4.12.0.0.a(PrelIOUtils.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `clang' failed in phase `Linker'. (Exit code: 1)

Note: with cabal I can build ghc-paths and install intero. But that doesn't help with my problem, as the IDE plugin I'm using, only understand `stack projects.

Your help is requested in resolving this.

Thanks!

terzievk commented 4 years ago

I have a similar problem on archlinux while installing intero. Here is the error: While building package ghc-paths-0.1.0.9 using: /home/terzievk/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.2/bin/ghc-8.8.2 --make -odir /tmp/stack-dcdca92561a018ae/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup -hidir /tmp/stack-dcdca92561a018ae/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup -i -i. -clear-package-db -global-package-db -package-db=/home/terzievk/.stack/snapshots/x86_64-linux-tinfo6/8c94611031dbc130e5574b8d8ad2b5c41557903cfa4a41958fb465ceb081bbeb/8.8.2/pkgdb -package-db=/home/terzievk/.stack/global-project/.stack-work/install/x86_64-linux-tinfo6/8c94611031dbc130e5574b8d8ad2b5c41557903cfa4a41958fb465ceb081bbeb/8.8.2/pkgdb -hide-all-packages -package=Cabal -package-id=base-4.13.0.0 -package-id=directory-1.3.4.0 -optP-include -optP/tmp/stack-dcdca92561a018ae/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup/setup_macros.h /tmp/stack-dcdca92561a018ae/ghc-paths-0.1.0.9/Setup.hs /home/terzievk/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /tmp/stack-dcdca92561a018ae/ghc-paths-0.1.0.9/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup/setup -threaded Process exited with code: ExitFailure 1

simonmar commented 4 years ago

If anyone could help with investigating and fixing this I'd be grateful. Why does it work with Cabal and not Stack? Is Stack perhaps not running the Setup.hs for the package?

terzievk commented 4 years ago

I didn't check at the time I made my previous comment, but since intero is discontinued, does it really matter?