Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/stirling/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ pl_cc_library(
# Used by stirling runtime to install linux headers on hosts having no Linux headers pre-installed.
#
# Note that each linux header tarball is ~15MB compressed and ~230MB uncompressed.
# Trimmed versions are ~8MB compressed and ~110MB uncompressed.
# These are all trimmed versions, so we have 8 * 12 = 96 MB of headers.
# Trimmed versions are ~8-11MB (8.6 MB avg) compressed and ~45MB uncompressed.
# These are all trimmed versions, so we have 9MB * 29 = ~250 MB of headers.
stirling_linux_headers_tarballs = select({
"@platforms//cpu:aarch64": ["@linux_headers_merged_arm64_tar_gz//file:file"],
"@platforms//cpu:x86_64": ["@linux_headers_merged_x86_64_tar_gz//file:file"],
Expand Down
35 changes: 28 additions & 7 deletions tools/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,36 @@ SYSROOT_CREATOR_IMAGE_TAG := sysroot-creator-$(SYSROOT_REV)
## Linux image parameters
LINUX_HEADER_BUILD_DIR := $(BUILD_DIR)/linux_headers
LINUX_HEADER_ASSETS_BUILD_DIR := $(LINUX_HEADER_BUILD_DIR)/assets
LINUX_KERNEL_VERSIONS := 4.14.304 \
LINUX_KERNEL_VERSIONS := 4.14.309 \
4.15.18 \
4.16.18 \
4.17.19 \
4.18.20 \
4.19.271 \
4.19.325 \
4.20.17 \
5.0.21 \
5.1.21 \
5.2.21 \
5.3.18 \
5.4.230 \
5.4.293 \
5.5.19 \
5.6.19 \
5.7.19 \
5.8.18 \
5.9.16 \
5.10.165 \
5.10.237 \
5.11.22 \
5.12.19 \
5.13.19 \
5.14.21 \
5.15.90 \
5.15.181 \
5.16.20 \
5.17.15 \
5.18.19 \
5.19.17 \
6.0.19 \
6.1.8
6.1.137 \
6.6.89

LINUX_HEADER_X86_64_TEMPLATE := linux-headers-x86_64-%.tar.gz
LINUX_HEADER_ARM64_TEMPLATE := linux-headers-arm64-%.tar.gz
Expand Down Expand Up @@ -210,19 +211,39 @@ ifndef LINUX_HEADERS_REV
$(error set LINUX_HEADERS_REV to a valid value)
endif
@mkdir -p $(@D)
# Linux 6.3 and later has differences in the build process.
# We need to use a different Dockerfile for these versions.
KERN_MAJ=$$(echo $* | cut -d. -f1); \
KERN_MIN=$$(echo $* | cut -d. -f2); \
HEADERS_DOCKERFILE_SUFFIX=""; \
if [ $${KERN_MAJ} -lt 6 ] || { [ $${KERN_MAJ} -le 6 ] && [ $${KERN_MIN} -lt 3 ]; }; then \
HEADERS_DOCKERFILE_SUFFIX=".bionic"; \
fi; \
linux_headers_image_tag="gcr.io/pixie-oss/pixie-dev-public:$*-$(LINUX_HEADERS_REV)"; \
$(DOCKER) build --build-arg KERN_VERSION=$* --build-arg ARCH=x86_64 linux_headers_image -t "$${linux_headers_image_tag}" && \
$(DOCKER) build --build-arg KERN_VERSION=$* \
--build-arg ARCH=x86_64 linux_headers_image \
-t "$${linux_headers_image_tag}" \
-f linux_headers_image/Dockerfile$${HEADERS_DOCKERFILE_SUFFIX} && \
$(DOCKER) run --rm -v $(PWD)/$(LINUX_HEADER_ASSETS_BUILD_DIR):/output "$${linux_headers_image_tag}"

$(LINUX_HEADER_ASSETS_BUILD_DIR)/linux-headers-arm64-%.tar.gz: linux_headers_image/Dockerfile linux_headers_image/arm64_config
ifndef LINUX_HEADERS_REV
$(error set LINUX_HEADERS_REV to a valid value)
endif
@mkdir -p $(@D)
# Linux 6.3 and later has differences in the build process.
# We need to use a different Dockerfile for these versions.
KERN_MAJ=$$(echo $* | cut -d. -f1); \
KERN_MIN=$$(echo $* | cut -d. -f2); \
HEADERS_DOCKERFILE_SUFFIX=""; \
if [ $${KERN_MAJ} -lt 6 ] || { [ $${KERN_MAJ} -le 6 ] && [ $${KERN_MIN} -lt 3 ]; }; then \
HEADERS_DOCKERFILE_SUFFIX=".bionic"; \
fi; \
linux_headers_image_tag="gcr.io/pixie-oss/pixie-dev-public:$*-$(LINUX_HEADERS_REV)"; \
$(DOCKER) build --build-arg KERN_VERSION=$* \
--build-arg ARCH=arm64 \
--build-arg CROSS_COMPILE=aarch64-linux-gnu- \
-f linux_headers_image/Dockerfile$${HEADERS_DOCKERFILE_SUFFIX} \
linux_headers_image -t "$${linux_headers_image_tag}" && \
$(DOCKER) run --rm -v $(PWD)/$(LINUX_HEADER_ASSETS_BUILD_DIR):/output "$${linux_headers_image_tag}"

Expand Down
11 changes: 7 additions & 4 deletions tools/docker/linux_headers_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
#
# SPDX-License-Identifier: Apache-2.0

FROM ubuntu:18.04@sha256:8aa9c2798215f99544d1ce7439ea9c3a6dfd82de607da1cec3a8a2fae005931b
# debhelper-compat (= 12) needed for kernels >= 6.3
FROM ubuntu:20.04@sha256:6d8d9799fe6ab3221965efac00b4c34a2bcc102c086a58dff9e19a08b913c7ef
Comment thread
ddelnano marked this conversation as resolved.
Outdated

# Install required packages
RUN apt-get update
RUN apt-get upgrade -y -q
RUN apt-get install -y -q build-essential \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q build-essential \
Comment thread
ddelnano marked this conversation as resolved.
Outdated
bc \
libelf-dev \
libssl-dev \
Expand All @@ -32,6 +33,7 @@ RUN apt-get install -y -q build-essential \
binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
dwarves \
debhelper \
python3

ARG KERN_VERSION
Expand All @@ -54,11 +56,12 @@ WORKDIR /px/src/linux-${KERN_VERSION}
RUN cp /configs/${ARCH} .config
RUN make ARCH=${ARCH} olddefconfig
RUN make ARCH=${ARCH} clean
RUN make ARCH=${ARCH} -j $(nproc) deb-pkg LOCALVERSION=-pl
RUN make ARCH=${ARCH} -j $(nproc) bindeb-pkg LOCALVERSION=-pl

# Extract headers into a tarball
WORKDIR /px
RUN DEB_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/g'); dpkg -x src/linux-headers-${KERN_VERSION}-pl_${KERN_VERSION}-pl-1_${DEB_ARCH}.deb .
# Linux 6.3 and later name the resulting package differently (there is no additional -pl suffix)
Comment thread
ddelnano marked this conversation as resolved.
Outdated
RUN DEB_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/g'); dpkg -x src/linux-headers-${KERN_VERSION}-pl_${KERN_VERSION}-1_${DEB_ARCH}.deb .

# Remove broken symlinks
RUN find usr/src/linux-headers-${KERN_VERSION}-pl -xtype l -exec rm {} +
Expand Down
78 changes: 78 additions & 0 deletions tools/docker/linux_headers_image/Dockerfile.bionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2018- The Pixie Authors.
Comment thread
ddelnano marked this conversation as resolved.
Outdated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

FROM ubuntu:18.04@sha256:8aa9c2798215f99544d1ce7439ea9c3a6dfd82de607da1cec3a8a2fae005931b
Comment thread
ddelnano marked this conversation as resolved.
Outdated

# Install required packages
RUN apt-get update
RUN apt-get upgrade -y -q
RUN apt-get install -y -q build-essential \
bc \
libelf-dev \
libssl-dev \
flex \
bison \
kmod \
cpio \
rsync \
wget \
binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
dwarves \
python3

ARG KERN_VERSION

# Download Linux sources
WORKDIR /px/src
RUN KERN_MAJ="$(echo "${KERN_VERSION}" | cut -d'.' -f1)"; \
wget -nv http://mirrors.edge.kernel.org/pub/linux/kernel/v${KERN_MAJ}.x/linux-${KERN_VERSION}.tar.gz
RUN tar zxf linux-${KERN_VERSION}.tar.gz

WORKDIR /configs
ADD x86_64_config /configs/x86_64
ADD arm64_config /configs/arm64

ARG ARCH
ARG CROSS_COMPILE

# Build Linux kernel
WORKDIR /px/src/linux-${KERN_VERSION}
RUN cp /configs/${ARCH} .config
RUN make ARCH=${ARCH} olddefconfig
RUN make ARCH=${ARCH} clean
RUN make ARCH=${ARCH} -j $(nproc) deb-pkg LOCALVERSION=-pl

# Extract headers into a tarball
WORKDIR /px
RUN DEB_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/g'); dpkg -x src/linux-headers-${KERN_VERSION}-pl_${KERN_VERSION}-pl-1_${DEB_ARCH}.deb .

# Remove broken symlinks
RUN find usr/src/linux-headers-${KERN_VERSION}-pl -xtype l -exec rm {} +

# Remove uneeded files to reduce size
# Keep only:
# - usr/src/linux-headers-x.x.x-pl/include
# - usr/src/linux-headers-x.x.x-pl/arch/${ARCH}
# This reduces the size by a little over 2x.
RUN rm -rf usr/share
RUN find usr/src/linux-headers-${KERN_VERSION}-pl -maxdepth 1 -mindepth 1 ! -name include ! -name arch -type d \
-exec rm -rf {} +
RUN find usr/src/linux-headers-${KERN_VERSION}-pl/arch -maxdepth 1 -mindepth 1 ! -name $(echo ${ARCH} | sed 's/x86_64/x86/g') -type d -exec rm -rf {} +
RUN tar zcf linux-headers-${ARCH}-${KERN_VERSION}.tar.gz usr

VOLUME /output
CMD ["sh", "-c", "cp linux-headers-*.tar.gz /output/"]
Loading