@@ -9,46 +9,53 @@ use super::intrinsic_helpers::IntrinsicTypeDefinition;
9
9
// The number of times each intrinsic will be called.
10
10
const PASSES : u32 = 20 ;
11
11
12
- pub fn write_cargo_toml ( w : & mut impl std:: io:: Write , binaries : & [ String ] ) -> std:: io:: Result < ( ) > {
12
+ fn write_cargo_toml_header ( w : & mut impl std:: io:: Write , name : & str ) -> std:: io:: Result < ( ) > {
13
13
writeln ! (
14
14
w,
15
15
concat!(
16
16
"[package]\n " ,
17
- "name = \" intrinsic-test-programs \" \n " ,
17
+ "name = \" {name} \" \n " ,
18
18
"version = \" {version}\" \n " ,
19
19
"authors = [{authors}]\n " ,
20
20
"license = \" {license}\" \n " ,
21
21
"edition = \" 2018\" \n " ,
22
- "[workspace]\n " ,
23
- "[dependencies]\n " ,
24
- "core_arch = {{ path = \" ../crates/core_arch\" }}" ,
25
22
) ,
23
+ name = name,
26
24
version = env!( "CARGO_PKG_VERSION" ) ,
27
25
authors = env!( "CARGO_PKG_AUTHORS" )
28
26
. split( ":" )
29
27
. format_with( ", " , |author, fmt| fmt( & format_args!( "\" {author}\" " ) ) ) ,
30
28
license = env!( "CARGO_PKG_LICENSE" ) ,
31
- ) ?;
29
+ )
30
+ }
32
31
33
- for binary in binaries {
34
- writeln ! (
35
- w ,
36
- concat! (
37
- "[[bin]] \n " ,
38
- "name = \" {binary} \" \n " ,
39
- "path = \" {binary}/main.rs \" \n " ,
40
- ) ,
41
- binary = binary ,
42
- ) ?;
32
+ pub fn write_bin_cargo_toml (
33
+ w : & mut impl std :: io :: Write ,
34
+ module_count : usize ,
35
+ ) -> std :: io :: Result < ( ) > {
36
+ write_cargo_toml_header ( w , "intrinsic-test-programs" ) ? ;
37
+
38
+ writeln ! ( w , "[dependencies]" ) ? ;
39
+
40
+ for i in 0 ..module_count {
41
+ writeln ! ( w , "mod_{i} = {{ path = \" mod_{i}/ \" }}" ) ?;
43
42
}
44
43
45
44
Ok ( ( ) )
46
45
}
47
46
47
+ pub fn write_lib_cargo_toml ( w : & mut impl std:: io:: Write , name : & str ) -> std:: io:: Result < ( ) > {
48
+ write_cargo_toml_header ( w, name) ?;
49
+
50
+ writeln ! ( w, "[dependencies]" ) ?;
51
+ writeln ! ( w, "core_arch = {{ path = \" ../../crates/core_arch\" }}" ) ?;
52
+
53
+ Ok ( ( ) )
54
+ }
55
+
48
56
pub fn write_main_rs < ' a > (
49
57
w : & mut impl std:: io:: Write ,
50
- available_parallelism : usize ,
51
- architecture : & str ,
58
+ chunk_count : usize ,
52
59
cfg : & str ,
53
60
definitions : & str ,
54
61
intrinsics : impl Iterator < Item = & ' a str > + Clone ,
@@ -65,10 +72,7 @@ pub fn write_main_rs<'a>(
65
72
writeln ! ( w, "{cfg}" ) ?;
66
73
writeln ! ( w, "{definitions}" ) ?;
67
74
68
- writeln ! ( w, "use core_arch::arch::{architecture}::*;" ) ?;
69
-
70
- for module in 0 ..Ord :: min ( available_parallelism, intrinsics. clone ( ) . count ( ) ) {
71
- writeln ! ( w, "mod mod_{module};" ) ?;
75
+ for module in 0 ..chunk_count {
72
76
writeln ! ( w, "use mod_{module}::*;" ) ?;
73
77
}
74
78
@@ -91,6 +95,38 @@ pub fn write_main_rs<'a>(
91
95
Ok ( ( ) )
92
96
}
93
97
98
+ pub fn write_lib_rs < T : IntrinsicTypeDefinition > (
99
+ w : & mut impl std:: io:: Write ,
100
+ architecture : & str ,
101
+ notice : & str ,
102
+ cfg : & str ,
103
+ definitions : & str ,
104
+ intrinsics : & [ impl IntrinsicDefinition < T > ] ,
105
+ ) -> std:: io:: Result < ( ) > {
106
+ write ! ( w, "{notice}" ) ?;
107
+
108
+ writeln ! ( w, "#![feature(simd_ffi)]" ) ?;
109
+ writeln ! ( w, "#![feature(f16)]" ) ?;
110
+ writeln ! ( w, "#![allow(unused)]" ) ?;
111
+
112
+ // Cargo will spam the logs if these warnings are not silenced.
113
+ writeln ! ( w, "#![allow(non_upper_case_globals)]" ) ?;
114
+ writeln ! ( w, "#![allow(non_camel_case_types)]" ) ?;
115
+ writeln ! ( w, "#![allow(non_snake_case)]" ) ?;
116
+
117
+ writeln ! ( w, "{cfg}" ) ?;
118
+
119
+ writeln ! ( w, "use core_arch::arch::{architecture}::*;" ) ?;
120
+
121
+ writeln ! ( w, "{definitions}" ) ?;
122
+
123
+ for intrinsic in intrinsics {
124
+ crate :: common:: gen_rust:: create_rust_test_module ( w, intrinsic) ?;
125
+ }
126
+
127
+ Ok ( ( ) )
128
+ }
129
+
94
130
pub fn compile_rust_programs ( toolchain : Option < & str > , target : & str , linker : Option < & str > ) -> bool {
95
131
/* If there has been a linker explicitly set from the command line then
96
132
* we want to set it via setting it in the RUSTFLAGS*/
@@ -100,6 +136,9 @@ pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Opti
100
136
let mut cargo_command = Command :: new ( "cargo" ) ;
101
137
cargo_command. current_dir ( "rust_programs" ) ;
102
138
139
+ // Do not use the target directory of the workspace please.
140
+ cargo_command. env ( "CARGO_TARGET_DIR" , "target" ) ;
141
+
103
142
if let Some ( toolchain) = toolchain
104
143
&& !toolchain. is_empty ( )
105
144
{
0 commit comments