1
+ use crate :: common:: cli:: ProcessedCli ;
1
2
use crate :: common:: compile_c:: CompilationCommandBuilder ;
2
3
use crate :: common:: gen_c:: compile_c_programs;
3
4
4
- pub fn compile_c_arm (
5
- intrinsics_name_list : & [ String ] ,
6
- compiler : & str ,
7
- target : & str ,
8
- cxx_toolchain_dir : Option < & str > ,
9
- ) -> bool {
5
+ pub fn compile_c_arm ( config : & ProcessedCli , intrinsics_name_list : & [ String ] ) -> bool {
6
+ let Some ( ref cpp_compiler) = config. cpp_compiler else {
7
+ return true ;
8
+ } ;
9
+
10
10
// -ffp-contract=off emulates Rust's approach of not fusing separate mul-add operations
11
11
let mut command = CompilationCommandBuilder :: new ( )
12
12
. add_arch_flags ( vec ! [ "armv8.6-a" , "crypto" , "crc" , "dotprod" , "fp16" ] )
13
- . set_compiler ( compiler )
14
- . set_target ( target)
13
+ . set_compiler ( cpp_compiler )
14
+ . set_target ( & config . target )
15
15
. set_opt_level ( "2" )
16
- . set_cxx_toolchain_dir ( cxx_toolchain_dir)
16
+ . set_cxx_toolchain_dir ( config . cxx_toolchain_dir . as_deref ( ) )
17
17
. set_project_root ( "c_programs" )
18
18
. add_extra_flags ( vec ! [ "-ffp-contract=off" , "-Wno-narrowing" ] ) ;
19
19
20
- if !target. contains ( "v7" ) {
20
+ if !config . target . contains ( "v7" ) {
21
21
command = command. add_arch_flags ( vec ! [ "faminmax" , "lut" , "sha3" ] ) ;
22
22
}
23
23
@@ -30,22 +30,33 @@ pub fn compile_c_arm(
30
30
* does not work as it gets caught up with `#include_next <stdlib.h>`
31
31
* not existing...
32
32
*/
33
- if target. contains ( "aarch64_be" ) {
34
- command = command
35
- . set_linker (
36
- cxx_toolchain_dir. unwrap_or ( "" ) . to_string ( ) + "/bin/aarch64_be-none-linux-gnu-g++" ,
33
+ if config. target . contains ( "aarch64_be" ) {
34
+ let Some ( ref cxx_toolchain_dir) = config. cxx_toolchain_dir else {
35
+ panic ! (
36
+ "target `{}` must specify `cxx_toolchain_dir`" ,
37
+ config. target
37
38
)
38
- . set_include_paths ( vec ! [
39
- "/include" ,
40
- "/aarch64_be-none-linux-gnu/include" ,
41
- "/aarch64_be-none-linux-gnu/include/c++/14.2.1" ,
42
- "/aarch64_be-none-linux-gnu/include/c++/14.2.1/aarch64_be-none-linux-gnu" ,
43
- "/aarch64_be-none-linux-gnu/include/c++/14.2.1/backward" ,
44
- "/aarch64_be-none-linux-gnu/libc/usr/include" ,
45
- ] ) ;
39
+ } ;
40
+
41
+ let linker = if let Some ( ref linker) = config. linker {
42
+ linker. to_owned ( )
43
+ } else {
44
+ format ! ( "{cxx_toolchain_dir}/bin/aarch64_be-none-linux-gnu-g++" )
45
+ } ;
46
+
47
+ trace ! ( "using linker: {linker}" ) ;
48
+
49
+ command = command. set_linker ( linker) . set_include_paths ( vec ! [
50
+ "/include" ,
51
+ "/aarch64_be-none-linux-gnu/include" ,
52
+ "/aarch64_be-none-linux-gnu/include/c++/14.2.1" ,
53
+ "/aarch64_be-none-linux-gnu/include/c++/14.2.1/aarch64_be-none-linux-gnu" ,
54
+ "/aarch64_be-none-linux-gnu/include/c++/14.2.1/backward" ,
55
+ "/aarch64_be-none-linux-gnu/libc/usr/include" ,
56
+ ] ) ;
46
57
}
47
58
48
- if !compiler . contains ( "clang" ) {
59
+ if !cpp_compiler . contains ( "clang" ) {
49
60
command = command. add_extra_flag ( "-flax-vector-conversions" ) ;
50
61
}
51
62
0 commit comments