Skip to content

Commit f23d779

Browse files
akoeplingerCopilot
andauthored
Fix rebuilding mono aot cross compiler when building locally (#118445)
* Fix rebuilding mono aot cross compiler when building locally This is a side-effect of the changes made in #109612. When we do rerun the offsets generation script locally it causes the file to be touched even if it's identical, which in turn causes the whole aot cross compiler binary to be rebuilt. To fix this only write to the output offsets file when it actually changed. * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 4bbd32d commit f23d779

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/mono/mono/offsets/offsets-tool.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,7 @@ def gen (self):
373373
outfile = self.args.outfile
374374
validate_outfile = self.args.validate_outfile
375375
target = self.target
376-
377-
if validate_outfile:
378-
f = ComparableFile ()
379-
else:
380-
f = open (outfile, 'w')
376+
f = ComparableFile ()
381377

382378
f.write ("#ifndef USED_CROSS_COMPILER_OFFSETS\n")
383379
if target.arch_define:
@@ -435,9 +431,18 @@ def gen (self):
435431
f.write ("#endif //USED_CROSS_COMPILER_OFFSETS check\n")
436432
f.close ()
437433

438-
if validate_outfile and f.compare (outfile):
439-
print ("Offsets file has changed.", file=sys.stderr)
440-
f.dump (outfile + ".new")
434+
if os.path.isfile (outfile):
435+
if f.compare (outfile):
436+
if validate_outfile:
437+
print ("Offsets file has changed, writing new offsets to " + outfile + ".new", file=sys.stderr)
438+
f.dump (outfile + ".new")
439+
else:
440+
print ("Offsets file has changed, updating " + outfile)
441+
f.dump (outfile)
442+
else:
443+
print ("Offsets file is up to date, no changes to " + outfile)
444+
else:
445+
f.dump (outfile)
441446

442447
tool = OffsetsTool ()
443448
tool.parse_args ()

0 commit comments

Comments
 (0)