@@ -4,6 +4,29 @@ use std::fmt::Display;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
use std:: process:: { Command , Stdio } ;
6
6
7
+ const OPTIONAL_COMPONENTS : & [ & str ] = & [
8
+ "x86" ,
9
+ "arm" ,
10
+ "aarch64" ,
11
+ "amdgpu" ,
12
+ "avr" ,
13
+ "m68k" ,
14
+ "mips" ,
15
+ "powerpc" ,
16
+ "systemz" ,
17
+ "jsbackend" ,
18
+ "webassembly" ,
19
+ "msp430" ,
20
+ "sparc" ,
21
+ "nvptx" ,
22
+ "hexagon" ,
23
+ "riscv" ,
24
+ "bpf" ,
25
+ ] ;
26
+
27
+ const REQUIRED_COMPONENTS : & [ & str ] =
28
+ & [ "ipo" , "bitreader" , "bitwriter" , "linker" , "asmparser" , "lto" , "coverage" , "instrumentation" ] ;
29
+
7
30
fn detect_llvm_link ( ) -> ( & ' static str , & ' static str ) {
8
31
// Force the link mode we want, preferring static by default, but
9
32
// possibly overridden by `configure --enable-llvm-link-shared`.
@@ -76,6 +99,10 @@ fn output(cmd: &mut Command) -> String {
76
99
}
77
100
78
101
fn main ( ) {
102
+ for component in REQUIRED_COMPONENTS . iter ( ) . chain ( OPTIONAL_COMPONENTS . iter ( ) ) {
103
+ println ! ( "cargo:rustc-check-cfg=values(llvm_component,\" {}\" )" , component) ;
104
+ }
105
+
79
106
if tracked_env_var_os ( "RUST_CHECK" ) . is_some ( ) {
80
107
// If we're just running `check`, there's no need for LLVM to be built.
81
108
return ;
@@ -131,42 +158,11 @@ fn main() {
131
158
let host = env:: var ( "HOST" ) . expect ( "HOST was not set" ) ;
132
159
let is_crossed = target != host;
133
160
134
- let optional_components = & [
135
- "x86" ,
136
- "arm" ,
137
- "aarch64" ,
138
- "amdgpu" ,
139
- "avr" ,
140
- "m68k" ,
141
- "mips" ,
142
- "powerpc" ,
143
- "systemz" ,
144
- "jsbackend" ,
145
- "webassembly" ,
146
- "msp430" ,
147
- "sparc" ,
148
- "nvptx" ,
149
- "hexagon" ,
150
- "riscv" ,
151
- "bpf" ,
152
- ] ;
153
-
154
- let required_components = & [
155
- "ipo" ,
156
- "bitreader" ,
157
- "bitwriter" ,
158
- "linker" ,
159
- "asmparser" ,
160
- "lto" ,
161
- "coverage" ,
162
- "instrumentation" ,
163
- ] ;
164
-
165
161
let components = output ( Command :: new ( & llvm_config) . arg ( "--components" ) ) ;
166
162
let mut components = components. split_whitespace ( ) . collect :: < Vec < _ > > ( ) ;
167
- components. retain ( |c| optional_components . contains ( c) || required_components . contains ( c) ) ;
163
+ components. retain ( |c| OPTIONAL_COMPONENTS . contains ( c) || REQUIRED_COMPONENTS . contains ( c) ) ;
168
164
169
- for component in required_components {
165
+ for component in REQUIRED_COMPONENTS {
170
166
if !components. contains ( component) {
171
167
panic ! ( "require llvm component {} but wasn't found" , component) ;
172
168
}
0 commit comments