Commit 4d5b10e
committed
Use
This is a big PR, but most of it is interdependent to the rest.
- Shared Rust infrastructure: `libkernel`, `libmodule`, `libcore`,
`liballoc`, `libcompiler_builtins`.
+ The Rust modules are now much smaller since they do not contain
several copies of those libraries. Our example `.ko` on release
is just 12 KiB, down from 1.3 MiB. For reference:
`vmlinux` on release w/ Rust is 23 MiB (compressed: 2.1 MiB)
`vmlinux` on release w/o Rust is 22 MiB (compressed: 1.9 MiB)
i.e. the bulk is now shared.
+ Multiple builtin modules are now supported since their symbols
do not collide against each other (fixes #9).
+ Faster compilation (less crates to compile & less repetition).
+ We achieve this by compiling all the shared code to `.rlib`s
(and the `.so` for the proc macro). For loadable modules,
we need to rely on the upcoming v0 Rust mangling scheme,
plus we need to export the Rust symbols needed by the `.ko`s.
- Simpler, flat file structure: now a small driver may only need
a single file like `drivers/char/rust_example.rs`, like in C.
+ All the `rust/*` and `driver/char/rust_example/*` files moved
to fit in the new structure: less files around.
- Only `rust-lang/{rust,rust-bindgen,compiler-builtins}` as dependencies.
+ Also helps with the faster compilation.
- Dependency handling integration with `Kbuild`/`fixdep`.
+ Changes to the Rust standard library, kernel headers (bindings),
`rust/` source files, `.rs` changes, etc. all trigger
recompilation of the proper things.
+ Works as expected with parallel support (`-j`).
- Proper `make clean` support.
- Offline builds by default (there is no "online compilation" anymore;
fixes #17).
- No more interleaved Cargo output (fixes #29).
- One less nightly dependency (Cargo's `build-std`); since now we manage
the cross-compilation ourselves (should fix #27).
- Since now a kernel can be "Rust-enabled", a new `CONFIG_RUST` option
is added to enable/disable it manually, regardless of whether one has
`rustc` available or not (`CONFIG_HAS_RUST`).
- Improved handling of `rustc` flags (`opt-level`, `debuginfo`, etc.),
following what the user selected for C (no Cargo profiles).
- Added Kconfig menu for tweaking `rustc` options, like overflow checks.
- This rewrite of the Kbuild support is cleaner, i.e. less hacks
in general handling paths (e.g. no more `shell readlink` for `O=`).
- Duplicated the example driver 3 times so that we can test in the CI
that 2 builtins and 2 loadables work, all at the same time.
- Updated the quick start guide.
- Updated CI `.config`s:
+ Add the new options and test with 2 builtins and 2 loadables.
At the same time, remove the matrix test for builtin/loadable.
+ Debug: more things enabled (debuginfo, kgdb, unit testing, etc.)
that mimic more what a developer would have. Running the CI
will be slightly slower, but should be OK.
+ Release: disabled `EXPERT` and changed a few things to make it
look more like a normal configuration.
+ Also update both configs to v5.9 while I was at it.
(I could have split a few of these ones off into another PR,
but anyway it is for the CI only and I had already done it).
- Less `extern crate`s needed since we pass it via `rustc`
(closer to idiomatic 2018 edition Rust code).
Things to note:
- There is one more nightly feature used (the new Rust mangling scheme),
but we know that one will be stable (and the default one, later on).
- The hack at `exports.c` to export symbols to loadable modules.
- The hack at `allocator.rs` to get the `__rust_*()` functions.
Signed-off-by: Miguel Ojeda <[email protected]>rustc directly instead of cargo
1 parent e68d341 commit 4d5b10e
File tree
45 files changed
+899
-451
lines changed- .github/workflows
- Documentation/rust
- drivers/char
- rust_example
- init
- lib
- rust
- kernel
- src
- module
- scripts
- kconfig
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
45 files changed
+899
-451
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
| |||
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 38 | | |
45 | 39 | | |
46 | 40 | | |
| |||
50 | 44 | | |
51 | 45 | | |
52 | 46 | | |
53 | | - | |
| 47 | + | |
54 | 48 | | |
55 | | - | |
| 49 | + | |
56 | 50 | | |
57 | 51 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
62 | 56 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
68 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
69 | 66 | | |
70 | | - | |
| 67 | + | |
71 | 68 | | |
72 | | - | |
| 69 | + | |
73 | 70 | | |
74 | 71 | | |
75 | | - | |
| 72 | + | |
76 | 73 | | |
77 | | - | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
199 | 202 | | |
200 | 203 | | |
201 | 204 | | |
202 | | - | |
| 205 | + | |
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
| 209 | + | |
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
| |||
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
331 | | - | |
332 | | - | |
333 | | - | |
| 335 | + | |
334 | 336 | | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | 337 | | |
339 | 338 | | |
340 | 339 | | |
| |||
349 | 348 | | |
350 | 349 | | |
351 | 350 | | |
352 | | - | |
353 | 351 | | |
354 | 352 | | |
355 | 353 | | |
| |||
554 | 552 | | |
555 | 553 | | |
556 | 554 | | |
557 | | - | |
558 | | - | |
559 | | - | |
| 555 | + | |
560 | 556 | | |
561 | 557 | | |
562 | 558 | | |
| |||
603 | 599 | | |
604 | 600 | | |
605 | 601 | | |
| 602 | + | |
606 | 603 | | |
| 604 | + | |
607 | 605 | | |
608 | 606 | | |
609 | 607 | | |
| |||
736 | 734 | | |
737 | 735 | | |
738 | 736 | | |
| 737 | + | |
739 | 738 | | |
740 | 739 | | |
741 | 740 | | |
| 741 | + | |
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
| |||
763 | 763 | | |
764 | 764 | | |
765 | 765 | | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
766 | 769 | | |
767 | 770 | | |
768 | 771 | | |
| |||
1093 | 1096 | | |
1094 | 1097 | | |
1095 | 1098 | | |
1096 | | - | |
1097 | | - | |
| 1099 | + | |
| 1100 | + | |
1098 | 1101 | | |
1099 | | - | |
1100 | | - | |
| 1102 | + | |
| 1103 | + | |
1101 | 1104 | | |
1102 | 1105 | | |
1103 | 1106 | | |
| |||
1137 | 1140 | | |
1138 | 1141 | | |
1139 | 1142 | | |
1140 | | - | |
1141 | 1143 | | |
1142 | 1144 | | |
1143 | 1145 | | |
| |||
1146 | 1148 | | |
1147 | 1149 | | |
1148 | 1150 | | |
| 1151 | + | |
1149 | 1152 | | |
1150 | 1153 | | |
1151 | 1154 | | |
| |||
1184 | 1187 | | |
1185 | 1188 | | |
1186 | 1189 | | |
1187 | | - | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1188 | 1197 | | |
1189 | 1198 | | |
1190 | 1199 | | |
1191 | | - | |
| 1200 | + | |
1192 | 1201 | | |
1193 | 1202 | | |
1194 | 1203 | | |
1195 | | - | |
| 1204 | + | |
1196 | 1205 | | |
| 1206 | + | |
1197 | 1207 | | |
1198 | 1208 | | |
1199 | 1209 | | |
1200 | 1210 | | |
1201 | 1211 | | |
1202 | 1212 | | |
1203 | | - | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1204 | 1217 | | |
1205 | 1218 | | |
1206 | 1219 | | |
1207 | 1220 | | |
1208 | 1221 | | |
1209 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1210 | 1228 | | |
1211 | 1229 | | |
1212 | 1230 | | |
1213 | 1231 | | |
1214 | 1232 | | |
1215 | 1233 | | |
1216 | 1234 | | |
| 1235 | + | |
| 1236 | + | |
1217 | 1237 | | |
1218 | 1238 | | |
1219 | 1239 | | |
| |||
1252 | 1272 | | |
1253 | 1273 | | |
1254 | 1274 | | |
1255 | | - | |
| 1275 | + | |
1256 | 1276 | | |
1257 | 1277 | | |
1258 | 1278 | | |
1259 | 1279 | | |
1260 | 1280 | | |
1261 | 1281 | | |
1262 | | - | |
| 1282 | + | |
1263 | 1283 | | |
1264 | 1284 | | |
1265 | 1285 | | |
1266 | | - | |
| 1286 | + | |
1267 | 1287 | | |
1268 | 1288 | | |
1269 | 1289 | | |
| |||
1348 | 1368 | | |
1349 | 1369 | | |
1350 | 1370 | | |
1351 | | - | |
| 1371 | + | |
1352 | 1372 | | |
1353 | 1373 | | |
1354 | 1374 | | |
| |||
1384 | 1404 | | |
1385 | 1405 | | |
1386 | 1406 | | |
1387 | | - | |
1388 | 1407 | | |
1389 | 1408 | | |
1390 | 1409 | | |
| |||
1404 | 1423 | | |
1405 | 1424 | | |
1406 | 1425 | | |
1407 | | - | |
| 1426 | + | |
1408 | 1427 | | |
1409 | 1428 | | |
1410 | 1429 | | |
| |||
1414 | 1433 | | |
1415 | 1434 | | |
1416 | 1435 | | |
1417 | | - | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1418 | 1441 | | |
1419 | 1442 | | |
1420 | 1443 | | |
1421 | 1444 | | |
1422 | 1445 | | |
1423 | | - | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
1424 | 1486 | | |
1425 | 1487 | | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
1426 | 1496 | | |
0 commit comments