python / cpython

The Python programming language
https://www.python.org
Other
62.32k stars 29.93k forks source link

support perf trampoline on -linux-musl #121608

Open nekopsykose opened 2 months ago

nekopsykose commented 2 months ago

Feature or enhancement

Proposal:

currently the autotools does the following check

AS_CASE([$PLATFORM_TRIPLET],
  [x86_64-linux-gnu], [perf_trampoline=yes],
  [aarch64-linux-gnu], [perf_trampoline=yes],
  [perf_trampoline=no]
)

simply making it

AS_CASE([$PLATFORM_TRIPLET],
  [x86_64-linux-gnu], [perf_trampoline=yes],
  [x86_64-linux-musl], [perf_trampoline=yes],
  [aarch64-linux-gnu], [perf_trampoline=yes],
  [aarch64-linux-musl], [perf_trampoline=yes],
  [perf_trampoline=no]
)

makes the trampoline build on musl libc systems too, and it seems to work fine: https://img.ayaya.dev/yT9j39Lfeb8u

it doesn't seem like the assembly actually depends on libc support. maybe it should check -linux-* instead?

in any case just adding the above triples seems to work ok, unless i'm missing something, so it would be nice if it was added :)

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

corona10 commented 1 month ago

@nekopsykose

Hi, which linux distro did you tested? I would like to cross check the changes work correctly. see: https://github.com/python/cpython/pull/122370#issuecomment-2256169989 and https://github.com/python/cpython/pull/122370#issuecomment-2256299367

nekopsykose commented 1 month ago

chimera-linux (container at docker.io/chimeralinux/chimera)

works fine with the (released) frame pointer version of perf support, i haven't tried dwarf myself with the new unreleased changes (i see in those mr comments the tests get skipped for whatever reason)

nekopsykose commented 1 month ago

ah, yeah, reading https://docs.python.org/3.14/howto/perf_profiling.html#how-to-work-without-frame-pointers indeed the perf is just too old on alpine, because they package linux-tools from the lts release (which doesn't make sense to me, but..). i guess it'll work fine with the newer ones