Closed farzadbekran closed 2 years ago
@agentm Sorry for some reason I cant connect to IRC. Text library version is set to : text >=0.11 && <2.0
and the stack resolver is: lts-16.31
Let me know if you need anything else.
I tried a stripped down example of this with just cabal:
{-# LANGUAGE OverloadedStrings #-}
module Issue311 where
import Data.Text
import ProjectM36.Base
import ProjectM36.AtomFunctionError
func :: [Atom] -> Either AtomFunctionError Atom
func (x:[]) = pure x
func _ = error "bad"
atomFunctions :: [AtomFunction]
atomFunctions =
[ AtomFunction { atomFuncName = "func"
, atomFuncType = [ IntegerAtomType
, IntegerAtomType]
, atomFuncBody = AtomFunctionBody Nothing func
}
]
built with:
cabal exec ghc Issue311.hs
TutorialD (master/main): loadatomfunctions "Issue311" "atomFunctions" "Issue311.o"
tutd: Issue311.o: unknown symbol `ghczmprim_GHCziCString_unpackCStringzh_closure'
tutd: Could not load Object Code Issue311.o.
Indeed, tutd does not include this symbol:
strings dist-newstyle/build/x86_64-linux/ghc-8.10.4/project-m36-0.9.3/x/tutd/build/tutd/tutd|grep ghczmprim_GHCziCString
ghczmprim_GHCziCString_unpackNByteszh_closure
ghczmprim_GHCziCString_unpackFoldrCStringzh_closure
ghczmprim_GHCziCString_unpackAppendCStringzh_closure
ghczmprim_GHCziCString_unpackCStringzh_info
ghczmprim_GHCziCString_unpackAppendCStringzh_info
ghczmprim_GHCziCString_unpackFoldrCStringzh_info
ghczmprim_GHCziCString_unpackCStringUtf8zh_info
ghczmprim_GHCziCString_unpackNByteszh_info
If I remove the error "bad"
, then I get a different missing symbol:
tutd: Issue311.o: unknown symbol `base_DataziEither_zdfApplicativeEither_closure'
tutd: Could not load Object Code Issue311.o.
I realized that ghc must be stripping these "unused" symbols and noticed that tutd is not built with -rdynamic
which prevents this. Originally, I thought that -rdynamic
at the library level would be sufficient, but apparently it is needed at the executable level, too.
Just for reference, there are two other ways to add new AtomFunctions to Project:M36:
I've made a few atom functions: Gist Link
I use stack to compile it from project root:
which compile without errors. then I start project-m36-server and tutd from the project root and load the object file like this:
no problem so far, but when I run
:showatomfunctions
in tutd, the server crashes with these errors: