Skip to content

Commit e371351

Browse files
authored
docs: refine claude code instructions for patching criu (#10)
1 parent 4d7266c commit e371351

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

CLAUDE.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cpack --config build/CPackConfig.cmake --verbose -B dist -G STGZ
2929

3030
### Patching CRIU
3131

32-
We are patching criu with the patches in the `patches/` folder.
32+
We are patching criu with the patches in the `patch/` folder.
3333
From time to time we will need to update the CRIU version in our CMakeLists.txt.
3434

3535
To make sure that everything works, you can clone criu in `/tmp/criu` via
@@ -42,25 +42,47 @@ Then ask the user which version they want to try to update criu-static to.
4242

4343
Once you have done that change the git commit to the version that the user wants to test.
4444

45-
Now apply the patches in `patches` one by one making sure that criu builds.
45+
Now apply the patches in `patch` one by one making sure that criu builds.
4646

4747
To build criu, however you have to first obtain all the dependencies, but not any dependency. You want
4848
the same dependencies that criu-static uses. criu-static patches criu to use CFLAGS and LDFLAGS
49-
and other env variables instead of pkg-cinfig, you can inspect what it does by checking `CMakeLists.txt`
50-
That `CMakeLists.txt` will output the env vars you have to use, it will become something like (paths might be wrong, double check, this was in a devcontainer!)
49+
and other env variables instead of pkg-config, you can inspect what it does by checking `CMakeLists.txt`.
50+
51+
First build the dependencies by running `cmake --preset static-release` (this will fail at the CRIU step
52+
if the version hasn't been updated yet, but all dependencies will be built).
53+
54+
The `CMakeLists.txt` configure step outputs the env vars you need. Look for these lines in the cmake output:
55+
56+
```
57+
-- criu CFLAGS ...
58+
-- criu LDFLAGS ...
59+
-- criu PATH ...
60+
```
61+
62+
Use those exact values. The full set of env vars that cmake passes to the CRIU make command is
63+
(see the `ExternalProject_Add(criu ...)` section in `CMakeLists.txt`):
5164

5265
```bash
53-
export CFLAGS="-I/workspaces/criu-static/build/protobuf-c-install/include -DCONFIG_HAS_NFTABLES_LIB_API_1 -I/workspaces/criu-static/build/protobuf-install/include -I/workspaces/criu-static/build/libnet-install/include -D_BSD_SOUR
54-
CE -D_DEFAULT_SOURCE -DHAVE_NET_ETHERNET_H -I/workspaces/criu-static/build/libnl-install/include -I/workspaces/criu-static/build/libnl-install/include/libnl3 -I/workspaces/criu-static/build/libcap-install/include -I/workspaces/criu-static/build/libaio-insta
55-
ll/include -I/workspaces/criu-static/build/zlib-install/include -I/workspaces/criu-static/build/libnftables-install/include -I/workspaces/criu-static/build/libnftnl-install/include -I/workspaces/criu-static/build/libmnl-install/include -I/workspaces/criu-st
56-
atic/build/util-linux-install/include -I/workspaces/criu-static/build/libintl-install/include"
57-
export LDFLAGS="-static -L/workspaces/criu-static/build/protobuf-c-install/lib -lprotobuf-c -L/workspaces/criu-static/build/protobuf-install/lib -lprotobuf -L/workspaces/criu-static/build/libnet-install/lib -lnet -L/workspa
58-
ces/criu-static/build/libnl-install/lib -lnl-3 -L/workspaces/criu-static/build/libcap-install/lib -lcap -L/workspaces/criu-static/build/libaio-install/lib -laio -L/workspaces/criu-static/build/zlib-install/lib -lz -L/workspaces/criu-static/build/libnftables
59-
-install/lib -lnftables -L/workspaces/criu-static/build/libnftnl-install/lib -lnftnl -L/workspaces/criu-static/build/libmnl-install/lib -lmnl -L/workspaces/criu-static/build/util-linux-install/lib -luuid -L/workspaces/criu-static/build/libintl-install/lib -
60-
lintl"
66+
export CFLAGS="<value from cmake output>"
67+
export LDFLAGS="<value from cmake output>"
68+
export PATH="<value from cmake output>"
69+
export CC=gcc
70+
export CUDA_PLUGIN_LIBCAP_CFLAGS="-I<build>/libcap-install/include"
71+
export SKIP_PIP_INSTALL=1
6172
```
6273

63-
plus all other env vars like CONFIG_AMDGPU, STATIC_PLUGINS, CUDA_PLUGIN_LIBCAP_CFLAGS but double check the cmake file to see what you have to pass.
74+
The PATH must include the directories for `protoc` and `protoc-gen-c` (protobuf compilers) that
75+
were built as dependencies. Without this, the CRIU build will fail with `protoc: No such file or directory`.
76+
77+
Then build with:
78+
79+
```bash
80+
cd /tmp/criu
81+
make mrproper
82+
# Copy descriptor.proto from the built protobuf
83+
cp <build>/protobuf-install/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
84+
make CONFIG_AMDGPU=n STATIC_PLUGINS=y -j$(nproc) criu
85+
```
6486

6587

6688

0 commit comments

Comments
 (0)