-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
base: master
Are you sure you want to change the base?
Enable xray support for Mac #140790
Conversation
These commits modify compiler targets. |
This comment has been minimized.
This comment has been minimized.
Since this affects the Tier 1 @rustbot ping apple |
Hey Apple notification group! This issue or PR could use some Apple-specific (In case it's useful, here are some instructions for tackling these sorts of cc @BlackHoleFox @hkratz @inflation @madsmtm @nvzqz @shepmaster @thomcc |
@rustbot author (test nits) |
Reminder, once the PR becomes ready for a review, use |
Responded to your questions in #140790 (comment). |
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 . @rustbot ready |
There was a problem hiding this 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
//@ rustc-env:RUSTC_BOOTSTRAP=-1 | ||
//@ compile-flags: -Z instrument-xray --target x86_64-unknown-linux-gnu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: What I meant was you can gate this test behind nightly-channel only (//@ only-nightly
), so the unstable flag is accepted by an unstable compiler (i.e. -Z instrument-xray
is accepted) but rejected because it's not supported for the given platform. You can then check for the target-platform-gate message:
//~? ERROR XRay instrumentation is not supported for this target
You can also introduce a differential revision to check that this is accepted, however, on x86_64-apple-darwin
and aarch64-apple-darwin
: e.g.
//@ only-nightly (flag is still unstable)
//@ revisions: unsupported
//@[unsupported] compile-flags: -Z instrument-xray --target=x86_64-pc-windows-msvc
//@ revisions: x86_64_darwin
//@[x86_64_darwin] compile-flags: -Z instrument-xray --target=x86_64-apple-darwin
//@[x86_64_darwin] check-pass
//@ revisions: aarch64_darwin
//@[aarch64_darwin] compile-flags: -Z instrument-xray --target=aarch64-apple-darwin
//@[aarch64_darwin] check-pass
So i.e. this test would be platform-support.rs
.
#![feature(no_core)] | ||
#![no_core] | ||
#![no_main] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: can this just be fn main() {}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I just copy this from tests/ui/instrument-xray/target-not-supported.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to work, which would cause the test to fail on linux. (because darwin std cannot be built).
If we are just test flag, using no_main
seems reasonable to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, yeah that's fine.
Sorry I shouldn't have said "platform stability", I should've said "platform support". @rustbot author |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As someone with very little experience with XRay, I tried to test this end-to-end:
$ ./x build --set=build.sanitizers=true
$ echo "fn main() {}" > main.rs
$ rustc +stage1 -Zinstrument-xray=always main.rs
$ objdump -h -j xray_instr_map main # Works
$ XRAY_OPTIONS="patch_premain=true xray_mode=xray-basic verbosity=1" ./main # No-op?
But it doesn't seem to do anything? Probably because I'm not linking the runtime, but it's not clear to me how I'd go about doing that? Does bootstrap
need to build it?
@madsmtm As with linux, you need to link to Anyway I don't really care about that, because I'll be using my own rt, like uftrace. So just rustc generate the correct nop sled and |
Could you add that as a remark on the unstable docs for this flag? I imagine Mads won't be the only person asking that question. |
@jieyouxu I think it is already mentioned in unstable book. https://github.com/rust-lang/rust/blob/1.87.0/src/doc/unstable-book/src/compiler-flags/instrument-xray.md?plain=1#L35 |
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
#102921
Upstream has supported Mac for a while, let's enable it.
I've tested it on M4 and it generates nop sled correctly.