Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

macOS build from source fails in linker #1135

Open
xsebek opened this issue Mar 14, 2019 · 7 comments
Open

macOS build from source fails in linker #1135

xsebek opened this issue Mar 14, 2019 · 7 comments
Labels
build Continuous integration and building os: macOS

Comments

@xsebek
Copy link

xsebek commented Mar 14, 2019

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
Copy link
Collaborator

lukel97 commented Mar 14, 2019

Did you install llvm tools? This happens with stack whenever you add them to your path: commercialhaskell/stack#4373

@xsebek
Copy link
Author

xsebek commented Mar 14, 2019

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
Copy link
Collaborator

lukel97 commented Mar 23, 2019

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
Copy link

xgrommx commented Mar 23, 2019

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

@nponeccop nponeccop added the build Continuous integration and building label Apr 10, 2019
@Huxpro
Copy link

Huxpro commented Jul 24, 2019

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
Copy link
Collaborator

fendor commented Jul 24, 2019

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
Copy link

Huxpro commented Jul 24, 2019

@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?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
build Continuous integration and building os: macOS
Projects
None yet
Development

No branches or pull requests

7 participants