Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): Add llvm, clang and linker #83

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
24 changes: 20 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ARG AARCH32_TOOLCHAIN_LINK=https://armkeil.blob.core.windows.net/developer/Files
ARG RISCV_TOOLCHAIN_LINK=https://github.com/bao-project/bao-riscv-toolchain/releases/download/gc891d8dc23e/riscv64-unknown-elf-13.2.0-ubuntu-22.04.tar.gz
ARG ASMFMT_LINK=https://github.com/klauspost/asmfmt/releases/download/v1.3.2/asmfmt-Linux_x86_64_1.3.2.tar.gz
ARG CLANG_VERSION=18
ARG CLANG_TOOLS_VERSION=18
# use this repo temporarily while the patches for misra fps are not in a new official version
ARG CPPCHECK_REPO=https://github.com/danmar/cppcheck.git
ARG CPPCHECK_VERSION=2.9
Expand Down Expand Up @@ -65,21 +66,36 @@ RUN npm install -g cspell@latest
# Install static analyzers
# clang-format and clang-tidy
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-$CLANG_VERSION main" && \
add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-$CLANG_TOOLS_VERSION main" && \
apt-get update && apt-get install -y \
clang-format-$CLANG_VERSION \
clang-tidy-$CLANG_VERSION
clang-format-$CLANG_TOOLS_VERSION \
clang-tidy-$CLANG_TOOLS_VERSION
# cppcheck
RUN mkdir /opt/cppcheck && git clone $CPPCHECK_REPO --depth 1 --branch $CPPCHECK_VERSION /opt/cppcheck && \
make -C /opt/cppcheck FILESDIR=/usr/share/cppcheck && make -C /opt/cppcheck install FILESDIR=/usr/share/cppcheck
# asmfmt
RUN mkdir /opt/asmfmt && curl -L $ASMFMT_LINK | tar xz -C /opt/asmfmt

# Install toolchains
# Install GNU toolchains
RUN mkdir /opt/aarch64-toolchain && curl $AARCH64_TOOLCHAIN_LINK | tar xJ -C /opt/aarch64-toolchain --strip-components=1 && \
mkdir /opt/aarch32-toolchain && curl $AARCH32_TOOLCHAIN_LINK | tar xJ -C /opt/aarch32-toolchain --strip-components=1 && \
mkdir /opt/riscv-toolchain && curl -L $RISCV_TOOLCHAIN_LINK | tar xz -C /opt/riscv-toolchain --strip-components=1

# Install LLVM toolchain
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-$CLANG_VERSION main" && \
apt-get update && apt-get install -y clang-$CLANG_VERSION lld-$CLANG_VERSION && \
export CLANG_PATH=$(dirname $(which clang-$CLANG_VERSION)) && \
ln -s $CLANG_PATH/clang-$CLANG_VERSION $CLANG_PATH/clang && \
ln -s $CLANG_PATH/clang-cpp-$CLANG_VERSION $CLANG_PATH/clang-cpp && \
ln -s $CLANG_PATH/llvm-strip-$CLANG_VERSION $CLANG_PATH/llvm-strip && \
ln -s $CLANG_PATH/llvm-as-$CLANG_VERSION $CLANG_PATH/llvm-as && \
ln -s $CLANG_PATH/llvm-objcopy-$CLANG_VERSION $CLANG_PATH/llvm-objcopy && \
ln -s $CLANG_PATH/llvm-objdump-$CLANG_VERSION $CLANG_PATH/llvm-objdump && \
ln -s $CLANG_PATH/llvm-readelf-$CLANG_VERSION $CLANG_PATH/llvm-readelf && \
ln -s $CLANG_PATH/llvm-size-$CLANG_VERSION $CLANG_PATH/llvm-size && \
ln -s $CLANG_PATH/ld.lld-$CLANG_VERSION $CLANG_PATH/ld.lld

# Add generic non-root user
RUN addgroup bao && adduser -disabled-password --ingroup bao bao

Expand Down