tracy icon indicating copy to clipboard operation
tracy copied to clipboard

(Do not submit) - draft for adapting to capstone arm64 renaming

Open bjacob opened this issue 1 year ago • 19 comments

FYI @wolfpld: Capstone has just done a breaking renaming: ARM64 --> AArch64 (https://github.com/capstone-engine/capstone/pull/2026)

This PR is a good-enough local patch for anyone trying to build against latest Capstone. It uses Capstone's own provided compatibility macros to resolve to either the old or the new identifiers.

The problem which IIUC makes this PR not good to merge is that by relying on these Capstone macros... it probably doesn't actually support older Capstone versions, which presumably don't have these macros.

You probably need to resolve that by forking these macros on the Tracy side...

bjacob avatar Nov 24 '23 21:11 bjacob

@bjacob Just stumbled on this. Capstone v5 and v4 have those macros now. See capstone.h in each branch.

Rot127 avatar Jan 16 '24 18:01 Rot127

oooh! I also hit the same issue! It seems that I should maybe just build capstone v5, but not next? Let me give it a shot..

hanhanW avatar Jan 22 '24 06:01 hanhanW

v5 works for me, I will use v5 for now

hanhanW avatar Jan 22 '24 07:01 hanhanW

@hanhanW Mind that v5 is pretty out of date already. It is based on LLVM 7, misses some Aarch64 extensions and has some bugs. We have a guide regarding the upcoming v6 if you want to take a look.

Rot127 avatar Jan 22 '24 07:01 Rot127

@hanhanW Mind that v5 is pretty out of date already. It is based on LLVM 7, misses some Aarch64 extensions and has some bugs. We have a guide regarding the upcoming v6 if you want to take a look.

I'm good with v5 for now because I don't need to jump into asm level at this moment. I mainly wanted to address compilation issues when building tracy with IREE. Thanks for the heads-up!

hanhanW avatar Jan 22 '24 08:01 hanhanW

@wolfpld, it seems that multiple people have hit this. Would you suggest merging some flavor of this (do you want to suggest changes to this draft) ?

bjacob avatar Mar 14 '24 19:03 bjacob

@bjacob Just stumbled on this. Capstone v5 and v4 have those macros now. See capstone.h in each branch.

I'm not sure that we can count on all users' package managers to have received the backport.

bjacob avatar Mar 14 '24 19:03 bjacob

The guaranteed thing that we can do here is, as suggested in the PR description, fork those CS compatibility macros on the Tracy side.

bjacob avatar Mar 14 '24 19:03 bjacob

#707 should solve this.

wolfpld avatar Mar 14 '24 19:03 wolfpld

https://github.com/wolfpld/tracy/pull/707 should solve this.

From a cursory look --- it looks like this hardcodes Capstone 5.0.1 ? I actually need to use Capstone 6 to use recent ISA extensions. Doing so would require Tracy-side source changes as in the present PR, right ?

bjacob avatar Mar 14 '24 19:03 bjacob

Looks like a good step though, from where the capstone 5->6 move could be made as a second step ? Given the headache that capstone has been giving tracy users, I definitely welcome Tracy internalizing it.

bjacob avatar Mar 14 '24 20:03 bjacob

The key thing is that it hardcodes a version, so you have one target, instead of the crapshoot that is currently the case (the :hankey: prize goes to ubububu, which ships 3.x :exploding_head:).

wolfpld avatar Mar 14 '24 20:03 wolfpld

Yup, exactly. Once https://github.com/wolfpld/tracy/pull/707 is merged, and we've rebased our downstream to work with that, i'll rebase the present PR into a capstone 5->6 bump (which you may or may not merge, but it's useful for me even if unmerged).

bjacob avatar Mar 14 '24 20:03 bjacob

FYI, CMake has been "merged".

wolfpld avatar Mar 24 '24 14:03 wolfpld

Yup, exactly. Once #707 is merged, and we've rebased our downstream to work with that, i'll rebase the present PR into a capstone 5->6 bump (which you may or may not merge, but it's useful for me even if unmerged).

I'm currently updating our (IREE's) downstream to use the CMake files now present here in Tracy upstream (we'll just use the upstream build and drop our custom CMake + custom instructions, unless there is some reason to keep them that I'm not seeing). @bjacob did you want to continue with a capstone 5 -> 6 update?

ScottTodd avatar May 23 '24 17:05 ScottTodd

Yup, that's the plan laid out at https://github.com/iree-org/iree/issues/16777. The above https://github.com/wolfpld/tracy/pull/671#issuecomment-2016830130 implies that the first step in the tasklist there is already completed, and what you describe doing is the second step in that tasklist, so after that we can bump from Capstone 5 to 6, the third step in that tasklist (the tasklist is framed in a way that assumes that the capstone 5->6 bump would be merged in upstream tracy (here) first, but if that's not desired here, we can keep that as a local tracy patch).

bjacob avatar May 23 '24 18:05 bjacob

I'm not sure why those steps are dependent on one another?

ScottTodd avatar May 23 '24 18:05 ScottTodd

not a strict dependence at every step, just my suggestion how in what order to tackle things.

bjacob avatar May 23 '24 18:05 bjacob

I am sorry, forgot to drop it here. But we have a compatibility header now. Though, it is still a PR until the other maintainers manage to look at it: https://github.com/capstone-engine/capstone/pull/2321

Rot127 avatar May 24 '24 09:05 Rot127