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

is_component_build=true mksnapshot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class v8::Platform * __cdecl v8::platform::CreateDefaultPlatform(int,enum v8::platform::IdleTaskSupport,enum v8::platform::InProcessStackDumping,class v8::TracingController *)" #6172

Closed
fpn opened this issue Sep 22, 2017 · 9 comments

Comments

@fpn
Copy link

fpn commented Sep 22, 2017

NWJS Version : 0.25.2
Operating System : windows 10 64 bit

Expected behavior

Trying to build nw.js as component build to reduce link times. Whenever I set is_component_build=true I get this build error:

C:\src\nwjs_v0.25.2\src>ninja -C out/nw nwjs
ninja: Entering directory `out/nw'
[15210/27017] LINK mksnapshot.exe mksnapshot.exe.pdb
FAILED: mksnapshot.exe mksnapshot.exe.pdb
C:/Python27/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./mksnapshot.exe /PDB:./mksnapshot.exe.pdb @./mksnapshot.exe.rsp
mksnapshot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class v8::Platform * __cdecl v8::platform::CreateDefaultPlatform(int,enum v8::platform::IdleTaskSupport,enum v8::platform::InProcessStackDumping,class v8::TracingController *)" (__imp_?CreateDefaultPlatform@platform@v8@@YAPEAVPlatform@2@HW4IdleTaskSupport@12@W4InProcessStackDumping@12@PEAVTracingController@2@@Z) referenced in function main
./mksnapshot.exe : fatal error LNK1120: 1 unresolved externals
[15219/27017] CXX irt_x64/obj/mojo/edk/system/system/node_controller.o

The args I have set are:

is_debug=false
is_component_ffmpeg=true
target_cpu="x64"
enable_nacl=true
ffmpeg_branding="Chrome"
is_component_build=true

Did run the python .\build\gyp_chromium.py -D component=shared_library ...

I tried with is_debug=true, but that didn't make a difference.

If I do the same without the is_component_build it works.

@hujiajie
Copy link
Contributor

@rogerwang I can confirm the issue, and I'd like to offer a hotfix if you are not working on this yet.

@fpn
Copy link
Author

fpn commented Sep 25, 2017

@hujiajie - If you have a patch - I would love to try it

hujiajie added a commit to hujiajie/v8 that referenced this issue Sep 26, 2017
libplatform is forced to be built as a static library in NW.js, so
USING_V8_PLATFORM_SHARED should not be defined for its direct
dependents. Instead, the macro should be defined at the same place as
USING_V8_SHARED since libplatform is part of the main V8 library now.

Refs: nwjs/nw.js#6172
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 26, 2017
The entire class has already been exported, so MSVC will complain about
the redundant BLINK_EXPORT attribute in component build.

Refs: nwjs/nw.js#6172
Refs: https://groups.google.com/forum/#!topic/nwjs-general/weTjocUM8U8
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 27, 2017
The following changes are based on the assumption that BLINK_HOOK_MAP is
always for symbols exported by blink_core, just like PLATFORM_HOOK_MAP
is for symbols from blink_platform.

* WebSharedWorkerImpl.cpp: symbols defined in blink_core will be used
  inside blink_core, so a forward declaration with the "extern" keyword
  is enough. The *_EXPORT attribute will break Windows component build.

* WebEmbeddedWorkerImpl.cpp: symbols exported by blink_core will be used
  by blink_modules, so use CORE_EXPORT instead.

* WebKit.cpp: symbols exported by blink_core will be used by blink_web,
  so use CORE_EXPORT instead.

* InProcessWorkerMessagingProxy.cpp: symbols are defined and exported by
  blink_core, so use CORE_EXPORT instead. This is analogous to how
  webthread_impl_for_worker_scheduler.cc exports PLATFORM_HOOK_MAP
  symbols.

Refs: nwjs/nw.js#6172
@hujiajie
Copy link
Contributor

@fpn Please see nwjs/v8#2 and nwjs/chromium.src#95

@fpn
Copy link
Author

fpn commented Sep 27, 2017

Hi @hujiajie ,

the build did go through, but when I start it - I have trouble loading my native modules:

C:\src\nwjs_v0.25.3\src\out\nw>.\nw.exe "C:\Users\fpn\bebo-app\build\nw\package.nw" --enable-logging --v=1

C:\src\nwjs_v0.25.3\src\out\nw>C:\Users\fpn\bebo-app\build\nw\package.nw\node_modules\bindings\bindings.js:88
        throw e
        ^

Error: The specified procedure could not be found.
\\?\C:\Users\fpn\bebo-app\build\nw\package.nw\node_modules\bebo-capture\build\Release\BeboCaptureNative.node
    at Object.Module._extensions..node (module.js:695:18)
    at Module.load (module.js:569:32)
    at tryModuleLoad (module.js:532:12)
    at Function.Module._load (module.js:524:3)
    at Module.require (module.js:592:17)
    at require (internal/module.js:11:18)
    at bindings (C:\Users\fpn\bebo-app\build\nw\package.nw\node_modules\bindings\bindings.js:81:44)
    at Object.<anonymous> (C:\Users\fpn\bebo-app\build\nw\package.nw\node_modules\bebo-capture\index.js:1:95)
    at Module._compile (module.js:648:30)
    at Object.Module._extensions..js (module.js:665:10)

Is there any magic I need to do for native modules with a component build? They are build with nw-gyp against the same version of nw.js (nwjs 0.25.3)

Thank you,
Florian

fpn pushed a commit to bebo/nw-js-test-case-6172 that referenced this issue Sep 28, 2017
@fpn
Copy link
Author

fpn commented Sep 28, 2017

Hi @hujiajie,

I created a simple test case to reproduce the issue outside of our app:
https://github.com/bebo/nw-js-test-case-6172

set_env.cmd has the environment variables I use for my nw.js native modules build
and then just npm install

Pointing my regular nw.js build at this test case reveals the result of a simple native computation in the js console: "SHA3SUM 1597842aac52bc9d13fe249d808afbf44da13524759477404c3592ee331173e89fe1cbf21a7e4360990d565fad4643cdb209d80fa41a91dea97e665022c92135"

Pointing my component build shows:

Uncaught Error: The specified procedure could not be found.
\\?\C:\Users\fpn\nwjs_6172\node_modules\sha3\build\Release\sha3.node
    at Object.Module._extensions..node (module.js:695:18)
    at Module.load (module.js:569:32)
    at tryModuleLoad (module.js:532:12)
    at Function.Module._load (module.js:524:3)
    at Module.require (module.js:592:17)
    at require (internal/module.js:11:18)
    at self.require (<anonymous>:11:26)

@hujiajie
Copy link
Contributor

@fpn Thanks for your test case.

The root cause of the issue is that the native addon is linked with nw.lib provided by nw-gyp, so the import table of the native addon will indicate that V8 symbols are imported from nw.dll, which is true for the default non-component build. But for component build, these symbols are actually provided by v8.dll instead of nw.dll, so the Windows dll loader will fail to resolve these symbols and report the above error.

Component build is not well supported, but I'll see how to provide a workaround as easy as possible.

@rogerwang
Copy link
Member

@hujiajie I'll see the native library issue.

@rogerwang rogerwang self-assigned this Oct 2, 2017
fpn pushed a commit to bebo/chromium.src that referenced this issue Oct 3, 2017
The following changes are based on the assumption that BLINK_HOOK_MAP is
always for symbols exported by blink_core, just like PLATFORM_HOOK_MAP
is for symbols from blink_platform.

* WebSharedWorkerImpl.cpp: symbols defined in blink_core will be used
  inside blink_core, so a forward declaration with the "extern" keyword
  is enough. The *_EXPORT attribute will break Windows component build.

* WebEmbeddedWorkerImpl.cpp: symbols exported by blink_core will be used
  by blink_modules, so use CORE_EXPORT instead.

* WebKit.cpp: symbols exported by blink_core will be used by blink_web,
  so use CORE_EXPORT instead.

* InProcessWorkerMessagingProxy.cpp: symbols are defined and exported by
  blink_core, so use CORE_EXPORT instead. This is analogous to how
  webthread_impl_for_worker_scheduler.cc exports PLATFORM_HOOK_MAP
  symbols.

Refs: nwjs/nw.js#6172
fpn pushed a commit to bebo/chromium.src that referenced this issue Oct 3, 2017
The entire class has already been exported, so MSVC will complain about
the redundant BLINK_EXPORT attribute in component build.

Refs: nwjs/nw.js#6172
Refs: https://groups.google.com/forum/#!topic/nwjs-general/weTjocUM8U8
fpn pushed a commit to bebo/chromium.src that referenced this issue Oct 4, 2017
The following changes are based on the assumption that BLINK_HOOK_MAP is
always for symbols exported by blink_core, just like PLATFORM_HOOK_MAP
is for symbols from blink_platform.

* WebSharedWorkerImpl.cpp: symbols defined in blink_core will be used
  inside blink_core, so a forward declaration with the "extern" keyword
  is enough. The *_EXPORT attribute will break Windows component build.

* WebEmbeddedWorkerImpl.cpp: symbols exported by blink_core will be used
  by blink_modules, so use CORE_EXPORT instead.

* WebKit.cpp: symbols exported by blink_core will be used by blink_web,
  so use CORE_EXPORT instead.

* InProcessWorkerMessagingProxy.cpp: symbols are defined and exported by
  blink_core, so use CORE_EXPORT instead. This is analogous to how
  webthread_impl_for_worker_scheduler.cc exports PLATFORM_HOOK_MAP
  symbols.

Refs: nwjs/nw.js#6172
fpn pushed a commit to bebo/chromium.src that referenced this issue Oct 4, 2017
The entire class has already been exported, so MSVC will complain about
the redundant BLINK_EXPORT attribute in component build.

Refs: nwjs/nw.js#6172
Refs: https://groups.google.com/forum/#!topic/nwjs-general/weTjocUM8U8
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Oct 9, 2017
The entire class has already been exported, so MSVC will complain about
the redundant BLINK_EXPORT attribute in component build.

Refs: nwjs/nw.js#6172
Refs: https://groups.google.com/forum/#!topic/nwjs-general/weTjocUM8U8
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Oct 9, 2017
The following changes are based on the assumption that BLINK_HOOK_MAP is
always for symbols exported by blink_core, just like PLATFORM_HOOK_MAP
is for symbols from blink_platform.

* WebSharedWorkerImpl.cpp: symbols defined in blink_core will be used
  inside blink_core, so a forward declaration with the "extern" keyword
  is enough. The *_EXPORT attribute will break Windows component build.

* WebEmbeddedWorkerImpl.cpp: symbols exported by blink_core will be used
  by blink_modules, so use CORE_EXPORT instead.

* WebKit.cpp: symbols exported by blink_core will be used by blink_web,
  so use CORE_EXPORT instead.

* InProcessWorkerMessagingProxy.cpp: symbols are defined and exported by
  blink_core, so use CORE_EXPORT instead. This is analogous to how
  webthread_impl_for_worker_scheduler.cc exports PLATFORM_HOOK_MAP
  symbols.

Refs: nwjs/nw.js#6172
rogerwang pushed a commit to nwjs/v8 that referenced this issue Oct 30, 2017
libplatform is forced to be built as a static library in NW.js, so
USING_V8_PLATFORM_SHARED should not be defined for its direct
dependents. Instead, the macro should be defined at the same place as
USING_V8_SHARED since libplatform is part of the main V8 library now.

Refs: nwjs/nw.js#6172
@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

@rogerwang
Copy link
Member

Here is the workaround for native library issue with component build:

  1. replace 'nw.lib' with 'v8.dll.lib' in %USERPROFILE%\AppData\Roaming\npm\node_modules\nw-gyp\addon.gypi
  2. copy 'v8.dll.lib' from your local component build directory to %USERPROFILE%.nw-gyp\nw.version\Release
  3. run npm rebuild

rogerwang pushed a commit to nwjs/v8 that referenced this issue Nov 6, 2017
libplatform is forced to be built as a static library in NW.js, so
USING_V8_PLATFORM_SHARED should not be defined for its direct
dependents. Instead, the macro should be defined at the same place as
USING_V8_SHARED since libplatform is part of the main V8 library now.

Refs: nwjs/nw.js#6172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants