Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lts8.8-rt] selftests/bpf: Fix pyperf180 compilation failure with clang18 #25

Open
wants to merge 1 commit into
base: ciqlts8_8-rt
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tools/testing/selftests/bpf/progs/pyperf180.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019 Facebook
#define STACK_MAX_LEN 180

/* llvm upstream commit at clang18
* https://github.com/llvm/llvm-project/commit/1a2e77cf9e11dbf56b5720c607313a566eebb16e
* changed inlining behavior and caused compilation failure as some branch
* target distance exceeded 16bit representation which is the maximum for
* cpu v1/v2/v3. Macro __BPF_CPU_VERSION__ is later implemented in clang18
* to specify which cpu version is used for compilation. So a smaller
* unroll_count can be set if __BPF_CPU_VERSION__ is less than 4, which
* reduced some branch target distances and resolved the compilation failure.
*
* To capture the case where a developer/ci uses clang18 but the corresponding
* repo checkpoint does not have __BPF_CPU_VERSION__, a smaller unroll_count
* will be set as well to prevent potential compilation failures.
*/
#ifdef __BPF_CPU_VERSION__
#if __BPF_CPU_VERSION__ < 4
#define UNROLL_COUNT 90
#endif
#elif __clang_major__ == 18
#define UNROLL_COUNT 90
#endif

#include "pyperf.h"