MakotoE
MakotoE

Reputation: 2099

Errors when compiling v8 on Windows

I'm following https://v8.dev/docs/embed to compile the sample program for embedding v8. I was able to complete it in Debian with no issues. I'm encountering compilation errors when building v8 on Windows.

I got the v8 source, and I tried compiling the latest master and refs/tags/9.1.193 due to the fact that the suggested refs/tags/7.1.11 in the tutorial requires VS 2017 and I have 2019. Furthermore I need the latest version of v8, not an old one.

Running gn args out.gn/x64.release.sample, I see that the args file contains this:

is_component_build = false
is_debug = false
target_cpu = "x64"
use_custom_libcxx = false
v8_monolithic = true
v8_use_external_startup_data = false

Step 4 of the tutorial, to run ninja -C out.gn/x64.release.sample v8_monolith, fails due to 3 similar compilation errors in obj/v8_base_without_compiler/debug-frames.obj, obj/v8_base_without_compiler/debug-evaluate.obj, and obj/v8_base_without_compiler/debug-coverage.obj.

This is part of the output:

FAILED: obj/v8_base_without_compiler/debug-coverage.obj
...
In file included from ../../src/debug/debug-coverage.cc:11:
../..\src/deoptimizer/deoptimizer.h(108,38): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
  static int input_offset() { return offsetof(Deoptimizer, input_); }
                                     ^                     ~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\13.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from ../../src/debug/debug-coverage.cc:11:
../..\src/deoptimizer/deoptimizer.h(110,12): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
    return offsetof(Deoptimizer, output_count_);
           ^                     ~~~~~~~~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\13.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from ../../src/debug/debug-coverage.cc:11:
../..\src/deoptimizer/deoptimizer.h(112,39): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
  static int output_offset() { return offsetof(Deoptimizer, output_); }
                                      ^                     ~~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\13.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from ../../src/debug/debug-coverage.cc:11:
../..\src/deoptimizer/deoptimizer.h(115,12): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
    return offsetof(Deoptimizer, caller_frame_top_);
           ^                     ~~~~~~~~~~~~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\13.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
4 errors generated.
[882/1736] CXX obj/torque_generated_initializers/test-torque-tq-csa.obj
ninja: build stopped: subcommand failed.

Similar errors on obj/v8_base_without_compiler/debug-frames.obj, obj/v8_base_without_compiler/debug-evaluate.obj

Is there a way to change the configuration so that I can compile v8 on Windows?

Upvotes: 1

Views: 533

Answers (1)

JDługosz
JDługosz

Reputation: 5652

Yes, disable the error mentioned in the message: -Winvalid-offsetof .

Upvotes: 1

Related Questions