@@ -67,12 +67,6 @@ fn generate_rust_program(intrinsic: &Intrinsic) -> String {
6767#![feature(stdsimd)]
6868#![allow(overflowing_literals)]
6969use core::arch::aarch64::*;
70- #[allow(unused_macros)]
71- macro_rules! bits_to_float(
72- ($t:ty, $bits:expr) => (
73- {{ let x: $t = ::std::mem::transmute($bits); x }}
74- )
75- );
7670
7771fn main() {{
7872{passes}
@@ -86,14 +80,17 @@ fn main() {{
8680}
8781
8882fn compile_c ( c_filename : & str , intrinsic : & Intrinsic , compiler : & str ) -> bool {
83+ let flags = std:: env:: var ( "CPPFLAGS" ) . unwrap_or ( "" . into ( ) ) ;
84+
8985 let output = Command :: new ( "sh" )
9086 . arg ( "-c" )
9187 . arg ( format ! (
92- "{cpp} -Wno-narrowing -O2 -target {target} -o c_programs/{intrinsic} {filename}" ,
88+ "{cpp} {cppflags} -Wno-narrowing -O2 -target {target} -o c_programs/{intrinsic} {filename}" ,
9389 target = "aarch64-unknown-linux-gnu" ,
9490 filename = c_filename,
9591 intrinsic = intrinsic. name,
9692 cpp = compiler,
93+ cppflags = flags,
9794 ) )
9895 . output ( ) ;
9996 if let Ok ( output) = output {
@@ -182,8 +179,9 @@ path = "{intrinsic}/main.rs""#,
182179 . current_dir ( "rust_programs" )
183180 . arg ( "-c" )
184181 . arg ( format ! (
185- "cargo + {toolchain} build --release" ,
182+ "cargo {toolchain} build --release --target {target} " ,
186183 toolchain = toolchain,
184+ target = "aarch64-unknown-linux-gnu" ,
187185 ) )
188186 . output ( ) ;
189187 if let Ok ( output) = output {
@@ -217,7 +215,6 @@ fn main() {
217215 . arg (
218216 Arg :: with_name ( "TOOLCHAIN" )
219217 . takes_value ( true )
220- . default_value ( "nightly" )
221218 . long ( "toolchain" )
222219 . help ( "The rust toolchain to use for building the rust code" ) ,
223220 )
@@ -228,12 +225,21 @@ fn main() {
228225 . long ( "cppcompiler" )
229226 . help ( "The C++ compiler to use for compiling the c++ code" ) ,
230227 )
228+ . arg (
229+ Arg :: with_name ( "RUNNER" )
230+ . takes_value ( true )
231+ . long ( "runner" )
232+ . help ( "Run the C programs under emulation with this command" ) ,
233+ )
231234 . get_matches ( ) ;
232235
233236 let filename = matches. value_of ( "INPUT" ) . unwrap ( ) ;
234- let toolchain = matches. value_of ( "TOOLCHAIN" ) . unwrap ( ) ;
235- let cpp_compiler = matches. value_of ( "CPPCOMPILER" ) . unwrap ( ) ;
237+ let toolchain = matches
238+ . value_of ( "TOOLCHAIN" )
239+ . map_or ( "" . into ( ) , |t| format ! ( "+{}" , t) ) ;
236240
241+ let cpp_compiler = matches. value_of ( "CPPCOMPILER" ) . unwrap ( ) ;
242+ let c_runner = matches. value_of ( "RUNNER" ) . unwrap_or ( "" ) ;
237243 let mut csv_reader = csv:: Reader :: from_reader ( std:: fs:: File :: open ( filename) . unwrap ( ) ) ;
238244
239245 let mut intrinsics = csv_reader
@@ -288,7 +294,7 @@ fn main() {
288294 std:: process:: exit ( 3 ) ;
289295 }
290296
291- if !compare_outputs ( & intrinsics, & toolchain) {
297+ if !compare_outputs ( & intrinsics, & toolchain, & c_runner ) {
292298 std:: process:: exit ( 1 )
293299 }
294300}
@@ -299,24 +305,26 @@ enum FailureReason {
299305 Difference ( String , String , String ) ,
300306}
301307
302- fn compare_outputs ( intrinsics : & Vec < Intrinsic > , toolchain : & str ) -> bool {
308+ fn compare_outputs ( intrinsics : & Vec < Intrinsic > , toolchain : & str , runner : & str ) -> bool {
303309 let intrinsics = intrinsics
304310 . par_iter ( )
305311 . filter_map ( |intrinsic| {
306312 let c = Command :: new ( "sh" )
307313 . arg ( "-c" )
308314 . arg ( format ! (
309- "./c_programs/{intrinsic}" ,
315+ "{runner} ./c_programs/{intrinsic}" ,
316+ runner = runner,
310317 intrinsic = intrinsic. name,
311318 ) )
312319 . output ( ) ;
313320 let rust = Command :: new ( "sh" )
314321 . current_dir ( "rust_programs" )
315322 . arg ( "-c" )
316323 . arg ( format ! (
317- "cargo + {toolchain} run --release --bin {intrinsic}" ,
324+ "cargo {toolchain} run --release --target {target} --bin {intrinsic}" ,
318325 intrinsic = intrinsic. name,
319326 toolchain = toolchain,
327+ target = "aarch64-unknown-linux-gnu" ,
320328 ) )
321329 . output ( ) ;
322330
0 commit comments