@@ -82,7 +82,7 @@ use std::env;
82
82
use std:: ffi:: OsString ;
83
83
use std:: fs:: { self , File } ;
84
84
use std:: io:: Read ;
85
- use std:: path:: { Component , PathBuf , Path } ;
85
+ use std:: path:: { PathBuf , Path } ;
86
86
use std:: process:: Command ;
87
87
88
88
use build_helper:: { run_silent, run_suppressed, output, mtime} ;
@@ -285,129 +285,12 @@ impl Build {
285
285
self . verbose ( & format ! ( "auto-detected local-rebuild {}" , local_release) ) ;
286
286
self . local_rebuild = true ;
287
287
}
288
- self . verbose ( "updating submodules" ) ;
289
- self . update_submodules ( ) ;
290
288
self . verbose ( "learning about cargo" ) ;
291
289
metadata:: build ( self ) ;
292
290
293
291
step:: run ( self ) ;
294
292
}
295
293
296
- /// Updates all git submodules that we have.
297
- ///
298
- /// This will detect if any submodules are out of date an run the necessary
299
- /// commands to sync them all with upstream.
300
- fn update_submodules ( & self ) {
301
- struct Submodule < ' a > {
302
- path : & ' a Path ,
303
- state : State ,
304
- }
305
-
306
- enum State {
307
- // The submodule may have staged/unstaged changes
308
- MaybeDirty ,
309
- // Or could be initialized but never updated
310
- NotInitialized ,
311
- // The submodule, itself, has extra commits but those changes haven't been commited to
312
- // the (outer) git repository
313
- OutOfSync ,
314
- }
315
-
316
- if !self . src_is_git || !self . config . submodules {
317
- return
318
- }
319
- let git = || {
320
- let mut cmd = Command :: new ( "git" ) ;
321
- cmd. current_dir ( & self . src ) ;
322
- return cmd
323
- } ;
324
- let git_submodule = || {
325
- let mut cmd = Command :: new ( "git" ) ;
326
- cmd. current_dir ( & self . src ) . arg ( "submodule" ) ;
327
- return cmd
328
- } ;
329
-
330
- // FIXME: this takes a seriously long time to execute on Windows and a
331
- // nontrivial amount of time on Unix, we should have a better way
332
- // of detecting whether we need to run all the submodule commands
333
- // below.
334
- let out = output ( git_submodule ( ) . arg ( "status" ) ) ;
335
- let mut submodules = vec ! [ ] ;
336
- for line in out. lines ( ) {
337
- // NOTE `git submodule status` output looks like this:
338
- //
339
- // -5066b7dcab7e700844b0e2ba71b8af9dc627a59b src/liblibc
340
- // +b37ef24aa82d2be3a3cc0fe89bf82292f4ca181c src/compiler-rt (remotes/origin/..)
341
- // e058ca661692a8d01f8cf9d35939dfe3105ce968 src/jemalloc (3.6.0-533-ge058ca6)
342
- //
343
- // The first character can be '-', '+' or ' ' and denotes the `State` of the submodule
344
- // Right next to this character is the SHA-1 of the submodule HEAD
345
- // And after that comes the path to the submodule
346
- let path = Path :: new ( line[ 1 ..] . split ( ' ' ) . skip ( 1 ) . next ( ) . unwrap ( ) ) ;
347
- let state = if line. starts_with ( '-' ) {
348
- State :: NotInitialized
349
- } else if line. starts_with ( '+' ) {
350
- State :: OutOfSync
351
- } else if line. starts_with ( ' ' ) {
352
- State :: MaybeDirty
353
- } else {
354
- panic ! ( "unexpected git submodule state: {:?}" , line. chars( ) . next( ) ) ;
355
- } ;
356
-
357
- submodules. push ( Submodule { path : path, state : state } )
358
- }
359
-
360
- self . run ( git_submodule ( ) . arg ( "sync" ) ) ;
361
-
362
- for submodule in submodules {
363
- // If using llvm-root then don't touch the llvm submodule.
364
- if submodule. path . components ( ) . any ( |c| c == Component :: Normal ( "llvm" . as_ref ( ) ) ) &&
365
- self . config . target_config . get ( & self . config . build )
366
- . and_then ( |c| c. llvm_config . as_ref ( ) ) . is_some ( )
367
- {
368
- continue
369
- }
370
-
371
- if submodule. path . components ( ) . any ( |c| c == Component :: Normal ( "jemalloc" . as_ref ( ) ) ) &&
372
- !self . config . use_jemalloc
373
- {
374
- continue
375
- }
376
-
377
- // `submodule.path` is the relative path to a submodule (from the repository root)
378
- // `submodule_path` is the path to a submodule from the cwd
379
-
380
- // use `submodule.path` when e.g. executing a submodule specific command from the
381
- // repository root
382
- // use `submodule_path` when e.g. executing a normal git command for the submodule
383
- // (set via `current_dir`)
384
- let submodule_path = self . src . join ( submodule. path ) ;
385
-
386
- match submodule. state {
387
- State :: MaybeDirty => {
388
- // drop staged changes
389
- self . run ( git ( ) . current_dir ( & submodule_path)
390
- . args ( & [ "reset" , "--hard" ] ) ) ;
391
- // drops unstaged changes
392
- self . run ( git ( ) . current_dir ( & submodule_path)
393
- . args ( & [ "clean" , "-fdx" ] ) ) ;
394
- } ,
395
- State :: NotInitialized => {
396
- self . run ( git_submodule ( ) . arg ( "init" ) . arg ( submodule. path ) ) ;
397
- self . run ( git_submodule ( ) . arg ( "update" ) . arg ( submodule. path ) ) ;
398
- } ,
399
- State :: OutOfSync => {
400
- // drops submodule commits that weren't reported to the (outer) git repository
401
- self . run ( git_submodule ( ) . arg ( "update" ) . arg ( submodule. path ) ) ;
402
- self . run ( git ( ) . current_dir ( & submodule_path)
403
- . args ( & [ "reset" , "--hard" ] ) ) ;
404
- self . run ( git ( ) . current_dir ( & submodule_path)
405
- . args ( & [ "clean" , "-fdx" ] ) ) ;
406
- } ,
407
- }
408
- }
409
- }
410
-
411
294
/// Clear out `dir` if `input` is newer.
412
295
///
413
296
/// After this executes, it will also ensure that `dir` exists.
@@ -475,12 +358,30 @@ impl Build {
475
358
. env ( "RUSTDOC_REAL" , self . rustdoc ( compiler) )
476
359
. env ( "RUSTC_FLAGS" , self . rustc_flags ( target) . join ( " " ) ) ;
477
360
478
- // Tools don't get debuginfo right now, e.g. cargo and rls don't get
479
- // compiled with debuginfo.
480
361
if mode != Mode :: Tool {
481
- cargo. env ( "RUSTC_DEBUGINFO" , self . config . rust_debuginfo . to_string ( ) )
482
- . env ( "RUSTC_DEBUGINFO_LINES" , self . config . rust_debuginfo_lines . to_string ( ) )
483
- . env ( "RUSTC_FORCE_UNSTABLE" , "1" ) ;
362
+ // Tools don't get debuginfo right now, e.g. cargo and rls don't
363
+ // get compiled with debuginfo.
364
+ cargo. env ( "RUSTC_DEBUGINFO" , self . config . rust_debuginfo . to_string ( ) )
365
+ . env ( "RUSTC_DEBUGINFO_LINES" , self . config . rust_debuginfo_lines . to_string ( ) )
366
+ . env ( "RUSTC_FORCE_UNSTABLE" , "1" ) ;
367
+
368
+ // Currently the compiler depends on crates from crates.io, and
369
+ // then other crates can depend on the compiler (e.g. proc-macro
370
+ // crates). Let's say, for example that rustc itself depends on the
371
+ // bitflags crate. If an external crate then depends on the
372
+ // bitflags crate as well, we need to make sure they don't
373
+ // conflict, even if they pick the same verison of bitflags. We'll
374
+ // want to make sure that e.g. a plugin and rustc each get their
375
+ // own copy of bitflags.
376
+
377
+ // Cargo ensures that this works in general through the -C metadata
378
+ // flag. This flag will frob the symbols in the binary to make sure
379
+ // they're different, even though the source code is the exact
380
+ // same. To solve this problem for the compiler we extend Cargo's
381
+ // already-passed -C metadata flag with our own. Our rustc.rs
382
+ // wrapper around the actual rustc will detect -C metadata being
383
+ // passed and frob it with this extra string we're passing in.
384
+ cargo. env ( "RUSTC_METADATA_SUFFIX" , "rustc" ) ;
484
385
}
485
386
486
387
// Enable usage of unstable features
0 commit comments