Comments (8)
OK, seems like I used brute force that did the trick, but there are nicer ways. Thanks a lot for your help on finding a workaround @qmonnet . Closing
from bpftool.
I tried this on a debian docker image, and it still doesn't link, and I'm getting a whole bunch of errors like:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libbfd.a(plugin.o): in function `try_load_plugin':
/build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/plugin.c:228: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libbfd.a(elf64-x86-64.o): in function `elf_x86_64_output_arch_local_syms':
/build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/elf64-x86-64.c:4551: undefined reference to `htab_traverse'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libbfd.a(elf.o): in function `_bfd_elf_is_local_label_name':
/build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/elf.c:8682: undefined reference to `_sch_istable'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libbfd.a(elflink.o): in function `elf_link_add_object_symbols':
/build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/elflink.c:5211: undefined reference to `objalloc_free_block'
/usr/bin/ld: /build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/elflink.c:5462: undefined reference to `_sch_istable'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libbfd.a(elflink.o): in function `bfd_elf_size_dynamic_sections':
/build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/elflink.c:6655: undefined reference to `lbasename'
/usr/bin/ld: /build/binutils-lybw70/binutils-2.31.1/builddir-single/bfd/../../bfd/elflink.c:6428: undefined reference to `lbasename'
I'm trying to build/link it similar to the instructions here: https://github.com/projectcalico/bpftool, but instead of building it from the Linux kernel, I thought it would be faster to git clone
this repo instead, but it doesn't seem to work when trying to statically link it.
P.S. Without the CFLAGS=--static
part, it works, but I need the binary statically linked
from bpftool.
Hi, and thanks for the report! The README specifies that note that this does not work out-of-the-box when linking with libbfd
, and this is what you're facing (at least on Debian).
I haven't found the time to look into the details for compiling statically with libbfd or llvm. I've been told that it works with LLVM, provided that the statically compiled version of the library is installed. For libbfd, it seems the libbfd.a library on the system is not enough, but I need to dig more to figure out the cause of these messages. Eventually we probably want to try static builds in the CI, too.
In the meantime, a quick workaround would be to disable linking against libbfd/llvm; then CFLAGS=--static make
works for me (tested on Ubuntu). At the moment you have to edit the Makefile to disable libbfd/llvm, though.
from bpftool.
@qmonnet oh hey thanks for the quick reply. Can I ask what did you modify in the Makefile to disable libbfd/llvm? I can try it on my Debian box, and if it doesn't work, I can certainly try it on Ubuntu as well.
from bpftool.
Ah I figured it out, just putting it here in case others might need a workaround:
root@eb84dabef474:/bpftool/src# ldd bpftool
not a dynamic executable
root@eb84dabef474:/bpftool/src# git diff Makefile
diff --git a/src/Makefile b/src/Makefile
index c2b9200..b12f82d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -20,6 +20,9 @@ else
endif
BOOTSTRAP_OUTPUT := $(_OUTPUT)bootstrap/
+feature-llvm := 0
+feature-libbfd := 0
+
LIBBPF_OUTPUT := $(_OUTPUT)libbpf/
LIBBPF_DESTDIR := $(LIBBPF_OUTPUT)
LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include
@@ -143,11 +146,11 @@ ifeq ($(feature-llvm),1)
else
# Fall back on libbfd
ifeq ($(feature-libbfd),1)
- LIBS += -lbfd -ldl -lopcodes
+ LIBS += -ldl -lopcodes
else ifeq ($(feature-libbfd-liberty),1)
- LIBS += -lbfd -ldl -lopcodes -liberty
+ LIBS += -ldl -lopcodes -liberty
else ifeq ($(feature-libbfd-liberty-z),1)
- LIBS += -lbfd -ldl -lopcodes -liberty -lz
+ LIBS += -ldl -lopcodes -liberty -lz
endif
# If one of the above feature combinations is set, we support libbfd
from bpftool.
Yes, disabling them should be doable just by changing FEATURE_TESTS
, but I realise the Makefile.feature
I did for this repo ignores FEATURE_TESTS
and always run the detection. I'll fix that soon.
from bpftool.
It was a useful report, I opened another issue as a follow-up.
from bpftool.
I also fixed the usage of FEATURE_TESTS
in the Makefile, so it's easier to tweak it to disable some features.
from bpftool.
Related Issues (20)
- Print error and exit instead of diplaying an empty map for unsupported map types
- Fix weird indent in documentation HOT 1
- streamline bpftool net dump HOT 1
- "make install" for man pages stops. HOT 1
- Wrong callq address displayed HOT 5
- Error: No JIT disassembly support HOT 2
- "libbpf: map 'xxx': unsupported map linkage static" in Android HOT 7
- Have bpftool return ID of created objects
- Attach programs to tcx HOT 2
- The proper usage of `bpftool prog attach` HOT 2
- BPFTool Prog Loadall command Deletes /sys/fs/cgroup virtual file system directory HOT 3
- bpftool: error while loading shared libraries: libLLVM-17.so: cannot open shared object file: No such file or directory HOT 14
- use bpftool dump this bpf_prog_982904fb4a4dfbdb_tracepoint_sche at 0x8a0/0x1000 how to do it? HOT 1
- Typo: `cgroup/sendmsg°unix`
- Check that the list of supported programs, map types, attach types, ... are up-to-date HOT 1
- Dump libbpf's output for `build_obj_refs_table()` when user asks for debug info HOT 2
- When loading eBPF binary with bpftool, the 'bpf_trace_printk' seems no output to '/sys/kernel/debug/tracing/trace_pipe' HOT 8
- bpftool 7.4.0 prog load Segmentation fault (core dumped) HOT 2
- Missing bpffs mount when pinning maps for prog load (`pinmaps`) HOT 6
- Cannot list programs attached to cgroup HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bpftool.