@@ -140,48 +140,58 @@ pub fn std_cargo(build: &Builder,
140
140
compiler : & Compiler ,
141
141
target : Interned < String > ,
142
142
cargo : & mut Command ) {
143
- let mut features = build. std_features ( ) ;
144
-
145
143
if let Some ( target) = env:: var_os ( "MACOSX_STD_DEPLOYMENT_TARGET" ) {
146
144
cargo. env ( "MACOSX_DEPLOYMENT_TARGET" , target) ;
147
145
}
148
146
149
- // When doing a local rebuild we tell cargo that we're stage1 rather than
150
- // stage0. This works fine if the local rust and being-built rust have the
151
- // same view of what the default allocator is, but fails otherwise. Since
152
- // we don't have a way to express an allocator preference yet, work
153
- // around the issue in the case of a local rebuild with jemalloc disabled.
154
- if compiler. stage == 0 && build. local_rebuild && !build. config . use_jemalloc {
155
- features. push_str ( " force_alloc_system" ) ;
156
- }
147
+ if build. no_std ( target) == Some ( true ) {
148
+ // for no-std targets we only compile a few no_std crates
149
+ cargo. arg ( "--features" ) . arg ( "c mem" )
150
+ . args ( & [ "-p" , "alloc" ] )
151
+ . args ( & [ "-p" , "compiler_builtins" ] )
152
+ . args ( & [ "-p" , "std_unicode" ] )
153
+ . arg ( "--manifest-path" )
154
+ . arg ( build. src . join ( "src/rustc/compiler_builtins_shim/Cargo.toml" ) ) ;
155
+ } else {
156
+ let mut features = build. std_features ( ) ;
157
+
158
+ // When doing a local rebuild we tell cargo that we're stage1 rather than
159
+ // stage0. This works fine if the local rust and being-built rust have the
160
+ // same view of what the default allocator is, but fails otherwise. Since
161
+ // we don't have a way to express an allocator preference yet, work
162
+ // around the issue in the case of a local rebuild with jemalloc disabled.
163
+ if compiler. stage == 0 && build. local_rebuild && !build. config . use_jemalloc {
164
+ features. push_str ( " force_alloc_system" ) ;
165
+ }
157
166
158
- if compiler. stage != 0 && build. config . sanitizers {
159
- // This variable is used by the sanitizer runtime crates, e.g.
160
- // rustc_lsan, to build the sanitizer runtime from C code
161
- // When this variable is missing, those crates won't compile the C code,
162
- // so we don't set this variable during stage0 where llvm-config is
163
- // missing
164
- // We also only build the runtimes when --enable-sanitizers (or its
165
- // config.toml equivalent) is used
166
- let llvm_config = build. ensure ( native:: Llvm {
167
- target : build. config . build ,
168
- emscripten : false ,
169
- } ) ;
170
- cargo. env ( "LLVM_CONFIG" , llvm_config) ;
171
- }
167
+ if compiler. stage != 0 && build. config . sanitizers {
168
+ // This variable is used by the sanitizer runtime crates, e.g.
169
+ // rustc_lsan, to build the sanitizer runtime from C code
170
+ // When this variable is missing, those crates won't compile the C code,
171
+ // so we don't set this variable during stage0 where llvm-config is
172
+ // missing
173
+ // We also only build the runtimes when --enable-sanitizers (or its
174
+ // config.toml equivalent) is used
175
+ let llvm_config = build. ensure ( native:: Llvm {
176
+ target : build. config . build ,
177
+ emscripten : false ,
178
+ } ) ;
179
+ cargo. env ( "LLVM_CONFIG" , llvm_config) ;
180
+ }
172
181
173
- cargo. arg ( "--features" ) . arg ( features)
174
- . arg ( "--manifest-path" )
175
- . arg ( build. src . join ( "src/libstd/Cargo.toml" ) ) ;
182
+ cargo. arg ( "--features" ) . arg ( features)
183
+ . arg ( "--manifest-path" )
184
+ . arg ( build. src . join ( "src/libstd/Cargo.toml" ) ) ;
176
185
177
- if let Some ( target) = build. config . target_config . get ( & target) {
178
- if let Some ( ref jemalloc) = target. jemalloc {
179
- cargo. env ( "JEMALLOC_OVERRIDE" , jemalloc) ;
186
+ if let Some ( target) = build. config . target_config . get ( & target) {
187
+ if let Some ( ref jemalloc) = target. jemalloc {
188
+ cargo. env ( "JEMALLOC_OVERRIDE" , jemalloc) ;
189
+ }
180
190
}
181
- }
182
- if target . contains ( "musl" ) {
183
- if let Some ( p ) = build . musl_root ( target ) {
184
- cargo . env ( "MUSL_ROOT" , p ) ;
191
+ if target . contains ( "musl" ) {
192
+ if let Some ( p ) = build . musl_root ( target ) {
193
+ cargo . env ( "MUSL_ROOT" , p ) ;
194
+ }
185
195
}
186
196
}
187
197
}
0 commit comments