From 194fef33cfa9c020ef4c3e3d09bab39aa4b02eb1 Mon Sep 17 00:00:00 2001 From: Krister Johansen Date: Mon, 30 Jul 2018 21:37:04 -0700 Subject: [PATCH 1/5] Get bcc project building again. Signed-off-by: Krister Johansen --- projects/ebpf/ebpf.build/Dockerfile | 14 +++++-- projects/ebpf/ebpf.build/Makefile | 2 +- projects/ebpf/ebpf.build/bcc-gnuism.patch | 9 +++-- projects/ebpf/ebpf.build/bcc-lua.patch | 43 ++++++++++++++++++++ projects/ebpf/ebpf.pkg/Dockerfile | 49 ++++++++++++++++++++--- projects/ebpf/ebpf.pkg/Makefile | 4 +- 6 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 projects/ebpf/ebpf.build/bcc-lua.patch diff --git a/projects/ebpf/ebpf.build/Dockerfile b/projects/ebpf/ebpf.build/Dockerfile index 6d558a9ff..de0ebea7b 100644 --- a/projects/ebpf/ebpf.build/Dockerfile +++ b/projects/ebpf/ebpf.build/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.5 +FROM alpine:3.7 RUN apk update && apk upgrade -a && \ apk add --no-cache \ argp-standalone \ @@ -8,6 +8,7 @@ RUN apk update && apk upgrade -a && \ build-base \ clang \ clang-dev \ + clang-static \ cmake \ curl \ flex-dev \ @@ -25,6 +26,11 @@ RUN apk update && apk upgrade -a && \ python \ zlib-dev \ && true + +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 + WORKDIR /build COPY . ./ COPY Dockerfile / @@ -37,8 +43,8 @@ RUN cat elfutils-$ELFUTILS_VERSION.tar.bz2 | tar xjf - && \ patch -p1 < ../100-musl-compat.patch && \ patch -p0 < ../decl.patch && \ patch -p0 < ../intl.patch -ENV BCC_COMMIT=d4fc95d92ec9bace9bd607dfd1833e9e06457486 +ENV BCC_COMMIT=6972806729da00ecda0235abac61d66c8fad7fad RUN git clone https://github.com/iovisor/bcc.git && cd bcc && git checkout $BCC_COMMIT -RUN cd bcc && patch -p0 < ../bcc-gnuism.patch -ENV LJSYSCALL_COMMIT=0b266e8f4f751ae894299d24a2d40d16c6cf856f +RUN cd bcc && patch -p0 < ../bcc-gnuism.patch && patch -p0 < ../bcc-lua.patch +ENV LJSYSCALL_COMMIT=e587f8c55aad3955dddab3a4fa6c1968037b5c6e RUN git clone https://github.com/justincormack/ljsyscall.git && cd ljsyscall && git checkout $LJSYSCALL_COMMIT diff --git a/projects/ebpf/ebpf.build/Makefile b/projects/ebpf/ebpf.build/Makefile index dc0021639..1b4fec7a1 100644 --- a/projects/ebpf/ebpf.build/Makefile +++ b/projects/ebpf/ebpf.build/Makefile @@ -1,6 +1,6 @@ .PHONY: tag push -BASE=alpine:3.5 +BASE=alpine:3.7 IMAGE=alpine-build-ebpf default: push diff --git a/projects/ebpf/ebpf.build/bcc-gnuism.patch b/projects/ebpf/ebpf.build/bcc-gnuism.patch index 539e24519..3312fde0e 100644 --- a/projects/ebpf/ebpf.build/bcc-gnuism.patch +++ b/projects/ebpf/ebpf.build/bcc-gnuism.patch @@ -1,9 +1,9 @@ --- src/cc/usdt.h-orig +++ src/cc/usdt.h -@@ -86,6 +86,24 @@ - ArgumentParser(const char *arg) : arg_(arg), cur_pos_(0) {} +@@ -125,6 +125,24 @@ public: + ArgumentParser_powerpc64(const char *arg) : ArgumentParser(arg) {} }; - + +#undef REG_A +#undef REG_B +#undef REG_C @@ -23,5 +23,6 @@ +#undef REG_RIP + class ArgumentParser_x64 : public ArgumentParser { + private: enum Register { - REG_A, + diff --git a/projects/ebpf/ebpf.build/bcc-lua.patch b/projects/ebpf/ebpf.build/bcc-lua.patch new file mode 100644 index 000000000..b10eb1b0c --- /dev/null +++ b/projects/ebpf/ebpf.build/bcc-lua.patch @@ -0,0 +1,43 @@ +--- src/cc/CMakeLists.txt ++++ src/cc/CMakeLists.txt +@@ -52,7 +52,7 @@ target_link_libraries(bcc-loader-static elf) + add_library(bcc-static STATIC + ${bcc_common_sources} ${bcc_table_sources} ${bcc_util_sources}) + set_target_properties(bcc-static PROPERTIES OUTPUT_NAME bcc) +-set(bcc-lua-static ++add_library(bcc-lua-static STATIC + ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} ${bcc_util_sources}) + + include(clang_libs) +@@ -64,9 +64,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${llvm_lib_exclude_f + set(bcc_common_libs_for_a b_frontend clang_frontend bpf-static + -Wl,--whole-archive ${clang_libs} ${llvm_libs} -Wl,--no-whole-archive + ${LIBELF_LIBRARIES}) +-set(bcc_common_libs_for_s ${bcc_common_libs_for_a}) +-set(bcc_common_libs_for_lua b_frontend clang_frontend bpf-static ++set(bcc_common_libs_for_s b_frontend clang_frontend bpf-static + ${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES}) ++set(bcc_common_libs_for_lua ${bcc_common_libs_for_s}) + + if(ENABLE_CPP_API) + add_subdirectory(api) +@@ -87,7 +87,7 @@ add_subdirectory(frontends) + # Link against LLVM libraries + target_link_libraries(bcc-shared ${bcc_common_libs_for_s}) + target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static) +-set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua}) ++target_link_libraries(bcc-lua-static ${bcc_common_libs_for_lua}) + + install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${bcc_table_headers} DESTINATION include/bcc) +--- src/lua/CMakeLists.txt ++++ src/lua/CMakeLists.txt +@@ -23,7 +23,7 @@ if (LUAJIT_LIBRARIES AND LUAJIT) + add_executable(bcc-lua src/main.c bcc.o) + set_target_properties(bcc-lua PROPERTIES LINKER_LANGUAGE C) + target_link_libraries(bcc-lua ${LUAJIT_LIBRARIES}) +- target_link_libraries(bcc-lua ${bcc-lua-static}) ++ target_link_libraries(bcc-lua -Wl,--whole-archive bcc-lua-static -Wl,--no-whole-archive) + if (NOT COMPILER_NOPIE_FLAG EQUAL "") + target_link_libraries(bcc-lua ${COMPILER_NOPIE_FLAG}) + endif() diff --git a/projects/ebpf/ebpf.pkg/Dockerfile b/projects/ebpf/ebpf.pkg/Dockerfile index a1bf7472e..dcd43df69 100644 --- a/projects/ebpf/ebpf.pkg/Dockerfile +++ b/projects/ebpf/ebpf.pkg/Dockerfile @@ -1,17 +1,54 @@ -# Tag: cc5bf4d39442741eaeffad79bbd9ae049a9253fa -FROM mobylinux/alpine-build-ebpf@sha256:da37d99a8baad18e68c44d3807c86977767ed90ce03133b508842eea3b786d3a +#FROM mobylinux/alpine-build-ebpf@sha256:da37d99a8baad18e68c44d3807c86977767ed90ce03133b508842eea3b786d3a +ARG IMAGE +FROM ${IMAGE} as ksrc +FROM alpine-build-ebpf:build as build -ADD kernel-headers.tar / -ADD kernel-dev.tar / -ADD kernel-modules.tar / +COPY --from=ksrc /kernel-headers.tar /build +RUN tar xf /build/kernel-headers.tar + +COPY --from=ksrc /kernel-dev.tar /build +RUN tar xf /build/kernel-dev.tar + +COPY --from=ksrc /kernel.tar /build +RUN tar xf /build/kernel.tar + +RUN cd /build RUN cd elfutils-$ELFUTILS_VERSION && \ + aclocal && \ automake && \ ./configure --prefix=/usr CFLAGS=-Wno-strict-aliasing && \ make -C libelf && make -C libelf install RUN mkdir -p bcc/build && cd bcc/build && \ - cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DLUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1 && \ + cmake .. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_C_FLAGS="-I/build/usr/include" -DCMAKE_CXX_FLAGS="-I/build/usr/include" -DCMAKE_INSTALL_PREFIX=/usr -DLUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1 && \ make && \ make install RUN mkdir -p /usr/local/share/lua/5.1/ && cd ljsyscall && cp -a *.lua syscall /usr/local/share/lua/5.1/ ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib64 + +FROM alpine:3.7 as mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk update && apk upgrade -a && \ + apk add --no-cache --initdb -p /out \ + busybox \ + luajit \ + python \ + strace \ + zlib \ + && true + +FROM scratch +ENTRYPOINT [] +CMD [] +WORKDIR / +COPY --from=mirror /out / +COPY --from=build /build/usr/src /usr/src/ +COPY --from=build /build/usr/include /usr/include/ +COPY --from=build /usr/lib/libelf* /usr/lib/ +COPY --from=build /usr/lib/libstdc* /usr/lib/ +COPY --from=build /usr/lib/libintl* /usr/lib/ +COPY --from=build /usr/lib64 /usr/lib/ +COPY --from=build /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages/ +COPY --from=build /usr/share/bcc /usr/share/bcc/ +COPY --from=build /usr/bin/bcc-lua /usr/bin/ +COPY --from=build /usr/local/share/lua /usr/local/share/lua/ diff --git a/projects/ebpf/ebpf.pkg/Makefile b/projects/ebpf/ebpf.pkg/Makefile index 850e21d6f..ca021be79 100644 --- a/projects/ebpf/ebpf.pkg/Makefile +++ b/projects/ebpf/ebpf.pkg/Makefile @@ -1,9 +1,9 @@ -KERNEL_FILES=-C ../alpine/kernel/x86_64 kernel-headers.tar kernel-dev.tar kernel-modules.tar +KERNEL_IMAGE=iad.ocir.io/odx-fn/linuxkit/kernel:4.14.48-ee964ca1fb8641370812be8ef4592b2708d3551b-amd64 default: ebpf.tag ebpf.tag: Dockerfile - BUILD=$$( tar cf - $^ $(KERNEL_FILES) | docker build -q - ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \ + BUILD=$$( docker build -q --build-arg IMAGE=$(KERNEL_IMAGE) . ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \ echo $$BUILD > $@ clean: From 188595fcb5c86bf4eba43786d60fe06647643d67 Mon Sep 17 00:00:00 2001 From: Krister Johansen Date: Mon, 30 Jul 2018 21:37:14 -0700 Subject: [PATCH 2/5] Pull bcc into kernel build. Signed-off-by: Krister Johansen --- kernel/Dockerfile.bcc | 112 ++++ kernel/Makefile | 41 ++ kernel/bcc.patches/100-musl-compat.patch | 788 +++++++++++++++++++++++ kernel/bcc.patches/bcc-gnuism.patch | 28 + kernel/bcc.patches/bcc-lua.patch | 43 ++ kernel/bcc.patches/cdefs.h | 628 ++++++++++++++++++ kernel/bcc.patches/decl.patch | 23 + kernel/bcc.patches/error.h | 29 + kernel/bcc.patches/intl.patch | 11 + kernel/bcc.patches/temp_failure.patch | 17 + 10 files changed, 1720 insertions(+) create mode 100644 kernel/Dockerfile.bcc create mode 100644 kernel/bcc.patches/100-musl-compat.patch create mode 100644 kernel/bcc.patches/bcc-gnuism.patch create mode 100644 kernel/bcc.patches/bcc-lua.patch create mode 100644 kernel/bcc.patches/cdefs.h create mode 100644 kernel/bcc.patches/decl.patch create mode 100644 kernel/bcc.patches/error.h create mode 100644 kernel/bcc.patches/intl.patch create mode 100644 kernel/bcc.patches/temp_failure.patch diff --git a/kernel/Dockerfile.bcc b/kernel/Dockerfile.bcc new file mode 100644 index 000000000..0085b7658 --- /dev/null +++ b/kernel/Dockerfile.bcc @@ -0,0 +1,112 @@ +ARG IMAGE +FROM ${IMAGE} as ksrc + +FROM linuxkit/alpine:8a89682421abf0d886d777235a05f4a04a736df2 AS build +RUN apk update && apk upgrade -a && \ + apk add --no-cache \ + argp-standalone \ + autoconf \ + automake \ + bison \ + build-base \ + clang \ + clang-dev \ + clang-static \ + cmake \ + curl \ + flex-dev \ + fts-dev \ + gettext-dev \ + git \ + iperf3 \ + libedit-dev \ + libtool \ + llvm \ + llvm-dev \ + llvm-static \ + luajit-dev \ + m4 \ + python \ + zlib-dev \ + && true + +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 + +WORKDIR /build +COPY ./bcc.patches/ ./ +RUN mv error.h /usr/include/ +RUN mv cdefs.h /usr/include/sys/ +ENV ELFUTILS_VERSION=0.165 +ENV ELFUTILS_SHA256="a7fc9277192caaa5f30b47e8c0518dbcfd8c4a19c6493a63d511d804290ce972" +RUN curl -sSL -O https://fedorahosted.org/releases/e/l/elfutils/0.165/elfutils-$ELFUTILS_VERSION.tar.bz2 + +RUN echo "${ELFUTILS_SHA256} /build/elfutils-$ELFUTILS_VERSION.tar.bz2" | sha256sum -c - && \ + tar xjf elfutils-$ELFUTILS_VERSION.tar.bz2 && \ + cd elfutils-$ELFUTILS_VERSION && \ + patch -p1 < ../100-musl-compat.patch && \ + patch -p0 < ../decl.patch && \ + patch -p0 < ../intl.patch +ENV BCC_COMMIT=6972806729da00ecda0235abac61d66c8fad7fad +RUN git clone https://github.com/iovisor/bcc.git && cd bcc && git checkout $BCC_COMMIT +RUN cd bcc && patch -p0 < ../bcc-gnuism.patch && patch -p0 < ../bcc-lua.patch +ENV LJSYSCALL_COMMIT=e587f8c55aad3955dddab3a4fa6c1968037b5c6e +RUN git clone https://github.com/justincormack/ljsyscall.git && cd ljsyscall && git checkout $LJSYSCALL_COMMIT + +COPY --from=ksrc /kernel-headers.tar /build +RUN tar xf /build/kernel-headers.tar + +COPY --from=ksrc /kernel-dev.tar /build +RUN tar xf /build/kernel-dev.tar + +COPY --from=ksrc /kernel.tar /build +RUN tar xf /build/kernel.tar + +RUN cd /build +RUN cd elfutils-$ELFUTILS_VERSION && \ + aclocal && \ + automake && \ + ./configure --prefix=/usr CFLAGS=-Wno-strict-aliasing && \ + make -C libelf && make -C libelf install +RUN mkdir -p bcc/build && cd bcc/build && \ + cmake .. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_C_FLAGS="-I/build/usr/include" -DCMAKE_CXX_FLAGS="-I/build/usr/include" -DCMAKE_INSTALL_PREFIX=/usr -DLUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1 && \ + make && \ + make install +RUN mkdir -p /usr/local/share/lua/5.1/ && cd ljsyscall && cp -a *.lua syscall /usr/local/share/lua/5.1/ +RUN mkdir -p /out/usr/ +RUN cp -a /build/usr/src /out/usr/ +RUN cp -a /build/usr/include /out/usr +RUN mkdir -p /out/usr/lib +RUN cp -a /usr/lib/libelf* /out/usr/lib/ +RUN cp -a /usr/lib/libstdc* /out/usr/lib/ +RUN cp -a /usr/lib/libintl* /out/usr/lib/ +RUN cp -a /usr/lib64/* /out/usr/lib/ +RUN mkdir -p /out/usr/lib/python2.7 +RUN cp -a /usr/lib/python2.7/site-packages /out/usr/lib/python2.7/ +RUN mkdir -p /out/usr/share +RUN cp -a /usr/share/bcc /out/usr/share/ +RUN mkdir -p /out/usr/bin +RUN cp -a /usr/bin/bcc-lua /out/usr/bin/ +RUN mkdir -p /out/usr/local/share/ +RUN cp -a /usr/local/share/lua /out/usr/local/share/ + +ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib64 + +FROM linuxkit/alpine:8a89682421abf0d886d777235a05f4a04a736df2 as mirror +RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ +RUN apk update && apk upgrade -a && \ + apk add --no-cache --initdb -p /out \ + busybox \ + luajit \ + python \ + zlib \ + && true + +FROM scratch +ENTRYPOINT [] +CMD [] +WORKDIR / +COPY --from=mirror /out / +COPY --from=build /out / + diff --git a/kernel/Makefile b/kernel/Makefile index 2ea93a217..a615eb7d5 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -15,6 +15,7 @@ # Name and Org on Hub ORG?=linuxkit IMAGE:=kernel +IMAGE_BCC:=kernel-bcc IMAGE_PERF:=kernel-perf IMAGE_ZFS:=zfs-kmod @@ -192,6 +193,46 @@ push: push_perf_$(2)$(3)$(4) forcepush: forcepush_perf_$(2)$(3)$(4) endif +# For BCC, only build on x86 and only on latest LTS and latest stable. +# That's 4.14.x and 4.17.x at time of authorship. +ifeq ($(ARCH),x86_64) +ifeq ($(2), $(filter $(2),4.14.x 4.17.x)) +build_bcc_$(2)$(3)$(4): build_$(2)$(3)$(4) + docker pull $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) || \ + DOCKER_CONTENT_TRUST=0 docker build -f Dockerfile.bcc \ + --build-arg IMAGE=$(ORG)/$(IMAGE):$(1)$(3)$(4)-$(TAG)$(SUFFIX) \ + --no-cache $(LABEL) -t $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) . + +forcebuild_bcc_$(2)$(3)$(4): build_$(2)$(3)$(4) + DOCKER_CONTENT_TRUST=0 docker build -f Dockerfile.bcc \ + --build-arg IMAGE=$(ORG)/$(IMAGE):$(1)$(3)$(4)-$(TAG)$(SUFFIX) \ + --no-cache $(LABEL) -t $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) . + +push_bcc_$(2)$(3)$(4): build_bcc_$(2)$(3)$(4) + @if [ x"$(DIRTY)" != x ]; then echo "Your repository is not clean. Will not push image"; exit 1; fi + docker pull $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) || \ + (docker push $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) && \ + docker tag $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)$(SUFFIX) && \ + docker push $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)$(SUFFIX) && \ + $(PUSH_MANIFEST) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG) $(DOCKER_CONTENT_TRUST) && \ + $(PUSH_MANIFEST) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4) $(DOCKER_CONTENT_TRUST)) + +forcepush_bcc_$(2)$(3)$(4): forcebuild_bcc_$(2)$(3)$(4) + @if [ x"$(DIRTY)" != x ]; then echo "Your repository is not clean. Will not push image"; exit 1; fi + docker push $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) && \ + docker tag $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG)$(SUFFIX) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)$(SUFFIX) && \ + docker push $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)$(SUFFIX) && \ + $(PUSH_MANIFEST) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG) $(DOCKER_CONTENT_TRUST) && \ + $(PUSH_MANIFEST) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4) $(DOCKER_CONTENT_TRUST) + + +build: build_bcc_$(2)$(3)$(4) +forcebuild: forcebuild_bcc_$(2)$(3)$(4) +push: push_bcc_$(2)$(3)$(4) +forcepush: forcepush_bcc_$(2)$(3)$(4) +endif +endif + ifeq ($(4),) # ZFS does not compile against -dbg kernels because CONFIG_DEBUG_LOCK_ALLOC # is incompatible with CDDL, apparently (this is ./configure check) diff --git a/kernel/bcc.patches/100-musl-compat.patch b/kernel/bcc.patches/100-musl-compat.patch new file mode 100644 index 000000000..25e15047a --- /dev/null +++ b/kernel/bcc.patches/100-musl-compat.patch @@ -0,0 +1,788 @@ +--- a/lib/system.h ++++ b/lib/system.h +@@ -68,6 +68,16 @@ extern int crc32_file (int fd, uint32_t + + #define gettext_noop(Str) Str + ++#ifndef TEMP_FAILURE_RETRY ++#define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif ++ ++#define error(status, errno, ...) err(status, __VA_ARGS__) + + static inline ssize_t __attribute__ ((unused)) + pwrite_retry (int fd, const void *buf, size_t len, off_t off) +--- a/lib/color.c ++++ b/lib/color.c +@@ -32,7 +32,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/lib/xmalloc.c ++++ b/lib/xmalloc.c +@@ -30,7 +30,7 @@ + # include + #endif + +-#include ++#include + #include + #include + #include +--- a/src/addr2line.c ++++ b/src/addr2line.c +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/ar.c ++++ b/src/ar.c +@@ -22,7 +22,7 @@ + + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/arlib2.c ++++ b/src/arlib2.c +@@ -20,7 +20,7 @@ + # include + #endif + +-#include ++#include + #include + #include + #include +--- a/src/arlib.c ++++ b/src/arlib.c +@@ -21,7 +21,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/src/elfcmp.c ++++ b/src/elfcmp.c +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -24,7 +24,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/findtextrel.c ++++ b/src/findtextrel.c +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/i386_ld.c ++++ b/src/i386_ld.c +@@ -20,7 +20,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/src/ld.c ++++ b/src/ld.c +@@ -21,7 +21,7 @@ + + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/ldgeneric.c ++++ b/src/ldgeneric.c +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/ldlex.c ++++ b/src/ldlex.c +@@ -1106,7 +1106,7 @@ char *ldtext; + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/ldscript.c ++++ b/src/ldscript.c +@@ -95,7 +95,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +@@ -106,7 +106,7 @@ + #include + #include + +-/* The error handler. */ ++/* The err.handler. */ + static void yyerror (const char *s); + + /* Some helper functions we need to construct the data structures +--- a/src/nm.c ++++ b/src/nm.c +@@ -26,7 +26,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/objdump.c ++++ b/src/objdump.c +@@ -21,7 +21,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/src/ranlib.c ++++ b/src/ranlib.c +@@ -24,7 +24,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/readelf.c ++++ b/src/readelf.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/size.c ++++ b/src/size.c +@@ -21,7 +21,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/src/stack.c ++++ b/src/stack.c +@@ -18,7 +18,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/strings.c ++++ b/src/strings.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/strip.c ++++ b/src/strip.c +@@ -24,7 +24,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/unstrip.c ++++ b/src/unstrip.c +@@ -31,7 +31,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/tests/addrscopes.c ++++ b/tests/addrscopes.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + + +--- a/tests/allregs.c ++++ b/tests/allregs.c +@@ -21,7 +21,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/tests/backtrace.c ++++ b/tests/backtrace.c +@@ -24,7 +24,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #ifdef __linux__ +--- a/tests/backtrace-data.c ++++ b/tests/backtrace-data.c +@@ -27,7 +27,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #if defined(__x86_64__) && defined(__linux__) +--- a/tests/buildid.c ++++ b/tests/buildid.c +@@ -23,7 +23,7 @@ + #include ELFUTILS_HEADER(elf) + #include ELFUTILS_HEADER(dwelf) + #include +-#include ++#include + #include + #include + #include +--- a/tests/debugaltlink.c ++++ b/tests/debugaltlink.c +@@ -23,7 +23,7 @@ + #include ELFUTILS_HEADER(dw) + #include ELFUTILS_HEADER(dwelf) + #include +-#include ++#include + #include + #include + #include +--- a/tests/debuglink.c ++++ b/tests/debuglink.c +@@ -21,7 +21,7 @@ + #include + #include ELFUTILS_HEADER(dwelf) + #include +-#include ++#include + #include + #include + #include +--- a/tests/dwfl-addr-sect.c ++++ b/tests/dwfl-addr-sect.c +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include ELFUTILS_HEADER(dwfl) +--- a/tests/dwfl-bug-addr-overflow.c ++++ b/tests/dwfl-bug-addr-overflow.c +@@ -20,7 +20,7 @@ + #include + #include + #include +-#include ++#include + #include + #include ELFUTILS_HEADER(dwfl) + +--- a/tests/dwfl-bug-fd-leak.c ++++ b/tests/dwfl-bug-fd-leak.c +@@ -24,7 +24,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/tests/dwfl-bug-getmodules.c ++++ b/tests/dwfl-bug-getmodules.c +@@ -18,7 +18,7 @@ + #include + #include ELFUTILS_HEADER(dwfl) + +-#include ++#include + + static const Dwfl_Callbacks callbacks = + { +--- a/tests/dwfllines.c ++++ b/tests/dwfllines.c +@@ -27,7 +27,7 @@ + #include + #include + #include +-#include ++#include + + int + main (int argc, char *argv[]) +--- a/tests/dwflmodtest.c ++++ b/tests/dwflmodtest.c +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include ELFUTILS_HEADER(dwfl) +--- a/tests/dwfl-report-elf-align.c ++++ b/tests/dwfl-report-elf-align.c +@@ -20,7 +20,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/tests/dwflsyms.c ++++ b/tests/dwflsyms.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + + static const char * +--- a/tests/early-offscn.c ++++ b/tests/early-offscn.c +@@ -19,7 +19,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/tests/ecp.c ++++ b/tests/ecp.c +@@ -20,7 +20,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/tests/find-prologues.c ++++ b/tests/find-prologues.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +--- a/tests/funcretval.c ++++ b/tests/funcretval.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +--- a/tests/funcscopes.c ++++ b/tests/funcscopes.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +--- a/tests/line2addr.c ++++ b/tests/line2addr.c +@@ -26,7 +26,7 @@ + #include + #include + #include +-#include ++#include + + + static void +--- a/tests/low_high_pc.c ++++ b/tests/low_high_pc.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +--- a/tests/md5-sha1-test.c ++++ b/tests/md5-sha1-test.c +@@ -19,7 +19,7 @@ + #endif + + #include +-#include ++#include + + #include "md5.h" + #include "sha1.h" +--- a/tests/rdwrmmap.c ++++ b/tests/rdwrmmap.c +@@ -19,7 +19,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/tests/saridx.c ++++ b/tests/saridx.c +@@ -17,7 +17,7 @@ + + #include + +-#include ++#include + #include + #include + #include +--- a/tests/sectiondump.c ++++ b/tests/sectiondump.c +@@ -18,7 +18,7 @@ + #include + + #include +-#include ++#include + #include + #include + #include +--- a/tests/varlocs.c ++++ b/tests/varlocs.c +@@ -25,7 +25,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/libelf/libelf.h ++++ b/libelf/libelf.h +@@ -29,6 +29,7 @@ + #ifndef _LIBELF_H + #define _LIBELF_H 1 + ++#include + #include + #include + +--- a/libasm/asm_end.c ++++ b/libasm/asm_end.c +@@ -32,7 +32,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/libasm/asm_newscn.c ++++ b/libasm/asm_newscn.c +@@ -32,7 +32,7 @@ + #endif + + #include +-#include ++#include + #include + #include + #include +--- a/libcpu/i386_gendis.c ++++ b/libcpu/i386_gendis.c +@@ -31,7 +31,7 @@ + # include + #endif + +-#include ++#include + #include + #include + #include +--- a/libcpu/i386_lex.c ++++ b/libcpu/i386_lex.c +@@ -578,7 +578,7 @@ char *i386_text; + #endif + + #include +-#include ++#include + #include + + #include +--- a/libcpu/i386_lex.l ++++ b/libcpu/i386_lex.l +@@ -31,7 +31,7 @@ + #endif + + #include +-#include ++#include + #include + + #include +--- a/libcpu/i386_parse.c ++++ b/libcpu/i386_parse.c +@@ -107,7 +107,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/libdw/libdw_alloc.c ++++ b/libdw/libdw_alloc.c +@@ -31,7 +31,7 @@ + # include + #endif + +-#include ++#include + #include + #include + #include +@@ -74,5 +74,5 @@ __attribute ((noreturn, visibility ("hid + __libdw_oom (void) + { + while (1) +- error (EXIT_FAILURE, ENOMEM, "libdw"); ++ err (EXIT_FAILURE, "libdw: out of memory"); + } +--- a/libebl/eblopenbackend.c ++++ b/libebl/eblopenbackend.c +@@ -32,7 +32,7 @@ + + #include + #include +-#include ++#include + #include + #include + #include +--- a/src/ldlex.l ++++ b/src/ldlex.l +@@ -23,7 +23,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +--- a/libebl/eblwstrtab.c ++++ b/libebl/eblwstrtab.c +@@ -305,7 +305,7 @@ copystrings (struct Ebl_WStrent *nodep, + + /* Process the current node. */ + nodep->offset = *offsetp; +- *freep = wmempcpy (*freep, nodep->string, nodep->len); ++ *freep = wmemcpy (*freep, nodep->string, nodep->len) + nodep->len; + *offsetp += nodep->len * sizeof (wchar_t); + + for (subs = nodep->next; subs != NULL; subs = subs->next) +--- a/libdwfl/dwfl_error.c ++++ b/libdwfl/dwfl_error.c +@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) + const char * + dwfl_errmsg (int error) + { ++ static __thread char s[64] = ""; + if (error == 0 || error == -1) + { + int last_error = global_error; +@@ -154,7 +155,8 @@ dwfl_errmsg (int error) + switch (error &~ 0xffff) + { + case OTHER_ERROR (ERRNO): +- return strerror_r (error & 0xffff, "bad", 0); ++ strerror_r (error & 0xffff, s, sizeof(s)); ++ return s; + case OTHER_ERROR (LIBELF): + return elf_errmsg (error & 0xffff); + case OTHER_ERROR (LIBDW): +--- a/libdwfl/libdwfl.h ++++ b/libdwfl/libdwfl.h +@@ -31,6 +31,27 @@ + + #include "libdw.h" + #include ++#include ++#include ++#include ++ ++#ifndef TEMP_FAILURE_RETRY ++#define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif ++ ++#ifndef strndupa ++#define strndupa(s, n) \ ++ (__extension__ ({const char *__in = (s); \ ++ size_t __len = strnlen (__in, (n)) + 1; \ ++ char *__out = (char *) alloca (__len); \ ++ __out[__len-1] = '\0'; \ ++ (char *) memcpy (__out, __in, __len-1);})) ++#endif + + /* Handle for a session using the library. */ + typedef struct Dwfl Dwfl; +--- a/libdwfl/find-debuginfo.c ++++ b/libdwfl/find-debuginfo.c +@@ -372,7 +372,7 @@ dwfl_standard_find_debuginfo (Dwfl_Modul + /* If FILE_NAME is a symlink, the debug file might be associated + with the symlink target name instead. */ + +- char *canon = canonicalize_file_name (file_name); ++ char *canon = realpath (file_name, NULL); + if (canon != NULL && strcmp (file_name, canon)) + fd = find_debuginfo_in_path (mod, canon, + debuglink_file, debuglink_crc, +--- a/libdwfl/dwfl_build_id_find_elf.c ++++ b/libdwfl/dwfl_build_id_find_elf.c +@@ -94,7 +94,7 @@ __libdwfl_open_by_build_id (Dwfl_Module + { + if (*file_name != NULL) + free (*file_name); +- *file_name = canonicalize_file_name (name); ++ *file_name = realpath (name, NULL); + if (*file_name == NULL) + { + *file_name = name; +--- a/libelf/elf_getarsym.c ++++ b/libelf/elf_getarsym.c +@@ -297,7 +297,7 @@ elf_getarsym (Elf *elf, size_t *ptr) + arsym[cnt].as_off = (*u32)[cnt]; + + arsym[cnt].as_hash = _dl_elf_hash (str_data); +- str_data = rawmemchr (str_data, '\0') + 1; ++ str_data = memchr (str_data, '\0', SIZE_MAX) + 1; + } + + /* At the end a special entry. */ diff --git a/kernel/bcc.patches/bcc-gnuism.patch b/kernel/bcc.patches/bcc-gnuism.patch new file mode 100644 index 000000000..3312fde0e --- /dev/null +++ b/kernel/bcc.patches/bcc-gnuism.patch @@ -0,0 +1,28 @@ +--- src/cc/usdt.h-orig ++++ src/cc/usdt.h +@@ -125,6 +125,24 @@ public: + ArgumentParser_powerpc64(const char *arg) : ArgumentParser(arg) {} + }; + ++#undef REG_A ++#undef REG_B ++#undef REG_C ++#undef REG_D ++#undef REG_SI ++#undef REG_DI ++#undef REG_BP ++#undef REG_SP ++#undef REG_8 ++#undef REG_9 ++#undef REG_10 ++#undef REG_11 ++#undef REG_12 ++#undef REG_13 ++#undef REG_14 ++#undef REG_15 ++#undef REG_RIP ++ + class ArgumentParser_x64 : public ArgumentParser { + private: + enum Register { + diff --git a/kernel/bcc.patches/bcc-lua.patch b/kernel/bcc.patches/bcc-lua.patch new file mode 100644 index 000000000..b10eb1b0c --- /dev/null +++ b/kernel/bcc.patches/bcc-lua.patch @@ -0,0 +1,43 @@ +--- src/cc/CMakeLists.txt ++++ src/cc/CMakeLists.txt +@@ -52,7 +52,7 @@ target_link_libraries(bcc-loader-static elf) + add_library(bcc-static STATIC + ${bcc_common_sources} ${bcc_table_sources} ${bcc_util_sources}) + set_target_properties(bcc-static PROPERTIES OUTPUT_NAME bcc) +-set(bcc-lua-static ++add_library(bcc-lua-static STATIC + ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} ${bcc_util_sources}) + + include(clang_libs) +@@ -64,9 +64,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${llvm_lib_exclude_f + set(bcc_common_libs_for_a b_frontend clang_frontend bpf-static + -Wl,--whole-archive ${clang_libs} ${llvm_libs} -Wl,--no-whole-archive + ${LIBELF_LIBRARIES}) +-set(bcc_common_libs_for_s ${bcc_common_libs_for_a}) +-set(bcc_common_libs_for_lua b_frontend clang_frontend bpf-static ++set(bcc_common_libs_for_s b_frontend clang_frontend bpf-static + ${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES}) ++set(bcc_common_libs_for_lua ${bcc_common_libs_for_s}) + + if(ENABLE_CPP_API) + add_subdirectory(api) +@@ -87,7 +87,7 @@ add_subdirectory(frontends) + # Link against LLVM libraries + target_link_libraries(bcc-shared ${bcc_common_libs_for_s}) + target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static) +-set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua}) ++target_link_libraries(bcc-lua-static ${bcc_common_libs_for_lua}) + + install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${bcc_table_headers} DESTINATION include/bcc) +--- src/lua/CMakeLists.txt ++++ src/lua/CMakeLists.txt +@@ -23,7 +23,7 @@ if (LUAJIT_LIBRARIES AND LUAJIT) + add_executable(bcc-lua src/main.c bcc.o) + set_target_properties(bcc-lua PROPERTIES LINKER_LANGUAGE C) + target_link_libraries(bcc-lua ${LUAJIT_LIBRARIES}) +- target_link_libraries(bcc-lua ${bcc-lua-static}) ++ target_link_libraries(bcc-lua -Wl,--whole-archive bcc-lua-static -Wl,--no-whole-archive) + if (NOT COMPILER_NOPIE_FLAG EQUAL "") + target_link_libraries(bcc-lua ${COMPILER_NOPIE_FLAG}) + endif() diff --git a/kernel/bcc.patches/cdefs.h b/kernel/bcc.patches/cdefs.h new file mode 100644 index 000000000..8ec977083 --- /dev/null +++ b/kernel/bcc.patches/cdefs.h @@ -0,0 +1,628 @@ +/* $NetBSD: cdefs.h,v 1.129 2016/12/27 21:52:01 christos Exp $ */ + +/* * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 + */ + +#ifndef _SYS_CDEFS_H_ +#define _SYS_CDEFS_H_ + +#ifdef _KERNEL_OPT +#include "opt_diagnostic.h" +#endif + +/* + * Macro to test if we're using a GNU C compiler of a specific vintage + * or later, for e.g. features that appeared in a particular version + * of GNU C. Usage: + * + * #if __GNUC_PREREQ__(major, minor) + * ...cool feature... + * #else + * ...delete feature... + * #endif + */ +#ifdef __GNUC__ +#define __GNUC_PREREQ__(x, y) \ + ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ + (__GNUC__ > (x))) +#else +#define __GNUC_PREREQ__(x, y) 0 +#endif + +#ifdef __GNUC__ +#define __strict_weak_alias(alias,sym) \ + __unused static __typeof__(alias) *__weak_alias_##alias = &sym; \ + __weak_alias(alias,sym) +#else +#define __strict_weak_alias(alias,sym) __weak_alias(alias,sym) +#endif + +/* + * Optional marker for size-optimised MD calling convention. + */ +#ifndef __compactcall +#define __compactcall +#endif + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ + +#define ___STRING(x) __STRING(x) +#define ___CONCAT(x,y) __CONCAT(x,y) + +#if __STDC__ || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) || defined(__PCC__) +#define __inline inline /* convert to C++/C99 keyword */ +#else +#if !defined(__GNUC__) && !defined(__lint__) +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ && !__lint__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +#endif /* !__GNUC__ */ + +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * Programs using the ANSI C keywords const, inline etc. as normal + * identifiers should define -DNO_ANSI_KEYWORDS. + */ +#ifndef NO_ANSI_KEYWORDS +#define const __const /* convert ANSI C keywords */ +#define inline __inline +#define signed __signed +#define volatile __volatile +#endif /* !NO_ANSI_KEYWORDS */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * Used for internal auditing of the NetBSD source tree. + */ +#ifdef __AUDIT__ +#define __aconst __const +#else +#define __aconst +#endif + +/* + * Compile Time Assertion. + */ +#ifdef __COUNTER__ +#define __CTASSERT(x) __CTASSERT0(x, __ctassert, __COUNTER__) +#else +#define __CTASSERT(x) __CTASSERT99(x, __INCLUDE_LEVEL__, __LINE__) +#define __CTASSERT99(x, a, b) __CTASSERT0(x, __CONCAT(__ctassert,a), \ + __CONCAT(_,b)) +#endif +#define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z) +#define __CTASSERT1(x, y, z) typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused + +/* + * The following macro is used to remove const cast-away warnings + * from gcc -Wcast-qual; it should be used with caution because it + * can hide valid errors; in particular most valid uses are in + * situations where the API requires it, not to cast away string + * constants. We don't use *intptr_t on purpose here and we are + * explicit about unsigned long so that we don't have additional + * dependencies. + */ +#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) + +/* + * The following macro is used to remove the volatile cast-away warnings + * from gcc -Wcast-qual; as above it should be used with caution + * because it can hide valid errors or warnings. Valid uses include + * making it possible to pass a volatile pointer to memset(). + * For the same reasons as above, we use unsigned long and not intptr_t. + */ +#define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a)) + +/* + * GCC2 provides __extension__ to suppress warnings for various GNU C + * language extensions under "-ansi -pedantic". + */ +#if !__GNUC_PREREQ__(2, 0) +#define __extension__ /* delete __extension__ if non-gcc or gcc1 */ +#endif + +/* + * GCC1 and some versions of GCC2 declare dead (non-returning) and + * pure (no side effects) functions using "volatile" and "const"; + * unfortunately, these then cause warnings under "-ansi -pedantic". + * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of + * these work for GNU C++ (modulo a slight glitch in the C++ grammar + * in the distribution version of 2.5.5). + * + * GCC defines a pure function as depending only on its arguments and + * global variables. Typical examples are strlen and sqrt. + * + * GCC defines a const function as depending only on its arguments. + * Therefore calling a const function again with identical arguments + * will always produce the same result. + * + * Rounding modes for floating point operations are considered global + * variables and prevent sqrt from being a const function. + * + * Calls to const functions can be optimised away and moved around + * without limitations. + */ +#if !__GNUC_PREREQ__(2, 0) && !defined(__lint__) +#define __attribute__(x) +#endif + +#if __GNUC_PREREQ__(2, 5) +#define __dead __attribute__((__noreturn__)) +#elif defined(__GNUC__) +#define __dead __volatile +#else +#define __dead +#endif + +#if __GNUC_PREREQ__(2, 96) +#define __pure __attribute__((__pure__)) +#elif defined(__GNUC__) +#define __pure __const +#else +#define __pure +#endif + +#if __GNUC_PREREQ__(2, 5) +#define __constfunc __attribute__((__const__)) +#else +#define __constfunc +#endif + +#if __GNUC_PREREQ__(3, 0) +#define __noinline __attribute__((__noinline__)) +#else +#define __noinline /* nothing */ +#endif + +#if __GNUC_PREREQ__(3, 0) +#define __always_inline __attribute__((__always_inline__)) +#else +#define __always_inline /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 1) +#define __returns_twice __attribute__((__returns_twice__)) +#else +#define __returns_twice /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 5) +#define __noclone __attribute__((__noclone__)) +#else +#define __noclone /* nothing */ +#endif + +/* + * __unused: Note that item or function might be unused. + */ +#if __GNUC_PREREQ__(2, 7) || defined(__lint__) +#define __unused __attribute__((__unused__)) +#else +#define __unused /* delete */ +#endif + +/* + * __used: Note that item is needed, even if it appears to be unused. + */ +#if __GNUC_PREREQ__(3, 1) +#define __used __attribute__((__used__)) +#else +#define __used __unused +#endif + +/* + * __diagused: Note that item is used in diagnostic code, but may be + * unused in non-diagnostic code. + */ +#if (defined(_KERNEL) && defined(DIAGNOSTIC)) \ + || (!defined(_KERNEL) && !defined(NDEBUG)) +#define __diagused /* empty */ +#else +#define __diagused __unused +#endif + +/* + * __debugused: Note that item is used in debug code, but may be + * unused in non-debug code. + */ +#if defined(DEBUG) +#define __debugused /* empty */ +#else +#define __debugused __unused +#endif + +#if __GNUC_PREREQ__(3, 1) +#define __noprofile __attribute__((__no_instrument_function__)) +#else +#define __noprofile /* nothing */ +#endif + +#if __GNUC_PREREQ__(4, 6) || defined(__clang__) +#define __unreachable() __builtin_unreachable() +#else +#define __unreachable() do {} while (/*CONSTCOND*/0) +#endif + +#if defined(__cplusplus) +#define __BEGIN_EXTERN_C extern "C" { +#define __END_EXTERN_C } +#define __static_cast(x,y) static_cast(y) +#else +#define __BEGIN_EXTERN_C +#define __END_EXTERN_C +#define __static_cast(x,y) (x)y +#endif + +#if __GNUC_PREREQ__(4, 0) +# define __dso_public __attribute__((__visibility__("default"))) +# define __dso_hidden __attribute__((__visibility__("hidden"))) +# define __BEGIN_PUBLIC_DECLS \ + _Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C +# define __END_PUBLIC_DECLS __END_EXTERN_C _Pragma("GCC visibility pop") +# define __BEGIN_HIDDEN_DECLS \ + _Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C +# define __END_HIDDEN_DECLS __END_EXTERN_C _Pragma("GCC visibility pop") +#else +# define __dso_public +# define __dso_hidden +# define __BEGIN_PUBLIC_DECLS __BEGIN_EXTERN_C +# define __END_PUBLIC_DECLS __END_EXTERN_C +# define __BEGIN_HIDDEN_DECLS __BEGIN_EXTERN_C +# define __END_HIDDEN_DECLS __END_EXTERN_C +#endif +#if __GNUC_PREREQ__(4, 2) +# define __dso_protected __attribute__((__visibility__("protected"))) +#else +# define __dso_protected +#endif + +#define __BEGIN_DECLS __BEGIN_PUBLIC_DECLS +#define __END_DECLS __END_PUBLIC_DECLS + +/* + * Non-static C99 inline functions are optional bodies. They don't + * create global symbols if not used, but can be replaced if desirable. + * This differs from the behavior of GCC before version 4.3. The nearest + * equivalent for older GCC is `extern inline'. For newer GCC, use the + * gnu_inline attribute additionally to get the old behavior. + * + * For C99 compilers other than GCC, the C99 behavior is expected. + */ +#if defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) +#define __c99inline extern __attribute__((__gnu_inline__)) __inline +#elif defined(__GNUC__) +#define __c99inline extern __inline +#elif defined(__STDC_VERSION__) +#define __c99inline __inline +#endif + +#if defined(__lint__) +#define __packed __packed +#define __aligned(x) /* delete */ +#define __section(x) /* delete */ +#elif __GNUC_PREREQ__(2, 7) || defined(__PCC__) +#define __packed __attribute__((__packed__)) +#define __aligned(x) __attribute__((__aligned__(x))) +#define __section(x) __attribute__((__section__(x))) +#elif defined(_MSC_VER) +#define __packed /* ignore */ +#else +#define __packed error: no __packed for this compiler +#define __aligned(x) error: no __aligned for this compiler +#define __section(x) error: no __section for this compiler +#endif + +/* + * C99 defines the restrict type qualifier keyword, which was made available + * in GCC 2.92. + */ +#if defined(__lint__) +#define __restrict /* delete __restrict when not supported */ +#elif __STDC_VERSION__ >= 199901L +#define __restrict restrict +#elif __GNUC_PREREQ__(2, 92) +#define __restrict __restrict__ +#else +#define __restrict /* delete __restrict when not supported */ +#endif + +/* + * C99 defines __func__ predefined identifier, which was made available + * in GCC 2.95. + */ +#if !(__STDC_VERSION__ >= 199901L) +#if __GNUC_PREREQ__(2, 6) +#define __func__ __PRETTY_FUNCTION__ +#elif __GNUC_PREREQ__(2, 4) +#define __func__ __FUNCTION__ +#else +#define __func__ "" +#endif +#endif /* !(__STDC_VERSION__ >= 199901L) */ + +#if defined(_KERNEL) +#if defined(NO_KERNEL_RCSIDS) +#undef __KERNEL_RCSID +#define __KERNEL_RCSID(_n, _s) /* nothing */ +#endif /* NO_KERNEL_RCSIDS */ +#endif /* _KERNEL */ + +#if !defined(_STANDALONE) && !defined(_KERNEL) +#if defined(__GNUC__) || defined(__PCC__) +#define __RENAME(x) ___RENAME(x) +#elif defined(__lint__) +#define __RENAME(x) __symbolrename(x) +#else +#error "No function renaming possible" +#endif /* __GNUC__ */ +#else /* _STANDALONE || _KERNEL */ +#define __RENAME(x) no renaming in kernel/standalone environment +#endif + +/* + * A barrier to stop the optimizer from moving code or assume live + * register values. This is gcc specific, the version is more or less + * arbitrary, might work with older compilers. + */ +#if __GNUC_PREREQ__(2, 95) +#define __insn_barrier() __asm __volatile("":::"memory") +#else +#define __insn_barrier() /* */ +#endif + +/* + * GNU C version 2.96 adds explicit branch prediction so that + * the CPU back-end can hint the processor and also so that + * code blocks can be reordered such that the predicted path + * sees a more linear flow, thus improving cache behavior, etc. + * + * The following two macros provide us with a way to use this + * compiler feature. Use __predict_true() if you expect the expression + * to evaluate to true, and __predict_false() if you expect the + * expression to evaluate to false. + * + * A few notes about usage: + * + * * Generally, __predict_false() error condition checks (unless + * you have some _strong_ reason to do otherwise, in which case + * document it), and/or __predict_true() `no-error' condition + * checks, assuming you want to optimize for the no-error case. + * + * * Other than that, if you don't know the likelihood of a test + * succeeding from empirical or other `hard' evidence, don't + * make predictions. + * + * * These are meant to be used in places that are run `a lot'. + * It is wasteful to make predictions in code that is run + * seldomly (e.g. at subsystem initialization time) as the + * basic block reordering that this affects can often generate + * larger code. + */ +#if __GNUC_PREREQ__(2, 96) +#define __predict_true(exp) __builtin_expect((exp) != 0, 1) +#define __predict_false(exp) __builtin_expect((exp) != 0, 0) +#else +#define __predict_true(exp) (exp) +#define __predict_false(exp) (exp) +#endif + +/* + * Compiler-dependent macros to declare that functions take printf-like + * or scanf-like arguments. They are null except for versions of gcc + * that are known to support the features properly (old versions of gcc-2 + * didn't permit keeping the keywords out of the application namespace). + */ +#if __GNUC_PREREQ__(2, 7) +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#ifndef __syslog_attribute__ +#define __syslog__ __printf__ +#endif +#define __sysloglike(fmtarg, firstvararg) \ + __attribute__((__format__ (__syslog__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) +#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) +#else +#define __printflike(fmtarg, firstvararg) /* nothing */ +#define __scanflike(fmtarg, firstvararg) /* nothing */ +#define __sysloglike(fmtarg, firstvararg) /* nothing */ +#define __format_arg(fmtarg) /* nothing */ +#endif + +/* + * Macros for manipulating "link sets". Link sets are arrays of pointers + * to objects, which are gathered up by the linker. + * + * Object format-specific code has provided us with the following macros: + * + * __link_set_add_text(set, sym) + * Add a reference to the .text symbol `sym' to `set'. + * + * __link_set_add_rodata(set, sym) + * Add a reference to the .rodata symbol `sym' to `set'. + * + * __link_set_add_data(set, sym) + * Add a reference to the .data symbol `sym' to `set'. + * + * __link_set_add_bss(set, sym) + * Add a reference to the .bss symbol `sym' to `set'. + * + * __link_set_decl(set, ptype) + * Provide an extern declaration of the set `set', which + * contains an array of pointers to type `ptype'. This + * macro must be used by any code which wishes to reference + * the elements of a link set. + * + * __link_set_start(set) + * This points to the first slot in the link set. + * + * __link_set_end(set) + * This points to the (non-existent) slot after the last + * entry in the link set. + * + * __link_set_count(set) + * Count the number of entries in link set `set'. + * + * In addition, we provide the following macros for accessing link sets: + * + * __link_set_foreach(pvar, set) + * Iterate over the link set `set'. Because a link set is + * an array of pointers, pvar must be declared as "type **pvar", + * and the actual entry accessed as "*pvar". + * + * __link_set_entry(set, idx) + * Access the link set entry at index `idx' from set `set'. + */ +#define __link_set_foreach(pvar, set) \ + for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++) + +#define __link_set_entry(set, idx) (__link_set_start(set)[idx]) + +/* + * Return the natural alignment in bytes for the given type + */ +#if __GNUC_PREREQ__(4, 1) +#define __alignof(__t) __alignof__(__t) +#else +#define __alignof(__t) (sizeof(struct { char __x; __t __y; }) - sizeof(__t)) +#endif + +/* + * Return the number of elements in a statically-allocated array, + * __x. + */ +#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) + +#ifndef __ASSEMBLER__ +/* __BIT(n): nth bit, where __BIT(0) == 0x1. */ +#define __BIT(__n) \ + (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \ + ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1)))) + +/* __BITS(m, n): bits m through n, m < n. */ +#define __BITS(__m, __n) \ + ((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1)) +#endif /* !__ASSEMBLER__ */ + +/* find least significant bit that is set */ +#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) + +#define __PRIuBIT PRIuMAX +#define __PRIuBITS __PRIuBIT + +#define __PRIxBIT PRIxMAX +#define __PRIxBITS __PRIxBIT + +#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) +#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) +#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask)) + +/* + * Only to be used in other headers that are included from both c or c++ + * NOT to be used in code. + */ +#ifdef __cplusplus +#define __CAST(__dt, __st) static_cast<__dt>(__st) +#else +#define __CAST(__dt, __st) ((__dt)(__st)) +#endif + +#define __CASTV(__dt, __st) __CAST(__dt, __CAST(void *, __st)) +#define __CASTCV(__dt, __st) __CAST(__dt, __CAST(const void *, __st)) + +#define __USE(a) ((void)(a)) + +#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \ + (~((1ULL << (sizeof(t) * NBBY)) - 1)) : 0ULL) + +#ifndef __ASSEMBLER__ +static __inline long long __zeroll(void) { return 0; } +static __inline unsigned long long __zeroull(void) { return 0; } +#else +#define __zeroll() (0LL) +#define __zeroull() (0ULL) +#endif + +#define __negative_p(x) (!((x) > 0) && ((x) != 0)) + +#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * NBBY - 1)))) +#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * NBBY - 1)))) +#define __type_min_u(t) ((t)0ULL) +#define __type_max_u(t) ((t)~0ULL) +#define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1) +#define __type_min(t) (__type_is_signed(t) ? __type_min_s(t) : __type_min_u(t)) +#define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t)) + + +#define __type_fit_u(t, a) (/*LINTED*/!__negative_p(a) && \ + (uintmax_t)((a) + __zeroull()) <= (uintmax_t)__type_max_u(t)) + +#define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \ + ((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \ + ((intmax_t)((a) + __zeroll()) >= (intmax_t)0 && \ + (intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t))) + +/* + * return true if value 'a' fits in type 't' + */ +#define __type_fit(t, a) (__type_is_signed(t) ? \ + __type_fit_s(t, a) : __type_fit_u(t, a)) + +#endif /* !_SYS_CDEFS_H_ */ diff --git a/kernel/bcc.patches/decl.patch b/kernel/bcc.patches/decl.patch new file mode 100644 index 000000000..4f69bfa76 --- /dev/null +++ b/kernel/bcc.patches/decl.patch @@ -0,0 +1,23 @@ +--- libelf/elf.h-orig ++++ libelf/elf.h +@@ -21,7 +21,9 @@ + + #include + +-__BEGIN_DECLS ++#ifdef __cplusplus ++extern "C" { ++#endif + + /* Standard ELF types. */ + +@@ -3553,6 +3555,8 @@ + #define R_TILEGX_NUM 130 + + +-__END_DECLS ++#ifdef __cplusplus ++} ++#endif + + #endif /* elf.h */ diff --git a/kernel/bcc.patches/error.h b/kernel/bcc.patches/error.h new file mode 100644 index 000000000..6b71c7e68 --- /dev/null +++ b/kernel/bcc.patches/error.h @@ -0,0 +1,29 @@ +# include +# include +# include +# include +static void error_at_line(int status, int errnum, const char *filename, + unsigned int linenum, const char *format, ...) +{ + va_list ap; + + fflush(stdout); + + if (filename != NULL) + fprintf(stderr, "%s:%u: ", filename, linenum); + + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + + if (errnum != 0) + fprintf(stderr, ": %s", strerror(errnum)); + + fprintf(stderr, "\n"); + + if (status != 0) + exit(status); +} + +#define error(status, errnum, format...) \ + error_at_line(status, errnum, NULL, 0, format) diff --git a/kernel/bcc.patches/intl.patch b/kernel/bcc.patches/intl.patch new file mode 100644 index 000000000..6c191937f --- /dev/null +++ b/kernel/bcc.patches/intl.patch @@ -0,0 +1,11 @@ +--- libelf/Makefile.am-orig ++++ libelf/Makefile.am +@@ -95,7 +95,7 @@ + libelf_pic_a_SOURCES = + am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os) + +-libelf_so_LDLIBS = -lz ++libelf_so_LDLIBS = -lz -lintl + if USE_LOCKS + libelf_so_LDLIBS += -lpthread + endif diff --git a/kernel/bcc.patches/temp_failure.patch b/kernel/bcc.patches/temp_failure.patch new file mode 100644 index 000000000..2997f45db --- /dev/null +++ b/kernel/bcc.patches/temp_failure.patch @@ -0,0 +1,17 @@ +--- lib/system.h-orig ++++ lib/system.h +@@ -70,6 +70,14 @@ + + #define gettext_noop(Str) Str + ++#ifndef TEMP_FAILURE_RETRY ++# define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif + + #define pwrite_retry(fd, buf, len, off) \ + TEMP_FAILURE_RETRY (pwrite (fd, buf, len, off)) From a6ac644703743f8ab129c63d32a25c111648f20a Mon Sep 17 00:00:00 2001 From: Krister Johansen Date: Mon, 30 Jul 2018 21:37:21 -0700 Subject: [PATCH 3/5] Add some documentation. Signed-off-by: Krister Johansen --- docs/kernel-bcc.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docs/kernel-bcc.md diff --git a/docs/kernel-bcc.md b/docs/kernel-bcc.md new file mode 100644 index 000000000..343a82736 --- /dev/null +++ b/docs/kernel-bcc.md @@ -0,0 +1,31 @@ +# Using the bcc utility with LinuxKit + +The `bcc` utility is a standard Linux tool to access performance +counters, trace events and access various other kernel internals for +performance analysis. + +The `bcc` utility needs to matched be with the kernel. For recent +kernel build, LinuxKit provides a `linuxkit/kernel-bcc` package with +a matching tag for each kernel under `linuxkit/kernel`. + +The preferred way of using the `linuxkit/kernel-bcc` package is to +add it to the `init` section. This adds `/usr/share/bcc` to the + systems' root filesystem. From there it can be + - bind mounted into your container + - accessed via `/proc/1/root/usr/share/bcc/tools` from with in the `getty` + or `ssh` container. + - accessed via a nsenter of `/bin/ash` of proc 1. + +If you want to use `bcc` you may also want to remove the `sysctl` +container, or alternatively, disable the kernel pointer restriction it +enables by default: + +``` +echo 0 > /proc/sys/kernel/kptr_restrict +``` + +Now, `bcc` is ready to use. The LinuxKit `bcc` package contains +the `bcc` binary, example and tool scripts, and kernel headers for the +associated kernel build. + + From 0643093f6a5857c6fcc1c573c2173783f9de22b5 Mon Sep 17 00:00:00 2001 From: Krister Johansen Date: Mon, 30 Jul 2018 21:37:27 -0700 Subject: [PATCH 4/5] Remove ebpf from projects Signed-off-by: Krister Johansen --- projects/ebpf/README.md | 18 - .../ebpf/ebpf.build/100-musl-compat.patch | 788 ------------------ projects/ebpf/ebpf.build/Dockerfile | 50 -- projects/ebpf/ebpf.build/Makefile | 29 - projects/ebpf/ebpf.build/bcc-gnuism.patch | 28 - projects/ebpf/ebpf.build/bcc-lua.patch | 43 - projects/ebpf/ebpf.build/cdefs.h | 628 -------------- projects/ebpf/ebpf.build/decl.patch | 23 - projects/ebpf/ebpf.build/error.h | 29 - projects/ebpf/ebpf.build/intl.patch | 11 - projects/ebpf/ebpf.build/temp_failure.patch | 17 - projects/ebpf/ebpf.md | 22 - projects/ebpf/ebpf.pkg/Dockerfile | 54 -- projects/ebpf/ebpf.pkg/Makefile | 12 - 14 files changed, 1752 deletions(-) delete mode 100644 projects/ebpf/README.md delete mode 100644 projects/ebpf/ebpf.build/100-musl-compat.patch delete mode 100644 projects/ebpf/ebpf.build/Dockerfile delete mode 100644 projects/ebpf/ebpf.build/Makefile delete mode 100644 projects/ebpf/ebpf.build/bcc-gnuism.patch delete mode 100644 projects/ebpf/ebpf.build/bcc-lua.patch delete mode 100644 projects/ebpf/ebpf.build/cdefs.h delete mode 100644 projects/ebpf/ebpf.build/decl.patch delete mode 100644 projects/ebpf/ebpf.build/error.h delete mode 100644 projects/ebpf/ebpf.build/intl.patch delete mode 100644 projects/ebpf/ebpf.build/temp_failure.patch delete mode 100644 projects/ebpf/ebpf.md delete mode 100644 projects/ebpf/ebpf.pkg/Dockerfile delete mode 100644 projects/ebpf/ebpf.pkg/Makefile diff --git a/projects/ebpf/README.md b/projects/ebpf/README.md deleted file mode 100644 index 45dd79400..000000000 --- a/projects/ebpf/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# iovisor eBPF tools - -The [iovisor eBPF tools](https://github.com/iovisor/bcc) are a -collection tools useful for debugging and performance analysis. This -project aims to provide an easy to consume packaging of these tools -for Moby. - -It comes in two parts: [ebpf.build](ebpf.build/) is used for building the binaries on alpine and [ebpf.pkg](ebpf.pkg/) is supposed to package the binaries with the required kernel files. - -**Note**: The packages currently do not build. - -## Roadmap - -**Near-term:** -- Make the package build again - -**Mid-term:** -- Trim the distribution package to make it easier to consume diff --git a/projects/ebpf/ebpf.build/100-musl-compat.patch b/projects/ebpf/ebpf.build/100-musl-compat.patch deleted file mode 100644 index 25e15047a..000000000 --- a/projects/ebpf/ebpf.build/100-musl-compat.patch +++ /dev/null @@ -1,788 +0,0 @@ ---- a/lib/system.h -+++ b/lib/system.h -@@ -68,6 +68,16 @@ extern int crc32_file (int fd, uint32_t - - #define gettext_noop(Str) Str - -+#ifndef TEMP_FAILURE_RETRY -+#define TEMP_FAILURE_RETRY(expression) \ -+ (__extension__ \ -+ ({ long int __result; \ -+ do __result = (long int) (expression); \ -+ while (__result == -1L && errno == EINTR); \ -+ __result; })) -+#endif -+ -+#define error(status, errno, ...) err(status, __VA_ARGS__) - - static inline ssize_t __attribute__ ((unused)) - pwrite_retry (int fd, const void *buf, size_t len, off_t off) ---- a/lib/color.c -+++ b/lib/color.c -@@ -32,7 +32,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/lib/xmalloc.c -+++ b/lib/xmalloc.c -@@ -30,7 +30,7 @@ - # include - #endif - --#include -+#include - #include - #include - #include ---- a/src/addr2line.c -+++ b/src/addr2line.c -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/ar.c -+++ b/src/ar.c -@@ -22,7 +22,7 @@ - - #include - #include --#include -+#include - #include - #include - #include ---- a/src/arlib2.c -+++ b/src/arlib2.c -@@ -20,7 +20,7 @@ - # include - #endif - --#include -+#include - #include - #include - #include ---- a/src/arlib.c -+++ b/src/arlib.c -@@ -21,7 +21,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/src/elfcmp.c -+++ b/src/elfcmp.c -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/elflint.c -+++ b/src/elflint.c -@@ -24,7 +24,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/findtextrel.c -+++ b/src/findtextrel.c -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/i386_ld.c -+++ b/src/i386_ld.c -@@ -20,7 +20,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/src/ld.c -+++ b/src/ld.c -@@ -21,7 +21,7 @@ - - #include - #include --#include -+#include - #include - #include - #include ---- a/src/ldgeneric.c -+++ b/src/ldgeneric.c -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/ldlex.c -+++ b/src/ldlex.c -@@ -1106,7 +1106,7 @@ char *ldtext; - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/ldscript.c -+++ b/src/ldscript.c -@@ -95,7 +95,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include -@@ -106,7 +106,7 @@ - #include - #include - --/* The error handler. */ -+/* The err.handler. */ - static void yyerror (const char *s); - - /* Some helper functions we need to construct the data structures ---- a/src/nm.c -+++ b/src/nm.c -@@ -26,7 +26,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/objdump.c -+++ b/src/objdump.c -@@ -21,7 +21,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/src/ranlib.c -+++ b/src/ranlib.c -@@ -24,7 +24,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/size.c -+++ b/src/size.c -@@ -21,7 +21,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/src/stack.c -+++ b/src/stack.c -@@ -18,7 +18,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/strings.c -+++ b/src/strings.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/strip.c -+++ b/src/strip.c -@@ -24,7 +24,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/src/unstrip.c -+++ b/src/unstrip.c -@@ -31,7 +31,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/tests/addrscopes.c -+++ b/tests/addrscopes.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - - ---- a/tests/allregs.c -+++ b/tests/allregs.c -@@ -21,7 +21,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/tests/backtrace.c -+++ b/tests/backtrace.c -@@ -24,7 +24,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #ifdef __linux__ ---- a/tests/backtrace-data.c -+++ b/tests/backtrace-data.c -@@ -27,7 +27,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #if defined(__x86_64__) && defined(__linux__) ---- a/tests/buildid.c -+++ b/tests/buildid.c -@@ -23,7 +23,7 @@ - #include ELFUTILS_HEADER(elf) - #include ELFUTILS_HEADER(dwelf) - #include --#include -+#include - #include - #include - #include ---- a/tests/debugaltlink.c -+++ b/tests/debugaltlink.c -@@ -23,7 +23,7 @@ - #include ELFUTILS_HEADER(dw) - #include ELFUTILS_HEADER(dwelf) - #include --#include -+#include - #include - #include - #include ---- a/tests/debuglink.c -+++ b/tests/debuglink.c -@@ -21,7 +21,7 @@ - #include - #include ELFUTILS_HEADER(dwelf) - #include --#include -+#include - #include - #include - #include ---- a/tests/dwfl-addr-sect.c -+++ b/tests/dwfl-addr-sect.c -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ELFUTILS_HEADER(dwfl) ---- a/tests/dwfl-bug-addr-overflow.c -+++ b/tests/dwfl-bug-addr-overflow.c -@@ -20,7 +20,7 @@ - #include - #include - #include --#include -+#include - #include - #include ELFUTILS_HEADER(dwfl) - ---- a/tests/dwfl-bug-fd-leak.c -+++ b/tests/dwfl-bug-fd-leak.c -@@ -24,7 +24,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/tests/dwfl-bug-getmodules.c -+++ b/tests/dwfl-bug-getmodules.c -@@ -18,7 +18,7 @@ - #include - #include ELFUTILS_HEADER(dwfl) - --#include -+#include - - static const Dwfl_Callbacks callbacks = - { ---- a/tests/dwfllines.c -+++ b/tests/dwfllines.c -@@ -27,7 +27,7 @@ - #include - #include - #include --#include -+#include - - int - main (int argc, char *argv[]) ---- a/tests/dwflmodtest.c -+++ b/tests/dwflmodtest.c -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ELFUTILS_HEADER(dwfl) ---- a/tests/dwfl-report-elf-align.c -+++ b/tests/dwfl-report-elf-align.c -@@ -20,7 +20,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/tests/dwflsyms.c -+++ b/tests/dwflsyms.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - - static const char * ---- a/tests/early-offscn.c -+++ b/tests/early-offscn.c -@@ -19,7 +19,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/tests/ecp.c -+++ b/tests/ecp.c -@@ -20,7 +20,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/tests/find-prologues.c -+++ b/tests/find-prologues.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - ---- a/tests/funcretval.c -+++ b/tests/funcretval.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - ---- a/tests/funcscopes.c -+++ b/tests/funcscopes.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - ---- a/tests/line2addr.c -+++ b/tests/line2addr.c -@@ -26,7 +26,7 @@ - #include - #include - #include --#include -+#include - - - static void ---- a/tests/low_high_pc.c -+++ b/tests/low_high_pc.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - ---- a/tests/md5-sha1-test.c -+++ b/tests/md5-sha1-test.c -@@ -19,7 +19,7 @@ - #endif - - #include --#include -+#include - - #include "md5.h" - #include "sha1.h" ---- a/tests/rdwrmmap.c -+++ b/tests/rdwrmmap.c -@@ -19,7 +19,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/tests/saridx.c -+++ b/tests/saridx.c -@@ -17,7 +17,7 @@ - - #include - --#include -+#include - #include - #include - #include ---- a/tests/sectiondump.c -+++ b/tests/sectiondump.c -@@ -18,7 +18,7 @@ - #include - - #include --#include -+#include - #include - #include - #include ---- a/tests/varlocs.c -+++ b/tests/varlocs.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/libelf/libelf.h -+++ b/libelf/libelf.h -@@ -29,6 +29,7 @@ - #ifndef _LIBELF_H - #define _LIBELF_H 1 - -+#include - #include - #include - ---- a/libasm/asm_end.c -+++ b/libasm/asm_end.c -@@ -32,7 +32,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/libasm/asm_newscn.c -+++ b/libasm/asm_newscn.c -@@ -32,7 +32,7 @@ - #endif - - #include --#include -+#include - #include - #include - #include ---- a/libcpu/i386_gendis.c -+++ b/libcpu/i386_gendis.c -@@ -31,7 +31,7 @@ - # include - #endif - --#include -+#include - #include - #include - #include ---- a/libcpu/i386_lex.c -+++ b/libcpu/i386_lex.c -@@ -578,7 +578,7 @@ char *i386_text; - #endif - - #include --#include -+#include - #include - - #include ---- a/libcpu/i386_lex.l -+++ b/libcpu/i386_lex.l -@@ -31,7 +31,7 @@ - #endif - - #include --#include -+#include - #include - - #include ---- a/libcpu/i386_parse.c -+++ b/libcpu/i386_parse.c -@@ -107,7 +107,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/libdw/libdw_alloc.c -+++ b/libdw/libdw_alloc.c -@@ -31,7 +31,7 @@ - # include - #endif - --#include -+#include - #include - #include - #include -@@ -74,5 +74,5 @@ __attribute ((noreturn, visibility ("hid - __libdw_oom (void) - { - while (1) -- error (EXIT_FAILURE, ENOMEM, "libdw"); -+ err (EXIT_FAILURE, "libdw: out of memory"); - } ---- a/libebl/eblopenbackend.c -+++ b/libebl/eblopenbackend.c -@@ -32,7 +32,7 @@ - - #include - #include --#include -+#include - #include - #include - #include ---- a/src/ldlex.l -+++ b/src/ldlex.l -@@ -23,7 +23,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include ---- a/libebl/eblwstrtab.c -+++ b/libebl/eblwstrtab.c -@@ -305,7 +305,7 @@ copystrings (struct Ebl_WStrent *nodep, - - /* Process the current node. */ - nodep->offset = *offsetp; -- *freep = wmempcpy (*freep, nodep->string, nodep->len); -+ *freep = wmemcpy (*freep, nodep->string, nodep->len) + nodep->len; - *offsetp += nodep->len * sizeof (wchar_t); - - for (subs = nodep->next; subs != NULL; subs = subs->next) ---- a/libdwfl/dwfl_error.c -+++ b/libdwfl/dwfl_error.c -@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) - const char * - dwfl_errmsg (int error) - { -+ static __thread char s[64] = ""; - if (error == 0 || error == -1) - { - int last_error = global_error; -@@ -154,7 +155,8 @@ dwfl_errmsg (int error) - switch (error &~ 0xffff) - { - case OTHER_ERROR (ERRNO): -- return strerror_r (error & 0xffff, "bad", 0); -+ strerror_r (error & 0xffff, s, sizeof(s)); -+ return s; - case OTHER_ERROR (LIBELF): - return elf_errmsg (error & 0xffff); - case OTHER_ERROR (LIBDW): ---- a/libdwfl/libdwfl.h -+++ b/libdwfl/libdwfl.h -@@ -31,6 +31,27 @@ - - #include "libdw.h" - #include -+#include -+#include -+#include -+ -+#ifndef TEMP_FAILURE_RETRY -+#define TEMP_FAILURE_RETRY(expression) \ -+ (__extension__ \ -+ ({ long int __result; \ -+ do __result = (long int) (expression); \ -+ while (__result == -1L && errno == EINTR); \ -+ __result; })) -+#endif -+ -+#ifndef strndupa -+#define strndupa(s, n) \ -+ (__extension__ ({const char *__in = (s); \ -+ size_t __len = strnlen (__in, (n)) + 1; \ -+ char *__out = (char *) alloca (__len); \ -+ __out[__len-1] = '\0'; \ -+ (char *) memcpy (__out, __in, __len-1);})) -+#endif - - /* Handle for a session using the library. */ - typedef struct Dwfl Dwfl; ---- a/libdwfl/find-debuginfo.c -+++ b/libdwfl/find-debuginfo.c -@@ -372,7 +372,7 @@ dwfl_standard_find_debuginfo (Dwfl_Modul - /* If FILE_NAME is a symlink, the debug file might be associated - with the symlink target name instead. */ - -- char *canon = canonicalize_file_name (file_name); -+ char *canon = realpath (file_name, NULL); - if (canon != NULL && strcmp (file_name, canon)) - fd = find_debuginfo_in_path (mod, canon, - debuglink_file, debuglink_crc, ---- a/libdwfl/dwfl_build_id_find_elf.c -+++ b/libdwfl/dwfl_build_id_find_elf.c -@@ -94,7 +94,7 @@ __libdwfl_open_by_build_id (Dwfl_Module - { - if (*file_name != NULL) - free (*file_name); -- *file_name = canonicalize_file_name (name); -+ *file_name = realpath (name, NULL); - if (*file_name == NULL) - { - *file_name = name; ---- a/libelf/elf_getarsym.c -+++ b/libelf/elf_getarsym.c -@@ -297,7 +297,7 @@ elf_getarsym (Elf *elf, size_t *ptr) - arsym[cnt].as_off = (*u32)[cnt]; - - arsym[cnt].as_hash = _dl_elf_hash (str_data); -- str_data = rawmemchr (str_data, '\0') + 1; -+ str_data = memchr (str_data, '\0', SIZE_MAX) + 1; - } - - /* At the end a special entry. */ diff --git a/projects/ebpf/ebpf.build/Dockerfile b/projects/ebpf/ebpf.build/Dockerfile deleted file mode 100644 index de0ebea7b..000000000 --- a/projects/ebpf/ebpf.build/Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -FROM alpine:3.7 -RUN apk update && apk upgrade -a && \ - apk add --no-cache \ - argp-standalone \ - autoconf \ - automake \ - bison \ - build-base \ - clang \ - clang-dev \ - clang-static \ - cmake \ - curl \ - flex-dev \ - fts-dev \ - gettext-dev \ - git \ - iperf \ - libedit-dev \ - libtool \ - llvm \ - llvm-dev \ - llvm-static \ - luajit-dev \ - m4 \ - python \ - zlib-dev \ - && true - -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 - -WORKDIR /build -COPY . ./ -COPY Dockerfile / -COPY error.h /usr/include/ -COPY cdefs.h /usr/include/sys/ -ENV ELFUTILS_VERSION=0.165 -RUN curl -sSL -O https://fedorahosted.org/releases/e/l/elfutils/0.165/elfutils-$ELFUTILS_VERSION.tar.bz2 -RUN cat elfutils-$ELFUTILS_VERSION.tar.bz2 | tar xjf - && \ - cd elfutils-$ELFUTILS_VERSION && \ - patch -p1 < ../100-musl-compat.patch && \ - patch -p0 < ../decl.patch && \ - patch -p0 < ../intl.patch -ENV BCC_COMMIT=6972806729da00ecda0235abac61d66c8fad7fad -RUN git clone https://github.com/iovisor/bcc.git && cd bcc && git checkout $BCC_COMMIT -RUN cd bcc && patch -p0 < ../bcc-gnuism.patch && patch -p0 < ../bcc-lua.patch -ENV LJSYSCALL_COMMIT=e587f8c55aad3955dddab3a4fa6c1968037b5c6e -RUN git clone https://github.com/justincormack/ljsyscall.git && cd ljsyscall && git checkout $LJSYSCALL_COMMIT diff --git a/projects/ebpf/ebpf.build/Makefile b/projects/ebpf/ebpf.build/Makefile deleted file mode 100644 index 1b4fec7a1..000000000 --- a/projects/ebpf/ebpf.build/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -.PHONY: tag push - -BASE=alpine:3.7 -IMAGE=alpine-build-ebpf - -default: push - -hash: Dockerfile *.patch cdefs.h error.h - DOCKER_CONTENT_TRUST=1 docker pull $(BASE) - tar cf - $^ | docker build --no-cache -t $(IMAGE):build - - docker run --rm $(IMAGE):build sh -c 'cat /Dockerfile /build/*.patch /build/*.h /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > hash - -push: hash - docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ - (docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \ - docker push mobylinux/$(IMAGE):$(shell cat hash)) - docker rmi $(IMAGE):build - rm -f hash - -tag: hash - docker pull mobylinux/$(IMAGE):$(shell cat hash) || \ - docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) - docker rmi $(IMAGE):build - rm -f hash - -clean: - rm -f hash - -.DELETE_ON_ERROR: diff --git a/projects/ebpf/ebpf.build/bcc-gnuism.patch b/projects/ebpf/ebpf.build/bcc-gnuism.patch deleted file mode 100644 index 3312fde0e..000000000 --- a/projects/ebpf/ebpf.build/bcc-gnuism.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- src/cc/usdt.h-orig -+++ src/cc/usdt.h -@@ -125,6 +125,24 @@ public: - ArgumentParser_powerpc64(const char *arg) : ArgumentParser(arg) {} - }; - -+#undef REG_A -+#undef REG_B -+#undef REG_C -+#undef REG_D -+#undef REG_SI -+#undef REG_DI -+#undef REG_BP -+#undef REG_SP -+#undef REG_8 -+#undef REG_9 -+#undef REG_10 -+#undef REG_11 -+#undef REG_12 -+#undef REG_13 -+#undef REG_14 -+#undef REG_15 -+#undef REG_RIP -+ - class ArgumentParser_x64 : public ArgumentParser { - private: - enum Register { - diff --git a/projects/ebpf/ebpf.build/bcc-lua.patch b/projects/ebpf/ebpf.build/bcc-lua.patch deleted file mode 100644 index b10eb1b0c..000000000 --- a/projects/ebpf/ebpf.build/bcc-lua.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- src/cc/CMakeLists.txt -+++ src/cc/CMakeLists.txt -@@ -52,7 +52,7 @@ target_link_libraries(bcc-loader-static elf) - add_library(bcc-static STATIC - ${bcc_common_sources} ${bcc_table_sources} ${bcc_util_sources}) - set_target_properties(bcc-static PROPERTIES OUTPUT_NAME bcc) --set(bcc-lua-static -+add_library(bcc-lua-static STATIC - ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} ${bcc_util_sources}) - - include(clang_libs) -@@ -64,9 +64,9 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${llvm_lib_exclude_f - set(bcc_common_libs_for_a b_frontend clang_frontend bpf-static - -Wl,--whole-archive ${clang_libs} ${llvm_libs} -Wl,--no-whole-archive - ${LIBELF_LIBRARIES}) --set(bcc_common_libs_for_s ${bcc_common_libs_for_a}) --set(bcc_common_libs_for_lua b_frontend clang_frontend bpf-static -+set(bcc_common_libs_for_s b_frontend clang_frontend bpf-static - ${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES}) -+set(bcc_common_libs_for_lua ${bcc_common_libs_for_s}) - - if(ENABLE_CPP_API) - add_subdirectory(api) -@@ -87,7 +87,7 @@ add_subdirectory(frontends) - # Link against LLVM libraries - target_link_libraries(bcc-shared ${bcc_common_libs_for_s}) - target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static) --set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua}) -+target_link_libraries(bcc-lua-static ${bcc_common_libs_for_lua}) - - install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(FILES ${bcc_table_headers} DESTINATION include/bcc) ---- src/lua/CMakeLists.txt -+++ src/lua/CMakeLists.txt -@@ -23,7 +23,7 @@ if (LUAJIT_LIBRARIES AND LUAJIT) - add_executable(bcc-lua src/main.c bcc.o) - set_target_properties(bcc-lua PROPERTIES LINKER_LANGUAGE C) - target_link_libraries(bcc-lua ${LUAJIT_LIBRARIES}) -- target_link_libraries(bcc-lua ${bcc-lua-static}) -+ target_link_libraries(bcc-lua -Wl,--whole-archive bcc-lua-static -Wl,--no-whole-archive) - if (NOT COMPILER_NOPIE_FLAG EQUAL "") - target_link_libraries(bcc-lua ${COMPILER_NOPIE_FLAG}) - endif() diff --git a/projects/ebpf/ebpf.build/cdefs.h b/projects/ebpf/ebpf.build/cdefs.h deleted file mode 100644 index 8ec977083..000000000 --- a/projects/ebpf/ebpf.build/cdefs.h +++ /dev/null @@ -1,628 +0,0 @@ -/* $NetBSD: cdefs.h,v 1.129 2016/12/27 21:52:01 christos Exp $ */ - -/* * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Berkeley Software Design, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 - */ - -#ifndef _SYS_CDEFS_H_ -#define _SYS_CDEFS_H_ - -#ifdef _KERNEL_OPT -#include "opt_diagnostic.h" -#endif - -/* - * Macro to test if we're using a GNU C compiler of a specific vintage - * or later, for e.g. features that appeared in a particular version - * of GNU C. Usage: - * - * #if __GNUC_PREREQ__(major, minor) - * ...cool feature... - * #else - * ...delete feature... - * #endif - */ -#ifdef __GNUC__ -#define __GNUC_PREREQ__(x, y) \ - ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ - (__GNUC__ > (x))) -#else -#define __GNUC_PREREQ__(x, y) 0 -#endif - -#ifdef __GNUC__ -#define __strict_weak_alias(alias,sym) \ - __unused static __typeof__(alias) *__weak_alias_##alias = &sym; \ - __weak_alias(alias,sym) -#else -#define __strict_weak_alias(alias,sym) __weak_alias(alias,sym) -#endif - -/* - * Optional marker for size-optimised MD calling convention. - */ -#ifndef __compactcall -#define __compactcall -#endif - -/* - * The __CONCAT macro is used to concatenate parts of symbol names, e.g. - * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. - * The __CONCAT macro is a bit tricky -- make sure you don't put spaces - * in between its arguments. __CONCAT can also concatenate double-quoted - * strings produced by the __STRING macro, but this only works with ANSI C. - */ - -#define ___STRING(x) __STRING(x) -#define ___CONCAT(x,y) __CONCAT(x,y) - -#if __STDC__ || defined(__cplusplus) -#define __P(protos) protos /* full-blown ANSI C */ -#define __CONCAT(x,y) x ## y -#define __STRING(x) #x - -#define __const const /* define reserved names to standard */ -#define __signed signed -#define __volatile volatile -#if defined(__cplusplus) || defined(__PCC__) -#define __inline inline /* convert to C++/C99 keyword */ -#else -#if !defined(__GNUC__) && !defined(__lint__) -#define __inline /* delete GCC keyword */ -#endif /* !__GNUC__ && !__lint__ */ -#endif /* !__cplusplus */ - -#else /* !(__STDC__ || __cplusplus) */ -#define __P(protos) () /* traditional C preprocessor */ -#define __CONCAT(x,y) x/**/y -#define __STRING(x) "x" - -#ifndef __GNUC__ -#define __const /* delete pseudo-ANSI C keywords */ -#define __inline -#define __signed -#define __volatile -#endif /* !__GNUC__ */ - -/* - * In non-ANSI C environments, new programs will want ANSI-only C keywords - * deleted from the program and old programs will want them left alone. - * Programs using the ANSI C keywords const, inline etc. as normal - * identifiers should define -DNO_ANSI_KEYWORDS. - */ -#ifndef NO_ANSI_KEYWORDS -#define const __const /* convert ANSI C keywords */ -#define inline __inline -#define signed __signed -#define volatile __volatile -#endif /* !NO_ANSI_KEYWORDS */ -#endif /* !(__STDC__ || __cplusplus) */ - -/* - * Used for internal auditing of the NetBSD source tree. - */ -#ifdef __AUDIT__ -#define __aconst __const -#else -#define __aconst -#endif - -/* - * Compile Time Assertion. - */ -#ifdef __COUNTER__ -#define __CTASSERT(x) __CTASSERT0(x, __ctassert, __COUNTER__) -#else -#define __CTASSERT(x) __CTASSERT99(x, __INCLUDE_LEVEL__, __LINE__) -#define __CTASSERT99(x, a, b) __CTASSERT0(x, __CONCAT(__ctassert,a), \ - __CONCAT(_,b)) -#endif -#define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z) -#define __CTASSERT1(x, y, z) typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused - -/* - * The following macro is used to remove const cast-away warnings - * from gcc -Wcast-qual; it should be used with caution because it - * can hide valid errors; in particular most valid uses are in - * situations where the API requires it, not to cast away string - * constants. We don't use *intptr_t on purpose here and we are - * explicit about unsigned long so that we don't have additional - * dependencies. - */ -#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) - -/* - * The following macro is used to remove the volatile cast-away warnings - * from gcc -Wcast-qual; as above it should be used with caution - * because it can hide valid errors or warnings. Valid uses include - * making it possible to pass a volatile pointer to memset(). - * For the same reasons as above, we use unsigned long and not intptr_t. - */ -#define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a)) - -/* - * GCC2 provides __extension__ to suppress warnings for various GNU C - * language extensions under "-ansi -pedantic". - */ -#if !__GNUC_PREREQ__(2, 0) -#define __extension__ /* delete __extension__ if non-gcc or gcc1 */ -#endif - -/* - * GCC1 and some versions of GCC2 declare dead (non-returning) and - * pure (no side effects) functions using "volatile" and "const"; - * unfortunately, these then cause warnings under "-ansi -pedantic". - * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of - * these work for GNU C++ (modulo a slight glitch in the C++ grammar - * in the distribution version of 2.5.5). - * - * GCC defines a pure function as depending only on its arguments and - * global variables. Typical examples are strlen and sqrt. - * - * GCC defines a const function as depending only on its arguments. - * Therefore calling a const function again with identical arguments - * will always produce the same result. - * - * Rounding modes for floating point operations are considered global - * variables and prevent sqrt from being a const function. - * - * Calls to const functions can be optimised away and moved around - * without limitations. - */ -#if !__GNUC_PREREQ__(2, 0) && !defined(__lint__) -#define __attribute__(x) -#endif - -#if __GNUC_PREREQ__(2, 5) -#define __dead __attribute__((__noreturn__)) -#elif defined(__GNUC__) -#define __dead __volatile -#else -#define __dead -#endif - -#if __GNUC_PREREQ__(2, 96) -#define __pure __attribute__((__pure__)) -#elif defined(__GNUC__) -#define __pure __const -#else -#define __pure -#endif - -#if __GNUC_PREREQ__(2, 5) -#define __constfunc __attribute__((__const__)) -#else -#define __constfunc -#endif - -#if __GNUC_PREREQ__(3, 0) -#define __noinline __attribute__((__noinline__)) -#else -#define __noinline /* nothing */ -#endif - -#if __GNUC_PREREQ__(3, 0) -#define __always_inline __attribute__((__always_inline__)) -#else -#define __always_inline /* nothing */ -#endif - -#if __GNUC_PREREQ__(4, 1) -#define __returns_twice __attribute__((__returns_twice__)) -#else -#define __returns_twice /* nothing */ -#endif - -#if __GNUC_PREREQ__(4, 5) -#define __noclone __attribute__((__noclone__)) -#else -#define __noclone /* nothing */ -#endif - -/* - * __unused: Note that item or function might be unused. - */ -#if __GNUC_PREREQ__(2, 7) || defined(__lint__) -#define __unused __attribute__((__unused__)) -#else -#define __unused /* delete */ -#endif - -/* - * __used: Note that item is needed, even if it appears to be unused. - */ -#if __GNUC_PREREQ__(3, 1) -#define __used __attribute__((__used__)) -#else -#define __used __unused -#endif - -/* - * __diagused: Note that item is used in diagnostic code, but may be - * unused in non-diagnostic code. - */ -#if (defined(_KERNEL) && defined(DIAGNOSTIC)) \ - || (!defined(_KERNEL) && !defined(NDEBUG)) -#define __diagused /* empty */ -#else -#define __diagused __unused -#endif - -/* - * __debugused: Note that item is used in debug code, but may be - * unused in non-debug code. - */ -#if defined(DEBUG) -#define __debugused /* empty */ -#else -#define __debugused __unused -#endif - -#if __GNUC_PREREQ__(3, 1) -#define __noprofile __attribute__((__no_instrument_function__)) -#else -#define __noprofile /* nothing */ -#endif - -#if __GNUC_PREREQ__(4, 6) || defined(__clang__) -#define __unreachable() __builtin_unreachable() -#else -#define __unreachable() do {} while (/*CONSTCOND*/0) -#endif - -#if defined(__cplusplus) -#define __BEGIN_EXTERN_C extern "C" { -#define __END_EXTERN_C } -#define __static_cast(x,y) static_cast(y) -#else -#define __BEGIN_EXTERN_C -#define __END_EXTERN_C -#define __static_cast(x,y) (x)y -#endif - -#if __GNUC_PREREQ__(4, 0) -# define __dso_public __attribute__((__visibility__("default"))) -# define __dso_hidden __attribute__((__visibility__("hidden"))) -# define __BEGIN_PUBLIC_DECLS \ - _Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C -# define __END_PUBLIC_DECLS __END_EXTERN_C _Pragma("GCC visibility pop") -# define __BEGIN_HIDDEN_DECLS \ - _Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C -# define __END_HIDDEN_DECLS __END_EXTERN_C _Pragma("GCC visibility pop") -#else -# define __dso_public -# define __dso_hidden -# define __BEGIN_PUBLIC_DECLS __BEGIN_EXTERN_C -# define __END_PUBLIC_DECLS __END_EXTERN_C -# define __BEGIN_HIDDEN_DECLS __BEGIN_EXTERN_C -# define __END_HIDDEN_DECLS __END_EXTERN_C -#endif -#if __GNUC_PREREQ__(4, 2) -# define __dso_protected __attribute__((__visibility__("protected"))) -#else -# define __dso_protected -#endif - -#define __BEGIN_DECLS __BEGIN_PUBLIC_DECLS -#define __END_DECLS __END_PUBLIC_DECLS - -/* - * Non-static C99 inline functions are optional bodies. They don't - * create global symbols if not used, but can be replaced if desirable. - * This differs from the behavior of GCC before version 4.3. The nearest - * equivalent for older GCC is `extern inline'. For newer GCC, use the - * gnu_inline attribute additionally to get the old behavior. - * - * For C99 compilers other than GCC, the C99 behavior is expected. - */ -#if defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) -#define __c99inline extern __attribute__((__gnu_inline__)) __inline -#elif defined(__GNUC__) -#define __c99inline extern __inline -#elif defined(__STDC_VERSION__) -#define __c99inline __inline -#endif - -#if defined(__lint__) -#define __packed __packed -#define __aligned(x) /* delete */ -#define __section(x) /* delete */ -#elif __GNUC_PREREQ__(2, 7) || defined(__PCC__) -#define __packed __attribute__((__packed__)) -#define __aligned(x) __attribute__((__aligned__(x))) -#define __section(x) __attribute__((__section__(x))) -#elif defined(_MSC_VER) -#define __packed /* ignore */ -#else -#define __packed error: no __packed for this compiler -#define __aligned(x) error: no __aligned for this compiler -#define __section(x) error: no __section for this compiler -#endif - -/* - * C99 defines the restrict type qualifier keyword, which was made available - * in GCC 2.92. - */ -#if defined(__lint__) -#define __restrict /* delete __restrict when not supported */ -#elif __STDC_VERSION__ >= 199901L -#define __restrict restrict -#elif __GNUC_PREREQ__(2, 92) -#define __restrict __restrict__ -#else -#define __restrict /* delete __restrict when not supported */ -#endif - -/* - * C99 defines __func__ predefined identifier, which was made available - * in GCC 2.95. - */ -#if !(__STDC_VERSION__ >= 199901L) -#if __GNUC_PREREQ__(2, 6) -#define __func__ __PRETTY_FUNCTION__ -#elif __GNUC_PREREQ__(2, 4) -#define __func__ __FUNCTION__ -#else -#define __func__ "" -#endif -#endif /* !(__STDC_VERSION__ >= 199901L) */ - -#if defined(_KERNEL) -#if defined(NO_KERNEL_RCSIDS) -#undef __KERNEL_RCSID -#define __KERNEL_RCSID(_n, _s) /* nothing */ -#endif /* NO_KERNEL_RCSIDS */ -#endif /* _KERNEL */ - -#if !defined(_STANDALONE) && !defined(_KERNEL) -#if defined(__GNUC__) || defined(__PCC__) -#define __RENAME(x) ___RENAME(x) -#elif defined(__lint__) -#define __RENAME(x) __symbolrename(x) -#else -#error "No function renaming possible" -#endif /* __GNUC__ */ -#else /* _STANDALONE || _KERNEL */ -#define __RENAME(x) no renaming in kernel/standalone environment -#endif - -/* - * A barrier to stop the optimizer from moving code or assume live - * register values. This is gcc specific, the version is more or less - * arbitrary, might work with older compilers. - */ -#if __GNUC_PREREQ__(2, 95) -#define __insn_barrier() __asm __volatile("":::"memory") -#else -#define __insn_barrier() /* */ -#endif - -/* - * GNU C version 2.96 adds explicit branch prediction so that - * the CPU back-end can hint the processor and also so that - * code blocks can be reordered such that the predicted path - * sees a more linear flow, thus improving cache behavior, etc. - * - * The following two macros provide us with a way to use this - * compiler feature. Use __predict_true() if you expect the expression - * to evaluate to true, and __predict_false() if you expect the - * expression to evaluate to false. - * - * A few notes about usage: - * - * * Generally, __predict_false() error condition checks (unless - * you have some _strong_ reason to do otherwise, in which case - * document it), and/or __predict_true() `no-error' condition - * checks, assuming you want to optimize for the no-error case. - * - * * Other than that, if you don't know the likelihood of a test - * succeeding from empirical or other `hard' evidence, don't - * make predictions. - * - * * These are meant to be used in places that are run `a lot'. - * It is wasteful to make predictions in code that is run - * seldomly (e.g. at subsystem initialization time) as the - * basic block reordering that this affects can often generate - * larger code. - */ -#if __GNUC_PREREQ__(2, 96) -#define __predict_true(exp) __builtin_expect((exp) != 0, 1) -#define __predict_false(exp) __builtin_expect((exp) != 0, 0) -#else -#define __predict_true(exp) (exp) -#define __predict_false(exp) (exp) -#endif - -/* - * Compiler-dependent macros to declare that functions take printf-like - * or scanf-like arguments. They are null except for versions of gcc - * that are known to support the features properly (old versions of gcc-2 - * didn't permit keeping the keywords out of the application namespace). - */ -#if __GNUC_PREREQ__(2, 7) -#define __printflike(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf__, fmtarg, firstvararg))) -#ifndef __syslog_attribute__ -#define __syslog__ __printf__ -#endif -#define __sysloglike(fmtarg, firstvararg) \ - __attribute__((__format__ (__syslog__, fmtarg, firstvararg))) -#define __scanflike(fmtarg, firstvararg) \ - __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) -#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) -#else -#define __printflike(fmtarg, firstvararg) /* nothing */ -#define __scanflike(fmtarg, firstvararg) /* nothing */ -#define __sysloglike(fmtarg, firstvararg) /* nothing */ -#define __format_arg(fmtarg) /* nothing */ -#endif - -/* - * Macros for manipulating "link sets". Link sets are arrays of pointers - * to objects, which are gathered up by the linker. - * - * Object format-specific code has provided us with the following macros: - * - * __link_set_add_text(set, sym) - * Add a reference to the .text symbol `sym' to `set'. - * - * __link_set_add_rodata(set, sym) - * Add a reference to the .rodata symbol `sym' to `set'. - * - * __link_set_add_data(set, sym) - * Add a reference to the .data symbol `sym' to `set'. - * - * __link_set_add_bss(set, sym) - * Add a reference to the .bss symbol `sym' to `set'. - * - * __link_set_decl(set, ptype) - * Provide an extern declaration of the set `set', which - * contains an array of pointers to type `ptype'. This - * macro must be used by any code which wishes to reference - * the elements of a link set. - * - * __link_set_start(set) - * This points to the first slot in the link set. - * - * __link_set_end(set) - * This points to the (non-existent) slot after the last - * entry in the link set. - * - * __link_set_count(set) - * Count the number of entries in link set `set'. - * - * In addition, we provide the following macros for accessing link sets: - * - * __link_set_foreach(pvar, set) - * Iterate over the link set `set'. Because a link set is - * an array of pointers, pvar must be declared as "type **pvar", - * and the actual entry accessed as "*pvar". - * - * __link_set_entry(set, idx) - * Access the link set entry at index `idx' from set `set'. - */ -#define __link_set_foreach(pvar, set) \ - for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++) - -#define __link_set_entry(set, idx) (__link_set_start(set)[idx]) - -/* - * Return the natural alignment in bytes for the given type - */ -#if __GNUC_PREREQ__(4, 1) -#define __alignof(__t) __alignof__(__t) -#else -#define __alignof(__t) (sizeof(struct { char __x; __t __y; }) - sizeof(__t)) -#endif - -/* - * Return the number of elements in a statically-allocated array, - * __x. - */ -#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) - -#ifndef __ASSEMBLER__ -/* __BIT(n): nth bit, where __BIT(0) == 0x1. */ -#define __BIT(__n) \ - (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \ - ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1)))) - -/* __BITS(m, n): bits m through n, m < n. */ -#define __BITS(__m, __n) \ - ((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1)) -#endif /* !__ASSEMBLER__ */ - -/* find least significant bit that is set */ -#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) - -#define __PRIuBIT PRIuMAX -#define __PRIuBITS __PRIuBIT - -#define __PRIxBIT PRIxMAX -#define __PRIxBITS __PRIxBIT - -#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask)) -#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) -#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask)) - -/* - * Only to be used in other headers that are included from both c or c++ - * NOT to be used in code. - */ -#ifdef __cplusplus -#define __CAST(__dt, __st) static_cast<__dt>(__st) -#else -#define __CAST(__dt, __st) ((__dt)(__st)) -#endif - -#define __CASTV(__dt, __st) __CAST(__dt, __CAST(void *, __st)) -#define __CASTCV(__dt, __st) __CAST(__dt, __CAST(const void *, __st)) - -#define __USE(a) ((void)(a)) - -#define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \ - (~((1ULL << (sizeof(t) * NBBY)) - 1)) : 0ULL) - -#ifndef __ASSEMBLER__ -static __inline long long __zeroll(void) { return 0; } -static __inline unsigned long long __zeroull(void) { return 0; } -#else -#define __zeroll() (0LL) -#define __zeroull() (0ULL) -#endif - -#define __negative_p(x) (!((x) > 0) && ((x) != 0)) - -#define __type_min_s(t) ((t)((1ULL << (sizeof(t) * NBBY - 1)))) -#define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * NBBY - 1)))) -#define __type_min_u(t) ((t)0ULL) -#define __type_max_u(t) ((t)~0ULL) -#define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1) -#define __type_min(t) (__type_is_signed(t) ? __type_min_s(t) : __type_min_u(t)) -#define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t)) - - -#define __type_fit_u(t, a) (/*LINTED*/!__negative_p(a) && \ - (uintmax_t)((a) + __zeroull()) <= (uintmax_t)__type_max_u(t)) - -#define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \ - ((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \ - ((intmax_t)((a) + __zeroll()) >= (intmax_t)0 && \ - (intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t))) - -/* - * return true if value 'a' fits in type 't' - */ -#define __type_fit(t, a) (__type_is_signed(t) ? \ - __type_fit_s(t, a) : __type_fit_u(t, a)) - -#endif /* !_SYS_CDEFS_H_ */ diff --git a/projects/ebpf/ebpf.build/decl.patch b/projects/ebpf/ebpf.build/decl.patch deleted file mode 100644 index 4f69bfa76..000000000 --- a/projects/ebpf/ebpf.build/decl.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- libelf/elf.h-orig -+++ libelf/elf.h -@@ -21,7 +21,9 @@ - - #include - --__BEGIN_DECLS -+#ifdef __cplusplus -+extern "C" { -+#endif - - /* Standard ELF types. */ - -@@ -3553,6 +3555,8 @@ - #define R_TILEGX_NUM 130 - - --__END_DECLS -+#ifdef __cplusplus -+} -+#endif - - #endif /* elf.h */ diff --git a/projects/ebpf/ebpf.build/error.h b/projects/ebpf/ebpf.build/error.h deleted file mode 100644 index 6b71c7e68..000000000 --- a/projects/ebpf/ebpf.build/error.h +++ /dev/null @@ -1,29 +0,0 @@ -# include -# include -# include -# include -static void error_at_line(int status, int errnum, const char *filename, - unsigned int linenum, const char *format, ...) -{ - va_list ap; - - fflush(stdout); - - if (filename != NULL) - fprintf(stderr, "%s:%u: ", filename, linenum); - - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); - - if (errnum != 0) - fprintf(stderr, ": %s", strerror(errnum)); - - fprintf(stderr, "\n"); - - if (status != 0) - exit(status); -} - -#define error(status, errnum, format...) \ - error_at_line(status, errnum, NULL, 0, format) diff --git a/projects/ebpf/ebpf.build/intl.patch b/projects/ebpf/ebpf.build/intl.patch deleted file mode 100644 index 6c191937f..000000000 --- a/projects/ebpf/ebpf.build/intl.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- libelf/Makefile.am-orig -+++ libelf/Makefile.am -@@ -95,7 +95,7 @@ - libelf_pic_a_SOURCES = - am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os) - --libelf_so_LDLIBS = -lz -+libelf_so_LDLIBS = -lz -lintl - if USE_LOCKS - libelf_so_LDLIBS += -lpthread - endif diff --git a/projects/ebpf/ebpf.build/temp_failure.patch b/projects/ebpf/ebpf.build/temp_failure.patch deleted file mode 100644 index 2997f45db..000000000 --- a/projects/ebpf/ebpf.build/temp_failure.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- lib/system.h-orig -+++ lib/system.h -@@ -70,6 +70,14 @@ - - #define gettext_noop(Str) Str - -+#ifndef TEMP_FAILURE_RETRY -+# define TEMP_FAILURE_RETRY(expression) \ -+ (__extension__ \ -+ ({ long int __result; \ -+ do __result = (long int) (expression); \ -+ while (__result == -1L && errno == EINTR); \ -+ __result; })) -+#endif - - #define pwrite_retry(fd, buf, len, off) \ - TEMP_FAILURE_RETRY (pwrite (fd, buf, len, off)) diff --git a/projects/ebpf/ebpf.md b/projects/ebpf/ebpf.md deleted file mode 100644 index ed5a893a7..000000000 --- a/projects/ebpf/ebpf.md +++ /dev/null @@ -1,22 +0,0 @@ -## Using eBPF programs - -There is now a development image `mobylinux/ebpf:_tag_`. These are currently being built -manually, I will tag one for each kernel release, as you should have a close one, eg -`mobylinux/ebpf:4.9` is currently available. - -This image has all the kernel headers, `iovisor/bcc` built with support for C, Python and Lua, -and all sources installed. It is very large so if we are shipping stuff based on this we will -just extract compiled eBPF programs probably, but it is also usable for experiments, debug, -benchmarks etc. - -You probably want to run with - -`docker run -it -v /sys/kernel/debug:/sys/kernel/debug --privileged --pid=host mobylinux/ebpf:tag sh` for -interactive use as some things use debugfs. You need at least `CAP_SYS_ADMIN` to do anything. -There are examples in `bcc/examples` that should generally just work, I have tried several of -the Lua ones. - -Some of the `iovisor/bcc` samples try to access the kernel symbols. For them to work correctly you should also execute: -```sh -echo 0 > /proc/sys/kernel/kptr_restrict -``` diff --git a/projects/ebpf/ebpf.pkg/Dockerfile b/projects/ebpf/ebpf.pkg/Dockerfile deleted file mode 100644 index dcd43df69..000000000 --- a/projects/ebpf/ebpf.pkg/Dockerfile +++ /dev/null @@ -1,54 +0,0 @@ -#FROM mobylinux/alpine-build-ebpf@sha256:da37d99a8baad18e68c44d3807c86977767ed90ce03133b508842eea3b786d3a -ARG IMAGE -FROM ${IMAGE} as ksrc -FROM alpine-build-ebpf:build as build - -COPY --from=ksrc /kernel-headers.tar /build -RUN tar xf /build/kernel-headers.tar - -COPY --from=ksrc /kernel-dev.tar /build -RUN tar xf /build/kernel-dev.tar - -COPY --from=ksrc /kernel.tar /build -RUN tar xf /build/kernel.tar - -RUN cd /build -RUN cd elfutils-$ELFUTILS_VERSION && \ - aclocal && \ - automake && \ - ./configure --prefix=/usr CFLAGS=-Wno-strict-aliasing && \ - make -C libelf && make -C libelf install -RUN mkdir -p bcc/build && cd bcc/build && \ - cmake .. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_C_FLAGS="-I/build/usr/include" -DCMAKE_CXX_FLAGS="-I/build/usr/include" -DCMAKE_INSTALL_PREFIX=/usr -DLUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1 && \ - make && \ - make install -RUN mkdir -p /usr/local/share/lua/5.1/ && cd ljsyscall && cp -a *.lua syscall /usr/local/share/lua/5.1/ - -ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib64 - -FROM alpine:3.7 as mirror -RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ -RUN apk update && apk upgrade -a && \ - apk add --no-cache --initdb -p /out \ - busybox \ - luajit \ - python \ - strace \ - zlib \ - && true - -FROM scratch -ENTRYPOINT [] -CMD [] -WORKDIR / -COPY --from=mirror /out / -COPY --from=build /build/usr/src /usr/src/ -COPY --from=build /build/usr/include /usr/include/ -COPY --from=build /usr/lib/libelf* /usr/lib/ -COPY --from=build /usr/lib/libstdc* /usr/lib/ -COPY --from=build /usr/lib/libintl* /usr/lib/ -COPY --from=build /usr/lib64 /usr/lib/ -COPY --from=build /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages/ -COPY --from=build /usr/share/bcc /usr/share/bcc/ -COPY --from=build /usr/bin/bcc-lua /usr/bin/ -COPY --from=build /usr/local/share/lua /usr/local/share/lua/ diff --git a/projects/ebpf/ebpf.pkg/Makefile b/projects/ebpf/ebpf.pkg/Makefile deleted file mode 100644 index ca021be79..000000000 --- a/projects/ebpf/ebpf.pkg/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -KERNEL_IMAGE=iad.ocir.io/odx-fn/linuxkit/kernel:4.14.48-ee964ca1fb8641370812be8ef4592b2708d3551b-amd64 - -default: ebpf.tag - -ebpf.tag: Dockerfile - BUILD=$$( docker build -q --build-arg IMAGE=$(KERNEL_IMAGE) . ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \ - echo $$BUILD > $@ - -clean: - rm -f ebpf.tag - -.DELETE_ON_ERROR: From 6e48041dee742b811cc1ec5262d285ca5fcae065 Mon Sep 17 00:00:00 2001 From: Krister Johansen Date: Mon, 30 Jul 2018 21:37:33 -0700 Subject: [PATCH 5/5] Add a test case for bcc to packages. Signed-off-by: Krister Johansen --- test/cases/040_packages/032_bcc/check.sh | 9 ++++++++ test/cases/040_packages/032_bcc/test.sh | 24 ++++++++++++++++++++ test/cases/040_packages/032_bcc/test.yml | 29 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 test/cases/040_packages/032_bcc/check.sh create mode 100644 test/cases/040_packages/032_bcc/test.sh create mode 100644 test/cases/040_packages/032_bcc/test.yml diff --git a/test/cases/040_packages/032_bcc/check.sh b/test/cases/040_packages/032_bcc/check.sh new file mode 100755 index 000000000..8be6949ad --- /dev/null +++ b/test/cases/040_packages/032_bcc/check.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +nsenter -t 1 -m -- /bin/ash -c "/usr/share/bcc/tools/softirqs 1 1" +if [ "$?" -ne "0" ]; then + printf "bcc test suite FAILED\n" >&1 + exit 1 +fi; + +printf "bcc test suite PASSED\n" >&1 diff --git a/test/cases/040_packages/032_bcc/test.sh b/test/cases/040_packages/032_bcc/test.sh new file mode 100644 index 000000000..5503ea2c9 --- /dev/null +++ b/test/cases/040_packages/032_bcc/test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# SUMMARY: Check that the bcc package works +# LABELS: skip +# REPEAT: + +set -e + +# Source libraries. Uncomment if needed/defined +#. "${RT_LIB}" +. "${RT_PROJECT_ROOT}/_lib/lib.sh" +NAME=bcc + +clean_up() { + rm -rf ${NAME}-* +} +trap clean_up EXIT + +# Test code goes here +linuxkit build -format kernel+initrd -name "${NAME}" test.yml +RESULT="$(linuxkit run ${NAME})" +echo "${RESULT}" +echo "${RESULT}" | grep -q "suite PASSED" + +exit 0 diff --git a/test/cases/040_packages/032_bcc/test.yml b/test/cases/040_packages/032_bcc/test.yml new file mode 100644 index 000000000..0147858d9 --- /dev/null +++ b/test/cases/040_packages/032_bcc/test.yml @@ -0,0 +1,29 @@ +kernel: + image: linuxkit/kernel:4.14.54 + cmdline: "console=ttyS0 console=ttyAMA0" +init: + - linuxkit/init:v0.5 + - linuxkit/runc:v0.5 + - linuxkit/kernel-bcc:4.14.54 +onboot: + - name: check-bcc + image: alpine:3.8 + binds: + - /check.sh:/check.sh + command: ["sh", "./check.sh"] + pid: host + net: host + ipc: host + capabilities: + - all + - name: poweroff + image: linuxkit/poweroff:2687ed712690766b8156a77ac600005b532d2c7d + command: ["/bin/sh", "/poweroff.sh", "10"] +files: + - path: check.sh + source: ./check.sh +trust: + org: + - linuxkit + image: + - alpine:3.8