Skip to content

Fix attach to process on arm64 Mac. #1917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

ConradIrwin
Copy link
Contributor

Before this change it was not possible to attach to a process on arm64 mac.

The primary issue was that we weren't building the attach.dylib for all targets; but even once we did that we had to ensure that we were exiting successfully after injecting into the process.

We pulled in the compile changes from JetBrains/intellij-community@2e7109f

Co-authored-by: @artemmukhin Artem.Mukhin@jetbrains.com
Co-authored-by: Cole Miller cole@zed.dev

@ConradIrwin ConradIrwin requested a review from a team as a code owner June 26, 2025 16:58
…4 mac.

The primary issue was that we weren't building the attach.dylib for all targets; but even once we did that we had to ensure that we were exiting successfully after injecting into the process.

We pulled in the compile changes from JetBrains/intellij-community@2e7109f

Co-authored-by: @artemmukhin <Artem.Mukhin@jetbrains.com>
Co-authored-by: Cole Miller <cole@zed.dev>
@ConradIrwin
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Zed Industries"

#!/bin/bash
set -euxo pipefail

clang++ -fPIC -D_REENTRANT -std=c++11 -arch arm64 -c -o attach_arm64.o attach.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume clang supports D_FORTIFY_SOURCE?. We have internal requirements on this flag being set or Microsoft security won't let us ship this binary. Can you try adding it back?

Copy link
Contributor

@rchiodo rchiodo Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why use clang instead of g++? Could you continue to use g++ to create the other arch, and then just add the lipo command?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SRC to attach.cpp is off. Should likely be this: $SRC/linux_and_mac/attach.cpp. I believe that's what is causing the build failure in the pipeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build script was pulled from JetBrains/intellij-community@2e7109f. I've pushed up a new version that is more like the original.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 26, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rchiodo
Copy link
Contributor

rchiodo commented Jun 26, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rchiodo rchiodo merged commit 0d65353 into microsoft:main Jun 26, 2025
22 of 24 checks passed
@rchiodo
Copy link
Contributor

rchiodo commented Jun 26, 2025

Thanks for the submission :). Should ship in our next release. Sometime before 3.14 goes GA I think.

@ConradIrwin
Copy link
Contributor Author

Great, thank you for the super fast turnaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants