Skip to content

Add support for xray in aarch64 unknown none targets - #148666

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
odlot:master
May 19, 2026
Merged

Add support for xray in aarch64 unknown none targets#148666
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
odlot:master

Conversation

@odlot

@odlotodlot commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

View all comments

I am currently working on an embedded project and use the target aarch64-unknown-none, which I want to profile.
I found the following compiler flag -Z instrument-xray (https://doc.rust-lang.org/unstable-book/compiler-flags/instrument-xray.html) available and I locally built a toolchain that sets the supports_xray: true option in TargetOptions for compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs.
Using this toolchain in rustup I am able to use the instrumentation pass and I verified that the disassembly looks as what I want.
I understand that it isn't available upstream while being supported due to the separate runtime library which has to be linked (e.g., https://www.llvm.org/docs/XRay.html#xray-runtime-library), which is not available for aarch64-unknown-none.
I argue that someone who cross-compiles for aarch64-unknown-none would be okay with writing a separate runtime library themselves, which I intend to do.
As far as I understood it is not necessarily required to have a runtime library at this point, i.e., the user of this API should link it, e.g., from their build.rs file using cargo::rustc-link-lib=LIB if there is an XRay LIB available for the respective target, e.g., clang+llvm-19.1.1-aarch64-linux-gnu/lib/clang/19/lib/aarch64-unknown-linux-gnu/libclang_rt.xray-fdr.a (which afaik there isn't for aarch64-unknown-none) and do "configuration as code" of XRay's options.
It should not be part of the compiler, because the instrumentation and the runtime library are completely decoupled. One can modify the instrumented code by the compiler pass however one wants to, this again pushes me into the direction of telling the developer to bring his own runtime library.

I would like to bring my change that enables this instrumentation back into upstream to facilitate my developer experience.

@rustbot

Copy link
Copy Markdown
Collaborator

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

@rustbotrustbot 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 Nov 7, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
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

@rust-log-analyzer

This comment has been minimized.

@odlot

Copy link
Copy Markdown
ContributorAuthor

@wesleywiser were you able to take a look yet? As far as I can tell CI failed because CI was in general broken at that point in time, I unfortunately can not rerun the pipeline.

@bors

bors commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #149581) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbotrustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 4, 2025
@odlotodlot closed this Dec 4, 2025
@rustbotrustbot removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Dec 4, 2025
@odlotodlot reopened this Dec 4, 2025
@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 4, 2025
@odlot

Copy link
Copy Markdown
ContributorAuthor

Anything from my side to do here?

@wesleywiserwesleywiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The rationale provided makes sense to me but as far as I'm aware, there are no other targets that "support" xray in this way. I think it potentially makes sense to do this for the other *-none targets as well.

@davidtwco what do you think?

View changes since this review

@odlot

Copy link
Copy Markdown
ContributorAuthor

Good point, I can also add this option to the aarch64-unknown-none-softfloat because we moved from aarch64-unknown-none and these are the two targets I've actually implemented and tested an analysis pass for.

@davidtwco

Copy link
Copy Markdown
Member

I think I'm fine with this - it makes sense that we'd allow use of -Zinstrument-xray on targets that do support it, even if that requires a little bit more work, it's still something you need to opt-in to so it won't affect anyone accidentally. We should adjust the docs to clarify that -Zinstrument-xray might require you do a bit more work.

@wesleywiserwesleywiser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@odlot thanks for your patience! If you wouldn't mind adding a mention of this to the docs in src/doc/unstable-book/src/compiler-flags/instrument-xray.md that would be awesome. Happy to approve after that!

View changes since this review

@rustbotrustbot 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 7, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

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

@rustbot

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot

This comment has been minimized.

@rustbotrustbot added the has-merge-commits PR has merge commits, merge with caution. label May 11, 2026
@rustbotrustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 11, 2026
@odlotodlot changed the title Add support for xray in aarch64 unknown none targetAdd support for xray in aarch64 unknown none targetsMay 11, 2026
@odlot

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 12, 2026
@wesleywiser

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-borsBot commented May 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 743c6a6 has been approved by wesleywiser

It is now in the queue for this repository.

@rust-borsrust-borsBot 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-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request May 19, 2026
Add support for xray in aarch64 unknown none targets
I am currently working on an embedded project and use the target `aarch64-unknown-none`, which I want to profile.
I found the following compiler flag `-Z instrument-xray` (https://doc.rust-lang.org/unstable-book/compiler-flags/instrument-xray.html) available and I locally built a toolchain that sets the `supports_xray: true` option in `TargetOptions` for `compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs`.
Using this toolchain in `rustup` I am able to use the instrumentation pass and I verified that the disassembly looks as what I want.
I understand that it isn't available upstream while being supported due to the separate runtime library which has to be linked (e.g., https://www.llvm.org/docs/XRay.html#xray-runtime-library), which is not available for `aarch64-unknown-none`.
I argue that someone who cross-compiles for `aarch64-unknown-none` would be okay with writing a separate runtime library themselves, which I intend to do.
As far as I understood it is not necessarily required to have a runtime library at this point, i.e., the user of this API should link it, e.g., from their `build.rs` file using `cargo::rustc-link-lib=LIB` if there is an XRay LIB available for the respective target, e.g., `clang+llvm-19.1.1-aarch64-linux-gnu/lib/clang/19/lib/aarch64-unknown-linux-gnu/libclang_rt.xray-fdr.a` (which afaik there isn't for `aarch64-unknown-none`) and do "configuration as code" of XRay's options.
It should not be part of the compiler, because the instrumentation and the runtime library are completely decoupled. One can modify the instrumented code by the compiler pass however one wants to, this again pushes me into the direction of telling the developer to bring his own runtime library.
I would like to bring my change that enables this instrumentation back into upstream to facilitate my developer experience.
@rust-borsrust-borsBot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 19, 2026
@rust-bors

rust-borsBot commented May 19, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 990826b failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web)(plain enhanced)(plain)

Click to see the possible cause of the failure (guessed by this bot)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors retry

@rust-borsrust-borsBot 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-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2026
rust-borsBot pushed a commit that referenced this pull request May 19, 2026
…uwer
Rollup of 6 pull requests
Successful merges:
- #154265 (ci: Add dist-aarch64-freebsd)
- #156739 (miri subtree update)
- #148666 (Add support for xray in aarch64 unknown none targets)
- #156547 (Move tests closures)
- #156578 (Add FileCheck for build_correct_coerce)
- #156734 ([rustdoc] Move `span_map` file to the right folder)
rust-borsBot pushed a commit that referenced this pull request May 19, 2026
…uwer
Rollup of 6 pull requests
Successful merges:
- #154265 (ci: Add dist-aarch64-freebsd)
- #156739 (miri subtree update)
- #148666 (Add support for xray in aarch64 unknown none targets)
- #156547 (Move tests closures)
- #156578 (Add FileCheck for build_correct_coerce)
- #156734 ([rustdoc] Move `span_map` file to the right folder)
rust-borsBot pushed a commit that referenced this pull request May 19, 2026
…uwer
Rollup of 6 pull requests
Successful merges:
- #154265 (ci: Add dist-aarch64-freebsd)
- #156739 (miri subtree update)
- #148666 (Add support for xray in aarch64 unknown none targets)
- #156547 (Move tests closures)
- #156578 (Add FileCheck for build_correct_coerce)
- #156734 ([rustdoc] Move `span_map` file to the right folder)
rust-borsBot pushed a commit that referenced this pull request May 19, 2026
…uwer
Rollup of 6 pull requests
Successful merges:
- #154265 (ci: Add dist-aarch64-freebsd)
- #156739 (miri subtree update)
- #148666 (Add support for xray in aarch64 unknown none targets)
- #156547 (Move tests closures)
- #156578 (Add FileCheck for build_correct_coerce)
- #156734 ([rustdoc] Move `span_map` file to the right folder)
@rust-bors
rust-borsBot merged commit 93e516b into rust-lang:mainMay 19, 2026
11 of 12 checks passed
@rustbotrustbot added this to the 1.97.0 milestone May 19, 2026
rust-timer added a commit that referenced this pull request May 19, 2026
Rollup merge of #148666 - odlot:master, r=wesleywiser
Add support for xray in aarch64 unknown none targets
I am currently working on an embedded project and use the target `aarch64-unknown-none`, which I want to profile.
I found the following compiler flag `-Z instrument-xray` (https://doc.rust-lang.org/unstable-book/compiler-flags/instrument-xray.html) available and I locally built a toolchain that sets the `supports_xray: true` option in `TargetOptions` for `compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs`.
Using this toolchain in `rustup` I am able to use the instrumentation pass and I verified that the disassembly looks as what I want.
I understand that it isn't available upstream while being supported due to the separate runtime library which has to be linked (e.g., https://www.llvm.org/docs/XRay.html#xray-runtime-library), which is not available for `aarch64-unknown-none`.
I argue that someone who cross-compiles for `aarch64-unknown-none` would be okay with writing a separate runtime library themselves, which I intend to do.
As far as I understood it is not necessarily required to have a runtime library at this point, i.e., the user of this API should link it, e.g., from their `build.rs` file using `cargo::rustc-link-lib=LIB` if there is an XRay LIB available for the respective target, e.g., `clang+llvm-19.1.1-aarch64-linux-gnu/lib/clang/19/lib/aarch64-unknown-linux-gnu/libclang_rt.xray-fdr.a` (which afaik there isn't for `aarch64-unknown-none`) and do "configuration as code" of XRay's options.
It should not be part of the compiler, because the instrumentation and the runtime library are completely decoupled. One can modify the instrumented code by the compiler pass however one wants to, this again pushes me into the direction of telling the developer to bring his own runtime library.
I would like to bring my change that enables this instrumentation back into upstream to facilitate my developer experience.
pullBot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request May 20, 2026
…uwer
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#154265 (ci: Add dist-aarch64-freebsd)
- rust-lang/rust#156739 (miri subtree update)
- rust-lang/rust#148666 (Add support for xray in aarch64 unknown none targets)
- rust-lang/rust#156547 (Move tests closures)
- rust-lang/rust#156578 (Add FileCheck for build_correct_coerce)
- rust-lang/rust#156734 ([rustdoc] Move `span_map` file to the right folder)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

7 participants

@odlot@rustbot@rust-log-analyzer@bors@davidtwco@wesleywiser@JonathanBrouwer