@@ -53,15 +53,26 @@ pub fn prepare(args: &Args) -> Result<()> {
5353 std:: fs:: create_dir_all ( & include_dst_dir)
5454 . context ( "Failed to create sysroot include directory" ) ?;
5555
56- const INCLUDE_DIRS : & [ & str ] = & [
57- "third_party/printf/" ,
58- "third_party/musl/include" ,
59- "third_party/musl/arch/generic" ,
60- "third_party/musl/arch/x86_64" ,
61- "third_party/musl/src/internal" ,
62- ] ;
63-
64- for dir in INCLUDE_DIRS {
56+ // Detect which libc variant is present: picolibc or legacy musl
57+ let include_dirs: & [ & str ] = if hyperlight_guest_bin_dir
58+ . join ( "third_party/musl/include" )
59+ . is_dir ( )
60+ {
61+ & [
62+ "third_party/printf/" ,
63+ "third_party/musl/include" ,
64+ "third_party/musl/arch/generic" ,
65+ "third_party/musl/arch/x86_64" ,
66+ "third_party/musl/src/internal" ,
67+ ]
68+ } else {
69+ & [
70+ "third_party/picolibc/libc/include" ,
71+ "third_party/picolibc/libc/stdio" ,
72+ ]
73+ } ;
74+
75+ for dir in include_dirs {
6576 let include_src_dir = hyperlight_guest_bin_dir. join ( dir) ;
6677 let files = glob:: glob ( & format ! ( "{}/**/*.h" , include_src_dir. display( ) ) )
6778 . context ( "Failed to read include source directory" ) ?;
@@ -94,7 +105,7 @@ pub fn cflags(args: &Args) -> OsString {
94105 "-fstack-clash-protection" ,
95106 "-mstack-probe-size=4096" ,
96107 "-mno-red-zone" ,
97- "-nostdinc " ,
108+ "-nostdlibinc " ,
98109 // Define HYPERLIGHT as we use this to conditionally enable/disable code
99110 // in the libc headers
100111 "-DHYPERLIGHT=1" ,
0 commit comments