Closed
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- 4.2.x, 5.0.x, 6.0.0 beta
- Operating System:
- Windows 10
- Last Known Working Electron version:
- 3.1.x
Expected Behavior
Native node modules are built in release mode with node-gyp (via npm install) and the binary size is similar to modules built for Electron 3.
Actual Behavior
Native node modules are not built with correct build settings, leading to bloated binaries
To Reproduce
Create .npmrc
with the following content
disturl = https://atom.io/download/atom-shell
runtime = electron
target = 4.2.0
arch = x64
npm install diskusage
for example
Screenshots
Additional Information
At least with Electron 4, the issue is caused by node_with_ltcg
not being set in include/node/common.gypi
['node_with_ltcg=="true"', {
'msvs_settings': {
'VCCLCompilerTool': {
'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
},
'VCLibrarianTool': {
'AdditionalOptions': [
'/LTCG:INCREMENTAL', # link time code generation
]
},
'VCLinkerTool': {
'OptimizeReferences': 2, # /OPT:REF
'EnableCOMDATFolding': 2, # /OPT:ICF
'LinkIncremental': 1, # disable incremental linking
'AdditionalOptions': [
'/LTCG:INCREMENTAL', # incremental link-time code generation
]
}
}
}, {
'msvs_settings': {
'VCCLCompilerTool': {
'WholeProgramOptimization': 'false'
},
'VCLinkerTool': {
'LinkIncremental': 2 # enable incremental linking
}
}
}]