This is an archive of the discontinued LLVM Phabricator instance.

[Driver][xray] Allow XRay on Apple Silicon
ClosedPublic

Authored by ilammy on Mar 11 2023, 7:57 AM.

Details

Summary

Codegen can handle XRay for AArch64, tell the driver to allow it.

Diff Detail

Event Timeline

ilammy created this revision.Mar 11 2023, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2023, 7:57 AM
ilammy requested review of this revision.Mar 11 2023, 7:57 AM
MaskRay accepted this revision.Mar 13 2023, 10:18 PM
MaskRay added inline comments.
clang/test/Driver/XRay/xray-instrument-macos.c
1 ↗(On Diff #504369)

--target=

Avoid -target (legacy) for new tests.

This revision is now accepted and ready to land.Mar 13 2023, 10:18 PM
ilammy updated this revision to Diff 530285.Jun 11 2023, 12:32 AM

Addressing feedback by @MaskRay:

  • Moved // REQUIRES: directive to the top of the test file
  • Replaced legacy -target option with proper --target in tests
  • Also rebased on updated trunk

This is a kinda odd case. Normally we should enable the option in the driver when the feature actually works.
However, Triple.isMacOSX() is allowed before the feature actually works and compiler-rt/test/xray/lit.cfg.py tests it.

clang/test/Driver/XRay/ is broken and does not follow the practice testing driver changes.
clang/test/Driver should not test code generation but XRay/ tests do.

The targets aren't really enabled since REQUIRES: aarch64 || x86_64 || x86_64h lines specified lit features aren't available.

clang/lib/Driver/XRayArgs.cpp
63

The file was written in a non-conventional way. I just cleaned up the file a bit.

However, Triple.isMacOSX() is allowed before the feature actually works and compiler-rt/test/xray/lit.cfg.py tests it.

I have some patches for compiler-rt cooking, fixing the build for AArch64. Should those go in first, before clang is ultimately allowed to use -fxray-instrument when targeting AArch64, so that everything works out of the box?

For me, Clang is able to compile binaries with XRay sections (with this change), but I have compiler-rt disabled and not linked in, since it's not possible to build it for AArch64 yet.

I thought it could be done separately. I was not aware of those tests in compiler-rt, checking all archs.

I guess the build should be fixed first, then this change should simultaneously allow clang to target AArch64 and update compiler-rt's expectations of what works.

How does that sound to you?

However, Triple.isMacOSX() is allowed before the feature actually works and compiler-rt/test/xray/lit.cfg.py tests it.

I have some patches for compiler-rt cooking, fixing the build for AArch64. Should those go in first, before clang is ultimately allowed to use -fxray-instrument when targeting AArch64, so that everything works out of the box?

For me, Clang is able to compile binaries with XRay sections (with this change), but I have compiler-rt disabled and not linked in, since it's not possible to build it for AArch64 yet.

I thought it could be done separately. I was not aware of those tests in compiler-rt, checking all archs.

I guess the build should be fixed first, then this change should simultaneously allow clang to target AArch64 and update compiler-rt's expectations of what works.

How does that sound to you?

Since Mach-O porting is supposed to be done soon, I think landing this change is fine. This patch should make fixing the underlying issue easier as we don't need to locally patch XRayArgs.cpp...

I think D152661 is very much desired and ideally landed before other fixes.

However, Triple.isMacOSX() is allowed before the feature actually works and compiler-rt/test/xray/lit.cfg.py tests it.

I have some patches for compiler-rt cooking, fixing the build for AArch64. Should those go in first, before clang is ultimately allowed to use -fxray-instrument when targeting AArch64, so that everything works out of the box?

For me, Clang is able to compile binaries with XRay sections (with this change), but I have compiler-rt disabled and not linked in, since it's not possible to build it for AArch64 yet.

I thought it could be done separately. I was not aware of those tests in compiler-rt, checking all archs.

I guess the build should be fixed first, then this change should simultaneously allow clang to target AArch64 and update compiler-rt's expectations of what works.

How does that sound to you?

Since Mach-O porting is supposed to be done soon, I think landing this change is fine. This patch should make fixing the underlying issue easier as we don't need to locally patch XRayArgs.cpp...

I think D152661 is very much desired and ideally landed before other fixes.

Needs to be rebased first. Hold on. I'll improve the xray-instrument* tests soon and you may want to git pull:)

This revision was automatically updated to reflect the committed changes.