Skip to content

Commit

Permalink
feat: add libc feature for linking to the C library
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Nov 13, 2024
1 parent 4a68720 commit fdeba57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hermit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ idle-poll = []
# Build the kernel with function instrument code for mcount-based tracing
instrument = []

libc = []
mmap = []
pci = []
pci-ids = ["pci"]
Expand All @@ -57,6 +58,7 @@ vga = []
vsock = []

[build-dependencies]
cc = "1"
flate2 = "1"
ureq = "2.4"
tar = "0.4"
12 changes: 12 additions & 0 deletions hermit/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ fn main() {
let kernel_src = KernelSrc::local().unwrap_or_else(KernelSrc::download);

kernel_src.build();

if has_feature("libc") {
let libc = cc::Build::new()
.get_compiler()
.to_command()
.arg("-print-file-name=libc.a")
.output()
.unwrap()
.stdout;
let libc = str::from_utf8(&libc).unwrap().trim_ascii_end();
println!("cargo:rustc-link-lib=static:+verbatim={libc}");
}
}

struct KernelSrc {
Expand Down

0 comments on commit fdeba57

Please sign in to comment.