@@ -2,7 +2,6 @@ use itertools::Itertools;
2
2
use rayon:: prelude:: * ;
3
3
use std:: collections:: BTreeMap ;
4
4
use std:: fs:: File ;
5
- use std:: io:: Write ;
6
5
use std:: process:: Command ;
7
6
8
7
use super :: argument:: Argument ;
@@ -23,8 +22,8 @@ pub fn format_rust_main_template(
23
22
) -> String {
24
23
format ! (
25
24
r#"{notices}#![feature(simd_ffi)]
26
- #![feature(link_llvm_intrinsics)]
27
25
#![feature(f16)]
26
+ #![allow(unused)]
28
27
{configurations}
29
28
{definitions}
30
29
@@ -38,75 +37,75 @@ fn main() {{
38
37
)
39
38
}
40
39
40
+ fn write_cargo_toml ( w : & mut impl std:: io:: Write , binaries : & [ String ] ) -> std:: io:: Result < ( ) > {
41
+ writeln ! (
42
+ w,
43
+ concat!(
44
+ "[package]\n " ,
45
+ "name = \" intrinsic-test-programs\" \n " ,
46
+ "version = \" {version}\" \n " ,
47
+ "authors = [{authors}]\n " ,
48
+ "license = \" {license}\" \n " ,
49
+ "edition = \" 2018\" \n " ,
50
+ "[workspace]\n " ,
51
+ "[dependencies]\n " ,
52
+ "core_arch = {{ path = \" ../crates/core_arch\" }}" ,
53
+ ) ,
54
+ version = env!( "CARGO_PKG_VERSION" ) ,
55
+ authors = env!( "CARGO_PKG_AUTHORS" )
56
+ . split( ":" )
57
+ . format_with( ", " , |author, fmt| fmt( & format_args!( "\" {author}\" " ) ) ) ,
58
+ license = env!( "CARGO_PKG_LICENSE" ) ,
59
+ ) ?;
60
+
61
+ for binary in binaries {
62
+ writeln ! (
63
+ w,
64
+ concat!(
65
+ "[[bin]]\n " ,
66
+ "name = \" {binary}\" \n " ,
67
+ "path = \" {binary}/main.rs\" \n " ,
68
+ ) ,
69
+ binary = binary,
70
+ ) ?;
71
+ }
72
+
73
+ Ok ( ( ) )
74
+ }
75
+
41
76
pub fn compile_rust_programs (
42
77
binaries : Vec < String > ,
43
78
toolchain : Option < & str > ,
44
79
target : & str ,
45
80
linker : Option < & str > ,
46
81
) -> bool {
47
82
let mut cargo = File :: create ( "rust_programs/Cargo.toml" ) . unwrap ( ) ;
48
- cargo
49
- . write_all (
50
- format ! (
51
- r#"[package]
52
- name = "intrinsic-test-programs"
53
- version = "{version}"
54
- authors = [{authors}]
55
- license = "{license}"
56
- edition = "2018"
57
- [workspace]
58
- [dependencies]
59
- core_arch = {{ path = "../crates/core_arch" }}
60
- {binaries}"# ,
61
- version = env!( "CARGO_PKG_VERSION" ) ,
62
- authors = env!( "CARGO_PKG_AUTHORS" )
63
- . split( ":" )
64
- . format_with( ", " , |author, fmt| fmt( & format_args!( "\" {author}\" " ) ) ) ,
65
- license = env!( "CARGO_PKG_LICENSE" ) ,
66
- binaries = binaries
67
- . iter( )
68
- . map( |binary| {
69
- format!(
70
- r#"[[bin]]
71
- name = "{binary}"
72
- path = "{binary}/main.rs""# ,
73
- )
74
- } )
75
- . collect:: <Vec <_>>( )
76
- . join( "\n " )
77
- )
78
- . into_bytes ( )
79
- . as_slice ( ) ,
80
- )
81
- . unwrap ( ) ;
82
-
83
- let toolchain = match toolchain {
84
- None => return true ,
85
- Some ( t) => t,
86
- } ;
83
+ write_cargo_toml ( & mut cargo, & binaries) . unwrap ( ) ;
87
84
88
85
/* If there has been a linker explicitly set from the command line then
89
86
* we want to set it via setting it in the RUSTFLAGS*/
90
87
91
- let cargo_command = format ! ( "cargo {toolchain} build --target {target} --release" ) ;
88
+ let mut cargo_command = Command :: new ( "cargo" ) ;
89
+ cargo_command. current_dir ( "rust_programs" ) ;
92
90
93
- let mut command = Command :: new ( "sh" ) ;
94
- command
95
- . current_dir ( "rust_programs" )
96
- . arg ( "-c" )
97
- . arg ( cargo_command) ;
91
+ if let Some ( toolchain) = toolchain {
92
+ if !toolchain. is_empty ( ) {
93
+ cargo_command. arg ( toolchain) ;
94
+ }
95
+ }
96
+ cargo_command. args ( [ "build" , "--target" , target, "--release" ] ) ;
98
97
99
98
let mut rust_flags = "-Cdebuginfo=0" . to_string ( ) ;
100
99
if let Some ( linker) = linker {
101
100
rust_flags. push_str ( " -C linker=" ) ;
102
101
rust_flags. push_str ( linker) ;
103
102
rust_flags. push_str ( " -C link-args=-static" ) ;
104
103
105
- command . env ( "CPPFLAGS" , "-fuse-ld=lld" ) ;
104
+ cargo_command . env ( "CPPFLAGS" , "-fuse-ld=lld" ) ;
106
105
}
107
106
108
- command . env ( "RUSTFLAGS" , rust_flags) ;
109
- let output = command . output ( ) ;
107
+ cargo_command . env ( "RUSTFLAGS" , rust_flags) ;
108
+ let output = cargo_command . output ( ) ;
110
109
111
110
if let Ok ( output) = output {
112
111
if output. status . success ( ) {
0 commit comments