Skip to content

Commit

Permalink
Make sure cuda binaries do not depend on dynamic libatomic
Browse files Browse the repository at this point in the history
This would require a non glibc dependency installed
  • Loading branch information
milot-mirdita committed Jan 7, 2025
1 parent 7e2732c commit 35537c4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
13 changes: 9 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 15 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 35537c4

Please sign in to comment.