-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --enable-static option to link icu4c libraries statically #164
Add --enable-static option to link icu4c libraries statically #164
Conversation
@brianmario What do you think of this change? It would help fix #156 and #163. |
462b89f
to
ecec7dc
Compare
Unfortunately this change doesn't work with Ubuntu out of the box because the shared libraries aren't compiled with g++ -shared -o charlock_holmes.so converter.o encoding_detector.o ext.o transliterator.o -L. -L/home/stanhu/.rbenv/versions/2.7.7/lib -Wl,-rpath,/home/stanhu/.rbenv/versions/2.7.7/lib -L. -L/home/stanhu/.rbenv/versions/2.7.7/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -L/home/stanhu/.rbenv/versions/2.7.7/lib -Wl,--compress-debug-sections=zlib -Wl,-rpath,/home/stanhu/.rbenv/versions/2.7.7/lib -L/home/stanhu/.rbenv/versions/2.7.7/lib -lruby -lz /usr/lib/x86_64-linux-gnu/libicui18n.a /usr/lib/x86_64-linux-gnu/libicuuc.a /usr/lib/x86_64-linux-gnu/libicudata.a /usr/lib/x86_64-linux-gnu/libicuio.a -lm -lc
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libicui18n.a(translit.ao): relocation R_X86_64_PC32 against symbol `_ZTVN6icu_6613UnicodeStringE' can not be used when making a shared object; recompile with -fPIC |
@tenderlove What do you think of this change? |
7b92381
to
43f7be7
Compare
@tenderlove Friendly ping. This would help close out #156 and #163. I've built on your macOS test to verify it works. |
Homebrew in macOS updates the `icu4c` library quite often, which often breaks this gem because the dynamically-loaded library no longer exists. To avoid this hassle, this gem can be compiled with `--enable-static` so that the resulting `charlock_holmes.bundle` will have all the required libraries statically linked.
43f7be7
to
cc93f88
Compare
@stanhu great, thank you. Yes, I think this is fine. TBH we should probably distribute statically built binary versions of the gem, but I'm a bit lazy for that 😅 |
@tenderlove I actually spent a while trying to build a precompiled gem, and I got it working for x86. However, the problem is that if you want to cross-compile ICU for other platforms, it requires even more steps: https://unicode-org.github.io/icu/userguide/icu4c/build.html#how-to-cross-compile-icu. Even if you were to get that all working each resulting gem was over 100 MB, since the statically-built library was about 30 MB * the number of Ruby versions supported in the gem. |
@stanhu wow. Thanks for doing this legwork. Seems like we probably shouldn't provide a binary gem then 😓 |
Homebrew in macOS updates the
icu4c
library quite often, which often breaks this gem because the dynamically-loaded library no longer exists.To avoid this hassle, this gem can be compiled with
--enable-static
so that the resultingcharlock_holmes.bundle
will have all the required libraries statically linked.