[commit: ghc] master: Change how we handle libffi (b30015e)
Ian Lynagh
igloo at earth.li
Sun Mar 24 01:01:29 CET 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : master
https://github.com/ghc/ghc/commit/b30015e78db99d79cdb48c6c810e3fd49573c5cd
>---------------------------------------------------------------
commit b30015e78db99d79cdb48c6c810e3fd49573c5cd
Author: Ian Lynagh <ian at well-typed.com>
Date: Sat Mar 23 23:55:56 2013 +0000
Change how we handle libffi
I think overall the new approach is simpler. Rather than unpacking
the libffi.a and putting the .o files into our libHSrts.a, we just
use the libffi.a.
This change also means that when compiling programs for the dyn
way, they get explicitly linked against libffi.so (rather than
relying on librts.so being linked against it). This might
fix a problem on FreeBSD, where programs cannot find libffi.so.
>---------------------------------------------------------------
compiler/main/Packages.lhs | 12 ++++++++++--
rts/ghc.mk | 39 ++++++++++++++++++++++-----------------
rts/package.conf.in | 2 +-
3 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
index 52361ce..54d9d1b 100644
--- a/compiler/main/Packages.lhs
+++ b/compiler/main/Packages.lhs
@@ -896,8 +896,16 @@ packageHsLibs dflags p = map (mkDynName . addSuffix) (hsLibraries p)
tag = mkBuildTag (filter (not . wayRTSOnly) ways2)
rts_tag = mkBuildTag ways2
- mkDynName | gopt Opt_Static dflags = id
- | otherwise = (++ ("-ghc" ++ cProjectVersion))
+ mkDynName x
+ | gopt Opt_Static dflags = x
+ | "HS" `isPrefixOf` x = x ++ "-ghc" ++ cProjectVersion
+ -- For non-Haskell libraries, we use the name "Cfoo". The .a
+ -- file is libCfoo.a, and the .so is libfoo.so. That way the
+ -- linker knows what we mean for the vanilla (-lCfoo) and dyn
+ -- (-lfoo) ways. We therefore need to strip the 'C' off here.
+ | Just x' <- stripPrefix "C" x = x'
+ | otherwise
+ = panic ("Don't understand library name " ++ x)
addSuffix rts@"HSrts" = rts ++ (expandTag rts_tag)
addSuffix other_lib = other_lib ++ (expandTag tag)
diff --git a/rts/ghc.mk b/rts/ghc.mk
index c567885..7324ba0 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -104,13 +104,6 @@ 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)" $@
-
# This is a little hacky. We don't know the SO version, so we only
# depend on libffi.so, but copy libffi.so*
rts/dist/build/libffi$(soext): libffi/build/inst/lib/libffi$(soext)
@@ -174,8 +167,8 @@ endif
rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
-ifneq "$(UseSystemLibFFI)" "YES"
-rts_dist_FFI_SO = rts/dist/build/libffi$(soext)
+ifneq "$$(UseSystemLibFFI)" "YES"
+rts_dist_FFI_SO = rts/dist/build/libffi$$(soext)
else
rts_dist_FFI_SO =
endif
@@ -188,7 +181,7 @@ $$(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
-ifneq "$(UseSystemLibFFI)" "YES"
+ifneq "$$(UseSystemLibFFI)" "YES"
LIBFFI_LIBS = -Lrts/dist/build -lffi
ifeq "$$(TargetElf)" "YES"
LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN'
@@ -205,10 +198,17 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend $$(rts_d
$$(rts_$1_DTRACE_OBJS) -o $$@
endif
else
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_ffi_objs_stamp)
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
"$$(RM)" $$(RM_OPTS) $$@
- echo $$(rts_ffi_objs) $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
+ echo $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
$$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
+
+ifneq "$$(UseSystemLibFFI)" "YES"
+$$(rts_$1_LIB) : rts/dist/build/libCffi$$($1_libsuf)
+rts/dist/build/libCffi$$($1_libsuf): libffi/build/inst/lib/libffi.a
+ cp $$< $$@
+endif
+
endif
endif
@@ -459,13 +459,15 @@ endif
ifeq "$(UseSystemLibFFI)" "YES"
-rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
-rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
+rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
+rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
+rts_PACKAGE_CPP_OPTS += '-DFFI_LIB='
else # UseSystemLibFFI==YES
-rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=""
-rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=""
+rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=
+rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=
+rts_PACKAGE_CPP_OPTS += '-DFFI_LIB="Cffi"'
endif
@@ -544,8 +546,11 @@ rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
# installing
RTS_INSTALL_LIBS += $(ALL_RTS_LIBS)
+ifneq "$(UseSystemLibFFI)" "YES"
RTS_INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
-RTS_INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL))
+RTS_INSTALL_LIBS += $(foreach w,$(filter-out dyn,$(rts_WAYS)),rts/dist/build/libffi$($w_libsuf))
+RTS_INSTALL_LIBS += rts/dist/build/$(LIBFFI_DLL)
+endif
ifneq "$(UseSystemLibFFI)" "YES"
install: install_libffi_headers
diff --git a/rts/package.conf.in b/rts/package.conf.in
index 5a34576..9aef05d 100644
--- a/rts/package.conf.in
+++ b/rts/package.conf.in
@@ -21,7 +21,7 @@ library-dirs: LIB_DIR"/rts-1.0" PAPI_LIB_DIR
library-dirs: TOP"/rts/dist/build" PAPI_LIB_DIR
#endif
-hs-libraries: "HSrts"
+hs-libraries: "HSrts" FFI_LIB
extra-libraries:
#ifdef HAVE_LIBM
More information about the ghc-commits
mailing list