Skip to content

Commit

Permalink
update LLVM version to 18
Browse files Browse the repository at this point in the history
choose dynamic link when building on Arch Linux

https://gitlab.archlinux.org/archlinux/packaging/packages/llvm/-/blob/main/PKGBUILD?ref_type=heads#L89

Update Dockerfile_ubuntu
  • Loading branch information
x14ngch3n authored and banach-space committed Jul 25, 2024
1 parent f9ee5e3 commit e9a9cfc
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile_archlinux --tag llvm-tutor:llvm-15
run: docker build . --file Dockerfile_archlinux --tag llvm-tutor:llvm-18
2 changes: 1 addition & 1 deletion .github/workflows/docker-fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile_fedora --tag llvm-tutor:llvm-17
run: docker build . --file Dockerfile_fedora --tag llvm-tutor:llvm-18
2 changes: 1 addition & 1 deletion .github/workflows/docker-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile_ubuntu --tag llvm-tutor:llvm-17
run: docker build . --file Dockerfile_ubuntu --tag llvm-tutor:llvm-18
2 changes: 1 addition & 1 deletion .github/workflows/docker-ubunut-apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile_ubuntu_apt --tag llvm-tutor:llvm-17
run: docker build . --file Dockerfile_ubuntu_apt --tag llvm-tutor:llvm-18
5 changes: 3 additions & 2 deletions Dockerfile_archlinux
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# USAGE:
# ```bash
# wget https://raw.githubusercontent.com/banach-space/llvm-tutor/main/Dockerfile_archlinux
# docker build -t=llvm-tutor:llvm-14 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-14 /bin/bash
# docker build -t=llvm-tutor:llvm-18 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-18 /bin/bash
# ```
# =============================================================================

Expand All @@ -19,6 +19,7 @@ ENV VENV_DIR /venv
# 1. INSTALL DEPENDENCIES
RUN pacman -Syu --noconfirm \
git \
zstd \
cmake \
ninja \
gcc \
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile_fedora
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# USAGE:
# ```bash
# wget https://raw.githubusercontent.com/banach-space/llvm-tutor/main/Dockerfile_fedora
# docker build -t=llvm-tutor:llvm-15 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-15 /bin/bash
# docker build -t=llvm-tutor:llvm-18 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-18 /bin/bash
# ```
# =============================================================================

FROM fedora:38
FROM fedora:40

ENV LLVM_DIR /usr/
ENV TUTOR_DIR /llvm-tutor
Expand All @@ -25,6 +25,7 @@ RUN dnf -y install \
llvm-devel \
clang \
zlib-devel \
libzstd-devel \
python3-pip

# 2. INSTALL LIT
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile_ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
# USAGE:
# ```bash
# wget https://raw.githubusercontent.com/banach-space/llvm-tutor/main/Dockerfile_ubuntu
# docker build -t=llvm-tutor:llvm-16 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-16 /bin/bash
# docker build -t=llvm-tutor:llvm-18 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-18 /bin/bash
# ```
# =============================================================================

FROM debian:buster
FROM ubuntu:22.04

# 1. INSTALL DEPENDENCIES
RUN apt-get update && apt-get install -y \
git \
cmake \
libzstd-dev \
ninja-build \
build-essential \
python3-minimal python3-pip\
Expand All @@ -30,7 +31,7 @@ RUN pip3 install lit
# reason, we need to add `-DLLVM_INSTALL_UTILS=ON` CMake flag when building
# LLVM.
ENV LLVM_DIR /opt/llvm
RUN git clone --branch release/17.x --depth 1 https://github.com/llvm/llvm-project \
RUN git clone --branch release/18.x --depth 1 https://github.com/llvm/llvm-project \
&& mkdir -p $LLVM_DIR \
&& mkdir -p llvm-project/build \
&& cd llvm-project/build \
Expand Down
15 changes: 8 additions & 7 deletions Dockerfile_ubuntu_apt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# USAGE:
# ```bash
# wget https://raw.githubusercontent.com/banach-space/llvm-tutor/main/Dockerfile_ubuntu_apt
# docker build -t=llvm-tutor:llvm-17 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-17 /bin/bash
# docker build -t=llvm-tutor:llvm-18 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-18 /bin/bash
# ```
# =============================================================================

FROM ubuntu:22.04

ENV LLVM_DIR /usr/lib/llvm-17/
ENV LLVM_DIR /usr/lib/llvm-18/
ENV TUTOR_DIR /llvm-tutor

# 1. INSTALL DEPENDENCIES
Expand All @@ -30,13 +30,14 @@ RUN apt-get update && apt-get install -y \
build-essential \
python3-minimal python3-pip\
wget \
libzstd-dev \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
RUN apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
RUN apt-get update
RUN apt-get install -y llvm-17 llvm-17-dev llvm-17-tools clang-17
RUN apt-get install -y llvm-18 llvm-18-dev llvm-18-tools clang-18
RUN apt-get install -y python3-setuptools

# 2. INSTALL LIT
Expand All @@ -50,8 +51,8 @@ RUN mkdir -p $TUTOR_DIR/hello-world-build \
&& cd $TUTOR_DIR/hello-world-build \
&& cmake -G Ninja -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../HelloWorld \
&& ninja
RUN cd $TUTOR_DIR/hello-world-build && /usr/bin/clang-17 -S -O1 -emit-llvm ../inputs/input_for_hello.c -o input_for_hello.ll
RUN cd $TUTOR_DIR/hello-world-build && /usr/bin/opt-17 -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output input_for_hello.ll 2>&1 | grep "(llvm-tutor) Hello from: foo"
RUN cd $TUTOR_DIR/hello-world-build && /usr/bin/clang-18 -S -O1 -emit-llvm ../inputs/input_for_hello.c -o input_for_hello.ll
RUN cd $TUTOR_DIR/hello-world-build && /usr/bin/opt-18 -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output input_for_hello.ll 2>&1 | grep "(llvm-tutor) Hello from: foo"

# 5. BUILD AND RUN LLVM-TUTOR
RUN mkdir -p $TUTOR_DIR/build \
Expand Down
11 changes: 8 additions & 3 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ target_include_directories(
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../include")

target_link_libraries(static
LLVMCore LLVMPasses LLVMIRReader LLVMSupport
)
if(UNIX AND EXISTS "/etc/arch-release")
message("LLVM is installed as shared library on Arch Linux")
target_link_libraries(static LLVM)
else()
target_link_libraries(static
LLVMCore LLVMPasses LLVMIRReader LLVMSupport
)
endif()

0 comments on commit e9a9cfc

Please sign in to comment.