Skip to content

Commit 46d833b

Browse files
committed
tentative fix 2 electric boogaloo
1 parent 634a549 commit 46d833b

2 files changed

Lines changed: 56 additions & 3 deletions

File tree

ci/build_wheel_libcuopt.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,28 @@ fi
2727
# Install Protobuf + gRPC (protoc + grpc_cpp_plugin)
2828
bash ci/utils/install_protobuf_grpc.sh
2929

30-
# The fast MPS parser requires OpenMP 5 symbols from the active GCC toolset. Pin FindOpenMP to
31-
# that compiler's libgomp instead of the older system runtime on Rocky/RHEL wheel builders.
30+
# The wheel must link against the active GCC toolset's OpenMP runtime. Rocky/RHEL's system
31+
# libgomp is older and does not provide the OpenMP 5 symbols required by libcuopt.
3232
CXX_COMPILER="${CXX:-g++}"
3333
GOMP_LIBRARY="$("${CXX_COMPILER}" -print-file-name=libgomp.so)"
3434
if [[ "${GOMP_LIBRARY}" != /* || ! -f "${GOMP_LIBRARY}" ]]; then
3535
echo "Could not resolve libgomp from ${CXX_COMPILER}: '${GOMP_LIBRARY}'" >&2
3636
exit 1
3737
fi
3838

39-
export SKBUILD_CMAKE_ARGS="-DCUOPT_BUILD_WHEELS=ON;-DDISABLE_DEPRECATION_WARNING=ON;-DOpenMP_gomp_LIBRARY:FILEPATH=${GOMP_LIBRARY}"
39+
if ! readelf --dyn-syms --wide "${GOMP_LIBRARY}" | \
40+
grep 'omp_fulfill_event' > /dev/null; then
41+
echo "${GOMP_LIBRARY} does not provide omp_fulfill_event" >&2
42+
exit 1
43+
fi
44+
45+
echo "Using OpenMP runtime from ${CXX_COMPILER}: ${GOMP_LIBRARY}"
46+
47+
export SKBUILD_CMAKE_ARGS="\
48+
-DCUOPT_BUILD_WHEELS=ON;\
49+
-DDISABLE_DEPRECATION_WARNING=ON;\
50+
-DOpenMP_gomp_LIBRARY:FILEPATH=${GOMP_LIBRARY};\
51+
-DCUOPT_OPENMP_RUNTIME_LIBRARY:FILEPATH=${GOMP_LIBRARY}"
4052

4153
# OpenSSL 3 hints for libcuopt's own find_package(OpenSSL).
4254
#

python/libcuopt/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ project(
1515
LANGUAGES CXX CUDA
1616
)
1717

18+
option(CUOPT_BUILD_WHEELS "Configure wheel-specific linkage" OFF)
19+
set(
20+
CUOPT_OPENMP_RUNTIME_LIBRARY
21+
""
22+
CACHE FILEPATH
23+
"Exact OpenMP runtime to link into wheel binaries"
24+
)
25+
1826
# Debug: Print CUDA compiler version early
1927
message(STATUS "=============================================================")
2028
message(STATUS "libcuopt: CMAKE_CUDA_COMPILER_VERSION = ${CMAKE_CUDA_COMPILER_VERSION}")
@@ -69,6 +77,39 @@ target_link_libraries(cuopt_cli PRIVATE
6977
argparse
7078
)
7179

80+
if(CUOPT_BUILD_WHEELS)
81+
if(NOT IS_ABSOLUTE "${CUOPT_OPENMP_RUNTIME_LIBRARY}" OR
82+
NOT EXISTS "${CUOPT_OPENMP_RUNTIME_LIBRARY}")
83+
message(
84+
FATAL_ERROR
85+
"CUOPT_OPENMP_RUNTIME_LIBRARY must name an existing absolute library"
86+
)
87+
endif()
88+
89+
message(
90+
STATUS
91+
"Wheel OpenMP runtime: ${CUOPT_OPENMP_RUNTIME_LIBRARY}"
92+
)
93+
94+
# Keep the exact OpenMP runtime attached even when the executable's only
95+
# reference to it comes through libcuopt.so.
96+
foreach(_target IN ITEMS cuopt cuopt_cli cuopt_grpc_server)
97+
if(TARGET ${_target})
98+
target_link_libraries(
99+
${_target}
100+
PRIVATE
101+
"-Wl,--no-as-needed"
102+
"${CUOPT_OPENMP_RUNTIME_LIBRARY}"
103+
"-Wl,--as-needed"
104+
)
105+
endif()
106+
endforeach()
107+
108+
# Report unresolved runtime symbols while linking libcuopt.so rather than
109+
# deferring the failure until cuopt_cli or cuopt_grpc_server is linked.
110+
target_link_options(cuopt PRIVATE "LINKER:-z,defs")
111+
endif()
112+
72113
set(rpaths
73114
"$ORIGIN/../lib64"
74115
"$ORIGIN/../../rapids_logger/lib64"

0 commit comments

Comments
 (0)