Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 Documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ The script takes these three arguments:
`./scripts/compile-kernel.sh <repository> <config> <compiler>`

For example, to build the current main-line kernel with the default kernel
configuration and clang compiler, run:
configuration and clang-5.0 compiler, run:

```
./scripts/compile-kernel.sh torvalds defconfig clang
./scripts/compile-kernel.sh torvalds defconfig clang-5.0
```

For other help, use `./scripts/compile-kernel.sh --help`.
File renamed without changes.
17 changes: 17 additions & 0 deletions docker/kernel-clang-6.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) Lukas Bulwahn, BMW Car IT GmbH
# SPDX-License-Identifier: GPL-2.0
FROM debian:buster

LABEL maintainer="Lukas Bulwahn <lukas.bulwahn@gmail.com>"

# Install tools needed for kernel build and clang compiler
RUN apt-get update && apt-get install --no-install-recommends -y \
bc \
bison \
bsdmainutils \
clang-6.0 \
flex \
libelf-dev \
libssl-dev \
make \
&& rm -rf /var/lib/apt/lists/*
25 changes: 25 additions & 0 deletions docker/kernel-clang-7-llvm-snapshot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) Lukas Bulwahn, BMW Car IT GmbH
# SPDX-License-Identifier: GPL-2.0
FROM debian:buster

LABEL maintainer="Lukas Bulwahn <lukas.bulwahn@gmail.com>"

# Install tools needed for kernel build and clang compiler
RUN apt-get update && apt-get install --no-install-recommends -y \
bc \
bison \
bsdmainutils \
ca-certificates \
gnupg \
gnupg-utils \
flex \
libelf-dev \
libssl-dev \
make \
wget

RUN echo "deb http://apt.llvm.org/unstable/ llvm-toolchain main" >> /etc/apt/sources.list \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
&& apt-get update \
&& apt-get install --no-install-recommends -y clang-7 \
&& rm -rf /var/lib/apt/lists/*
17 changes: 17 additions & 0 deletions docker/kernel-clang-7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) Lukas Bulwahn, BMW Car IT GmbH
# SPDX-License-Identifier: GPL-2.0
FROM debian:sid

LABEL maintainer="Lukas Bulwahn <lukas.bulwahn@gmail.com>"

# Install tools needed for kernel build and clang compiler
RUN apt-get update && apt-get install --no-install-recommends -y \
bc \
bison \
bsdmainutils \
clang-7 \
flex \
libelf-dev \
libssl-dev \
make \
&& rm -rf /var/lib/apt/lists/*
13 changes: 6 additions & 7 deletions scripts/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo 'Building the Docker image "kernel-gcc"'
cd "$SCRIPT_DIR/../docker/kernel-gcc"
docker build -t kernel-gcc .

echo 'Building the Docker image "kernel-clang"'
cd "$SCRIPT_DIR/../docker/kernel-clang"
docker build -t kernel-clang .
for DOCKER_IMAGE in $(find $SCRIPT_DIR/../docker -mindepth 1 -maxdepth 1 -type d -printf "%f\n")
do
echo Building the Docker image "$DOCKER_IMAGE"
cd "$SCRIPT_DIR/../docker/$DOCKER_IMAGE"
docker build -t $DOCKER_IMAGE .
done
16 changes: 8 additions & 8 deletions scripts/compile-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ usage() {
echo
echo " <repository> = torvalds | stable | next"
echo " <config> = allnoconfig | allmodconfig | allyesconfig | defconfig | randconfig"
echo " <compiler> = gcc | clang"
echo " <compiler> = gcc | clang-5.0 | clang-6.0 | clang-7"
}

# Provide help if requested
Expand Down Expand Up @@ -83,12 +83,12 @@ esac
# Check third argument and set COMPILER

case "$3" in
gcc | clang)
gcc | clang-5.0 | clang-6.0 | clang-7)
COMPILER=$3
;;
*)
echo "Error: Invalid compiler: $3"
echo 'The compiler must be either "gcc" or "clang"'
echo 'The compiler must be "gcc", "clang-5.0", "clang-6.0" or "clang-7"'
exit 1
;;
esac
Expand All @@ -102,13 +102,13 @@ case "$COMPILER" in
kernel-gcc \
/bin/sh -c "cd linux && make clean && make $KERNEL_CONFIG && make -j32"
;;
clang)
clang-5.0 | clang-6.0 | clang-7)
docker run \
-v "$KERNEL_SRC_DIR:/linux/" \
kernel-clang \
kernel-$COMPILER \
/bin/sh -c "cd linux && \
make CC=clang-5.0 clean && \
make HOSTCC=clang-5.0 $KERNEL_CONFIG && \
make -j32 HOSTCC=clang-5.0 CC=clang-5.0"
make CC=$COMPILER clean && \
make HOSTCC=$COMPILER $KERNEL_CONFIG && \
make -j32 HOSTCC=$COMPILER CC=$COMPILER"
;;
esac