From 6d7644a9b1ab57f537e774c0d66b39b773674cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 6 Aug 2025 15:27:57 +0200 Subject: [PATCH 1/2] Fix rebuilding mono aot cross compiler when building locally This is a side-effect of the changes made in https://github.com/dotnet/runtime/pull/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. --- src/mono/mono/offsets/offsets-tool.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/offsets/offsets-tool.py b/src/mono/mono/offsets/offsets-tool.py index c91f96f4cfd68f..0bd2e95733c08d 100644 --- a/src/mono/mono/offsets/offsets-tool.py +++ b/src/mono/mono/offsets/offsets-tool.py @@ -373,11 +373,7 @@ def gen (self): outfile = self.args.outfile validate_outfile = self.args.validate_outfile target = self.target - - if validate_outfile: - f = ComparableFile () - else: - f = open (outfile, 'w') + f = ComparableFile () f.write ("#ifndef USED_CROSS_COMPILER_OFFSETS\n") if target.arch_define: @@ -435,9 +431,18 @@ def gen (self): f.write ("#endif //USED_CROSS_COMPILER_OFFSETS check\n") f.close () - if validate_outfile and f.compare (outfile): - print ("Offsets file has changed.", file=sys.stderr) - f.dump (outfile + ".new") + if os.path.isfile (outfile): + if f.compare (outfile): + if validate_outfile: + print ("Offsets file has changed, writing new offsets to " + outfile + ".new", file=sys.stderr) + f.dump (outfile + ".new") + else: + print ("Offsets file has changed, updating " + outfile) + f.dump (outfile) + else: + print ("Offsets file is up to date, no changes to " + outfile) + else: + f.dump (outfile) tool = OffsetsTool () tool.parse_args () From e9c336ae1b91eec2c9221fc5fc4ae6fae09ef370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 6 Aug 2025 15:33:41 +0200 Subject: [PATCH 2/2] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/mono/mono/offsets/offsets-tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/offsets/offsets-tool.py b/src/mono/mono/offsets/offsets-tool.py index 0bd2e95733c08d..05fe89fc6297b0 100644 --- a/src/mono/mono/offsets/offsets-tool.py +++ b/src/mono/mono/offsets/offsets-tool.py @@ -440,7 +440,7 @@ def gen (self): print ("Offsets file has changed, updating " + outfile) f.dump (outfile) else: - print ("Offsets file is up to date, no changes to " + outfile) + print ("Offsets file is up to date, no changes to " + outfile) else: f.dump (outfile)