summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
diff options
context:
space:
mode:
authorSimon Marlow <smarlow@fb.com>2018-02-28 11:03:37 -0800
committerSimon Marlow <marlowsd@gmail.com>2018-03-08 08:36:15 +0000
commitd99a65a80cb671363fa41c826b95b9a89de60878 (patch)
treef5a659eb0f44e6b2a62b24f39e4b8db36ba321ed /compiler/nativeGen
parent43fbb905eade2e3e3af67ce944262709763b6578 (diff)
downloadhaskell-d99a65a80cb671363fa41c826b95b9a89de60878.tar.gz
Add -fexternal-dynamic-refs
Summary: The `-dynamic` flag does two things: * In the code generator, it generates code designed to link against external shared libraries. References outside of the current module go through platform-specific indirection tables (e.g. the GOT on ELF). * It enables a "way", which changes which hi files we look for (`Foo.dyn_hi`) and which libraries we link against. Some specialised applications want the first of these without the second. (I could go into detail here but it's probably not all that important). This diff splits out the code-generation effects of `-dynamic` from the "way" parts of its behaviour, via a new flag `-fexternal-dynamic-refs`. Test Plan: validate Reviewers: niteria, bgamari, erikd Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4477
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r--compiler/nativeGen/PIC.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/nativeGen/PIC.hs b/compiler/nativeGen/PIC.hs
index 834aa1b86c..b28e0fc68f 100644
--- a/compiler/nativeGen/PIC.hs
+++ b/compiler/nativeGen/PIC.hs
@@ -178,7 +178,8 @@ cmmMakePicReference dflags lbl
(platformOS $ targetPlatform dflags)
lbl ]
- | (positionIndependent dflags || WayDyn `elem` ways dflags) && absoluteLabel lbl
+ | (positionIndependent dflags || gopt Opt_ExternalDynamicRefs dflags)
+ && absoluteLabel lbl
= CmmMachOp (MO_Add (wordWidth dflags))
[ CmmReg (CmmGlobal PicBaseReg)
, CmmLit $ picRelative
@@ -238,7 +239,7 @@ howToAccessLabel
howToAccessLabel dflags _ OSMinGW32 this_mod _ lbl
-- Assume all symbols will be in the same PE, so just access them directly.
- | WayDyn `notElem` ways dflags
+ | not (gopt Opt_ExternalDynamicRefs dflags)
= AccessDirectly
-- If the target symbol is in another PE we need to access it via the
@@ -339,7 +340,8 @@ howToAccessLabel dflags _ os _ _ _
-- if we don't dynamically link to Haskell code,
-- it actually manages to do so without messing things up.
| osElfTarget os
- , not (positionIndependent dflags) && WayDyn `notElem` ways dflags
+ , not (positionIndependent dflags) &&
+ not (gopt Opt_ExternalDynamicRefs dflags)
= AccessDirectly
howToAccessLabel dflags arch os this_mod DataReference lbl
@@ -470,7 +472,7 @@ needImportedSymbols dflags arch os
-- PowerPC Linux: -fPIC or -dynamic
| osElfTarget os
, arch == ArchPPC
- = positionIndependent dflags || WayDyn `elem` ways dflags
+ = positionIndependent dflags || gopt Opt_ExternalDynamicRefs dflags
-- PowerPC 64 Linux: always
| osElfTarget os
@@ -480,7 +482,8 @@ needImportedSymbols dflags arch os
-- i386 (and others?): -dynamic but not -fPIC
| osElfTarget os
, arch /= ArchPPC_64 ELF_V1 && arch /= ArchPPC_64 ELF_V2
- = WayDyn `elem` ways dflags && not (positionIndependent dflags)
+ = gopt Opt_ExternalDynamicRefs dflags &&
+ not (positionIndependent dflags)
| otherwise
= False