diff --git a/kernel/Dockerfile.bcc b/kernel/Dockerfile.bcc index 337ace260..fbab562e6 100644 --- a/kernel/Dockerfile.bcc +++ b/kernel/Dockerfile.bcc @@ -50,11 +50,10 @@ RUN curl -sSL -O https://fedorahosted.org/releases/e/l/elfutils/0.165/elfutils-$ patch -p0 < ../decl.patch && \ patch -p0 < ../intl.patch -ENV BCC_COMMIT=6972806729da00ecda0235abac61d66c8fad7fad +ENV BCC_COMMIT=0fa419a64e71984d42f107c210d3d3f0cc82d59a RUN git clone https://github.com/iovisor/bcc.git && \ cd bcc && \ - git checkout $BCC_COMMIT && \ - patch -p0 < ../bcc-gnuism.patch && patch -p0 < ../bcc-lua.patch + git checkout $BCC_COMMIT ENV LJSYSCALL_COMMIT=e587f8c55aad3955dddab3a4fa6c1968037b5c6e RUN git clone https://github.com/justincormack/ljsyscall.git && \ diff --git a/kernel/Makefile b/kernel/Makefile index 8dff45de3..ffb363750 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -149,9 +149,9 @@ show-tags: show-tag_$(2)$(3)$(4) # with DCT as part of the dependency on build_$(2)$(3)$(4) and then build # with DOCKER_CONTENT_TRUST explicitly set to 0 -# Skip perf build for now. See: -# https://github.com/linuxkit/linuxkit/issues/3299 -ifeq ($(ARCH),SKIP) +# Only build perf on latest LTS and stable kernels. Skip arm64. +ifeq ($(2), $(filter $(2),5.3.x 4.19.x)) +ifneq ($(ARCH),aarch64) build_perf_$(2)$(3)$(4): build_$(2)$(3)$(4) docker pull $(ORG)/$(IMAGE_PERF):$(1)$(3)$(4)-$(TAG)$(SUFFIX) || \ DOCKER_CONTENT_TRUST=0 docker build -f Dockerfile.perf \ @@ -185,10 +185,11 @@ forcebuild: forcebuild_perf_$(2)$(3)$(4) push: push_perf_$(2)$(3)$(4) forcepush: forcepush_perf_$(2)$(3)$(4) endif +endif # Only build BCC on x86 and only on latest LTS and latest stable kernels. ifeq ($(ARCH),x86_64) -ifneq ($(2), $(filter $(2),4.9.x)) +ifeq ($(2), $(filter $(2),5.3.x 4.19.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 \ diff --git a/kernel/bcc.patches/bcc-gnuism.patch b/kernel/bcc.patches/bcc-gnuism.patch deleted file mode 100644 index 3312fde0e..000000000 --- a/kernel/bcc.patches/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/kernel/bcc.patches/bcc-lua.patch b/kernel/bcc.patches/bcc-lua.patch deleted file mode 100644 index b10eb1b0c..000000000 --- a/kernel/bcc.patches/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/kernel/patches-4.19.x/0001-perf-symbols-Add-fallback-definitions-for-GELF_ST_VI.patch b/kernel/patches-4.19.x/0001-perf-symbols-Add-fallback-definitions-for-GELF_ST_VI.patch new file mode 100644 index 000000000..aea60a553 --- /dev/null +++ b/kernel/patches-4.19.x/0001-perf-symbols-Add-fallback-definitions-for-GELF_ST_VI.patch @@ -0,0 +1,52 @@ +From c3770da814783f82f86d36673fd19e4ebde6bf54 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 4 Feb 2019 15:48:03 -0300 +Subject: [PATCH 1/2] perf symbols: Add fallback definitions for + GELF_ST_VISIBILITY() + +Those aren't present in Alpine Linux 3.4 to edge, so provide fallback +defines to get the next patch building there keeping the build +bisectable. + +Cc: Adrian Hunter +Cc: Alexander Shishkin +Cc: Jiri Olsa +Cc: Masami Hiramatsu +Cc: Michael Petlan +Cc: Namhyung Kim +Cc: Nick Clifton +Cc: Peter Zijlstra +Link: https://lkml.kernel.org/n/tip-03cg3gya2ju4ba2x6ibb9fuz@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/util/symbol-elf.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c +index a701a8a48f00..dc3fbcbb0e79 100644 +--- a/tools/perf/util/symbol-elf.c ++++ b/tools/perf/util/symbol-elf.c +@@ -19,6 +19,20 @@ + #define EM_AARCH64 183 /* ARM 64 bit */ + #endif + ++#ifndef ELF32_ST_VISIBILITY ++#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) ++#endif ++ ++/* For ELF64 the definitions are the same. */ ++#ifndef ELF64_ST_VISIBILITY ++#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) ++#endif ++ ++/* How to extract information held in the st_other field. */ ++#ifndef GELF_ST_VISIBILITY ++#define GELF_ST_VISIBILITY(val) ELF64_ST_VISIBILITY (val) ++#endif ++ + typedef Elf64_Nhdr GElf_Nhdr; + + #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT +-- +2.24.0 + diff --git a/kernel/patches-4.19.x/0002-include-uapi-linux-swab-Fix-potentially-missing-__al.patch b/kernel/patches-4.19.x/0002-include-uapi-linux-swab-Fix-potentially-missing-__al.patch new file mode 100644 index 000000000..37817e1e8 --- /dev/null +++ b/kernel/patches-4.19.x/0002-include-uapi-linux-swab-Fix-potentially-missing-__al.patch @@ -0,0 +1,55 @@ +From 01d3d9d51e7036eb0f83cfc874b5d6daf18a146f Mon Sep 17 00:00:00 2001 +From: Matt Redfearn +Date: Wed, 3 Jan 2018 09:57:30 +0000 +Subject: [PATCH 2/2] include/uapi/linux/swab: Fix potentially missing + __always_inline +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit bc27fb68aaad ("include/uapi/linux/byteorder, swab: force inlining +of some byteswap operations") added __always_inline to swab functions +and commit 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to +userspace headers") added a definition of __always_inline for use in +exported headers when the kernel's compiler.h is not available. + +However, since swab.h does not include stddef.h, if the header soup does +not indirectly include it, the definition of __always_inline is missing, +resulting in a compilation failure, which was observed compiling the +perf tool using exported headers containing this commit: + +In file included from /usr/include/linux/byteorder/little_endian.h:12:0, + from /usr/include/asm/byteorder.h:14, + from tools/include/uapi/linux/perf_event.h:20, + from perf.h:8, + from builtin-bench.c:18: +/usr/include/linux/swab.h:160:8: error: unknown type name ‘__always_inline’ + static __always_inline __u16 __swab16p(const __u16 *p) + +Fix this by replacing the inclusion of linux/compiler.h with +linux/stddef.h to ensure that we pick up that definition if required, +without relying on it's indirect inclusion. compiler.h is then included +indirectly, via stddef.h. + +Fixes: 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to userspace headers") +Signed-off-by: Matt Redfearn +--- + include/uapi/linux/swab.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h +index 23cd84868cc3..f6a8cf737abf 100644 +--- a/include/uapi/linux/swab.h ++++ b/include/uapi/linux/swab.h +@@ -3,7 +3,7 @@ + #define _UAPI_LINUX_SWAB_H + + #include +-#include ++#include + #include + + /* +-- +2.24.0 + diff --git a/kernel/patches-5.3.x/0001-include-uapi-linux-swab-Fix-potentially-missing-__al.patch b/kernel/patches-5.3.x/0001-include-uapi-linux-swab-Fix-potentially-missing-__al.patch new file mode 100644 index 000000000..be294edd0 --- /dev/null +++ b/kernel/patches-5.3.x/0001-include-uapi-linux-swab-Fix-potentially-missing-__al.patch @@ -0,0 +1,55 @@ +From 8d4b24575143777bf185e659c280be2cec3ff9b0 Mon Sep 17 00:00:00 2001 +From: Matt Redfearn +Date: Wed, 3 Jan 2018 09:57:30 +0000 +Subject: [PATCH] include/uapi/linux/swab: Fix potentially missing + __always_inline +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit bc27fb68aaad ("include/uapi/linux/byteorder, swab: force inlining +of some byteswap operations") added __always_inline to swab functions +and commit 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to +userspace headers") added a definition of __always_inline for use in +exported headers when the kernel's compiler.h is not available. + +However, since swab.h does not include stddef.h, if the header soup does +not indirectly include it, the definition of __always_inline is missing, +resulting in a compilation failure, which was observed compiling the +perf tool using exported headers containing this commit: + +In file included from /usr/include/linux/byteorder/little_endian.h:12:0, + from /usr/include/asm/byteorder.h:14, + from tools/include/uapi/linux/perf_event.h:20, + from perf.h:8, + from builtin-bench.c:18: +/usr/include/linux/swab.h:160:8: error: unknown type name ‘__always_inline’ + static __always_inline __u16 __swab16p(const __u16 *p) + +Fix this by replacing the inclusion of linux/compiler.h with +linux/stddef.h to ensure that we pick up that definition if required, +without relying on it's indirect inclusion. compiler.h is then included +indirectly, via stddef.h. + +Fixes: 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to userspace headers") +Signed-off-by: Matt Redfearn +--- + include/uapi/linux/swab.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h +index 23cd84868cc3..f6a8cf737abf 100644 +--- a/include/uapi/linux/swab.h ++++ b/include/uapi/linux/swab.h +@@ -3,7 +3,7 @@ + #define _UAPI_LINUX_SWAB_H + + #include +-#include ++#include + #include + + /* +-- +2.24.0 +