Skip to content

Commit 046d284

Browse files
committed
Merge branch 'main' into harpoon_port
2 parents abdc31d + 4af0f8a commit 046d284

File tree

3 files changed

+92
-9
lines changed

3 files changed

+92
-9
lines changed

docs/getting-started.md

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ The following output should be printed out:
105105
## Troubleshooting
106106

107107
### Building dependencies:
108-
This step includes compiling the Linux kernel which can get quite resource intensive. In our tests `6GB` is the minimum value for which compiling Linux is possible, this means you might not be able to use Rex on machines with 6GB or less RAM. A sign that you ran into Out-Of-Memory (OOM) error is if you encounter this warning:
108+
109+
This step includes compiling the Linux kernel which can get quite resource
110+
intensive. In our tests `6GB` is the minimum value for which compiling
111+
Linux is possible, this means you might not be able to use Rex on machines
112+
with 6GB or less RAM. A sign that you ran into Out-Of-Memory (OOM) error is
113+
if you encounter this warning:
109114

110115
```bash
111116
/root/rex/linux/scripts/link-vmlinux.sh: line 113: 55407 Killed LLVM_OBJCOPY="${OBJCOPY}" ${PAHOLE} -J ${PAHOLE_FLAGS} ${1}
@@ -119,23 +124,65 @@ FAILED: load BTF from vmlinux: invalid argument
119124

120125
Or similar problems.
121126

122-
For WSL users, it is recommended to allocate more RAM to WSL before starting this step since WSL by default only utilizes half the RAM available on the host machine:
127+
For WSL users, it is recommended to allocate more RAM to WSL before
128+
starting this step since WSL by default only utilizes half the RAM
129+
available on the host machine:
130+
131+
From a Powershell instance, create and open a `.wslconfig` file in your
132+
home directory:
123133

124-
From a Powershell instance, create and open a `.wslconfig` file in your home directory:
125134
```bash
126135
notepad $HOME/.wslconfig
127136
```
128137

129138
Add the following lines to the file then save:
139+
130140
```bash
131141
[wsl2]
132-
memory=6GB
142+
memory=8GB
143+
swap=8GB
133144
```
134145

135146
You should change the value to how much memory you want to allocate to WSL.
136147

148+
Another issue that may happen is bootstrap failure due to the missing
149+
`libLLVM-19-rex.so`:
150+
151+
```console
152+
--- stderr
153+
llvm-config: error: libLLVM-19-rex.so is missing
154+
thread 'main' panicked at compiler/rustc_llvm/build.rs:264:16:
155+
command did not execute successfully: "/home/chin39/Documents/rex-kernel/build/rust-build/x86_64-unknown-linux-gnu/llvm/bin/llvm-config" "--link-shared" "--libs" "--system-libs" "asmparser" "bitreader" "bitwriter" "coverage" "instrumentation" "ipo" "linker" "lto" "x86"
156+
expected success, got: exit status: 1
157+
stack backtrace:
158+
0: rust_begin_unwind
159+
at /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/std/src/panicking.rs:665:5
160+
1: core::panicking::panic_fmt
161+
at /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/core/src/panicking.rs:76:14
162+
2: build_script_build::output
163+
3: build_script_build::main
164+
4: core::ops::function::FnOnce::call_once
165+
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
166+
Build completed unsuccessfully in 0:00:12
167+
FAILED: cargo rustc
168+
env 'RUSTFLAGS=-Z threads=8 -C target-cpu=native -C codegen-units=1 -C link-arg=-fuse-ld=mold -C link-arg=-Wl,-O1 -C link-arg=-Wl,--as-needed -C link-arg=-flto=thin' /usr/bin/python3 ../rust/x.py install --config=../rust/rex-config.toml --build-dir=./rust-build --set install.prefix=./rust-dist
169+
ninja: build stopped: subcommand failed.
170+
```
171+
172+
Notably this may happen as a result of [`ba85ec815c2f ("rust: enable more
173+
optimizations and features in bootstrap
174+
config")`](https://github.com/rex-rs/rex/commit/ba85ec815c2fc9721e3b466d1c296bd7dd79b1b3),
175+
as it changes the linkage of `libLLVM` from static to dynamic, but rust
176+
bootstrap process does not rebuild `libLLVM.so` following the change.
177+
The issue can be fixed by removing the build directory created by meson and
178+
starting a clean build.
179+
137180
### Building the Rex samples:
138-
There are some caveats before you run this step. By default the `ninja` build tool uses a quite high level of parallelism, which might again cause OOM on personal machines. A sign of this happenning is if you try this step and run into similar errors to:
181+
182+
There are some caveats before you run this step. By default the `ninja`
183+
build tool uses a quite high level of parallelism, which might again cause
184+
OOM on personal machines. A sign of this happenning is if you try this step
185+
and run into similar errors to:
139186

140187
```bash
141188
error: could not compile `core` (lib)
@@ -144,19 +191,24 @@ Caused by:
144191
process didn't exit successfully:
145192
```
146193
147-
To resolve this problem, try running with fewer commands in parallel using the `-j` argument, for example to run with 4 commands in parallel:
194+
To resolve this problem, try running with fewer commands in parallel using
195+
the `-j` argument, for example to run with 4 commands in parallel:
148196
149197
```bash
150198
meson compile -C build -j 4
151199
```
152200
153-
Our tests indicate a peak memory usage of 12GB with `-j 8`, so if you have less RAM it's helpful to keep the `-j` argument below 8.
201+
Our tests indicate a peak memory usage of 12GB with `-j 8`, so if you have
202+
less RAM it's helpful to keep the `-j` argument below 8.
154203

155204
### Booting the QEMU VM:
156-
By default our QEMU VM runs on 8GB of memory. To reduce this, open the qemu scripts using an editor and locate line 300:
205+
206+
By default our QEMU VM runs on 8GB of memory. To reduce this, open the qemu
207+
scripts using an editor and locate line 300:
157208

158209
```bash
159210
MEMORY=8192
160211
```
161212

162-
And change this value to the number you want. Rex has been tested to work with 4GB or `MEMORY=4096`.
213+
And change this value to the number you want. Rex has been tested to work
214+
with 4GB or `MEMORY=4096`.

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ sanity_test_scripts = join_paths(meson.project_source_root(), 'scripts/sanity_te
7373
runtest_deps = []
7474

7575
subdir('samples')
76+
subdir('rex')

rex/meson.build

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
build_dir = run_command(
2+
realpath,
3+
'--relative-to',
4+
meson.current_source_dir(),
5+
meson.current_build_dir(),
6+
capture: true,
7+
check: true
8+
).stdout().strip()
9+
10+
env = environment()
11+
env.prepend('PATH', rust_bin)
12+
env.set('LINUX_OBJ', kbuild_dir)
13+
env.set('LINUX_SRC', join_paths(meson.project_source_root(), './linux'))
14+
env.set('CARGO_TARGET_DIR', join_paths(build_dir, 'target'))
15+
16+
rex_build = custom_target(
17+
'rex-build',
18+
output: ['target'],
19+
command: [
20+
cargo_wrapper, rust_bin, '-Z',
21+
'unstable-options',
22+
'-C', meson.current_source_dir(),
23+
'rustc', '-qr', '--',
24+
'-Cenable_rex'
25+
],
26+
env: env,
27+
console: false,
28+
build_always_stale: true,
29+
build_by_default: false
30+
)

0 commit comments

Comments
 (0)