Skip to content

Enable xray support for Mac #140790

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
May 27, 2025
Merged

Enable xray support for Mac #140790

merged 2 commits into from
May 27, 2025

Conversation

quininer
Copy link
Contributor

@quininer quininer commented May 8, 2025

#102921

Upstream has supported Mac for a while, let's enable it.

I've tested it on M4 and it generates nop sled correctly.

try-job: x86_64-apple-1
try-job: aarch64-apple

@rustbot
Copy link
Collaborator

rustbot commented May 8, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 8, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 8, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

jieyouxu commented May 8, 2025

Since this affects the Tier 1 {x86_64,aarch64}-apple-darwin targets (albeit -Z instrument-xray is still unstable), asking Apple experts for second opinion as I neither have access to apple envs nor am I aware of how well LLVM xray currently works on those targets.

@rustbot ping apple

@rustbot rustbot added the O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) label May 8, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 8, 2025

Hey Apple notification group! This issue or PR could use some Apple-specific
guidance. Could one of you weigh in? Thanks <3

(In case it's useful, here are some instructions for tackling these sorts of
issues).

cc @BlackHoleFox @hkratz @inflation @madsmtm @nvzqz @shepmaster @thomcc

@jieyouxu
Copy link
Member

jieyouxu commented May 9, 2025

@rustbot author (test nits)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 9, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@quininer quininer requested review from wesleywiser and jieyouxu May 14, 2025 04:08
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 14, 2025
@jieyouxu
Copy link
Member

Responded to your questions in #140790 (comment).
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 15, 2025
@quininer
Copy link
Contributor Author

I added tests for assembly output, which should be seen as supplementing the previous missing tests for xray.

I also added flag stable test, but I still don't think it's necessary. I don't see any other flags have this test, I can only get this from https://github.com/rust-lang/rust/blob/1.87.0/tests/ui/bootstrap/rustc_bootstrap.rs#L36 .
and this test has nothing to do with xray, but is a test of the order of -Z flag and target checks.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, just a nit on the platform support test

@jieyouxu
Copy link
Member

I also added flag stable test, but I still don't think it's necessary. I don't see any other flags have this test, I can only get this from https://github.com/rust-lang/rust/blob/1.87.0/tests/ui/bootstrap/rustc_bootstrap.rs#L36 .
and this test has nothing to do with xray, but is a test of the order of -Z flag and target checks.

Sorry I shouldn't have said "platform stability", I should've said "platform support".

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2025
@jieyouxu
Copy link
Member

@bors try

@jieyouxu jieyouxu added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 25, 2025
@bors
Copy link
Collaborator

bors commented May 25, 2025

⌛ Trying commit 8d7def6 with merge 19349e1...

bors added a commit that referenced this pull request May 25, 2025
Enable xray support for Mac

#102921

Upstream has supported Mac for a while, let's enable it.

I've tested it on M4 and it generates nop sled correctly.

* https://maskray.me/blog/2023-06-18-port-llvm-xray-to-apple-systems
* https://github.com/llvm/llvm-project/blob/llvmorg-20.1.4/clang/lib/Driver/XRayArgs.cpp#L31

try-job: x86_64-apple-1
try-job: aarch64-apple
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 25, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 25, 2025
@jieyouxu
Copy link
Member

Oh right, sometimes there are CFI directives

@quininer
Copy link
Contributor Author

Ah, aarch64 generate sled in a different style than x86_64. It's always a jmp to ret instruction, not a direct ret.

I haven't really tested it so it may still have error.

@jieyouxu
Copy link
Member

@bors try

bors added a commit that referenced this pull request May 25, 2025
Enable xray support for Mac

#102921

Upstream has supported Mac for a while, let's enable it.

I've tested it on M4 and it generates nop sled correctly.

* https://maskray.me/blog/2023-06-18-port-llvm-xray-to-apple-systems
* https://github.com/llvm/llvm-project/blob/llvmorg-20.1.4/clang/lib/Driver/XRayArgs.cpp#L31

try-job: x86_64-apple-1
try-job: aarch64-apple
@bors
Copy link
Collaborator

bors commented May 25, 2025

⌛ Trying commit 45ed022 with merge 1ad0547...

@bors
Copy link
Collaborator

bors commented May 25, 2025

☀️ Try build successful - checks-actions
Build commit: 1ad0547 (1ad0547a1ba5d3926045afcd95e6fa17278ce9ba)

@jieyouxu
Copy link
Member

@bors r=wesleywiser,jieyouxu

@bors
Copy link
Collaborator

bors commented May 26, 2025

📌 Commit 45ed022 has been approved by wesleywiser,jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2025
@bors
Copy link
Collaborator

bors commented May 26, 2025

⌛ Testing commit 45ed022 with merge d76fe15...

@bors
Copy link
Collaborator

bors commented May 27, 2025

☀️ Test successful - checks-actions
Approved by: wesleywiser,jieyouxu
Pushing d76fe15 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 27, 2025
@bors bors merged commit d76fe15 into rust-lang:master May 27, 2025
7 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 27, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 2805e1d (parent) -> d76fe15 (this PR)

Test differences

Show 38 test diffs

Stage 1

  • [assembly] tests/assembly/aarch64-xray.rs#aarch64-darwin: [missing] -> ignore (only executed when the target is aarch64-apple-darwin) (J2)
  • [assembly] tests/assembly/aarch64-xray.rs#aarch64-linux: [missing] -> ignore (only executed when the target is aarch64-unknown-linux-gnu) (J2)
  • [assembly] tests/assembly/x86_64-xray.rs#x86_64-darwin: [missing] -> ignore (only executed when the target is x86_64-apple-darwin) (J2)
  • [assembly] tests/assembly/x86_64-xray.rs#x86_64-linux: [missing] -> pass (J2)
  • [ui] tests/ui/instrument-xray/platform-support.rs#aarch64-darwin: [missing] -> pass (J2)
  • [ui] tests/ui/instrument-xray/platform-support.rs#unsupported: [missing] -> pass (J2)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-darwin: [missing] -> pass (J2)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-linux: [missing] -> pass (J2)
  • [ui] tests/ui/instrument-xray/target-not-supported.rs: pass -> [missing] (J2)

Stage 2

  • [assembly] tests/assembly/aarch64-xray.rs#aarch64-linux: [missing] -> pass (J0)
  • [ui] tests/ui/instrument-xray/flags-always-never-1.rs: ignore (ignored on targets without xray tracing) -> pass (J1)
  • [ui] tests/ui/instrument-xray/flags-always-never-2.rs: ignore (ignored on targets without xray tracing) -> pass (J1)
  • [ui] tests/ui/instrument-xray/flags-basic.rs: ignore (ignored on targets without xray tracing) -> pass (J1)
  • [ui] tests/ui/instrument-xray/flags-dupe-always.rs: ignore (ignored on targets without xray tracing) -> pass (J1)
  • [ui] tests/ui/instrument-xray/flags-dupe-ignore-loops.rs: ignore (ignored on targets without xray tracing) -> pass (J1)
  • [codegen] tests/codegen/instrument-xray/basic.rs: ignore (ignored on targets without xray tracing) -> pass (J3)
  • [codegen] tests/codegen/instrument-xray/options-combine.rs: ignore (ignored on targets without xray tracing) -> pass (J3)
  • [codegen] tests/codegen/instrument-xray/options-override.rs: ignore (ignored on targets without xray tracing) -> pass (J3)
  • [ui] tests/ui/instrument-xray/target-not-supported.rs: pass -> [missing] (J4)
  • [assembly] tests/assembly/aarch64-xray.rs#aarch64-darwin: [missing] -> ignore (only executed when the target is aarch64-apple-darwin) (J5)
  • [assembly] tests/assembly/aarch64-xray.rs#aarch64-darwin: [missing] -> pass (J6)
  • [assembly] tests/assembly/aarch64-xray.rs#aarch64-linux: [missing] -> ignore (only executed when the target is aarch64-unknown-linux-gnu) (J7)
  • [ui] tests/ui/instrument-xray/platform-support.rs#aarch64-darwin: [missing] -> ignore (only executed when the release channel is nightly ((flag is still unstable))) (J8)
  • [ui] tests/ui/instrument-xray/platform-support.rs#unsupported: [missing] -> ignore (only executed when the release channel is nightly ((flag is still unstable))) (J8)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-darwin: [missing] -> ignore (only executed when the release channel is nightly ((flag is still unstable))) (J8)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-linux: [missing] -> ignore (only executed when the release channel is nightly ((flag is still unstable))) (J8)
  • [ui] tests/ui/instrument-xray/platform-support.rs#aarch64-darwin: [missing] -> ignore (ignored on targets without xray tracing) (J9)
  • [ui] tests/ui/instrument-xray/platform-support.rs#unsupported: [missing] -> ignore (ignored on targets without xray tracing) (J9)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-darwin: [missing] -> ignore (ignored on targets without xray tracing) (J9)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-linux: [missing] -> ignore (ignored on targets without xray tracing) (J9)
  • [ui] tests/ui/instrument-xray/platform-support.rs#aarch64-darwin: [missing] -> pass (J10)
  • [ui] tests/ui/instrument-xray/platform-support.rs#unsupported: [missing] -> pass (J10)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-darwin: [missing] -> pass (J10)
  • [ui] tests/ui/instrument-xray/platform-support.rs#x86_64-linux: [missing] -> pass (J10)
  • [assembly] tests/assembly/x86_64-xray.rs#x86_64-linux: [missing] -> pass (J11)
  • [assembly] tests/assembly/x86_64-xray.rs#x86_64-linux: [missing] -> ignore (only executed when the target is x86_64-unknown-linux-gnu) (J12)
  • [assembly] tests/assembly/x86_64-xray.rs#x86_64-darwin: [missing] -> pass (J13)
  • [assembly] tests/assembly/x86_64-xray.rs#x86_64-darwin: [missing] -> ignore (only executed when the target is x86_64-apple-darwin) (J14)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard d76fe154029e03aeb64af721beafdcef856d576a --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. aarch64-gnu: 8134.0s -> 6749.3s (-17.0%)
  2. x86_64-apple-1: 7620.1s -> 6457.1s (-15.3%)
  3. dist-aarch64-linux: 5327.3s -> 6108.9s (14.7%)
  4. dist-x86_64-mingw: 7869.8s -> 8775.6s (11.5%)
  5. x86_64-apple-2: 5102.8s -> 5610.8s (10.0%)
  6. i686-msvc-2: 7944.3s -> 7187.0s (-9.5%)
  7. dist-armhf-linux: 4960.8s -> 5357.1s (8.0%)
  8. x86_64-mingw-1: 9421.8s -> 8697.2s (-7.7%)
  9. dist-aarch64-apple: 5839.4s -> 5443.7s (-6.8%)
  10. dist-x86_64-msvc-alt: 7373.8s -> 7847.3s (6.4%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@quininer quininer deleted the mac-xray branch May 27, 2025 03:00
@quininer
Copy link
Contributor Author

Thanks everyone for help, especially @jieyouxu 🎉

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d76fe15): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 1

Max RSS (memory usage)

Results (primary 0.4%, secondary -0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.2% [3.2%, 3.2%] 1
Regressions ❌
(secondary)
4.3% [2.8%, 5.8%] 2
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-1.7% [-2.7%, -1.3%] 10
All ❌✅ (primary) 0.4% [-2.3%, 3.2%] 2

Cycles

Results (secondary 3.8%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.8% [2.2%, 5.0%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 778.675s -> 779.351s (0.09%)
Artifact size: 366.38 MiB -> 366.34 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants