Compare commits
11 Commits
c59e1df710
...
e175d3c2ea
Author | SHA1 | Date | |
---|---|---|---|
|
e175d3c2ea | ||
|
9b4d13546f | ||
|
f2e74a48c5 | ||
|
f95afdd34e | ||
|
e6c898ff58 | ||
|
90464df9b9 | ||
|
5866046ca0 | ||
|
57aa1e606a | ||
|
2443774403 | ||
|
f6e23dd402 | ||
|
25daaf8f80 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
/testsuite/makewith/io/TestIO.conf
|
||||
/testsuite/makewith/unsafeio/Unsafe.conf
|
||||
/.stack-work/
|
||||
/dist-newstyle/
|
189
.travis.yml
189
.travis.yml
@ -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
|
||||
sudo: false
|
||||
dist: xenial
|
||||
|
||||
git:
|
||||
submodules: false # whether to recursively clone submodules
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cabsnap
|
||||
- $HOME/.cabal/packages
|
||||
- $HOME/.cabal/store
|
||||
|
||||
before_cache:
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
|
||||
- rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
|
||||
# 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:
|
||||
include:
|
||||
- env: CABALVER=1.16 GHCVER=7.4.1 HAPPYVER=1.19.5
|
||||
compiler: ": #GHC 7.4.1"
|
||||
addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.1,happy-1.19.5], sources: [hvr-ghc]}}
|
||||
- env: CABALVER=1.16 GHCVER=7.4.2 HAPPYVER=1.19.5
|
||||
compiler: ": #GHC 7.4.2"
|
||||
addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2,happy-1.19.5], sources: [hvr-ghc]}}
|
||||
- env: CABALVER=1.16 GHCVER=7.6.1 HAPPYVER=1.19.5
|
||||
compiler: ": #GHC 7.6.1"
|
||||
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.1,happy-1.19.5], sources: [hvr-ghc]}}
|
||||
- env: CABALVER=1.16 GHCVER=7.6.2 HAPPYVER=1.19.5
|
||||
compiler: ": #GHC 7.6.2"
|
||||
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.2,happy-1.19.5], sources: [hvr-ghc]}}
|
||||
- env: CABALVER=1.16 GHCVER=7.6.3 HAPPYVER=1.19.5
|
||||
compiler: ": #GHC 7.6.3"
|
||||
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]}}
|
||||
- compiler: "ghc-8.6.4"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.6.4], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-8.2.2"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.2.2], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-8.0.2"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.0.2], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-7.10.3"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.10.3], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-7.8.4"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.8.4], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-7.6.3"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.6.3], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-7.4.2"
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.4.2], sources: [hvr-ghc]}}
|
||||
|
||||
before_install:
|
||||
- unset CC
|
||||
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/happy/$HAPPYVER/bin:$PATH
|
||||
- HC=/opt/ghc/bin/${CC}
|
||||
- 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:
|
||||
- cabal --version
|
||||
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
|
||||
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
|
||||
then
|
||||
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
|
||||
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
|
||||
fi
|
||||
- travis_retry cabal update -v
|
||||
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
|
||||
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
|
||||
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
|
||||
|
||||
# check whether current requested install-plan matches cached package-db snapshot
|
||||
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
|
||||
then
|
||||
echo "cabal build-cache HIT";
|
||||
rm -rfv .ghc;
|
||||
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
|
||||
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
|
||||
else
|
||||
echo "cabal build-cache MISS";
|
||||
rm -rf $HOME/.cabsnap;
|
||||
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
|
||||
cabal install --only-dependencies --enable-tests --enable-benchmarks;
|
||||
fi
|
||||
|
||||
# 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
|
||||
- ${CABAL} --version
|
||||
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
|
||||
- TEST=--enable-tests
|
||||
- BENCH=--enable-benchmarks
|
||||
- GHCHEAD=${GHCHEAD-false}
|
||||
- travis_retry ${CABAL} update -v
|
||||
- sed -i.bak 's/^jobs:/-- jobs:/' $CABALHOME/config
|
||||
- rm -fv cabal.project cabal.project.local
|
||||
- grep -Ev -- '^\s*--' $CABALHOME/config | grep -Ev '^\s*$'
|
||||
- rm -f cabal.project
|
||||
- touch cabal.project
|
||||
- "printf 'packages: \".\"\\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
|
||||
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
|
||||
- rm -f cabal.project.freeze
|
||||
- ${CABAL} new-freeze -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dry
|
||||
- "cat \"cabal.project.freeze\" | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
|
||||
- rm "cabal.project.freeze"
|
||||
- ${CABAL} new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
|
||||
- ${CABAL} new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
|
||||
- rm -rf .ghc.environment.* "."/dist
|
||||
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
|
||||
|
||||
# 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.
|
||||
script:
|
||||
- if [ -f configure.ac ]; then autoreconf -i; fi
|
||||
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
|
||||
- cabal build # this builds all libraries and executables (including tests/benchmarks)
|
||||
- cabal test
|
||||
- cabal check
|
||||
- cabal sdist # tests that a source-distribution can be generated
|
||||
# test that source-distributions can be generated
|
||||
- ${CABAL} new-sdist all
|
||||
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
|
||||
- cd ${DISTDIR} || false
|
||||
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
|
||||
- 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.
|
||||
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
|
||||
# `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")
|
||||
# build & run tests, build benchmarks
|
||||
- ${CABAL} new-build -w ${HC} ${TEST} ${BENCH} all
|
||||
|
||||
# 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: plugins
|
||||
version: 1.5.6.1
|
||||
version: 1.6.0
|
||||
homepage: https://github.com/stepcut/plugins
|
||||
synopsis: Dynamic linking for Haskell and C objects
|
||||
description: Dynamic linking and runtime evaluation of Haskell,
|
||||
@ -20,12 +20,13 @@ author: Don Stewart 2004..2010
|
||||
maintainer: Jeremy Shaw <jeremy@seereason.com>
|
||||
cabal-version: >= 1.6
|
||||
build-type: Configure
|
||||
Tested-with: GHC == 7.4.*
|
||||
, GHC == 7.6.*
|
||||
, GHC == 7.8.*
|
||||
, GHC == 7.10.*
|
||||
, GHC == 8.0.*
|
||||
, GHC == 8.2.*
|
||||
Tested-with: GHC == 7.4.2
|
||||
, GHC == 7.6.3
|
||||
, GHC == 7.8.4
|
||||
, GHC == 7.10.3
|
||||
, GHC == 8.0.2
|
||||
, GHC == 8.2.2
|
||||
, GHC == 8.6.4
|
||||
extra-source-files: config.guess, config.h.in, config.mk.in, config.sub,
|
||||
configure, configure.ac, install.sh, Makefile,
|
||||
testsuite/makewith/io/TestIO.conf.in,
|
||||
@ -59,6 +60,7 @@ library
|
||||
filepath,
|
||||
random,
|
||||
process,
|
||||
split,
|
||||
ghc >= 6.10,
|
||||
ghc-prim
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
module System.Plugins.Consts where
|
||||
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#if __GLASGOW_HASKELL__ >= 604
|
||||
|
@ -40,17 +40,19 @@ module System.Plugins.Env (
|
||||
lookupMerged,
|
||||
addMerge,
|
||||
addPkgConf,
|
||||
defaultPkgConf,
|
||||
union,
|
||||
addStaticPkg,
|
||||
isStaticPkg,
|
||||
rmStaticPkg,
|
||||
grabDefaultPkgConf,
|
||||
readPackageConf,
|
||||
lookupPkg
|
||||
lookupPkg,
|
||||
pkgManglingPrefix
|
||||
|
||||
) where
|
||||
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
|
||||
import System.Plugins.LoadTypes (Module)
|
||||
import System.Plugins.Consts ( sysPkgSuffix )
|
||||
@ -59,7 +61,7 @@ import Control.Monad ( liftM )
|
||||
|
||||
import Data.IORef ( writeIORef, readIORef, newIORef, IORef() )
|
||||
import Data.Maybe ( isJust, isNothing, fromMaybe )
|
||||
import Data.List ( (\\), nub, )
|
||||
import Data.List ( (\\), nub )
|
||||
|
||||
import System.IO.Unsafe ( unsafePerformIO )
|
||||
import System.Directory ( doesFileExist )
|
||||
@ -76,13 +78,14 @@ import DynFlags (
|
||||
Way(WayDyn), dynamicGhc, ways,
|
||||
#endif
|
||||
defaultDynFlags, initDynFlags)
|
||||
import SysTools (initSysTools)
|
||||
import SysTools (initSysTools, initLlvmConfig)
|
||||
|
||||
import Distribution.Package hiding (
|
||||
#if MIN_VERSION_ghc(7,6,0)
|
||||
Module,
|
||||
#endif
|
||||
depends, packageName, PackageName(..)
|
||||
, installedUnitId
|
||||
#if MIN_VERSION_ghc(7,10,0)
|
||||
, installedPackageId
|
||||
#endif
|
||||
@ -96,6 +99,9 @@ import Distribution.Simple.PackageIndex
|
||||
import Distribution.Simple.Program
|
||||
import Distribution.Verbosity
|
||||
|
||||
import System.Environment
|
||||
import Data.List.Split
|
||||
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
--
|
||||
@ -305,6 +311,15 @@ addPkgConf f = do
|
||||
ps <- readPackageConf f
|
||||
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
|
||||
-- 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
|
||||
where
|
||||
-- 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
|
||||
|
||||
-- if no version number specified, pick the higher version
|
||||
addToPkgEnvs = addWithFM higherVersion
|
||||
|
||||
higherVersion pkgconf1 pkgconf2
|
||||
| installedPackageId pkgconf1 >= installedPackageId pkgconf2 = pkgconf1
|
||||
| packageId pkgconf1 >= packageId pkgconf2 = pkgconf1
|
||||
| otherwise = pkgconf2
|
||||
|
||||
--
|
||||
@ -335,7 +350,7 @@ union ls ps' =
|
||||
|
||||
grabDefaultPkgConf :: IO PkgEnvs
|
||||
grabDefaultPkgConf = do
|
||||
pc <- configureAllKnownPrograms silent defaultProgramConfiguration
|
||||
pc <- configureAllKnownPrograms silent defaultProgramDb
|
||||
#if MIN_VERSION_Cabal(1,24,0)
|
||||
(compiler, _platform, _programConfiguration)
|
||||
<- configure silent Nothing Nothing pc
|
||||
@ -351,7 +366,7 @@ grabDefaultPkgConf = do
|
||||
--
|
||||
readPackageConf :: FilePath -> IO [PackageConfig]
|
||||
readPackageConf f = do
|
||||
pc <- configureAllKnownPrograms silent defaultProgramConfiguration
|
||||
pc <- configureAllKnownPrograms silent defaultProgramDb
|
||||
#if MIN_VERSION_Cabal(1,24,0)
|
||||
(compiler, _platform, _programConfiguration)
|
||||
<- configure silent Nothing Nothing pc
|
||||
@ -407,6 +422,17 @@ lookupPkg pn = go [] pn
|
||||
(f', g') <- liftM unzip $ mapM (go (nub $ seen ++ ps)) (ps \\ seen)
|
||||
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
|
||||
= DLL String -- -lLib
|
||||
| DLLPath FilePath -- -Lpath
|
||||
@ -459,14 +485,15 @@ lookupPkg' p = withPkgEnvs env $ \fms -> go fms p
|
||||
ldOptsPaths = [ path | Just (DLLPath path) <- ldInput ]
|
||||
dlls = map mkSOName (extras ++ ldOptsLibs)
|
||||
#if defined(CYGWIN) || defined(__MINGW32__)
|
||||
libdirs = fix_topdir (libraryDirs pkg) ++ ldOptsPaths
|
||||
libdirs = fix_topdir (libraryDirs pkg) ++ ldOptsPaths ++ fix_topdir (libraryDynDirs pkg)
|
||||
#else
|
||||
libdirs = libraryDirs pkg ++ ldOptsPaths
|
||||
libdirs = libraryDirs pkg ++ ldOptsPaths ++ libraryDynDirs pkg
|
||||
#endif
|
||||
-- If we're loading dynamic libs we need the cbits to appear before the
|
||||
-- real packages.
|
||||
settings <- initSysTools (Just libdir)
|
||||
dflags <- initDynFlags $ defaultDynFlags settings
|
||||
settings <- initSysTools (libdir)
|
||||
llvmConfig <- initLlvmConfig (libdir)
|
||||
dflags <- initDynFlags $ defaultDynFlags settings llvmConfig
|
||||
libs <- mapM (findHSlib
|
||||
#if MIN_VERSION_ghc(7,8,0)
|
||||
(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
|
||||
-- and add any other dynamic libraries found.
|
||||
dl <- findHSdlib dirs lib
|
||||
let rdl = case dl of
|
||||
Just file -> Right $ Dynamic file
|
||||
Nothing -> Left lib
|
||||
rdl <- case dl of
|
||||
Just file -> return $ Right $ Dynamic file
|
||||
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
|
||||
rsl <- findHSslib dirs lib
|
||||
return $ case rsl of
|
||||
|
@ -61,7 +61,7 @@ module System.Plugins.Load (
|
||||
|
||||
) where
|
||||
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
|
||||
import System.Plugins.Make ( build )
|
||||
import System.Plugins.Env
|
||||
@ -104,7 +104,7 @@ import GHC ( defaultCallbacks )
|
||||
#else
|
||||
import DynFlags (defaultDynFlags, initDynFlags)
|
||||
import GHC.Paths (libdir)
|
||||
import SysTools (initSysTools)
|
||||
import SysTools (initSysTools, initLlvmConfig)
|
||||
#endif
|
||||
import GHC.Ptr ( Ptr(..), nullPtr )
|
||||
#if !MIN_VERSION_ghc(7,4,1)
|
||||
@ -126,8 +126,9 @@ readBinIface' :: FilePath -> IO ModIface
|
||||
readBinIface' hi_path = do
|
||||
-- kludgy as hell
|
||||
#if MIN_VERSION_ghc(7,2,0)
|
||||
mySettings <- initSysTools (Just libdir) -- how should we really set the top dir?
|
||||
dflags <- initDynFlags (defaultDynFlags mySettings)
|
||||
mySettings <- initSysTools (libdir) -- how should we really set the top dir?
|
||||
llvmConfig <- initLlvmConfig (libdir)
|
||||
dflags <- initDynFlags (defaultDynFlags mySettings llvmConfig)
|
||||
e <- newHscEnv dflags
|
||||
#else
|
||||
e <- newHscEnv defaultCallbacks undefined
|
||||
@ -259,11 +260,11 @@ pdynload object incpaths pkgconfs ty sym = do
|
||||
#if DEBUG
|
||||
putStr "Checking types ... " >> hFlush stdout
|
||||
#endif
|
||||
errors <- unify object incpaths [] ty sym
|
||||
(errors, success) <- unify object incpaths [] ty sym
|
||||
#if DEBUG
|
||||
putStrLn "done"
|
||||
#endif
|
||||
if null errors
|
||||
if success
|
||||
then load object incpaths pkgconfs sym
|
||||
else return $ LoadFailure errors
|
||||
|
||||
@ -283,11 +284,11 @@ pdynload_ object incpaths pkgconfs args ty sym = do
|
||||
#if DEBUG
|
||||
putStr "Checking types ... " >> hFlush stdout
|
||||
#endif
|
||||
errors <- unify object incpaths args ty sym
|
||||
(errors, success) <- unify object incpaths args ty sym
|
||||
#if DEBUG
|
||||
putStrLn "done"
|
||||
#endif
|
||||
if null errors
|
||||
if success
|
||||
then load object incpaths pkgconfs sym
|
||||
else return $ LoadFailure errors
|
||||
|
||||
@ -316,9 +317,9 @@ unify obj incs args ty sym = do
|
||||
|
||||
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]
|
||||
return e
|
||||
return (e, success)
|
||||
|
||||
where
|
||||
-- fix up hierarchical names
|
||||
@ -473,10 +474,17 @@ loadFunction__ :: Maybe String
|
||||
-> String
|
||||
-> IO (Maybe a)
|
||||
loadFunction__ pkg m valsym
|
||||
= do let symbol = prefixUnderscore++(maybe "" (\p -> zEncodeString p++"_") pkg)
|
||||
++zEncodeString m++"_"++(zEncodeString valsym)++"_closure"
|
||||
= do let encode = zEncodeString
|
||||
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
|
||||
putStrLn $ "Looking for <<"++symbol++">>"
|
||||
initLinker
|
||||
#endif
|
||||
ptr@(Ptr addr) <- withCString symbol c_lookupSymbol
|
||||
if (ptr == nullPtr)
|
||||
@ -595,10 +603,15 @@ unloadObj (Module { path = p, kind = k, key = ky }) = case k of
|
||||
-- Load a .so type object file.
|
||||
--
|
||||
loadShared :: FilePath -> IO Module
|
||||
loadShared str = do
|
||||
loadShared str' = do
|
||||
#if DEBUG
|
||||
putStrLn $ " shared: " ++ str
|
||||
putStrLn $ " shared: " ++ str'
|
||||
#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
|
||||
if maybe_errmsg == nullPtr
|
||||
then return (Module str (mkModid str) Shared undefined (Package (mkModid str)))
|
||||
@ -617,6 +630,7 @@ loadShared str = do
|
||||
--
|
||||
loadPackage :: String -> IO ()
|
||||
loadPackage p = do
|
||||
initLinker
|
||||
#if DEBUG
|
||||
putStr (' ':p) >> hFlush stdout
|
||||
#endif
|
||||
|
@ -269,11 +269,11 @@ rawMake src args docheck = do
|
||||
#if DEBUG
|
||||
putStr "Compiling object ... " >> hFlush stdout
|
||||
#endif
|
||||
err <- build src obj args
|
||||
(err, success) <- build src obj args
|
||||
#if DEBUG
|
||||
putStrLn "done"
|
||||
#endif
|
||||
return $ if null err
|
||||
return $ if success
|
||||
then MakeSuccess ReComp obj
|
||||
else MakeFailure err
|
||||
}
|
||||
@ -287,7 +287,7 @@ rawMake src args docheck = do
|
||||
build :: FilePath -- ^ path to .hs source
|
||||
-> FilePath -- ^ path to object file
|
||||
-> [String] -- ^ any extra cmd line flags
|
||||
-> IO [String]
|
||||
-> IO ([String], Bool)
|
||||
|
||||
build src obj extra_opts = do
|
||||
|
||||
@ -306,12 +306,12 @@ build src obj extra_opts = do
|
||||
putStr $ show $ ghc : flags
|
||||
#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
|
||||
return $ if not obj_exists && null err -- no errors, but no object?
|
||||
then ["Compiled, but didn't create object file `"++obj++"'!"]
|
||||
else err
|
||||
return $ if not obj_exists && success
|
||||
then (["Compiled, but didn't create object file `"++obj++"'!"], success)
|
||||
else (err, success)
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- | Merge to source files into a temporary file. If we've tried to
|
||||
|
@ -25,7 +25,7 @@ module System.Plugins.Parser (
|
||||
replaceModName
|
||||
) where
|
||||
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
|
||||
import Data.List
|
||||
import Data.Char
|
||||
|
@ -7,25 +7,19 @@
|
||||
module System.Plugins.Process (exec, popen) where
|
||||
|
||||
import System.Exit
|
||||
#if __GLASGOW_HASKELL__ >= 604
|
||||
import System.IO
|
||||
import System.Process
|
||||
import Control.Concurrent (forkIO)
|
||||
#else
|
||||
import qualified Posix as P
|
||||
#endif
|
||||
|
||||
import qualified Control.Exception as E
|
||||
|
||||
--
|
||||
-- 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
|
||||
(a,b,_) <- popen f as (Just [])
|
||||
return (lines a, lines b)
|
||||
|
||||
#if __GLASGOW_HASKELL__ >= 604
|
||||
(a,b,c,_) <- popen f as (Just [])
|
||||
return (lines a, lines b,c)
|
||||
|
||||
type ProcessID = ProcessHandle
|
||||
|
||||
@ -37,9 +31,9 @@ type ProcessID = ProcessHandle
|
||||
-- Posix.popen doesn't have this problem, so maybe we can reproduce its
|
||||
-- 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 =
|
||||
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
|
||||
|
||||
@ -64,27 +58,6 @@ popen file args minput =
|
||||
case exitCode of
|
||||
ExitFailure code
|
||||
| null errput -> let errMsg = file ++ ": failed with error code " ++ show code
|
||||
in return ([],errMsg,error errMsg)
|
||||
_ -> return (output,errput,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
|
||||
in return ([],errMsg,False,error errMsg)
|
||||
| otherwise -> return ([],errput,False,error errput)
|
||||
_ -> return (output,errput,True,pid)
|
||||
|
@ -58,7 +58,7 @@ module System.Plugins.Utils (
|
||||
) where
|
||||
|
||||
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
|
||||
import System.Plugins.Env ( isLoaded )
|
||||
import System.Plugins.Consts ( objSuf, hiSuf, tmpDir )
|
||||
@ -289,7 +289,7 @@ findFile (ext:exts) file
|
||||
infixr 6 </>
|
||||
infixr 6 <.>
|
||||
|
||||
(</>), (<.>), (<+>), (<>) :: FilePath -> FilePath -> FilePath
|
||||
(</>), (<.>), (<+>) :: FilePath -> FilePath -> FilePath
|
||||
[] </> b = b
|
||||
a </> b = a ++ "/" ++ b
|
||||
|
||||
@ -299,9 +299,6 @@ a <.> b = a ++ "." ++ b
|
||||
[] <+> b = b
|
||||
a <+> b = a ++ " " ++ b
|
||||
|
||||
[] <> b = b
|
||||
a <> b = a ++ b
|
||||
|
||||
--
|
||||
-- | dirname : return the directory portion of a file path
|
||||
-- if null, return "."
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 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)
|
||||
resolver: lts-8.0
|
||||
resolver: lts-16.13
|
||||
|
||||
# Local packages, usually specified by relative directory name
|
||||
packages:
|
||||
|
12
stack.yaml.lock
Normal file
12
stack.yaml.lock
Normal 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
|
Loading…
x
Reference in New Issue
Block a user