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

error: collect2: fatal error: cannot find 'ld' #7341

Closed
mbucc opened this issue Mar 24, 2021 · 8 comments
Closed

error: collect2: fatal error: cannot find 'ld' #7341

mbucc opened this issue Mar 24, 2021 · 8 comments

Comments

@mbucc
Copy link

mbucc commented Mar 24, 2021

Describe the bug
With the same sources, cabal build works on OSX but fails on Alpine Linux.

To Reproduce
./app/Main.hs

module Main where

import Lib

main :: IO ()
main = someFunc

./app/Lib.hs

{-# LANGUAGE OverloadedStrings #-}

module Lib
    ( someFunc
    ) where

import Network.Wai
import Network.HTTP.Types
import Network.Wai.Handler.Warp (run)

app2 :: Application
app2 _ respond = respond index

index :: Response
index = responseFile
    status200
    [("Content-Type", "text/html")]
    "index.html"
    Nothing

someFunc :: IO ()
someFunc = do
    putStrLn $ "http://localhost:8080/"
    run 8080 app2
$ cabal v2-build
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - basement-0.0.11 (lib) (requires build)
 - bsb-http-chunked-0.0.0.4 (lib) (requires build)
 - byteorder-1.0.4 (lib:byteorder) (requires build)
 - hashable-1.3.1.0 (lib) (requires build)
 - hourglass-0.2.12 (lib) (requires build)
 - hsc2hs-0.68.7 (exe:hsc2hs) (requires build)
 - integer-logarithms-1.0.3.1 (lib) (requires build)
 - network-byte-order-0.1.6 (lib) (requires build)
 - primitive-0.7.1.0 (lib) (requires build)
 - splitmix-0.1.0.3 (lib) (requires build)
 - time-manager-0.0.0 (lib) (requires build)
 - unix-compat-0.5.3 (lib) (requires build)
 - word8-0.1.3 (lib) (requires build)
 - zlib-0.6.2.3 (lib) (requires build)
 - memory-0.15.0 (lib) (requires build)
 - unordered-containers-0.2.13.0 (lib) (requires build)
 - psqueues-0.2.7.2 (lib) (requires build)
 - case-insensitive-1.2.1.0 (lib) (requires build)
 - async-2.2.3 (lib) (requires build)
 - network-3.1.2.1 (lib:network) (requires build)
 - scientific-0.3.6.2 (lib) (requires build)
 - random-1.2.0 (lib) (requires build)
 - pem-0.2.4 (lib) (requires build)
 - cryptonite-0.28 (lib) (requires build)
 - asn1-types-0.3.4 (lib:asn1-types) (requires build)
 - vault-0.3.1.5 (lib) (requires build)
 - http-types-0.12.3 (lib) (requires build)
 - simple-sendfile-0.2.30 (lib) (requires build)
 - iproute-1.7.11 (lib) (requires build)
 - attoparsec-0.14.1 (lib) (requires build)
 - streaming-commons-0.2.2.1 (lib) (requires build)
 - asn1-encoding-0.9.6 (lib) (requires build)
 - wai-3.2.3 (lib) (requires build)
 - http2-2.0.6 (lib) (requires build)
 - http-date-0.0.11 (lib) (requires build)
 - asn1-parse-0.9.5 (lib:asn1-parse) (requires build)
 - x509-1.7.5 (lib) (requires build)
 - warp-3.3.14 (lib) (requires build)
 - hacs-1 (exe:hacs) (first run)
Configuring library for basement-0.0.11..
Preprocessing library for basement-0.0.11..
linking dist/build/Basement/Terminal/Size_hsc_make.o failed (exit code 1)
rsp file was: "dist/build/Basement/Terminal/hsc2hscall6160-2.rsp"
command was: /usr/bin/cc dist/build/Basement/Terminal/Size_hsc_make.o dist/build/Basement/Terminal/Size_hsc_utils.o -o dist/build/Basement/Terminal/Size_hsc_make -fuse-ld=gold -L/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/base-4.14.1.0 -Wl,-R,/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/base-4.14.1.0 -L/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/integer-gmp-1.0.3.0 -Wl,-R,/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/integer-gmp-1.0.3.0 -lgmp -L/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/ghc-prim-0.6.1 -Wl,-R,/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/ghc-prim-0.6.1 -lc -lm -L/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/rts-1.0 -Wl,-R,/home/mark/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-linux-ghc-8.10.4/rts-1.0 -lm -lrt -ldl
error: collect2: fatal error: cannot find 'ld'
compilation terminated.

cabal: Failed to build basement-0.0.11 (which is required by exe:hacs from
hacs-1).

$
$ which ld
/usr/bin/ld

$ ld -version
GNU ld (GNU Binutils) 2.35.1
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

$ 

Expected behavior
It should compile.

System information

  • 5.10.24-0-lts Add support for the Apache license #1-Alpine SMP Thu, 18 Mar 2021 09:17:05 UTC x86_64 Linux
  • cabal-install version 3.4.0.0
  • The Glorious Glasgow Haskell Compilation System, version 8.10.4
@emilypi
Copy link
Member

emilypi commented Mar 26, 2021

@mbucc thanks for raising this. Does the build work with Stack?

@mbucc
Copy link
Author

mbucc commented Apr 7, 2021

I could not get it to work with Stack either in this environment. However, I did not record the error. I do know it was a different problem.

@Mistuke
Copy link
Collaborator

Mistuke commented Jul 25, 2021

error is slightly misleading, your compiling with -fuse-ld=gold so you need to check gold not ld.

@gbaz
Copy link
Collaborator

gbaz commented Aug 28, 2021

Does this fail with raw ghc as well? If so we should close as not our issue.

@gbaz gbaz closed this as completed Aug 28, 2021
@gbaz gbaz reopened this Aug 28, 2021
@Mikolaj
Copy link
Member

Mikolaj commented Aug 30, 2021

Pasting the .cabal file and also a log with -v2 verbosity would help, too. I had success compiling on Alpine, but that was statically, so perhaps that makes a difference.

@Mikolaj
Copy link
Member

Mikolaj commented Aug 30, 2021

Also, a repro, e.g., using https://github.com/utdemir/ghc-musl, would be invaluable.

@mbucc: when you can provide any of these, or any further info, please kindly re-open.

@Mikolaj Mikolaj closed this as completed Aug 30, 2021
@mbucc
Copy link
Author

mbucc commented Aug 30, 2021

a repro ... would be invaluable.

@mbucc: when you can provide ... please kindly re-open.

@Mikolaj I believe my original bug report includes everything you need to reproduce the issue. I'll leave it to you to reopen if you think it is worth the effort. This is no longer an itch I need to scratch. Thanks!

@Mikolaj
Copy link
Member

Mikolaj commented Aug 30, 2021

@mbucc: did I miss the .cabal file you used? Did you manage to reproduce with the docker image I provided or any other way accessible without installing Alpine?

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

5 participants