Bug 1125 - [Anck 4.19][ck26_rc1][aarch_64]Failed to compile test case: 'Basic BPF llvm compile'
Summary: [Anck 4.19][ck26_rc1][aarch_64]Failed to compile test case: 'Basic BPF llvm c...
Status: CONFIRMED
Alias: None
Product: ANCK 4.19 Dev
Classification: ANCK
Component: general/others (show other bugs) general/others
Version: 4.19-026.x
Hardware: aarch64 Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: maqiao_mq
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-06 12:22 UTC by kangjiangbo
Modified: 2022-07-29 17:27 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kangjiangbo 2022-05-06 12:22:38 UTC
Description of problem:
an7 ck26_rc1内核 Failed to compile test case: 'Basic BPF llvm compile'

只在arm内核失败,x86上成功
an8上成功


Version-Release number of selected component (if applicable):
# cat /etc/os-release
NAME="Anolis OS"
VERSION="7.7"
ID="anolis"
ID_LIKE="rhel fedora centos"
VERSION_ID="7.7"
PRETTY_NAME="Anolis OS 7.7"
ANSI_COLOR="0;31"
HOME_URL="https://openanolis.cn/"
BUG_REPORT_URL="https://bugs.openanolis.cn/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@iZ2zebfu2pfe96wy4xb5lrZ ~]# lscpu
Architecture:          aarch64
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Model:                 1
BogoMIPS:              50.00
NUMA node0 CPU(s):     0-3
Flags:                 fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs


How reproducible:
# perf test -v 38
38: LLVM search and compile                               :
38.1: Basic BPF llvm compile                              :
--- start ---
test child forked, pid 26405
Kernel build dir is set to /lib/modules/4.19.91-26_rc1.an7.aarch64/build
set env: KBUILD_DIR=/lib/modules/4.19.91-26_rc1.an7.aarch64/build
unset env: KBUILD_OPTS
include option is set to  -nostdinc -isystem /usr/lib/gcc/aarch64-redhat-linux/4.8.5/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h
set env: NR_CPUS=4
set env: LINUX_VERSION_CODE=0x4135b
set env: CLANG_EXEC=/usr/bin/clang
set env: CLANG_OPTIONS=-xc
set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/aarch64-redhat-linux/4.8.5/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h
set env: PERF_BPF_INC_OPTIONS=-I/usr/lib/perf/include/bpf
set env: WORKING_DIR=/lib/modules/4.19.91-26_rc1.an7.aarch64/build
set env: CLANG_SOURCE=-
llvm compiling command template: echo '/*
 * bpf-script-example.c
 * Test basic LLVM building
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
#endif
#define BPF_ANY 0
#define BPF_MAP_TYPE_ARRAY 2
#define BPF_FUNC_map_lookup_elem 1
#define BPF_FUNC_map_update_elem 2

static void *(*bpf_map_lookup_elem)(void *map, void *key) =
        (void *) BPF_FUNC_map_lookup_elem;
static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
        (void *) BPF_FUNC_map_update_elem;

struct bpf_map_def {
        unsigned int type;
        unsigned int key_size;
        unsigned int value_size;
        unsigned int max_entries;
};

#define SEC(NAME) __attribute__((section(NAME), used))
struct bpf_map_def SEC("maps") flip_table = {
        .type = BPF_MAP_TYPE_ARRAY,
        .key_size = sizeof(int),
        .value_size = sizeof(int),
        .max_entries = 1,
};

SEC("func=do_epoll_wait")
int bpf_func__SyS_epoll_pwait(void *ctx)
{
        int ind =0;
        int *flag = bpf_map_lookup_elem(&flip_table, &ind);
        int new_flag;
        if (!flag)
                return 0;
        /* flip flag and store back */
        new_flag = !*flag;
        bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
        return new_flag;
}
char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE
llvm compiling command : echo '/*
 * bpf-script-example.c
 * Test basic LLVM building
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt=-DLINUX_VERSION_CODE=0x40200 into llvm section of ~/.perfconfig'
#endif
#define BPF_ANY 0
#define BPF_MAP_TYPE_ARRAY 2
#define BPF_FUNC_map_lookup_elem 1
#define BPF_FUNC_map_update_elem 2

static void *(*bpf_map_lookup_elem)(void *map, void *key) =
        (void *) BPF_FUNC_map_lookup_elem;
static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
        (void *) BPF_FUNC_map_update_elem;

struct bpf_map_def {
        unsigned int type;
        unsigned int key_size;
        unsigned int value_size;
        unsigned int max_entries;
};

#define SEC(NAME) __attribute__((section(NAME), used))
struct bpf_map_def SEC(maps) flip_table = {
        .type = BPF_MAP_TYPE_ARRAY,
        .key_size = sizeof(int),
        .value_size = sizeof(int),
        .max_entries = 1,
};

SEC(func=do_epoll_wait)
int bpf_func__SyS_epoll_pwait(void *ctx)
{
        int ind =0;
        int *flag = bpf_map_lookup_elem(&flip_table, &ind);
        int new_flag;
        if (!flag)
                return 0;
        /* flip flag and store back */
        new_flag = !*flag;
        bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
        return new_flag;
}
char _license[] SEC(license) = GPL;
int _version SEC(version) = LINUX_VERSION_CODE;
' | /usr/bin/clang -D__KERNEL__ -D__NR_CPUS__=4 -DLINUX_VERSION_CODE=0x4135b -xc   -nostdinc -isystem /usr/lib/gcc/aarch64-redhat-linux/4.8.5/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -I/usr/lib/perf/include/bpf -Wno-unused-value -Wno-pointer-sign -working-directory /lib/modules/4.19.91-26_rc1.an7.aarch64/build -c - -target bpf  -O2 -o -
error: unknown target triple 'bpf', please use -triple or -arch
ERROR:  unable to compile -
Hint:   Check error message shown above.
Hint:   You can also pre-compile it into .o using:
                clang -target bpf -O2 -c -
        with proper -I and -D options.
Failed to compile test case: 'Basic BPF llvm compile'
test child finished with -1
---- end ----
LLVM search and compile subtest 1: FAILED!
38.2: kbuild searching                                    :
--- force skipped ---
LLVM search and compile subtest 2: Skip
38.3: Compile source for BPF prologue generation          :
--- force skipped ---
LLVM search and compile subtest 3: Skip
38.4: Compile source for BPF relocation                   :
--- force skipped ---
LLVM search and compile subtest 4: Skip


Additional info:
# rpm -qa|grep perf
python-perf-4.19.91-26_rc1.an7.x86_64
gperftools-libs-2.6.1-1.an7.x86_64
perf-4.19.91-26_rc1.an7.x86_64

# gcc --version
gcc (GCC) 4.8.5 20150623 (Anolis 4.8.5-44.0.1)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


rpm -qa|grep glibc
glibc-static-2.17-323.1.an7.1.x86_64
glibc-common-2.17-323.1.an7.1.x86_64
glibc-headers-2.17-323.1.an7.1.x86_64
glibc-devel-2.17-323.1.an7.1.x86_64
glibc-2.17-323.1.an7.1.x86_64
Comment 1 Shiloong admin 2022-05-06 17:07:06 UTC
这个请@maqiao 帮忙确认一下是否依赖 llvm 版本
Comment 2 maqiao_mq alibaba_cloud_group 2022-05-06 17:52:13 UTC
为什么是在7.7上跑的?
遇到好几个bpftrace和bcc的版本不对带来的问题了。

建议在7.9上安装最新的版本再来测试一次,看能不能复现。
Comment 3 shanxifanshi alibaba_cloud_group 2022-07-29 17:27:22 UTC
anolis 7.9 ck26.1版本测试,arm内核存在同样问题

测试日志:
# perf test -v 38
38: LLVM search and compile                               :
38.1: Basic BPF llvm compile                              :
--- start ---
test child forked, pid 19836
Kernel build dir is set to /lib/modules/4.19.91-26.1.an7.aarch64/build
set env: KBUILD_DIR=/lib/modules/4.19.91-26.1.an7.aarch64/build
unset env: KBUILD_OPTS
include option is set to  -nostdinc -isystem /usr/lib/gcc/aarch64-redhat-linux/4.8.5/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h
set env: NR_CPUS=4
set env: LINUX_VERSION_CODE=0x4135b
set env: CLANG_EXEC=/usr/bin/clang
set env: CLANG_OPTIONS=-xc
set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/aarch64-redhat-linux/4.8.5/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h
set env: PERF_BPF_INC_OPTIONS=-I/usr/lib/perf/include/bpf
set env: WORKING_DIR=/lib/modules/4.19.91-26.1.an7.aarch64/build
set env: CLANG_SOURCE=-
llvm compiling command template: echo '/*
 * bpf-script-example.c
 * Test basic LLVM building
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
#endif
#define BPF_ANY 0
#define BPF_MAP_TYPE_ARRAY 2
#define BPF_FUNC_map_lookup_elem 1
#define BPF_FUNC_map_update_elem 2

static void *(*bpf_map_lookup_elem)(void *map, void *key) =
        (void *) BPF_FUNC_map_lookup_elem;
static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
        (void *) BPF_FUNC_map_update_elem;

struct bpf_map_def {
        unsigned int type;
        unsigned int key_size;
        unsigned int value_size;
        unsigned int max_entries;
};

#define SEC(NAME) __attribute__((section(NAME), used))
struct bpf_map_def SEC("maps") flip_table = {
        .type = BPF_MAP_TYPE_ARRAY,
        .key_size = sizeof(int),
        .value_size = sizeof(int),
        .max_entries = 1,
};

SEC("func=do_epoll_wait")
int bpf_func__SyS_epoll_pwait(void *ctx)
{
        int ind =0;
        int *flag = bpf_map_lookup_elem(&flip_table, &ind);
        int new_flag;
        if (!flag)
                return 0;
        /* flip flag and store back */
        new_flag = !*flag;
        bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
        return new_flag;
}
char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE
llvm compiling command : echo '/*
 * bpf-script-example.c
 * Test basic LLVM building
 */
#ifndef LINUX_VERSION_CODE
# error Need LINUX_VERSION_CODE
# error Example: for 4.2 kernel, put 'clang-opt=-DLINUX_VERSION_CODE=0x40200 into llvm section of ~/.perfconfig'
#endif
#define BPF_ANY 0
#define BPF_MAP_TYPE_ARRAY 2
#define BPF_FUNC_map_lookup_elem 1
#define BPF_FUNC_map_update_elem 2

static void *(*bpf_map_lookup_elem)(void *map, void *key) =
        (void *) BPF_FUNC_map_lookup_elem;
static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
        (void *) BPF_FUNC_map_update_elem;

struct bpf_map_def {
        unsigned int type;
        unsigned int key_size;
        unsigned int value_size;
        unsigned int max_entries;
};

#define SEC(NAME) __attribute__((section(NAME), used))
struct bpf_map_def SEC(maps) flip_table = {
        .type = BPF_MAP_TYPE_ARRAY,
        .key_size = sizeof(int),
        .value_size = sizeof(int),
        .max_entries = 1,
};

SEC(func=do_epoll_wait)
int bpf_func__SyS_epoll_pwait(void *ctx)
{
        int ind =0;
        int *flag = bpf_map_lookup_elem(&flip_table, &ind);
        int new_flag;
        if (!flag)
                return 0;
        /* flip flag and store back */
        new_flag = !*flag;
        bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
        return new_flag;
}
char _license[] SEC(license) = GPL;
int _version SEC(version) = LINUX_VERSION_CODE;
' | /usr/bin/clang -D__KERNEL__ -D__NR_CPUS__=4 -DLINUX_VERSION_CODE=0x4135b -xc   -nostdinc -isystem /usr/lib/gcc/aarch64-redhat-linux/4.8.5/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -I/usr/lib/perf/include/bpf -Wno-unused-value -Wno-pointer-sign -working-directory /lib/modules/4.19.91-26.1.an7.aarch64/build -c - -target bpf  -O2 -o -
error: unknown target triple 'bpf', please use -triple or -arch
ERROR:  unable to compile -
Hint:   Check error message shown above.
Hint:   You can also pre-compile it into .o using:
                clang -target bpf -O2 -c -
        with proper -I and -D options.
Failed to compile test case: 'Basic BPF llvm compile'
test child finished with -1
---- end ----
LLVM search and compile subtest 1: FAILED!
38.2: kbuild searching                                    :
--- force skipped ---
LLVM search and compile subtest 2: Skip
38.3: Compile source for BPF prologue generation          :
--- force skipped ---
LLVM search and compile subtest 3: Skip
38.4: Compile source for BPF relocation                   :
--- force skipped ---
LLVM search and compile subtest 4: Skip
[root@VM20210305-5 yum.repos.d]# gcc --version
gcc (GCC) 4.8.5 20150623 (Anolis 4.8.5-44.0.1)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


机器信息:
# uname -r
4.19.91-26.1.an7.aarch64

# cat /etc/os-release
NAME="Anolis OS"
VERSION="7.9"
ID="anolis"
ID_LIKE="rhel fedora centos"
VERSION_ID="7.9"
PRETTY_NAME="Anolis OS 7.9"
ANSI_COLOR="0;31"
HOME_URL="https://openanolis.cn/"
BUG_REPORT_URL="https://bugs.openanolis.cn/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

# gcc --version
gcc (GCC) 4.8.5 20150623 (Anolis 4.8.5-44.0.1)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

# yum list llvm
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
llvm.aarch64                                                   3.4.2-9.el7                                                    @epel

# yum install llvm
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel                                                                                                        | 5.4 kB  00:00:00
extras                                                                                                      | 3.8 kB  00:00:00
os                                                                                                          | 4.3 kB  00:00:00
updates                                                                                                     | 3.8 kB  00:00:00
Package llvm-3.4.2-9.el7.aarch64 already installed and latest version
Nothing to do