Compare commits

...

11 Commits

Author SHA1 Message Date
Jon Doe
c59e1df710 maybe fix build for lts-16.13 2020-09-13 14:53:32 +02:00
Jon Doe
5e2355eadd uh maybe fix api incompatibility for stackage lts-14.27 2020-09-13 14:48:12 +02:00
Jeremy Shaw
09b3a1d7cd bumped version to 1.6.0 2019-09-03 11:58:22 -05:00
Jeremy Shaw
e5fa9c39f6 Merge pull request #11 from noughtmare/master
Pretty ugly fix for #10
2019-09-03 11:55:20 -05:00
Jeremy Shaw
78fa51c00c regen .travis.yml 2019-09-03 09:52:21 -05:00
Jaro Reinders
9c5017edee pretty ugly fix #10 2019-08-13 16:25:52 +02:00
Jeremy Shaw
991e54a928 Merge pull request #9 from galenhuntington/master
Try to get this package working again.
2019-03-18 11:39:05 -05:00
Galen Huntington
ff6d053a4c Try to integrate @abarbu patches. 2019-03-15 21:43:56 -07:00
Galen Huntington
f569b82460 Get this to compile. 2019-03-15 21:10:40 -07:00
Jeremy Shaw
0f9def059a bumped version to 1.5.7 2018-01-23 08:40:30 -06:00
Jeremy Shaw
98892b0fa3 Merge pull request #6 from drvink/recent-ghc
Fixes for GHC 8.x, archive loading, -dynamic, and file generation
2018-01-22 22:34:40 -06:00
12 changed files with 216 additions and 177 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
/testsuite/makewith/io/TestIO.conf /testsuite/makewith/io/TestIO.conf
/testsuite/makewith/unsafeio/Unsafe.conf /testsuite/makewith/unsafeio/Unsafe.conf
/.stack-work/ /.stack-work/
/dist-newstyle/

View File

@ -1,112 +1,119 @@
# This file has been generated -- see https://github.com/hvr/multi-ghc-travis # This Travis job script has been generated by a script via
#
# haskell-ci 'plugins.cabal'
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.2.1
#
language: c language: c
sudo: false dist: xenial
git:
submodules: false # whether to recursively clone submodules
cache: cache:
directories: directories:
- $HOME/.cabsnap
- $HOME/.cabal/packages - $HOME/.cabal/packages
- $HOME/.cabal/store
before_cache: before_cache:
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar # remove files that are regenerated by 'cabal update'
- rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
- rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
- rm -rfv $CABALHOME/packages/head.hackage
matrix: matrix:
include: include:
- env: CABALVER=1.16 GHCVER=7.4.1 HAPPYVER=1.19.5 - compiler: "ghc-8.6.4"
compiler: ": #GHC 7.4.1" addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.6.4], sources: [hvr-ghc]}}
addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.1,happy-1.19.5], sources: [hvr-ghc]}} - compiler: "ghc-8.2.2"
- env: CABALVER=1.16 GHCVER=7.4.2 HAPPYVER=1.19.5 addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.2.2], sources: [hvr-ghc]}}
compiler: ": #GHC 7.4.2" - compiler: "ghc-8.0.2"
addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2,happy-1.19.5], sources: [hvr-ghc]}} addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.0.2], sources: [hvr-ghc]}}
- env: CABALVER=1.16 GHCVER=7.6.1 HAPPYVER=1.19.5 - compiler: "ghc-7.10.3"
compiler: ": #GHC 7.6.1" addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.10.3], sources: [hvr-ghc]}}
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.1,happy-1.19.5], sources: [hvr-ghc]}} - compiler: "ghc-7.8.4"
- env: CABALVER=1.16 GHCVER=7.6.2 HAPPYVER=1.19.5 addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.8.4], sources: [hvr-ghc]}}
compiler: ": #GHC 7.6.2" - compiler: "ghc-7.6.3"
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.2,happy-1.19.5], sources: [hvr-ghc]}} addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.6.3], sources: [hvr-ghc]}}
- env: CABALVER=1.16 GHCVER=7.6.3 HAPPYVER=1.19.5 - compiler: "ghc-7.4.2"
compiler: ": #GHC 7.6.3" addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.4.2], sources: [hvr-ghc]}}
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.18 GHCVER=7.8.1 HAPPYVER=1.19.5
compiler: ": #GHC 7.8.1"
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.1,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.18 GHCVER=7.8.2 HAPPYVER=1.19.5
compiler: ": #GHC 7.8.2"
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.2,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.18 GHCVER=7.8.3 HAPPYVER=1.19.5
compiler: ": #GHC 7.8.3"
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.3,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.18 GHCVER=7.8.4 HAPPYVER=1.19.5
compiler: ": #GHC 7.8.4"
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.22 GHCVER=7.10.1 HAPPYVER=1.19.5
compiler: ": #GHC 7.10.1"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.22 GHCVER=7.10.2 HAPPYVER=1.19.5
compiler: ": #GHC 7.10.2"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.22 GHCVER=7.10.3 HAPPYVER=1.19.5
compiler: ": #GHC 7.10.3"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
- env: CABALVER=1.24 GHCVER=8.0.1 HAPPYVER=1.19.5
compiler: ": #GHC 8.0.1"
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5], sources: [hvr-ghc]}}
before_install: before_install:
- unset CC - HC=/opt/ghc/bin/${CC}
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/happy/$HAPPYVER/bin:$PATH - HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- CABAL=/opt/ghc/bin/cabal
- CABALHOME=$HOME/.cabal
- export PATH="$CABALHOME/bin:$PATH"
- ROOTDIR=$(pwd)
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
- echo $HCNUMVER
install: install:
- cabal --version - ${CABAL} --version
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ]; - TEST=--enable-tests
then - BENCH=--enable-benchmarks
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz > - GHCHEAD=${GHCHEAD-false}
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar; - travis_retry ${CABAL} update -v
fi - sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
- travis_retry cabal update -v - rm -fv cabal.project cabal.project.local
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config - grep -Ev -- '^\s*--' $CABALHOME/config | grep -Ev '^\s*$'
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt - rm -f cabal.project
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt - touch cabal.project
- "printf 'packages: \".\"\\n' >> cabal.project"
# check whether current requested install-plan matches cached package-db snapshot - "printf 'write-ghc-environment-files: always\\n' >> cabal.project"
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt; - touch cabal.project.local
then - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(plugins)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
echo "cabal build-cache HIT"; - cat cabal.project || true
rm -rfv .ghc; - cat cabal.project.local || true
cp -a $HOME/.cabsnap/ghc $HOME/.ghc; - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/; - rm -f cabal.project.freeze
else - ${CABAL} new-freeze -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dry
echo "cabal build-cache MISS"; - "cat \"cabal.project.freeze\" | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
rm -rf $HOME/.cabsnap; - rm "cabal.project.freeze"
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin; - ${CABAL} new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
cabal install --only-dependencies --enable-tests --enable-benchmarks; - ${CABAL} new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
fi - rm -rf .ghc.environment.* "."/dist
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
# snapshot package-db on cache miss
- if [ ! -d $HOME/.cabsnap ];
then
echo "snapshotting package-db to build-cache";
mkdir $HOME/.cabsnap;
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
fi
# Here starts the actual work to be performed for the package under test; # Here starts the actual work to be performed for the package under test;
# any command which exits with a non-zero exit code causes the build to fail. # any command which exits with a non-zero exit code causes the build to fail.
script: script:
- if [ -f configure.ac ]; then autoreconf -i; fi # test that source-distributions can be generated
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging - ${CABAL} new-sdist all
- cabal build # this builds all libraries and executables (including tests/benchmarks) - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
- cabal test - cd ${DISTDIR} || false
- cabal check - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
- cabal sdist # tests that a source-distribution can be generated - rm -f cabal.project
- touch cabal.project
- "printf 'packages: \"plugins-*/*.cabal\"\\n' >> cabal.project"
- "printf 'write-ghc-environment-files: always\\n' >> cabal.project"
- touch cabal.project.local
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(plugins)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
- cat cabal.project || true
- cat cabal.project.local || true
# this builds all libraries and executables (without tests/benchmarks)
- ${CABAL} new-build -w ${HC} --disable-tests --disable-benchmarks all
# Check that the resulting source distribution can be built & installed. # build & run tests, build benchmarks
# If there are no other `.tar.gz` files in `dist`, this can be even simpler: - ${CABAL} new-build -w ${HC} ${TEST} ${BENCH} all
# `cabal install --force-reinstalls dist/*-*.tar.gz`
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
# cabal check
- (cd plugins-* && ${CABAL} check)
# haddock
- ${CABAL} new-haddock -w ${HC} ${TEST} ${BENCH} all
# Build without installed constraints for packages in global-db
- rm -f cabal.project.local; ${CABAL} new-build -w ${HC} --disable-tests --disable-benchmarks all;
# REGENDATA ["plugins.cabal"]
# EOF # EOF

View File

@ -1,5 +1,5 @@
name: plugins name: plugins
version: 1.5.6.1 version: 1.6.0
homepage: https://github.com/stepcut/plugins homepage: https://github.com/stepcut/plugins
synopsis: Dynamic linking for Haskell and C objects synopsis: Dynamic linking for Haskell and C objects
description: Dynamic linking and runtime evaluation of Haskell, description: Dynamic linking and runtime evaluation of Haskell,
@ -20,12 +20,13 @@ author: Don Stewart 2004..2010
maintainer: Jeremy Shaw <jeremy@seereason.com> maintainer: Jeremy Shaw <jeremy@seereason.com>
cabal-version: >= 1.6 cabal-version: >= 1.6
build-type: Configure build-type: Configure
Tested-with: GHC == 7.4.* Tested-with: GHC == 7.4.2
, GHC == 7.6.* , GHC == 7.6.3
, GHC == 7.8.* , GHC == 7.8.4
, GHC == 7.10.* , GHC == 7.10.3
, GHC == 8.0.* , GHC == 8.0.2
, GHC == 8.2.* , GHC == 8.2.2
, GHC == 8.6.4
extra-source-files: config.guess, config.h.in, config.mk.in, config.sub, extra-source-files: config.guess, config.h.in, config.mk.in, config.sub,
configure, configure.ac, install.sh, Makefile, configure, configure.ac, install.sh, Makefile,
testsuite/makewith/io/TestIO.conf.in, testsuite/makewith/io/TestIO.conf.in,
@ -59,6 +60,7 @@ library
filepath, filepath,
random, random,
process, process,
split,
ghc >= 6.10, ghc >= 6.10,
ghc-prim ghc-prim

View File

@ -20,7 +20,7 @@
module System.Plugins.Consts where module System.Plugins.Consts where
#include "../../../config.h" #include "config.h"
#if __GLASGOW_HASKELL__ >= 604 #if __GLASGOW_HASKELL__ >= 604

View File

@ -40,17 +40,19 @@ module System.Plugins.Env (
lookupMerged, lookupMerged,
addMerge, addMerge,
addPkgConf, addPkgConf,
defaultPkgConf,
union, union,
addStaticPkg, addStaticPkg,
isStaticPkg, isStaticPkg,
rmStaticPkg, rmStaticPkg,
grabDefaultPkgConf, grabDefaultPkgConf,
readPackageConf, readPackageConf,
lookupPkg lookupPkg,
pkgManglingPrefix
) where ) where
#include "../../../config.h" #include "config.h"
import System.Plugins.LoadTypes (Module) import System.Plugins.LoadTypes (Module)
import System.Plugins.Consts ( sysPkgSuffix ) import System.Plugins.Consts ( sysPkgSuffix )
@ -59,7 +61,7 @@ import Control.Monad ( liftM )
import Data.IORef ( writeIORef, readIORef, newIORef, IORef() ) import Data.IORef ( writeIORef, readIORef, newIORef, IORef() )
import Data.Maybe ( isJust, isNothing, fromMaybe ) import Data.Maybe ( isJust, isNothing, fromMaybe )
import Data.List ( (\\), nub, ) import Data.List ( (\\), nub )
import System.IO.Unsafe ( unsafePerformIO ) import System.IO.Unsafe ( unsafePerformIO )
import System.Directory ( doesFileExist ) import System.Directory ( doesFileExist )
@ -76,13 +78,14 @@ import DynFlags (
Way(WayDyn), dynamicGhc, ways, Way(WayDyn), dynamicGhc, ways,
#endif #endif
defaultDynFlags, initDynFlags) defaultDynFlags, initDynFlags)
import SysTools (initSysTools) import SysTools (initSysTools, initLlvmConfig)
import Distribution.Package hiding ( import Distribution.Package hiding (
#if MIN_VERSION_ghc(7,6,0) #if MIN_VERSION_ghc(7,6,0)
Module, Module,
#endif #endif
depends, packageName, PackageName(..) depends, packageName, PackageName(..)
, installedUnitId
#if MIN_VERSION_ghc(7,10,0) #if MIN_VERSION_ghc(7,10,0)
, installedPackageId , installedPackageId
#endif #endif
@ -96,6 +99,9 @@ import Distribution.Simple.PackageIndex
import Distribution.Simple.Program import Distribution.Simple.Program
import Distribution.Verbosity import Distribution.Verbosity
import System.Environment
import Data.List.Split
import qualified Data.Map as M import qualified Data.Map as M
import qualified Data.Set as S import qualified Data.Set as S
-- --
@ -305,6 +311,15 @@ addPkgConf f = do
ps <- readPackageConf f ps <- readPackageConf f
modifyPkgEnv env $ \ls -> return $ union ls ps modifyPkgEnv env $ \ls -> return $ union ls ps
-- | This function is required when running with stack.
defaultPkgConf :: IO ()
defaultPkgConf = do
paths <- lookupEnv "GHC_PACKAGE_PATH"
unsetEnv "GHC_PACKAGE_PATH"
case paths of
Nothing -> return ()
Just s -> mapM_ addPkgConf $ splitOn ":" s
-- --
-- | add a new FM for the package.conf to the list of existing ones; if a package occurs multiple -- | add a new FM for the package.conf to the list of existing ones; if a package occurs multiple
-- times, pick the one with the higher version number as the default (e.g., important for base in -- times, pick the one with the higher version number as the default (e.g., important for base in
@ -316,14 +331,14 @@ union ls ps' =
in foldr addOnePkg fm ps' : ls in foldr addOnePkg fm ps' : ls
where where
-- we add each package with and without it's version number and with the full installedPackageId -- we add each package with and without it's version number and with the full installedPackageId
addOnePkg p fm' = addToPkgEnvs (addToPkgEnvs (addToPkgEnvs fm' (display $ sourcePackageId p) p) (display $ installedPackageId p) p) addOnePkg p fm' = addToPkgEnvs (addToPkgEnvs (addToPkgEnvs fm' (display $ sourcePackageId p) p) (display $ packageId p) p)
(packageName p) p (packageName p) p
-- if no version number specified, pick the higher version -- if no version number specified, pick the higher version
addToPkgEnvs = addWithFM higherVersion addToPkgEnvs = addWithFM higherVersion
higherVersion pkgconf1 pkgconf2 higherVersion pkgconf1 pkgconf2
| installedPackageId pkgconf1 >= installedPackageId pkgconf2 = pkgconf1 | packageId pkgconf1 >= packageId pkgconf2 = pkgconf1
| otherwise = pkgconf2 | otherwise = pkgconf2
-- --
@ -335,7 +350,7 @@ union ls ps' =
grabDefaultPkgConf :: IO PkgEnvs grabDefaultPkgConf :: IO PkgEnvs
grabDefaultPkgConf = do grabDefaultPkgConf = do
pc <- configureAllKnownPrograms silent defaultProgramConfiguration pc <- configureAllKnownPrograms silent defaultProgramDb
#if MIN_VERSION_Cabal(1,24,0) #if MIN_VERSION_Cabal(1,24,0)
(compiler, _platform, _programConfiguration) (compiler, _platform, _programConfiguration)
<- configure silent Nothing Nothing pc <- configure silent Nothing Nothing pc
@ -351,7 +366,7 @@ grabDefaultPkgConf = do
-- --
readPackageConf :: FilePath -> IO [PackageConfig] readPackageConf :: FilePath -> IO [PackageConfig]
readPackageConf f = do readPackageConf f = do
pc <- configureAllKnownPrograms silent defaultProgramConfiguration pc <- configureAllKnownPrograms silent defaultProgramDb
#if MIN_VERSION_Cabal(1,24,0) #if MIN_VERSION_Cabal(1,24,0)
(compiler, _platform, _programConfiguration) (compiler, _platform, _programConfiguration)
<- configure silent Nothing Nothing pc <- configure silent Nothing Nothing pc
@ -407,6 +422,17 @@ lookupPkg pn = go [] pn
(f', g') <- liftM unzip $ mapM (go (nub $ seen ++ ps)) (ps \\ seen) (f', g') <- liftM unzip $ mapM (go (nub $ seen ++ ps)) (ps \\ seen)
return $ (nub $ (concat f') ++ f, if static then [] else nub $ (concat g') ++ g) return $ (nub $ (concat f') ++ f, if static then [] else nub $ (concat g') ++ g)
-- This is the prefix of mangled symbols that come from this package.
pkgManglingPrefix :: PackageName -> IO (Maybe String)
-- base seems to be mangled differently!
pkgManglingPrefix "base" = return $ Just "base"
pkgManglingPrefix p = withPkgEnvs env $ \fms -> return (go fms p)
where
go [] _ = Nothing
go (fm:fms) q = case lookupFM fm q of
Nothing -> go fms q -- look in other pkgs
Just pkg -> Just $ drop 2 $ getHSLibraryName $ installedUnitId pkg
data LibrarySpec data LibrarySpec
= DLL String -- -lLib = DLL String -- -lLib
| DLLPath FilePath -- -Lpath | DLLPath FilePath -- -Lpath
@ -459,14 +485,15 @@ lookupPkg' p = withPkgEnvs env $ \fms -> go fms p
ldOptsPaths = [ path | Just (DLLPath path) <- ldInput ] ldOptsPaths = [ path | Just (DLLPath path) <- ldInput ]
dlls = map mkSOName (extras ++ ldOptsLibs) dlls = map mkSOName (extras ++ ldOptsLibs)
#if defined(CYGWIN) || defined(__MINGW32__) #if defined(CYGWIN) || defined(__MINGW32__)
libdirs = fix_topdir (libraryDirs pkg) ++ ldOptsPaths libdirs = fix_topdir (libraryDirs pkg) ++ ldOptsPaths ++ fix_topdir (libraryDynDirs pkg)
#else #else
libdirs = libraryDirs pkg ++ ldOptsPaths libdirs = libraryDirs pkg ++ ldOptsPaths ++ libraryDynDirs pkg
#endif #endif
-- If we're loading dynamic libs we need the cbits to appear before the -- If we're loading dynamic libs we need the cbits to appear before the
-- real packages. -- real packages.
settings <- initSysTools (Just libdir) settings <- initSysTools (libdir)
dflags <- initDynFlags $ defaultDynFlags settings llvmConfig <- initLlvmConfig (libdir)
dflags <- initDynFlags $ defaultDynFlags settings llvmConfig
libs <- mapM (findHSlib libs <- mapM (findHSlib
#if MIN_VERSION_ghc(7,8,0) #if MIN_VERSION_ghc(7,8,0)
(WayDyn `elem` ways dflags || dynamicGhc) (WayDyn `elem` ways dflags || dynamicGhc)
@ -530,9 +557,15 @@ lookupPkg' p = withPkgEnvs env $ \fms -> go fms p
-- Solution: look for dynamic libraries only if using -dynamic; otherwise, use static -- Solution: look for dynamic libraries only if using -dynamic; otherwise, use static
-- and add any other dynamic libraries found. -- and add any other dynamic libraries found.
dl <- findHSdlib dirs lib dl <- findHSdlib dirs lib
let rdl = case dl of rdl <- case dl of
Just file -> Right $ Dynamic file Just file -> return $ Right $ Dynamic file
Nothing -> Left lib Nothing -> do
-- TODO Generate this suffix automatically. It's absurd we have to use the preprocessor.
dynamicSuffix <- findHSdlib dirs (lib ++ "-ghc" ++ (reverse $ takeWhile (/= '-') $ reverse GHC_LIB_PATH))
case dynamicSuffix of
Just file -> return $ Right $ Dynamic file
Nothing -> return $ Left lib
if dynonly then return rdl else do if dynonly then return rdl else do
rsl <- findHSslib dirs lib rsl <- findHSslib dirs lib
return $ case rsl of return $ case rsl of

View File

@ -61,7 +61,7 @@ module System.Plugins.Load (
) where ) where
#include "../../../config.h" #include "config.h"
import System.Plugins.Make ( build ) import System.Plugins.Make ( build )
import System.Plugins.Env import System.Plugins.Env
@ -104,7 +104,7 @@ import GHC ( defaultCallbacks )
#else #else
import DynFlags (defaultDynFlags, initDynFlags) import DynFlags (defaultDynFlags, initDynFlags)
import GHC.Paths (libdir) import GHC.Paths (libdir)
import SysTools (initSysTools) import SysTools (initSysTools, initLlvmConfig)
#endif #endif
import GHC.Ptr ( Ptr(..), nullPtr ) import GHC.Ptr ( Ptr(..), nullPtr )
#if !MIN_VERSION_ghc(7,4,1) #if !MIN_VERSION_ghc(7,4,1)
@ -126,8 +126,9 @@ readBinIface' :: FilePath -> IO ModIface
readBinIface' hi_path = do readBinIface' hi_path = do
-- kludgy as hell -- kludgy as hell
#if MIN_VERSION_ghc(7,2,0) #if MIN_VERSION_ghc(7,2,0)
mySettings <- initSysTools (Just libdir) -- how should we really set the top dir? mySettings <- initSysTools (libdir) -- how should we really set the top dir?
dflags <- initDynFlags (defaultDynFlags mySettings) llvmConfig <- initLlvmConfig (libdir)
dflags <- initDynFlags (defaultDynFlags mySettings llvmConfig)
e <- newHscEnv dflags e <- newHscEnv dflags
#else #else
e <- newHscEnv defaultCallbacks undefined e <- newHscEnv defaultCallbacks undefined
@ -259,11 +260,11 @@ pdynload object incpaths pkgconfs ty sym = do
#if DEBUG #if DEBUG
putStr "Checking types ... " >> hFlush stdout putStr "Checking types ... " >> hFlush stdout
#endif #endif
errors <- unify object incpaths [] ty sym (errors, success) <- unify object incpaths [] ty sym
#if DEBUG #if DEBUG
putStrLn "done" putStrLn "done"
#endif #endif
if null errors if success
then load object incpaths pkgconfs sym then load object incpaths pkgconfs sym
else return $ LoadFailure errors else return $ LoadFailure errors
@ -283,11 +284,11 @@ pdynload_ object incpaths pkgconfs args ty sym = do
#if DEBUG #if DEBUG
putStr "Checking types ... " >> hFlush stdout putStr "Checking types ... " >> hFlush stdout
#endif #endif
errors <- unify object incpaths args ty sym (errors, success) <- unify object incpaths args ty sym
#if DEBUG #if DEBUG
putStrLn "done" putStrLn "done"
#endif #endif
if null errors if success
then load object incpaths pkgconfs sym then load object incpaths pkgconfs sym
else return $ LoadFailure errors else return $ LoadFailure errors
@ -316,9 +317,9 @@ unify obj incs args ty sym = do
hWrite hdl src hWrite hdl src
e <- build tmpf tmpf1 (i:is++args++["-fno-code","-c","-ohi "++tmpf1]) (e,success) <- build tmpf tmpf1 (i:is++args++["-fno-code","-c","-ohi "++tmpf1])
mapM_ removeFile [tmpf,tmpf1] mapM_ removeFile [tmpf,tmpf1]
return e return (e, success)
where where
-- fix up hierarchical names -- fix up hierarchical names
@ -473,10 +474,17 @@ loadFunction__ :: Maybe String
-> String -> String
-> IO (Maybe a) -> IO (Maybe a)
loadFunction__ pkg m valsym loadFunction__ pkg m valsym
= do let symbol = prefixUnderscore++(maybe "" (\p -> zEncodeString p++"_") pkg) = do let encode = zEncodeString
++zEncodeString m++"_"++(zEncodeString valsym)++"_closure" p <- case pkg of
Just p -> do
prefix <- pkgManglingPrefix p
return $ encode (maybe p id prefix)++"_"
Nothing -> return ""
let symbol = prefixUnderscore++p++encode m++"_"++(encode valsym)++"_closure"
#if DEBUG #if DEBUG
putStrLn $ "Looking for <<"++symbol++">>" putStrLn $ "Looking for <<"++symbol++">>"
initLinker
#endif #endif
ptr@(Ptr addr) <- withCString symbol c_lookupSymbol ptr@(Ptr addr) <- withCString symbol c_lookupSymbol
if (ptr == nullPtr) if (ptr == nullPtr)
@ -595,10 +603,15 @@ unloadObj (Module { path = p, kind = k, key = ky }) = case k of
-- Load a .so type object file. -- Load a .so type object file.
-- --
loadShared :: FilePath -> IO Module loadShared :: FilePath -> IO Module
loadShared str = do loadShared str' = do
#if DEBUG #if DEBUG
putStrLn $ " shared: " ++ str putStrLn $ " shared: " ++ str'
#endif #endif
let str = case str' of
-- TODO My GHC segfaults because libm.so is a linker script
"libm.so" -> "/lib/x86_64-linux-gnu/libm.so.6"
"libpthread.so" -> "/lib/x86_64-linux-gnu/libpthread.so.0"
x -> x
maybe_errmsg <- withCString str $ \dll -> c_addDLL dll maybe_errmsg <- withCString str $ \dll -> c_addDLL dll
if maybe_errmsg == nullPtr if maybe_errmsg == nullPtr
then return (Module str (mkModid str) Shared undefined (Package (mkModid str))) then return (Module str (mkModid str) Shared undefined (Package (mkModid str)))
@ -617,6 +630,7 @@ loadShared str = do
-- --
loadPackage :: String -> IO () loadPackage :: String -> IO ()
loadPackage p = do loadPackage p = do
initLinker
#if DEBUG #if DEBUG
putStr (' ':p) >> hFlush stdout putStr (' ':p) >> hFlush stdout
#endif #endif

View File

@ -269,11 +269,11 @@ rawMake src args docheck = do
#if DEBUG #if DEBUG
putStr "Compiling object ... " >> hFlush stdout putStr "Compiling object ... " >> hFlush stdout
#endif #endif
err <- build src obj args (err, success) <- build src obj args
#if DEBUG #if DEBUG
putStrLn "done" putStrLn "done"
#endif #endif
return $ if null err return $ if success
then MakeSuccess ReComp obj then MakeSuccess ReComp obj
else MakeFailure err else MakeFailure err
} }
@ -287,7 +287,7 @@ rawMake src args docheck = do
build :: FilePath -- ^ path to .hs source build :: FilePath -- ^ path to .hs source
-> FilePath -- ^ path to object file -> FilePath -- ^ path to object file
-> [String] -- ^ any extra cmd line flags -> [String] -- ^ any extra cmd line flags
-> IO [String] -> IO ([String], Bool)
build src obj extra_opts = do build src obj extra_opts = do
@ -306,12 +306,12 @@ build src obj extra_opts = do
putStr $ show $ ghc : flags putStr $ show $ ghc : flags
#endif #endif
(_out,err) <- exec ghc flags -- this is a fork() (_out,err,success) <- exec ghc flags -- this is a fork()
obj_exists <- doesFileExist obj -- sanity obj_exists <- doesFileExist obj -- sanity
return $ if not obj_exists && null err -- no errors, but no object? return $ if not obj_exists && success
then ["Compiled, but didn't create object file `"++obj++"'!"] then (["Compiled, but didn't create object file `"++obj++"'!"], success)
else err else (err, success)
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- | Merge to source files into a temporary file. If we've tried to -- | Merge to source files into a temporary file. If we've tried to

View File

@ -25,7 +25,7 @@ module System.Plugins.Parser (
replaceModName replaceModName
) where ) where
#include "../../../config.h" #include "config.h"
import Data.List import Data.List
import Data.Char import Data.Char

View File

@ -7,25 +7,19 @@
module System.Plugins.Process (exec, popen) where module System.Plugins.Process (exec, popen) where
import System.Exit import System.Exit
#if __GLASGOW_HASKELL__ >= 604
import System.IO import System.IO
import System.Process import System.Process
import Control.Concurrent (forkIO) import Control.Concurrent (forkIO)
#else
import qualified Posix as P
#endif
import qualified Control.Exception as E import qualified Control.Exception as E
-- --
-- slight wrapper over popen for calls that don't care about stdin to the program -- slight wrapper over popen for calls that don't care about stdin to the program
-- --
exec :: String -> [String] -> IO ([String],[String]) exec :: String -> [String] -> IO ([String],[String],Bool)
exec f as = do exec f as = do
(a,b,_) <- popen f as (Just []) (a,b,c,_) <- popen f as (Just [])
return (lines a, lines b) return (lines a, lines b,c)
#if __GLASGOW_HASKELL__ >= 604
type ProcessID = ProcessHandle type ProcessID = ProcessHandle
@ -37,9 +31,9 @@ type ProcessID = ProcessHandle
-- Posix.popen doesn't have this problem, so maybe we can reproduce its -- Posix.popen doesn't have this problem, so maybe we can reproduce its
-- pipe handling somehow. -- pipe handling somehow.
-- --
popen :: FilePath -> [String] -> Maybe String -> IO (String,String,ProcessID) popen :: FilePath -> [String] -> Maybe String -> IO (String,String,Bool,ProcessID)
popen file args minput = popen file args minput =
E.handle (\e -> return ([],show (e::E.IOException), error (show e))) $ do E.handle (\e -> return ([],show (e::E.IOException), False, error (show e))) $ do
(inp,out,err,pid) <- runInteractiveProcess file args Nothing Nothing (inp,out,err,pid) <- runInteractiveProcess file args Nothing Nothing
@ -64,27 +58,6 @@ popen file args minput =
case exitCode of case exitCode of
ExitFailure code ExitFailure code
| null errput -> let errMsg = file ++ ": failed with error code " ++ show code | null errput -> let errMsg = file ++ ": failed with error code " ++ show code
in return ([],errMsg,error errMsg) in return ([],errMsg,False,error errMsg)
_ -> return (output,errput,pid) | otherwise -> return ([],errput,False,error errput)
_ -> return (output,errput,True,pid)
#else
--
-- catch so that we can deal with forkProcess failing gracefully. and
-- getProcessStatus is needed so as not to get a bunch of zombies,
-- leading to forkProcess failing.
--
-- Large amounts of input will cause problems with blocking as we wait
-- on the process to finish. Make sure no lambdabot processes will
-- generate 1000s of lines of output.
--
popen :: FilePath -> [String] -> Maybe String -> IO (String,String,P.ProcessID)
popen f s m =
E.handle (\e -> return ([], show (e::IOException), error $ show e )) $ do
x@(_,_,pid) <- P.popen f s m
b <- P.getProcessStatus True False pid -- wait
return $ case b of
Nothing -> ([], "process has disappeared", pid)
_ -> x
#endif

View File

@ -58,7 +58,7 @@ module System.Plugins.Utils (
) where ) where
#include "../../../config.h" #include "config.h"
import System.Plugins.Env ( isLoaded ) import System.Plugins.Env ( isLoaded )
import System.Plugins.Consts ( objSuf, hiSuf, tmpDir ) import System.Plugins.Consts ( objSuf, hiSuf, tmpDir )
@ -289,7 +289,7 @@ findFile (ext:exts) file
infixr 6 </> infixr 6 </>
infixr 6 <.> infixr 6 <.>
(</>), (<.>), (<+>), (<>) :: FilePath -> FilePath -> FilePath (</>), (<.>), (<+>) :: FilePath -> FilePath -> FilePath
[] </> b = b [] </> b = b
a </> b = a ++ "/" ++ b a </> b = a ++ "/" ++ b
@ -299,9 +299,6 @@ a <.> b = a ++ "." ++ b
[] <+> b = b [] <+> b = b
a <+> b = a ++ " " ++ b a <+> b = a ++ " " ++ b
[] <> b = b
a <> b = a ++ b
-- --
-- | dirname : return the directory portion of a file path -- | dirname : return the directory portion of a file path
-- if null, return "." -- if null, return "."

View File

@ -1,7 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md # For more information, see: https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-8.0 resolver: lts-16.13
# Local packages, usually specified by relative directory name # Local packages, usually specified by relative directory name
packages: packages:

12
stack.yaml.lock Normal file
View File

@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
size: 532381
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/13.yaml
sha256: 6ee17f7996e5bc75ae4406250841f1362ad4196418a4d90a0615ff4f26ac98df
original: lts-16.13