-
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
VC++ on v12+ builds bloated addon binaries. #29501
Comments
@nodejs/platform-windows |
It sounds plausible but I don't seen obvious culprits in Is there a way for you to check what runtime your add-on links against? I could see that making a difference. |
VS 2019, so it should be picking up the universal runtime, seems like both are statically linking it. With --target=v10.16.0:
With --target=v12.0.0:
And only If it helps, here's the gyp spam for 10.16.0:
and:
doesn't seem to be anything suspicious there. |
Ugh, should have started here, the vcxproj diff is: --- v10.16.0.vcxproj Tue Sep 10 18:19:55 2019
+++ v12.0.0.vcxproj Tue Sep 10 18:20:44 2019
@@ -36,7 +36,6 @@
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\</ExecutablePath>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
<IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
@@ -48,8 +47,8 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
- <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\10.16.0\include\node;C:\Users\simon\.node-gyp\10.16.0\src;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\config;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\10.16.0\deps\uv\include;C:\Users\simon\.node-gyp\10.16.0\deps\zlib;C:\Users\simon\.node-gyp\10.16.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <AdditionalOptions>/std:c++17 /bigobj %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\12.0.0\include\node;C:\Users\simon\.node-gyp\12.0.0\src;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\config;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\12.0.0\deps\uv\include;C:\Users\simon\.node-gyp\12.0.0\deps\zlib;C:\Users\simon\.node-gyp\12.0.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalOptions>/std:c++17 %(AdditionalOptions)</AdditionalOptions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<BufferSecurityCheck>true</BufferSecurityCheck>
<CompileAsWinRT>false</CompileAsWinRT>
@@ -61,7 +60,7 @@
<OmitFramePointers>false</OmitFramePointers>
<Optimization>Disabled</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<StringPooling>true</StringPooling>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -69,28 +68,23 @@
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<Link>
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\simon\.node-gyp\10.16.0\x64\node.lib"</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\simon\.node-gyp\12.0.0\x64\node.lib"</AdditionalDependencies>
<AdditionalOptions>/ignore:4199 %(AdditionalOptions)</AdditionalOptions>
- <AllowIsolation>true</AllowIsolation>
- <DataExecutionPrevention>true</DataExecutionPrevention>
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <GenerateMapFile>true</GenerateMapFile>
- <MapExports>true</MapExports>
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
- <RandomizedBaseAddress>true</RandomizedBaseAddress>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetExt>.node</TargetExt>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<ResourceCompile>
- <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\10.16.0\include\node;C:\Users\simon\.node-gyp\10.16.0\src;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\config;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\10.16.0\deps\uv\include;C:\Users\simon\.node-gyp\10.16.0\deps\zlib;C:\Users\simon\.node-gyp\10.16.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\12.0.0\include\node;C:\Users\simon\.node-gyp\12.0.0\src;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\config;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\12.0.0\deps\uv\include;C:\Users\simon\.node-gyp\12.0.0\deps\zlib;C:\Users\simon\.node-gyp\12.0.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
- <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\10.16.0\include\node;C:\Users\simon\.node-gyp\10.16.0\src;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\config;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\10.16.0\deps\uv\include;C:\Users\simon\.node-gyp\10.16.0\deps\zlib;C:\Users\simon\.node-gyp\10.16.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\12.0.0\include\node;C:\Users\simon\.node-gyp\12.0.0\src;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\config;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\12.0.0\deps\uv\include;C:\Users\simon\.node-gyp\12.0.0\deps\zlib;C:\Users\simon\.node-gyp\12.0.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/std:c++17 %(AdditionalOptions)</AdditionalOptions>
<BufferSecurityCheck>true</BufferSecurityCheck>
<CompileAsWinRT>false</CompileAsWinRT>
@@ -105,38 +99,27 @@
<OmitFramePointers>true</OmitFramePointers>
<Optimization>Full</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<StringPooling>true</StringPooling>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TreatWarningAsError>false</TreatWarningAsError>
<WarningLevel>Level4</WarningLevel>
- <WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
- <Lib>
- <AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
- </Lib>
<Link>
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\simon\.node-gyp\10.16.0\x64\node.lib"</AdditionalDependencies>
- <AdditionalOptions>/ignore:4199 /LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
- <AllowIsolation>true</AllowIsolation>
- <DataExecutionPrevention>true</DataExecutionPrevention>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\Users\simon\.node-gyp\12.0.0\x64\node.lib"</AdditionalDependencies>
+ <AdditionalOptions>/ignore:4199 %(AdditionalOptions)</AdditionalOptions>
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <GenerateMapFile>true</GenerateMapFile>
- <MapExports>true</MapExports>
- <OptimizeReferences>true</OptimizeReferences>
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
- <RandomizedBaseAddress>true</RandomizedBaseAddress>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetExt>.node</TargetExt>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<ResourceCompile>
- <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\10.16.0\include\node;C:\Users\simon\.node-gyp\10.16.0\src;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\config;C:\Users\simon\.node-gyp\10.16.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\10.16.0\deps\uv\include;C:\Users\simon\.node-gyp\10.16.0\deps\zlib;C:\Users\simon\.node-gyp\10.16.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>C:\Users\simon\.node-gyp\12.0.0\include\node;C:\Users\simon\.node-gyp\12.0.0\src;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\config;C:\Users\simon\.node-gyp\12.0.0\deps\openssl\openssl\include;C:\Users\simon\.node-gyp\12.0.0\deps\uv\include;C:\Users\simon\.node-gyp\12.0.0\deps\zlib;C:\Users\simon\.node-gyp\12.0.0\deps\v8\include;..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=notify_icon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;_WIN32_WINNT=_WIN32_WINNT_WIN7;_UNICODE;UNICODE;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup> A bit of noise in the Debug section further up - the relevant change further down is the missing |
Looks like the culprit is 20a917c moving the optimization options into Seems like there's little reason to not at least restore the non LTCG optimizations to
@refack, as the original committer, does the above make sense? |
@nodejs/platform-windows See above. @simonbuchan's conclusion seems on point to me. |
Also reiterating my comments from #25931 (comment), any reason this configuration for native modules cannot be added to node-gyp's addon.gypi file if the original reason for moving them out was build time concerns ? This would benefit embedders like Electron who build node as a GN target and hence maintains its own generation of common.gypi, instead of fixing it in Electron I would like to have it fixed here that would benefit all. Thoughts ? |
Putting the configuration into node-gyp's addon.gypi would be consistent with nodejs/node-gyp#1118 goal of decoupling addons from being affected by common.gypi changes (like what happened here). |
@richardlau thanks for the pointer! I can try sending a PR for the node-gyp issue as it shares my concerns as well. |
Fixed by nodejs/node-gyp@e18a61a |
Opening this as a node bug, rather than a node-gyp bug, as it's specific to the target version of node, thus presumably to do with the files node-gyp fetches from nodejs.org/dist/...
I've been maintaining a native module available here for low-level access to the windows notification icon and closely related APIs, and recently found that my
.node
binary size increased from ~300kB to ~1MB. Since I'm only targeting windows and using N-API, I prebuild the binary and include that in my package so users don't have to install build tools, and I wanted to debug why this increase happened.After some debugging, I found that this is due to building against node v12.0.0 up:
Attached is the output of Sizer, which seems to give the most readable output for windows, the output seems to be identical for all before v12 and for all from 12:
Notably, when diffing:
There's a whole new bunch of VC++ de-mangling and formatting code included... huh?
I couldn't see anything on the v12.0.0 changelog that made it look like this was a deliberate change, and 600kB+/200%+ extra for each addon is pretty heavy, so I thought it was worth raising, if only to have something for people to be pointed at.
For now, I'm happy to target an earlier node version.
The text was updated successfully, but these errors were encountered: