Skip to content
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

node-gyp build on Windows always rebuilds the final binary even if no files were changed #1115

Closed
DuBistKomisch opened this issue Feb 13, 2017 · 7 comments

Comments

@DuBistKomisch
Copy link

DuBistKomisch commented Feb 13, 2017

Cloned bufferutil, ran npm install and node-gyp rebuild, then running node-gyp build:

PS C:\Users\jake\src\bufferutil> node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=Win32' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
     Creating library C:\Users\jake\src\bufferutil\build\Release\bufferutil.lib and object C:\Users\jake\src\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> C:\Users\jake\src\bufferutil\build\Release\\bufferutil.node
  bufferutil.vcxproj -> C:\Users\jake\src\bufferutil\build\Release\bufferutil.pdb (Full PDB)
gyp info ok

No source files were modified, but it still rebuilds the binaries. On Linux and Mac this would be a no-op as it recognises nothing has changed.

Is this a limitation of gyp itself? Surely msbuild is capable of this. Is there some setting I can put in binding.gyp to override this?

This is an issue because it slows down build scripts with unnecessary rebuilds. We have a fairly big native addon so it adds about 20 seconds.

@joaocgreis
Copy link
Member

Notice that bufferutil.cc and win_delay_load_hook.cc don't get rebuilt into object files (they would appear above Creating library ...), only linking is done every time.

I noticed that this doesn't happen when nodedir is a full node source tree, only when it's downloaded by node-gyp and investigated a bit. Turns out that node-gyp is somehow updating the lastwritetime of node.lib before running MSBuild, forcing the linker to run. This looks like something that can be improved.

@DuBistKomisch
Copy link
Author

Yeah luckily, build time would be several minutes if it rebuilt all the object files!

Had a look and you're right, write time on the node.lib gets updated each time I do a build, weird. Could it be being copied internally each time? I'll have a poke around.

@DuBistKomisch
Copy link
Author

Yeah there's some 5 year old copyNodeLib function in lib/build.js which copies the node.lib for the right architecture before each build. I'll put together a PR with a check that the right file is already there.

@bnoordhuis
Copy link
Member

There is an open pull request about that: #951

@DuBistKomisch
Copy link
Author

Tried it with npm install -g https://github.com/pmed/node-gyp#target-arch-windows (from #964) and it seems to fix the problem. I look forward to either of them landing I guess.

@bnoordhuis
Copy link
Member

@joaocgreis Perhaps you can test/review #951 or #964? I think my preference is for the latter.

@joaocgreis
Copy link
Member

Fixed by c307b30...386746c (#964)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants