You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of a library containing a manually written build-depends
corresponding to a stackage snapshot, we now have an executable that
queries stackage directly, and then uses the response to generate
the desired cabal file. The executable then builds that project.
The executable also includes the ability to split the package set into
smaller groups, where each group is built sequentially. This allows
for scenarios where building the entire set at once is not feasible,
at the cost of performance.
We also add 'postgresql-libpq' to linux/osx (requires postgres dep),
and 'hfsevents' to osx.
Copy file name to clipboardExpand all lines: README.md
+80-16Lines changed: 80 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## How to?
4
4
5
-
This is a meta-package to facilitate impact assessment for [CLC proposals](https://github.com/haskell/core-libraries-committee). The package `clc-stackage.cabal` lists almost entire Stackage as `build-depends`, so that `cabal build` transitively compiles them all.
5
+
This is a meta-package to facilitate impact assessment for [CLC proposals](https://github.com/haskell/core-libraries-committee).
6
6
7
7
An impact assessment is due when
8
8
@@ -13,32 +13,96 @@ An impact assessment is due when
13
13
The procedure is as follows:
14
14
15
15
1. Rebase changes, mandated by your proposal, atop of `ghc-9.8` branch.
16
+
16
17
2. Compile a patched GHC, say, `~/ghc/_build/stage1/bin/ghc`.
17
-
3.`git clone https://github.com/Bodigrim/clc-stackage`, then `cd clc-stackage`.
18
-
4. Run `cabal build -w ~/ghc/_build/stage1/bin/ghc --keep-going` and wait for a long time.
19
-
* On a recent Macbook Air it takes around 12 hours, YMMV.
20
-
* You can interrupt `cabal` at any time and rerun again later.
21
-
* Consider setting `--jobs` to retain free CPU cores for other tasks.
22
-
* Full build requires roughly 7 Gb of free disk space.
23
-
5. If any packages fail to compile:
24
-
* copy them locally using `cabal unpack`,
25
-
* patch to confirm with your proposal,
26
-
* link them from `packages` section of `cabal.project`,
27
-
* return to Step 4.
28
-
6. When everything finally builds, get back to CLC with a list of packages affected and patches required.
18
+
19
+
3.`git clone https://github.com/haskell/clc-stackage`, then `cd clc-stackage`.
20
+
21
+
4. Build the exe: `cabal install clc-stackage --installdir=./bin`.
22
+
23
+
> :warning:**Warning:** Use a normal downloaded GHC for this step, **not** your custom built one. Why? Using the custom GHC can force a build of many dependencies you'd otherwise get for free e.g. `vector`.
24
+
25
+
5. Uncomment and modify the `with-compiler` line in [generated/cabal.project](generated/cabal.project) e.g.
26
+
27
+
```
28
+
with-compiler: /home/ghc/_build/stage1/bin/ghc
29
+
```
30
+
31
+
6. Run `./bin/clc-stackage` and wait for a long time. See [below](#the-clc-stackage-exe) for more details.
32
+
33
+
* On a recent Macbook Air it takes around 12 hours, YMMV.
34
+
* You can interrupt `cabal` at any time and rerun again later.
35
+
* Consider setting `--jobs` to retain free CPU cores for other tasks.
36
+
* Full build requires roughly 7 Gb of free disk space.
37
+
38
+
To get an idea of the current progress, we can run the following commands
* link them from `packages` section of `cabal.project`,
56
+
* return to Step 6.
57
+
58
+
8. When everything finally builds, get back to CLC with a list of packages affected and patches required.
59
+
60
+
### The clc-stackage exe
61
+
62
+
Previously, this project was just a single (massive) cabal file that had to be manually updated. Usage was fairly simple: `cabal build clc-stackage --keep-going` to build the project, `--keep-going` so that as many packages as possible are built.
63
+
64
+
This has been updated so that `clc-stackage` is now an executable that will automatically generate the desired cabal file based on the results of querying stackage directly. This streamlines updates, provides a more flexible build process, and potentially has prettier output (with `--batch` arg):
65
+
66
+

67
+
68
+
In particular, the `clc-stackage` exe allows for splitting the entire package set into subset groups of size `N` with the `--batch N` option. Each group is then built sequentially. Not only can this be useful for situations where building the entire package set in one go is infeasible, but it also provides a "cache" functionality, that allows us to interrupt the program at any point (e.g. `CTRL-C`), and pick up where we left off. For example:
69
+
70
+
```
71
+
$ ./bin/clc-stackage --batch 100
72
+
```
73
+
74
+
This will split the entire downloaded package set into groups of size 100. Each time a group finishes (success or failure), stdout/err will be updated, and then the next group will start. If the group failed to build and we have `--write-logs save-failures` (the default), then the logs and error output will be in `./output/logs/<pkg>/`, where `<pkg>` is the name of the first package in the group.
75
+
76
+
See `./bin/clc-stackage --help` for more info.
77
+
78
+
#### Optimal performance
79
+
80
+
On the one hand, splitting the entire package set into `--batch` groups makes the output easier to understand and offers a nice workflow for interrupting/restarting the build. On the other hand, there is a question of what the best value of `N` is for `--batch N`, with respect to performance.
81
+
82
+
In general, the smaller `N` is, the worse the performance. There are several reasons for this:
83
+
84
+
- The smaller `N` is, the more `cabal build` processes, which adds overhead.
85
+
- More packages increase the chances for concurrency gains.
86
+
87
+
Thus for optimal performance, you want to take the largest group possible, with the upper limit being no `--batch` argument at all, as that puts all packages into the same group.
88
+
89
+
> [!TIP]
90
+
>
91
+
> Additionally, the `./output/cache.json` file can be manipulated directly. For example, if you want to try building only `foo`, ensure `foo` is the only entry in the json file's `untested` field.
29
92
30
93
## Getting dependencies via `nix`
94
+
31
95
For Linux based systems, there's a provided `flake.nix` and `shell.nix` to get a nix shell
32
96
with an approximation of the required dependencies (cabal itself, C libs) to build `clc-stackage`.
33
97
34
98
Note that it is not actively maintained, so it may require some tweaking to get working, and conversely, it may have some redundant dependencies.
35
99
36
100
## Misc
37
101
38
-
* Your custom GHC will need to be on the PATH to build the `stack` library i.e.
102
+
* Your custom GHC will need to be on the PATH to build the `stack` library e.g.
39
103
40
104
```
41
-
export PATH=/path/to/custom/ghc/stage1/bin/:$PATH
105
+
export PATH=/home/ghc/_build/stage1/bin/:$PATH
42
106
```
43
107
44
-
Nix users can uncomment (and modify) this line in the `flake.nix`.
108
+
Nix users can uncomment (and modify) this line in the `flake.nix`.
0 commit comments