hadrian: Only link against libffi when it is needed for adjustors
AcceptedPublic

Authored by bgamari on Dec 9 2018, 9:06 AM.

Details

Reviewers
DavidEichmann
snowleopard
Trac Issues
#16022
Summary
bgamari created this revision.Dec 9 2018, 9:06 AM
snowleopard accepted this revision.Dec 10 2018, 4:34 AM

Hope that's enough to fix the issue.

This revision is now accepted and ready to land.Dec 10 2018, 4:34 AM

Im confused: setting the ffi flag *enables* linking with ffi. So if I understand correctly, this can only serve to *increase* the cases where we link with ffi. I'm trying to find the relevant logic in the make build system now.

There seems to be some logic using -l$$(LIBFFI_NAME) in rts/ghc.mk. configure.ac also seems to set the default value of the ffi flag by doing AC_SUBST([CabalHaveLibffi],[False]) or AC_SUBST([CabalHaveLibffi],[True]).

@DavidEichmann, what is the status of this?

@bgamari, last we spoke it was unclear why this would work to limit linking agains ffi as per my previous comment:

Im confused: setting the ffi flag *enables* linking with ffi. So if I understand correctly, this can only serve to *increase* the cases where we link with ffi. I'm trying to find the relevant logic in the make build system now.

If you'd like me to look into this more I can, though it may be a few days before I get to this.

Looking at the make build system, the UseLibFFIForAdjustors variable is only used to toggle cLibFFI in Config.hs files, and also in compiler/ghc.mk to set the USE_LIBFFI_FOR_ADJUSTORS flag when compiling the rts:

ifeq "$(UseLibFFIForAdjustors)" "YES"
rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
endif

The above logic isn't implemented in Hadrian, which seems like a separate issue. I can't find any logic in the make system that toggles linking with ffi.