Skip to content
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

win: fix delay-load hook for electron 4 #1566

Merged
merged 1 commit into from
Oct 22, 2018

Conversation

adill
Copy link
Contributor

@adill adill commented Oct 12, 2018

Checklist
Description of change

Electron, starting with major version 4, ships a node.lib import library referencing electron.exe (node is statically linked) so it is no longer possible to freely rename electron.exe and have native modules work out of the box.

Is node-gyp interested in a change like this? or is this be something that the Electron team should work around themselves?

@refack
Copy link
Contributor

refack commented Oct 12, 2018

Is node-gyp interested in a change like this? or is this be something that the Electron team should work around themselves?

@adill seems like a valid use case to me.

If you are up to the challenge, could you parameterize this? It could be something like <(node_core_target_name)<(EXECUTABLE_SUFFIX) in the .gyp files. Hence

  'defines': [ 'CORE_EXE_NAME=electron.exe', ],

and then the change is the .cc file would be:

  if (_stricmp(info->szDll, CORE_EXE_NAME) != 0)
    return NULL;

@adill
Copy link
Contributor Author

adill commented Oct 14, 2018

@refack Is this what you had in mind? The idea being that electron's node fork will add node_host_binary: 'electron', to it's common.gypi?

@adill
Copy link
Contributor Author

adill commented Oct 14, 2018

note: As implemented anyone still using iojs.exe would be broken by this change.

@refack
Copy link
Contributor

refack commented Oct 14, 2018

@adill yes. Just need to verify two things:

  1. the this works as expected
    'defines': [ 'HOST_BINARY=\"<(node_host_binary)<(EXECUTABLE_SUFFIX)\"', ],

    I'm need to verify GYP will expanad the variable in this case
  2. That this in fact solves the binary-was-renamed issue

@adill
Copy link
Contributor Author

adill commented Oct 14, 2018

I've tested locally and verified that it works as expected. (I used cld as my test native module.)

@richardlau
Copy link
Member

note: As implemented anyone still using iojs.exe would be broken by this change.

I don't think that will be an issue if we release in node-gyp@4 (where we're dropping support for EOL versions of Node.js/io.js).

@refack
Copy link
Contributor

refack commented Oct 14, 2018

I've tested locally and verified that it works as expected. (I used cld as my test native module.)

@adill Could you write a test for this? I'm thinking something like:

  1. There's a sample addon in https://github.com/nodejs/node-gyp/tree/master/test/node_modules/hello_world.
  2. Copy process.execPath to a temp directory, then call tmp1exe nodeGyp on it and rename the exe
    var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')

@adill
Copy link
Contributor Author

adill commented Oct 15, 2018

@refack Added a test. Seems to work -- passes per usual, fails when I make the delay load hook return nullptr.

@khanhas
Copy link

khanhas commented Oct 21, 2018

Is this fixed released?
It is quite frustrating right now. Electron 4.0 beta 4 didn't "revert" anything. I have to rename my app to node.exe for it recognize native module.

@refack
Copy link
Contributor

refack commented Oct 22, 2018

CI: https://ci.nodejs.org/job/nodegyp-test-pull-request/102/
CI after rebase: https://ci.nodejs.org/job/nodegyp-test-pull-request/103/

@khanhas, if this passes CI I'll land this, but a release is not ready yet. Hopefully this will be release soon, and quickly adopted by npm for an update.

refack pushed a commit to discord/node-gyp that referenced this pull request Oct 22, 2018
PR-URL: nodejs#1566
Reviewed-By: Refael Ackermann <refack@gmail.com>
refack pushed a commit to discord/node-gyp that referenced this pull request Oct 22, 2018
PR-URL: nodejs#1566
Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: nodejs#1566
Reviewed-By: Refael Ackermann <refack@gmail.com>
@refack refack merged commit 3fcddce into nodejs:master Oct 22, 2018
@adill adill deleted the support-electron-4 branch October 25, 2018 19:55
rvagg pushed a commit that referenced this pull request Apr 24, 2019
PR-URL: #1566
Reviewed-By: Refael Ackermann <refack@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants