Why does GHC take so long to link?

前端 未结 3 724
你的背包
你的背包 2020-12-29 06:23
>cabal update
>cabal install cabal-install
.......
[43 of 44] Compiling Distribution.Client.Install ( Distribution/Client/Install.hs, dist/build/cabal/cabal-tm         


        
3条回答
  •  醉梦人生
    2020-12-29 06:31

    This should be a comment, but I cannot format code like this in comments:

    I managed to use gold as the linker used by GHC, working around standard ghc-with-gold errors like /usr/bin/ld.gold: --hash-size=31: unknown option, by installing binutils-gold (as suggested in Michael Snoyman's answer) and then replacing the symlink /usr/bin/ld by the following script (made executable with chmod +x):

    #!/usr/bin/env python2
    
    import sys
    import os
    import subprocess
    
    
    tofilter = [
        "--hash-size",
        "--reduce-memory-overheads",
    ]
    
    filtered = [ a for a in sys.argv if not any(a.startswith(p) for p in tofilter) ]
    filtered[0] = "/usr/bin/ld.gold"
    
    subprocess.check_call(subprocess.list2cmdline(filtered))
    

    Note that trying to set the linker with ghc -pgml /usr/bin/ld.gold or ghc -pgml /usr/bin/ld.whateverElse is not sufficient because the argument to -pgml needs to be a replacement for GCC, not LD. GHC calls GCC, which calls /usr/bin/ld; this is why the above script works.

提交回复
热议问题