|
| 1 | +# |
| 2 | +# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# |
| 4 | +# See file LICENSE for terms. |
| 5 | +# |
| 6 | + |
| 7 | +check_elf_soname() { |
| 8 | + lib_path=$1 |
| 9 | + soname=$2 |
| 10 | + |
| 11 | + if [ ! -f "$lib_path" ]; then |
| 12 | + azure_log_error "Missing library $lib_path" |
| 13 | + exit 1 |
| 14 | + fi |
| 15 | + |
| 16 | + if ! readelf -d "$lib_path" | grep -q "Library soname: \\[$soname\\]"; then |
| 17 | + azure_log_error "Library $lib_path does not have SONAME $soname" |
| 18 | + exit 1 |
| 19 | + fi |
| 20 | +} |
| 21 | + |
| 22 | +check_elf_needed() { |
| 23 | + binary_path=$1 |
| 24 | + needed=$2 |
| 25 | + |
| 26 | + if [ ! -f "$binary_path" ]; then |
| 27 | + azure_log_error "Missing binary $binary_path" |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + |
| 31 | + if ! readelf -d "$binary_path" | grep -q "Shared library: \\[$needed\\]"; then |
| 32 | + azure_log_error "Binary $binary_path is not linked to $needed" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | +} |
| 36 | + |
| 37 | +check_linker_symlink() { |
| 38 | + link_path=$1 |
| 39 | + target_pattern=$2 |
| 40 | + |
| 41 | + if [ ! -L "$link_path" ]; then |
| 42 | + azure_log_error "Missing linker symlink $link_path" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + |
| 46 | + if ! readlink "$link_path" | grep -q "$target_pattern"; then |
| 47 | + azure_log_error "Linker symlink $link_path does not point to $target_pattern" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | +} |
| 51 | + |
| 52 | +check_uct_module_linkage() { |
| 53 | + module=$1 |
| 54 | + suffix=$2 |
| 55 | + module_path="${ucx_inst}/lib/ucx/libuct_${module}-${suffix}.so.0.0.0" |
| 56 | + shift 2 |
| 57 | + |
| 58 | + check_elf_soname "$module_path" "libuct_${module}-${suffix}.so.0" |
| 59 | + for needed in "$@"; do |
| 60 | + check_elf_needed "$module_path" "$needed" |
| 61 | + done |
| 62 | +} |
| 63 | + |
| 64 | +build_soname_suffix() { |
| 65 | + suffix=ci |
| 66 | + foreign_build_dir=${ucx_build_dir}/foreign |
| 67 | + foreign_inst=${ucx_build_dir}/foreign-install |
| 68 | + soname_suffix_check_hw=${soname_suffix_check_hw:-no} |
| 69 | + common_soname_config_args=( |
| 70 | + --without-java |
| 71 | + --without-go |
| 72 | + --without-rocm |
| 73 | + --without-xpmem |
| 74 | + --without-knem |
| 75 | + --disable-doxygen-doc |
| 76 | + ) |
| 77 | + |
| 78 | + if [ "${soname_suffix_check_hw}" = "yes" ]; then |
| 79 | + echo "==== Enable CUDA and IB for SONAME suffix build ====" |
| 80 | + cuda_local_dir="/usr/local/cuda" |
| 81 | + have_gdrcopy=no |
| 82 | + |
| 83 | + if ! nvidia-smi -L; then |
| 84 | + azure_log_error "SONAME suffix CUDA/IB check requires a GPU" |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | + |
| 88 | + if [ ! -d /dev/infiniband ]; then |
| 89 | + azure_log_error "SONAME suffix CUDA/IB check requires IB devices" |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | + |
| 93 | + if [ -d "$cuda_local_dir" ] && |
| 94 | + find "$cuda_local_dir" -name 'libcudart.so.1[2-9]*' | grep -q .; then |
| 95 | + common_soname_config_args+=(--with-cuda=$cuda_local_dir) |
| 96 | + elif az_module_load $CUDA_MODULE; then |
| 97 | + common_soname_config_args+=(--with-cuda) |
| 98 | + else |
| 99 | + azure_log_error "SONAME suffix CUDA/IB check requires CUDA" |
| 100 | + exit 1 |
| 101 | + fi |
| 102 | + |
| 103 | + if [ -w "/dev/gdrdrv" ] && az_module_load $GDRCOPY_MODULE; then |
| 104 | + have_gdrcopy=yes |
| 105 | + common_soname_config_args+=(--with-gdrcopy) |
| 106 | + else |
| 107 | + common_soname_config_args+=(--without-gdrcopy) |
| 108 | + fi |
| 109 | + |
| 110 | + common_soname_config_args+=(--with-verbs --with-rdmacm) |
| 111 | + else |
| 112 | + common_soname_config_args+=( |
| 113 | + --without-verbs |
| 114 | + --without-rdmacm |
| 115 | + --without-cuda |
| 116 | + ) |
| 117 | + fi |
| 118 | + |
| 119 | + echo "==== Build foreign UCX without SONAME suffix ====" |
| 120 | + mkdir -p $foreign_build_dir |
| 121 | + pushd $foreign_build_dir |
| 122 | + ${WORKSPACE}/contrib/configure-release --prefix=$foreign_inst \ |
| 123 | + "${common_soname_config_args[@]}" |
| 124 | + $MAKEP |
| 125 | + $MAKEP install |
| 126 | + popd |
| 127 | + |
| 128 | + echo "==== Build with SONAME suffix and module deepbind ====" |
| 129 | + ${WORKSPACE}/contrib/configure-release --prefix=$ucx_inst \ |
| 130 | + --enable-gtest \ |
| 131 | + --enable-test-apps \ |
| 132 | + --with-soname-suffix=$suffix \ |
| 133 | + --enable-module-deepbind \ |
| 134 | + "${common_soname_config_args[@]}" |
| 135 | + $MAKEP |
| 136 | + $MAKEP install |
| 137 | + |
| 138 | + grep "#define UCX_MODULE_FILE_SUFFIX \"-$suffix\"" config.h |
| 139 | + grep "#define UCX_MODULE_DLOPEN_DEEPBIND 1" config.h |
| 140 | + grep " -lucp-${suffix}" "${ucx_inst}/lib/pkgconfig/ucx.pc" |
| 141 | + grep " -lucs-${suffix} -lucm-${suffix}" \ |
| 142 | + "${ucx_inst}/lib/pkgconfig/ucx-ucs.pc" |
| 143 | + grep " -luct-${suffix}" "${ucx_inst}/lib/pkgconfig/ucx-uct.pc" |
| 144 | + for lib in ucs ucp uct; do |
| 145 | + grep "lib${lib}-${suffix}.so" \ |
| 146 | + "${ucx_inst}/lib/cmake/ucx/ucx-targets.cmake" |
| 147 | + done |
| 148 | + if [ "${soname_suffix_check_hw}" = "yes" ]; then |
| 149 | + grep "#define HAVE_CUDA 1" config.h |
| 150 | + grep "#define HAVE_IB 1" config.h |
| 151 | + fi |
| 152 | + |
| 153 | + for lib in ucm ucs uct ucp; do |
| 154 | + check_elf_soname \ |
| 155 | + "${ucx_inst}/lib/lib${lib}-${suffix}.so.0.0.0" \ |
| 156 | + "lib${lib}-${suffix}.so.0" |
| 157 | + check_linker_symlink \ |
| 158 | + "${ucx_inst}/lib/lib${lib}-${suffix}.so" \ |
| 159 | + "lib${lib}-${suffix}\\.so" |
| 160 | + check_linker_symlink \ |
| 161 | + "${ucx_inst}/lib/lib${lib}.so" \ |
| 162 | + "lib${lib}-${suffix}\\.so" |
| 163 | + done |
| 164 | + |
| 165 | + check_uct_module_linkage cma $suffix \ |
| 166 | + "libuct-${suffix}.so.0" \ |
| 167 | + "libucs-${suffix}.so.0" |
| 168 | + if [ "${soname_suffix_check_hw}" = "yes" ]; then |
| 169 | + for module in cuda ib rdmacm; do |
| 170 | + check_uct_module_linkage $module $suffix \ |
| 171 | + "libuct-${suffix}.so.0" \ |
| 172 | + "libucs-${suffix}.so.0" |
| 173 | + done |
| 174 | + if [ "${have_gdrcopy}" = "yes" ]; then |
| 175 | + check_uct_module_linkage cuda_gdrcopy $suffix \ |
| 176 | + "libuct_cuda-${suffix}.so.0" |
| 177 | + fi |
| 178 | + fi |
| 179 | + check_elf_soname \ |
| 180 | + "${ucx_build_dir}/test/gtest/ucs/test_module/.libs/libtest_module-${suffix}.so.0.0.0" \ |
| 181 | + "libtest_module-${suffix}.so.0" |
| 182 | + check_elf_needed \ |
| 183 | + "${ucx_inst}/lib/libucp-${suffix}.so.0.0.0" \ |
| 184 | + "libuct-${suffix}.so.0" |
| 185 | + check_elf_needed \ |
| 186 | + "${ucx_inst}/lib/libucp-${suffix}.so.0.0.0" \ |
| 187 | + "libucs-${suffix}.so.0" |
| 188 | + for lib in ucp uct ucs; do |
| 189 | + check_elf_needed \ |
| 190 | + "${ucx_inst}/bin/ucx_info" \ |
| 191 | + "lib${lib}-${suffix}.so.0" |
| 192 | + done |
| 193 | + check_elf_needed \ |
| 194 | + "${ucx_build_dir}/test/apps/.libs/libtest_ucx_isolation_plugin.so" \ |
| 195 | + "libucp-${suffix}.so.0" |
| 196 | + |
| 197 | + LD_LIBRARY_PATH="${ucx_inst}/lib:${foreign_inst}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" \ |
| 198 | + "${ucx_build_dir}/test/apps/test_ucx_dlopen_isolation" \ |
| 199 | + "${foreign_inst}/lib/libucp.so.0.0.0" \ |
| 200 | + "${ucx_build_dir}/test/apps/.libs/libtest_ucx_isolation_plugin.so" \ |
| 201 | + "$suffix" deepbind |
| 202 | + |
| 203 | + UCX_MODULES= \ |
| 204 | + UCX_HANDLE_ERRORS=bt \ |
| 205 | + GTEST_FILTER=test_sys.module_file_suffix \ |
| 206 | + $MAKE -C test/gtest test |
| 207 | +} |
0 commit comments