Skip to content

Commit

Permalink
add clad (a clang plugin) (#80)
Browse files Browse the repository at this point in the history
* add clad (a cland plugin)

Adds the ability to build llvm external projects along with clang/llvm

* updates according to code review
  • Loading branch information
Vipul-Cariappa authored Dec 13, 2024
1 parent 0489d63 commit d792c84
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ NINJA_TARGET=install
NINJA_TARGET_RUNTIMES=install-runtimes
TAG=
declare -a PATCHES_TO_APPLY
EXTERNAL_PROJECT_DIR=${ROOT}/external
declare -a EXTERNAL_PROJECT_URLS
declare -a LLVM_EXTERNAL_PROJECTS_LIST

case $VERSION in
ce-trunk)
Expand Down Expand Up @@ -334,6 +337,12 @@ mlir-*)
if [[ $MAJOR -ge 18 ]]; then
CMAKE_EXTRA_ARGS+=("-DLIBCXX_INSTALL_MODULES=ON")
fi

if [[ $MAJOR -eq 18 ]]; then
EXTERNAL_PROJECT_URLS+=("https://github.com/vgvassilev/clad.git")
LLVM_EXTERNAL_PROJECTS_LIST+=("clad")
CMAKE_EXTRA_ARGS+=("-DLLVM_EXTERNAL_CLAD_SOURCE_DIR=${EXTERNAL_PROJECT_DIR}/clad")
fi
;;
esac
;;
Expand Down Expand Up @@ -383,6 +392,16 @@ for PATCH_TO_APPLY in "${PATCHES_TO_APPLY[@]}"; do
git -C "${ROOT}/llvm-project" apply "${PATCH_TO_APPLY}" -v
done

# Setup external projects
mkdir -p "${EXTERNAL_PROJECT_DIR}"
for LLVM_EXTERNAL_PROJECT in "${!EXTERNAL_PROJECT_URLS[@]}"; do
git clone --depth 1 "${EXTERNAL_PROJECT_URLS[LLVM_EXTERNAL_PROJECT]}" "${EXTERNAL_PROJECT_DIR}/${LLVM_EXTERNAL_PROJECTS_LIST[LLVM_EXTERNAL_PROJECT]}"
done
LLVM_EXTERNAL_PROJECTS=
for LLVM_EXTERNAL_PROJECT in "${LLVM_EXTERNAL_PROJECTS_LIST}"; do
LLVM_EXTERNAL_PROJECTS+="${LLVM_EXTERNAL_PROJECT};";
done

# For older LLVM versions, merge runtime and projects
# August 2021 is when bootstrapping become necessary, bootstrapping might have been supported previously a few years prior
COMMIT_DATE=$(cd "${ROOT}/llvm-project/llvm" && git show -s --format=%ct HEAD)
Expand Down Expand Up @@ -413,6 +432,7 @@ cmake \
-G "Ninja" "${ROOT}/llvm-project/llvm" \
-DLLVM_ENABLE_PROJECTS="${LLVM_ENABLE_PROJECTS}" \
-DLLVM_ENABLE_RUNTIMES="${LLVM_ENABLE_RUNTIMES}" \
-DLLVM_EXTERNAL_PROJECTS="${LLVM_EXTERNAL_PROJECTS}" \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:PATH="${STAGING_DIR}" \
-DCMAKE_C_COMPILER:PATH="/opt/compiler-explorer/gcc-${GCC_VERSION}/bin/gcc" \
Expand Down

0 comments on commit d792c84

Please sign in to comment.