From 52a4bd2be072bafec29a45d15877bf168b1ccc61 Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Wed, 19 Jan 2022 23:35:46 +0700 Subject: [PATCH] Apply upstream patch to improve crashpad goma cachehits. https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3394052 --- ...ashpad-crashpad-util-mach-mig_fix.py.patch | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 patches/third_party-crashpad-crashpad-util-mach-mig_fix.py.patch diff --git a/patches/third_party-crashpad-crashpad-util-mach-mig_fix.py.patch b/patches/third_party-crashpad-crashpad-util-mach-mig_fix.py.patch new file mode 100644 index 00000000000..bfc3daf09fa --- /dev/null +++ b/patches/third_party-crashpad-crashpad-util-mach-mig_fix.py.patch @@ -0,0 +1,76 @@ +diff --git a/third_party/crashpad/crashpad/util/mach/mig_fix.py b/third_party/crashpad/crashpad/util/mach/mig_fix.py +index 037746fac3bb8eda68a04ba0af5707e7025e547f..6e2877136a9e9312e28341a603e3e66d78a1ac31 100755 +--- a/third_party/crashpad/crashpad/util/mach/mig_fix.py ++++ b/third_party/crashpad/crashpad/util/mach/mig_fix.py +@@ -23,6 +23,33 @@ import sys + from mig_gen import MigInterface + + ++def _make_generated_comments_deterministic(contents): ++ """Replaces generated code comments with determenistic ones. ++ ++ This is what is generated by mig (only in .c files): ++ /* ++ * IDENTIFICATION: ++ * stub generated Mon Jan 17 15:28:03 2022 ++ * with a MiG generated by bootstrap_cmds-122 ++ * OPTIONS: ++ */ ++ ++ We look for two specific lines and replace them like so: ++ /* ++ * IDENTIFICATION: ++ * stub generated ++ * with a MiG generated by ++ * OPTIONS: ++ */ ++ """ ++ ++ return re.sub(r'^( \* (?:stub generated|with a MiG generated by) ).+$', ++ r'\1', ++ contents, ++ count=2, ++ flags=re.MULTILINE) ++ ++ + def _fix_user_implementation(implementation, fixed_implementation, header, + fixed_header): + """Rewrites a MIG-generated user implementation (.c) file. +@@ -33,7 +60,8 @@ def _fix_user_implementation(implementation, fixed_implementation, header, + unused in the user implementation file, and this will trigger a + -Wunused-local-typedefs warning in gcc unless removed or marked with the + “unused” attribute. Also changes header references to point to the new +- header filename, if changed. ++ header filename, if changed. Replaces generated code comments with ++ deterministic ones. + + If |fixed_implementation| is None, overwrites the original; otherwise, puts + the result in the file at |fixed_implementation|. +@@ -50,6 +78,9 @@ def _fix_user_implementation(implementation, fixed_implementation, header, + '#include "%s"' % os.path.basename(header), + '#include "%s"' % os.path.basename(fixed_header)) + ++ # Replace generated code comments with determenistic ones. ++ contents = _make_generated_comments_deterministic(contents) ++ + if fixed_implementation is None: + file.seek(0) + file.truncate() +@@ -71,6 +102,7 @@ def _fix_server_implementation(implementation, fixed_implementation, header, + added to a header file, so that other files that include that header file + will have access to these declarations from a compilation perspective. Also + changes header references to point to the new header filename, if changed. ++ Replaces generated code comments with deterministic ones. + + If |fixed_implementation| is None or not provided, overwrites the original; + otherwise, puts the result in the file at |fixed_implementation|. +@@ -117,6 +149,9 @@ extern + '#include "%s"' % os.path.basename(header), + '#include "%s"' % os.path.basename(fixed_header)) + ++ # Replace generated code comments with determenistic ones. ++ contents = _make_generated_comments_deterministic(contents) ++ + if fixed_implementation is None: + file.seek(0) + file.truncate()