Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,869
    • Issues 4,869
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19514
Closed
Open
Created Mar 09, 2021 by Javier Sagredo@Jasagredo

Building an integer-simple GHC with Hadrian in Mac OS defaults to -fuse-ld=gold on hsc2hs which crashes

Summary

After building GHC 8.10.4 with hadrian with a installed GHC 8.8.4, trying to build a project that transitively depends on basement which makes use if hsc2hs results in a crash as it is using -fuse-ld=gold.

Steps to reproduce

from a clean system, I did the following:

ghcup install ghc 8.8.4
ghcup set ghc 8.8.4

git clone -b ghc-8.10.4-release https://gitlab.haskell.org/ghc/ghc.git --recurse-submodules
cd ghc
./boot
./configure --disable-numa [--disable-ld-override] # tried with and without that
./hadrian/build.sh -j5 --integer-simple --docs=none
./hadrian/build.sh binary-dist --integer-simple --docs=none

ghcup rm 8.8.4
ghcup install ghc -u file://$(pwd)/_build/bindist/ghc-8.10.4-x86_64-apple-darwin.tar.xz 8.10.4 # just named it 8.10.4
ghcup set ghc 8.10.4

Then trying to build anything that depends on basement fails, but for the record, basement itself fails:

> ~ % git clone https://github.com/haskell-foundation/foundation                                 
Cloning into 'foundation'...
remote: Enumerating objects: 12612, done.
remote: Total 12612 (delta 0), reused 0 (delta 0), pack-reused 12612
Receiving objects: 100% (12612/12612), 2.46 MiB | 13.33 MiB/s, done.
Resolving deltas: 100% (8724/8724), done.
> ~ % cd foundation
> foundation % vi stack.yaml # to update the lts to 17.5 // ghc-8.10.4
> foundation % stack build --system-ghc
basement  > configure (lib)
basement  > Configuring basement-0.0.11...
basement  > build (lib)
basement  > Preprocessing library for basement-0.0.11..
basement  > linking .stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/Basement/Terminal/Size_hsc_make.o failed (exit code 1)
basement  > rsp file was: ".stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/Basement/Terminal/hsc2hscall86830-2.rsp"
basement  > command was: /usr/bin/cc .stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/Basement/Terminal/Size_hsc_make.o .stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/Basement/Terminal/Size_hsc_utils.o -o .stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/Basement/Terminal/Size_hsc_make -fuse-ld=gold -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/base-4.14.1.0 -liconv -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/integer-simple-0.1.2.0 -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/ghc-prim-0.6.1 -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/rts-1.0 -lm -ldl
basement  > error: clang: error: invalid linker name in argument '-fuse-ld=gold'
basement  > 
Progress 1/2

--  While building package basement-0.0.11 (scroll up to its section to see the error) using:
      /Users/administrator/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.2.1.0 build lib:basement --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Building with cabal also fails:

> foundation % cd basement
> basement % cabal build
Resolving dependencies...
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) (first run)
Configuring library for basement-0.0.11..
Preprocessing library for basement-0.0.11..
linking /Users/administrator/foundation/basement/dist-newstyle/build/x86_64-osx/ghc-8.10.4/basement-0.0.11/build/Basement/Terminal/Size_hsc_make.o failed (exit code 1)
rsp file was: "/Users/administrator/foundation/basement/dist-newstyle/build/x86_64-osx/ghc-8.10.4/basement-0.0.11/build/Basement/Terminal/hsc2hscall86894-2.rsp"
command was: /usr/bin/cc /Users/administrator/foundation/basement/dist-newstyle/build/x86_64-osx/ghc-8.10.4/basement-0.0.11/build/Basement/Terminal/Size_hsc_make.o /Users/administrator/foundation/basement/dist-newstyle/build/x86_64-osx/ghc-8.10.4/basement-0.0.11/build/Basement/Terminal/Size_hsc_utils.o -o /Users/administrator/foundation/basement/dist-newstyle/build/x86_64-osx/ghc-8.10.4/basement-0.0.11/build/Basement/Terminal/Size_hsc_make -fuse-ld=gold -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/base-4.14.1.0 -liconv -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/integer-simple-0.1.2.0 -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/ghc-prim-0.6.1 -L/Users/administrator/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/../lib/x86_64-osx-ghc-8.10.4/rts-1.0 -lm -ldl
error: clang: error: invalid linker name in argument '-fuse-ld=gold'

In fact, calling hsc2hs directly just fails:

> basement % hsc2hs Basement/Terminal/Size.hsc -I cbits              
linking Basement/Terminal/Size_hsc_make.o failed (exit code 1)
rsp file was: "Basement/Terminal/hsc2hscall86916-2.rsp"
command was: /usr/bin/cc Basement/Terminal/Size_hsc_make.o Basement/Terminal/Size_hsc_utils.o -o Basement/Terminal/Size_hsc_make -fuse-ld=gold
error: clang: error: invalid linker name in argument '-fuse-ld=gold'

But providing the -fuse-ld=ld flag succeeds:

> % hsc2hs Basement/Terminal/Size.hsc -I cbits -L-fuse-ld=ld 
# no output 

The only way I am able to compile my project or basement with cabal/stack is using cabal and --hsc2hs-options=-L-fuse-ld=ld.

Expected behavior

I expected it to use ld by default. Even more when the settings file of the GHC specifies ld as ld command:

> ~ % cat .ghcup/ghc/8.10.4/lib/ghc-8.10.4/lib/settings | grep ld
,("ld command", "ld")
,("ld flags", "")
,("ld supports compact unwind", "YES")
,("ld supports build-id", "NO")
,("ld supports filelist", "YES")
,("ld is GNU ld", "NO")
,("Merge objects command", "ld")

Environment

  • GHC version used: 8.8.4 to build 8.10.4
% cabal --version                                                                                                                                                                          
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library 
% stack --version                                                                                                                                                                          
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0

Optional:

  • Operating System: Mac OS
  • System Architecture: x86_64
Edited Mar 09, 2021 by Javier Sagredo
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking