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
Use folly/GLog.h instead of directly including glog #21915
Conversation
…bing in case of missing include.
What do you mean by stubbing? Which exact problem are we solving with this? |
I have a local branch of folly where I stub out the glog macros if __has_include(<glog/logging.h>) fails. One of the platforms I'm testing cxxreact/fabric on doesn't have a glog port, and getting it to build and run isn't trivial. To test folly (and cxxreact) on that platform, I stub out glog macros in the folly header. If glog didn't use macros, I could do a link-time substitution. I could also add defines for the macros on the commandline, but then it would need to be duplicated just in a different way. |
Generated by 🚫 dangerJS |
Yeah, sure. But why do you think this change is a right solutions for that? It's just make it more convenient to you as a side effect which... does not seems so reasonable? Why couldn't you "implement" glog for your platform with noop implementation? |
I could indeed stub out glog/logging.h to fix this problem, but there's a deeper binary size bloat and version mismatch issue I'm trying to solve as well. If folly is statically linking against glog and consumed as a shared library, then the version brought in by RN would need to match pretty precisely to avoid struct size and function signature mismatches, etc. Additionally, there's then two versions of glog occupying space in the program and that bloats memory size at least and app size at worst. By having folly consistently be the way glog functionality/binary impl is conveyed, we aren't falling prey to this duplication and its ripply effects. I can understand that the internal monorepo might not have this issue. FWIW, in my local build of CxxReact, glog, and folly (and boost, gflags, etc), I build them as static libraries with LTO bytecode so the optimization of the final app binary build crosses the library boundaries. This shaved a several hundred kilobytes off my final binary size (and RSS mem usage). When deploying to Android, maybe using the system-installed glog shared library would make more sense from an app binary size perspective, but at a runtime cost. |
Oh my, I want to know more! Maybe should we include (incapsulate this into) (Let me import this to check something...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Ooops, suddenly, If you really want to abstract GLOG, I would just move this to |
@matthargett @shergin : Any updates on this? Including GLog.h is causing macro redefinition issues for us. |
closing this since the GLog.h header isn't included in folly:molly, and the folly repo doesn't seem to expose a way to submit a PR to include it in that build config. |
This allows for stubbing of GLog by checking for the presence of its headers in a centralized place.
Test Plan:
Compiled and ran cxxreact tests. Fabric still doesn't compile in OSS due to headers not being in the correct place.
Release Notes:
[INTERNAL][ENHANCEMENT][ReactCommon]