Repository: electron/electron (language: cpp)

Issue:
[Bug]: mksnapshot args shipped with v21 doen't work properly
### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

21.2.2

### What operating system are you using?

macOS

### Operating System Version

13

### What arch are you using?

arm64 (including Apple Silicon)

### Last Known Working Electron version

20.3.4

### Expected Behavior

Running mksnapshot works normally.

### Actual Behavior

It fails.
It succeeds if I remove
```
--turbo-profiling-input
../../v8/tools/builtins-pgo/arm64.profile
```
from the `mksnapshot_args` file.

I'm not able to find this `arm64.profile` file anywhere to try and build with it being present. (the path mentioned is two levels up, so I'm guessing it is somehow missed while creating the zip and relative path ends up here)

### Testcase Gist URL

_No response_

### Additional Information

Contents of the mksnapshot_args file across recent versions

![Screenshot 2022-11-10 at 20 26 02](https://user-images.githubusercontent.com/16598275/201139071-2178ce68-160a-4d64-8fa0-f37bf2350302.png)


Note: I'm running mksnapshot via electron-mksnapshot


Discussion / hints:

Fix patch:
diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml
index 368fc15d6ee17..bfd6567296d58 100644
--- a/.circleci/config/base.yml
+++ b/.circleci/config/base.yml
@@ -701,6 +701,13 @@ step-mksnapshot-build: &step-mksnapshot-build
       if [ "$USE_PREBUILT_V8_CONTEXT_SNAPSHOT" != "1" ]; then
         ninja -C out/Default electron:electron_mksnapshot -j $NUMBER_OF_NINJA_PROCESSES
         gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args
+        # Remove unused args from mksnapshot_args
+        SEDOPTION=
+        if [ "`uname`" == "Darwin" ]; then
+          SEDOPTION="-i ''"
+        fi
+        sed $SEDOPTION '/.*builtins-pgo/d' out/Default/mksnapshot_args
+        sed $SEDOPTION '/--turbo-profiling-input/d' out/Default/mksnapshot_args
       fi
       if [ "`uname`" != "Darwin" ]; then
         if [ "$TARGET_ARCH" == "arm" ]; then
@@ -1216,6 +1223,13 @@ commands:
               ninja -C out/Default electron:electron_mksnapshot_zip -j $NUMBER_OF_NINJA_PROCESSES
               ninja -C out/Default tools/v8_context_snapshot -j $NUMBER_OF_NINJA_PROCESSES
               gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args
+              # Remove unused args from mksnapshot_args
+              SEDOPTION=
+              if [ "`uname`" == "Darwin" ]; then
+                SEDOPTION="-i ''"
+              fi
+              sed $SEDOPTION '/.*builtins-pgo/d' out/Default/mksnapshot_args
+              sed $SEDOPTION '/--turbo-profiling-input/d' out/Default/mksnapshot_args
               (cd out/Default; zip mksnapshot.zip mksnapshot_args clang_x64_v8_arm64/gen/v8/embedded.S)
               if [ "<< parameters.clean-prebuilt-snapshot >>" == "true" ]; then
                 rm -rf out/Default/clang_x64_v8_arm64/gen
diff --git a/appveyor.yml b/appveyor.yml
index 914b9f88266cf..86dcc96ea8a45 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -179,7 +179,11 @@ for:
     - ninja -C out/ffmpeg electron:electron_ffmpeg_zip
     - ninja -C out/Default electron:electron_dist_zip
     - ninja -C out/Default shell_browser_ui_unittests
-    - gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args
+    - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
+    - ps: >-
+        # Remove unused args from mksnapshot_args
+
+        Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args
     - ninja -C out/Default electron:electron_mksnapshot_zip
     - cd out\Default
     - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
@@ -190,7 +194,6 @@ for:
     - python %LOCAL_GOMA_DIR%\goma_ctl.py stat
     - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
     - 7z a node_headers.zip out\Default\gen\node_headers
-    - 7z a builtins-pgo.zip v8\tools\builtins-pgo
     - ps: >-
         if ($env:GN_CONFIG -eq 'release') {
           # Needed for msdia140.dll on 64-bit windows
@@ -235,7 +238,6 @@ for:
       - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
       - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
       - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
-      - if exist builtins-pgo.zip (appveyor-retry appveyor PushArtifact builtins-pgo.zip)
       - ps: >-
           if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
             appveyor-retry appveyor PushArtifact pdb.zip
@@ -269,7 +271,7 @@ for:
         # Download build artifacts
         $apiUrl = 'https://ci.appveyor.com/api'             
         $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
-        $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','builtins-pgo.zip')
+        $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
         foreach ($job in $build_info.build.jobs) {
           if ($job.name -eq "Build") {
             $jobId = $job.jobId
@@ -290,7 +292,6 @@ for:
         }
     - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
     - ps: 7z x -y -osrc node_headers.zip
-    - ps: 7z x -y -osrc builtins-pgo.zip
 
     test_script:
       # Workaround for https://github.com/appveyor/ci/issues/2420


Test patch: