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

compile error while running make in example/c #95

Closed
ANOLASC opened this issue Jul 21, 2022 · 6 comments
Closed

compile error while running make in example/c #95

ANOLASC opened this issue Jul 21, 2022 · 6 comments

Comments

@ANOLASC
Copy link

ANOLASC commented Jul 21, 2022

git clone and git submodule update --init --recursive
run make in example/c dir

BPF      .output/usdt.bpf.o
In file included from usdt.bpf.c:6:
.output/bpf/usdt.bpf.h:94:7: error: use of unknown builtin '__builtin_preserve_enum_value' [-Wimplicit-function-declaration]
        if (!BPF_USDT_HAS_BPF_COOKIE) {
             ^
.output/bpf/usdt.bpf.h:39:2: note: expanded from macro 'BPF_USDT_HAS_BPF_COOKIE'
        bpf_core_enum_value_exists(enum bpf_func_id___usdt, BPF_FUNC_get_attach_cookie___usdt)
        ^
.output/bpf/bpf_core_read.h:205:2: note: expanded from macro 'bpf_core_enum_value_exists'
        __builtin_preserve_enum_value(*(typeof(enum_type) *)enum_value, BPF_ENUMVAL_EXISTS)
        ^
1 error generated.
make: *** [Makefile:106: .output/usdt.bpf.o] Error 1

ubuntu 20.04 with 5.13.0-52-generic kernel

@chenhengqi
Copy link
Contributor

You can either update your LLVM or apply the following diff:

diff --git a/examples/c/usdt.bpf.c b/examples/c/usdt.bpf.c
index 418aa48..ce6eedd 100644
--- a/examples/c/usdt.bpf.c
+++ b/examples/c/usdt.bpf.c
@@ -3,6 +3,7 @@
 #include <vmlinux.h>
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_tracing.h>
+#define BPF_USDT_HAS_BPF_COOKIE 0
 #include <bpf/usdt.bpf.h>
 
 pid_t my_pid;

@ANOLASC
Copy link
Author

ANOLASC commented Jul 22, 2022

You can either update your LLVM or apply the following diff:

diff --git a/examples/c/usdt.bpf.c b/examples/c/usdt.bpf.c
index 418aa48..ce6eedd 100644
--- a/examples/c/usdt.bpf.c
+++ b/examples/c/usdt.bpf.c
@@ -3,6 +3,7 @@
 #include <vmlinux.h>
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_tracing.h>
+#define BPF_USDT_HAS_BPF_COOKIE 0
 #include <bpf/usdt.bpf.h>
 
 pid_t my_pid;

Applied it. Now have a new error

  BPF      .output/usdt.bpf.o
  GEN-SKEL .output/usdt.skel.h
libbpf: sec '.relusdt/libc.so.6:libc:setjmp': corrupted symbol #25 pointing to invalid section #65522 for relo #3
Error: failed to open BPF object file: BPF object format invalid
make: *** [Makefile:112: .output/usdt.skel.h] Error 95
make: *** Deleting file '.output/usdt.skel.h'

@anakryiko
Copy link
Member

@ANOLASC, please try to repull libbpf-bootstrap (we've updated libbpf and other stuff meanwhile) and try again? You shouldn't need BPF_USDT_HAS_BPF_COOKIE anymore, btw.

Please also make sure you are using a decently recent LLVM/Clang (as recent as you can). Please also report what Clang version you are using. Thanks.

@ANOLASC
Copy link
Author

ANOLASC commented Aug 8, 2022

@ANOLASC, please try to repull libbpf-bootstrap (we've updated libbpf and other stuff meanwhile) and try again? You shouldn't need BPF_USDT_HAS_BPF_COOKIE anymore, btw.

Please also make sure you are using a decently recent LLVM/Clang (as recent as you can). Please also report what Clang version you are using. Thanks.

Still got the same error issue-1313523553.

I use apt to install clang.

clang --version

clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@anakryiko
Copy link
Member

Clang 10 is pretty old. Try upgrading to something newer. Also please check that your Clang supports BPF target.

@ANOLASC
Copy link
Author

ANOLASC commented Aug 15, 2022

Clang 10 is pretty old. Try upgrading to something newer. Also please check that your Clang supports BPF target.

Make success by upgrading clang to 15. Thx.

@ANOLASC ANOLASC closed this as completed Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants