From: naruse@... Date: 2021-03-22T22:42:11+00:00 Subject: [ruby-core:102980] [Ruby master Feature#17730] Ruby on macOS transitively links to ~150 dylibs Issue #17730 has been updated by naruse (Yui NARUSE). rickmark (Rick Mark) wrote in #note-9: > naruse (Yui NARUSE) wrote in #note-7: > > duerst (Martin D�rst) wrote in #note-6: > > > rickmark (Rick Mark) wrote: > > > > > > > Further CoreFoundation is only used for one call in the entire codebase of `CFStringNormalize(m, kCFStringNormalizationFormC);` - if we can replace this, Ruby could work with only `libSystem` and `libgmp`. > > > > > > I'm not at all familiar with the details on a Mac, nor with this library or function in particular. But Unicode String Normalization is provided by String#unicode_normalize, which is implemented in pure Ruby. There may be a bit of glue code necessary, but essentially, the above call should be convertible to something close to `m.unicode_normalize(:nfc)`. > > > > Why it uses `CFStringNormalize(m, kCFStringNormalizationFormC);` is because it needs to just the same conversion as HFS+/APFS, which is different from standard NFC. > > Yep - the normalization is called `UTF-8-MAC` on libicu. This implies we can use other code to do this. Also since CF is opensource we could just bring in the routine directly and avoid any linkage to core macOS frameworks other then libSystem.B. This would also allow other platforms to do proper normalization for macOS as well? I will cut a new ticket for this. Ruby also has UTF-8-MAC, but HFS+/APFS's one is sometimes updated. We first used our own encoding table for the usage, but finally we switched to use OS's to ensure the behavior is exactly same as the filesystem. ---------------------------------------- Feature #17730: Ruby on macOS transitively links to ~150 dylibs https://bugs.ruby-lang.org/issues/17730#change-91042 * Author: rickmark (Rick Mark) * Status: Closed * Priority: Normal ---------------------------------------- By using `-framework Security` and `-framework Foundation` Ruby 3 pulls in about 150 dylibs when compiled for macOS By using CoreCrypto / CoreFoundation I was able to reduce this to ~50. This greatly reduces Ruby's surface area and dependencies on macOS. Further CoreFoundation is only used for one call in the entire codebase of `CFStringNormalize(m, kCFStringNormalizationFormC);` - if we can replace this, Ruby could work with only `libSystem` and `libgmp`. ---Files-------------------------------- ruby_deps_after.txt (2.24 KB) ruby_deps_before.txt (9.81 KB) 0001-Remove-unneeded-dependencies-on-macOS.patch (2.36 KB) ruby_final.txt (2.24 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: