@@ -5255,17 +5255,16 @@ fn execute_syqure_native(
52555255 cmd. env ( k, v) ;
52565256 }
52575257
5258- // ── LD_LIBRARY_PATH: ensure Codon shared libs are discoverable ───
5259- // On Linux, the syqure binary links libcodonrt.so and libcodonc.so
5260- // dynamically. The compiled rpath ($ORIGIN/lib/codon) only works when
5261- // libs are co-located with the binary. In dev/CI the libs live under
5262- // CODON_PATH/lib/codon or the bundle cache, so we must add them to
5263- // LD_LIBRARY_PATH explicitly. On macOS this is harmless (dyld ignores it).
5258+ // ── Dynamic library lookup path: ensure Codon shared libs are discoverable ───
5259+ // Linux uses LD_LIBRARY_PATH; macOS uses DYLD_LIBRARY_PATH.
5260+ // The syqure binary links codon runtime dylibs/so files dynamically and
5261+ // dev/CI layouts do not always co-locate libs beside the syqure binary.
52645262 if let Some ( ref lib_dir) = codon_lib_dir {
52655263 let lib_dir_str = lib_dir. to_string_lossy ( ) . to_string ( ) ;
52665264 // Also include the parent (lib/) for any top-level .so files.
52675265 let lib_parent = lib_dir. parent ( ) . map ( |p| p. to_string_lossy ( ) . to_string ( ) ) ;
52685266 let existing_ld = env:: var ( "LD_LIBRARY_PATH" ) . unwrap_or_default ( ) ;
5267+ let existing_dyld = env:: var ( "DYLD_LIBRARY_PATH" ) . unwrap_or_default ( ) ;
52695268 let mut parts: Vec < String > = vec ! [ lib_dir_str. clone( ) ] ;
52705269 if let Some ( ref parent) = lib_parent {
52715270 parts. push ( parent. clone ( ) ) ;
@@ -5276,6 +5275,19 @@ fn execute_syqure_native(
52765275 let new_ld = parts. join ( ":" ) ;
52775276 cmd. env ( "LD_LIBRARY_PATH" , & new_ld) ;
52785277 println ! ( " LD_LIBRARY_PATH={}" , new_ld) ;
5278+ #[ cfg( target_os = "macos" ) ]
5279+ {
5280+ let mut dyld_parts: Vec < String > = vec ! [ lib_dir_str] ;
5281+ if let Some ( parent) = lib_parent {
5282+ dyld_parts. push ( parent) ;
5283+ }
5284+ if !existing_dyld. is_empty ( ) {
5285+ dyld_parts. push ( existing_dyld) ;
5286+ }
5287+ let new_dyld = dyld_parts. join ( ":" ) ;
5288+ cmd. env ( "DYLD_LIBRARY_PATH" , & new_dyld) ;
5289+ println ! ( " DYLD_LIBRARY_PATH={}" , new_dyld) ;
5290+ }
52795291 }
52805292 if env:: var ( "BV_SYQURE_BACKTRACE" )
52815293 . map ( |v| v == "1" || v. to_lowercase ( ) == "true" )
0 commit comments