@@ -62,8 +62,6 @@ fn cargo_main() {
62
62
. include ( "third_party/musl/arch/x86_64" ) ;
63
63
}
64
64
65
- let is_pe = env:: var ( "CARGO_CFG_WINDOWS" ) . is_ok ( ) ;
66
-
67
65
if cfg ! ( any( feature = "printf" , feature = "libc" ) ) {
68
66
cfg. define ( "HYPERLIGHT" , None ) ; // used in certain musl files for conditional compilation
69
67
@@ -78,37 +76,28 @@ fn cargo_main() {
78
76
. flag ( "-Wno-unused-parameter" )
79
77
. flag ( "-Wno-string-plus-int" ) ;
80
78
81
- if is_pe {
82
- cfg. flag ( "-Wno-unused-label" ) ;
83
- cfg. flag ( "-Wno-unused-variable" ) ;
84
- cfg. compiler ( "clang-cl" ) ;
85
- } else {
86
- cfg. flag ( "-fPIC" ) ;
87
- // This is a terrible hack, because
88
- // - we need stack clash protection, because we have put the
89
- // stack right smack in the middle of everything in the guest
90
- // - clang refuses to do stack clash protection unless it is
91
- // required by a target ABI (Windows, MacOS) or the target is
92
- // is Linux or FreeBSD (see Clang.cpp RenderSCPOptions
93
- // https://github.com/llvm/llvm-project/blob/1bb52e9/clang/lib/Driver/ToolChains/Clang.cpp#L3724).
94
- // Hopefully a flag to force stack clash protection on generic
95
- // targets will eventually show up.
96
- cfg. flag ( "--target=x86_64-unknown-linux-none" ) ;
97
-
98
- // We don't support stack protectors at the moment, but Arch Linux clang
99
- // auto-enables them for -linux platforms, so explicitly disable them.
100
- cfg. flag ( "-fno-stack-protector" ) ;
101
- cfg. flag ( "-fstack-clash-protection" ) ;
102
- cfg. flag ( "-mstack-probe-size=4096" ) ;
103
- cfg. compiler ( "clang" ) ;
104
- }
79
+ cfg. flag ( "-fPIC" ) ;
80
+ // This is a terrible hack, because
81
+ // - we need stack clash protection, because we have put the
82
+ // stack right smack in the middle of everything in the guest
83
+ // - clang refuses to do stack clash protection unless it is
84
+ // required by a target ABI (Windows, MacOS) or the target is
85
+ // is Linux or FreeBSD (see Clang.cpp RenderSCPOptions
86
+ // https://github.com/llvm/llvm-project/blob/1bb52e9/clang/lib/Driver/ToolChains/Clang.cpp#L3724).
87
+ // Hopefully a flag to force stack clash protection on generic
88
+ // targets will eventually show up.
89
+ cfg. flag ( "--target=x86_64-unknown-linux-none" ) ;
90
+
91
+ // We don't support stack protectors at the moment, but Arch Linux clang
92
+ // auto-enables them for -linux platforms, so explicitly disable them.
93
+ cfg. flag ( "-fno-stack-protector" ) ;
94
+ cfg. flag ( "-fstack-clash-protection" ) ;
95
+ cfg. flag ( "-mstack-probe-size=4096" ) ;
96
+ cfg. compiler ( "clang" ) ;
105
97
106
98
if cfg ! ( windows) {
107
99
unsafe { env:: set_var ( "AR_x86_64_unknown_none" , "llvm-ar" ) } ;
108
- } else {
109
- unsafe { env:: set_var ( "AR_x86_64_pc_windows_msvc" , "llvm-lib" ) } ;
110
100
}
111
-
112
101
cfg. compile ( "hyperlight_guest_bin" ) ;
113
102
}
114
103
@@ -183,29 +172,20 @@ fn cargo_main() {
183
172
fs:: create_dir_all ( & binroot)
184
173
. unwrap_or_else ( |e| panic ! ( "Could not create binary root {:?}: {}" , & binroot, e) ) ;
185
174
fs:: write ( binroot. join ( ".out_dir" ) , out_dir) . expect ( "Could not write out_dir" ) ;
186
- fs:: copy ( & binpath, binroot. join ( "ml64.exe" ) ) . expect ( "Could not copy to ml64.exe" ) ;
187
175
fs:: copy ( & binpath, binroot. join ( "clang" ) ) . expect ( "Could not copy to clang" ) ;
188
176
fs:: copy ( & binpath, binroot. join ( "clang.exe" ) ) . expect ( "Could not copy to clang.exe" ) ;
189
- fs:: copy ( & binpath, binroot. join ( "clang-cl" ) ) . expect ( "Could not copy to clang-cl" ) ;
190
- fs:: copy ( & binpath, binroot. join ( "clang-cl.exe" ) ) . expect ( "Could not copy to clang-cl.exe" ) ;
191
177
}
192
178
}
193
179
194
180
#[ derive( PartialEq ) ]
195
181
enum Tool {
196
182
CargoBuildScript ,
197
- Ml64 ,
198
183
Clang ,
199
- ClangCl ,
200
184
}
201
185
impl From < & std:: ffi:: OsStr > for Tool {
202
186
fn from ( x : & std:: ffi:: OsStr ) -> Tool {
203
- if x == "ml64.exe" {
204
- Tool :: Ml64
205
- } else if x == "clang" || x == "clang.exe" {
187
+ if x == "clang" {
206
188
Tool :: Clang
207
- } else if x == "clang-cl" || x == "clang-cl.exe" {
208
- Tool :: ClangCl
209
189
} else {
210
190
Tool :: CargoBuildScript
211
191
}
@@ -252,44 +232,24 @@ fn main() -> std::process::ExitCode {
252
232
let mut args = env:: args ( ) ;
253
233
args. next ( ) ; // ignore the exe name
254
234
let include_dir = <String as AsRef < Path > >:: as_ref ( & out_dir) . join ( "include" ) ;
255
- match tool {
256
- Tool :: Ml64 => std:: process:: Command :: new ( "llvm-ml" )
257
- . arg ( "-m64" )
258
- . args ( args)
259
- . status ( )
260
- . ok ( )
261
- . and_then ( |x| ( x. code ( ) ) )
262
- . map ( |x| ( x as u8 ) . into ( ) )
263
- . unwrap_or ( std:: process:: ExitCode :: FAILURE ) ,
264
- Tool :: Clang => std:: process:: Command :: new ( find_next ( root_dir, "clang" ) )
265
- // terrible hack, see above
266
- . arg ( "--target=x86_64-unknown-linux-none" )
267
- . args ( [
268
- // We don't support stack protectors at the moment, but Arch Linux clang
269
- // auto-enables them for -linux platforms, so explicitly disable them.
270
- "-fno-stack-protector" ,
271
- "-fstack-clash-protection" ,
272
- "-mstack-probe-size=4096" ,
273
- ] )
274
- . arg ( "-nostdinc" )
275
- . arg ( "-isystem" )
276
- . arg ( include_dir)
277
- . args ( args)
278
- . status ( )
279
- . ok ( )
280
- . and_then ( |x| ( x. code ( ) ) )
281
- . map ( |x| ( x as u8 ) . into ( ) )
282
- . unwrap_or ( std:: process:: ExitCode :: FAILURE ) ,
283
- Tool :: ClangCl => std:: process:: Command :: new ( find_next ( root_dir, "clang-cl" ) )
284
- . arg ( "-nostdinc" )
285
- . arg ( "/external:I" )
286
- . arg ( include_dir)
287
- . args ( args)
288
- . status ( )
289
- . ok ( )
290
- . and_then ( |x| ( x. code ( ) ) )
291
- . map ( |x| ( x as u8 ) . into ( ) )
292
- . unwrap_or ( std:: process:: ExitCode :: FAILURE ) ,
293
- _ => std:: process:: ExitCode :: FAILURE ,
294
- }
235
+
236
+ std:: process:: Command :: new ( find_next ( root_dir, "clang" ) )
237
+ // terrible hack, see above
238
+ . arg ( "--target=x86_64-unknown-linux-none" )
239
+ . args ( [
240
+ // We don't support stack protectors at the moment, but Arch Linux clang
241
+ // auto-enables them for -linux platforms, so explicitly disable them.
242
+ "-fno-stack-protector" ,
243
+ "-fstack-clash-protection" ,
244
+ "-mstack-probe-size=4096" ,
245
+ ] )
246
+ . arg ( "-nostdinc" )
247
+ . arg ( "-isystem" )
248
+ . arg ( include_dir)
249
+ . args ( args)
250
+ . status ( )
251
+ . ok ( )
252
+ . and_then ( |x| ( x. code ( ) ) )
253
+ . map ( |x| ( x as u8 ) . into ( ) )
254
+ . unwrap_or ( std:: process:: ExitCode :: FAILURE )
295
255
}
0 commit comments