Skip to content

Commit 7996993

Browse files
committed
Drop libffi; Stop shipping a copy of libffi
GHC used to depend on an in-flight version of libffi. As libffis releases are more frequent now, there is no immediate need for this anymore. GHC should be able to rely on system provided libffi, and not try to become a system library package manager as well.
1 parent ab56989 commit 7996993

File tree

5 files changed

+10
-28
lines changed

5 files changed

+10
-28
lines changed

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@
100100
path = utils/hsc2hs
101101
url = https://gitlab.haskell.org/ghc/hsc2hs.git
102102
ignore = untracked
103-
[submodule "libffi-tarballs"]
104-
path = libffi-tarballs
105-
url = https://gitlab.haskell.org/ghc/libffi-tarballs.git
106-
ignore = untracked
107103
[submodule "gmp-tarballs"]
108104
path = libraries/ghc-internal/gmp/gmp-tarballs
109105
url = https://gitlab.haskell.org/ghc/gmp-tarballs.git

compiler/GHC/Driver/CodeOutput.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,11 @@ outputJS _ _ _ _ _ = pgmError $ "codeOutput: Hit JavaScript case. We should neve
255255
-}
256256

257257
{-
258-
Note [Packaging libffi headers]
258+
Note [libffi headers]
259259
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260260
The C code emitted by GHC for libffi adjustors must depend upon the ffi_arg type,
261-
defined in <ffi.h>. For this reason, we must ensure that <ffi.h> is available
262-
in binary distributions. To do so, we install these headers as part of the
263-
`rts` package.
261+
defined in <ffi.h>. On systems where GHC uses the libffi adjustors, the libffi
262+
library, and headers must be installed.
264263
-}
265264

266265
outputForeignStubs

libffi-tarballs

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
# localpath tag remotepath upstreamurl
3838
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3939
ghc-tarballs windows ghc-tarballs.git -
40-
libffi-tarballs - - -
4140
utils/hsc2hs - - ssh://[email protected]/haskell/hsc2hs.git
4241
libraries/array - - -
4342
libraries/binary - - https://github.com/kolmodin/binary.git

rts/rts.cabal

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ flag librt
276276
flag libdl
277277
default: False
278278
manual: True
279-
flag use-system-libffi
280-
default: False
281-
manual: True
282279
flag libffi-adjustors
283280
default: False
284281
manual: True
@@ -402,18 +399,6 @@ library
402399
stg/Types.h
403400

404401
else
405-
-- If we are using an in-tree libffi then we must declare it as a bundled
406-
-- library to ensure that Cabal installs it.
407-
if !flag(use-system-libffi)
408-
if os(windows)
409-
extra-bundled-libraries: Cffi-6
410-
else
411-
extra-bundled-libraries: Cffi
412-
413-
install-includes: ffi.h ffitarget.h
414-
-- ^ see Note [Packaging libffi headers] in
415-
-- GHC.Driver.CodeOutput.
416-
417402
-- Here we declare several flavours to be available when passing the
418403
-- suitable (combination of) flag(s) when configuring the RTS from hadrian,
419404
-- using Cabal.
@@ -465,9 +450,6 @@ library
465450
extra-libraries: rt
466451
if flag(libdl)
467452
extra-libraries: dl
468-
if flag(use-system-libffi)
469-
extra-libraries: ffi
470-
extra-libraries-static: ffi
471453
if os(windows)
472454
extra-libraries:
473455
-- for the linker
@@ -634,6 +616,8 @@ library
634616
-- Adjustor stuff
635617
if flag(libffi-adjustors)
636618
c-sources: adjustor/LibffiAdjustor.c
619+
extra-libraries: ffi
620+
extra-libraries-static: ffi
637621
else
638622
-- Use GHC's native adjustors
639623
if arch(i386)
@@ -646,6 +630,11 @@ library
646630
else
647631
asm-sources: adjustor/NativeAmd64Asm.S
648632
c-sources: adjustor/NativeAmd64.c
633+
-- fall back to the LibffiAdjustor if neither i386, or x86_64
634+
if !arch(x86_64) && !arch(i386)
635+
c-sources: adjustor/LibffiAdjustor.c
636+
extra-libraries: ffi
637+
extra-libraries-static: ffi
649638

650639
-- Use assembler STG entrypoint on architectures where it is used
651640
if arch(ppc) || arch(ppc64) || arch(s390x) || arch(riscv64) || arch(loongarch64)

0 commit comments

Comments
 (0)