This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][CMake] Multiarch build of XRay libraries
ClosedPublic

Authored by ilammy on Jun 18 2023, 1:33 AM.

Details

Summary

Instead of dumping all sources into RTXray object library with a weird
special case for x86, handle multiarch builds better. Build a separate
object library for each arch with its arch-specific sources, then link
in all those libraries.

This fixes the build on platforms that produce fat binaries, such as new
macOS which expects both x86_64 and aarch64 objects in the same library
since Apple Silicon is a thing.

This only enables building XRay support for Apple Silicon. It does not
actually work yet on macOS, neither on Intel nor on Apple Silicon CPUs.
Thus the tests are still disabled.

Diff Detail

Event Timeline

ilammy created this revision.Jun 18 2023, 1:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 18 2023, 1:33 AM
ilammy requested review of this revision.Jun 18 2023, 1:33 AM
Herald added a subscriber: Restricted Project. · View Herald TranscriptJun 18 2023, 1:33 AM
MaskRay added a comment.EditedJun 20 2023, 9:47 PM

I don't know enough about CMake, so I wish that an expert can look into this.

If you can test arm64-apple-darwin, I wonder whether the following all work:

  • unset CMAKE_OSX_ARCHITECTURES
  • -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64'
  • -DCMAKE_OSX_ARCHITECTURES='x86_64'
compiler-rt/lib/xray/CMakeLists.txt
82

sort alphabetically

In a build not setting CMAKE_OSX_ARCHITECTURES on an arm64-apple-darwin machine, I cannot find RTXray_aarch64.osx or RTXray_arm64.osx. I don't know what's wrong...

% ninja -C out/release -t targets | grep RTXray
RTXray.osx: phony
RTXrayBASIC.osx: phony
RTXrayFDR.osx: phony
RTXrayPROFILING.osx: phony
RTXray_x86_64.osx: phony
phosek accepted this revision.Jun 21 2023, 12:03 AM

Ideally we would use CMAKE_OSX_ARCHITECTURES which is the native CMake solution, but that's not currently supported in compiler-rt which implements its own crude version. We should eventually migrate to CMAKE_OSX_ARCHITECTURES, but I'm fine with this change as an interim solution.

This revision is now accepted and ready to land.Jun 21 2023, 12:03 AM

I'll land this. I don't get RTXray_arm64.osx on an Apple M1, but this looks like a step forward. Thanks!

MaskRay accepted this revision.Jun 22 2023, 6:38 PM
This revision was landed with ongoing or failed builds.Jun 22 2023, 6:41 PM
This revision was automatically updated to reflect the committed changes.