Skip to content

Commit

Permalink
Fix bug with running CLT from x64 process on macOS arm64.
Browse files Browse the repository at this point in the history
  • Loading branch information
ww898 committed May 17, 2024
1 parent 10beb42 commit 06a35c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions JetBrains.Profiler.SelfApi/src/Impl/ConsoleProfiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using JetBrains.Annotations;
using JetBrains.HabitatDetector;

namespace JetBrains.Profiler.SelfApi.Impl
{
Expand All @@ -27,11 +28,18 @@ public ConsoleProfiler(string executable, string arguments, string messageServic
_presentableName = presentableName;
_isApiReady = isApiReady;

// Note(ww898): Process architecture is inherited by default in macOS ARM64. Here we turn off this behavior!!!
var isX64ProcessUnderMacOsArm64 = HabitatInfo.Platform == JetPlatform.MacOsX &&
HabitatInfo.OSArchitecture == JetArchitecture.Arm64 &&
HabitatInfo.ProcessArchitecture == JetArchitecture.X64;
var effectiveExecutable = isX64ProcessUnderMacOsArm64 ? "/usr/bin/arch" : executable;
var effectiveArguments = isX64ProcessUnderMacOsArm64 ? $"-arm64 \"${executable}\" ${arguments}" : arguments;

This comment has been minimized.

Copy link
@k15tfu

k15tfu Aug 23, 2024

typo $: $"-arm64 \"${executable}\" ${arguments}"

var commandRegex = BuildCommandRegex("([a-zA-Z-]*)", "(.*)");
var si = new ProcessStartInfo
{
FileName = executable,
Arguments = arguments,
FileName = effectiveExecutable,
Arguments = effectiveArguments,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Supported frameworks:
<PackageProjectUrl>https://github.com/JetBrains/profiler-self-api/blob/master/README.md</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>jetbrains profiler profiling memory performance net dotnet netcore dotnetcore netstandard windows uwp macos mac linux musl glibc x86 x64 arm64 x86-64 x86_64 aarch64</PackageTags>
<Version>2.5.4</Version>
<Version>2.5.5-preview1</Version>
</PropertyGroup>
<ItemGroup>
<None Include="../../icon.png" Pack="true" Visible="false" PackagePath="" />
Expand Down

0 comments on commit 06a35c8

Please sign in to comment.