estk / log4rs

A highly configurable logging framework for Rust
Apache License 2.0
973 stars 143 forks source link

bug: Cannot compile on Apple Silicon (arm64) - symbol not found for architecture arm64 #375

Closed acovaci closed 1 month ago

acovaci commented 1 month ago

Build output:

Undefined symbols for architecture arm64:
  "_CFRelease", referenced from:
      _$LT$iana_time_zone..platform..system_time_zone..SystemTimeZone$u20$as$u20$core..ops..drop..Drop$GT$::drop::hbb56264c2fc411ed in libbiter.a[151](iana_time_zone-06283feb7db532f3.iana_time_zone.622fcdf3bb7d37e6-cgu.0.rcgu.o)
  "_CFStringGetBytes", referenced from:
      iana_time_zone::platform::string_ref::StringRef$LT$T$GT$::to_utf8::hfb53c8c9672ed66d in libbiter.a[151](iana_time_zone-06283feb7db532f3.iana_time_zone.622fcdf3bb7d37e6-cgu.0.rcgu.o)
  "_CFStringGetCStringPtr", referenced from:
      iana_time_zone::platform::string_ref::StringRef$LT$T$GT$::as_utf8::h8c595ddcb21c8e8b in libbiter.a[151](iana_time_zone-06283feb7db532f3.iana_time_zone.622fcdf3bb7d37e6-cgu.0.rcgu.o)
  "_CFStringGetLength", referenced from:
      iana_time_zone::platform::string_ref::StringRef$LT$T$GT$::to_utf8::hfb53c8c9672ed66d in libbiter.a[151](iana_time_zone-06283feb7db532f3.iana_time_zone.622fcdf3bb7d37e6-cgu.0.rcgu.o)
  "_CFTimeZoneCopySystem", referenced from:
      iana_time_zone::platform::system_time_zone::SystemTimeZone::new::he6c623e887675c83 in libbiter.a[151](iana_time_zone-06283feb7db532f3.iana_time_zone.622fcdf3bb7d37e6-cgu.0.rcgu.o)
  "_CFTimeZoneGetName", referenced from:
      iana_time_zone::platform::system_time_zone::SystemTimeZone::name::h68d1791a7ae92b3b in libbiter.a[151](iana_time_zone-06283feb7db532f3.iana_time_zone.622fcdf3bb7d37e6-cgu.0.rcgu.o)
ld: symbol(s) not found for architecture arm64

My minimal log4rs config:

log4rs::init_config(
        log4rs::config::Config::builder()
            .build(
                log4rs::config::Root::builder()
                    .appender("console")
                    .build(log::LevelFilter::Debug),
            )
            .unwrap(),
    )
    .unwrap();
acovaci commented 1 month ago

Never mind, sorry, my fault :)

I have some external C build process on top, and I forgot to check that as well. Indeed something in log4rs messes that, but it's outside of the Rust ecosystem, so I'll figure that out myself :)

acovaci commented 1 month ago

UPDATE: In case anyone else runs into this in the future, it was because my gcc compilation didn't link against Core Foundation:

$ gcc -dynamiclib -o dylib_path source.c rustlib.a -framework CoreFoundation