Skip to content

Commit

Permalink
modifications to buildsystem for llvm, in particular --enable-llvm no…
Browse files Browse the repository at this point in the history
…w works
  • Loading branch information
atzedijkstra committed Dec 16, 2009
1 parent 9d35646 commit fdcc82b
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 27 deletions.
2 changes: 1 addition & 1 deletion EHC/SVNREVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1737:1742M
1737:1746M
110 changes: 101 additions & 9 deletions EHC/configure
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ javacCmd
jarCmd
JAVAC_CMD
JAR_CMD
ENABLE_LLVM
ENABLE_CLR
ranlibCmd
RANLIB_CMD
Expand Down Expand Up @@ -1354,6 +1355,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-java include java code generation
--enable-llvm include llvm code generation
--enable-clr include clr code generation

Optional Packages:
Expand Down Expand Up @@ -2200,7 +2202,7 @@ SVN_VERSION_CMD=$svnVersionCmd
SVN_REVISION=$svnRevision


### enable options
### enable options: java
# Check whether --enable-java was given.
if test "${enable_java+set}" = set; then
enableval=$enable_java; enableJava=yes
Expand Down Expand Up @@ -2345,6 +2347,18 @@ echo "$as_me: error:

fi

### enable options: llvm
# Check whether --enable-llvm was given.
if test "${enable_llvm+set}" = set; then
enableval=$enable_llvm; enableLlvm=yes
else
enableLlvm=no
fi

ENABLE_LLVM=$enableLlvm


### enable options: clr
# Check whether --enable-clr was given.
if test "${enable_clr+set}" = set; then
enableval=$enable_clr; enableClr=yes
Expand Down Expand Up @@ -4155,8 +4169,11 @@ if test "${with_llvm_as+set}" = set; then
withval=$with_llvm_as; llvmAs="$withval"
else

if test "$LLVM_AS" = ""; then
# Extract the first word of "llvm-as", so it can be a program name with args.
if test "x$LLVM_AS" = "x"; then
if test x$enableLlvm = xyes
then

# Extract the first word of "llvm-as", so it can be a program name with args.
set dummy llvm-as; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
Expand Down Expand Up @@ -4196,6 +4213,19 @@ echo "${ECHO_T}no" >&6; }
fi


if test -z "$llvmAs"; then

{ { echo "$as_me:$LINENO: error:
You must install llvm-as before you can continue
Perhaps it is already installed, but not in your PATH?" >&5
echo "$as_me: error:
You must install llvm-as before you can continue
Perhaps it is already installed, but not in your PATH?" >&2;}
{ (exit 1); exit 1; }; }

fi

fi
else
llvmAs=$LLVM_AS
fi
Expand All @@ -4213,8 +4243,11 @@ if test "${with_opt+set}" = set; then
withval=$with_opt; llvmOpt="$withval"
else

if test "$LLVM_OPT" = ""; then
# Extract the first word of "opt", so it can be a program name with args.
if test "x$LLVM_OPT" = "x"; then
if test x$enableLlvm = xyes
then

# Extract the first word of "opt", so it can be a program name with args.
set dummy opt; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
Expand Down Expand Up @@ -4254,6 +4287,19 @@ echo "${ECHO_T}no" >&6; }
fi


if test -z "$llvmOpt"; then

{ { echo "$as_me:$LINENO: error:
You must install opt before you can continue
Perhaps it is already installed, but not in your PATH?" >&5
echo "$as_me: error:
You must install opt before you can continue
Perhaps it is already installed, but not in your PATH?" >&2;}
{ (exit 1); exit 1; }; }

fi

fi
else
llvmOpt=$LLVM_OPT
fi
Expand All @@ -4271,8 +4317,11 @@ if test "${with_llc+set}" = set; then
withval=$with_llc; llvmLlc="$withval"
else

if test "$LLC" = ""; then
# Extract the first word of "llc", so it can be a program name with args.
if test "x$LLC" = "x"; then
if test x$enableLlvm = xyes
then

# Extract the first word of "llc", so it can be a program name with args.
set dummy llc; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
Expand Down Expand Up @@ -4312,6 +4361,19 @@ echo "${ECHO_T}no" >&6; }
fi


if test -z "$llvmLlc"; then

{ { echo "$as_me:$LINENO: error:
You must install llc before you can continue
Perhaps it is already installed, but not in your PATH?" >&5
echo "$as_me: error:
You must install llc before you can continue
Perhaps it is already installed, but not in your PATH?" >&2;}
{ (exit 1); exit 1; }; }

fi

fi
else
llvmLlc=$LLC
fi
Expand All @@ -4322,6 +4384,13 @@ fi
LLVM_LLC_CMD=$llvmLlc


if test -x $llvmLlc -a -x $llvmAs -a -x $llvmOpt
then
llvmExists=yes
else
llvmExists=no
fi

# md5
# Extract the first word of "md5 md5sum", so it can be a program name with args.
set dummy md5 md5sum; ac_word=$2
Expand Down Expand Up @@ -29776,6 +29845,7 @@ javacCmd!$javacCmd$ac_delim
jarCmd!$jarCmd$ac_delim
JAVAC_CMD!$JAVAC_CMD$ac_delim
JAR_CMD!$JAR_CMD$ac_delim
ENABLE_LLVM!$ENABLE_LLVM$ac_delim
ENABLE_CLR!$ENABLE_CLR$ac_delim
ranlibCmd!$ranlibCmd$ac_delim
RANLIB_CMD!$RANLIB_CMD$ac_delim
Expand Down Expand Up @@ -29807,7 +29877,6 @@ UUAGC_CMD!$UUAGC_CMD$ac_delim
gccCmd!$gccCmd$ac_delim
GCC_CMD!$GCC_CMD$ac_delim
CC!$CC$ac_delim
CFLAGS!$CFLAGS$ac_delim
_ACEOF

if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
Expand Down Expand Up @@ -29849,6 +29918,7 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
CFLAGS!$CFLAGS$ac_delim
LDFLAGS!$LDFLAGS$ac_delim
CPPFLAGS!$CPPFLAGS$ac_delim
ac_ct_CC!$ac_ct_CC$ac_delim
Expand Down Expand Up @@ -29908,7 +29978,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF

if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 57; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 58; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
Expand Down Expand Up @@ -30400,6 +30470,28 @@ then
fi
fi

if test x$enableLlvm = xyes
then
echo " llvm is available? : $llvmExists"
echo " command for llc : $llvmLlc"
if test -x $llvmLlc
then
echo " version :" `$llvmLlc -version`
else
echo " **** ERROR **** : llc is not available and/or executable"
fi
echo " command for llvm-as : $llvmAs"
if test ! -x $llvmAs
then
echo " **** ERROR **** : llvm-as is not available and/or executable"
fi
echo " command for opt : $llvmOpt"
if test ! -x $llvmOpt
then
echo " **** ERROR **** : opt is not available and/or executable"
fi
fi

echo " MP library : $mplib"
if test "$mplib" == "gmp" ; then
if test "x$gmpLibArchiveExists" = "xyes" ;then
Expand Down
57 changes: 50 additions & 7 deletions EHC/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ AC_SUBST(SVN_VERSION_EXISTS,$svnVersionExists)
AC_SUBST(SVN_VERSION_CMD,$svnVersionCmd)
AC_SUBST(SVN_REVISION,$svnRevision)

### enable options
### enable options: java
AC_ARG_ENABLE(java, AS_HELP_STRING([--enable-java],[include java code generation]), [enableJava=yes], [enableJava=no])
AC_SUBST(ENABLE_JAVA,$enableJava)
if test x$enableJava = xyes
Expand Down Expand Up @@ -128,6 +128,11 @@ then
AC_SUBST(JAR_CMD,$jarCmd)
fi

### enable options: llvm
AC_ARG_ENABLE(llvm, AS_HELP_STRING([--enable-llvm],[include llvm code generation]), [enableLlvm=yes], [enableLlvm=no])
AC_SUBST(ENABLE_LLVM,$enableLlvm)

### enable options: clr
AC_ARG_ENABLE(clr, AS_HELP_STRING([--enable-clr],[include clr code generation]), [enableClr=yes], [enableClr=no])
AC_SUBST(ENABLE_CLR,$enableClr)

Expand Down Expand Up @@ -506,8 +511,11 @@ AC_ARG_WITH(llvm-as,
[Path to the LLVM Assembler])],
[ llvmAs="$withval" ],
[
if test "$LLVM_AS" = ""; then
AC_PATH_PROG(llvmAs,llvm-as)
if test "x$LLVM_AS" = "x"; then
if test x$enableLlvm = xyes
then
REQUIRED_PROG_FOR_EH(llvmAs,llvm-as)
fi
else
llvmAs=$LLVM_AS
fi
Expand All @@ -521,8 +529,11 @@ AC_ARG_WITH(opt,
[Path to the LLVM bitcode optimizer])],
[ llvmOpt="$withval" ],
[
if test "$LLVM_OPT" = ""; then
AC_PATH_PROG(llvmOpt,opt)
if test "x$LLVM_OPT" = "x"; then
if test x$enableLlvm = xyes
then
REQUIRED_PROG_FOR_EH(llvmOpt,opt)
fi
else
llvmOpt=$LLVM_OPT
fi
Expand All @@ -536,15 +547,25 @@ AC_ARG_WITH(llc,
[Path to the LLVM Compiler])],
[ llvmLlc="$withval" ],
[
if test "$LLC" = ""; then
AC_PATH_PROG(llvmLlc, llc)
if test "x$LLC" = "x"; then
if test x$enableLlvm = xyes
then
REQUIRED_PROG_FOR_EH(llvmLlc,llc)
fi
else
llvmLlc=$LLC
fi
]
)
AC_SUBST(LLVM_LLC_CMD,$llvmLlc)

if test -x $llvmLlc -a -x $llvmAs -a -x $llvmOpt
then
llvmExists=yes
else
llvmExists=no
fi

# md5
AC_PATH_PROG(md5Cmd,md5 md5sum)
AC_SUBST(MD5_CMD,$md5Cmd)
Expand Down Expand Up @@ -1073,6 +1094,28 @@ then
fi
fi

if test x$enableLlvm = xyes
then
echo " llvm is available? : $llvmExists"
echo " command for llc : $llvmLlc"
if test -x $llvmLlc
then
echo " version :" `$llvmLlc -version`
else
echo " **** ERROR **** : llc is not available and/or executable"
fi
echo " command for llvm-as : $llvmAs"
if test ! -x $llvmAs
then
echo " **** ERROR **** : llvm-as is not available and/or executable"
fi
echo " command for opt : $llvmOpt"
if test ! -x $llvmOpt
then
echo " **** ERROR **** : opt is not available and/or executable"
fi
fi

echo " MP library : $mplib"
if test "$mplib" == "gmp" ; then
if test "x$gmpLibArchiveExists" = "xyes" ;then
Expand Down
2 changes: 2 additions & 0 deletions EHC/ehclib/files2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ ehclib-codegentargetspecific-core:

ehclib-codegentargetspecific-clr:

ehclib-codegentargetspecific-llvm: $(if $(EHC_CFG_USE_GRIN),$(if $(ENABLE_LLVM),$(INSTALL_LIB_RTS),),)

###########################################################################################
# ehclib dispatch
###########################################################################################
Expand Down
6 changes: 6 additions & 0 deletions EHC/mk/config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ ifeq (@ENABLE_JAVA@,yes)
ENABLE_JAVA := yes
endif

# include java code generation
ifeq (@ENABLE_CLR@,yes)
ENABLE_CLR := yes
endif

# include llvm code generation
ifeq (@ENABLE_LLVM@,yes)
ENABLE_LLVM := yes
endif

3 changes: 2 additions & 1 deletion EHC/mk/shared.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ EXIT_IF_ABSENT_LIB_OR_TOOL := @EXIT_IF_ABSENT_LIB_OR_TOOL@
# which specific target is built, used by rts
EHC_CFG_TARGET_IS_bc := $(filter bc,$(EHC_VARIANT_TARGET))
EHC_CFG_TARGET_IS_C := $(filter C,$(EHC_VARIANT_TARGET))
EHC_CFG_TARGET_IS_llvm := $(filter llvm,$(EHC_VARIANT_TARGET))

# which MP lib
EHC_CFG_MPLIB := @MPLIB@
Expand Down Expand Up @@ -369,7 +370,7 @@ EXTLIBS_GCC_CC_OPTS := @GCC_EXTLIBS_OPTIONS@
EXTLIBS_GMP_ABI := @GMP_ABI@
EHC_GCC_CC_OPTS := -I$(INSTALLFORBLDABS_INC_PREFIX) -I$(INSTALLFORBLDABS_INC_PREFIX)/gc $(GCC_OPTS_WHEN_EHC)
EHC_GCC_LD_OPTS := -L$(INSTALLFORBLDABS_LIB_PREFIX)
RTS_GCC_CC_OPTS := -D__UHC_BUILDS_RTS__ -D__UHC_TARGET_$(if $(EHC_CFG_TARGET_IS_bc),BC,$(if $(EHC_CFG_TARGET_IS_C),C,))__ -D__UHC_TARGET__=$(EHC_VARIANT_TARGET)
RTS_GCC_CC_OPTS := -D__UHC_BUILDS_RTS__ -D__UHC_TARGET_$(if $(EHC_CFG_TARGET_IS_bc),BC,$(if $(EHC_CFG_TARGET_IS_C),C,$(if $(EHC_CFG_TARGET_IS_llvm),LLVM,)))__ -D__UHC_TARGET__=$(EHC_VARIANT_TARGET)
RTS_GCC_CC_OPTS_OPTIM := $(RTS_GCC_CC_OPTS) -O3

# library building, using libtool
Expand Down
6 changes: 6 additions & 0 deletions EHC/src/ehc/Base/Target.chs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ supportedTargetMp :: Map.Map String Target
, mk Target_FullProgAnal_Grin_C [FFIWay_CCall]
]
%%]]
%%[[(8 codegen llvm)
++ [ mk Target_FullProgAnal_Grin_LLVM [FFIWay_CCall] ]
%%]]
%%[[(8 codegen clr)
++ [ mk Target_FullProgAnal_Grin_CLR [FFIWay_CCall] ]
%%]]
Expand Down Expand Up @@ -284,6 +287,9 @@ ffiWayForPrim Target_Interpreter_Core_Jazy = Just FFIWay_Jazy
%%[[(8 codegen clr)
ffiWayForPrim Target_FullProgAnal_Grin_CLR = Just FFIWay_CLR
%%]]
%%[[(8 codegen llvm)
ffiWayForPrim Target_FullProgAnal_Grin_LLVM = Just FFIWay_CCall
%%]]
ffiWayForPrim t | targetIsC t = Just FFIWay_CCall
| otherwise = Nothing
%%]
Expand Down
2 changes: 1 addition & 1 deletion EHC/src/ehc/variant.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# aspects, EHC_ASPECTS to be configured at top level, for now here
###########################################################################################

EHC_ASPECTS := $(if $(ASPECTS),$(ASPECTS),base hmtyinfer codegen grin noHmTyRuler $(if $(ENABLE_JAVA),java jazy,) $(if $(ENABLE_CLR),clr,))
EHC_ASPECTS := $(if $(ASPECTS),$(ASPECTS),base hmtyinfer codegen grin noHmTyRuler $(if $(ENABLE_JAVA),java jazy,) $(if $(ENABLE_LLVM),llvm,) $(if $(ENABLE_CLR),clr,))
EHC_ASPECTS_SUFFIX := $(if $(ASPECTS),-$(subst $(space),-,$(ASPECTS)),)
EHC_ASPECTS_SUFFIX2 := $(subst -,,$(EHC_ASPECTS_SUFFIX))

Expand Down
Loading

0 comments on commit fdcc82b

Please sign in to comment.