Skip to content

Commit 4fb1458

Browse files
committed
Auto merge of #33991 - alexcrichton:rustbuild-more-clean, r=aturon
rustbuild: Clean more on `make clean` Be sure to not use the old build cache for the bootstrap build system nor the old caches of the compiler/cargo extractions (in case something went wrong). Closes #33986
2 parents 7738479 + ac19420 commit 4fb1458

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/bootstrap/bootstrap.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ def cargo_stamp(self):
182182
return os.path.join(self.bin_root(), '.cargo-stamp')
183183

184184
def rustc_out_of_date(self):
185-
if not os.path.exists(self.rustc_stamp()):
185+
if not os.path.exists(self.rustc_stamp()) or self.clean:
186186
return True
187187
with open(self.rustc_stamp(), 'r') as f:
188188
return self.stage0_rustc_date() != f.read()
189189

190190
def cargo_out_of_date(self):
191-
if not os.path.exists(self.cargo_stamp()):
191+
if not os.path.exists(self.cargo_stamp()) or self.clean:
192192
return True
193193
with open(self.cargo_stamp(), 'r') as f:
194194
return self.stage0_cargo_date() != f.read()
@@ -235,8 +235,11 @@ def exe_suffix(self):
235235
return ''
236236

237237
def build_bootstrap(self):
238+
build_dir = os.path.join(self.build_dir, "bootstrap")
239+
if self.clean and os.path.exists(build_dir):
240+
shutil.rmtree(build_dir)
238241
env = os.environ.copy()
239-
env["CARGO_TARGET_DIR"] = os.path.join(self.build_dir, "bootstrap")
242+
env["CARGO_TARGET_DIR"] = build_dir
240243
env["RUSTC"] = self.rustc()
241244
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
242245
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
@@ -340,6 +343,7 @@ def build_triple(self):
340343
def main():
341344
parser = argparse.ArgumentParser(description='Build rust')
342345
parser.add_argument('--config')
346+
parser.add_argument('--clean', action='store_true')
343347
parser.add_argument('-v', '--verbose', action='store_true')
344348

345349
args = [a for a in sys.argv if a != '-h']
@@ -352,6 +356,7 @@ def main():
352356
rb.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
353357
rb.build_dir = os.path.join(os.getcwd(), "build")
354358
rb.verbose = args.verbose
359+
rb.clean = args.clean
355360

356361
try:
357362
with open(args.config or 'config.toml') as config:

0 commit comments

Comments
 (0)