|
| 1 | +name: 'Build FAISS Native Library' |
| 2 | +description: 'Build FAISS native library for specified platform' |
| 3 | +inputs: |
| 4 | + platform: |
| 5 | + description: 'Target platform (linux-amd64, linux-aarch64, darwin-aarch64)' |
| 6 | + required: true |
| 7 | + faiss-version: |
| 8 | + description: 'FAISS version to build (e.g., 1.7.4)' |
| 9 | + required: false |
| 10 | + default: '1.7.4' |
| 11 | + use-homebrew: |
| 12 | + description: 'Whether to use Homebrew for dependencies (macOS)' |
| 13 | + required: false |
| 14 | + default: 'false' |
| 15 | + |
| 16 | +runs: |
| 17 | + using: 'composite' |
| 18 | + steps: |
| 19 | + - name: Install native dependencies (Linux) |
| 20 | + if: inputs.use-homebrew == 'false' |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + sudo apt-get update |
| 24 | + sudo apt-get install -y \ |
| 25 | + build-essential \ |
| 26 | + libopenblas-dev \ |
| 27 | + liblapack-dev \ |
| 28 | + patchelf \ |
| 29 | + libgomp1 \ |
| 30 | + wget |
| 31 | +
|
| 32 | + - name: Install GCC 9 (Linux) |
| 33 | + if: inputs.use-homebrew == 'false' |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + sudo apt-get install -y gcc-9 g++-9 || sudo apt-get install -y gcc g++ |
| 37 | + if command -v gcc-9 &>/dev/null; then |
| 38 | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 |
| 39 | + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 90 |
| 40 | + fi |
| 41 | + gcc --version |
| 42 | +
|
| 43 | + - name: Install CMake 3.30.1 (Linux) |
| 44 | + if: inputs.use-homebrew == 'false' |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + CMAKE_VERSION="3.30.1" |
| 48 | + if [[ "${{ inputs.platform }}" == *"amd64"* ]]; then |
| 49 | + CMAKE_ARCH="x86_64" |
| 50 | + else |
| 51 | + CMAKE_ARCH="aarch64" |
| 52 | + fi |
| 53 | + wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH}.tar.gz |
| 54 | + tar -xzf cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH}.tar.gz |
| 55 | + sudo mv cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH} /opt/cmake |
| 56 | + sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake |
| 57 | + cmake --version |
| 58 | +
|
| 59 | + - name: Install FAISS (Linux) |
| 60 | + if: inputs.use-homebrew == 'false' |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + git clone --depth 1 --branch v1.7.4 https://github.com/facebookresearch/faiss.git /tmp/faiss |
| 64 | + cd /tmp/faiss |
| 65 | + cmake -B build \ |
| 66 | + -DFAISS_ENABLE_GPU=OFF \ |
| 67 | + -DFAISS_ENABLE_PYTHON=OFF \ |
| 68 | + -DBUILD_TESTING=OFF \ |
| 69 | + -DCMAKE_BUILD_TYPE=Release |
| 70 | + cmake --build build -j $(nproc) |
| 71 | + sudo cmake --install build |
| 72 | +
|
| 73 | + - name: Install dependencies (macOS) |
| 74 | + if: inputs.use-homebrew == 'true' |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + brew install cmake libomp openblas faiss |
| 78 | +
|
| 79 | + - name: Build native library |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + ./paimon-faiss/paimon-faiss-jni/scripts/build-native.sh --clean --fat-lib --faiss-version ${{ inputs.faiss-version }} |
| 83 | +
|
| 84 | + - name: List built libraries (Linux) |
| 85 | + if: inputs.use-homebrew == 'false' && inputs.platform == 'linux-amd64' |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + echo "=== Built libraries ===" |
| 89 | + ls -la paimon-faiss/paimon-faiss-jni/src/main/resources/linux/amd64/ |
| 90 | + echo "" |
| 91 | + echo "=== Library dependencies ===" |
| 92 | + ldd paimon-faiss/paimon-faiss-jni/src/main/resources/linux/amd64/libpaimon_faiss_jni.so || true |
| 93 | +
|
| 94 | + - name: List built libraries (Linux AARCH64) |
| 95 | + if: inputs.use-homebrew == 'false' && inputs.platform == 'linux-aarch64' |
| 96 | + shell: bash |
| 97 | + run: | |
| 98 | + echo "=== Built libraries ===" |
| 99 | + ls -la paimon-faiss/paimon-faiss-jni/src/main/resources/linux/aarch64/ |
| 100 | + echo "" |
| 101 | + echo "=== Library dependencies ===" |
| 102 | + ldd paimon-faiss/paimon-faiss-jni/src/main/resources/linux/aarch64/libpaimon_faiss_jni.so || true |
| 103 | +
|
| 104 | + - name: List built libraries (macOS) |
| 105 | + if: inputs.use-homebrew == 'true' |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + echo "=== Built libraries ===" |
| 109 | + ls -la paimon-faiss/paimon-faiss-jni/src/main/resources/darwin/aarch64/ |
| 110 | + echo "" |
| 111 | + echo "=== Library dependencies ===" |
| 112 | + otool -L paimon-faiss/paimon-faiss-jni/src/main/resources/darwin/aarch64/libpaimon_faiss_jni.dylib || true |
0 commit comments