-
Notifications
You must be signed in to change notification settings - Fork 30k
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
cleanup: reduce the number of #include "env.h"
and #include "env-inl.h"
in the code base
#27531
Comments
I think this is a good first issue if you know how forward declaration and C++ headers work. If nobody picks this up (say in a week) I'll do it anyway because...I touch |
BTW I believe that as of C++11 this assumption is not as relevant as it used to be. |
I think the instructions from @joyeecheung are very clear. Can I take up this issue? Thanks! |
@Jinshuo1994 sure, go head! |
Since I'm learning c++ in context of Node core, I tried out #27620 for this "good first issue" for c++ in core. Thanks. |
Hi, This is my first time with contributing to open source and would like to know, how exactly I can help. |
@sarkararpan710 There was #27620 but it did not exactly do what this issue requests. Since there has been no progress there since more than a week, I think you can take another stab at this - please take a look at #27620 (comment) about what the request is. |
@joyeecheung, sorry about the delay to update the PR. Been busy w. work lately. I’ll close the PR, and look out for other opportunities to do PRs. |
@joyeecheung I was wondering if I could work on this issue, is it still something that needs to be worked on? I am brand new to open-source and this would be my first contribution, so please excuse if I ask something ignorant. |
I suggest waiting until #27755 lands. It probably (mostly) cleans up many unnecessary includes of env-inl.h, but it doesn't deal with the problem of files that include env.h purely for its class declaration. As a heads up, to do this, you'll need to know how a |
@sam-github Thank you very much. Will this take about 48 hours? How will I know when it lands? I appreciate your comment. |
Hopefully will land by the end of day. You can probably use the 'subscribe' button on the PR to start getting updates on it. |
@sam-github Are we waiting for someone with write access to merge it with Master, am I understanding? Then, I re-build and start working? Thank you. Thank you for your patience with a new person, I am in my last quarter of a CS degree and new to git. |
Does this issue still need attention? I would like to try and fix it |
@alferpal I think this still is an issue, but maybe to a smaller extent. BTW https://include-what-you-use.org/ can probably be useful in hunting these down but I have never tried to get it working in this code base. |
Thank you for the tip, @joyeecheung . I'll try what you suggested. |
I've tried to do a first pass of the cleanup in the header files, when possible. My intention is to make another more thorough pass using the tool @joyeecheung mentioned, but that will take a bit more time as I have to get familiar with it and so on. Submitted the PR because I think a little improvement is always welcome, and I don't know when I'll find the time to sit and get more familiar with the codebase. |
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: #27531 PR-URL: #30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: nodejs/node#27531 PR-URL: nodejs/node#30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: #27531 PR-URL: #30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
I've managed to clean some more headers leftover in the code using include-what-you-use. For those that haven't used it, it builds the project and outputs a list of suggestions for headers that should be added or removed and the total list of includes and forward declarations a file should have. The output is something like this:
The instructions on IWYU's documentation don't manage to build node, as make will exit just after finishing building v8 due to all the suggestions thrown from IWYU. I managed to get a full build using the following:
Leaving this hoping it helps. |
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: #27531 PR-URL: #30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: #27531 PR-URL: #30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: #27531 PR-URL: #30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: #27531 PR-URL: #30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Node codebase has evolved a lot in the more than 10 years of its existence. As more features (and code) have been added, changed, removed, it's sometimes hard to keep track of what gets used and what not. This commits attempts to clean some of those potentially left-over headers using suggestions from include-what-you-use Refs: #27531 PR-URL: #30328 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Due to how the Environment class is used throughout the codebase, there are a log of includes referencing eitehr env.h or env-inl.h. This commit cleans up the remaining extra includes of 'env.h' or 'env-inl.h' and adds forward declarations of the Environment class. PR-URL: nodejs#32293 Refs: nodejs#27531
Due to how the Environment class is used throughout the codebase, there are a log of includes referencing eitehr env.h or env-inl.h. This commit cleans up the remaining extra includes of 'env.h' or 'env-inl.h' and adds forward declarations of the Environment class. PR-URL: #32293 Refs: #27531 Fixes: #27531 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Due to how the Environment class is used throughout the codebase, there are a log of includes referencing eitehr env.h or env-inl.h. This commit cleans up the remaining extra includes of 'env.h' or 'env-inl.h' and adds forward declarations of the Environment class. PR-URL: #32293 Refs: #27531 Fixes: #27531 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Due to how the Environment class is used throughout the codebase, there are a log of includes referencing eitehr env.h or env-inl.h. This commit cleans up the remaining extra includes of 'env.h' or 'env-inl.h' and adds forward declarations of the Environment class. PR-URL: nodejs#32293 Refs: nodejs#27531 Fixes: nodejs#27531 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Due to how the Environment class is used throughout the codebase, there are a log of includes referencing eitehr env.h or env-inl.h. This commit cleans up the remaining extra includes of 'env.h' or 'env-inl.h' and adds forward declarations of the Environment class. PR-URL: #32293 Refs: #27531 Fixes: #27531 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Because of how
Environment
is used in the code base (e.g. to grab Node.js things from callbacks, to have fast access to persistent properties),Environment
is used in almost every C++ file, which results in a lot of#include "env.h"
and#include "env-inl.h"
in the code base. However many files (mostly headers) only need a forward declaration ofclass Environment
instead of requiringenv.h
orenv-inl.h
because they just need to know theEnvironment
type to haveEnvironment*
in the declarations. When there is code in a header that actually uses something fromEnvironment
(so a forward declaration is not enough), the code may be moved out of the header if it is not in a hot path (i.e. it does not need to be inlined).Reducing the number of these includes should reduce the amount of files being compiled whenever
env.h
/env-inl.h
is touched.The text was updated successfully, but these errors were encountered: