Skip to content

Commit

Permalink
Add additional mitigation for nodejs/node#29501
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbuchan committed Sep 10, 2019
1 parent 6094cde commit e98eb2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
"DisableSpecificWarnings": [
4100
]
},
# https://github.com/nodejs/node/issues/29501
"VCLinkerTool": {
"OptimizeReferences": 2, # /OPT:REF
"EnableCOMDATFolding": 2, # /OPT:ICF
"LinkIncremental": 1 # disable incremental linking
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const node_gyp = require('node-gyp');
// stripped down version of node-gyp/bin/node-gyp.js
// runs main node-gyp logic, but copies .node output to root

function parseGyp(path) {
return JSON.parse(fs.readFileSync(path, 'utf8').replace(/\#.+\n/, ''))
}

async function main() {
const gyp = node_gyp();
// reuse existing .node-gyp files
Expand All @@ -20,9 +24,9 @@ async function main() {
for (const { name, args } of gyp.todo) {
await promisify(gyp.commands[name])(args);
if (name == "build") {
const binding = JSON.parse(fs.readFileSync(`${__dirname}/binding.gyp`));
const binding = parseGyp(`${__dirname}/binding.gyp`);
// Compute build output dir the same way as node-gyp/lib/build.js
const config = JSON.parse(fs.readFileSync(`${__dirname}/build/config.gypi`, 'utf8').replace(/\#.+\n/, ''));
const config = parseGyp(`${__dirname}/build/config.gypi`);
let buildType = config.target_defaults.default_configuration;
if ('debug' in gyp.opts) {
buildType = gyp.opts.debug ? 'Debug' : 'Release';
Expand Down

0 comments on commit e98eb2b

Please sign in to comment.