Skip to content

V8 is rebuilt every time when building a debug build #16367

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
seishun opened this issue Oct 21, 2017 · 3 comments · Fixed by #16415
Closed

V8 is rebuilt every time when building a debug build #16367

seishun opened this issue Oct 21, 2017 · 3 comments · Fixed by #16415
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.

Comments

@seishun
Copy link
Contributor

seishun commented Oct 21, 2017

  • Version: master
  • Platform: Windows
  • Subsystem: build

After #16333 landed, every time you try to build a debug build using either vcbuild or Visual Studio, V8 gets rebuilt. I'm not sure why the /MP switch is causing this. Perhaps someone more familiar with V8 can help investigate this. If we can't figure it out, I'll submit a revert PR.

cc @nodejs/platform-windows

@seishun seishun added build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform. labels Oct 21, 2017
@seishun
Copy link
Contributor Author

seishun commented Oct 22, 2017

No need to revert, the following patch solves the rebuilding problem:

diff --git a/common.gypi b/common.gypi
index 726b234aa5..34f681b988 100644
--- a/common.gypi
+++ b/common.gypi
@@ -120,6 +120,7 @@
             'BasicRuntimeChecks': 3, # /RTC1
             'AdditionalOptions': [
               '/bigobj', # prevent error C1128 in VS2015
+              '/MP', # compile across multiple CPUs
             ],
           },
           'VCLinkerTool': {
@@ -175,6 +176,9 @@
             'EnableFunctionLevelLinking': 'true',
             'EnableIntrinsicFunctions': 'true',
             'RuntimeTypeInfo': 'false',
+            'AdditionalOptions': [
+              '/MP', # compile across multiple CPUs
+            ],
           },
           'VCLibrarianTool': {
             'AdditionalOptions': [
@@ -207,9 +211,6 @@
         # and their sheer number drowns out other, more legitimate warnings.
         'DisableSpecificWarnings': ['4267'],
         'WarnAsError': 'false',
-        'AdditionalOptions': [
-          '/MP', # compile across multiple CPUs
-        ],
       },
       'VCLibrarianTool': {
       },

Trying to figure out why.

@seishun
Copy link
Contributor Author

seishun commented Oct 22, 2017

Okay I've figured it out (more or less). GYP generates 4 ItemDefinitionGroups in V8's vcxproj files, 2 for Release and 2 for Debug. When /MP is specified separately for Debug and Release in common.gypi, the /MP option is present in only two ItemDefinitionGroups, one for Release and one for Debug. But if it's specified "globally", then it's present in all 4 ItemDefinitionGroups. See below for the comparison between /MP being specified separately and globally:

diff --git a/deps/v8/src/v8_base_3.vcxproj b/deps/v8/src/v8_base_3.vcxproj
index 77f8df3528..71246bc1a5 100644
--- a/deps/v8/src/v8_base_3.vcxproj
+++ b/deps/v8/src/v8_base_3.vcxproj
@@ -54,7 +54,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
       <AdditionalIncludeDirectories>..;..\..\..;$(OutDir)obj\global_intermediate;..\include;..\..\..\deps\icu-small\source\i18n;..\..\..\deps\icu-small\source\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <AdditionalOptions>/bigobj /MP %(AdditionalOptions)</AdditionalOptions>
+      <AdditionalOptions>/MP /bigobj %(AdditionalOptions)</AdditionalOptions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <BufferSecurityCheck>true</BufferSecurityCheck>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -95,6 +95,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
       <AdditionalIncludeDirectories>..;..\..\..;$(OutDir)obj\global_intermediate;..\include;..\..\..\deps\icu-small\source\i18n;..\..\..\deps\icu-small\source\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
       <BufferSecurityCheck>true</BufferSecurityCheck>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <DisableSpecificWarnings>4267;4351;4355;4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -181,6 +182,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <ClCompile>
       <AdditionalIncludeDirectories>..;..\..\..;$(OutDir)obj\global_intermediate;..\include;..\..\..\deps\icu-small\source\i18n;..\..\..\deps\icu-small\source\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
       <BufferSecurityCheck>true</BufferSecurityCheck>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <DisableSpecificWarnings>4267;4351;4355;4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>

msbuild combines the AdditionalOptions from both ItemDefinitionGroups that match the configuration (Debug or Release), and as the result /MP appears twice in the command line. That causes it to rebuild the project every time.

Why does msbuild rebuild the project if /MP is present twice? Apparently it's a bug: https://connect.microsoft.com/VisualStudio/feedback/details/770834/visual-studio-2012-rebuilds-project-over-and-over

Why does GYP generate ItemDefinitionGroup twice for each configuration in V8 projects, and do it differently depending on where AdditionalOptions is defined? Who knows, probably a GYP bug.

Is it worth trying to get GYP fixed (is it even still maintained?) or is it more worthwhile to just introduce the workaround?

@fhinkel
Copy link
Member

fhinkel commented Oct 23, 2017

Gyp is still maintained, but Chromium doesn't use it anymore. And V8 is ceasing Gyp support soon, cc @hashseed.
I'd say we should land the workaround.

addaleax pushed a commit to ayojs/ayo that referenced this issue Oct 26, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: nodejs/node#16415
Fixes: nodejs/node#16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
gibfahn pushed a commit that referenced this issue Oct 30, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: #16415
Fixes: #16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
gibfahn pushed a commit that referenced this issue Oct 31, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: #16415
Fixes: #16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 16, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: #16415
Fixes: #16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 21, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: #16415
Fixes: #16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 28, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: #16415
Fixes: #16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this issue Dec 7, 2017
Setting /MP globally causes it to appear twice in the command line due
to a GYP bug, which causes the project to be rebuilt unconditionally due
to an msbuild bug.

PR-URL: nodejs/node#16415
Fixes: nodejs/node#16367
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants