haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

macOS build from source fails in linker #1135

Open xsebek opened 5 years ago

xsebek commented 5 years ago

I am getting the following error when installing from source on macOS Mojave:

ondrejsebek haskell-ide-engine$ stack build
Downloaded nightly-2019-03-07 build plan.    
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-8.6.4.                                      
Installed GHC.                                                                      
Didn't see MonadRandom-0.5.1.1@sha256:935d79b8a589f4b0f847cb787f8efaa6f5d67ec1e8f0e023775b3b5f85643f92,1414 in your package indices.
Updating and trying again.
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/                                 
Downloading timestamp                                                                            
Downloading snapshot                                                                             
Updating index                                                                                   
Updated package index downloaded                                                                 
Update complete                                                                                  
Populated index cache.    
[1 of 2] Compiling Main             ( /Users/ondrejsebek/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /Users/ondrejsebek/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim   ( /Users/ondrejsebek/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /Users/ondrejsebek/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /Users/ondrejsebek/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 ...
ld64.lld: warning: ignoring unknown argument: --gc-sections
ld64.lld: warning: ignoring unknown argument: -u

# ... this goes on for quite some time ...

ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
Cannot open /Users/ondrejsebek/.stack/setup-exe-src/setup-mPHDZzAJ.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=21c, r1_type=5, r1_extern=1, r1_length=2, r1_pcrel=0, r1_symbolnum=37), (r2_address=21c, r2_type=0, r2_extern=1, r2_length=2, r2_pcrel=0, r2_symbolnum=30)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building simple Setup.hs using:
      /Users/ondrejsebek/.stack/programs/x86_64-osx/ghc-8.6.4/bin/ghc -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.4.0.1 /Users/ondrejsebek/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/ondrejsebek/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/ondrejsebek/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4
    Process exited with code: ExitFailure 1

As I am only starting to use stack & friends I have no clue what to do. Any tips would be greatly appreciated

lukel97 commented 5 years ago

Did you install llvm tools? This happens with stack whenever you add them to your path: https://github.com/commercialhaskell/stack/issues/4373

xsebek commented 5 years ago

Thanks, that does make the error message shorter:

Linking /Users/ondrejsebek/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.2 ...
clang: error: invalid linker name in argument '-fuse-ld=lld'
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building simple Setup.hs using:
      /Users/ondrejsebek/.stack/programs/x86_64-osx/ghc-8.6.2/bin/ghc -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.4.0.1 /Users/ondrejsebek/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/ondrejsebek/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/ondrejsebek/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.2
    Process exited with code: ExitFailure 1

I can't find whats wrong in this message apart from the version of GHC (I am using 8.6.3).
Is there any similar workaround? Thanks in advance

EDIT: from what I read it seems as if it is now missing the llvm tools O.o

lukel97 commented 5 years ago

I had to blow away my ~/.stack/setup-exe-cache, I think stack picks up LLD when configuring projects and caches it away there

xgrommx commented 5 years ago

I have the same problem. Anyone have solved this problem?

Huxpro commented 5 years ago

Having the exact same problem w/ @Arkemyr: bad relocation (Invalid pointer diff) first, invalid linker name in argument '-fuse-ld=lld' after removing LLVM bin from PATH.

Do we have any temp workaround? Any alternative editor tooling? Out of curiosity, why can't HIE be shipped as pre-built binary and has to be built from source?

fendor commented 5 years ago

Any alternative editor tooling, there are a lot of alternatives, ghcid, intero, haskero, haskforce, etc... There are a lot of issues discussing why there are no pre built binaries for mainstream distros, see #1068.

Huxpro commented 5 years ago

@fendor hmm I think as long as stack is failed to build...majority of editor tooling would just break. Probably I should ask what stack version should I fallback to to work around the build issue on macOS?