@@ -352,44 +352,43 @@ pub fn link_libstdcpp_static() {
352352/// Configuration for rdma-core static libraries from monarch_cpp_static_libs.
353353///
354354/// Use `CppStaticLibsConfig::from_env()` to get the paths, then use the include
355- /// paths for bindgen/cc, and call `emit_link_directives()` to link.
355+ /// directory for bindgen/cc, and call `emit_link_directives()` to link.
356356pub struct CppStaticLibsConfig {
357- pub rdma_include : String ,
358- pub rdma_lib_dir : String ,
359- pub rdma_util_dir : String ,
357+ /// Include directory for rdma-core headers
358+ pub rdma_include_dir : String ,
359+ /// Paths to static libraries (.a files) to link
360+ pub rdma_static_libraries : Vec < String > ,
360361}
361362
362363impl CppStaticLibsConfig {
363364 /// Load configuration from DEP_* environment variables set by monarch_cpp_static_libs.
364365 ///
365366 /// The monarch_cpp_static_libs crate must be listed as a build-dependency.
366367 pub fn from_env ( ) -> Self {
368+ let rdma_include_dir = std:: env:: var ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_INCLUDE_DIR" )
369+ . expect ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_INCLUDE_DIR not set - add monarch_cpp_static_libs as build-dependency" ) ;
370+
371+ let rdma_static_libraries = std:: env:: var ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_STATIC_LIBRARIES" )
372+ . expect ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_STATIC_LIBRARIES not set - add monarch_cpp_static_libs as build-dependency" )
373+ . split ( ';' )
374+ . map ( |s| s. to_string ( ) )
375+ . collect ( ) ;
376+
367377 Self {
368- rdma_include : std:: env:: var ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_INCLUDE" )
369- . expect ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_INCLUDE not set - add monarch_cpp_static_libs as build-dependency" ) ,
370- rdma_lib_dir : std:: env:: var ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_LIB_DIR" )
371- . expect ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_LIB_DIR not set - add monarch_cpp_static_libs as build-dependency" ) ,
372- rdma_util_dir : std:: env:: var ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_UTIL_DIR" )
373- . expect ( "DEP_MONARCH_CPP_STATIC_LIBS_RDMA_UTIL_DIR not set - add monarch_cpp_static_libs as build-dependency" ) ,
378+ rdma_include_dir,
379+ rdma_static_libraries,
374380 }
375381 }
376382
377383 /// Emit all cargo link directives for static linking of rdma-core.
378384 ///
379- /// This emits search paths and link-lib directives for:
380- /// - libmlx5.a
381- /// - libibverbs.a
382- /// - librdma_util.a
385+ /// This uses direct paths to the .a files we built, avoiding any path ordering
386+ /// issues where the linker might find system libraries or libraries built with
387+ /// different flags (e.g., ENABLE_RESOLVE_NEIGH=1).
383388 pub fn emit_link_directives ( & self ) {
384- // Emit link search paths
385- println ! ( "cargo::rustc-link-search=native={}" , self . rdma_lib_dir) ;
386- println ! ( "cargo::rustc-link-search=native={}" , self . rdma_util_dir) ;
387-
388- println ! ( "cargo::rustc-link-lib=static=mlx5" ) ;
389- println ! ( "cargo::rustc-link-lib=static=ibverbs" ) ;
390-
391- // rdma_util helper library
392- println ! ( "cargo::rustc-link-lib=static=rdma_util" ) ;
389+ for lib_path in & self . rdma_static_libraries {
390+ println ! ( "cargo::rustc-link-arg={}" , lib_path) ;
391+ }
393392 }
394393}
395394
@@ -401,7 +400,7 @@ impl CppStaticLibsConfig {
401400/// Example:
402401/// ```ignore
403402/// let config = build_utils::setup_cpp_static_libs();
404- /// // Use config.rdma_include for bindgen/cc
403+ /// // Use config.rdma_include_dir for bindgen/cc
405404/// ```
406405pub fn setup_cpp_static_libs ( ) -> CppStaticLibsConfig {
407406 let config = CppStaticLibsConfig :: from_env ( ) ;
0 commit comments