-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes build issues which occur when building on Apple Silicon #77
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,9 @@ RUN \ | |
###libomp-dev \ | ||
# Other "our" apt installs (development and testing) | ||
build-essential \ | ||
#FIXME: Update to clang-17 once available in apt repository (expected with next LTS version of Ubuntu April 2024) | ||
# to be use a consistent version of clang throughout | ||
clang-15 \ | ||
git \ | ||
nano-tiny \ | ||
less \ | ||
|
@@ -54,7 +57,9 @@ RUN \ | |
#cuda \ | ||
$([ -n "$_CUDA_" ] && echo nvidia-cuda-toolkit) \ | ||
&& \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* && \ | ||
apt-get clean && \ | ||
apt-get autoremove && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ | ||
locale-gen | ||
|
||
|
@@ -130,13 +135,16 @@ RUN \ | |
# Other "our" conda installs | ||
cmake \ | ||
#"clangdev=$LLVM_REQUIRED_VERSION" \ | ||
'xeus>=2.0,<3.0' \ | ||
'xeus>=2.0' \ | ||
xeus-zmq \ | ||
'nlohmann_json>=3.9.1,<3.10' \ | ||
'cppzmq>=4.6.0,<5' \ | ||
'xtl>=0.7,<0.8' \ | ||
'openssl<2' \ | ||
'openssl<4' \ | ||
ipykernel \ | ||
pugixml \ | ||
zlib \ | ||
libxml2 \ | ||
'cxxopts>=2.2.1,<2.3' \ | ||
libuuid \ | ||
# Test dependencies | ||
|
@@ -159,6 +167,9 @@ RUN \ | |
set -x && \ | ||
source /home/jovyan/.conda.init && \ | ||
conda activate .venv && \ | ||
export ARCHITECHURE=$(uname -m) && \ | ||
if [ "$ARCHITECHURE" == "x86_64" ] ; \ | ||
then \ | ||
# | ||
artifact_name="clang-dev" && \ | ||
# | ||
|
@@ -167,9 +178,10 @@ RUN \ | |
echo $PWD && git_remote_origin_url=$(git config --get remote.origin.url) && \ | ||
echo "Debug: Remote origin url: $git_remote_origin_url" && \ | ||
arr=(${git_remote_origin_url//\// }) && \ | ||
gh_repo_owner=${arr[2]} && \ | ||
arr2=(${arr[0]//:/ }) && \ | ||
gh_repo_owner=${arr2[1]} && \ | ||
gh_f_repo_owner="compiler-research" && \ | ||
arr=(${arr[3]//./ }) && \ | ||
arr=(${arr[1]//./ }) && \ | ||
gh_repo_name=${arr[0]} && \ | ||
gh_repo="${gh_repo_owner}/${gh_repo_name}" && \ | ||
gh_f_repo_name=${gh_repo_name} && \ | ||
|
@@ -193,7 +205,6 @@ RUN \ | |
pushd /home/runner/work/xeus-clang-repl/xeus-clang-repl && \ | ||
# repo | ||
echo "Debug: Repo owner/name: ${gh_repo_owner} / ${gh_repo_name}" && \ | ||
|
||
#RUN \ | ||
# set -x && \ | ||
source /home/jovyan/.conda.init && \ | ||
|
@@ -231,26 +242,48 @@ RUN \ | |
popd && \ | ||
# | ||
echo "Debug clang path: $PATH_TO_CLANG_DEV" && \ | ||
export PATH_TO_LLVM_BUILD=$PATH_TO_CLANG_DEV/inst && \ | ||
export PATH_TO_LLVM_BUILD=$PATH_TO_CLANG_DEV/inst/ && \ | ||
export PATH_TO_LLVM_CONFIG=$PATH_TO_CLANG_DEV/inst/lib/cmake/llvm/ && \ | ||
export PATH_TO_CLANG_CONFIG=$PATH_TO_CLANG_DEV/inst/lib/cmake/clang/ ; \ | ||
fi && \ | ||
export VENV=${CONDA_DIR}/envs/.venv && \ | ||
export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH_TO_LLVM_BUILD/bin:$PATH && \ | ||
export LD_LIBRARY_PATH=$PATH_TO_LLVM_BUILD/lib:$LD_LIBRARY_PATH && \ | ||
echo "export VENV=$VENV" >> ~/.profile && \ | ||
echo "export PATH=$PATH" >> ~/.profile && \ | ||
echo "export EDITOR=emacs" >> ~/.profile && \ | ||
# | ||
# Build CppInterOp | ||
# | ||
# Build LLVM (if on arm) & CppInterOp | ||
# | ||
sys_incs=$(LC_ALL=C c++ -xc++ -E -v /dev/null 2>&1 | LC_ALL=C sed -ne '/starts here/,/End of/p' | LC_ALL=C sed '/^ /!d' | cut -c2- | tr '\n' ':') && \ | ||
export CPLUS_INCLUDE_PATH="${PATH_TO_LLVM_BUILD}/include/llvm:${PATH_TO_LLVM_BUILD}/include/clange:$CPLUS_INCLUDE_PATH:${sys_incs%:}" && \ | ||
git clone https://github.com/compiler-research/CppInterOp.git && \ | ||
if [ "$ARCHITECHURE" == "aarch64" ] ; \ | ||
then \ | ||
#FIXME: Update to clang-17 once clang-17 is available in apt repository (expected with next LTS version of Ubuntu | ||
# around April 2024) | ||
export CC=/usr/bin/clang-15 && \ | ||
export CXX=/usr/bin/clang++-15 && \ | ||
Comment on lines
+262
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clang-17? |
||
#FIXME: Currently build with version 16.x on arm due to issue mentioned here https://github.com/compiler-research/xeus-clang-repl/issues/78 | ||
git clone --depth=1 --branch release/16.x https://github.com/llvm/llvm-project.git && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. release/17.x |
||
cd ./llvm-project/ && \ | ||
mkdir build && \ | ||
export LLVM_DIR=$(pwd) && \ | ||
compgen -G "../CppInterOp/patches/llvm/clang16-*.patch" > /dev/null && find ../CppInterOp/patches/llvm/clang16-*.patch -printf "%f\n" && git apply ../CppInterOp/patches/llvm/clang16-*.patch && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clang17-*.patch? |
||
cd build && \ | ||
cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=gold -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DCLANG_ENABLE_ARCMT=OFF -DCLANG_ENABLE_FORMAT=OFF -DCLANG_ENABLE_BOOTSTRAP=OFF ../llvm && \ | ||
cmake --build . --target clang clang-repl --parallel $(nproc --all) && \ | ||
export PATH_TO_LLVM_CONFIG=$LLVM_DIR/build/lib/cmake/llvm/ && \ | ||
export PATH_TO_CLANG_CONFIG=$LLVM_DIR/build/lib/cmake/clang/ && \ | ||
export PATH_TO_LLVM_BUILD=$LLVM_DIR/build && \ | ||
cd ../../ ; \ | ||
fi && \ | ||
export PATH=${VENV}/bin:${CONDA_DIR}/bin:$PATH_TO_LLVM_BUILD/bin:$PATH && \ | ||
export LD_LIBRARY_PATH=$PATH_TO_LLVM_BUILD/lib:$LD_LIBRARY_PATH && \ | ||
echo "export PATH=$PATH" >> ~/.profile && \ | ||
export CB_PYTHON_DIR="$PWD/cppyy-backend/python" && \ | ||
export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend" && \ | ||
cd CppInterOp && \ | ||
mkdir build && \ | ||
cd build && \ | ||
mkdir CppInterOp/build && \ | ||
cd CppInterOp/build && \ | ||
export CPPINTEROP_BUILD_DIR=$PWD && \ | ||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_CLING=OFF -DUSE_REPL=ON -DLLVM_DIR=$PATH_TO_LLVM_BUILD -DLLVM_USE_LINKER=gold -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR .. && \ | ||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_CLING=OFF -DUSE_REPL=ON -DLLVM_DIR=$PATH_TO_LLVM_CONFIG -DClang_DIR=$PATH_TO_CLANG_CONFIG -DLLVM_USE_LINKER=gold -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR .. && \ | ||
cmake --build . --parallel $(nproc --all) && \ | ||
#make install -j$(nproc --all) | ||
export CPLUS_INCLUDE_PATH="$CPPINTEROP_DIR/include:$CPLUS_INCLUDE_PATH" && \ | ||
|
@@ -260,9 +293,10 @@ RUN \ | |
# | ||
# Build and Install cppyy-backend | ||
# | ||
git clone https://github.com/compiler-research/cppyy-backend.git && \ | ||
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git && \ | ||
cd cppyy-backend && \ | ||
mkdir -p $CPPINTEROP_DIR/lib build && cd build && \ | ||
mkdir -p $CPPINTEROP_DIR/lib build && \ | ||
cd build && \ | ||
# Install CppInterOp | ||
(cd $CPPINTEROP_BUILD_DIR && cmake --build . --target install --parallel $(nproc --all)) && \ | ||
# Build and Install cppyy-backend | ||
|
@@ -274,9 +308,9 @@ RUN \ | |
# Build and Install CPyCppyy | ||
# | ||
# Install CPyCppyy | ||
git clone https://github.com/compiler-research/CPyCppyy.git && \ | ||
cd CPyCppyy && \ | ||
mkdir build && cd build && \ | ||
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git && \ | ||
mkdir CPyCppyy/build && \ | ||
cd CPyCppyy/build && \ | ||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && \ | ||
cmake --build . --parallel $(nproc --all) && \ | ||
export CPYCPPYY_DIR=$PWD && \ | ||
|
@@ -285,7 +319,7 @@ RUN \ | |
# Build and Install cppyy | ||
# | ||
# Install cppyy | ||
git clone https://github.com/compiler-research/cppyy.git && \ | ||
git clone --depth=1 https://github.com/compiler-research/cppyy.git && \ | ||
cd cppyy && \ | ||
python -m pip install --upgrade . --no-deps && \ | ||
cd .. && \ | ||
|
@@ -294,9 +328,9 @@ RUN \ | |
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR:/home/jovyan && \ | ||
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.profile && \ | ||
export CPLUS_INCLUDE_PATH="/home/jovyan/CPyCppyy/include/:$CPLUS_INCLUDE_PATH" && \ | ||
# FIXME: Remove the hardcoded version of python here. | ||
export PYTHON_VERSION=$(python --version | cut -c8- | cut -f1,2 -d'.') && \ | ||
export CPLUS_INCLUDE_PATH="/home/jovyan/clad/include:$CPLUS_INCLUDE_PATH" && \ | ||
export CPLUS_INCLUDE_PATH="${VENV}/include:${VENV}/include/python3.10:$CPLUS_INCLUDE_PATH" && \ | ||
export CPLUS_INCLUDE_PATH="${VENV}/include:${VENV}/include/python${PYTHON_VERSION}:$CPLUS_INCLUDE_PATH" && \ | ||
python -c "import cppyy" && \ | ||
# | ||
# Build and Install xeus-clang-repl | ||
|
@@ -312,13 +346,11 @@ RUN \ | |
# Build and Install Clad | ||
# | ||
git clone --depth=1 https://github.com/vgvassilev/clad.git && \ | ||
cd clad && \ | ||
mkdir build && \ | ||
cd build && \ | ||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. -DClang_DIR=${PATH_TO_LLVM_BUILD}/lib/cmake/clang/ -DLLVM_DIR=${PATH_TO_LLVM_BUILD}/lib/cmake/llvm/ -DCMAKE_INSTALL_PREFIX=${CONDA_DIR} -DLLVM_EXTERNAL_LIT="$(which lit)" && \ | ||
#make -j$(nproc --all) && \ | ||
make && \ | ||
make install && \ | ||
mkdir clad/build && \ | ||
cd clad/build && \ | ||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. -DClang_DIR=$PATH_TO_CLANG_CONFIG -DLLVM_DIR=$PATH_TO_LLVM_CONFIG -DCMAKE_INSTALL_PREFIX=${CONDA_DIR} -DLLVM_EXTERNAL_LIT="$(which lit)" && \ | ||
make -j$(nproc --all) && \ | ||
make install -j$(nproc --all) && \ | ||
### install clad in all exist kernels | ||
##for i in "$KERNEL_PYTHON_PREFIX"/share/jupyter/kernels/*; do if [[ $i =~ .*/clad-xcpp.* ]]; then jq '.argv += ["-fplugin=$KERNEL_PYTHON_PREFIX/lib/clad.so"] | .display_name += " (with clad)"' "$i"/kernel.json > tmp.$$.json && mv tmp.$$.json "$i"/kernel.json; fi; done && \ | ||
### | ||
|
@@ -339,8 +371,8 @@ RUN \ | |
k="/opt/conda/share/jupyter/kernels/python3/kernel.json" && \ | ||
jq ".argv[0] = \"${VENV}/bin/python\"" $k > $k.$$.tmp && mv $k.$$.tmp $k && \ | ||
# xtensor | ||
git clone https://github.com/xtensor-stack/xtensor.git && \ | ||
cd xtensor && \ | ||
mkdir build && cd build && \ | ||
git clone --depth=1 https://github.com/xtensor-stack/xtensor.git && \ | ||
mkdir xtensor/build && \ | ||
cd xtensor/build && \ | ||
cmake -DCMAKE_INSTALL_PREFIX=$KERNEL_PYTHON_PREFIX .. && \ | ||
make install | ||
make install -j$(nproc --all) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
docker build . -t xeus-clang-repl | ||
|
||
export OS=$(uname -s) | ||
|
||
if [ "$OS" == "Darwin" ] | ||
then | ||
docker run --publish 8888:8888 --name xeus-clang-repl-c -i -t xeus-clang-repl "start-notebook.sh" | ||
else | ||
docker container run --rm -i hadolint/hadolint hadolint - < Dockerfile | ||
|
||
jupyter-repo2docker \ | ||
--no-run \ | ||
--user-name=jovyan \ | ||
--image-name xeus-clang-repl \ | ||
. | ||
|
||
docker run --gpus all --publish 8888:8888 --name xeus-clang-repl-c -i -t xeus-clang-repl "start-notebook.sh" | ||
#docker run --rm --runtime=nvidia --gpus all --publish 8888:8888 --name xeus-clang-repl-c -i -t xeus-clang-repl "start-notebook.sh" | ||
|
||
# --editable \ | ||
# --ref InterOpIntegration \ | ||
# https://github.com/alexander-penev/xeus-clang-repl.git \ | ||
|
||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
#include "nlohmann/json.hpp" | ||
|
||
#include <iostream> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is mentioned in the PR description. When building natively on MacOS it would not build without this include due to the use of std::cerr and others |
||
#include <map> | ||
#include <memory> | ||
#include <regex> | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ci.yaml matrix we use clang-runtime==17. Can you use the newer version (17) of the clang runtime here as well? It should be able to since the CI test passes with version 17.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used clang-15 as that is the latest version of clang I could find in the apt repository which is available for Ubuntu 22.04 . Also when building llvm-project I had to build version 16 as building version 17 and using this with CppInterOp would build but fail with this command on an arm architechture (I cannot remember off the top of my head what message it failed with). It is not currently possible to switch this build of llvm-project to version 17, as although it passes on x86, it doesn't pass on arm (from tests on my local machine).
xeus-clang-repl/Dockerfile
Line 329 in ce09338
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes. This is a good one. I am misled that conda-forge also has the 17th version, but this is APT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could put a fixme next the part of the dockerfile which builds llvm-project version 16.x , until the issue using 17.x on arm is resolved (I'd raise it as an issue, so that there is a log of what the error is), and put a fixme next to using Clang-15 from apt (when the next LTS version of Ubuntu comes out April next year this would have the latest version of Clang since its in apt repository for version 23.10 of Ubuntu, so would be a quick fix).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍