Skip to content

Commit

Permalink
Update LLVM to 18.1.3. (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas authored Apr 16, 2024
1 parent b11a183 commit 356e667
Show file tree
Hide file tree
Showing 23 changed files with 168 additions and 176 deletions.
3 changes: 2 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
examples
tests/bazel_integration
tests/bazel_integration
.sl
26 changes: 15 additions & 11 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ build --copt -Wno-deprecated-non-prototype
build --cxxopt -std=c++17
build --host_cxxopt -std=c++17

build:asan -c dbg
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --copt -O1
build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address
common --features=layering_check

common:asan -c dbg
common:asan --strip=never
common:asan --copt -fsanitize=address
common:asan --copt -DADDRESS_SANITIZER
common:asan --copt -O1
common:asan --copt -g
common:asan --copt -fno-omit-frame-pointer
common:asan --linkopt -fsanitize=address


build --experimental_remote_merkle_tree_cache
Expand All @@ -33,6 +35,8 @@ build --keep_going
test --keep_going
test --test_verbose_timeout_warnings

build:ci --google_default_credentials
build:ci --remote_upload_local_results
build:ci --spawn_strategy standalone
common:ci --google_default_credentials
common:ci --remote_upload_local_results
common:ci --spawn_strategy sandboxed

--@llvm_zlib//:llvm_enable_zlib=true
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.1.1
6.5.0
122 changes: 67 additions & 55 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,63 +1,75 @@
FROM ubuntu:latest
FROM debian:bookworm
MAINTAINER Thomas Bailleux <[email protected]>

SHELL ["/bin/bash", "-c"]

RUN apt update
RUN apt install -y clang-15
RUN apt install -y lld-15
RUN apt install -y git
RUN apt install -y rsync
RUN apt install -y graphviz
RUN apt install -y cmake
RUN apt install -y ninja-build
RUN apt install -y curl
RUN apt install -y clang-format-15
RUN apt install -y python3-pip
RUN apt-get update && apt-get install --yes --no-install-recommends \
bash \
ca-certificates \
cmake \
curl \
gcc \
g++ \
git \
gnupg \
graphviz \
gzip \
lsb-release \
make \
ninja-build \
openjdk-17-jdk-headless \
patch \
python3-pip \
rsync \
software-properties-common \
ssh \
sudo \
tar \
wget \
zlib1g \
zlib1g-dev \
zstd && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && \
echo 'deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-18 main' | sudo tee /etc/apt/sources.list && \
apt-get update && \
apt-get install --yes --no-install-recommends \
llvm-18 \
llvm-18-dev \
clang-18 \
clang-format-18 \
libclang-rt-18-dev \
lld-18 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV CC=clang-15
ENV CXX=clang++-15
ENV LD=lld-15
ENV LLVM_CONFIG=/usr/lib/llvm-15/bin/llvm-config
ENV CLANG_FORMAT=clang-format-15
ENV GOBIN='/usr/local/go/bin'
ENV PATH="${PATH}:${GOBIN}"
RUN wget -qLO- https://go.dev/dl/go1.22.0.linux-amd64.tar.gz | tar -C /usr/local -xz && \
wget -L https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 -O /usr/bin/bazelisk && \
wget -L https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildifier-linux-amd64 -O /usr/bin/buildifier && \
chmod +x /usr/bin/bazelisk /usr/bin/buildifier && \
pip3 install cmake-format --break-system-packages

RUN curl -Lo bazelisk-linux-amd64 'https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64'
RUN sha384sum -c <<< "55d9ef786360f97902c886eff515c5dd2e05985c52d43809645f963b9a7e19ccf87cef3d07d2cfda8c2cf16aed119616 bazelisk-linux-amd64"
RUN mv bazelisk-linux-amd64 /usr/bin/bazel
RUN chmod +x /usr/bin/bazel
ARG USER="pawn"
RUN useradd -ms /bin/bash "${USER}" && \
adduser "${USER}" sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

RUN curl -Lo /tmp/doxygen.tar.gz 'https://github.com/doxygen/doxygen/releases/download/Release_1_9_6/doxygen-1.9.6.linux.bin.tar.gz'
RUN sha384sum -c <<< "f06f1668637572695d11747a6527797beb4d184f11a5df03ccf87a4a094c2df0e6f38a3a57ea9ec2c3de625e87fc1d8e /tmp/doxygen.tar.gz"
WORKDIR /tmp
RUN tar xf doxygen.tar.gz doxygen-1.9.6/bin/doxygen
RUN mv doxygen-1.9.6/bin/doxygen /usr/bin/doxygen
RUN chmod +x /usr/bin/doxygen
RUN rm -rf doxygen-1.9.6 doxygen.tar.gz
USER "${USER}"
WORKDIR "/home/${USER}"
RUN git config --global --add safe.directory '*'
RUN USE_BAZEL_VERSION=6.5.0 bazelisk version

# Cargo
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
ENV PATH="${PATH}:/home/${USER}/.cargo/bin"
ENV HOME="/home/${USER}"

RUN curl -Lo /tmp/go.tar.gz 'https://go.dev/dl/go1.20.3.linux-amd64.tar.gz'
RUN sha384sum -c <<< "66fccde4a792c96fed6a85c789d0bf0eb954183b9cc70eb10b1c4c485bccfc5cfbebb82966d53d475150ae6fb8670c80 /tmp/go.tar.gz"
WORKDIR /tmp/
RUN tar -C /usr/local -xf /tmp/go.tar.gz
ENV PATH=$PATH:/usr/local/go/bin
RUN go version
ENV GOPATH=/usr/local/go

RUN go install github.com/bazelbuild/buildtools/buildifier@latest
RUN buildifier --version

RUN pip3 install cmake-format

RUN useradd -ms /bin/bash pawn
USER pawn
WORKDIR /home/pawn
ENV GOOGLE_APPLICATION_CREDENTIALS=/home/pawn/gcloud-service-key.json

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH=$PATH:/home/pawn/.cargo/bin
RUN source /home/pawn/.cargo/env
RUN rustup update

RUN go version
RUN buildifier --version
RUN cmake-format --version
RUN rustc --version
ENV CC=clang-18
ENV CXX=clang++-18
ENV LD=lld-18
ENV LDFLAGS="-no-canonical-prefixes -L/usr/lib/llvm-18/lib"
ENV LLVM_CONFIG=/usr/lib/llvm-18/bin/llvm-config
ENV LLVM_DIR=/usr/lib/llvm-18/lib/cmake/
ENV CLANG_FORMAT=clang-format-18
ENV GOOGLE_APPLICATION_CREDENTIALS="$HOME/gcloud-service-key.json"
28 changes: 7 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ jobs:
command: |
echo "${BAZEL_CACHE_GCS_SA_KEY}" > "${GOOGLE_APPLICATION_CREDENTIALS}"
echo "build --remote_cache=${BAZEL_REMOTE_CACHE_URL}" > $HOME/.bazelrc
bazel test \
--action_env=CC="${CC}" \
--action_env=CXX="${CXX}" \
--action_env=LLVM_CONFIG="${LLVM_CONFIG}" \
--repo_env=LLVM_CONFIG="${LLVM_CONFIG}" \
bazelisk test \
--config=ci \
...
- run:
Expand All @@ -34,14 +30,8 @@ jobs:
echo "${BAZEL_CACHE_GCS_SA_KEY}" > "${GOOGLE_APPLICATION_CREDENTIALS}"
echo "build --remote_cache=${BAZEL_REMOTE_CACHE_URL}" > $HOME/.bazelrc
bazel build \
--google_default_credentials \
--remote_upload_local_results \
--spawn_strategy standalone \
--action_env=CC="${CC}" \
--action_env=CXX="${CXX}" \
--action_env=LLVM_CONFIG="${LLVM_CONFIG}" \
--repo_env=LLVM_CONFIG="${LLVM_CONFIG}" \
echo '6.5.0' > .bazelversion
bazelisk build \
--config=ci \
...
Expand All @@ -61,7 +51,7 @@ jobs:
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR=/usr/lib/llvm-15/lib/cmake \
-DLLVM_DIR=/usr/lib/llvm-18/lib/cmake \
-GNinja
cmake --build build/ "-j$(nproc)"
Expand All @@ -79,12 +69,8 @@ jobs:
command: |
echo "${BAZEL_CACHE_GCS_SA_KEY}" > "${GOOGLE_APPLICATION_CREDENTIALS}"
echo "build --remote_cache=${BAZEL_REMOTE_CACHE_URL}" > $HOME/.bazelrc
bazel test \
--config asan \
--action_env=CC="${CC}" \
--action_env=CXX="${CXX}" \
--action_env=LLVM_CONFIG="${LLVM_CONFIG}" \
--repo_env=LLVM_CONFIG="${LLVM_CONFIG}" \
bazelisk test \
--config=asan \
--config=ci \
...
Expand Down Expand Up @@ -157,7 +143,7 @@ jobs:
- run:
name: "Build Bartleby Rust library"
command: |
LLVM_DIR=/usr/lib/llvm-15/lib/cmake cargo build
LLVM_DIR=/usr/lib/llvm-18/lib/cmake cargo build
workflows:
check-format:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13.4)
project(Bartleby)

set(BARTLEBY_LLVM_VERSION "15.0" CACHE STRING "LLVM version to use")
set(BARTLEBY_LLVM_VERSION "18.1.2" CACHE STRING "LLVM version to use")

find_package(LLVM "${BARTLEBY_LLVM_VERSION}" REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion bartleby/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@llvm-project.llvm//utils/bazel:configure.bzl", "llvm_configure")
load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
load("//vendor/github.com/llvm/llvm-project:deps.bzl", "llvm_deps")
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

Expand Down
3 changes: 2 additions & 1 deletion bartleby/include/Bartleby-c/Bartleby.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ SAQ_BARTLEBY_API int saq_bartleby_add_binary(struct BartlebyHandle *bh,
/** \brief Builds the final archive and writes its content to a buffer.
*
* \warning This function consumes the input Bartleby handle. Thus, users
* must not call `saq_bartleby_free` after calling `saq_bartleby_build_archive`.
* must not call `saq_bartleby_free` after calling
* `saq_bartleby_build_archive`.
*
* \param bh Bartleby handle.
* \param[out] s Destination buffer.
Expand Down
1 change: 1 addition & 0 deletions bartleby/include/Bartleby/Bartleby.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "Bartleby/Symbol.h"

#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Object/Binary.h"
Expand Down
8 changes: 4 additions & 4 deletions bartleby/lib/Bartleby/ArchiveWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class Bartleby::ArchiveWriter : public llvm::objcopy::MultiFormatConfig {

for (auto &[Fmt, Ar] : Archives) {
if (auto BufferOrErr = llvm::writeArchiveToBuffer(
Ar.Members,
/* WriteSymtab= */ true, Ar.Members[0].detectKindFromObject(),
Ar.Members, llvm::SymtabWritingMode::NormalSymtab,
Ar.Members[0].detectKindFromObject(),
/* Deterministic=*/true, /*Thin=*/false)) {
Ar.OutBuffer = std::move(*BufferOrErr);
} else {
Expand Down Expand Up @@ -204,7 +204,7 @@ class Bartleby::ArchiveWriter : public llvm::objcopy::MultiFormatConfig {
}

return llvm::writeArchive(OutFilepath, ArMembers,
/* WriteSymtab= */ true,
llvm::SymtabWritingMode::NormalSymtab,
ArMembers[0].detectKindFromObject(),
/* Deterministic= */ true,
/* Thin= */ false);
Expand All @@ -224,7 +224,7 @@ class Bartleby::ArchiveWriter : public llvm::objcopy::MultiFormatConfig {
}

return llvm::writeArchiveToBuffer(ArMembers,
/* WriteSymtab= */ true,
llvm::SymtabWritingMode::NormalSymtab,
ArMembers[0].detectKindFromObject(),
/* Deterministic= */ true,
/* Thin= */ false);
Expand Down
6 changes: 6 additions & 0 deletions bartleby/lib/Bartleby/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cc_library(
"//bartleby/include/Bartleby:bartleby",
"@llvm-project//llvm:ObjCopy",
"@llvm-project//llvm:Object",
"@llvm-project//llvm:Support",
],
)

Expand All @@ -32,6 +33,7 @@ cc_library(
":export",
":symbol",
"//bartleby/include/Bartleby:bartleby",
"//bartleby/include/Bartleby:symbol",
"@llvm-project//llvm:ObjCopy",
"@llvm-project//llvm:Object",
"@llvm-project//llvm:Support",
Expand All @@ -49,6 +51,7 @@ cc_library(
deps = [
"//bartleby/include/Bartleby:bartleby",
"@llvm-project//llvm:Support",
"@llvm-project//llvm:TargetParser",
],
)

Expand All @@ -74,6 +77,9 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":bartleby",
"//bartleby/include/Bartleby:bartleby",
"//bartleby/include/Bartleby-c:bartleby",
"@llvm-project//llvm:Object",
"@llvm-project//llvm:Support",
],
)
Loading

0 comments on commit 356e667

Please sign in to comment.