Repository: linuxkit/linuxkit (language: go)

Issue:
bcc fails to compile with alpine 3.13
With the soon to be updated kernel build to the `linuxkit/alpine` based on 3.13, `lixnukti/kernel-bcc` fails to compile.

After a few warnings about `size_t` and `const counter_type` size mismatches we get:

```
/build/bcc/src/cc/frontends/b/lexer.h:61:38: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'const counter_type' {aka 'const int'} [-Wsign-compare]
   61 |       } else if (i > begin.line && i == end.line) {
      |                                    ~~^~~~~~~~~~~
/build/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function 'virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_string_expr_node(ebpf::cc::StringExprNode*)':
/build/bcc/src/cc/frontends/b/codegen_llvm.cc:429:55: warning: 'llvm::CallInst* llvm::IRBuilderBase::CreateMemCpy(llvm::Value*, unsigned int, llvm::Value*, unsigned int, uint64_t, bool, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*)' is deprecated [-Wdeprecated-declarations
]
  429 |   B.CreateMemCpy(ptr, 1, global, 1, n->val_.size() + 1);
      |                                                       ^
In file included from /usr/lib/llvm10/include/llvm/Support/AlignOf.h:16,
                 from /usr/lib/llvm10/include/llvm/ADT/SmallVector.h:17,
                 from /usr/lib/llvm10/include/llvm/ADT/Twine.h:12,
                 from /usr/lib/llvm10/include/llvm/IR/BasicBlock.h:17,
                 from /build/bcc/src/cc/frontends/b/codegen_llvm.cc:21:
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:523:17: note: declared here
  523 |       CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
      |                 ^~~~~~~~~~~~
/usr/lib/llvm10/include/llvm/Support/Compiler.h:305:3: note: in definition of macro 'LLVM_ATTRIBUTE_DEPRECATED'
  305 |   decl __attribute__((deprecated))
      |   ^~~~
/build/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function 'virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_table_index_expr_node(ebpf::cc::TableIndexExprNode*)':
/build/bcc/src/cc/frontends/b/codegen_llvm.cc:824:96: error: no matching function for call to 'llvm::IRBuilder<>::CreateMemSet(llvm::Value*&, llvm::ConstantInt*, llvm::ConstantInt*, int)'
  824 |     B.CreateMemSet(leaf_ptr, B.getInt8(0), B.getInt64(n->table_->leaf_id()->bit_width_ >> 3), 1);
      |                                                                                                ^
In file included from /build/bcc/src/cc/frontends/b/codegen_llvm.cc:31:
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:452:13: note: candidate: 'llvm::CallInst* llvm::IRBuilderBase::CreateMemSet(llvm::Value*, llvm::Value*, uint64_t, llvm::MaybeAlign, bool, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*)'
  452 |   CallInst *CreateMemSet(Value *Ptr, Value *Val, uint64_t Size,
      |             ^~~~~~~~~~~~
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:453:37: note:   no known conversion for argument 4 from 'int' to 'llvm::MaybeAlign'
  453 |                          MaybeAlign Align, bool isVolatile = false,
      |                          ~~~~~~~~~~~^~~~~
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:460:13: note: candidate: 'llvm::CallInst* llvm::IRBuilderBase::CreateMemSet(llvm::Value*, llvm::Value*, llvm::Value*, llvm::MaybeAlign, bool, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*)'
  460 |   CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, MaybeAlign Align,
      |             ^~~~~~~~~~~~
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:460:74: note:   no known conversion for argument 4 from 'int' to 'llvm::MaybeAlign'
  460 |   CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, MaybeAlign Align,
      |                                                               ~~~~~~~~~~~^~~~~
/build/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function 'virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_struct_variable_decl_stmt_node(ebpf::cc::StructVariableDeclStmtNode*)':
/build/bcc/src/cc/frontends/b/codegen_llvm.cc:1006:79: error: no matching function for call to 'llvm::IRBuilder<>::CreateMemSet(llvm::AllocaInst*&, llvm::ConstantInt*, llvm::ConstantInt*, int)'
 1006 |       B.CreateMemSet(ptr_a, B.getInt8(0), B.getInt64(decl->bit_width_ >> 3), 1);
      |                                                                               ^
In file included from /build/bcc/src/cc/frontends/b/codegen_llvm.cc:31:
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:452:13: note: candidate: 'llvm::CallInst* llvm::IRBuilderBase::CreateMemSet(llvm::Value*, llvm::Value*, uint64_t, llvm::MaybeAlign, bool, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*)'
  452 |   CallInst *CreateMemSet(Value *Ptr, Value *Val, uint64_t Size,
      |             ^~~~~~~~~~~~
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:453:37: note:   no known conversion for argument 4 from 'int' to 'llvm::MaybeAlign'
  453 |                          MaybeAlign Align, bool isVolatile = false,
      |                          ~~~~~~~~~~~^~~~~
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:460:13: note: candidate: 'llvm::CallInst* llvm::IRBuilderBase::CreateMemSet(llvm::Value*, llvm::Value*, llvm::Value*, llvm::MaybeAlign, bool, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*)'
  460 |   CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, MaybeAlign Align,
      |             ^~~~~~~~~~~~
/usr/lib/llvm10/include/llvm/IR/IRBuilder.h:460:74: note:   no known conversion for argument 4 from 'int' to 'llvm::MaybeAlign'
  460 |   CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, MaybeAlign Align,
      |                                                               ~~~~~~~~~~~^~~~~
make[2]: *** [src/cc/frontends/b/CMakeFiles/b_frontend.dir/build.make:109: src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o] Error 1
make[2]: Leaving directory '/build/bcc/build'
make[1]: *** [CMakeFiles/Makefile2:977: src/cc/frontends/b/CMakeFiles/b_frontend.dir/all] Error 2
make[1]: Leaving directory '/build/bcc/build'
make: *** [Makefile:163: all] Error 2
The command '/bin/sh -c 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_DI
R=/usr/include/luajit-2.1 &&     make &&     make install' returned a non-zero code: 2
make: *** [Makefile:251: build_bcc_5.11.x] Error 2
```


Discussion / hints:
This looks like it might be caused by a newer version of LLVM in Alpine 3.13 and an older version of bcc.  There are a couple of fixes from 2020 that might be germane:

https://github.com/iovisor/bcc/pull/2643
https://github.com/iovisor/bcc/pull/2932
Might be worth seeing if we can move up to commit `14278bf1a52dd76ff66eed02cc9db7c7ec240da6` and have things build again.  I haven't had a chance to test this, but that's the hash for the `0.20.0` bcc release

Fix patch:
diff --git a/kernel/Dockerfile.bcc b/kernel/Dockerfile.bcc
index f84a8425d6..938920ca59 100644
--- a/kernel/Dockerfile.bcc
+++ b/kernel/Dockerfile.bcc
@@ -16,6 +16,7 @@ RUN apk update && apk upgrade -a && \
   clang-static \
   cmake \
   curl \
+  elfutils-dev \
   flex-dev \
   fts-dev \
   gettext-dev \
@@ -32,35 +33,17 @@ RUN apk update && apk upgrade -a && \
   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
+RUN ln -s /usr/lib/cmake/llvm10/ /usr/lib/cmake/llvm && \
+    ln -s /usr/include/llvm10/llvm-c/ /usr/include/llvm-c && \
+    ln -s /usr/include/llvm10/llvm/ /usr/include/llvm
 
 WORKDIR /build
 
-COPY ./bcc.patches/ ./
-RUN mv error.h /usr/include/ && \
-    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 && \
-    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=0fa419a64e71984d42f107c210d3d3f0cc82d59a
+ENV BCC_COMMIT=14278bf1a52dd76ff66eed02cc9db7c7ec240da6
 RUN git clone https://github.com/iovisor/bcc.git && \
     cd bcc && \
-    git checkout $BCC_COMMIT
-
-ENV LJSYSCALL_COMMIT=e587f8c55aad3955dddab3a4fa6c1968037b5c6e
-RUN git clone https://github.com/justincormack/ljsyscall.git && \
-    cd ljsyscall && \
-    git checkout $LJSYSCALL_COMMIT
+    git checkout $BCC_COMMIT && \
+    sed -i 's/<error.h>/<errno.h>/' examples/cpp/KModRetExample.cc
 
 COPY --from=ksrc /kernel-headers.tar /build
 COPY --from=ksrc /kernel-dev.tar /build
@@ -69,24 +52,15 @@ RUN tar xf /build/kernel-headers.tar && \
     tar xf /build/kernel-dev.tar && \
     tar xf /build/kernel.tar
 
-RUN cd elfutils-$ELFUTILS_VERSION && \
-    aclocal && \
-    automake && \
-    ./configure --prefix=/usr CFLAGS="-Wno-strict-aliasing -Wno-error" && \
-    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" \
+             -DPYTHON_CMD=python3 \
              -DCMAKE_CXX_FLAGS="-I/build/usr/include" \
-             -DCMAKE_INSTALL_PREFIX=/usr \
-             -DLUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1 && \
+             -DCMAKE_INSTALL_PREFIX=/usr && \
     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/ && \
     cp -a /build/usr/src /out/usr/ && \
     cp -a /build/usr/include /out/usr
@@ -95,14 +69,12 @@ RUN mkdir -p /out/usr/lib && \
     cp -a /usr/lib/libstdc* /out/usr/lib/ && \
     cp -a /usr/lib/libintl* /out/usr/lib/ && \
     cp -a /usr/lib64/* /out/usr/lib/
-RUN mkdir -p /out/usr/lib/python2.7 && \
-    cp -a /usr/lib/python2.7/site-packages /out/usr/lib/python2.7/
+RUN mkdir -p /out/usr/lib/python3.8 && \
+    cp -a /usr/lib/python3.8/site-packages /out/usr/lib/python3.8/
 RUN mkdir -p /out/usr/share && \
     cp -a /usr/share/bcc /out/usr/share/
 RUN mkdir -p /out/usr/bin && \
     cp -a /usr/bin/bcc-lua /out/usr/bin/
-RUN mkdir -p /out/usr/local/share/ && \
-    cp -a /usr/local/share/lua /out/usr/local/share/
 
 FROM ${BUILD_IMAGE} as mirror
 RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
@@ -110,7 +82,7 @@ RUN apk update && apk upgrade -a && \
   apk add --no-cache --initdb -p /out \
   busybox \
   luajit \
-  python \
+  python3 \
   zlib \
   && true
 
diff --git a/kernel/Makefile b/kernel/Makefile
index 851293e9d6..9a26a2d1e1 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -226,11 +226,10 @@ forcepush_bcc_$(2)$(3)$(4): notdirty forcebuild_bcc_$(2)$(3)$(4)
 	$(PUSH_MANIFEST) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)-$(TAG) && \
 	$(PUSH_MANIFEST) $(ORG)/$(IMAGE_BCC):$(1)$(3)$(4)
 
-# Disable bcc build as it is failing: https://github.com/linuxkit/linuxkit/issues/3652
-# build: build_bcc_$(2)$(3)$(4)
-# forcebuild: forcebuild_bcc_$(2)$(3)$(4)
-# push: push_bcc_$(2)$(3)$(4)
-# forcepush: forcepush_bcc_$(2)$(3)$(4)
+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
 
diff --git a/kernel/bcc.patches/100-musl-compat.patch b/kernel/bcc.patches/100-musl-compat.patch
deleted file mode 100644
index 25e15047a5..0000000000
--- a/kernel/bcc.patches/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 <argp.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <stdlib.h>
- #include <string.h>
---- a/lib/xmalloc.c
-+++ b/lib/xmalloc.c
-@@ -30,7 +30,7 @@
- # include <config.h>
- #endif
- 
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <stddef.h>
- #include <stdlib.h>
---- a/src/addr2line.c
-+++ b/src/addr2line.c
-@@ -23,7 +23,7 @@
- #include <argp.h>
- #include <assert.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <inttypes.h>
- #include <libdwfl.h>
---- a/src/ar.c
-+++ b/src/ar.c
-@@ -22,7 +22,7 @@
- 
- #include <argp.h>
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <libintl.h>
---- a/src/arlib2.c
-+++ b/src/arlib2.c
-@@ -20,7 +20,7 @@
- # include <config.h>
- #endif
- 
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <limits.h>
- #include <string.h>
---- a/src/arlib.c
-+++ b/src/arlib.c
-@@ -21,7 +21,7 @@
- #endif
- 
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <gelf.h>
- #include <libintl.h>
- #include <stdio.h>
---- a/src/elfcmp.c
-+++ b/src/elfcmp.c
-@@ -23,7 +23,7 @@
- #include <argp.h>
- #include <assert.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <locale.h>
- #include <libintl.h>
---- a/src/elflint.c
-+++ b/src/elflint.c
-@@ -24,7 +24,7 @@
- #include <assert.h>
- #include <byteswap.h>
- #include <endian.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <inttypes.h>
---- a/src/findtextrel.c
-+++ b/src/findtextrel.c
-@@ -23,7 +23,7 @@
- #include <argp.h>
- #include <assert.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <libdw.h>
---- a/src/i386_ld.c
-+++ b/src/i386_ld.c
-@@ -20,7 +20,7 @@
- #endif
- 
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <stdlib.h>
- #include <string.h>
---- a/src/ld.c
-+++ b/src/ld.c
-@@ -21,7 +21,7 @@
- 
- #include <argp.h>
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <libelf.h>
- #include <libintl.h>
---- a/src/ldgeneric.c
-+++ b/src/ldgeneric.c
-@@ -23,7 +23,7 @@
- #include <ctype.h>
- #include <dlfcn.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <fnmatch.h>
- #include <gelf.h>
---- a/src/ldlex.c
-+++ b/src/ldlex.c
-@@ -1106,7 +1106,7 @@ char *ldtext;
- #include <assert.h>
- #include <ctype.h>
- #include <elf.h>
--#include <error.h>
-+#include <err.h>
- #include <inttypes.h>
- #include <libintl.h>
- #include <stdbool.h>
---- a/src/ldscript.c
-+++ b/src/ldscript.c
-@@ -95,7 +95,7 @@
- #endif
- 
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <stdbool.h>
- #include <stdint.h>
-@@ -106,7 +106,7 @@
- #include <system.h>
- #include <ld.h>
- 
--/* 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 <ctype.h>
- #include <dwarf.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <inttypes.h>
---- a/src/objdump.c
-+++ b/src/objdump.c
-@@ -21,7 +21,7 @@
- #endif
- 
- #include <argp.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <inttypes.h>
- #include <libintl.h>
---- a/src/ranlib.c
-+++ b/src/ranlib.c
-@@ -24,7 +24,7 @@
- #include <argp.h>
- #include <assert.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <libintl.h>
---- a/src/readelf.c
-+++ b/src/readelf.c
-@@ -25,7 +25,7 @@
- #include <ctype.h>
- #include <dwarf.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <inttypes.h>
---- a/src/size.c
-+++ b/src/size.c
-@@ -21,7 +21,7 @@
- #endif
- 
- #include <argp.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <inttypes.h>
---- a/src/stack.c
-+++ b/src/stack.c
-@@ -18,7 +18,7 @@
- #include <config.h>
- #include <assert.h>
- #include <argp.h>
--#include <error.h>
-+#include <err.h>
- #include <stdlib.h>
- #include <inttypes.h>
- #include <stdio.h>
---- a/src/strings.c
-+++ b/src/strings.c
-@@ -25,7 +25,7 @@
- #include <ctype.h>
- #include <endian.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <inttypes.h>
---- a/src/strip.c
-+++ b/src/strip.c
-@@ -24,7 +24,7 @@
- #include <assert.h>
- #include <byteswap.h>
- #include <endian.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <libelf.h>
---- a/src/unstrip.c
-+++ b/src/unstrip.c
-@@ -31,7 +31,7 @@
- #include <argp.h>
- #include <assert.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <fnmatch.h>
- #include <libintl.h>
---- a/tests/addrscopes.c
-+++ b/tests/addrscopes.c
-@@ -25,7 +25,7 @@
- #include <stdio_ext.h>
- #include <locale.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- 
- 
---- a/tests/allregs.c
-+++ b/tests/allregs.c
-@@ -21,7 +21,7 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
--#include <error.h>
-+#include <err.h>
- #include <locale.h>
- #include <argp.h>
- #include <assert.h>
---- a/tests/backtrace.c
-+++ b/tests/backtrace.c
-@@ -24,7 +24,7 @@
- #include <dirent.h>
- #include <stdlib.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <unistd.h>
- #include <dwarf.h>
- #ifdef __linux__
---- a/tests/backtrace-data.c
-+++ b/tests/backtrace-data.c
-@@ -27,7 +27,7 @@
- #include <dirent.h>
- #include <stdlib.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <unistd.h>
- #include <dwarf.h>
- #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 <stdio.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <stdlib.h>
- #include <sys/types.h>
---- a/tests/debugaltlink.c
-+++ b/tests/debugaltlink.c
-@@ -23,7 +23,7 @@
- #include ELFUTILS_HEADER(dw)
- #include ELFUTILS_HEADER(dwelf)
- #include <stdio.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <stdlib.h>
- #include <sys/types.h>
---- a/tests/debuglink.c
-+++ b/tests/debuglink.c
-@@ -21,7 +21,7 @@
- #include <errno.h>
- #include ELFUTILS_HEADER(dwelf)
- #include <stdio.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <stdlib.h>
- #include <sys/types.h>
---- a/tests/dwfl-addr-sect.c
-+++ b/tests/dwfl-addr-sect.c
-@@ -23,7 +23,7 @@
- #include <stdio_ext.h>
- #include <stdlib.h>
- #include <string.h>
--#include <error.h>
-+#include <err.h>
- #include <locale.h>
- #include <argp.h>
- #include ELFUTILS_HEADER(dwfl)
---- a/tests/dwfl-bug-addr-overflow.c
-+++ b/tests/dwfl-bug-addr-overflow.c
-@@ -20,7 +20,7 @@
- #include <inttypes.h>
- #include <stdio.h>
- #include <stdio_ext.h>
--#include <error.h>
-+#include <err.h>
- #include <locale.h>
- #include ELFUTILS_HEADER(dwfl)
- 
---- a/tests/dwfl-bug-fd-leak.c
-+++ b/tests/dwfl-bug-fd-leak.c
-@@ -24,7 +24,7 @@
- #include <dirent.h>
- #include <stdlib.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <unistd.h>
- #include <dwarf.h>
- #include <sys/resource.h>
---- a/tests/dwfl-bug-getmodules.c
-+++ b/tests/dwfl-bug-getmodules.c
-@@ -18,7 +18,7 @@
- #include <config.h>
- #include ELFUTILS_HEADER(dwfl)
- 
--#include <error.h>
-+#include <err.h>
- 
- static const Dwfl_Callbacks callbacks =
-   {
---- a/tests/dwfllines.c
-+++ b/tests/dwfllines.c
-@@ -27,7 +27,7 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
--#include <error.h>
-+#include <err.h>
- 
- int
- main (int argc, char *argv[])
---- a/tests/dwflmodtest.c
-+++ b/tests/dwflmodtest.c
-@@ -23,7 +23,7 @@
- #include <stdio_ext.h>
- #include <stdlib.h>
- #include <string.h>
--#include <error.h>
-+#include <err.h>
- #include <locale.h>
- #include <argp.h>
- #include ELFUTILS_HEADER(dwfl)
---- a/tests/dwfl-report-elf-align.c
-+++ b/tests/dwfl-report-elf-align.c
-@@ -20,7 +20,7 @@
- #include <inttypes.h>
- #include <stdio.h>
- #include <stdio_ext.h>
--#include <error.h>
-+#include <err.h>
- #include <locale.h>
- #include <string.h>
- #include <stdlib.h>
---- a/tests/dwflsyms.c
-+++ b/tests/dwflsyms.c
-@@ -25,7 +25,7 @@
- #include <stdio.h>
- #include <stdio_ext.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- 
- static const char *
---- a/tests/early-offscn.c
-+++ b/tests/early-offscn.c
-@@ -19,7 +19,7 @@
- #endif
- 
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <stdio.h>
---- a/tests/ecp.c
-+++ b/tests/ecp.c
-@@ -20,7 +20,7 @@
- #endif
- 
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <stdlib.h>
---- a/tests/find-prologues.c
-+++ b/tests/find-prologues.c
-@@ -25,7 +25,7 @@
- #include <stdio_ext.h>
- #include <locale.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <fnmatch.h>
- 
---- a/tests/funcretval.c
-+++ b/tests/funcretval.c
-@@ -25,7 +25,7 @@
- #include <stdio_ext.h>
- #include <locale.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <fnmatch.h>
- 
---- a/tests/funcscopes.c
-+++ b/tests/funcscopes.c
-@@ -25,7 +25,7 @@
- #include <stdio_ext.h>
- #include <locale.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <fnmatch.h>
- 
---- a/tests/line2addr.c
-+++ b/tests/line2addr.c
-@@ -26,7 +26,7 @@
- #include <locale.h>
- #include <stdlib.h>
- #include <string.h>
--#include <error.h>
-+#include <err.h>
- 
- 
- static void
---- a/tests/low_high_pc.c
-+++ b/tests/low_high_pc.c
-@@ -25,7 +25,7 @@
- #include <stdio_ext.h>
- #include <locale.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <fnmatch.h>
- 
---- a/tests/md5-sha1-test.c
-+++ b/tests/md5-sha1-test.c
-@@ -19,7 +19,7 @@
- #endif
- 
- #include <string.h>
--#include <error.h>
-+#include <err.h>
- 
- #include "md5.h"
- #include "sha1.h"
---- a/tests/rdwrmmap.c
-+++ b/tests/rdwrmmap.c
-@@ -19,7 +19,7 @@
- #endif
- 
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <unistd.h>
---- a/tests/saridx.c
-+++ b/tests/saridx.c
-@@ -17,7 +17,7 @@
- 
- #include <config.h>
- 
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <stdio.h>
---- a/tests/sectiondump.c
-+++ b/tests/sectiondump.c
-@@ -18,7 +18,7 @@
- #include <config.h>
- 
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <fcntl.h>
- #include <gelf.h>
- #include <inttypes.h>
---- a/tests/varlocs.c
-+++ b/tests/varlocs.c
-@@ -25,7 +25,7 @@
- #include <dwarf.h>
- #include <stdio.h>
- #include <stdlib.h>
--#include <error.h>
-+#include <err.h>
- #include <string.h>
- #include <sys/types.h>
- #include <sys/stat.h>
---- a/libelf/libelf.h
-+++ b/libelf/libelf.h
-@@ -29,6 +29,7 @@
- #ifndef _LIBELF_H
- #define _LIBELF_H 1
- 
-+#include <fcntl.h>
- #include <stdint.h>
- #include <sys/types.h>
- 
---- a/libasm/asm_end.c
-+++ b/libasm/asm_end.c
-@@ -32,7 +32,7 @@
- #endif
- 
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <stdio.h>
- #include <stdlib.h>
---- a/libasm/asm_newscn.c
-+++ b/libasm/asm_newscn.c
-@@ -32,7 +32,7 @@
- #endif
- 
- #include <assert.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- #include <stdlib.h>
- #include <string.h>
---- a/libcpu/i386_gendis.c
-+++ b/libcpu/i386_gendis.c
-@@ -31,7 +31,7 @@
- # include <config.h>
- #endif
- 
--#include <error.h>
-+#include <err.h>
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
---- a/libcpu/i386_lex.c
-+++ b/libcpu/i386_lex.c
-@@ -578,7 +578,7 @@ char *i386_text;
- #endif
- 
- #include <ctype.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- 
- #include <system.h>
---- a/libcpu/i386_lex.l
-+++ b/libcpu/i386_lex.l
-@@ -31,7 +31,7 @@
- #endif
- 
- #include <ctype.h>
--#include <error.h>
-+#include <err.h>
- #include <libintl.h>
- 
- #include <system.h>
---- a/libcpu/i386_parse.c
-+++ b/libcpu/i386_parse.c
-@@ -107,7 +107,7 @@
- #include <assert.h>
- #include <ctype.h>
- #include <errno.h>
--#include <error.h>
-+#include <err.h>
- #include <inttypes.h>
- #include <libintl.h>
- #include <math.h>
---- a/libdw/libdw_alloc.c
-+++ b/libdw/libdw_alloc.c
-@@ -31,7 +31,7 @@
- # include <config.h>
- #endif
- 
--#include <error.h>
-+#include <err.h>
- #include <errno.h>
- #include <stdlib.h>
- #include <sys/param.h>
-@@ -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 <assert.h>
- #include <dlfcn.h>
--#include <error.h>
-+#include <err.h>
- #include <libelfP.h>
- #include <dwarf.h>
- #include <stdlib.h>
---- a/src/ldlex.l
-+++ b/src/ldlex.l
-@@ -23,7 +23,7 @@
- #include <assert.h>
- #include <ctype.h>
- #include <elf.h>
--#include <error.h>
-+#include <err.h>
- #include <inttypes.h>
- #include <libintl.h>
- #include <stdbool.h>
---- 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 <stdio.h>
-+#include <unistd.h>
-+#include <alloca.h>
-+#include <string.h>
-+
-+#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/cdefs.h b/kernel/bcc.patches/cdefs.h
deleted file mode 100644
index 8ec977083e..0000000000
--- a/kernel/bcc.patches/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<x>(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
deleted file mode 100644
index 4f69bfa76e..0000000000
--- a/kernel/bcc.patches/decl.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- libelf/elf.h-orig
-+++ libelf/elf.h
-@@ -21,7 +21,9 @@
- 
- #include <features.h>
- 
--__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
deleted file mode 100644
index 6b71c7e688..0000000000
--- a/kernel/bcc.patches/error.h
+++ /dev/null
@@ -1,29 +0,0 @@
-# include <stdio.h>
-# include <stdarg.h>
-# include <stdlib.h>
-# include <string.h>
-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
deleted file mode 100644
index 6c191937f4..0000000000
--- a/kernel/bcc.patches/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/kernel/bcc.patches/temp_failure.patch b/kernel/bcc.patches/temp_failure.patch
deleted file mode 100644
index 2997f45db4..0000000000
--- a/kernel/bcc.patches/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))


Test patch: