mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
images: use mulitarch default image instead of hacky workaround
Instead of lying to clang about the targeted system, we can install the necessary package only on x86_64 machines. Our tooling supports multiarch packages (see tools/images.mk). PiperOrigin-RevId: 591385576
This commit is contained in:
committed by
gVisor bot
parent
c1aef9f901
commit
dc40c49df4
@@ -10,6 +10,10 @@ RUN apt-get update && apt-get install -y curl gnupg2 git \
|
||||
pkg-config libffi-dev patch diffutils libssl-dev iptables kmod \
|
||||
clang crossbuild-essential-amd64 erofs-utils busybox-static libbpf-dev
|
||||
|
||||
# This package is needed to build eBPF on amd64, but not on arm64 where it
|
||||
# doesn't exist.
|
||||
RUN test "$(uname -m)" != x86_64 && exit 0 || apt-get install -y libc6-dev-i386
|
||||
|
||||
# Install Docker client for the website build.
|
||||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
||||
RUN add-apt-repository \
|
||||
|
||||
@@ -104,21 +104,5 @@ def bpf_program(name, src, bpf_object, visibility, hdrs):
|
||||
srcs = [src],
|
||||
visibility = visibility,
|
||||
outs = [bpf_object],
|
||||
# Note: "-D __x86_64__" is a hack to deal with building across
|
||||
# architectures. As we're targeting eBPF, setting this doesn't lead to
|
||||
# any x86_64-specific code. But it does help with an annoying edge
|
||||
# case:
|
||||
#
|
||||
# We have a single container -- images/default -- that runs on both
|
||||
# arm64 and x86_64 machines. To build eBPF on x86_64, package
|
||||
# gcc-multilib or libc6-dev-i386 is needed to install headers. But
|
||||
# these don't exist on arm64, so adding it to the image breaks arm64
|
||||
# builds.
|
||||
#
|
||||
# Defining __x86_64__ lets us avoid the need for these packages
|
||||
# altogether. It turns out that the missing headers are irrelevant
|
||||
# (unused) when building eBPF, and pretending we're targeting x86_64
|
||||
# causes #includes to resolve without installing architecture-specific
|
||||
# packages.
|
||||
cmd = "clang -O2 -Wall -Werror -target bpf -c $< -o $@ -I/usr/include/$$(uname -m)-linux-gnu -D __x86_64__",
|
||||
cmd = "clang -O2 -Wall -Werror -target bpf -c $< -o $@ -I/usr/include/$$(uname -m)-linux-gnu",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user