From 35537c46a00c33db96409ce6aea42a42224f7917 Mon Sep 17 00:00:00 2001 From: Milot Mirdita Date: Tue, 7 Jan 2025 19:36:56 +0900 Subject: [PATCH] Make sure cuda binaries do not depend on dynamic libatomic This would require a non glibc dependency installed --- azure-pipelines.yml | 13 +++++++++---- src/CMakeLists.txt | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5df2017b..fe00b8b1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -150,19 +150,24 @@ jobs: - script: | mkdir build && cd build export CC=gcc-10 ; export CXX=g++-10; export CUDAHOSTCXX=$CXX; export CUDACXX=/usr/local/cuda/bin/nvcc; - LIBGOMP=/usr/lib/gcc/x86_64-linux-gnu/10; + LIBGCC=/usr/lib/gcc/x86_64-linux-gnu/10; /usr/local/bin/cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DHAVE_TESTS=1 -DENABLE_WERROR=1 -DHAVE_AVX2=1 \ - -DOpenMP_C_FLAGS="-fopenmp -I${LIBGOMP}" -DOpenMP_C_LIB_NAMES=gomp -DOpenMP_CXX_FLAGS="-fopenmp -I${LIBGOMP}" -DOpenMP_CXX_LIB_NAMES=gomp -DOpenMP_gomp_LIBRARY=${LIBGOMP}/libgomp.a \ + -DOpenMP_C_FLAGS="-fopenmp -I${LIBGCC}" -DOpenMP_C_LIB_NAMES=gomp -DOpenMP_CXX_FLAGS="-fopenmp -I${LIBGCC}" -DOpenMP_CXX_LIB_NAMES=gomp -DOpenMP_gomp_LIBRARY=${LIBGCC}/libgomp.a \ + -DATOMIC_LIB_OVERRIDE=${LIBGCC}/libatomic.a \ -DFORCE_STATIC_DEPS=1 -DENABLE_CUDA=1 -DCMAKE_CUDA_ARCHITECTURES="75-real;80-real;86-real;89-real;90" .. cmake --build . -j$(nproc --all) -v # fail if GLIBC_PRIVATE or too new GLIBC is present - readelf -Ws src/mmseqs - readelf -V src/mmseqs if readelf -Ws src/mmseqs | grep -q GLIBC_PRIVATE; then + echo "Error: binary contains private glibc symbols" exit 1 fi LIBC_V=$(readelf -V src/mmseqs | awk '$3 ~ /^GLIBC_/ { print $3 }' | sort -V | tail -n1) if [[ "$LIBC_V" > "GLIBC_2.29" ]]; then + echo "Error: glibc too new" + exit 1 + fi + if readelf -d src/mmseqs | grep -q "libatomic.so"; then + echo "Error: libatomic.so is present as a dependency" exit 1 fi displayName: Build MMseqs2 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5d4e386..89bc7f31 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,7 @@ set(HAVE_GPROF 0 CACHE BOOL "Have GPROF Profiler") set(ENABLE_WERROR 0 CACHE BOOL "Enable Warnings as Errors") #set(DISABLE_LTO 0 CACHE BOOL "Disable link-time optimization in non-debug builds") set(REQUIRE_OPENMP 1 CACHE BOOL "Require availability of OpenMP") +set(ATOMIC_LIB_OVERRIDE "" CACHE PATH "Override path to libatomic") include(AppendTargetProperty) @@ -117,13 +118,21 @@ if (HAVE_POSIX_MADVISE) endif () if (NOT DISABLE_IPS4O) - find_package(Atomic) - if (ATOMIC_FOUND) - target_link_libraries(mmseqs-framework ${ATOMIC_LIBRARIES}) + if (ATOMIC_LIB_OVERRIDE) + add_library(LibAtomic STATIC IMPORTED) + set_target_properties(LibAtomic PROPERTIES IMPORTED_LOCATION ${ATOMIC_LIB_OVERRIDE}) + target_link_libraries(mmseqs-framework LibAtomic) target_compile_definitions(mmseqs-framework PUBLIC -DENABLE_IPS4O=1) - message("-- IPS4O sorting works") - else () - message("-- OMPTL sorting fallback") + message("-- IPS4O sorting forced with ${ATOMIC_LIB_OVERRIDE}") + else() + find_package(Atomic) + if (ATOMIC_FOUND) + target_link_libraries(mmseqs-framework ${ATOMIC_LIBRARIES}) + target_compile_definitions(mmseqs-framework PUBLIC -DENABLE_IPS4O=1) + message("-- IPS4O sorting works") + else () + message("-- OMPTL sorting fallback") + endif () endif () else () message("-- OMPTL sorting fallback")