@@ -358,6 +358,7 @@ macro_rules! compatibility_check {
358
358
359
359
#[ cfg( windows) ]
360
360
fn get_shared_object_name( ) -> Option <String > {
361
+ eprintln!( "Entering get_shared_object_name function" ) ;
361
362
use std:: mem:: MaybeUninit ;
362
363
use std:: ptr;
363
364
use std:: ffi:: OsString ;
@@ -388,28 +389,39 @@ macro_rules! compatibility_check {
388
389
}
389
390
390
391
unsafe {
392
+ eprintln!( "Calling GetModuleHandleW" ) ;
391
393
let module = GetModuleHandleW ( ptr:: null( ) ) ;
392
394
if module. is_null( ) {
395
+ eprintln!( "GetModuleHandleW returned null" ) ;
393
396
return None ;
394
397
}
395
398
396
399
let mut buffer_size = MAX_PATH ;
397
400
loop {
401
+ eprintln!( "Entering loop with buffer_size: {}" , buffer_size) ;
398
402
let mut buffer = Vec :: <u16 >:: with_capacity( buffer_size as usize ) ;
403
+ eprintln!( "Calling GetModuleFileNameW" ) ;
399
404
let result = GetModuleFileNameW ( module, buffer. as_mut_ptr( ) , buffer_size) ;
400
405
401
406
if result == 0 {
407
+ eprintln!( "GetModuleFileNameW returned 0" ) ;
402
408
return None ;
403
409
}
404
410
405
411
if result < buffer_size {
412
+ eprintln!( "GetModuleFileNameW succeeded with result: {}" , result) ;
406
413
buffer. set_len( result as usize ) ;
407
- return Some ( OsString :: from_wide( & buffer) . to_string_lossy( ) . into_owned( ) ) ;
414
+ let os_string = OsString :: from_wide( & buffer) ;
415
+ let string = os_string. to_string_lossy( ) . into_owned( ) ;
416
+ eprintln!( "Returning string: {}" , string) ;
417
+ return Some ( string) ;
408
418
}
409
419
410
420
if GetLastError ( ) == ERROR_INSUFFICIENT_BUFFER {
421
+ eprintln!( "Buffer insufficient, doubling size" ) ;
411
422
buffer_size *= 2 ;
412
423
} else {
424
+ eprintln!( "Unexpected error: {}" , GetLastError ( ) ) ;
413
425
return None ;
414
426
}
415
427
}
@@ -476,21 +488,25 @@ macro_rules! compatibility_check {
476
488
477
489
#[ ctor]
478
490
fn check_compatibility( ) {
491
+ eprintln!( "Entering check_compatibility function" ) ;
479
492
let imported: & [ ( & str , & str ) ] = & [
480
493
( "rustc-version" , $crate:: RUBICON_RUSTC_VERSION ) ,
481
494
( "target-triple" , $crate:: RUBICON_TARGET_TRIPLE ) ,
482
495
$( $feature) *
483
496
] ;
484
497
let exported = unsafe { COMPATIBILITY_INFO } ;
485
498
499
+ eprintln!( "Comparing imported and exported compatibility info" ) ;
486
500
let missing: Vec <_> = imported. iter( ) . filter( |& item| !exported. contains( item) ) . collect( ) ;
487
501
let extra: Vec <_> = exported. iter( ) . filter( |& item| !imported. contains( item) ) . collect( ) ;
488
502
489
503
if missing. is_empty( ) && extra. is_empty( ) {
504
+ eprintln!( "No compatibility issues found" ) ;
490
505
// all good
491
506
return ;
492
507
}
493
508
509
+ eprintln!( "Compatibility issues detected, preparing error message" ) ;
494
510
let so_name = get_shared_object_name( ) . unwrap_or( "unknown_so" . to_string( ) ) ;
495
511
// get only the last bit of the path
496
512
let so_name = so_name. rsplit( '/' ) . next( ) . unwrap_or( "unknown_so" ) ;
@@ -503,6 +519,7 @@ macro_rules! compatibility_check {
503
519
504
520
error_message. push_str( & format!( "Loading {} would mix different configurations of the {} crate.\n \n " , blue( so_name) , red( env!( "CARGO_PKG_NAME" ) ) ) ) ;
505
521
522
+ eprintln!( "Calculating column widths for grid display" ) ;
506
523
// Compute max lengths for alignment
507
524
let max_exported_len = exported. iter( ) . map( |( k, v) | format!( "{}={}" , k, v) . len( ) ) . max( ) . unwrap_or( 0 ) ;
508
525
let max_ref_len = imported. iter( ) . map( |( k, v) | format!( "{}={}" , k, v) . len( ) ) . max( ) . unwrap_or( 0 ) ;
@@ -570,6 +587,7 @@ macro_rules! compatibility_check {
570
587
}
571
588
}
572
589
590
+ eprintln!( "Creating grid for compatibility info display" ) ;
573
591
let mut grid = Grid :: new( ) ;
574
592
575
593
// Add header
@@ -599,6 +617,7 @@ macro_rules! compatibility_check {
599
617
grid. add_row( vec![ key_column, binary_column, module_column] ) ;
600
618
}
601
619
620
+ eprintln!( "Writing grid to error message" ) ;
602
621
grid. write_to( & mut error_message) ;
603
622
604
623
struct MessageBox {
@@ -648,6 +667,7 @@ macro_rules! compatibility_check {
648
667
649
668
error_message. push_str( "More info: \x1b [4m\x1b [34mhttps://crates.io/crates/rubicon\x1b [0m\n " ) ;
650
669
670
+ eprintln!( "Creating message box for additional information" ) ;
651
671
let mut message_box = MessageBox :: new( ) ;
652
672
message_box. add_line( format!( "To fix this issue, {} needs to enable" , blue( so_name) ) ) ;
653
673
message_box. add_line( format!( "the same cargo features as {} for crate {}." , blue( & exe_name) , red( env!( "CARGO_PKG_NAME" ) ) ) ) ;
@@ -658,6 +678,7 @@ macro_rules! compatibility_check {
658
678
message_box. write_to( & mut error_message) ;
659
679
error_message. push_str( "\n \x1b [31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b [0m\n " ) ;
660
680
681
+ eprintln!( "Panicking with error message" ) ;
661
682
panic!( "{}" , error_message) ;
662
683
}
663
684
} ;
0 commit comments