@@ -11,7 +11,6 @@ use crate::common::intrinsic_types::IntrinsicTypeDefinition;
1111use crate :: common:: write_file;
1212use itertools:: Itertools ;
1313use rayon:: prelude:: * ;
14- use std:: collections:: BTreeMap ;
1514
1615// The number of times each intrinsic will be called.
1716const PASSES : u32 = 20 ;
@@ -162,11 +161,11 @@ fn generate_rust_program_arm(
162161
163162fn compile_c_arm (
164163 intrinsics_name_list : & Vec < String > ,
165- _filename_mapping : BTreeMap < & String , String > ,
166164 compiler : & str ,
167165 target : & str ,
168166 cxx_toolchain_dir : Option < & str > ,
169167) -> bool {
168+ // -ffp-contract=off emulates Rust's approach of not fusing separate mul-add operations
170169 let mut command = CompilationCommandBuilder :: new ( )
171170 . add_arch_flags ( vec ! [ "armv8.6-a" , "crypto" , "crc" , "dotprod" , "fp16" ] )
172171 . set_compiler ( compiler)
@@ -180,8 +179,17 @@ fn compile_c_arm(
180179 command = command. add_arch_flags ( vec ! [ "faminmax" , "lut" , "sha3" ] ) ;
181180 }
182181
183- command = if target == "aarch64_be-unknown-linux-gnu" {
184- command
182+ /*
183+ * clang++ cannot link an aarch64_be object file, so we invoke
184+ * aarch64_be-unknown-linux-gnu's C++ linker. This ensures that we
185+ * are testing the intrinsics against LLVM.
186+ *
187+ * Note: setting `--sysroot=<...>` which is the obvious thing to do
188+ * does not work as it gets caught up with `#include_next <stdlib.h>`
189+ * not existing...
190+ */
191+ if target == "aarch64_be-unknown-linux-gnu" {
192+ command = command
185193 . set_linker (
186194 cxx_toolchain_dir. unwrap_or ( "" ) . to_string ( ) + "/bin/aarch64_be-none-linux-gnu-g++" ,
187195 )
@@ -192,14 +200,12 @@ fn compile_c_arm(
192200 "/aarch64_be-none-linux-gnu/include/c++/14.2.1/aarch64_be-none-linux-gnu" ,
193201 "/aarch64_be-none-linux-gnu/include/c++/14.2.1/backward" ,
194202 "/aarch64_be-none-linux-gnu/libc/usr/include" ,
195- ] )
196- } else {
197- if compiler. contains ( "clang" ) {
198- command. add_extra_flag ( format ! ( "-target {target}" ) . as_str ( ) )
199- } else {
200- command. add_extra_flag ( "-flax-vector-conversions" )
201- }
202- } ;
203+ ] ) ;
204+ }
205+
206+ if !compiler. contains ( "clang" ) {
207+ command = command. add_extra_flag ( "-flax-vector-conversions" ) ;
208+ }
203209
204210 let compiler_commands = intrinsics_name_list
205211 . iter ( )
@@ -237,13 +243,7 @@ pub fn build_c(
237243
238244 match compiler {
239245 None => true ,
240- Some ( compiler) => compile_c_arm (
241- & intrinsics_name_list,
242- filename_mapping,
243- compiler,
244- target,
245- cxx_toolchain_dir,
246- ) ,
246+ Some ( compiler) => compile_c_arm ( & intrinsics_name_list, compiler, target, cxx_toolchain_dir) ,
247247 }
248248}
249249
0 commit comments