Skip to content

Commit

Permalink
Let pluto use system clang for compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
kumasento committed Dec 16, 2020
1 parent 90eb985 commit f78f252
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
33 changes: 18 additions & 15 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
-DLLVM_ENABLE_OCAMLDOC=OFF \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang-9 \
-DCMAKE_CXX_COMPILER=clang++-9 \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON
cmake --build . --target install -- -j$(nproc)
Expand All @@ -74,14 +74,19 @@ jobs:
needs: build-llvm
runs-on: ubuntu-20.04
steps:
- name: Configure Environment
run: echo "${GITHUB_WORKSPACE}/llvm/install/bin" >> $GITHUB_PATH

# - name: Configure Environment
# run: echo "${GITHUB_WORKSPACE}/llvm/install/bin" >> $GITHUB_PATH
- name: Get dependences
run: |
sudo apt-get update -y
sudo apt-get install -y libgmp-dev libclang-dev
sudo apt-get install -y build-essential libtool autoconf pkg-config flex bison libgmp-dev clang-9 libclang-9-dev texinfo
- name: Update the LLVM/Clang version to 9
run: |
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-9 100
sudo update-alternatives --install /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-9 100
# Clone the Polymer repo and its submodules. Do shallow clone to save clone
# time.
- name: Get Polymer
Expand Down Expand Up @@ -125,8 +130,8 @@ jobs:
-DLLVM_ENABLE_OCAMLDOC=OFF \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang-9 \
-DCMAKE_CXX_COMPILER=clang++-9 \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON
cmake --build . --target install -- -j$(nproc)
Expand All @@ -150,9 +155,8 @@ jobs:
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_DIR=${PWD}/../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=${PWD}/../llvm/install/lib/cmake/llvm/ \
-DCMAKE_C_COMPILER=/bin/clang \
-DCMAKE_CXX_COMPILER=/bin/clang++ \
-DLLVM_EXTERNAL_LIT=${PWD}/../llvm/build/bin/llvm-lit \
-DCMAKE_C_COMPILER=clang-9 \
-DCMAKE_CXX_COMPILER=clang++-9 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build . --target check-polymer
Expand All @@ -164,8 +168,7 @@ jobs:
-DCMAKE_BUILD_TYPE=RELEASE \
-DMLIR_DIR=${PWD}/../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=${PWD}/../llvm/install/lib/cmake/llvm/ \
-DCMAKE_C_COMPILER=/bin/clang \
-DCMAKE_CXX_COMPILER=/bin/clang++ \
-DLLVM_EXTERNAL_LIT=${PWD}/../llvm/build/bin/llvm-lit \
-DCMAKE_C_COMPILER=clang-9 \
-DCMAKE_CXX_COMPILER=clang++-9 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build . --target check-polymer
16 changes: 15 additions & 1 deletion cmake/PLUTO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@ include(ExternalProject)
set(PLUTO_INCLUDE_DIR "${CMAKE_BINARY_DIR}/pluto/include")
set(PLUTO_LIB_DIR "${CMAKE_BINARY_DIR}/pluto/lib")

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
execute_process(
COMMAND bash -c "which ${CMAKE_CXX_COMPILER}"
OUTPUT_VARIABLE CLANG_ABSPATH
)
get_filename_component(CLANG_BINDIR ${CLANG_ABSPATH} DIRECTORY)
get_filename_component(CLANG_PREFIX ${CLANG_BINDIR} DIRECTORY)
set(CLANG_PREFIX_CONFIG "--with-clang-prefix=${CLANG_PREFIX}")
else()
set(CLANG_PREFIX_CONFIG "")
endif()

message(STATUS ${CLANG_PREFIX_CONFIG})

ExternalProject_Add(
pluto
SOURCE_DIR "${CMAKE_SOURCE_DIR}/pluto"
CONFIGURE_COMMAND "${CMAKE_SOURCE_DIR}/pluto/autogen.sh" && "${CMAKE_SOURCE_DIR}/pluto/configure" --prefix=${CMAKE_BINARY_DIR}/pluto
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${CMAKE_SOURCE_DIR}/pluto/autogen.sh && ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${CMAKE_SOURCE_DIR}/pluto/configure --prefix=${CMAKE_BINARY_DIR}/pluto ${CLANG_PREFIX_CONFIG}
PREFIX ${CMAKE_BINARY_DIR}/pluto
BUILD_COMMAND make
INSTALL_COMMAND make install
Expand Down

0 comments on commit f78f252

Please sign in to comment.