-
-
Notifications
You must be signed in to change notification settings - Fork 146
Add MicroHs support. #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dmjio
wants to merge
18
commits into
master
Choose a base branch
from
micro-miso
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add MicroHs support. #864
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
841f4e7
to
5b4fd94
Compare
We'd like to add support for the [MicroHs project](https://github.com/augustss/MicroHs) as a first class citizen, to explore its cross-compilation capabilities (w/ emscripten, and other platforms). This PR fetches MicroHs at master and builds (with ghc910) using the recommended Makefile workflow. We "make install" into /nix/store during the installPhase. 1) The 'microhs' package that places cpphs, mcabal inside of $out/bin, mhs is placed inside of $out/lib/bin. We also copy lib, generated, boards, docs, into $out (aka /nix/store/). 2) 'microhs-wrapper' package. This is a shell script that ensure `mhs` is present on PATH, also ensures the $MSHDIR variable points to the MicroHs /lib that exists in the /nix/store. "export MHSDIR=${self.microhs}" 3) 'microhs-env' shell environment that includes both of the above packages. Using `nix-shell` we can now enter an environment where `mhs` is present on PATH and points to the correct $MHSDIR, along with all the other build tools present (cpphs, mcabal). To test, clone miso and call "nix-shell --argstr pkg micro --run 'mhs --version'" - [x] Build MicroHS into miso's nixpkgs (mcabal,mhs,cpphs) - [x] Create 3 derivations for microhs (microhs,microhs-env,microhs-wrapper) - [x] Introduce micro/ subdirectory with a new 'miso.cabal' that MicroHS supports - [x] Add MicroHs shell environment to shell.nix (command above) - [ ] Use 'mcabal install' to fetch and build all of miso's dependencies (TODO) - [ ] Explore adding support for a JS FFI via emscripten (this might require modifications to mcabal or mhs to support "foreign import javascript" syntax) - [ ] Create install script with nix that uses mcabal to install all deps. and builds miso. Place miso's MicroHS build under CI using both emscripten and native - [ ] Consider upstreaming MicroHs into nixpkgs proper (with pkgsCross support) For JSFFI support (for browser targets) w/ emscripten consider the following docs - https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-javascript-from-c-c
- Add src/ because the RTS gets compiled during compilation. - Clean-up bash
Use this for CI testing (for now, until miso builds).
- Use compiler generated targets from Makefile
We need to ensure we support QuickJS on Darwin/OSX
NixOS/nixpkgs#139943 (comment) We need to ensure that ~/.emscripten_cache is created, populated and EM_CACHE is set.
- Export CC - Put GHC compiled mhs on $PATH - set $MHSDIR
8c59252
to
ffdf202
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We'd like to add support for @augustss's MicroHs project as a first class citizen, to explore its cross-compilation capabilities (w/
emscripten
, and other platforms).This PR fetches
MicroHs
atmaster
and builds using the recommendedMakefile
workflow. Wemake install
into/nix/store
during theinstallPhase
, along with other tools. This PR introduces 3 derivations to facilitate the process of getting a miso MicroHS build into miso's CI.The
microhs
nix package placescpphs
,mhs
andmcabal
inside of$out/bin
. We also copylib
,generated
,src
,boards
,docs
, into$out
(aka/nix/store/
).We now acquire
mcabal
,mhs
andcpphs
through themake
C bootstrapping install, and have a derivation formhs
built w/ GHC (separately).We have created a
targets.conf
file that lives in the/nix/store
thatmhs
now uses to setCC
andCC-FLAGS
correctly.microhs-env
is a shell environment (cd miso/micro && nix-shell
) that includes both of the above packages. Usingnix-shell
we can now enter an environment wheremhs
is present on$PATH
and points to the correct$MHSDIR
, along with all the other build tools present (cpphs
,mcabal
).To test, clone miso and call
nix-shell --argstr pkg micro --run 'mhs --version'
mcabal
,mhs
,cpphs
)microhs
,microhs-env
,microhs-wrapper
)micro/
subdirectory with a newmiso.cabal
that MicroHS supportsshell.nix
(command above), edit: addsnodejs
andemscripten
tooMicroHs
works on Darwin OSXExample.hs
in CI for x86Example.hs
in CI for JS (even w/-temscripten
gcc
is still chosen (andtargets.conf
has both).mcabal install
to fetch and build all of miso's dependencies (WIP)foreign import javascript
&js-sources:
) viaemscripten
(this might require modifications tomhs
andmcabal
).emscripten
and nativepkgsCross
support) -- using the traditional haskell nixpkgs workflowFor JSFFI support (for browser targets) w/
emscripten
research the following