@@ -53,47 +53,52 @@ 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 {
65- let include_src_dir = hyperlight_guest_bin_dir. join ( dir) ;
66- let files = glob:: glob ( & format ! ( "{}/**/*.h" , include_src_dir. display( ) ) )
67- . context ( "Failed to read include source directory" ) ?;
68-
69- for file in files {
70- let src = file. context ( "Failed to read include source file" ) ?;
71- let dst = src. strip_prefix ( & include_src_dir) . unwrap ( ) ;
72- let dst = include_dst_dir. join ( dst) ;
73-
74- std:: fs:: create_dir_all ( dst. parent ( ) . unwrap ( ) )
75- . context ( "Failed to create include subdirectory" ) ?;
76- std:: fs:: copy ( & src, & dst) . context ( "Failed to copy include file" ) ?;
56+ // Skip musl header copying on aarch64 — no musl/C support yet
57+ if !args. target . starts_with ( "aarch64" ) {
58+ let include_dirs: & [ & str ] = & [
59+ "third_party/printf/" ,
60+ "third_party/musl/include" ,
61+ "third_party/musl/arch/generic" ,
62+ "third_party/musl/arch/x86_64" ,
63+ "third_party/musl/src/internal" ,
64+ ] ;
65+
66+ for dir in include_dirs {
67+ let include_src_dir = hyperlight_guest_bin_dir. join ( dir) ;
68+ let files = glob:: glob ( & format ! ( "{}/**/*.h" , include_src_dir. display( ) ) )
69+ . context ( "Failed to read include source directory" ) ?;
70+
71+ for file in files {
72+ let src = file. context ( "Failed to read include source file" ) ?;
73+ let dst = src. strip_prefix ( & include_src_dir) . unwrap ( ) ;
74+ let dst = include_dst_dir. join ( dst) ;
75+
76+ std:: fs:: create_dir_all ( dst. parent ( ) . unwrap ( ) )
77+ . context ( "Failed to create include subdirectory" ) ?;
78+ std:: fs:: copy ( & src, & dst) . context ( "Failed to copy include file" ) ?;
79+ }
7780 }
7881 }
7982
8083 Ok ( ( ) )
8184}
8285
8386pub fn cflags ( args : & Args ) -> OsString {
84- const FLAGS : & [ & str ] = & [
85- // terrible hack, see
86- // https://github.com/hyperlight-dev/hyperlight/blob/main/src/hyperlight_guest_bin/build.rs#L80
87- "--target=x86_64-unknown-linux-none" ,
87+ let clang_target = if args. target . starts_with ( "aarch64" ) {
88+ "--target=aarch64-unknown-linux-none"
89+ } else {
90+ "--target=x86_64-unknown-linux-none"
91+ } ;
92+
93+ let common_flags: & [ & str ] = & [
94+ clang_target,
8895 "-U__linux__" ,
89- // Our rust target also has this set since it based off "x86_64-unknown-none"
9096 "-fPIC" ,
9197 // We don't support stack protectors at the moment, but Arch Linux clang
9298 // auto-enables them for -linux platforms, so explicitly disable them.
9399 "-fno-stack-protector" ,
94100 "-fstack-clash-protection" ,
95101 "-mstack-probe-size=4096" ,
96- "-mno-red-zone" ,
97102 "-nostdinc" ,
98103 // Define HYPERLIGHT as we use this to conditionally enable/disable code
99104 // in the libc headers
@@ -102,10 +107,15 @@ pub fn cflags(args: &Args) -> OsString {
102107 ] ;
103108
104109 let mut flags = OsString :: new ( ) ;
105- for flag in FLAGS {
110+ for flag in common_flags {
106111 flags. push ( flag) ;
107112 flags. push ( " " ) ;
108113 }
114+
115+ // x86_64-specific flags
116+ if args. target . starts_with ( "x86_64" ) {
117+ flags. push ( "-mno-red-zone " ) ;
118+ }
109119 flags. push ( " " ) ;
110120 flags. push ( "-isystem" ) ;
111121 flags. push ( " " ) ;
0 commit comments