Re: [PATCH 2/2] Revert "perf tools: Fix arm64 build by generating unistd_64.h"

From: Leo Yan

Date: Fri Dec 05 2025 - 11:21:53 EST


On Thu, Dec 04, 2025 at 10:19:59AM -0800, Ian Rogers wrote:
> On Thu, Dec 4, 2025 at 8:53 AM Leo Yan <leo.yan@xxxxxxx> wrote:
> >
> > This reverts:
> >
> > commit 8988c4b91945 ("perf tools: Fix in-source libperf build")
> > commit bfb713ea53c7 ("perf tools: Fix arm64 build by generating unistd_64.h")
> >
> > Since we now have a static unistd_64.h for the arm64 build, there is no
> > need to generate unistd_64.h in libperf. Revert all patches related to
> > generating unistd_64.h.
>
> Could we generate the file and then compare the two? We do something
> like this for empty-pmu-events.c here:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/pmu-events/Build?h=perf-tools-next#n49
>
> Similarly, could we get rid of the unistd_64.h generation and just add
> a build time validation test? Generating the file is painful in many
> ways, as this series testifies.

Thanks for suggestions!

I had a question: why we need to maintain unistd.h particually in
./tools folder? This header is a standard C header and should be
provided by toolchain instead. Due to multiple copies, it is a bit mess
the programs might include unpurposed one.

I went through the history and found:

commit 34b009cfde2b ("tools include: Grab copies of arm64 dependent unistd.h files")

It introduces the header unistd.h for generating system call table.

Afterwards,

commit cb8197db8c09 ("perf tools arm64: Use syscall table")

unistd.h headers are not used to generate syscall table anymore. Since
then, syscall tables are maintained in
tools/perf/arch/*/entry/syscalls/syscall*.tbl for each arch.

To verify this, I did a quick try with removing x86 and arm64 headers:

tools/arch/arm64/include/uapi/asm/unistd.h
tools/arch/x86/include/uapi/asm/unistd.h
tools/arch/x86/include/uapi/asm/unistd_32.h
tools/arch/x86/include/uapi/asm/unistd_64.h

I run the linux-tools-container-builds and confirmed all x86 and arm64
building tests pass and did not see any failure.

For a neat fix, I think we can remove all unistd.h headers:

$ ls tools/arch/*/include/uapi/asm/unistd*
tools/arch/arc/include/uapi/asm/unistd.h
tools/arch/hexagon/include/uapi/asm/unistd.h
tools/arch/riscv/include/uapi/asm/unistd.h
tools/arch/x86/include/uapi/asm/unistd_64.h
tools/arch/arm64/include/uapi/asm/unistd.h
tools/arch/loongarch/include/uapi/asm/unistd.h
tools/arch/x86/include/uapi/asm/unistd_32.h
tools/arch/x86/include/uapi/asm/unistd.h

Any concern? I would get maintainers's confirmation before proceeding.

Thanks,
Leo