All Projects → grin-compiler → ghc-whole-program-compiler-project

grin-compiler / ghc-whole-program-compiler-project

Licence: other
GHC Whole Program Compiler and External STG IR tooling

Programming Languages

haskell
3896 projects
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ghc-whole-program-compiler-project

Haskell Ide Engine
The engine for haskell ide-integration. Not an IDE
Stars: ✭ 2,433 (+2633.71%)
Mutual labels:  ghc
ghc-stack
Hacking GHC's Stack for Fun and Profit (featuring The Glorious Haskell Debugger v0.0.1 Pre-alpha)
Stars: ✭ 69 (-22.47%)
Mutual labels:  ghc
ghcide-nix
Nix installation for ghcide
Stars: ✭ 76 (-14.61%)
Mutual labels:  ghc
Ghcup
DEPRECATED IN FAVOR OF haskell/ghcup-hs
Stars: ✭ 249 (+179.78%)
Mutual labels:  ghc
haskell-hot-swap
Hot swapping compiled code while keeping a websocket connection open
Stars: ✭ 24 (-73.03%)
Mutual labels:  ghc
stupid-computer
A understandable Haskell tracer.
Stars: ✭ 13 (-85.39%)
Mutual labels:  ghc
Vscode Ghc Simple
Simple GHC (Haskell) integration for VSCode
Stars: ✭ 214 (+140.45%)
Mutual labels:  ghc
cdetect
🔬 Detect which compiler and compiler version a Linux executable (in the ELF format) was compiled with
Stars: ✭ 23 (-74.16%)
Mutual labels:  ghc
stm
Software Transactional Memory
Stars: ✭ 74 (-16.85%)
Mutual labels:  ghc
what-it-do
Automatically trace all (showable) binds in do expressions
Stars: ✭ 81 (-8.99%)
Mutual labels:  ghc
vabal
cabal in Valle
Stars: ✭ 43 (-51.69%)
Mutual labels:  ghc
zsh-haskell
ghc and cabal completion for zsh shell
Stars: ✭ 18 (-79.78%)
Mutual labels:  ghc
the-thoralf-plugin
This a type-checker plugin to rule all type checker plugins involving type-equality reasoning using smt solvers.
Stars: ✭ 22 (-75.28%)
Mutual labels:  ghc
Haskell Symbol Search Cheatsheet
Haskell/GHC symbol search cheatsheet
Stars: ✭ 243 (+173.03%)
Mutual labels:  ghc
ghci-hexcalc
Haskell/GHCi as a Hex-Calculator interactive
Stars: ✭ 24 (-73.03%)
Mutual labels:  ghc
Haskell Ghc Illustrated
haskell ghc-illustrated
Stars: ✭ 218 (+144.94%)
Mutual labels:  ghc
Pi-Pool
Cardano Stakepool on Raspberry Pi
Stars: ✭ 204 (+129.21%)
Mutual labels:  ghc
haskell-code-spot
Visual tool to spot odd runtime behaviour of Haskell programs.
Stars: ✭ 106 (+19.1%)
Mutual labels:  ghc
htoml
TOML file format parser in Haskell
Stars: ✭ 39 (-56.18%)
Mutual labels:  ghc
ghc-alt-libc
GHC compiled against musl & uClibc
Stars: ✭ 41 (-53.93%)
Mutual labels:  ghc

GHC whole program compiler project

The project consists of GHC-WPC and the corresponding External STG IR and tooling.

GHC-WPC is an extended GHC that exports the STG IR (.modpak) for the compiled modules and linker metadata (.ghc_stgapp) at application link time.

The external-stg-compiler package should be compiled with GHC-WPC but the other packages i.e. external-stg compiles with vanilla GHC also.

Presentation video

Readings

External STG tools (Ext-STG)

  • gen-exe main compiler driver, it produces executable from .ghc_stgapp files.
  • gen-obj compiles STG IR files .o_stgbin to object code .o. (gen-exe calls it)
  • ext-stg CLI tool for external STG IR, it can pretty print .o_stgbin files.

Sample applications for GHC-WPC

There is a set of prepared applications in the ghc-wpc-sample-programs repository that you can compile easily to try out GHC-WPC.

Why?

  • to make it easy to develop new backends for GHC without extending Cabal with new targets
  • to facilitate compiler/PL research that needs real world programs to analyse
  • to allow whole program analysis (new insights might be adopted to incremental compilers)
  • to escape from GHC codebase to the mainstream Haskell UX/DX that allows to use any library
  • to allow program observation with arbitrary precision
  • to make it easy to focus on the compiler backend development without hacking GHC
  • to allow other compilers to target GHC/STG and the feature rich RTS

Usage

You'll need 13GB of free space (Sorry)

If you change the External STG IR, then GHC-WPC must be recompiled.

  1. Install (exact version):

    • GHC 8.8.3
    • happy 1.19.12
    • alex 3.2.5
  2. Clone this repository.

    git clone --recursive [email protected]:grin-compiler/ghc-whole-program-compiler-project.git
    

    If you did non-recursive cloning (when the ghc-wpc folder is empty) then you'll need to init submodules

    git submodule update --init --recursive
    
  3. Install modpak tooling

    (cd mod-pak ; stack install)
    
  4. Compile GHC-WPC in ./ghc-wpc folder with Hadrian (see ghc.dev for details).

    cd ghc-wpc
    ./boot
    ./configure
    hadrian/build-stack -j
    

    IMPORTANT: use hadrian/build-stack

  5. At this point you have a working GHC-WPC.
    The next steps are about the compilation of GHC-WPC tooling and the usage of GHC-WPC.

  6. Go back to the repository top folder and set the path to the local GHC-WPC build in the corresponding part of ./stack.yaml. change the following line to your GHC-WPC build path:

    extra-path:
      - /home/csaba/haskell/grin-compiler/ghc-whole-program-compiler-project/ghc-wpc/_build/stage1/bin
    

    i.e. set the USER and PROJECT part properly (./stack.yaml line 32)

    extra-path:
      - /home/USER/PROJECT/ghc-whole-program-compiler-project/ghc-wpc/_build/stage1/bin
    
  7. Install the external stg tooling with the following commands:

    stack --stack-root `pwd`/.stack-root install
    

    NOTE: the stack root is set to the local folder to prevent spamming the global stack sandbox.

  8. Use gen-exe and ext-stg from terminal. (it should be in PATH due to the stack install)

TODO

Ext-STG IR

  • export IdInfo (without it gen-exe compiles -O0 executables)

UnZip with Zstd support

The .modpak and .fullpak files use Zstd compression method that was introduced in the Zip 6.3.8 standard in 2020.
The GHC-WPC tooling can handle Zstd zip files out of the box.
But if you'd like to unpack the .modpak and .fullpak files manually then you'll need an unzip version with Zstd support.
https://github.com/csabahruska/unzip-zstd

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].