Linker error w/ prof enabled ghc used with stack
Summary
I'm trying to get ghc
built with profiling, then use stack with that ghc
to profile the build of a large codebase to better understand what is going on during compilation.
So far I have ghc
building, installed it to the system, linked it with stack
, but when I build some libraries with stack
, a linker error (ld.gold
) appears. Not all packages will fail to build, and if I try to run stack with the profiled ghc on the "large codebase", a few of the dependencies will be built until there is a problem finding a shared dependency.
The problem manifests itself on both macos and ubuntu.
Steps to reproduce
Build ghc as a binary distribution w/ profiling and install
For both architectures, mac/ubuntu, I used the same commands to build ghc
and repeat the error report.
Note: I the binary distribution is missing wrappers/ghctags
. This might be unrelated, but I need to touch the file in order for the make install
to properly work.
cd ghc/
git checkout -b ghc-8.8.3 d0bab2e3
git submodule update --init
./boot
./configure
./hadrian/build.stack.sh --flavour=prof --configure -j binary-dist --docs=none
cd _build/bindist/ghc-8.8.3-x86_64-unknown-linux/
./configure
touch wrappers/ghctags
sudo make install
Try to build a package with the installed ghc
stack unpack data-dword-0.3.2
cd data-dword-0.3.2/
stack --system-ghc init
echo $'extra-path:\n - /usr/local/bin/\nsystem-ghc: true\ncompiler: ghc-8.8.3\n' >> stack.yaml
stack -v --system-ghc build --ghc-options="-v" 2>&1 | tee build.log
build.log Ubuntu Build Log
build.macos.log MacOs Build Log
Expected behavior
The package should build, and stack should return successfully.
Environment
- GHC version used: 8.8.3
Ubuntu ghc info
bash$ /usr/local/bin/ghc --info
[("Project name","The Glorious Glasgow Haskell Compilation System")
,("GCC extra via C opts"," -fwrapv -fno-builtin")
,("C compiler command","gcc")
,("C compiler flags","")
,("C compiler link flags"," -fuse-ld=gold")
,("C compiler supports -no-pie","YES")
,("Haskell CPP command","gcc")
,("Haskell CPP flags","-E -undef -traditional")
,("ld command","ld.gold")
,("ld flags","")
,("ld supports compact unwind","YES")
,("ld supports build-id","YES")
,("ld supports filelist","NO")
,("ld is GNU ld","YES")
,("ar command","ar")
,("ar flags","q")
,("ar supports at file","YES")
,("ranlib command","ranlib")
,("touch command","touch")
,("dllwrap command","/bin/false")
,("windres command","/bin/false")
,("libtool command","libtool")
,("perl command","/usr/bin/perl")
,("cross compiling","NO")
,("target os","OSLinux")
,("target arch","ArchX86_64")
,("target word size","8")
,("target has GNU nonexec stack","True")
,("target has .ident directive","True")
,("target has subsections via symbols","False")
,("target has RTS linker","YES")
,("Unregisterised","NO")
,("LLVM llc command","llc")
,("LLVM opt command","opt")
,("LLVM clang command","clang")
,("Project version","8.8.3")
,("Project Git commit id","d0bab2e3419e49cdbb1201d4650572b57f33420c")
,("Booter version","8.4.3")
,("Stage","2")
,("Build platform","x86_64-unknown-linux")
,("Host platform","x86_64-unknown-linux")
,("Target platform","x86_64-unknown-linux")
,("Have interpreter","YES")
,("Object splitting supported","YES")
,("Have native code generator","YES")
,("Support SMP","YES")
,("Tables next to code","YES")
,("RTS ways","v thr p thr_p debug_p thr_debug_p l thr_l debug thr_debug dyn thr_dyn debug_dyn l_dyn thr_debug_dyn thr_l_dyn")
,("RTS expects libdw","NO")
,("Support dynamic-too","YES")
,("Support parallel --make","YES")
,("Support reexported-modules","YES")
,("Support thinning and renaming package flags","YES")
,("Support Backpack","YES")
,("Requires unified installed package IDs","YES")
,("Uses package keys","YES")
,("Uses unit IDs","YES")
,("Dynamic by default","NO")
,("GHC Dynamic","NO")
,("GHC Profiled","YES")
,("Leading underscore","NO")
,("Debug on","False")
,("LibDir","/usr/local/lib")
,("Global Package DB","/usr/local/lib/package.conf.d")
]
MacOS ghc info
SS~$ /usr/local/bin/ghc --info
[("Project name","The Glorious Glasgow Haskell Compilation System")
,("GCC extra via C opts"," -fwrapv -fno-builtin")
,("C compiler command","gcc")
,("C compiler flags","")
,("C compiler link flags"," ")
,("C compiler supports -no-pie","NO")
,("Haskell CPP command","gcc")
,("Haskell CPP flags","-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs")
,("ld command","ld")
,("ld flags","")
,("ld supports compact unwind","YES")
,("ld supports build-id","NO")
,("ld supports filelist","YES")
,("ld is GNU ld","NO")
,("ar command","ar")
,("ar flags","qcls")
,("ar supports at file","NO")
,("ranlib command","ranlib")
,("touch command","touch")
,("dllwrap command","/bin/false")
,("windres command","/bin/false")
,("libtool command","libtool")
,("perl command","/usr/local/bin/perl")
,("cross compiling","NO")
,("target os","OSDarwin")
,("target arch","ArchX86_64")
,("target word size","8")
,("target has GNU nonexec stack","False")
,("target has .ident directive","True")
,("target has subsections via symbols","True")
,("target has RTS linker","YES")
,("Unregisterised","NO")
,("LLVM llc command","llc")
,("LLVM opt command","opt")
,("LLVM clang command","clang")
,("Project version","8.8.3")
,("Project Git commit id","d0bab2e3419e49cdbb1201d4650572b57f33420c")
,("Booter version","8.4.3")
,("Stage","2")
,("Build platform","x86_64-apple-darwin")
,("Host platform","x86_64-apple-darwin")
,("Target platform","x86_64-apple-darwin")
,("Have interpreter","YES")
,("Object splitting supported","YES")
,("Have native code generator","YES")
,("Support SMP","YES")
,("Tables next to code","YES")
,("RTS ways","v thr p thr_p debug_p thr_debug_p l thr_l debug thr_debug dyn thr_dyn debug_dyn l_dyn thr_debug_dyn thr_l_dyn")
,("RTS expects libdw","NO")
,("Support dynamic-too","YES")
,("Support parallel --make","YES")
,("Support reexported-modules","YES")
,("Support thinning and renaming package flags","YES")
,("Support Backpack","YES")
,("Requires unified installed package IDs","YES")
,("Uses package keys","YES")
,("Uses unit IDs","YES")
,("Dynamic by default","NO")
,("GHC Dynamic","NO")
,("GHC Profiled","YES")
,("Leading underscore","YES")
,("Debug on","False")
,("LibDir","/usr/local/lib")
,("Global Package DB","/usr/local/lib/package.conf.d")
]
Stack Version: 2.5.1
bash $ stack --version
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
Optional:
for "build.log"
- Operating System: Ubuntu 18.04.4 LTS
- System Architecture: x86_64 GNU/Linux
for "build.macos.log"
- Operating System: macOS Catalina
- System Architecture: x86_64 i386 MacBookPro16,1 Darwin