#1 Backport ghc riscv64 fixes to ghc9.6 branch
Merged 4 months ago by petersen. Opened 4 months ago by rjones.
rpms/ rjones/ghc9.6 riscv64-backports  into  rawhide

@@ -0,0 +1,43 @@ 

+ diff --git a/libraries/Cabal/Cabal-syntax/src/Distribution/System.hs b/libraries/Cabal/Cabal-syntax/src/Distribution/System.hs

+ index 68bda63..6521464 100644

+ --- a/libraries/Cabal/Cabal-syntax/src/Distribution/System.hs

+ +++ b/libraries/Cabal/Cabal-syntax/src/Distribution/System.hs

+ @@ -159,7 +159,7 @@ buildOS = classifyOS Permissive System.Info.os

+  

+  -- | These are the known Arches: I386, X86_64, PPC, PPC64, Sparc,

+  -- Arm, AArch64, Mips, SH, IA64, S390, S390X, Alpha, Hppa, Rs6000,

+ --- M68k, Vax, JavaScript and Wasm32.

+ +-- M68k, Vax, RISCV64, JavaScript and Wasm32.

+  --

+  -- The following aliases can also be used:

+  --    * PPC alias: powerpc

+ @@ -173,7 +173,7 @@ data Arch = I386  | X86_64  | PPC  | PPC64 | Sparc

+            | Arm   | AArch64 | Mips | SH

+            | IA64  | S390    | S390X

+            | Alpha | Hppa    | Rs6000

+ -          | M68k  | Vax

+ +          | M68k  | Vax | RISCV64

+            | JavaScript

+            | Wasm32

+            | OtherArch String

+ @@ -188,7 +188,7 @@ knownArches = [I386, X86_64, PPC, PPC64, Sparc

+                ,Arm, AArch64, Mips, SH

+                ,IA64, S390, S390X

+                ,Alpha, Hppa, Rs6000

+ -              ,M68k, Vax

+ +              ,M68k, Vax, RISCV64

+                ,JavaScript

+                ,Wasm32]

+  

+ diff --git a/libraries/Cabal/Cabal/src/Distribution/Simple/PreProcess.hs b/libraries/Cabal/Cabal/src/Distribution/Simple/PreProcess.hs

+ index fbe5710..a53b33d 100644

+ --- a/libraries/Cabal/Cabal/src/Distribution/Simple/PreProcess.hs

+ +++ b/libraries/Cabal/Cabal/src/Distribution/Simple/PreProcess.hs

+ @@ -729,6 +729,7 @@ platformDefines lbi =

+        Rs6000      -> ["rs6000"]

+        M68k        -> ["m68k"]

+        Vax         -> ["vax"]

+ +      RISCV64     -> ["riscv64"]

+        JavaScript  -> ["javascript"]

+        Wasm32      -> ["wasm32"]

+        OtherArch _ -> []

@@ -0,0 +1,26 @@ 

+ From dd38aca95ac25adc9888083669b32ff551151259 Mon Sep 17 00:00:00 2001

+ From: Andreas Schwab <schwab@suse.de>

+ Date: Mon, 19 Jun 2023 10:38:26 +0200

+ Subject: [PATCH] Hadrian: enable GHCi support on riscv64

+ 

+ ---

+  hadrian/src/Oracles/Setting.hs | 3 ++-

+  1 file changed, 2 insertions(+), 1 deletion(-)

+ 

+ diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs

+ index b9e5d312074..93561a94fe4 100644

+ --- a/hadrian/src/Oracles/Setting.hs

+ +++ b/hadrian/src/Oracles/Setting.hs

+ @@ -302,7 +302,8 @@ ghcWithInterpreter = do

+                            , "darwin", "kfreebsdgnu" ]

+      goodArch <- anyTargetArch [ "i386", "x86_64", "powerpc"

+                                , "arm", "aarch64", "s390x"

+ -                              , "powerpc64", "powerpc64le" ]

+ +                              , "powerpc64", "powerpc64le"

+ +                              , "riscv64" ]

+      return $ goodOs && goodArch

+  

+  -- | Variants of the ARM architecture.

+ -- 

+ GitLab

+ 

@@ -0,0 +1,11 @@ 

+ --- a/compiler/GHC/HsToCore/Foreign/C.hs

+ +++ b/compiler/GHC/HsToCore/Foreign/C.hs

+ @@ -560,7 +560,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc

+       ,   ppUnless res_hty_is_unit $

+           if libffi

+                    then char '*' <> parens (ffi_cResType <> char '*') <>

+ -                       text "resp = cret;"

+ +                       text "resp = " <> parens ffi_cResType <> text "cret;"

+                    else text "return cret;"

+       , rbrace

+       ]

file modified
+30 -4
@@ -46,8 +46,8 @@ 

  %else

  %global llvm_major 14

  %endif

- %global ghc_llvm_archs armv7hl s390x

- %global ghc_unregisterized_arches s390 %{mips} riscv64

+ %global ghc_llvm_archs armv7hl s390x riscv64

+ %global ghc_unregisterized_arches s390 %{mips}

  

  Name: %{ghc_name}

  Version: 9.6.4
@@ -55,7 +55,7 @@ 

  # - release can only be reset if *all* library versions get bumped simultaneously

  #   (sometimes after a major release)

  # - minor release numbers for a branch should be incremented monotonically

- Release: 16%{?dist}

+ Release: 17%{?dist}

  Summary: Glasgow Haskell Compiler

  

  License: BSD-3-Clause AND HaskellReport
@@ -104,6 +104,18 @@ 

  

  Patch30: https://src.opensuse.org/rpm/ghc/raw/branch/factory/sphinx7.patch

  

+ # RISCV64 added to Cabal

+ # See: https://github.com/haskell/cabal/pull/9062

+ Patch40: cabal-add-riscv64.patch

+ 

+ # Enable GHCi support on riscv64

+ # Upstream in >= 9.9.

+ Patch41: https://gitlab.haskell.org/ghc/ghc/-/commit/dd38aca95ac25adc9888083669b32ff551151259.patch

+ 

+ # https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/SKVM4NSFZRWUT5MJKBS6IRUXCG3SCD34/

+ # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12079

+ Patch42: ghc-modern-c-fix.patch

+ 

  # https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms

  

  # fedora ghc has been bootstrapped on
@@ -403,7 +415,7 @@ 

  %patch -P13 -p1 -b .orig

  %endif

  

- %ifarch %{ghc_unregisterized_arches}

+ %ifarch %{ghc_unregisterized_arches} riscv64

  %patch -P16 -p1 -b .orig

  %endif

  # remove if epel9 ghc using llvm
@@ -423,6 +435,15 @@ 

  %patch -P30 -p1 -b .orig

  %endif

  

+ %ifarch riscv64

+ #RISCV64 cabal support

+ %patch -P40 -p1 -b .orig

+ #GHCi support

+ %patch -P41 -p1 -b .orig

+ %endif

+ 

+ #Modern C fix

+ %patch -P42 -p1 -b .orig

  

  %build

  # patch5 and patch12
@@ -434,7 +455,9 @@ 

  # /usr/bin/debugedit: Cannot handle 8-byte build ID

  # https://bugzilla.redhat.com/show_bug.cgi?id=2116508

  # https://gitlab.haskell.org/ghc/ghc/-/issues/22195

+ %ifnarch riscv64

  export LD=%{_bindir}/ld.gold

+ %endif

  

  export GHC=%{_bindir}/ghc%{?ghcboot_major:-%{ghcboot_major}}

  
@@ -829,6 +852,9 @@ 

  

  

  %changelog

+ * Thu Feb 15 2024 Richard W.M. Jones <rjones@redhat.com> - 9.6.4-17

+ - Fix generated C for Modern C Initiative

+ 

  * Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 9.6.4-16

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

  

Just cherry picks of all the riscv64 and modern C patches to the ghc9.6 branch.

@davidlt @tekkamanninja

The scratch builds on Koji are working, hence remove the "WIP" tag. I have not yet build this on riscv64 as it requires many build dependencies first.

Pull-Request has been merged by petersen

4 months ago

Merged, thank you!

(No sure why CI successful build is marked failure..)