diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-12-15 01:07:24 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-15 01:38:10 +0100 |
commit | 6d9c18cb43c1fda95932ef0f640dcf41906a2773 (patch) | |
tree | 3c43af6f62a7de90e86e8c29a56bda6fd7ee2bb4 /compiler/nativeGen/PIC.hs | |
parent | 05a5ebed916dc00bc5761224047440fefe10485e (diff) | |
download | haskell-6d9c18cb43c1fda95932ef0f640dcf41906a2773.tar.gz |
DynFlags: remove Opt_Static
There are currently 2 different ways to test for a static or dynamic
build:
* Test if WayDyn is in ways
* Test if Opt_Static is set
The problem is that these can easily go out of sync, especially when
using the
GHC API.
This commit replaces all queries of Opt_Static with an equivalent query
of
WayDyn. This would have prevented bug #8294 and fixes #11154.
Reviewers: hvr, austin, bgamari
Reviewed By: austin, bgamari
Differential Revision: https://phabricator.haskell.org/D1607
GHC Trac Issues: #10636
Diffstat (limited to 'compiler/nativeGen/PIC.hs')
-rw-r--r-- | compiler/nativeGen/PIC.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/nativeGen/PIC.hs b/compiler/nativeGen/PIC.hs index ca556759ed..fa726dddd1 100644 --- a/compiler/nativeGen/PIC.hs +++ b/compiler/nativeGen/PIC.hs @@ -167,7 +167,7 @@ cmmMakePicReference dflags lbl (platformOS $ targetPlatform dflags) lbl ] - | (gopt Opt_PIC dflags || not (gopt Opt_Static dflags)) && absoluteLabel lbl + | (gopt Opt_PIC dflags || WayDyn `elem` ways dflags) && absoluteLabel lbl = CmmMachOp (MO_Add (wordWidth dflags)) [ CmmReg (CmmGlobal PicBaseReg) , CmmLit $ picRelative @@ -220,14 +220,14 @@ howToAccessLabel -- To access the function at SYMBOL from our local module, we just need to -- dereference the local __imp_SYMBOL. -- --- If Opt_Static is set then we assume that all our code will be linked +-- If not compiling with -dynamic we assume that all our code will be linked -- into the same .exe file. In this case we always access symbols directly, -- and never use __imp_SYMBOL. -- howToAccessLabel dflags _ OSMinGW32 this_mod _ lbl -- Assume all symbols will be in the same PE, so just access them directly. - | gopt Opt_Static dflags + | WayDyn `notElem` ways dflags = AccessDirectly -- If the target symbol is in another PE we need to access it via the @@ -317,7 +317,7 @@ 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 (gopt Opt_PIC dflags) && gopt Opt_Static dflags + , not (gopt Opt_PIC dflags) && WayDyn `notElem` ways dflags = AccessDirectly howToAccessLabel dflags arch os this_mod DataReference lbl @@ -439,7 +439,7 @@ needImportedSymbols dflags arch os -- PowerPC Linux: -fPIC or -dynamic | osElfTarget os , arch == ArchPPC - = gopt Opt_PIC dflags || not (gopt Opt_Static dflags) + = gopt Opt_PIC dflags || WayDyn `elem` ways dflags -- PowerPC 64 Linux: always | osElfTarget os @@ -449,7 +449,7 @@ needImportedSymbols dflags arch os -- i386 (and others?): -dynamic but not -fPIC | osElfTarget os , arch /= ArchPPC_64 ELF_V1 && arch /= ArchPPC_64 ELF_V2 - = not (gopt Opt_Static dflags) && not (gopt Opt_PIC dflags) + = WayDyn `elem` ways dflags && not (gopt Opt_PIC dflags) | otherwise = False @@ -650,7 +650,7 @@ pprImportedSymbol _ (Platform { platformOS = OSDarwin }) _ -- section. -- The "official" GOT mechanism (label@got) isn't intended to be used -- in position dependent code, so we have to create our own "fake GOT" --- when not Opt_PIC && not (gopt Opt_Static dflags). +-- when not Opt_PIC && WayDyn `elem` ways dflags. -- -- 2) PowerPC Linux is just plain broken. -- While it's theoretically possible to use GOT offsets larger |