
Replying to [comment:19 slyfox]:
Hardened gentoo patches gcc to default to -fPIC -fPIE -pie. Defaults
#9007: fails to build with hardening flags enabled (relocation R_X86_64_32 against `stg_CHARLIKE_closure'...) -------------------------------------+------------------------------------- Reporter: nomeata | Owner: nomeata Type: bug | Status: infoneeded Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by slyfox): Replying to [comment:21 kgardas]: there:
... An evil corner case as we use ld for partial linking. Can be an argument for native fPIE/pie support in ghc.
I'm curious but isn't -split-objs purely static library thing? IMHO it's not usable for -shared nor -dynamic nor -fPIC etc. Please correct me if I'm wrong here...
A couple of points here: - -fPIC is valid for static libraries (it's used for hardening even statically linked binaries), recent example of accidental fPIC no a static haskell library: https://ghc.haskell.org/trac/ghc/ticket/10402#comment:14 . It's not necessary but not outright harmful. - -split-objs used to split .o files into smaller .o files to allow linker remove unused code. That unused code can come from: - external static haskell library (typical case) when linking static binary, no need to run -spit-objs - internal static or dynamic haskell library (or binary) I would say it makes sense to run -split-objs every time object files are produced. I view it as trick similar to 'gcc -function-sections -fdata- sections -Wl,--gc-sections'. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9007#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler