8000 Native node modules binaries targeting Electron 4+ are bloated · Issue #18670 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Native node modules binaries targeting Electron 4+ are bloated #18670
Closed
@miniak

Description

@miniak

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

Electron 3
size-e3

Electron 4
size-e4

Electron 5
size-e5

Electron 6
size-e6

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
    }
}
}]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0