在 alpine 中构建密件抄送,"does not name a type" 错误
Building bcc in alpine, "does not name a type" error
我正在尝试构建 bcc bcc
Alpine。
这是我写的用来编译的Dockerfile bcc
:
FROM alpine:3.7
RUN apk add --update \
git \
llvm-dev \
llvm-static \
clang-dev \
clang-static \
cmake \
flex-dev \
bison \
luajit-dev \
build-base \
iperf \
linux-headers \
elfutils-dev \
zlib-dev \
python-dev
RUN ln -s /usr/lib/cmake/llvm5/ /usr/lib/cmake/llvm; \
ln -s /usr/include/llvm5/llvm-c/ /usr/include/llvm-c; \
ln -s /usr/include/llvm5/llvm/ /usr/include/llvm
RUN git clone https://github.com/iovisor/bcc.git
WORKDIR /bcc/build
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr
不幸的是,当 运行 make
我偶然发现以下错误:
# make
[ 1%] [FLEX][Lexer] Building scanner with flex 2.6.4
lexer.ll:110: warning, -s option given but default rule can be matched
[ 2%] [BISON][Parser] Building parser with bison 3.0.4
parser.yy:19.9-17: warning: deprecated directive, use ‘%define api.namespace ebpf::cc’ [-Wdeprecated]
%define namespace "ebpf::cc"
^^^^^^^^^
parser.yy:19.9-17: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
%define namespace "ebpf::cc"
^^^^^^^^^
parser.yy:20.9-25: warning: %define variable 'parser_class_name' requires '{...}' values [-Wdeprecated]
%define parser_class_name "BisonParser"
^^^^^^^^^^^^^^^^^
Scanning dependencies of target b_frontend
[ 3%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/loader.cc.o
[ 4%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o
[ 5%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/node.cc.o
[ 6%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/parser.cc.o
[ 7%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/printer.cc.o
[ 8%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/type_check.cc.o
[ 9%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/parser.yy.cc.o
[ 10%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/lexer.ll.cc.o
[ 11%] Linking CXX static library libb_frontend.a
[ 11%] Built target b_frontend
Scanning dependencies of target bcc-loader-static
[ 12%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_syms.cc.o
[ 13%] Building C object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_elf.c.o
[ 14%] Building C object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_perf_map.c.o
[ 15%] Building C object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_proc.c.o
[ 17%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/ns_guard.cc.o
[ 18%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/common.cc.o
[ 19%] Linking CXX static library libbcc-loader-static.a
[ 19%] Built target bcc-loader-static
Scanning dependencies of target bpf-static
[ 20%] Building C object src/cc/CMakeFiles/bpf-static.dir/libbpf.c.o
[ 21%] Building C object src/cc/CMakeFiles/bpf-static.dir/perf_reader.c.o
/bcc/src/cc/perf_reader.c: In function 'read_data_head':
/bcc/src/cc/perf_reader.c:213:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
uint64_t data_head = *((volatile uint64_t *)&perf_header->data_head);
^~~~~~~~
[ 22%] Linking C static library libbpf.a
[ 22%] Built target bpf-static
Scanning dependencies of target api-static
[ 23%] Building CXX object src/cc/api/CMakeFiles/api-static.dir/BPF.cc.o
In file included from /bcc/src/cc/usdt.h:23:0,
from /bcc/src/cc/api/BPF.cc:35:
/bcc/src/cc/ns_guard.h:35:3: error: 'ino_t' does not name a type
ino_t target_ino() const { return target_ino_; }
^~~~~
/bcc/src/cc/ns_guard.h:40:3: error: 'ino_t' does not name a type
ino_t target_ino_;
^~~~~
In file included from /bcc/src/cc/api/BPF.cc:35:0:
/bcc/src/cc/usdt.h: In member function 'ino_t USDT::Context::inode() const':
/bcc/src/cc/usdt.h:259:52: error: 'class ProcMountNS' has no member named 'target_ino'; did you mean 'target_fd_'?
ino_t inode() const { return mount_ns_instance_->target_ino(); }
^~~~~~~~~~
make[2]: *** [src/cc/api/CMakeFiles/api-static.dir/build.make:63: src/cc/api/CMakeFiles/api-static.dir/BPF.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:334: src/cc/api/CMakeFiles/api-static.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
#
如何解决这个问题?
有点明白了。
ino_t
在 src/cc/ns_guard.h
中不可用。我添加了包含定义的 ino_t
:
#include <sys/types.h>
不过,在 Alpine 上构建 bcc
时还有其他障碍:
在文件 tests/cc/test_c_api.cc
中我不得不注释掉这一部分:
if (dlinfo(dlhdl, RTLD_DI_ORIGIN, &libpath) < 0) {
fprintf(stderr, "Unable to find origin of libz.so.1: %s\n", dlerror());
return -1;
}
因为某些原因 RTLD_DI_ORIGIN
不存在于 /usr/include/dlfcn.h
中:
cat /usr/include/dlfcn.h | grep RTLD_DI_ORIGIN
安装几个丢失的包(我更新了有问题的原始 Dockerfile
以包含它们)。
我正在尝试构建 bcc bcc
Alpine。
这是我写的用来编译的Dockerfile bcc
:
FROM alpine:3.7
RUN apk add --update \
git \
llvm-dev \
llvm-static \
clang-dev \
clang-static \
cmake \
flex-dev \
bison \
luajit-dev \
build-base \
iperf \
linux-headers \
elfutils-dev \
zlib-dev \
python-dev
RUN ln -s /usr/lib/cmake/llvm5/ /usr/lib/cmake/llvm; \
ln -s /usr/include/llvm5/llvm-c/ /usr/include/llvm-c; \
ln -s /usr/include/llvm5/llvm/ /usr/include/llvm
RUN git clone https://github.com/iovisor/bcc.git
WORKDIR /bcc/build
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr
不幸的是,当 运行 make
我偶然发现以下错误:
# make
[ 1%] [FLEX][Lexer] Building scanner with flex 2.6.4
lexer.ll:110: warning, -s option given but default rule can be matched
[ 2%] [BISON][Parser] Building parser with bison 3.0.4
parser.yy:19.9-17: warning: deprecated directive, use ‘%define api.namespace ebpf::cc’ [-Wdeprecated]
%define namespace "ebpf::cc"
^^^^^^^^^
parser.yy:19.9-17: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
%define namespace "ebpf::cc"
^^^^^^^^^
parser.yy:20.9-25: warning: %define variable 'parser_class_name' requires '{...}' values [-Wdeprecated]
%define parser_class_name "BisonParser"
^^^^^^^^^^^^^^^^^
Scanning dependencies of target b_frontend
[ 3%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/loader.cc.o
[ 4%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o
[ 5%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/node.cc.o
[ 6%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/parser.cc.o
[ 7%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/printer.cc.o
[ 8%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/type_check.cc.o
[ 9%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/parser.yy.cc.o
[ 10%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/lexer.ll.cc.o
[ 11%] Linking CXX static library libb_frontend.a
[ 11%] Built target b_frontend
Scanning dependencies of target bcc-loader-static
[ 12%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_syms.cc.o
[ 13%] Building C object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_elf.c.o
[ 14%] Building C object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_perf_map.c.o
[ 15%] Building C object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_proc.c.o
[ 17%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/ns_guard.cc.o
[ 18%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/common.cc.o
[ 19%] Linking CXX static library libbcc-loader-static.a
[ 19%] Built target bcc-loader-static
Scanning dependencies of target bpf-static
[ 20%] Building C object src/cc/CMakeFiles/bpf-static.dir/libbpf.c.o
[ 21%] Building C object src/cc/CMakeFiles/bpf-static.dir/perf_reader.c.o
/bcc/src/cc/perf_reader.c: In function 'read_data_head':
/bcc/src/cc/perf_reader.c:213:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
uint64_t data_head = *((volatile uint64_t *)&perf_header->data_head);
^~~~~~~~
[ 22%] Linking C static library libbpf.a
[ 22%] Built target bpf-static
Scanning dependencies of target api-static
[ 23%] Building CXX object src/cc/api/CMakeFiles/api-static.dir/BPF.cc.o
In file included from /bcc/src/cc/usdt.h:23:0,
from /bcc/src/cc/api/BPF.cc:35:
/bcc/src/cc/ns_guard.h:35:3: error: 'ino_t' does not name a type
ino_t target_ino() const { return target_ino_; }
^~~~~
/bcc/src/cc/ns_guard.h:40:3: error: 'ino_t' does not name a type
ino_t target_ino_;
^~~~~
In file included from /bcc/src/cc/api/BPF.cc:35:0:
/bcc/src/cc/usdt.h: In member function 'ino_t USDT::Context::inode() const':
/bcc/src/cc/usdt.h:259:52: error: 'class ProcMountNS' has no member named 'target_ino'; did you mean 'target_fd_'?
ino_t inode() const { return mount_ns_instance_->target_ino(); }
^~~~~~~~~~
make[2]: *** [src/cc/api/CMakeFiles/api-static.dir/build.make:63: src/cc/api/CMakeFiles/api-static.dir/BPF.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:334: src/cc/api/CMakeFiles/api-static.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
#
如何解决这个问题?
有点明白了。
ino_t
在 src/cc/ns_guard.h
中不可用。我添加了包含定义的 ino_t
:
#include <sys/types.h>
不过,在 Alpine 上构建 bcc
时还有其他障碍:
在文件
tests/cc/test_c_api.cc
中我不得不注释掉这一部分:if (dlinfo(dlhdl, RTLD_DI_ORIGIN, &libpath) < 0) { fprintf(stderr, "Unable to find origin of libz.so.1: %s\n", dlerror()); return -1; }
因为某些原因
RTLD_DI_ORIGIN
不存在于/usr/include/dlfcn.h
中:cat /usr/include/dlfcn.h | grep RTLD_DI_ORIGIN
安装几个丢失的包(我更新了有问题的原始
Dockerfile
以包含它们)。