From 9075fb5bb7aa23c5258a031ee3a3702dd8c2b9a0 Mon Sep 17 00:00:00 2001 From: Finn <67562851+finnroblin@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:30:19 -0700 Subject: [PATCH] Update dev guide to fix clang linking issue on arm (#1746) * updated dev guide to fix clang linking issue on arm Signed-off-by: Finn Roblin * restore clang instructions and add additional msg to use gcc if clang linker error Signed-off-by: Finn Roblin * update changelog Signed-off-by: Finn Roblin --------- Signed-off-by: Finn Roblin --- CHANGELOG.md | 1 + DEVELOPER_GUIDE.md | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62006a6f3..9864fd04b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,5 +18,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Bug Fixes ### Infrastructure ### Documentation +* Update dev guide to fix clang linking issue on arm [#1746](https://github.com/opensearch-project/k-NN/pull/1746) ### Maintenance ### Refactoring diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index ff37b456b..0ff5a0bdb 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -102,7 +102,7 @@ cd jni sed -i -e 's/\/usr\/local\/opt\/libomp\//\/opt\/homebrew\/opt\/llvm\//g' cmake/init-faiss.cmake sed -i -e 's/__aarch64__/__undefine_aarch64__/g' external/faiss/faiss/utils/distances_simd.cpp sed -i -e 's/pragma message WARN/pragma message /g' external/nmslib/similarity_search/src/distcomp_scalar.cc -// Change -mcpu value to use chip version according to your M series, for example, -mcpu=apple-m1 +// Change -mcpu value to use chip version according to your M series, for example, -mcpu=apple-m1. You can see the supported mcpu values via gcc --print-supported-cpus sed -i -e 's/-march=native/-mcpu=apple-m1/g' external/nmslib/similarity_search/CMakeLists.txt sed -i -e 's/-mcpu=apple-a14/-mcpu=apple-m1/g' external/nmslib/python_bindings/setup.py @@ -115,6 +115,11 @@ source ~/.zshrc export CC=/opt/homebrew/opt/llvm/bin/clang export CXX=/opt/homebrew/opt/llvm/bin/clang++ +// In case of linking issues with the external libraries and clang, you can try setting the CMAKE compiler to gcc/g++ instead through the following commands: +export CC=gcc +export CXX=g++ +sed -i '' '/set(CMAKE_CXX_STANDARD_REQUIRED True)/a\'$'\n''set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp -L/opt/homebrew/opt/libomp/lib -I/opt/homebrew/opt/libomp/include -lomp -arch arm64 -fexceptions")' CMakeLists.txt + // Build cmake . --fresh make @@ -452,4 +457,4 @@ The Github workflow in [`backport.yml`](.github/workflows/backport.yml) creates original PR with an appropriate label `backport ` is merged to main with the backport workflow run successfully on the PR. For example, if a PR on main needs to be backported to `1.x` branch, add a label `backport 1.x` to the PR and make sure the backport workflow runs on the PR along with other checks. Once this PR is -merged to main, the workflow will create a backport PR to the `1.x` branch. +merged to main, the workflow will create a backport PR to the `1.x` branch. \ No newline at end of file