Skip to content
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

Enable cross-compiler development #154

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/riscv64-cross-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: RISC-V 64bit cross-compiler CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Prepare git
run:
git config --global url."git://github.com/ghc/packages-".insteadOf git://github.com/ghc/packages/ &&
git config --global url."http://github.com/ghc/packages-".insteadOf http://github.com/ghc/packages/ &&
git config --global url."https://github.com/ghc/packages-".insteadOf https://github.com/ghc/packages/ &&
git config --global url."ssh://[email protected]/ghc/packages-".insteadOf ssh://[email protected]/ghc/packages/ &&
git config --global url."[email protected]:ghc/packages-".insteadOf [email protected]:ghc/packages/

- name: Checkout GHC
uses: actions/[email protected]
with:
repository: ghc/ghc
submodules: recursive

- name: Checkout ghc.nix
uses: actions/[email protected]
with:
path: ghc.nix

- name: Install nix
uses: cachix/install-nix-action@v20

- name: Use cachix
uses: cachix/cachix-action@v12
with:
name: ghc-nix
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'

- name: Run nix-shell - Boot and Configure
run: nix-shell --pure ghc.nix/shell.nix --arg withLlvm true --arg crossTarget '"riscv64"' --command "./boot && configure_ghc"

- name: Run nix-shell - cabal update
run: nix-shell --pure ghc.nix/shell.nix --arg withLlvm true --arg crossTarget '"riscv64"' --command "pushd hadrian; cabal update; popd"

- name: Run nix-shell - Build GHC
run: nix-shell --pure ghc.nix/shell.nix --arg withLlvm true --arg crossTarget '"riscv64"' --command "hadrian/build -j --flavour=quickest"
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ nix develop github:alpmestan/ghc.nix#js-cross
**Note** for the JavaScript backend, use `bignum=native` or the `native_bignum`
transformer.

## Building a cross-compiler

Cross-compiling in this section means: GHC is developed/built on one
architecture (`--build`) to run on the same architecture (`--host`) and target
another architecture (`--target`).

E.g. develop GHC on *amd64*, run it on *amd64* and let the resulting GHC produce
binaries for *riscv64*.

The `crossTarget` argument defines the target. The string must be a supported
architecture in `nixpkgs.pkgsCross`. When `crossTarget` is defined, all required
environment variables and `configure_ghc` parameters are setup for building a
cross-compiler.

``` sh
nix-shell --pure ghc.nix/shell.nix --arg withLlvm true --arg crossTarget '"riscv64"'
```

## Cachix

There is a Cachix cache ([ghc-nix](https://app.cachix.org/cache/ghc-nix)) which is filled by our CI. To use it, run the following command and follow the instructions:
Expand Down
86 changes: 26 additions & 60 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
};

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
Expand Down
Loading
Loading