Skip to content

Commit

Permalink
Update docker build to use LLVM 16 (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Mar 25, 2023
1 parent 314eeac commit 15a18dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 3 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
FROM ubuntu:22.04 as dist

ADD dist/wasi-sdk-*.*-linux.tar.gz /
ADD dist/libclang_rt.builtins-wasm32-wasi-*.*.tar.gz /wasi-sysroot-clang_rt

# Move versioned folder to unversioned to using bash glob to allow
# this file to be independent of major version number.
RUN mv /wasi-sdk-* /wasi-sdk

FROM ubuntu:22.04

ENV LLVM_VERSION 15
ENV LLVM_VERSION 16

# Install build toolchain including clang, ld, make, autotools, ninja, and cmake
RUN apt-get update && \
Expand All @@ -33,11 +34,7 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

COPY --from=dist /wasi-sdk/share/wasi-sysroot/ /wasi-sysroot/
# The path to the rt directory contains the LLVM patch version which is not reflected in the LLVM apt repository
# or package. To make adding the RT robust to changing patch versions without needing to duplicate the folder
# content, we symlink after extracting using a bash glob to resolve the patch version
ADD dist/libclang_rt.builtins-wasm32-wasi-*.*.tar.gz /wasi-sysroot-clang_rt
RUN ln -s /wasi-sysroot-clang_rt/lib/wasi/ $(echo /usr/lib/llvm-${LLVM_VERSION}/lib/clang/${LLVM_VERSION}.*)/lib/wasi
COPY --from=dist /wasi-sysroot-clang_rt/lib/wasi /usr/lib/llvm-${LLVM_VERSION}/lib/clang/${LLVM_VERSION}/lib/wasi

ADD docker/wasi-sdk.cmake /usr/share/cmake/wasi-sdk.cmake
ENV CMAKE_TOOLCHAIN_FILE /usr/share/cmake/wasi-sdk.cmake
Expand Down
9 changes: 5 additions & 4 deletions docker/wasi-sdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR wasm32)
set(triple wasm32-wasi)

set(CMAKE_C_COMPILER /usr/bin/clang-15)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-15)
set(CMAKE_AR /usr/bin/llvm-ar-15)
set(CMAKE_RANLIB /usr/bin/llvm-ranlib-15)
set(CMAKE_C_COMPILER /usr/bin/clang-$ENV{LLVM_VERSION})
set(CMAKE_CXX_COMPILER /usr/bin/clang++-$ENV{LLVM_VERSION})
set(CMAKE_ASM_COMPILER /usr/bin/clang-$ENV{LLVM_VERSION})
set(CMAKE_AR /usr/bin/llvm-ar-$ENV{LLVM_VERSION})
set(CMAKE_RANLIB /usr/bin/llvm-ranlib-$ENV{LLVM_VERSION})
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
SET(CMAKE_SYSROOT /wasi-sysroot)
Expand Down

0 comments on commit 15a18dc

Please sign in to comment.