elaborate build-std-features

This commit is contained in:
janis 2026-07-17 16:22:58 +02:00
parent ba089a5169
commit 5c872bfca0
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8

View file

@ -162,9 +162,12 @@ cargo -Zjson-target-spec build --target x86_64-unknown-kernel.json
#+begin_src toml #+begin_src toml
[unstable] [unstable]
json-target-spec = true # lets us specify a custom target specification file json-target-spec = true # lets us specify a custom target specification file
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"] build-std = ["core", "compiler_builtins"]
#+end_src #+end_src
Because we plan on using builtin functions like =memcpy=, we tell cargo to build the =compiler_builtins= crate with the =mem= feature enabled.
Rust permits the user to abort the program at any time by calling the =panic!= macro, or a function that “panics” internally. Typically, the mechanism by which this happens, as well as the more complex behaviour of unwinding the stack and catching unwinds, is provided by the =std=. Since weve opted out of using =std=, we will need to provide a panic handler for rust to call in case of a panic. Unwinding is already disabled by the =panic-strategy= field in our target specification file. Rust permits the user to abort the program at any time by calling the =panic!= macro, or a function that “panics” internally. Typically, the mechanism by which this happens, as well as the more complex behaviour of unwinding the stack and catching unwinds, is provided by the =std=. Since weve opted out of using =std=, we will need to provide a panic handler for rust to call in case of a panic. Unwinding is already disabled by the =panic-strategy= field in our target specification file.
For the time being, we will again simply spin in an infinite loop whenever a panic occurs: For the time being, we will again simply spin in an infinite loop whenever a panic occurs: