[Git][haskell-team/DHG_packages][master] 3 commits: ghc: Add binutils-gold, this fixes FTBFS on armel and armhf (Closes: #1094995)
Gianfranco Costamagna (@locutusofborg)
gitlab at salsa.debian.org
Fri Feb 14 07:55:14 GMT 2025
Gianfranco Costamagna pushed to branch master at Debian Haskell Group / DHG_packages
Commits:
2eba3da5 by Gianfranco Costamagna at 2025-02-12T21:01:35+01:00
ghc: Add binutils-gold, this fixes FTBFS on armel and armhf (Closes: #1094995)
- - - - -
45685be3 by Gianfranco Costamagna at 2025-02-12T21:05:56+01:00
>From 王鑫 <wangxin03 at loongson.cn> Backport upstream commits to fix loong64 relocation failures (Closes: #1089921)
- - - - -
2bd30daf by Gianfranco Costamagna at 2025-02-14T08:54:29+01:00
ghc: Add links to upstream commits for cherry-picked patches
- - - - -
9 changed files:
- p/ghc/debian/changelog
- p/ghc/debian/control
- + p/ghc/debian/patches/0001-llvmGen-Add-export-list-to-GHC.Llvm.MetaData.patch
- + p/ghc/debian/patches/0002-llvmGen-Allow-LlvmLits-in-MetaExprs.patch
- + p/ghc/debian/patches/0003-llvmGen-Introduce-infrastructure-for-module-flag-metadata.patch
- + p/ghc/debian/patches/0004-llvmGen-Pass-mcmodel-medium-option-to-LLVM-backend-on-LoongArch.patch
- − p/ghc/debian/patches/7e2d3eb507da184cf3337d36715fd82a81643d91.patch
- p/ghc/debian/patches/series
- p/ghc/debian/rules
Changes:
=====================================
p/ghc/debian/changelog
=====================================
@@ -1,7 +1,16 @@
ghc (9.6.6-4) UNRELEASED; urgency=medium
+ [ John Paul Adrian Glaubitz ]
* Add patch to fix FTBFS on alpha (Closes#: 1086830)
+ [ Gianfranco Costamagna ]
+ * Add binutils-gold to armel and armhf, according to rules file
+ (Closes: #1094995)
+
+ [ 王鑫 <wangxin03 at loongson.cn> ]
+ * Update loongarch64 patch with new upstream backported commits
+ (Closes: #1089921)
+
-- John Paul Adrian Glaubitz <glaubitz at physik.fu-berlin.de> Fri, 07 Feb 2025 18:37:05 +0100
ghc (9.6.6-3) unstable; urgency=medium
=====================================
p/ghc/debian/control
=====================================
@@ -35,6 +35,7 @@ Package: ghc
Architecture: any
Depends:
llvm-18 [armel armhf s390x riscv64 loong64],
+ binutils-gold [armel armhf],
gcc,
libgmp-dev,
libffi-dev,
=====================================
p/ghc/debian/patches/0001-llvmGen-Add-export-list-to-GHC.Llvm.MetaData.patch
=====================================
@@ -0,0 +1,31 @@
+Origin: https://github.com/ghc/ghc/commit/e8b4aac437b2620d93546a57eb5818f317a4549e
+From fcfc1777c22ad47613256c3c5e7304cfd29bc761 Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben at smart-cactus.org>
+Date: Tue, 22 Aug 2023 12:23:26 -0400
+Subject: [PATCH] llvmGen: Add export list to GHC.Llvm.MetaData
+
+---
+ compiler/GHC/Llvm/MetaData.hs | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/compiler/GHC/Llvm/MetaData.hs b/compiler/GHC/Llvm/MetaData.hs
+index 3f8818ee45..2ad759fba8 100644
+--- a/compiler/GHC/Llvm/MetaData.hs
++++ b/compiler/GHC/Llvm/MetaData.hs
+@@ -1,6 +1,12 @@
+ {-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
+-module GHC.Llvm.MetaData where
++module GHC.Llvm.MetaData
++ ( MetaId(..)
++ , ppMetaId
++ , MetaExpr(..)
++ , MetaAnnot(..)
++ , MetaDecl(..)
++ ) where
+
+ import GHC.Prelude
+
+--
+2.25.1
+
=====================================
p/ghc/debian/patches/0002-llvmGen-Allow-LlvmLits-in-MetaExprs.patch
=====================================
@@ -0,0 +1,38 @@
+Origin: https://github.com/ghc/ghc/commit/5880fff6d353a14785c457999fded5a7100c9514
+From 5880fff6d353a14785c457999fded5a7100c9514 Mon Sep 17 00:00:00 2001
+From: Wang Xin <wangxin03 at loongson.cn>
+Date: Fri, 13 Dec 2024 03:47:29 +0000
+Subject: [PATCH] llvmGen: Allow LlvmLits in MetaExprs
+
+---
+ compiler/GHC/Llvm/MetaData.hs | 1 +
+ compiler/GHC/Llvm/Ppr.hs | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/compiler/GHC/Llvm/MetaData.hs b/compiler/GHC/Llvm/MetaData.hs
+index 8f1ba411..5d0a996c 100644
+--- a/compiler/GHC/Llvm/MetaData.hs
++++ b/compiler/GHC/Llvm/MetaData.hs
+@@ -77,6 +77,7 @@ instance Outputable MetaId where
+
+ -- | LLVM metadata expressions
+ data MetaExpr = MetaStr !LMString
++ | MetaLit !LlvmLit
+ | MetaNode !MetaId
+ | MetaVar !LlvmVar
+ | MetaStruct [MetaExpr]
+diff --git a/compiler/GHC/Llvm/Ppr.hs b/compiler/GHC/Llvm/Ppr.hs
+index 787b6efc..bcb73b74 100644
+--- a/compiler/GHC/Llvm/Ppr.hs
++++ b/compiler/GHC/Llvm/Ppr.hs
+@@ -256,6 +256,7 @@ ppMetaExpr :: LlvmCgConfig -> MetaExpr -> SDoc
+ ppMetaExpr opts = \case
+ MetaVar (LMLitVar (LMNullLit _)) -> text "null"
+ MetaStr s -> char '!' <> doubleQuotes (ftext s)
++ MetaLit l -> ppTypeLit opts l
+ MetaNode n -> ppr n
+ MetaVar v -> ppVar opts v
+ MetaStruct es -> char '!' <> braces (ppCommaJoin (map (ppMetaExpr opts) es))
+--
+2.45.2
+
=====================================
p/ghc/debian/patches/0003-llvmGen-Introduce-infrastructure-for-module-flag-metadata.patch
=====================================
@@ -0,0 +1,87 @@
+Origin: https://github.com/ghc/ghc/commit/a6a3874276ced1b037365c059dcd0a758e813a5b
+From a6a3874276ced1b037365c059dcd0a758e813a5b Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben at smart-cactus.org>
+Date: Tue, 22 Aug 2023 13:26:46 -0400
+Subject: [PATCH] llvmGen: Introduce infrastructure for module flag metadata
+
+---
+ compiler/GHC/Llvm.hs | 4 ++++
+ compiler/GHC/Llvm/MetaData.hs | 43 +++++++++++++++++++++++++++++++++++
+ 2 files changed, 47 insertions(+)
+
+diff --git a/compiler/GHC/Llvm.hs b/compiler/GHC/Llvm.hs
+index 5226c59db5..c628ad673d 100644
+--- a/compiler/GHC/Llvm.hs
++++ b/compiler/GHC/Llvm.hs
+@@ -42,6 +42,10 @@ module GHC.Llvm (
+
+ -- ** Metadata types
+ MetaExpr(..), MetaAnnot(..), MetaDecl(..), MetaId(..),
++ -- *** Module flags
++ ModuleFlagBehavior(..),
++ ModuleFlag(..),
++ moduleFlagToMetaExpr,
+
+ -- ** Operations on the type system.
+ isGlobal, getLitType, getVarType,
+diff --git a/compiler/GHC/Llvm/MetaData.hs b/compiler/GHC/Llvm/MetaData.hs
+index bf8b2a3185..78454c3c0f 100644
+--- a/compiler/GHC/Llvm/MetaData.hs
++++ b/compiler/GHC/Llvm/MetaData.hs
+@@ -6,6 +6,10 @@ module GHC.Llvm.MetaData
+ , MetaExpr(..)
+ , MetaAnnot(..)
+ , MetaDecl(..)
++ -- * Module flags
++ , ModuleFlagBehavior(..)
++ , ModuleFlag(..)
++ , moduleFlagToMetaExpr
+ ) where
+
+ import GHC.Prelude
+@@ -98,3 +102,42 @@ data MetaDecl
+ -- | Metadata node declaration.
+ -- ('!0 = metadata !{ \<metadata expression> }' form).
+ | MetaUnnamed !MetaId !MetaExpr
++
++----------------------------------------------------------------
++-- Module flags
++----------------------------------------------------------------
++data ModuleFlagBehavior
++ = MFBError
++ | MFBWarning
++ | MFBRequire
++ | MFBOverride
++ | MFBAppend
++ | MFBAppendUnique
++ | MFBMax
++ | MFBMin
++
++moduleFlagBehaviorToMetaExpr :: ModuleFlagBehavior -> MetaExpr
++moduleFlagBehaviorToMetaExpr mfb =
++ MetaLit $ LMIntLit n i32
++ where
++ n = case mfb of
++ MFBError -> 1
++ MFBWarning -> 2
++ MFBRequire -> 3
++ MFBOverride -> 4
++ MFBAppend -> 5
++ MFBAppendUnique -> 6
++ MFBMax -> 7
++ MFBMin -> 8
++
++data ModuleFlag = ModuleFlag { mfBehavior :: ModuleFlagBehavior
++ , mfName :: LMString
++ , mfValue :: MetaExpr
++ }
++
++moduleFlagToMetaExpr :: ModuleFlag -> MetaExpr
++moduleFlagToMetaExpr flag = MetaStruct
++ [ moduleFlagBehaviorToMetaExpr (mfBehavior flag)
++ , MetaStr (mfName flag)
++ , mfValue flag
++ ]
+--
+2.25.1
+
=====================================
p/ghc/debian/patches/0004-llvmGen-Pass-mcmodel-medium-option-to-LLVM-backend-on-LoongArch.patch
=====================================
@@ -0,0 +1,96 @@
+From e70d41406b5d5638b42c4d8222cd03e76bbfeb86 Mon Sep 17 00:00:00 2001
+From: Xin Wang <wangxin03 at loongson.cn>
+Date: Mon, 13 Dec 2024 10:45:20 +0800
+Subject: [PATCH] llvmGen: Pass mcmodel medium option to LLVM backend on LoongArch
+
+---
+ compiler/GHC/CmmToLlvm.hs | 36 ++++++++++++++++++++++++++++++++++-
+ compiler/GHC/Llvm/MetaData.hs | 1 -
+ configure.ac | 2 +-
+ 3 files changed, 36 insertions(+), 3 deletions(-)
+
+diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs
+index ea58844..04a542c 100644
+--- a/compiler/GHC/CmmToLlvm.hs
++++ b/compiler/GHC/CmmToLlvm.hs
+@@ -190,7 +190,7 @@ cmmLlvmGen _ = return ()
+
+ cmmMetaLlvmPrelude :: LlvmM ()
+ cmmMetaLlvmPrelude = do
+- metas <- flip mapM stgTBAA $ \(uniq, name, parent) -> do
++ tbaa_metas <- flip mapM stgTBAA $ \(uniq, name, parent) -> do
+ -- Generate / lookup meta data IDs
+ tbaaId <- getMetaUniqueId
+ setUniqMeta uniq tbaaId
+@@ -203,9 +203,43 @@ cmmMetaLlvmPrelude = do
+ -- just a name on its own. Previously `null` was accepted as the
+ -- name.
+ Nothing -> [ MetaStr name ]
++
++ platform <- getPlatform
++ cfg <- getConfig
++ let code_model_metas =
++ case platformArch platform of
++ -- FIXME: We should not rely on LLVM
++ ArchLoongArch64 -> [mkCodeModelMeta CMMedium]
++ _ -> []
++ module_flags_metas <- mkModuleFlagsMeta code_model_metas
++ let metas = tbaa_metas ++ module_flags_metas
+ cfg <- getConfig
+ renderLlvm $ ppLlvmMetas cfg metas
+
++mkNamedMeta :: LMString -> [MetaExpr] -> LlvmM [MetaDecl]
++mkNamedMeta name exprs = do
++ (ids, decls) <- unzip <$> mapM f exprs
++ return $ decls ++ [MetaNamed name ids]
++ where
++ f expr = do
++ i <- getMetaUniqueId
++ return (i, MetaUnnamed i expr)
++
++mkModuleFlagsMeta :: [ModuleFlag] -> LlvmM [MetaDecl]
++mkModuleFlagsMeta =
++ mkNamedMeta "llvm.module.flags" . map moduleFlagToMetaExpr
++
++-- LLVM's @LLVM::CodeModel::Model@ enumeration
++data CodeModel = CMMedium
++
++-- Pass -mcmodel=medium option to LLVM on LoongArch64
++mkCodeModelMeta :: CodeModel -> ModuleFlag
++mkCodeModelMeta codemodel =
++ ModuleFlag MFBError "Code Model" (MetaLit $ LMIntLit n i32)
++ where
++ n = case codemodel of CMMedium -> 3 -- as of LLVM 8
++
++
+ -- -----------------------------------------------------------------------------
+ -- | Marks variables as used where necessary
+ --
+diff --git a/compiler/GHC/Llvm/MetaData.hs b/compiler/GHC/Llvm/MetaData.hs
+index 2b28be4..5d0a996 100644
+--- a/compiler/GHC/Llvm/MetaData.hs
++++ b/compiler/GHC/Llvm/MetaData.hs
+@@ -2,7 +2,6 @@
+
+ module GHC.Llvm.MetaData
+ ( MetaId(..)
+- , ppMetaId
+ , MetaExpr(..)
+ , MetaAnnot(..)
+ , MetaDecl(..)
+diff --git a/configure.ac b/configure.ac
+index 02a1eee..0665af5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -555,7 +555,7 @@ AC_SUBST(InstallNameToolCmd)
+ # tools we are looking for. In the past, GHC supported a number of
+ # versions of LLVM simultaneously, but that stopped working around
+ # 3.5/3.6 release of LLVM.
+-LlvmMinVersion=11 # inclusive
++LlvmMinVersion=13 # inclusive
+ LlvmMaxVersion=19 # not inclusive
+ AC_SUBST([LlvmMinVersion])
+ AC_SUBST([LlvmMaxVersion])
+--
+2.25.1
+
=====================================
p/ghc/debian/patches/7e2d3eb507da184cf3337d36715fd82a81643d91.patch deleted
=====================================
@@ -1,108 +0,0 @@
-From 7e2d3eb507da184cf3337d36715fd82a81643d91 Mon Sep 17 00:00:00 2001
-From: lrzlin <lrzlin at 163.com>
-Date: Fri, 13 Jan 2023 00:56:37 +0800
-Subject: [PATCH] Enable tables next to code for LoongArch64
-
----
- compiler/GHC/CmmToLlvm/Mangler.hs | 25 ++++++++++++++++++++++++-
- compiler/ghc.cabal.in | 2 +-
- libraries/ghci/GHCi/InfoTable.hsc | 9 +++++++++
- m4/ghc_tables_next_to_code.m4 | 2 +-
- 4 files changed, 35 insertions(+), 3 deletions(-)
-
-diff --git a/compiler/GHC/CmmToLlvm/Mangler.hs b/compiler/GHC/CmmToLlvm/Mangler.hs
-index 749cedef2dd4..62625195b579 100644
---- a/compiler/GHC/CmmToLlvm/Mangler.hs
-+++ b/compiler/GHC/CmmToLlvm/Mangler.hs
-@@ -38,7 +38,7 @@ llvmFixupAsm platform f1 f2 = {-# SCC "llvm_mangler" #-}
-
- -- | These are the rewrites that the mangler will perform
- rewrites :: [Rewrite]
--rewrites = [rewriteSymType, rewriteAVX, rewriteCall]
-+rewrites = [rewriteSymType, rewriteAVX, rewriteCall, rewriteJump]
-
- type Rewrite = Platform -> B.ByteString -> Maybe B.ByteString
-
-@@ -123,6 +123,29 @@ rewriteCall platform l
- removePlt = replaceOnce (B.pack "@plt") (B.pack "")
- appendInsn i = (`B.append` B.pack ("\n\t" ++ i))
-
-+-- | This rewrites bl and b jump inst to avoid creating PLT entries for
-+-- functions on loongarch64, because there is no separate call instruction
-+-- for function calls in loongarch64. Also, this replacement will load
-+-- the function address from the GOT, which is resolved to point to the
-+-- real address of the function.
-+rewriteJump :: Rewrite
-+rewriteJump platform l
-+ | not isLoongArch64 = Nothing
-+ | isBL l = Just $ replaceJump "bl" "$ra" "$ra" l
-+ | isB l = Just $ replaceJump "b" "$zero" "$t0" l
-+ | otherwise = Nothing
-+ where
-+ isLoongArch64 = platformArch platform == ArchLoongArch64
-+ isBL = B.isPrefixOf (B.pack "bl\t")
-+ isB = B.isPrefixOf (B.pack "b\t")
-+
-+ replaceJump jump rd rj l =
-+ appendInsn ("jirl" ++ "\t" ++ rd ++ ", " ++ rj ++ ", 0") $ removeBracket $
-+ replaceOnce (B.pack (jump ++ "\t%plt(")) (B.pack ("la\t" ++ rj ++ ", ")) l
-+ where
-+ removeBracket = replaceOnce (B.pack ")") (B.pack "")
-+ appendInsn i = (`B.append` B.pack ("\n\t" ++ i))
-+
- -- | @replaceOnce match replace bs@ replaces the first occurrence of the
- -- substring @match@ in @bs@ with @replace at .
- replaceOnce :: B.ByteString -> B.ByteString -> B.ByteString -> B.ByteString
-diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
-index 98cc71dde2d8..cb3d82e5910f 100644
---- a/compiler/ghc.cabal.in
-+++ b/compiler/ghc.cabal.in
-@@ -557,6 +557,7 @@ Library
- GHC.Platform.ARM
- GHC.Platform.AArch64
- GHC.Platform.Constants
-+ GHC.Platform.LoongArch64
- GHC.Platform.NoRegs
- GHC.Platform.PPC
- GHC.Platform.Profile
-@@ -564,7 +565,6 @@ Library
- GHC.Platform.Reg.Class
- GHC.Platform.Regs
- GHC.Platform.RISCV64
-- GHC.Platform.LoongArch64
- GHC.Platform.S390X
- GHC.Platform.Wasm32
- GHC.Platform.Ways
-diff --git a/libraries/ghci/GHCi/InfoTable.hsc b/libraries/ghci/GHCi/InfoTable.hsc
-index ce5aee21fbc1..5ac08f693c80 100644
---- a/libraries/ghci/GHCi/InfoTable.hsc
-+++ b/libraries/ghci/GHCi/InfoTable.hsc
-@@ -228,6 +228,15 @@ mkJumpToAddr a = case hostPlatformArch of
- , fromIntegral w64
- , fromIntegral (w64 `shiftR` 32) ]
-
-+ ArchLoongArch64 -> pure $
-+ let w64 = fromIntegral (funPtrToInt a) :: Word64
-+ in Right [ 0x1c00000c -- pcaddu12i $t0,0
-+ , 0x28c0418c -- ld.d $t0,$t0,16
-+ , 0x4c000180 -- jr $t0
-+ , 0x03400000 -- nop
-+ , fromIntegral w64
-+ , fromIntegral (w64 `shiftR` 32) ]
-+
- arch ->
- -- The arch isn't supported. You either need to add your architecture as a
- -- distinct case, or use non-TABLES_NEXT_TO_CODE mode.
-diff --git a/m4/ghc_tables_next_to_code.m4 b/m4/ghc_tables_next_to_code.m4
-index 8acf250c4474..3e0ced2137df 100644
---- a/m4/ghc_tables_next_to_code.m4
-+++ b/m4/ghc_tables_next_to_code.m4
-@@ -17,7 +17,7 @@ AC_DEFUN([GHC_TABLES_NEXT_TO_CODE],
- case "$Unregisterised" in
- NO)
- case "$TargetArch" in
-- ia64|powerpc64|powerpc64le|s390x|wasm32|loongarch64)
-+ ia64|powerpc64|powerpc64le|s390x|wasm32)
- TablesNextToCodeDefault=NO
- AC_MSG_RESULT([no])
- ;;
=====================================
p/ghc/debian/patches/series
=====================================
@@ -27,5 +27,8 @@ llvm-new-pass-manager
llvm-newer-version
hadrian-plans
pr-13096
-7e2d3eb507da184cf3337d36715fd82a81643d91.patch
alpha-fix-ieee_set_fp_control-invocation.patch
+0001-llvmGen-Add-export-list-to-GHC.Llvm.MetaData.patch
+0002-llvmGen-Allow-LlvmLits-in-MetaExprs.patch
+0003-llvmGen-Introduce-infrastructure-for-module-flag-metadata.patch
+0004-llvmGen-Pass-mcmodel-medium-option-to-LLVM-backend-on-LoongArch.patch
=====================================
p/ghc/debian/rules
=====================================
@@ -110,7 +110,9 @@ ifneq (,$(filter noopt, $(DEB_BUILD_OPTIONS)))
endif
ifneq (,$(filter loong64, $(DEB_HOST_ARCH)))
- EXTRA_HADRIAN_FLAGS += "*.*.ghc.*.opts += -optc-mcmodel=medium"
+ EXTRA_HADRIAN_FLAGS += "*.*.ghc.c.opts += -optc-mcmodel=medium"
+ EXTRA_HADRIAN_FLAGS += "*.*.ghc.hs.opts += -optc-mcmodel=medium"
+ EXTRA_HADRIAN_FLAGS += "*.*.cc.c.opts += -optc-mcmodel=medium"
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
View it on GitLab: https://salsa.debian.org/haskell-team/DHG_packages/-/compare/35c4b57be410d542c255ed2d91a5146447c8212a...2bd30daf49af53334b43c4b79682eef80ae53eb4
--
View it on GitLab: https://salsa.debian.org/haskell-team/DHG_packages/-/compare/35c4b57be410d542c255ed2d91a5146447c8212a...2bd30daf49af53334b43c4b79682eef80ae53eb4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-haskell-commits/attachments/20250214/36624266/attachment-0001.htm>
More information about the Pkg-haskell-commits
mailing list