Building static v8 lib on Windows with VS 2022 toolchain fails

229 views
Skip to first unread message

Johannes Gerd Becker

unread,
Apr 17, 2022, 6:59:51 PM4/17/22
to v8-users
Dear all,

currently, I am experiencing problems building v8 as a static library on Windows within a developer command prompt for VS 2022.

Using the following args.gn

is_debug = false
target_cpu = "x86"
v8_monolithic = true
v8_optimized_debug = false
is_component_build = false
v8_static_library = true
use_custom_libcxx = false
use_custom_libcxx_for_host = false
treat_warnings_as_errors = false
v8_enable_i18n_support = false
v8_use_external_startup_data = false

I get the following error:

FAILED: obj/v8_heap_base_headers.lib ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /lib /OUT:obj/v8_heap_base_headers.lib /nologo /WX /ignore:4221 /llvmlibthin @obj/v8_heap_base_headers.lib.rsp warning: no input files, not writing output file pass /llvmlibempty to write empty .lib file, pass /ignore:emptyoutput to suppress warning treating warning as error due to /WX lld-link: error: lib failed

When I add

fatal_linker_warnings = false

I get, later in the build process,

[1743/2146] LINK v8_heap_base_unittests.exe v8_heap_base_unittests.exe.pdb
FAILED: v8_heap_base_unittests.exe v8_heap_base_unittests.exe.pdb
..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /OUT:./v8_heap_base_unittests.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\15.0.0\lib\windows "-libpath:../../../../../../../Program Files (x86)/Windows Kits/NETFXSDK/4.8/lib/um/x86" "-libpath:../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.20348.0/ucrt/x86" "-libpath:../../../../../../../Program Files (x86)/Windows Kits/10/lib/10.0.20348.0/um/x86" /MACHINE:X86  /PDB:./v8_heap_base_unittests.exe.pdb @./v8_heap_base_unittests.exe.rsp
lld-link: error: could not open 'obj/v8_heap_base_headers.lib': no such file or directory
[1747/2146] CXX obj/third_party/inspector_protocol/crdtp_test/json_test.obj
ninja: build stopped: subcommand failed.

How can I get a monolithic static v8 library on Windows? The last time I did this is about 2 years ago, with the then current version of the v8 source, and then it worked without any problems. What am I doing wrong?

Any help is most appreciated.

Best regards,
Johannes

Paul Harris

unread,
Jul 19, 2022, 9:55:02 PM7/19/22
to v8-users
I had this same issue.
I notice that v8_heap_base_headers is a header-only target in BUILD.gn,
but it is defined as "v8_source_set()" which ends up as a lib.

If you change the line in BUILD.gn:
v8_source_set("v8_heap_base_headers") {
to
v8_header_set("v8_heap_base_headers") {

It is around the line 5544 or 5653 depending on which version you are looking at.

It changes to a virtual target, doesn't build a lib, and works!

Note that "gn" source_set() normally builds virtual targets, but the v8_source_set() seems to behave differently.
Reply all
Reply to author
Forward
0 new messages