@@ -235,6 +235,13 @@ const ASM_TARGETS: &[AsmTarget] = &[
235
235
asm_extension : "S" ,
236
236
preassemble : true ,
237
237
} ,
238
+ AsmTarget {
239
+ oss : & [ UEFI ] ,
240
+ arch : "x86_64" ,
241
+ perlasm_format : "nasm" ,
242
+ asm_extension : "asm" ,
243
+ preassemble : true ,
244
+ } ,
238
245
] ;
239
246
240
247
struct AsmTarget {
@@ -279,6 +286,8 @@ const MACOS_ABI: &[&str] = &["ios", "macos"];
279
286
280
287
const WINDOWS : & str = "windows" ;
281
288
289
+ const UEFI : & str = "uefi" ;
290
+
282
291
/// Read an environment variable and tell Cargo that we depend on it.
283
292
///
284
293
/// This needs to be used for any environment variable that isn't a standard
@@ -381,8 +390,9 @@ fn pregenerate_asm_main() {
381
390
perlasm ( & perlasm_src_dsts, asm_target) ;
382
391
383
392
if asm_target. preassemble {
384
- // Preassembly is currently only done for Windows targets.
385
- assert_eq ! ( & asm_target. oss, & [ WINDOWS ] ) ;
393
+ // Preassembly is currently done for Windows and UEFI targets.
394
+ assert ! ( asm_target. oss. contains( & WINDOWS ) || asm_target. oss. contains( & UEFI ) ) ;
395
+
386
396
let os = WINDOWS ;
387
397
388
398
let srcs = asm_srcs ( perlasm_src_dsts) ;
@@ -460,7 +470,7 @@ fn build_c_code(
460
470
461
471
// For Windows we also pregenerate the object files for non-Git builds so
462
472
// the user doesn't need to install the assembler.
463
- if use_pregenerated && target. os == WINDOWS {
473
+ if use_pregenerated && ( target. os == WINDOWS || target . os == UEFI ) {
464
474
asm_srcs = asm_srcs
465
475
. iter ( )
466
476
. map ( |src| obj_path ( & pregenerated, src. as_path ( ) ) )
@@ -602,6 +612,7 @@ fn cc(file: &Path, ext: &str, target: &Target, include_dir: &Path, out_file: &Pa
602
612
&& target. os != "redox"
603
613
&& target. os != "windows"
604
614
&& target. arch != "wasm32"
615
+ && target. os != "uefi"
605
616
{
606
617
let _ = c. flag ( "-fstack-protector" ) ;
607
618
}
@@ -642,6 +653,13 @@ fn cc(file: &Path, ext: &str, target: &Target, include_dir: &Path, out_file: &Pa
642
653
}
643
654
}
644
655
656
+ // UEFI is a baremental freestanding environment without stdlib.
657
+ if target. os == "uefi" && target. arch == "x86_64" {
658
+ let _ = c. flag ( "-nostdlibinc" ) ;
659
+ let _ = c. define ( "RING_CORE_NOSTDLIBINC" , "1" ) ;
660
+ let _ = c. flag ( "-ffreestanding" ) ;
661
+ }
662
+
645
663
if target. force_warnings_into_errors {
646
664
c. warnings_into_errors ( true ) ;
647
665
}
0 commit comments