Use static picolibc.h file instead of generating it at buildtime#1407
Use static picolibc.h file instead of generating it at buildtime#1407jprendes merged 5 commits intohyperlight-dev:mainfrom
Conversation
14a3877 to
0b0f496
Compare
There was a problem hiding this comment.
Pull request overview
This PR switches hyperlight_guest_bin from generating picolibc.h during the build to shipping a static picolibc.h header in the repo, addressing source-tree pollution during libc builds and helping C artifact packaging.
Changes:
- Add a static
src/hyperlight_guest_bin/include/picolibc.hfile with the picolibc configuration defines. - Remove build-time generation of
picolibc.hfrombuild.rs(including compiler feature probing). - Update the build script to add the crate
include/directory to the C compiler include paths and to rerun when the static header changes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/hyperlight_guest_bin/include/picolibc.h |
Introduces a checked-in picolibc configuration header previously generated at build time. |
src/hyperlight_guest_bin/build.rs |
Removes config header generation and adjusts include paths + rebuild triggers to use the checked-in header. |
Comments suppressed due to low confidence (1)
src/hyperlight_guest_bin/build.rs:216
picolibc.his no longer generated intothird_party/picolibc/libc/include, butcopy_includesstill only copies headers from that directory intoOUT_DIR/include. Since the clang wrapper later uses-nostdinc -isystem <OUT_DIR>/includeonly, downstream compilation will likely fail when picolibc headers includepicolibc.h(it won’t be present in the exported include dir). Copyinclude/picolibc.hintoinclude_diras part of the build script (or extendcopy_includesto also copy frommanifest_dir/include) so the exported sysroot is self-contained.
// include for picolibc configuration: picolibc.h
build.include(manifest_dir.join("include"));
add_libc(&mut build, &picolibc_dir, &target)?;
add_libm(&mut build, &picolibc_dir, &target)?;
if cfg!(windows) {
unsafe { env::set_var("AR_x86_64_unknown_none", "llvm-ar") };
}
build.compile("hyperlight_guest_bin");
copy_includes(&include_dir, "third_party/picolibc/libc/include")?;
}
|
@copilot apply changes based on the comments in this thread |
|
One thing that we were discussing was to expose |
|
If we have configuration knobs and generated header, we need to figure out how that will work with published C artifacts. I am open to ideas :-) |
|
Something I've been thinking is having a sibling project to cargo-hyperlight that provides clang-hyperlight (or hyperlight-clang), that prepares the sysroot just like cargo-hyperlight, but provides a clang wrapper instead of a cargo wrapper. But I there are some raough edges, like... which guest version do we use? with cargo-hyperlight we get that from the dependencies list, but for clang... how do we do that? |
I think the most straight forward approach to this is: offer libc build features to Rust users, C artifacts are build from default features -- we package |
|
There are some questions regarding the generated header and race conditions (e.g., building a -sys crate that needs to build C code, and racing the build between the -sys dependency and building the hl-guest-bin dependency that generates the header). Because of this, we've decided that as a short term solution we would use a static file, and we will revisit generating the header when address #1399 . |
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
c20fc36 to
62f4cc5
Compare
Fixes #1401
It will also help fixing #1406