diff --git a/hermit/Cargo.toml b/hermit/Cargo.toml index 383a3d26a..55d10ccb8 100644 --- a/hermit/Cargo.toml +++ b/hermit/Cargo.toml @@ -37,6 +37,7 @@ idle-poll = [] # Build the kernel with function instrument code for mcount-based tracing instrument = [] +libc = [] mmap = [] pci = [] pci-ids = ["pci"] @@ -57,6 +58,7 @@ vga = [] vsock = [] [build-dependencies] +cc = "1" flate2 = "1" ureq = "2.4" tar = "0.4" diff --git a/hermit/build.rs b/hermit/build.rs index 6a028ee28..cbe790856 100644 --- a/hermit/build.rs +++ b/hermit/build.rs @@ -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 {