Skip to content

Failed to compile the bpf code in tutorial 1 #178

@handewo

Description

@handewo

OS: Rocky Linux 9
ecc version: 0.3.4

> $ ./ecc minimal.bpf.c
INFO [ecc_rs::bpf_compiler] Compiling bpf object...
INFO [ecc_rs::bpf_compiler] $ "clang" CommandArgs { inner: ["-g", "-O2", "-target", "bpf", "-Wno-unknown-attributes", "-D__TARGET_ARCH_x86", "-idirafter", "/usr/bin/../lib/clang/18/include", "-idirafter", "/usr/local/include", "-idirafter", "/usr/include", "-I/tmp/.tmpDVfSiQ/include", "-I/tmp/.tmpDVfSiQ/include/vmlinux/x86", "-I/home/rick/eunomia", "-c", "minimal.bpf.c", "-o", "minimal.bpf.o"] }
INFO [ecc_rs::bpf_compiler]
ERROR [ecc_rs::bpf_compiler] In file included from minimal.bpf.c:3:
In file included from /tmp/.tmpDVfSiQ/include/bpf/bpf_helpers.h:11:
/tmp/.tmpDVfSiQ/include/bpf/bpf_helper_defs.h:78:90: error: unknown type name '__u64'
   78 | static long (* const bpf_map_update_elem)(void *map, const void *key, const void *value, __u64 flags) = (void *) 2;
      |                                                                                          ^
/tmp/.tmpDVfSiQ/include/bpf/bpf_helper_defs.h:102:49: error: unknown type name '__u32'
  102 | static long (* const bpf_probe_read)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 4;
      |                                                 ^

ecc compile successfully after change include as below:

/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
#define BPF_NO_GLOBAL_DATA
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions