Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add libc feature for linking to the C library #640

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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