summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2017-06-12 17:02:44 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-12 17:02:44 -0400
commitdcdc391609d6ff902989d806266855901c051608 (patch)
tree3dd3e15b9b5eab3cdd6b6a6c0f0e0a8c20fd9aed /compiler
parentf942f65a525dd972cd96e6ae42922b6a3ce4b2d0 (diff)
downloadhaskell-dcdc391609d6ff902989d806266855901c051608.tar.gz
Fix #13807 - foreign import nondeterminism
The problem was that the generated label included a freshly assigned Unique value. Test Plan: Added a new test and looked at the generated stub: ``` #include "HsFFI.h" #ifdef __cplusplus extern "C" { #endif extern HsInt zdmainzdAzdAzuzzlzzgzzg(StgStablePtr the_stableptr); extern HsInt zdmainzdAzdAzumkStringWriter(StgStablePtr the_stableptr); #ifdef __cplusplus } #endif ``` ./validate Reviewers: simonmar, austin, bgamari Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13807 Differential Revision: https://phabricator.haskell.org/D3633
Diffstat (limited to 'compiler')
-rw-r--r--compiler/deSugar/DsForeign.hs13
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/deSugar/DsForeign.hs b/compiler/deSugar/DsForeign.hs
index fb3752d104..9b088b280d 100644
--- a/compiler/deSugar/DsForeign.hs
+++ b/compiler/deSugar/DsForeign.hs
@@ -52,6 +52,7 @@ import OrdList
import Pair
import Util
import Hooks
+import Encoding
import Data.Maybe
import Data.List
@@ -412,16 +413,12 @@ dsFExportDynamic :: Id
-> CCallConv
-> DsM ([Binding], SDoc, SDoc)
dsFExportDynamic id co0 cconv = do
- fe_id <- newSysLocalDs ty
mod <- getModule
dflags <- getDynFlags
- let
- -- hack: need to get at the name of the C stub we're about to generate.
- -- TODO: There's no real need to go via String with
- -- (mkFastString . zString). In fact, is there a reason to convert
- -- to FastString at all now, rather than sticking with FastZString?
- fe_nm = mkFastString (zString (zEncodeFS (moduleNameFS (moduleName mod))) ++ "_" ++ toCName dflags fe_id)
-
+ let fe_nm = mkFastString $ zEncodeString
+ (moduleStableString mod ++ "$" ++ toCName dflags id)
+ -- Construct the label based on the passed id, don't use names
+ -- depending on Unique. See #13807 and Note [Unique Determinism].
cback <- newSysLocalDs arg_ty
newStablePtrId <- dsLookupGlobalId newStablePtrName
stable_ptr_tycon <- dsLookupTyCon stablePtrTyConName