Skip to content

Commit

Permalink
ghc-prim integration with new virtual_modules (#4)
Browse files Browse the repository at this point in the history
based on MercuryTechnologies/buck2-prelude#47

* retry ghc-prim build.
now -this-unit-id ghc-prim with use_same_package_name=True.
a little bit more progress.
* Success in building ghc-prim and ghc-bignum, ghc-internal depending on that in-tree lib!
by virtual_modules = ["GHC.Prim"]
* remove hard-coded paths (unnecessary)
* remove irrelevant comment now
  • Loading branch information
wavewave authored Sep 27, 2024
1 parent 101c093 commit c7485e6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
70 changes: 43 additions & 27 deletions ghc-build/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,49 @@ cp $(location :primop-vector-tycons.hs-incl) ../out/primop_headers
)

genrule(
name = "GHC.Prim.hs",
name = "GHC/Prim.hs",
srcs = [":primops.txt"],
out = "GHC.Prim.hs",
cmd = "$(location :genprimopcode) --make-haskell-source < $(location :primops.txt) > ../out/GHC.Prim.hs",
out = "GHC/Prim.hs",
cmd = "$(location :genprimopcode) --make-haskell-source < $(location :primops.txt) > ../out/GHC/Prim.hs",
)

# NOTE: GHC.Prim and GHC.Types are mutually recursive. It seesm like a bug.
# Until we figure out how, we rely on external ghc-prim.
#haskell_library(
# name = "ghc-prim",
# srcs = [
# ":GHC.Prim.hs",
# "ghc/libraries/ghc-prim/GHC/Classes.hs",
# "ghc/libraries/ghc-prim/GHC/CString.hs",
# "ghc/libraries/ghc-prim/GHC/Magic.hs",
# "ghc/libraries/ghc-prim/GHC/Magic/Dict.hs",
# "ghc/libraries/ghc-prim/GHC/Prim/Ext.hs",
# "ghc/libraries/ghc-prim/GHC/Prim/PtrEq.hs",
# "ghc/libraries/ghc-prim/GHC/Tuple.hs",
# "ghc/libraries/ghc-prim/GHC/Types.hs",
# ],
# compiler_flags = default_ghc_flags,
# visibility = ["PUBLIC"],
# deps = [
# "//haskell:base",
# ],
#)
haskell_library(
name = "ghc-prim",
use_same_package_name = True,
srcs = [
"ghc/libraries/ghc-prim/GHC/Classes.hs",
"ghc/libraries/ghc-prim/GHC/CString.hs",
"ghc/libraries/ghc-prim/GHC/Debug.hs",
"ghc/libraries/ghc-prim/GHC/Magic.hs",
"ghc/libraries/ghc-prim/GHC/Magic/Dict.hs",
"ghc/libraries/ghc-prim/GHC/Prim/Exception.hs",
"ghc/libraries/ghc-prim/GHC/Prim/Ext.hs",
"ghc/libraries/ghc-prim/GHC/Prim/PtrEq.hs",
"ghc/libraries/ghc-prim/GHC/Tuple.hs",
"ghc/libraries/ghc-prim/GHC/Types.hs",
],
virtual_modules = ["GHC.Prim"],
compiler_flags = [
"-XHaskell2010",
"-XBangPatterns",
"-XCPP",
"-XDeriveGeneric",
"-XMagicHash",
"-XMultiParamTypeClasses",
"-XNoImplicitPrelude",
"-XStandaloneDeriving",
#"-XTrustworthy",
"-XTypeFamilies",
"-XUnboxedTuples",
"-XUnliftedFFITypes",
"-Wno-trustworthy-safe",
"-this-unit-id",
"ghc-prim",
],
visibility = ["PUBLIC"],
deps = [
],
)

haskell_library(
name = "ghc-bignum",
Expand Down Expand Up @@ -202,7 +218,7 @@ haskell_library(
],
visibility = ["PUBLIC"],
deps = [
"//haskell:ghc-prim",
":ghc-prim",
],
)

Expand Down Expand Up @@ -448,8 +464,8 @@ haskell_library(
#default_ghc_flags
visibility = ["PUBLIC"],
deps = [
"//haskell:ghc-prim",
"//ghc-build:ghc-bignum",
":ghc-prim",
":ghc-bignum",
],
)

Expand Down
2 changes: 1 addition & 1 deletion prelude

0 comments on commit c7485e6

Please sign in to comment.