@@ -67,12 +67,6 @@ fn generate_rust_program(intrinsic: &Intrinsic) -> String {
67
67
#![feature(stdsimd)]
68
68
#![allow(overflowing_literals)]
69
69
use 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
- );
76
70
77
71
fn main() {{
78
72
{passes}
@@ -86,14 +80,17 @@ fn main() {{
86
80
}
87
81
88
82
fn compile_c ( c_filename : & str , intrinsic : & Intrinsic , compiler : & str ) -> bool {
83
+ let flags = std:: env:: var ( "CPPFLAGS" ) . unwrap_or ( "" . into ( ) ) ;
84
+
89
85
let output = Command :: new ( "sh" )
90
86
. arg ( "-c" )
91
87
. 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}" ,
93
89
target = "aarch64-unknown-linux-gnu" ,
94
90
filename = c_filename,
95
91
intrinsic = intrinsic. name,
96
92
cpp = compiler,
93
+ cppflags = flags,
97
94
) )
98
95
. output ( ) ;
99
96
if let Ok ( output) = output {
@@ -182,8 +179,9 @@ path = "{intrinsic}/main.rs""#,
182
179
. current_dir ( "rust_programs" )
183
180
. arg ( "-c" )
184
181
. arg ( format ! (
185
- "cargo + {toolchain} build --release" ,
182
+ "cargo {toolchain} build --release --target {target} " ,
186
183
toolchain = toolchain,
184
+ target = "aarch64-unknown-linux-gnu" ,
187
185
) )
188
186
. output ( ) ;
189
187
if let Ok ( output) = output {
@@ -217,7 +215,6 @@ fn main() {
217
215
. arg (
218
216
Arg :: with_name ( "TOOLCHAIN" )
219
217
. takes_value ( true )
220
- . default_value ( "nightly" )
221
218
. long ( "toolchain" )
222
219
. help ( "The rust toolchain to use for building the rust code" ) ,
223
220
)
@@ -228,12 +225,21 @@ fn main() {
228
225
. long ( "cppcompiler" )
229
226
. help ( "The C++ compiler to use for compiling the c++ code" ) ,
230
227
)
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
+ )
231
234
. get_matches ( ) ;
232
235
233
236
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) ) ;
236
240
241
+ let cpp_compiler = matches. value_of ( "CPPCOMPILER" ) . unwrap ( ) ;
242
+ let c_runner = matches. value_of ( "RUNNER" ) . unwrap_or ( "" ) ;
237
243
let mut csv_reader = csv:: Reader :: from_reader ( std:: fs:: File :: open ( filename) . unwrap ( ) ) ;
238
244
239
245
let mut intrinsics = csv_reader
@@ -288,7 +294,7 @@ fn main() {
288
294
std:: process:: exit ( 3 ) ;
289
295
}
290
296
291
- if !compare_outputs ( & intrinsics, & toolchain) {
297
+ if !compare_outputs ( & intrinsics, & toolchain, & c_runner ) {
292
298
std:: process:: exit ( 1 )
293
299
}
294
300
}
@@ -299,24 +305,26 @@ enum FailureReason {
299
305
Difference ( String , String , String ) ,
300
306
}
301
307
302
- fn compare_outputs ( intrinsics : & Vec < Intrinsic > , toolchain : & str ) -> bool {
308
+ fn compare_outputs ( intrinsics : & Vec < Intrinsic > , toolchain : & str , runner : & str ) -> bool {
303
309
let intrinsics = intrinsics
304
310
. par_iter ( )
305
311
. filter_map ( |intrinsic| {
306
312
let c = Command :: new ( "sh" )
307
313
. arg ( "-c" )
308
314
. arg ( format ! (
309
- "./c_programs/{intrinsic}" ,
315
+ "{runner} ./c_programs/{intrinsic}" ,
316
+ runner = runner,
310
317
intrinsic = intrinsic. name,
311
318
) )
312
319
. output ( ) ;
313
320
let rust = Command :: new ( "sh" )
314
321
. current_dir ( "rust_programs" )
315
322
. arg ( "-c" )
316
323
. arg ( format ! (
317
- "cargo + {toolchain} run --release --bin {intrinsic}" ,
324
+ "cargo {toolchain} run --release --target {target} --bin {intrinsic}" ,
318
325
intrinsic = intrinsic. name,
319
326
toolchain = toolchain,
327
+ target = "aarch64-unknown-linux-gnu" ,
320
328
) )
321
329
. output ( ) ;
322
330
0 commit comments