@@ -15,6 +15,7 @@ mod universal;
1515mod win_aarch64;
1616mod win_x86_64;
1717
18+ use crate :: nasm_builder:: NasmBuilder ;
1819use crate :: {
1920 cargo_env, emit_warning, env_var_to_bool, execute_command, get_crate_cflags, is_no_asm,
2021 optional_env_optional_crate_target, optional_env_target, out_dir, requested_c_std,
@@ -137,6 +138,15 @@ impl BuildOption {
137138 }
138139 }
139140 }
141+
142+ pub ( crate ) fn apply_nasm < ' a > ( & self , nasm_builder : & ' a mut NasmBuilder ) -> & ' a mut NasmBuilder {
143+ match self {
144+ BuildOption :: FLAG ( val) => nasm_builder. flag ( val) ,
145+ BuildOption :: DEFINE ( key, val) => nasm_builder. define ( key, Some ( val. as_str ( ) ) ) ,
146+ BuildOption :: INCLUDE ( path) => nasm_builder. include ( path. as_path ( ) ) ,
147+ _ => nasm_builder, // STD ignored for NASM
148+ }
149+ }
140150}
141151
142152impl CcBuilder {
@@ -436,6 +446,14 @@ impl CcBuilder {
436446 . display( )
437447 ) ) ;
438448
449+ let mut build_options = vec ! [ ] ;
450+ self . add_includes ( & mut build_options) ;
451+ let mut nasm_builder = NasmBuilder :: new ( self . out_dir . clone ( ) ) ;
452+
453+ for option in & build_options {
454+ option. apply_nasm ( & mut nasm_builder) ;
455+ }
456+
439457 let s2n_bignum_source_feature_map = Self :: build_s2n_bignum_source_feature_map ( ) ;
440458 let compiler_features = self . compiler_features . take ( ) ;
441459 for source in sources {
@@ -470,6 +488,8 @@ impl CcBuilder {
470488 }
471489 } else if is_jitter_entropy {
472490 jitter_entropy_builder. file ( source_path) ;
491+ } else if source_path. extension ( ) == Some ( "asm" . as_ref ( ) ) {
492+ nasm_builder. file ( source_path) ;
473493 } else {
474494 cc_build. file ( source_path) ;
475495 }
@@ -483,6 +503,10 @@ impl CcBuilder {
483503 for object in jitter_entropy_object_files {
484504 cc_build. object ( object) ;
485505 }
506+ let nasm_object_files = nasm_builder. compile_intermediates ( ) ;
507+ for object in nasm_object_files {
508+ cc_build. object ( object) ;
509+ }
486510 cc_build. file ( PathBuf :: from_str ( "rust_wrapper.c" ) . unwrap ( ) ) ;
487511 }
488512
0 commit comments