summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-10-14 02:43:50 +0100
committerIan Lynagh <igloo@earth.li>2011-10-14 02:43:50 +0100
commit7c3b22edada41d6ad811a453575ec2084c6af823 (patch)
tree22e5b67cf08ec630ff25bcda904a9e37d70817de
parentbcab1273dcb58199001e225eca1708e6648a3bb4 (diff)
downloadhaskell-7c3b22edada41d6ad811a453575ec2084c6af823.tar.gz
Simplify the libffi build
We now put the libffi objects into the RTS library, rather than trying to mangle libffi into being a ghc package itself. It would be nicer to make it a separate library (but not a ghc package), but for now hopefully this will get the build going through on Windows again.
-rwxr-xr-xcompiler/ghc.cabal.in2
-rw-r--r--compiler/ghc.mk2
-rw-r--r--ghc.mk15
-rw-r--r--libffi/ghc.mk186
-rw-r--r--rts/ghc.mk28
-rw-r--r--rts/package.conf.in1
6 files changed, 39 insertions, 195 deletions
diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
index 09b0fb9335..56d9538524 100755
--- a/compiler/ghc.cabal.in
+++ b/compiler/ghc.cabal.in
@@ -81,7 +81,7 @@ Library
if flag(ghci)
Build-Depends: template-haskell
CPP-Options: -DGHCI
- Include-Dirs: ../libffi/build/include
+ Include-Dirs: ../rts/dist/build
Build-Depends: bin-package-db
Build-Depends: hoopl
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 4b84924609..43b609b7b5 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -265,7 +265,7 @@ PRIMOP_BITS = compiler/primop-data-decl.hs-incl \
compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
compiler_CPP_OPTS += ${GhcCppOpts}
-compiler/stage2/build/LibFFI.hs : libffi/dist-install/build/ffi.h
+compiler/stage2/build/LibFFI.hs : $(ffi_HEADER)
$(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
$(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
diff --git a/ghc.mk b/ghc.mk
index 9607fc8992..8f1888c404 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -257,7 +257,7 @@ include rules/tags-package.mk
include rules/extra-packages.mk
# -----------------------------------------------------------------------------
-# Registering hand-written package descriptions (used in libffi and rts)
+# Registering hand-written package descriptions (used in rts)
include rules/manual-package-config.mk
@@ -471,10 +471,8 @@ utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk
utils/compare_sizes/dist-install/package-data.mk: compiler/stage2/package-data.mk
utils/runghc/dist-install/package-data.mk: compiler/stage2/package-data.mk
-# add the final two package.conf dependencies: ghc-prim depends on RTS,
-# and RTS depends on libffi.
+# add the final package.conf dependency: ghc-prim depends on RTS
libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
-rts/package.conf.inplace : libffi/package.conf.inplace
endif
# --------------------------------
@@ -492,11 +490,6 @@ ALL_STAGE1_LIBS += $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-inst
endif
BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB))
-OTHER_LIBS = libffi/dist-install/build/libHSffi$(v_libsuf) libffi/dist-install/build/HSffi.o
-ifeq "$(BuildSharedLibs)" "YES"
-OTHER_LIBS += libffi/dist-install/build/libHSffi$(dyn_libsuf)
-endif
-
# ----------------------------------------
# Special magic for the ghc-prim package
@@ -890,11 +883,10 @@ INSTALL_DISTDIR_compiler = stage2
# Now we can do the installation
install_packages: install_libexecs
-install_packages: libffi/package.conf.install rts/package.conf.install
+install_packages: rts/package.conf.install
$(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
"$(RM)" $(RM_OPTS_REC) "$(INSTALLED_PACKAGE_CONF)"
$(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF)")
- "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update libffi/package.conf.install
"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
$(foreach p, $(INSTALLED_PKG_DIRS), \
$(call make-command, \
@@ -1219,7 +1211,6 @@ maintainer-clean : distclean
.PHONY: all_libraries
.PHONY: bootstrapping-files
-bootstrapping-files: $(OTHER_LIBS)
bootstrapping-files: includes/ghcautoconf.h
bootstrapping-files: includes/DerivedConstants.h
bootstrapping-files: includes/GHCConstants.h
diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index 3aa1cbc296..f6e99c2e58 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -11,75 +11,18 @@
# -----------------------------------------------------------------------------
-# We package libffi as Haskell package for two reasons:
-
-# 1) GHC uses different names for shared and static libs, so it can
-# choose the lib variant to link with on its own. With regular
-# libtool styled shared lib names, the linker would interfer and
-# link against the shared lib variant even when GHC runs in -static
-# mode.
-# 2) The first issue isn't a problem when a shared lib of libffi would
-# be installed in system locations, but we do not assume that. So,
-# when running in -dynamic mode, we must either install libffi to
-# system locations ourselves, or we must add its location to
-# respective environment variable, (DY)LD_LIBRARY_PATH etc...before
-# we call dynamically linked binaries. Especially, the latter is
-# necessary as GHC calls binary it produced before its installation
-# phase. However, both mechanism, installing to system locations or
-# modifying (DY)LD_LIBRARY_PATH, are already in place for Haskell
-# packages so with packaging libffi as Haskell package we reuse
-# them naturally.
-
-# -----------------------------------------------------------------------------
-#
-# We use libffi's own configuration stuff.
-
-# 2007-07-05
-# Passing
-# as_ln_s='cp -p'
-# isn't sufficient to stop cygwin using symlinks the mingw gcc can't
-# follow, as it isn't used consistently. Instead we put an ln.bat in
-# path that always fails.
-
ifeq "$(BuildSharedLibs)" "YES"
libffi_STAMP_CONFIGURE = libffi/stamp.ffi.configure-shared
libffi_STAMP_BUILD = libffi/stamp.ffi.build-shared
+libffi_STAMP_INSTALL = libffi/stamp.ffi.install-shared
else
libffi_STAMP_CONFIGURE = libffi/stamp.ffi.configure
libffi_STAMP_BUILD = libffi/stamp.ffi.build
+libffi_STAMP_INSTALL = libffi/stamp.ffi.install
endif
-BINDIST_STAMPS = libffi/stamp.ffi.build libfii/stamp.ffi.configure
-
-INSTALL_HEADERS += libffi/dist-install/build/ffi.h \
- libffi/dist-install/build/ffitarget.h
-libffi_STATIC_LIB = libffi/dist-install/build/libffi.a
-INSTALL_LIBS += libffi/dist-install/build/libHSffi.a \
- libffi/dist-install/build/libHSffi_p.a \
- libffi/dist-install/build/HSffi.o
-
-# We have to add the GHC version to the name of our dynamic libs, because
-# they will be residing in the system location along with dynamic libs from
-# other GHC installations.
-
-libffi_HS_DYN_LIB_NAME = libHSffi$(dyn_libsuf)
-libffi_HS_DYN_LIB = libffi/dist-install/build/$(libffi_HS_DYN_LIB_NAME)
-
-ifeq "$(Windows)" "YES"
-libffi_DYNAMIC_PROG = $(libffi_HS_DYN_LIB).a
-libffi_DYNAMIC_LIBS = $(libffi_HS_DYN_LIB)
-else
-libffi_DYNAMIC_PROG =
-ifeq "$(darwin_TARGET_OS)" "1"
-libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi$(soext) \
- libffi/dist-install/build/libffi.5$(soext)
-else ifeq "$(openbsd_TARGET_OS)" "1"
-libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi.so.5.10
-else
-libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi.so \
- libffi/dist-install/build/libffi.so.5
-endif
-endif
+libffi_STATIC_LIB = libffi/build/inst/lib/libffi.a
+ffi_HEADER = rts/dist/build/ffi.h
ifeq "$(BuildSharedLibs)" "YES"
libffi_EnableShared=yes
@@ -87,29 +30,21 @@ else
libffi_EnableShared=no
endif
-ifeq "$(BuildSharedLibs)" "YES"
-INSTALL_LIBS += $(libffi_HS_DYN_LIB)
-ifeq "$(Windows)" "YES"
-INSTALL_PROGS += $(libffi_HS_DYN_LIB).a
-endif
-endif
-
-# We have to fake a non-working ln for configure, so that the fallback
-# option (cp -p) gets used instead. Otherwise the libffi build system
-# will use cygwin symbolic linkks which cannot be read by mingw gcc.
-# The same trick is played by the GMP build in ../gmp.
-
ifneq "$(BINDIST)" "YES"
$(libffi_STAMP_CONFIGURE):
"$(RM)" $(RM_OPTS_REC) $(LIBFFI_DIR) libffi/build
cat ghc-tarballs/libffi/libffi*.tar.gz | $(GZIP_CMD) -d | { cd libffi && $(TAR_CMD) -xf - ; }
mv libffi/libffi-* libffi/build
+
+# We have to fake a non-working ln for configure, so that the fallback
+# option (cp -p) gets used instead. Otherwise the libffi build system
+# will use cygwin symbolic links which cannot be read by mingw gcc.
chmod +x libffi/ln
# Because -Werror may be in SRC_CC_OPTS/SRC_LD_OPTS, we need to turn
# warnings off or the compilation of libffi might fail due to warnings
cd libffi && \
- PATH=`pwd`:$$PATH; \
+ PATH=$(TOP)/libffi:$$PATH; \
export PATH; \
cd build && \
CC=$(CC_STAGE1) \
@@ -119,24 +54,11 @@ $(libffi_STAMP_CONFIGURE):
CFLAGS="$(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -w" \
LDFLAGS="$(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE1) -w" \
"$(SHELL)" configure \
+ --prefix=$(TOP)/libffi/build/inst \
--enable-static=yes \
--enable-shared=$(libffi_EnableShared) \
--host=$(HOSTPLATFORM) --build=$(BUILDPLATFORM)
- cp libffi/build/*/libtool libffi/build
-
- # libffi.so needs to be built with the correct soname.
- # NOTE: this builds libffi_convience.so with the incorrect
- # soname, but we don't need that anyway!
- cd libffi && \
- "$(CP)" build/libtool build/libtool.orig && \
- sed -e s/soname_spec=.*/soname_spec="$(libffi_HS_DYN_LIB_NAME)"/ build/libtool.orig > build/libtool
-
- # We don't want libtool's cygwin hacks
- cd libffi && \
- "$(CP)" build/libtool build/libtool.orig && \
- sed -e s/dlname=\'\$$tdlname\'/dlname=\'\$$dlname\'/ build/libtool.orig > build/libtool
-
# wc on OS X has spaces in its output, which libffi's Makefile
# doesn't expect, so we tweak it to sed them out
mv libffi/build/Makefile libffi/build/Makefile.orig
@@ -144,89 +66,23 @@ $(libffi_STAMP_CONFIGURE):
touch $@
-libffi/dist-install/build/ffi.h: $(libffi_STAMP_CONFIGURE) libffi/dist-install/build/ffitarget.h | $$(dir $$@)/.
- "$(CP)" libffi/build/*/include/ffi.h $@
-
-libffi/dist-install/build/ffitarget.h: $(libffi_STAMP_CONFIGURE) | $$(dir $$@)/.
- "$(CP)" libffi/build/*/include/ffitarget.h $@
-
-$(libffi_STAMP_BUILD): $(libffi_STAMP_CONFIGURE) | libffi/dist-install/build/.
+$(libffi_STAMP_BUILD): $(libffi_STAMP_CONFIGURE)
$(MAKE) -C libffi/build MAKEFLAGS=
- cd libffi/build && ./libtool --mode=install cp */libffi.la $(TOP)/libffi/dist-install/build
-
- # We actually want both static and dllized libraries, because we build
- # the runtime system both ways. libffi_convenience.a is the static version.
-ifeq "$(Windows)" "YES"
- cp libffi/build/.libs/libffi_convenience.a $(libffi_STATIC_LIB)
-endif
-
touch $@
-$(libffi_STATIC_LIB): $(libffi_STAMP_BUILD)
- @test -f $@ || { echo "$< exits, but $@ does not."; echo "Suggest removing $<."; exit 1; }
-
-# Rename libffi.a to libHSffi.a
-libffi/dist-install/build/libHSffi.a: $(libffi_STATIC_LIB)
- "$(CP)" $(libffi_STATIC_LIB) libffi/dist-install/build/libHSffi.a
-
-libffi/dist-install/build/libHSffi_p.a: $(libffi_STATIC_LIB)
- "$(CP)" $(libffi_STATIC_LIB) libffi/dist-install/build/libHSffi_p.a
-
-$(eval $(call all-target,libffi,$(INSTALL_HEADERS) $(INSTALL_LIBS)))
-
-# The GHCi import lib isn't needed as compiler/ghci/Linker.lhs + rts/Linker.c
-# link the interpreted references to FFI to the compiled FFI.
-# Instead of adding libffi to the list preloaded packages (see
-# compiler/ghci/Linker.lhs:emptyPLS) we generate an empty HSffi.o
-
-libffi/dist-install/build/HSffi.o: libffi/dist-install/build/libHSffi.a
- cd libffi/dist-install/build && \
- touch empty.c && \
- "$(CC_STAGE1)" $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -c empty.c -o HSffi.o
-
-$(eval $(call all-target,libffi,libffi/dist-install/build/HSffi.o))
-
-ifeq "$(BuildSharedLibs)" "YES"
-ifeq "$(Windows)" "YES"
-libffi/dist-install/build/libffi.dll.a $(libffi_HS_DYN_LIB): $(libffi_STAMP_BUILD)
- @test -f $@ || { echo "$< exits, but $@ does not."; echo "Suggest removing $<."; exit 1; }
+$(libffi_STAMP_INSTALL): $(libffi_STAMP_BUILD)
+ $(MAKE) -C libffi/build MAKEFLAGS= install
+ touch $@
-# Windows libtool creates <soname>.dll, and as we already patched that
-# there is no need to copy from libffi.dll to libHSffi...dll.
-# However, the renaming is still required for the import library
-# libffi.dll.a.
-$(libffi_HS_DYN_LIB).a: libffi/dist-install/build/libffi.dll.a | $$(dir $$@)/.
- "$(CP)" $< $@
+$(libffi_STATIC_LIB): $(libffi_STAMP_INSTALL)
+ @test -f $@ || { echo "$< exists, but $@ does not."; echo "Suggest removing $<."; exit 1; }
-$(eval $(call all-target,libffi,$(libffi_HS_DYN_LIB).a))
-
-else
-$(libffi_DYNAMIC_LIBS): $(libffi_STAMP_BUILD)
- @test -f $@ || { echo "$< exits, but $@ does not."; echo "Suggest removing $<."; exit 1; }
-
-# Rename libffi.so to libHSffi...so
-$(libffi_HS_DYN_LIB): $(libffi_DYNAMIC_LIBS) | $$(dir $$@)/.
- "$(CP)" $(word 1,$(libffi_DYNAMIC_LIBS)) $(libffi_HS_DYN_LIB)
-ifeq "$(darwin_TARGET_OS)" "1"
- # Ensure library's install name is correct before anyone links with it.
- install_name_tool -id $(ghclibdir)/$(libffi_HS_DYN_LIB_NAME) $(libffi_HS_DYN_LIB)
-endif
-
-$(eval $(call all-target,libffi,$(libffi_HS_DYN_LIB)))
-endif
-endif
+$(ffi_HEADER): $(libffi_STAMP_INSTALL) | $$(dir $$@)/.
+ cp libffi/build/inst/lib/libffi-*/include/ffitarget.h $(dir $@)
+ cp libffi/build/inst/lib/libffi-*/include/ffi.h $@
$(eval $(call clean-target,libffi,, \
- libffi/build libffi/stamp.ffi.* libffi/dist-install))
-endif
-
-#-----------------------------------------------------------------------------
-# Do the package config
+ libffi/build libffi/stamp.ffi.* libffi/dist-install))
-$(eval $(call manual-package-config,libffi))
-
-#-----------------------------------------------------------------------------
-#
-# binary-dist
+endif
-BINDIST_EXTRAS += libffi/package.conf.in
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 9f3680d71b..767194e23f 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -172,15 +172,15 @@ rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
# Making a shared library for the RTS.
ifneq "$$(findstring dyn, $1)" ""
ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32"
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend $$(rts_ffi_objs_stamp)
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
- -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
+ -no-auto-link-packages `cat rts/libs.depend` $$(rts_ffi_objs) $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
else
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend $$(rts_ffi_objs_stamp)
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
- -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) \
+ -no-auto-link-packages `cat rts/libs.depend` $$(rts_ffi_objs) $$(rts_$1_OBJS) \
$$(rts_$1_DTRACE_OBJS) -o $$@
ifeq "$$(darwin_HOST_OS)" "1"
# Ensure library's install name is correct before anyone links with it.
@@ -188,9 +188,9 @@ ifeq "$$(darwin_HOST_OS)" "1"
endif
endif
else
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_ffi_objs_stamp)
"$$(RM)" $$(RM_OPTS) $$@
- echo $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
+ echo $$(rts_ffi_objs) $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
$$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
endif
@@ -198,6 +198,12 @@ endif
endef
+rts_ffi_objs_stamp = rts/dist/ffi/stamp
+rts_ffi_objs = rts/dist/ffi/*.o
+$(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) | $$(dir $$@)/.
+ cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
+ touch $@
+
# And expand the above for each way:
$(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
@@ -455,15 +461,7 @@ endif
$(eval $(call dependencies,rts,dist,1))
-$(rts_dist_depfile_c_asm) : libffi/dist-install/build/ffi.h $(DTRACEPROBES_H)
-
-#-----------------------------------------------------------------------------
-# libffi stuff
-
-rts_CC_OPTS += -Ilibffi/dist-install/build
-rts_HC_OPTS += -Ilibffi/dist-install/build
-rts_HSC2HS_OPTS += -Ilibffi/dist-install/build
-rts_LD_OPTS += -Llibffi/dist-install/build
+$(rts_dist_depfile_c_asm) : $(ffi_HEADER) $(DTRACEPROBES_H)
# -----------------------------------------------------------------------------
# compile dtrace probes if dtrace is supported
diff --git a/rts/package.conf.in b/rts/package.conf.in
index c60bf8759a..e38a38186d 100644
--- a/rts/package.conf.in
+++ b/rts/package.conf.in
@@ -55,7 +55,6 @@ include-dirs: TOP"/includes"
#endif
includes: Stg.h
-depends: builtin_ffi
hugs-options:
cc-options: