Skip to content

Commit

Permalink
WIP of AArch64 container
Browse files Browse the repository at this point in the history
Building seL4 projects and CAmkES projects should work now.
The l4v container is not tested.
  • Loading branch information
Ivan-Velickovic committed Jun 21, 2023
1 parent 0d9f9f7 commit 12ae898
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ endif

ETC_LOCALTIME := $(realpath /etc/localtime)

HOST_ARCH := $(shell arch)
ifeq ($(HOST_ARCH),x86_64)
DOCKER_PLATFORM := "linux/amd64"
else ifeq ($(HOST_ARCH),arm64)
# We assume ARMv8 as the platform
DOCKER_PLATFORM := "linux/arm64/v8"
else
@echo "Unsupported host architecture: $HOST_ARCH"
@exit 1
endif

# Extra arguments to pass to `docker run` if it is or is not `podman` - these
# are constructed in a very verbose way to be obvious about why we want to do
# certain things under regular `docker` vs` podman`
Expand Down Expand Up @@ -136,7 +147,6 @@ user_run:
--group-add sudo \
-v $(HOST_DIR):/host:z \
-v $(DOCKER_VOLUME_HOME):/home/$(shell whoami) \
-v $(ETC_LOCALTIME):/etc/localtime:ro \
$(USER_IMG) $(EXEC)

.PHONY: user_run_l4v
Expand Down Expand Up @@ -171,12 +181,12 @@ endif

.PHONY: build_user
build_user: run_checks
$(DOCKER_BUILD) $(DOCKER_FLAGS) \
$(DOCKER_BUILD) --platform $(DOCKER_PLATFORM) $(DOCKER_FLAGS) \
--build-arg=USER_BASE_IMG=$(DOCKERHUB)$(USER_BASE_IMG) \
-f dockerfiles/extras.Dockerfile \
-t $(EXTRAS_IMG) \
.
$(DOCKER_BUILD) $(DOCKER_FLAGS) \
$(DOCKER_BUILD) --platform $(DOCKER_PLATFORM) $(DOCKER_FLAGS) \
--build-arg=EXTRAS_IMG=$(EXTRAS_IMG) \
--build-arg=UNAME=$(shell whoami) \
--build-arg=UID=$(shell id -u) \
Expand Down
14 changes: 12 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ set -ef
DOCKER_BUILD="docker build"
DOCKER_FLAGS="--force-rm=true"

HOST_ARCH=`arch`
if [[ $HOST_ARCH == "x86_64" ]]; then
DOCKER_PLATFORM="linux/amd64"
elif [[ $HOST_ARCH == "arm64" ]]; then
DOCKER_PLATFORM="linux/arm64/v8"
else
echo "Unsupported host architecture: $HOST_ARCH"
exit 1
fi

# Special variables to be passed through Docker to the build scripts
: "${SCM}"

Expand All @@ -61,7 +71,7 @@ build_internal_image()

build_args_to_pass_to_docker=$(echo "$build_args" | grep "=" | awk '{print "--build-arg", $1}')
# shellcheck disable=SC2086
$DOCKER_BUILD $DOCKER_FLAGS \
$DOCKER_BUILD --platform $DOCKER_PLATFORM $DOCKER_FLAGS \
--build-arg BASE_IMG="$base_img" \
--build-arg SCM="$SCM" \
$build_args_to_pass_to_docker \
Expand Down Expand Up @@ -91,7 +101,7 @@ apply_software_to_image()

# NOTE: it's OK to supply docker build-args that aren't requested in the Dockerfile

$DOCKER_BUILD $DOCKER_FLAGS \
$DOCKER_BUILD --platform $DOCKER_PLATFORM $DOCKER_FLAGS \
--build-arg BASE_BUILDER_IMG="$DOCKERHUB$prebuilt_img" \
--build-arg BASE_IMG="$DOCKERHUB$orig_img" \
--build-arg SCM="$SCM" \
Expand Down
9 changes: 6 additions & 3 deletions scripts/camkes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ possibly_toggle_apt_snapshot

# Get dependencies
as_root dpkg --add-architecture i386
as_root dpkg --add-architecture arm64
as_root apt-get update -q
as_root apt-get install -y --no-install-recommends \
acl \
Expand All @@ -43,7 +44,6 @@ as_root apt-get install -y --no-install-recommends \
linux-libc-dev:i386 \
pkg-config \
spin \
lib32stdc++-10-dev \
# end of list

# Required for testing
Expand Down Expand Up @@ -84,8 +84,11 @@ as_root pip3 install --no-cache-dir \
# end of list

# Get stack
wget -O - https://get.haskellstack.org/ | sh
echo "export PATH=\"\$PATH:\$HOME/.local/bin\"" >> "$HOME/.bashrc"
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_GHC_VERSION=latest \
BOOTSTRAP_HASKELL_CABAL_VERSION=latest \
BOOTSTRAP_HASKELL_INSTALL_STACK=1 \
BOOTSTRAP_HASKELL_ADJUST_BASHRC=P sh

# Pick a random group ID, one that won't clash with common user GIDs
as_root groupadd -g "$STACK_GID" stack
Expand Down
16 changes: 13 additions & 3 deletions scripts/sel4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ test -d "$DIR" || DIR=$PWD
# Add additional architectures for cross-compiled libraries.
# Install the tools required to compile seL4.
as_root apt-get update -q
as_root dpkg --add-architecture amd64
as_root dpkg --add-architecture i386
as_root dpkg --add-architecture armhf
as_root dpkg --add-architecture armel
as_root dpkg --add-architecture arm64
as_root apt-get install -y --no-install-recommends \
astyle=3.1-2+b1 \
build-essential \
Expand All @@ -55,16 +58,17 @@ as_root apt-get install -y --no-install-recommends \
u-boot-tools \
clang-11 \
g++-10 \
g++-10-aarch64-linux-gnu \
g++-10-arm-linux-gnueabi \
g++-10-arm-linux-gnueabihf \
gcc-10 \
gcc-10-aarch64-linux-gnu \
gcc-10-arm-linux-gnueabi \
gcc-10-arm-linux-gnueabihf \
gcc-10-base \
gcc-10-multilib \
gcc-riscv64-unknown-elf \
gcc-10-x86-64-linux-gnu:arm64 \
g++-10-x86-64-linux-gnu:arm64 \
gcc-10-i686-linux-gnu:arm64 \
g++-10-i686-linux-gnu:arm64 \
libclang-11-dev \
qemu-system-arm \
qemu-system-misc
Expand Down Expand Up @@ -97,6 +101,12 @@ if [ "$DESKTOP_MACHINE" = "no" ] ; then
gcc-${compiler_version}-arm-linux-gnueabihf \
cpp-${compiler_version}-arm-linux-gnueabihf \
g++-${compiler_version}-arm-linux-gnueabihf \
gcc-${compiler_version}-x86-64-linux-gnu \
cpp-${compiler_version}-x86-64-linux-gnu \
g++-${compiler_version}-x86-64-linux-gnu \
gcc-${compiler_version}-i686-linux-gnu \
cpp-${compiler_version}-i686-linux-gnu \
g++-${compiler_version}-i686-linux-gnu \
# end of list
do
echo ${compiler}
Expand Down

0 comments on commit 12ae898

Please sign in to comment.