Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GHC Whole Program Compiler and External STG IR tooling

NotificationsYou must be signed in to change notification settings

haskell-debugger/ghc-whole-program-compiler-project

 
 

Repository files navigation

The project consists of GHCwpc-plugin and the correspondingExternal STG IR andtooling.

The wpc-plugin is a compiler plugin for GHC 9.6 or newer. It exports the STG IR(.modpak) for the compiled modules and linker metadata (.ghc_stgapp) at application link time.

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.

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

Build

external stg tooling

stack install

wpc-plugin

  1. Installzip-cmd, a simple CLI for thezip package
    cabal install zip-cmd
  2. Compile thewpc-pluginThewpc-plugin has a speparatestack.yaml because it uses the plugin API ofGHC 9.6.1.
    cd wpc-pluginstack build
  3. Find the builtlibwpc-plugin.[so|dylib|dll]
    ln -s `find . -type f -name 'libwpc-plugin.so' -o -name 'libwpc-plugin.dylib' -o -name 'libwpc-plugin.dll' | head -1`

Usage

It is required to use GHC 9.6.1.

cabal

Add the following lines to your project'scabal.project:

package *  ghc-options:    -fplugin-trustworthy    -fplugin-library=PATH_TO/libwpc-plugin.so;wpc-plugin-unit;WPC.Plugin;[]

stack

Add the following lines to your project'sstack.yaml:

apply-ghc-options: everythingghc-options:  "$everything":      -fplugin-trustworthy      -fplugin-library=PATH_TO/libwpc-plugin.so;wpc-plugin-unit;WPC.Plugin;[]

TODO

Ext-STG IR

  • export IdInfo (without itgen-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 anunzip version with Zstd support.
https://github.com/csabahruska/unzip-zstd

About

GHC Whole Program Compiler and External STG IR tooling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell93.0%
  • C++4.3%
  • Python2.5%
  • Other0.2%

[8]ページ先頭

©2009-2025 Movatter.jp