mirror of
https://github.com/tweag/asterius.git
synced 2024-09-11 08:55:32 +03:00
nix-shell working but can't find ahc binaries
This commit is contained in:
parent
b919d41adb
commit
eee84f68ad
@ -115,22 +115,25 @@ bootRTSCmm bootArgs@BootArgs {..} =
|
||||
"-O2",
|
||||
"-DASTERIUS",
|
||||
"-optc=-DASTERIUS",
|
||||
"-I" <> obj_topdir </> "include"
|
||||
"-I" <> obj_topdir </> "include",
|
||||
"-odir " <> asteriusObjectDir
|
||||
]
|
||||
}
|
||||
cmm_files
|
||||
( \obj_path ir@CmmIR {..} ->
|
||||
( \obj_path ir@CmmIR {..} -> do
|
||||
putStrLn obj_path
|
||||
let out_path = asteriusObjectDir </> makeRelative asteriusBootLibsPath obj_path
|
||||
let ms_mod =
|
||||
( GHC.Module GHC.rtsUnitId $ GHC.mkModuleName $
|
||||
takeBaseName
|
||||
obj_path
|
||||
out_path
|
||||
)
|
||||
in runCodeGen (marshalCmmIR ms_mod ir) dflags ms_mod >>= \case
|
||||
runCodeGen (marshalCmmIR ms_mod ir) dflags ms_mod >>= \case
|
||||
Left err -> throwIO err
|
||||
Right m -> do
|
||||
let out_path = bootDir </> makeRelative asteriusBootLibsPath obj_path
|
||||
putStrLn out_path
|
||||
createDirectoryIfMissing True $ takeDirectory out_path
|
||||
putFile obj_path $ toCachedModule m
|
||||
putFile out_path $ toCachedModule m
|
||||
modifyIORef' obj_paths_ref (out_path :)
|
||||
when is_debug $ do
|
||||
let p = (out_path -<.>)
|
||||
|
@ -24,7 +24,8 @@ module Asterius.BuildInfo
|
||||
getBootDir,
|
||||
rootBootDir,
|
||||
asteriusSandboxGhcLibDir,
|
||||
asteriusBootLibsPath
|
||||
asteriusBootLibsPath,
|
||||
asteriusObjectDir
|
||||
)
|
||||
where
|
||||
|
||||
@ -85,8 +86,10 @@ asteriusSandboxGhcLibDir = unsafePerformIO (catch (getEnv "sandbox_ghc_lib_dir")
|
||||
|
||||
-- Allow nix to override the bootLibsPath (from ghc toolkit)
|
||||
asteriusBootLibsPath :: FilePath
|
||||
asteriusBootLibsPath = unsafePerformIO (catch ((</> "libraries") <$> getEnv "boot_libs_path")
|
||||
(\(_ :: IOException) -> pure bootLibsPath))
|
||||
asteriusBootLibsPath = unsafePerformIO ((</> "libraries") <$> getEnv "boot_libs_path")
|
||||
|
||||
asteriusObjectDir :: FilePath
|
||||
asteriusObjectDir = unsafePerformIO (getEnv "boot_obj_path")
|
||||
|
||||
setupGhcPrim :: FilePath
|
||||
setupGhcPrim = binDir </> "Setup-ghc-prim" <.> exeExtension
|
||||
|
39
default.nix
39
default.nix
@ -213,14 +213,24 @@ let
|
||||
cp -r ${ghc-patched-src} $out
|
||||
chmod +w -R $out
|
||||
cd $out/libraries
|
||||
# cp -r ${./ghc-toolkit/boot-libs}/* $out/libraries
|
||||
# chmod +w -R $out
|
||||
patch -p2 < ${patch}
|
||||
# TODO find a better way to get these
|
||||
cp ${ghc-prim}/GHC/Prim.hs ghc-prim/GHC/Prim.hs
|
||||
cp ${ghc-prim}/GHC/PrimopWrappers.hs ghc-prim/GHC/PrimopWrappers.hs
|
||||
# This all compiles now although I'm not 100% that it is correct yet
|
||||
mkdir $out/libraries/asterius-prelude
|
||||
cp -r ${./ghc-toolkit/boot-libs}/asterius-prelude/* $out/libraries/asterius-prelude
|
||||
cp -r ${./ghc-toolkit/boot-libs}/base/* $out/libraries/base
|
||||
cp -r ${./ghc-toolkit/boot-libs}/ghc-boot/* $out/libraries/ghc-boot
|
||||
cp -r ${./ghc-toolkit/boot-libs}/ghc-boot-th/* $out/libraries/ghc-boot-th
|
||||
cp -r ${./ghc-toolkit/boot-libs}/ghc-heap/* $out/libraries/ghc-heap
|
||||
cp -r ${./ghc-toolkit/boot-libs}/ghc-prim/* $out/libraries/ghc-prim
|
||||
cp -r ${./ghc-toolkit/boot-libs}/ghci/* $out/libraries/ghci
|
||||
cp -r ${./ghc-toolkit/boot-libs}/integer-simple/* $out/libraries/integer-simple
|
||||
cp -r ${./ghc-toolkit/boot-libs}/rts/* $out/libraries/rts
|
||||
cp -r ${./ghc-toolkit/boot-libs}/template-haskell/* $out/libraries/template-haskell
|
||||
cp -r ${./ghc-toolkit/boot-libs}/text/* $out/libraries/text
|
||||
# TODO figure out a better way remove the unwanted stuff from ghc-prim.cabal
|
||||
sed -i '96,$ d' ghc-prim/ghc-prim.cabal
|
||||
ls -l $out/libraries/rts
|
||||
chmod +w $out/libraries/rts/rts.conf
|
||||
cd $out/libraries/rts
|
||||
cp -r ${./ghc-toolkit/boot-libs}/rts/rts.conf $out/libraries/rts/rts.conf
|
||||
runghc --ghc-arg=-I$(ghc --print-libdir)/include $out/utils/genapply/Main.hs > AutoApply.cmm
|
||||
@ -229,10 +239,21 @@ let
|
||||
|
||||
asterius-boot = pkgs.runCommand "asterius-boot" {
|
||||
preferLocalBuild = true;
|
||||
nativeBuildInputs = [ pkgs.makeWrapper pkgs.haskell-nix.compiler.${compilerName} pkgs.autoconf pkgs.automake ];
|
||||
# nativeBuildInputs = [ pkgs.makeWrapper pkgs.haskell-nix.compiler.${compilerName} pkgs.autoconf pkgs.automake ];
|
||||
nativeBuildInputs = [
|
||||
pkgs.makeWrapper
|
||||
pkgs.haskell-nix.compiler.${compilerName}
|
||||
pkgs.autoconf
|
||||
pkgs.automake
|
||||
(pkgs.haskell-nix.tool "cabal" {
|
||||
version = "3.2.0.0";
|
||||
ghc = pkgs.haskell-nix.compiler.${compilerName};
|
||||
})
|
||||
];
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/boot
|
||||
mkdir -p $out/obj
|
||||
mkdir -p $out/ghc-libdir
|
||||
cp -r $(ghc --print-libdir)/include $out/ghc-libdir
|
||||
cp $(ghc --print-libdir)/llvm-passes $out/ghc-libdir
|
||||
@ -248,8 +269,11 @@ let
|
||||
--set asterius_bindir $out/bin \
|
||||
--set asterius_bootdir $out/boot \
|
||||
--set boot_libs_path ${ghc883.boot-libs} \
|
||||
--set boot_obj_path $out/obj \
|
||||
--set sandbox_ghc_lib_dir $out/ghc-libdir
|
||||
'') (pkgs.lib.attrNames project.hsPkgs.asterius.components.exes)}
|
||||
export PATH=$PATH:$out/bin
|
||||
export HOME=$TMP
|
||||
$out/bin/ahc-boot
|
||||
'';
|
||||
wasm-asterius-ghc = (pkgs.runCommand "wasm-asterius-ghc" {
|
||||
@ -292,7 +316,8 @@ let
|
||||
nodejs
|
||||
nodePkgs.parcel-bundler
|
||||
nodePkgs.todomvc-app-css
|
||||
nodePkgs.todomvc-common ];
|
||||
nodePkgs.todomvc-common
|
||||
];
|
||||
}).overrideAttrs (oldAttrs: {
|
||||
shellHook = (oldAttrs.shellHook or "") + ''
|
||||
${ pkgs.lib.optionalString (cached != null) ''
|
||||
|
Loading…
Reference in New Issue
Block a user