Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] GHC 9.0.1 #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,213 changes: 3,604 additions & 2,609 deletions EHC/configure

Large diffs are not rendered by default.

177 changes: 175 additions & 2 deletions EHC/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
AC_INIT([UHC],[1.1.7],[[email protected], http://www.cs.uu.nl/wiki/UHC/WebHome])

### version of autoconf used (and required)
#AC_PREREQ(2.64)
#AC_PREREQ([2.71])

### revision
AC_REVISION($Revision: 1.26 $)
Expand All @@ -14,6 +14,156 @@ AC_CANONICAL_HOST
dnl ** canonicalize platform names
HostPlatform=`/bin/sh $srcdir/config.sub $host` || exit 1

# GHC_CONVERT_CPU(cpu, target_var)
# --------------------------------
# Converts cpu from gnu to ghc naming, and assigns the result to $target_var.
# Should you modify this list, you are invited to reflect the changes in
# `libraries/base/System/Info.hs`'s documentation.
AC_DEFUN([GHC_CONVERT_CPU],[
case "$1" in
aarch64*|arm64*)
$2="aarch64"
;;
alpha*)
$2="alpha"
;;
arm*)
$2="arm"
;;
hppa1.1*)
$2="hppa1_1"
;;
hppa*)
$2="hppa"
;;
i386|i486|i586|i686)
$2="i386"
;;
ia64)
$2="ia64"
;;
m68k*)
$2="m68k"
;;
mipseb*)
$2="mipseb"
;;
mipsel*)
$2="mipsel"
;;
mips*)
$2="mips"
;;
nios2)
$2="nios2"
;;
powerpc64le*)
$2="powerpc64le"
;;
powerpc64*)
$2="powerpc64"
;;
powerpc*)
$2="powerpc"
;;
riscv64*)
$2="riscv64"
;;
riscv|riscv32*)
$2="riscv32"
;;
rs6000)
$2="rs6000"
;;
s390x*)
$2="s390x"
;;
s390*)
$2="s390"
;;
sh4)
$2="sh4"
;;
sparc64*)
$2="sparc64"
;;
sparc*)
$2="sparc"
;;
vax)
$2="vax"
;;
x86_64|amd64)
$2="x86_64"
;;
*)
echo "Unknown CPU $1"
exit 1
;;
esac
])

# GHC_CONVERT_OS(os, converted_cpu, target_var)
# --------------------------------
# converts os from gnu to ghc naming, and assigns the result to $target_var
AC_DEFUN([GHC_CONVERT_OS],[
case "$1" in
gnu*) # e.g. i686-unknown-gnu0.9
$3="gnu"
;;
# watchos and tvos are ios variants as of May 2017.
ios|watchos|tvos)
$3="ios"
;;
linux-android*)
$3="linux-android"
;;
linux-*|linux)
$3="linux"
;;
netbsd*)
$3="netbsd"
;;
openbsd*)
$3="openbsd"
;;
# As far as I'm aware, none of these have relevant variants
freebsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|mingw32|darwin|nextstep2|nextstep3|sunos4|ultrix|haiku)
$3="$1"
;;
msys)
AC_MSG_ERROR([Building GHC using the msys toolchain is not supported; please use mingw instead. Perhaps you need to set 'MSYSTEM=MINGW64 or MINGW32?'])
;;
aix*) # e.g. powerpc-ibm-aix7.1.3.0
$3="aix"
;;
darwin*) # e.g. aarch64-apple-darwin14
$3="darwin"
;;
solaris2*)
$3="solaris2"
;;
freebsd*) # like i686-gentoo-freebsd7
# i686-gentoo-freebsd8
# i686-gentoo-freebsd8.2
$3="freebsd"
;;
nto-qnx*)
$3="nto-qnx"
;;
*)
echo "Unknown OS $1"
exit 1
;;
esac
])

GHC_CONVERT_CPU($host_cpu, ghcCPU)
GHC_CONVERT_OS($host_os, $ghcCPU, ghcOS)

AC_SUBST(GHC_CPU, $ghcCPU)
AC_SUBST(GHC_OS, $ghcOS)

### check whether we are indeed in the toplevel dir, otherwise copy required stuff to the current dir first
if test "${srcdir}" != "." -a "${srcdir}" != ""
then
Expand Down Expand Up @@ -186,6 +336,10 @@ AC_SUBST(ENABLE_TAUPHI,$enableTauPhi)
AC_ARG_ENABLE(sandbox, AS_HELP_STRING([--enable-sandbox],[build EHC/UHC libs with cabal sandbox]), [enableSandbox=yes], [enableSandbox=no])
AC_SUBST(ENABLE_SANDBOX,$enableSandbox)

### enable options: use cabal v2 commands for building libs, default is no
AC_ARG_ENABLE(v2-commands, AS_HELP_STRING([--enable-v2-commands],[build EHC/UHC libs with cabal v2 commands]), [enableV2Commands=yes], [enableV2Commands=no])
AC_SUBST(ENABLE_V2_COMMANDS,$enableV2Commands)

### enable options: turn on CHR based type system impl
AC_ARG_ENABLE(chrtysys, AS_HELP_STRING([--enable-chrtysys],[build EHC/UHC with CHR based type system]), [enableChrTySys=yes], [enableChrTySys=no])
AC_SUBST(ENABLE_CHRTYSYS,$enableChrTySys)
Expand Down Expand Up @@ -476,6 +630,9 @@ AC_PATH_PROG(ghcPkgCmd,ghc-pkg)
AC_PATH_PROG(hsc2hsCmd,hsc2hs)
AC_SUBST(HSC2HS_CMD,$hsc2hsCmd)

if test x$enableV2Commands = "xno"
then

### now we know we have ghc, check for some libraries using ghc-pkg
ghcLibsRequired="fgl vector uulib network binary hashable chr-data uhc-util base mtl transformers directory containers array process filepath utf8-string bytestring"
#if test x$enableClr = "xyes"
Expand Down Expand Up @@ -536,6 +693,7 @@ then
fi
fi


# GHC version dependencies: packages passed as option, cabal packages
cabal_base_lib_depends="${ghcLibsRequiredWithVersion} ${ghcLibsRequiredWithoutVersion}"
if test x$enableClr = "xyes"
Expand All @@ -557,6 +715,8 @@ case $ghcVersion in
;;
esac

fi

AC_SUBST(OPT_GHC_STANDARD_PACKAGES,"$optStandardGHCPackages")
AC_SUBST(CABAL_BASE_LIB_DEPENDS,"$cabal_base_lib_depends")
AC_SUBST(CABAL_EXTRA_LIB_DEPENDS,"$cabal_extra_lib_depends")
Expand Down Expand Up @@ -819,7 +979,20 @@ AC_CHECK_FUNCS([ftime gmtime_r localtime_r])
AC_CHECK_FUNCS([lchown])

dnl ** check if it is safe to include both <time.h> and <sys/time.h>
AC_HEADER_TIME
m4_warn([obsolete],
[Update your code to rely only on HAVE_SYS_TIME_H,
then remove this warning and the obsolete code below it.
All current systems provide time.h; it need not be checked for.
Not all systems provide sys/time.h, but those that do, all allow
you to include it and time.h simultaneously.])dnl
AC_CHECK_HEADERS_ONCE([sys/time.h])
# Obsolete code to be removed.
if test $ac_cv_header_sys_time_h = yes; then
AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h>
and <time.h>. This macro is obsolete.])
fi
# End of obsolete code.


dnl ** how do we get a timezone name, and UTC offset ?
AC_STRUCT_TIMEZONE
Expand Down
5 changes: 5 additions & 0 deletions EHC/mk/config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ ifeq (@ENABLE_SANDBOX@,yes)
ENABLE_SANDBOX := yes
endif

# use cabal v2 commands
ifeq (@ENABLE_V2_COMMANDS@,yes)
ENABLE_V2_COMMANDS := yes
endif

# include CHR based type system
ifeq (@ENABLE_CHRTYSYS@,yes)
ENABLE_CHRTYSYS := yes
Expand Down
2 changes: 2 additions & 0 deletions EHC/mk/shared.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ RULER2 := @RULER_CMD@
GHC := @GHC_CMD@
GHC1 := @GHC_CMD1@
GHC_VERSION := @GHC_VERSION@
GHC_CPU := @GHC_CPU@
GHC_OS := @GHC_OS@
CABAL := @CABAL_CMD@
HSC2HS := @HSC2HS_CMD@
HADDOCK := @HADDOCK_CMD@
Expand Down
2 changes: 1 addition & 1 deletion EHC/src/ehc/CodeGen/BuiltinPrims.chs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Ideally, these tables should be merged.
data PrimitiveNeedsEval
= Prim
{ primArgNeedEval :: ![Bool] -- default: True
, primResNeedEval :: ! Bool -- default: False
, primResNeedEval :: !Bool -- default: False
}

lookupPrimNeedsEval :: {- Backend -> -} String -> Maybe PrimitiveNeedsEval
Expand Down
4 changes: 2 additions & 2 deletions EHC/src/ehc/EH/Generics.cag
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ mkGenerRepresentableTypeSynTyProj
fmapTy = appTopApp (fun : firstargs)
_ -> dflt
| otherwise = dflt
where mbVar @(~(Just tvar )) = tyMbVar t
funArgs @( (fun,args) ) = appUnApp t
where mbVar@(~(Just tvar )) = tyMbVar t
funArgs@( (fun,args) ) = appUnApp t
isRepr = maybe (isJust $ tyMbVar fun) (\con -> isRepresentable con remArity) $ tyMbCon fun
dflt = ([ mkC ehbnGenerDataRec0, t ], Proj_K1 [t])
mkAlt tg c (t,p) = (appTopApp [mkC2 ehbnGenerDataMetaCN 1, appCon c, t], Proj_M1 $ Proj_Con tg p)
Expand Down
30 changes: 18 additions & 12 deletions EHC/src/ehc/EHC/BuildFunction/Run.chs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,21 +1374,27 @@ bend = cstk =$: tail
-- | memoize
bmemo :: (EHCCompileRunner m, Typeable f, Typeable res) => f res -> EHCompilePhaseT m ()
bmemo res = do
(BFun bfun : _) <- getl $ st ^* bstateCallStack
case cast bfun of
Just bfun -> do
cpTr TraceOn_BldFun $ ["memo " ++ show bfun]
st ^* bstateCache =$: bcacheInsert bfun res
_ -> panic $ "BuildFunction.Run.bcall.bmemo: " ++ show bfun
s <- getl $ st ^* bstateCallStack
case s of
BFun bfun : _ ->
case cast bfun of
Just bfun -> do
cpTr TraceOn_BldFun $ ["memo " ++ show bfun]
st ^* bstateCache =$: bcacheInsert bfun res
_ -> panic $ "BuildFunction.Run.bcall.bmemo: " ++ show bfun
_ -> panic $ "BuildFunction.Run.bcall.bmemo: empty stack"

bmemo' :: (EHCCompileRunner m, Typeable res) => res -> EHCompilePhaseT m ()
bmemo' res = do
(BFun bfun : _) <- getl $ st ^* bstateCallStack
case cast bfun of
Just bfun -> do
cpTr TraceOn_BldFun $ ["memo " ++ show bfun]
st ^* bstateCache =$: bcacheInsert bfun (Identity res)
_ -> panic $ "BuildFunction.Run.bcall.bmemo': " ++ show bfun ++ ", " ++ show (typeOf bfun) ++ ", " ++ show (typeOf res)
s <- getl $ st ^* bstateCallStack
case s of
(BFun bfun : _) ->
case cast bfun of
Just bfun -> do
cpTr TraceOn_BldFun $ ["memo " ++ show bfun]
st ^* bstateCache =$: bcacheInsert bfun (Identity res)
_ -> panic $ "BuildFunction.Run.bcall.bmemo': " ++ show bfun ++ ", " ++ show (typeOf bfun) ++ ", " ++ show (typeOf res)
_ -> panic $ "BuildFunction.Run.bcall.bmemo': empty stack, " ++ show (typeOf res)

-- memoize & return
breturn :: (EHCCompileRunner m, Typeable res) => res -> EHCompilePhaseT m res
Expand Down
15 changes: 12 additions & 3 deletions EHC/src/ehc/files1.mk
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ EHC_ALL_DPDS_NOPREPROC := $(subst $(EHC_BLD_LIB_HS_VARIANT_PREFIX)ConfigDefi
# cabal library dependencies and extensions
###########################################################################################

CABAL_EHCLIB_DEPENDS_ON := binary syb bytestring uulib>=0.9.12 old-locale
CABAL_EHCLIB_EXTENSIONS := $(CABAL_OPT_ALLOW_UNDECIDABLE_INSTANCES) DeriveDataTypeable LiberalTypeSynonyms StandaloneDeriving DeriveGeneric FlexibleContexts FlexibleInstances TypeSynonymInstances ScopedTypeVariables TypeFamilies
CABAL_EHCLIB_DEPENDS_ON := binary syb bytestring uulib>=0.9.12 old-locale base fgl syb uulib network binary hashable uhc-util mtl containers directory array chr-data utf8-string process

CABAL_EHCLIB_EXTENSIONS := UndecidableInstances DeriveDataTypeable LiberalTypeSynonyms StandaloneDeriving DeriveGeneric FlexibleContexts FlexibleInstances TypeSynonymInstances ScopedTypeVariables TypeFamilies

###########################################################################################
# variant dispatch rules
Expand Down Expand Up @@ -396,7 +397,15 @@ $(LIB_EHC_SETUP_HS_DRV): $(EHC_MKF)
$(LIB_EHC_SETUP2): $(LIB_EHC_SETUP_HS_DRV)
$(call GHC_CABAL,$<,$@)

ifeq ($(ENABLE_SANDBOX),yes)
ifeq ($(ENABLE_V2_COMMANDS),yes)
# cabal v2 version
$(LIB_EHC_INS_FLAG): $(LIB_EHC_CABAL_DRV) $(INSABS_EHC_LIB_ALL_AG) $(EHC_MKF)
mkdir -p $(@D)
cd $(EHC_BLD_LIBEHC_VARIANT_PREFIX) && \
$(CABAL) v2-configure $(CABAL_SETUP_OPTS) --write-ghc-environment-files=always && \
$(CABAL) v2-build && \
echo $@ > $@
else ifeq ($(ENABLE_SANDBOX),yes)
# cabal sandbox version
# Note/TBD: configure should be done before installing dpds, in particular choice of compiler cannot be done correctly now
$(LIB_EHC_INS_FLAG): $(LIB_EHC_CABAL_DRV) $(INSABS_EHC_LIB_ALL_AG) $(EHC_MKF)
Expand Down
1 change: 1 addition & 0 deletions EHC/src/ehc/files2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ehc-variant-dflt: \
mkdir -p $(dir $(EHC_INSTALL_VARIANT_ASPECTS_EXEC)) && \
$(GHC) --make \
$(if $(ENABLE_SANDBOX),--package-conf=$(EHC_BLD_LIBEHC_VARIANT_PREFIX)dist/package.conf.inplace,) \
$(if $(ENABLE_V2_COMMANDS),-package-env=$(EHC_BLD_LIBEHC_VARIANT_PREFIX).ghc.environment.$(GHC_CPU)-$(GHC_OS)-$(GHC_VERSION),) \
$(GHC_OPTS) $(GHC_OPTS_WHEN_EHC) -package $(LIB_EHC_PKG_NAME) \
-i$(EHC_BLD_VARIANT_ASPECTS_PREFIX) $(EHC_BLD_VARIANT_ASPECTS_PREFIX)$(EHC_MAIN).hs -o $(EHC_INSTALL_VARIANT_ASPECTS_EXEC)
$(if $(EHC_CFG_USE_CODEGEN), \
Expand Down
8 changes: 6 additions & 2 deletions EHC/src/gen/files.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ $(GEN_GENERTUPINST_HS_MAIN_DRV_HS): $(EHC_BLD_GEN_VARIANT_PREFIX)%.hs: $(SRC_GEN

$(GEN_RTSGBCCALL_BLD_EXEC): $(GEN_RTSGBCCALL_HS_MAIN_DRV_HS)
mkdir -p $(dir $(GEN_RTSGBCCALL_BLD_EXEC))
$(GHC) --make $(GHC_OPTS) $(GHC_OPTS_WHEN_EHC) -package $(LIB_EHC_PKG_NAME) -i$(EHC_BLD_GEN_VARIANT_PREFIX) $(GEN_RTSGBCCALL_MAIN_HS) -o $(GEN_RTSGBCCALL_BLD_EXEC)
$(GHC) --make \
$(if $(ENABLE_V2_COMMANDS),-package-env=$(EHC_BLD_LIBEHC_VARIANT_PREFIX).ghc.environment.$(GHC_CPU)-$(GHC_OS)-$(GHC_VERSION),) \
$(GHC_OPTS) $(GHC_OPTS_WHEN_EHC) -package $(LIB_EHC_PKG_NAME) -i$(EHC_BLD_GEN_VARIANT_PREFIX) $(GEN_RTSGBCCALL_MAIN_HS) -o $(GEN_RTSGBCCALL_BLD_EXEC)

$(GEN_GENERTUPINST_BLD_EXEC): $(GEN_GENERTUPINST_HS_MAIN_DRV_HS)
mkdir -p $(dir $(GEN_GENERTUPINST_BLD_EXEC))
$(GHC) --make $(GHC_OPTS) $(GHC_OPTS_WHEN_EHC) -package $(LIB_EHC_PKG_NAME) -i$(EHC_BLD_GEN_VARIANT_PREFIX) $(GEN_GENERTUPINST_MAIN_HS) -o $(GEN_GENERTUPINST_BLD_EXEC)
$(GHC) --make \
$(if $(ENABLE_V2_COMMANDS),-package-env=$(EHC_BLD_LIBEHC_VARIANT_PREFIX).ghc.environment.$(GHC_CPU)-$(GHC_OS)-$(GHC_VERSION),) \
$(GHC_OPTS) $(GHC_OPTS_WHEN_EHC) -package $(LIB_EHC_PKG_NAME) -i$(EHC_BLD_GEN_VARIANT_PREFIX) $(GEN_GENERTUPINST_MAIN_HS) -o $(GEN_GENERTUPINST_BLD_EXEC)