node-v8 icon indicating copy to clipboard operation
node-v8 copied to clipboard

Build error on Windows

Open targos opened this issue 3 years ago • 4 comments

https://ci.nodejs.org/job/node-compile-windows-debug/12735/nodes=win-vs2019/console

14:33:41 C:\workspace\node-compile-windows-debug\node\deps\v8\src\wasm\wasm-disassembler-impl.h(77,52): error C2487: 'v8::internal::wasm::WasmDecoder<v8::internal::wasm::Decoder::kFullValidation,v8::internal::wasm::kFunctionBody>::StackEffect': member of dll interface class may not be declared with dll interface [C:\workspace\node-compile-windows-debug\node\tools\v8_gypfiles\v8_base_without_compiler.vcxproj]

targos avatar Jul 20 '22 12:07 targos

@nodejs/platform-windows

targos avatar Jul 20 '22 12:07 targos

This is actually not specific to debug builds.

targos avatar Jul 20 '22 14:07 targos

I just created an upstream issue: https://bugs.chromium.org/p/v8/issues/detail?id=13093

targos avatar Jul 20 '22 15:07 targos

Unfortunately this is still happening...

https://github.com/nodejs/node-v8/runs/8087799918?check_suite_focus=true

targos avatar Aug 30 '22 10:08 targos

Bit of a long shot but does this help?

diff --git a/src/wasm/function-body-decoder-impl.h b/src/wasm/function-body-decoder-impl.h
index f8ca69d8485..5ef0eed5aed 100644
--- a/src/wasm/function-body-decoder-impl.h
+++ b/src/wasm/function-body-decoder-impl.h
@@ -2136,7 +2136,7 @@ class WasmDecoder : public Decoder {
   }
 
   // TODO(clemensb): This is only used by the interpreter; move there.
-  V8_EXPORT_PRIVATE std::pair<uint32_t, uint32_t> StackEffect(const byte* pc) {
+  std::pair<uint32_t, uint32_t> StackEffect(const byte* pc) {
     WasmOpcode opcode = static_cast<WasmOpcode>(*pc);
     // Handle "simple" opcodes with a fixed signature first.
     const FunctionSig* sig = WasmOpcodes::Signature(opcode);

WasmDecoder is a template class. Annotating members with __declspec(dllexport) doesn't seem appropriate.

bnoordhuis avatar Sep 15 '22 10:09 bnoordhuis

Let's try: https://ci.nodejs.org/job/node-test-commit-windows-fanned/50518/ https://github.com/targos/node/commit/ae23865d822f33b75a062cbbe5051da35e9f2511

targos avatar Sep 15 '22 11:09 targos

@bnoordhuis looks good (arm64 build failed because of https://github.com/nodejs/node-v8/issues/240)!

targos avatar Sep 15 '22 13:09 targos

Nice. I'll open a V8 CL tomorrow.

bnoordhuis avatar Sep 15 '22 13:09 bnoordhuis

@bnoordhuis can you please post a link to the V8 CL here?

targos avatar Sep 20 '22 10:09 targos

Just a thought, but this might be related to nodejs build system layer (gyp).

V8_EXPORT_PRIVATE is defined here following other macros:

// Setup for Windows shared library export.
#ifdef BUILDING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllexport)
#elif USING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllimport)
#else
#define V8_EXPORT_PRIVATE
#endif  // BUILDING_V8_SHARED

Those macros are set in tools/v8_gypfiles/v8.gyp.

The solution to remove V8_EXPORT_PRIVATE for StackEffect function is equivalent to not declare BUILDING_V8_SHARED nor USING_V8_SHARED.

pbo-linaro avatar Sep 20 '22 14:09 pbo-linaro

@targos I can confirm this compilation error is not present when building v8 directly. I'd suggest a fix around nodejs build system with macros explained above.

pbo-linaro avatar Sep 22 '22 12:09 pbo-linaro

@pbo-linaro would you be able to identify exactly where the wrong macro is set?

targos avatar Sep 22 '22 12:09 targos

I'll try to look at it, but that would be better if someone who worked on gyp/gn layer tackles this. First, I'm working to upstream https://github.com/nodejs/node-v8/issues/240.

pbo-linaro avatar Sep 22 '22 12:09 pbo-linaro

@targos: For now, how do you deal with custom patches that nodejs applies to v8? Are there kept somewhere?

pbo-linaro avatar Sep 22 '22 12:09 pbo-linaro

I keep them on the canary-base branch (https://github.com/nodejs/node/tree/canary-base) which I rebase from time to time (usually when the daily update workflow of this repo fails because of a conflict)

targos avatar Sep 22 '22 12:09 targos

You can safely remove that V8_EXPORT_PRIVATE in src/wasm/function-body-decoder-impl.h. Another class inherits from the one defining this StackEffect function, and reuse V8_EXPORT_PRIVATE, which is forbidden by msvc (should be defined either at class or method level, but not both).

pbo-linaro avatar Sep 22 '22 13:09 pbo-linaro

@targos After trying random stuff around node build system, I could not get something that was solving this issue. I suggest you keep a patch (on node side) removing that export for now.

pbo-linaro avatar Sep 23 '22 14:09 pbo-linaro

Will do, thanks a lot for investigating!

targos avatar Sep 23 '22 14:09 targos