[Git][ghc/ghc][wip/ghc-9.6.7-backports] 2 commits: JS: fake support for native adjustors (#25159)

Luite Stegeman (@luite) gitlab at gitlab.haskell.org
Sun Jan 26 12:18:43 UTC 2025



Luite Stegeman pushed to branch wip/ghc-9.6.7-backports at Glasgow Haskell Compiler / GHC


Commits:
1dd6f426 by Sylvain Henry at 2025-01-26T13:18:02+01:00
JS: fake support for native adjustors (#25159)

The JS backend doesn't support adjustors (I believe) and in any case if
it ever supports them it will be a native support, not one via libffi.

(cherry picked from commit 03055c71446c8f1265de3a6ccb5bc9e09827821e)

- - - - -
94794c38 by Matthew Pickering at 2025-01-26T13:18:02+01:00
hadrian: Make sure ffi headers are built before using a compiler

When we are using ffi adjustors then we rely on `ffi.h` and
`ffitarget.h` files during code generation when compiling stubs.

Therefore we need to add this dependency to the build system (which this
patch does).

Reproducer, configure with `--enable-libffi-adjustors` and then build
"_build/stage1/libraries/ghc-prim/build/GHC/Types.p_o".

Observe that this fails before this patch and works afterwards.

Fixes #24864

Co-authored-by: Sylvain Henry <sylvain at haskus.fr>
(cherry picked from commit 0167e472e7035d31591777983d8e35528aceefff)

- - - - -


2 changed files:

- hadrian/src/Builder.hs
- m4/ghc_adjustors_method.m4


Changes:

=====================================
hadrian/src/Builder.hs
=====================================
@@ -241,6 +241,8 @@ instance H.Builder Builder where
             -- GHC from the previous stage is used to build artifacts in the
             -- current stage. Need the previous stage's GHC deps.
             ghcdeps <- ghcBinDeps (predStage stage)
+            libffi_adjustors <- useLibffiForAdjustors
+            use_system_ffi <- flag UseSystemFfi
 
             return $ [ unlitPath ]
                   ++ ghcdeps
@@ -249,6 +251,13 @@ instance H.Builder Builder where
                      -- proxy for the entire mingw toolchain that
                      -- we have in inplace/mingw initially, and then at
                      -- root -/- mingw.
+                  -- ffi.h needed by the compiler when using libffi_adjustors (#24864)
+                  -- It would be nicer to not duplicate this logic between here
+                  -- and needRtsLibffiTargets and libffiHeaderFiles but this doesn't change
+                  -- very often.
+                  ++ [ root -/- buildDir (rtsContext stage) -/- "include" -/- header
+                     | header <- ["ffi.h", "ffitarget.h"]
+                     , libffi_adjustors && not use_system_ffi ]
 
         Hsc2Hs stage -> (\p -> [p]) <$> templateHscPath stage
         Make dir  -> return [dir -/- "Makefile"]


=====================================
m4/ghc_adjustors_method.m4
=====================================
@@ -4,7 +4,7 @@ dnl Use libffi for adjustors?
 AC_DEFUN([GHC_ADJUSTORS_METHOD],
 [
   case [$]{$1[Arch]} in
-      i386|x86_64)
+      i386|x86_64|javascript)
           # We have native adjustor support on these platforms
           HaveNativeAdjustor=yes
           ;;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e69b5f63cb57982ac26ac5138b97ff8dbb16a407...94794c38b62079ee0912b3561fbdbc2e6473ad89

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e69b5f63cb57982ac26ac5138b97ff8dbb16a407...94794c38b62079ee0912b3561fbdbc2e6473ad89
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250126/85282d99/attachment-0001.html>


More information about the ghc-commits mailing list