always use -fPIC on OpenBSD/AMD64 platform
authorKarel Gardas <karel.gardas@centrum.cz>
Tue, 7 Jul 2015 16:35:09 +0000 (18:35 +0200)
committerKarel Gardas <karel.gardas@centrum.cz>
Tue, 7 Jul 2015 18:50:03 +0000 (20:50 +0200)
Summary:
This patch switches -fPIC on for every invocation of GHC
on OpenBSD/AMD64 platform. The reason is OpenBSD's support
for PIE (PIC for executables) hence -fPIC is also needed
for GHC compiled code.

Fixes #10597

Reviewers: austin

Subscribers: thomie, bgamari

Differential Revision: https://phabricator.haskell.org/D1027

compiler/main/DynFlags.hs

index 23a5fed..78614a4 100644 (file)
@@ -3228,6 +3228,12 @@ default_PIC :: Platform -> [GeneralFlag]
 default_PIC platform =
   case (platformOS platform, platformArch platform) of
     (OSDarwin, ArchX86_64) -> [Opt_PIC]
+    (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in
+                                         -- OpenBSD since 5.3 release
+                                         -- (1 May 2013) we need to
+                                         -- always generate PIC. See
+                                         -- #10597 for more
+                                         -- information.
     _                      -> []
 
 impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)]