Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/3005e90936c47c1f71672bf6c84fff20cb14014b >--------------------------------------------------------------- commit 3005e90936c47c1f71672bf6c84fff20cb14014b Author: Ian Lynagh <i...@well-typed.com> Date: Thu Nov 29 22:22:39 2012 +0000 Add configure option to use system provided libffi; fixes #5743 Based on patch from Peter Trommler: From 293495d40f62e691520331a41c6d85d82e120169 Mon Sep 17 00:00:00 2001 From: Peter Trommler <ptromm...@acm.org> Date: Sun, 21 Oct 2012 18:47:01 +0200 Subject: [PATCH] Add configure option to use system provided libffi This fixes track # 5743 and #4496. >--------------------------------------------------------------- configure.ac | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ ghc.mk | 11 ++++++++- mk/config.mk.in | 7 ++++++ rts/ghc.mk | 42 ++++++++++++++++++++++++++++++++++---- rts/package.conf.in | 3 ++ 5 files changed, 111 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 54e7c14..6b9335e 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,61 @@ AC_ARG_WITH([ghc], fi WithGhc="$GHC"]) +# system libffi + +AC_ARG_WITH([system-libffi], +[AC_HELP_STRING([--with-system-libffi], + [Use system provided libffi for RTS [default=no]]) +]) + +AS_IF([test "x$with_system_libffi" = "xyes"], + [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"] +) + + +AC_SUBST(UseSystemLibFFI) + +AC_ARG_WITH([ffi-includes], +[AC_HELP_STRING([--with-ffi-includes=ARG] + [Find includes for libffi in ARG [default=system default]]) +], +[ + if test "x$UseSystemLibFFI" != "xYES"; then + AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set]) + else + FFIIncludeDir="$withval" + LIBFFI_CFLAGS="-I $withval" + fi +]) + +AC_SUBST(FFIIncludeDir) + +AC_ARG_WITH([ffi-libraries], +[AC_HELP_STRING([--with-ffi-libraries=ARG] + [Find libffi in ARG [default=system default]]) +], +[ + if test "x$UseSystemLibFFI" != "xYES"; then + AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set]) + else + FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval" + fi +]) + +AC_SUBST(FFILibDir) + +AS_IF([test "$UseSystemLibFFI" = "YES"], [ + CFLAGS2="$CFLAGS" + CFLAGS="$LIBFFI_CFLAGS $CFLAGS" + LDFLAGS2="$LDFLAGS" + LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS" + AC_CHECK_LIB(ffi, ffi_call, + [AC_CHECK_HEADERS([ffi.h], [break], []) + AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])], + [UseSystemLibFFI="NO"]) + CFLAGS="$CFLAGS2" + LDFLAGS="$LDFLAGS2" +]) dnl ** Tell the make system which OS we are using dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something diff --git a/ghc.mk b/ghc.mk index 39af75c..852baa9 100644 --- a/ghc.mk +++ b/ghc.mk @@ -52,7 +52,7 @@ # * For each package: # o configure, generate package-data.mk and inplace-pkg-info # o register each package into inplace/lib/package.conf -# * build libffi +# * build libffi (if not disabled by --with-system-libffi) # * With bootstrapping compiler: # o Build libraries/{filepath,hpc,Cabal} # o Build compiler (stage 1) @@ -618,12 +618,18 @@ else MAYBE_GHCI=driver/ghci endif +ifeq "$(UseSystemLibFFI)" "YES" +MAYBE_LIBFFI= +else +MAYBE_LIBFFI=libffi +endif + BUILD_DIRS += \ driver \ $(MAYBE_GHCI) \ driver/ghc \ driver/haddock \ - libffi \ + $(MAYBE_LIBFFI) \ includes \ rts @@ -1044,6 +1050,7 @@ unix-binary-dist-prep: echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK) echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK) echo "GHC_CABAL_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" >> $(BIN_DIST_MK) + echo "UseSystemLibFFI = $(UseSystemLibFFI)" >> $(BIN_DIST_MK) cd $(BIN_DIST_PREP_DIR) && autoreconf $(call removeFiles,$(BIN_DIST_PREP_TAR)) # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source diff --git a/mk/config.mk.in b/mk/config.mk.in index 206232a..3d8ca8c 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -380,6 +380,13 @@ GhcRtsWithPapi = NO PapiLibDir= PapiIncludeDir= +# Configuration for libffi +UseSystemLibFFI=@UseSystemLibFFI@ +# Flags to go into package.conf for rts +FFILibDir=@FFILibDir@ +FFIIncludeDir=@FFIIncludeDir@ + + ################################################################################ # # Paths (see paths.mk) diff --git a/rts/ghc.mk b/rts/ghc.mk index fe26ee1..bf01a90 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -107,8 +107,10 @@ $(foreach lib,$(ALL_RTS_DEF_LIBNAMES),$(eval $(call make-importlib-def,$(lib)))) endif ifneq "$(BINDIST)" "YES" +ifneq "$(UseSystemLibFFI)" "YES" rts_ffi_objs_stamp = rts/dist/ffi/stamp rts_ffi_objs = rts/dist/ffi/*.o + $(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) $(TOUCH_DEP) | $$(dir $$@)/. cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB) "$(TOUCH_CMD)" $@ @@ -121,6 +123,7 @@ rts/dist/build/libffi$(soext): libffi/build/inst/lib/libffi$(soext) rts/dist/build/$(LIBFFI_DLL): libffi/build/inst/bin/$(LIBFFI_DLL) cp $< $@ endif +endif #----------------------------------------------------------------------------- # Building one way @@ -177,6 +180,12 @@ endif rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\" +ifneq "$(UseSystemLibFFI)" "YES" +rts_dist_FFI_SO = rts/dist/build/libffi$(soext) +else +rts_dist_FFI_SO = +endif + # Making a shared library for the RTS. ifneq "$$(findstring dyn, $1)" "" ifeq "$$(HostOS_CPP)" "mingw32" @@ -185,10 +194,10 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend rts/dist/b "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \ -no-auto-link-packages -Lrts/dist/build -l$(LIBFFI_WINDOWS_LIB) `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@ else -$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend rts/dist/build/libffi$$(soext) +$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend $$(rts_dist_FFI_SO) "$$(RM)" $$(RM_OPTS) $$@ "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \ - -no-auto-link-packages -Lrts/dist/build -lffi `cat rts/libs.depend` $$(rts_$1_OBJS) \ + -no-auto-link-packages $$(LIBFFI_LIBS) `cat rts/libs.depend` $$(rts_$1_OBJS) \ $$(rts_$1_DTRACE_OBJS) -o $$@ endif else @@ -377,10 +386,16 @@ rts/dist/build/AutoApply_HC_OPTS += -fno-PIC -static endif endif +# add CFLAGS for libffi # ffi.h triggers prototype warnings, so disable them here: -rts/Interpreter_CC_OPTS += -Wno-strict-prototypes -rts/Adjustor_CC_OPTS += -Wno-strict-prototypes -rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes +ifeq "$(UseSystemLibFFI)" "YES" +LIBFFI_CFLAGS = $(addprefix -I,$(FFIIncludeDir)) +else +LIBFFI_CFLAGS = +endif +rts/Interpreter_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS) +rts/Adjustor_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS) +rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS) # inlining warnings happen in Compact rts/sm/Compact_CC_OPTS += -Wno-inline @@ -438,6 +453,21 @@ rts_PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR="" endif +#----------------------------------------------------------------------------- +# Use system provided libffi + +ifeq "$(UseSystemLibFFI)" "YES" + +rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir) +rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir) + +else # UseSystemLibFFI==YES + +rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR="" +rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR="" + +endif + # ----------------------------------------------------------------------------- # dependencies @@ -515,7 +545,9 @@ RTS_INSTALL_LIBS += $(ALL_RTS_LIBS) RTS_INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*) RTS_INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL)) +ifneq "$(UseSystemLibFFI)" "YES" install: install_libffi_headers +endif .PHONY: install_libffi_headers install_libffi_headers : diff --git a/rts/package.conf.in b/rts/package.conf.in index 9fc8721..ee964db 100644 --- a/rts/package.conf.in +++ b/rts/package.conf.in @@ -33,6 +33,9 @@ extra-libraries: #ifdef HAVE_LIBDL , "dl" #endif +#ifdef HAVE_LIBFFI + , "ffi" +#endif #ifdef mingw32_HOST_OS ,"wsock32" /* for the linker */ ,"gdi32" /* for the linker */ _______________________________________________ Cvs-ghc mailing list Cvs-ghc@haskell.org http://www.haskell.org/mailman/listinfo/cvs-ghc