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

Describe how to use the plugin on the boot libs #16

Merged
merged 1 commit into from
Jan 12, 2025
Merged
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
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ You should then be able to build or run your executable, rebuilding (almost)
all of its dependencies, with

```bash
$ cabal run --project-file cabal.project.plugin <your-exec>
cabal run --project-file cabal.project.plugin <your-exec>
```

### Upgrading the plugin
Expand All @@ -190,6 +190,44 @@ packages). So wipe your `cabal-plugin-store` as well as your `dist-newstyle`
directory each time you update your plugin (another good reason for using a
separate store for the plugin).

## Enabling the plugin on the GHC boot libraries

If you want to track time spent in foreign calls made in the GHC boot libraries,
you will need to recompile GHC. Checkout

```
git clone https://gitlab.haskell.org/edsko/ghc.git \
--branch edsko/trace-foreign-calls \
./ghc-trace-foreign-calls
```

Then in the `ghc-trace-foreign-calls` directory run

```
git submodule update --init --recursive
./boot && ./configure
hadrian/build -j
```

Use GHC 9.10 as your bootstrap compiler. See
[Building and Porting GHC](https://gitlab.haskell.org/ghc/ghc/-/wikis/building/#building-and-porting-ghc)
for all the nitty gritty details about building ghc.

Once built, use the compiler in `_build/stage1/bin` instead of your regular GHC.
In this case there is no need to separately enable the plugin; just compile with
this custom build of GHC, and all packages will have `trace-foreign-calls`
enabled; you might still want to use a custom cabal store, something like

```
import: cabal.project

package *
ghc-options:
-package-db=/tmp/cabal-plugin-store/ghc-9.13.20250112/package.db

store-dir: /tmp/cabal-plugin-store
```

## The generated wrappers

### IO function, no profiling
Expand Down