stepcut / plugins

Dynamic linking and runtime evaluation of Haskell, and C, including dependency chasing and package resolution.
GNU Lesser General Public License v2.1
52 stars 17 forks source link

fix build for my doodad using stackage lts-16.13 and cabal 3+ #12

Closed v-e-h closed 4 years ago

v-e-h commented 4 years ago

Hello @stepcut

I've been trying to use the library with a dings I'm making, with the latest stackage lts-16.13 and cabal3+, and there seemed to be incompatibilities due to API changes in cabal, so I ran some mechanical replaces, after going over the two changes which were stopping the build.

my setup:


 ❯ stack --version                                                                                                                                                  [15:04:43]
Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) x86_64 hpack-0.31.2

 ❯ cabal --version                                                                                                                                                  [15:04:59]
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library 

 ❯ sudo aura -Q haskell-cabal                                                                                                                                       [15:05:17]
ghc-libs 8.10.2-1
 ❯ sudo aura -Q cabal-install                                                                                                                                       [15:12:43]
cabal-install 3.2.0.0-71

build spam:

 ❯ stack build                                                                                                                                                      [14:54:34]
Cloning e175d3c2ea9a8cc08126d37d9e30a327d8dc8b29 from git@github.com:v-e-h/plugins.git
Stack has not been tested with GHC versions above 8.6, and using 8.8.4, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
happy      > using precompiled package
ghc-paths  > using precompiled package
random     > using precompiled package
split      > using precompiled package
syb        > using precompiled package
haskell-src> using precompiled package     
plugins    > configure   
plugins    > [1 of 2] Compiling Main             ( /tmp/pszczola/stack540765/plugins-1.6.0/Setup.lhs, /tmp/pszczola/stack540765/plugins-1.6.0/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup/Main.o )
plugins    > [2 of 2] Compiling StackSetupShim   ( /home/pszczola/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /tmp/pszczola/stack540765/plugins-1.6.0/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup/StackSetupShim.o )
plugins    > Linking /tmp/pszczola/stack540765/plugins-1.6.0/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/setup/setup ...
plugins    > Configuring plugins-1.6.0...
plugins    > configure: WARNING: unrecognized options: --with-compiler
plugins    > checking build system type... x86_64-unknown-linux-gnu
plugins    > checking for ghc... ghc
plugins    > checking for value of __GLASGOW_HASKELL__... 808
plugins    > checking for ghc library directory... /home/pszczola/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/lib/ghc-8.8.4
plugins    > checking for gcc... /usr/bin/gcc
plugins    > checking whether the C compiler works... yes
plugins    > checking for C compiler default output file name... a.out
plugins    > checking for suffix of executables... 
plugins    > checking whether we are cross compiling... no
plugins    > checking for suffix of object files... o
plugins    > checking whether we are using the GNU C compiler... yes
plugins    > checking whether /usr/bin/gcc accepts -g... yes
plugins    > checking for /usr/bin/gcc option to accept ISO C89... none needed
plugins    > checking for arc4random... no
plugins    > checking for a BSD-compatible install... /usr/bin/install -c
plugins    > configure: creating ./config.status
plugins    > config.status: creating config.mk
plugins    > config.status: creating testsuite/makewith/io/TestIO.conf
plugins    > config.status: creating testsuite/makewith/unsafeio/Unsafe.conf
plugins    > config.status: creating config.h
plugins    > configure: WARNING: unrecognized options: --with-compiler
plugins    > build   
plugins    > Preprocessing library for plugins-1.6.0..
plugins    > Building library for plugins-1.6.0..
plugins    > [ 1 of 12] Compiling System.Plugins.Consts
plugins    > [ 2 of 12] Compiling System.Plugins.LoadTypes
plugins    > [ 3 of 12] Compiling System.Plugins.Env
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Env.hs:83:1: warning: [-Wdodgy-imports]
plugins    >     Module ‘Distribution.Package’ does not export ‘depends’
plugins    >    |    
plugins    > 83 | import Distribution.Package hiding (
plugins    >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Env.hs:83:1: warning: [-Wdodgy-imports]
plugins    >     The import item ‘PackageName(..)’ suggests that
plugins    >     ‘PackageName’ has (in-scope) constructors or class methods,
plugins    >     but it has none
plugins    >    |    
plugins    > 83 | import Distribution.Package hiding (
plugins    >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Env.hs:83:1: warning: [-Wdodgy-imports]
plugins    >     Module ‘Distribution.Package’ does not export ‘installedPackageId’
plugins    >    |    
plugins    > 83 | import Distribution.Package hiding (
plugins    >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Env.hs:391:16: warning: [-Wunused-matches]
plugins    >     Defined but not used: ‘s’
plugins    >     |   
plugins    > 391 |   (willRemove, s) <- withStaticPkgEnv env $ \s -> return (S.member pkg s, s)
plugins    >     |                ^
plugins    > [ 4 of 12] Compiling System.Plugins.Parser
plugins    > [ 5 of 12] Compiling System.Plugins.Process
plugins    > [ 6 of 12] Compiling System.Plugins.Utils
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Utils.hs:66:1: warning: [-Wunused-imports]
plugins    >     The import of ‘CString, withCString’
plugins    >     from module ‘Foreign.C’ is redundant
plugins    >    |    
plugins    > 66 | import Foreign.C (CInt(..), CString, withCString)
plugins    >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Utils.hs:75:1: warning: [-Wdodgy-imports]
plugins    >     Module ‘Prelude’ does not export ‘catch’
plugins    >    |    
plugins    > 75 | import Prelude hiding (catch)
plugins    >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Utils.hs:127:1: warning: [-Wunused-top-binds]
plugins    >     Defined but not used: ‘openBinaryTempFile’
plugins    >     |   
plugins    > 127 | openBinaryTempFile tmp_dir pfx sfx
plugins    >     | ^^^^^^^^^^^^^^^^^^
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Utils.hs:133:1: warning: [-Wunused-top-binds]
plugins    >     Defined but not used: ‘openTempFileWithDefaultPermissions’
plugins    >     |   
plugins    > 133 | openTempFileWithDefaultPermissions tmp_dir pfx sfx
plugins    >     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Utils.hs:139:1: warning: [-Wunused-top-binds]
plugins    >     Defined but not used: ‘openBinaryTempFileWithDefaultPermissions’
plugins    >     |   
plugins    > 139 | openBinaryTempFileWithDefaultPermissions tmp_dir pfx sfx
plugins    >     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
plugins    > [ 7 of 12] Compiling System.Plugins.Make
plugins    > [ 8 of 12] Compiling System.Plugins.Load
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Load.hs:183:19: warning: [-Wtype-defaults]
plugins    >     • Defaulting the following constraints to type ‘Integer’
plugins    >         (Integral a0)
plugins    >           arising from a use of ‘fromIntegral’
plugins    >           at src/System/Plugins/Load.hs:183:19-32
plugins    >         (Num a0)
plugins    >           arising from the literal ‘0’ at src/System/Plugins/Load.hs:183:32
plugins    >     • In the second argument of ‘($)’, namely ‘fromIntegral 0’
plugins    >       In a stmt of a 'do' block: initLinker_ $ fromIntegral 0
plugins    >       In the expression:
plugins    >         do initLinker_ $ fromIntegral 0
plugins    >            mapM_ addPkgConf pkgconfs
plugins    >            (hif, moduleDeps) <- loadDepends obj incpaths
plugins    >            m' <- loadObject obj . Object . ifaceModuleName $ hif
plugins    >            ....
plugins    >     |   
plugins    > 183 |     initLinker_ $ fromIntegral 0
plugins    >     |                   ^^^^^^^^^^^^^^
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Load.hs:454:28: warning: [-Wtype-defaults]
plugins    >     • Defaulting the following constraints to type ‘Integer’
plugins    >         (Integral a0)
plugins    >           arising from a use of ‘fromIntegral’
plugins    >           at src/System/Plugins/Load.hs:454:28-41
plugins    >         (Num a0)
plugins    >           arising from the literal ‘0’ at src/System/Plugins/Load.hs:454:41
plugins    >     • In the second argument of ‘($)’, namely ‘fromIntegral 0’
plugins    >       In the expression: initLinker_ $ fromIntegral 0
plugins    >       In an equation for ‘initLinker’:
plugins    >           initLinker = initLinker_ $ fromIntegral 0
plugins    >     |   
plugins    > 454 | initLinker = initLinker_ $ fromIntegral 0
plugins    >     |                            ^^^^^^^^^^^^^^
plugins    >         
plugins    > /tmp/pszczola/stack540765/plugins-1.6.0/src/System/Plugins/Load.hs:477:13: warning: [-Wname-shadowing]
plugins    >     This binding for ‘encode’ shadows the existing binding
plugins    >       imported from ‘System.Plugins.Utils’ at src/System/Plugins/Load.hs:68:1-27
plugins    >       (and originally defined at src/System/Plugins/Utils.hs:493:1-6)
plugins    >     |   
plugins    > 477 |    = do let encode = zEncodeString
plugins    >     |             ^^^^^^
plugins    > [ 9 of 12] Compiling System.Plugins
plugins    > [10 of 12] Compiling System.Eval.Utils
plugins    > [11 of 12] Compiling System.Eval.Haskell
plugins    > [12 of 12] Compiling System.Eval
plugins    >         
plugins    > copy/register
plugins    > Installing library in /home/pszczola/.stack/snapshots/x86_64-linux-tinfo6/c304d34d46a215afd1aa4bec16572fb047fb9686deeba06afb61b8678555b7f5/8.8.4/lib/x86_64-linux-ghc-8.8.4/plugins-1.6.0-8Q3L7LrY1F5DGhsFp89EOU
plugins    > Registering library for plugins-1.6.0..

I'm not sure I'm not doing something universally stupid here, but these commits make the package build and at least makeAll seems to still work with the binary built against this version and against lts-16.13. I don't really have any other tests yet because I just started playing around with it last night and I've never looked at the cabal libs before. Please have a look and see if this works, and/or suggest any further changes, I guess.

Cheers, veh.

CC: @drvink

stepcut commented 4 years ago

Thanks for the pull request. I did not write this library, and do not do any pro-active maintenance on this package, but I do merge pull requests and upload to hackage.

This library predates the GHC API and should really be replaced by something which uses the GHC API. I once developed a proof of concept which shows that the GHC API is sufficient to replace this library, but more work more is required to turn it into a useful library,

https://github.com/Happstack/plugins-ng