v8 / v8.dev

The source code of v8.dev, the official website of the V8 project.
https://v8.dev/
Apache License 2.0
955 stars 322 forks source link

visual studio release compilation static lib error: lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory #512

Open meiry opened 3 years ago

meiry commented 3 years ago

i followed all the steps from https://v8.dev/docs/build-gn to build release-static v8 lib but I'm getting this error : using VC 2019 , win10 64bit from https://v8.dev/docs/build-gn doing git branch it shows :

c:\Dev\my\v8\depot_tools\v8\v8>git branch
* (HEAD detached at origin/master)
  master

the error I'm getting :

c:\Dev\my\v8\depot_tools\v8\v8>python tools/dev/v8gen.py x64.release
c:\Dev\my\v8\depot_tools\v8\v8>ninja -C out.gn/x64.release
ninja: Entering directory `out.gn/x64.release'
[1/1] Regenerating ninja files
[206/2990] LINK bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
FAILED: bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /OUT:./bytecode_builtins_list_generator.exe /PDB:./bytecode_builtins_list_generator.exe.pdb @./bytecode_builtins_list_generator.exe.rsp
lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory
[207/2990] LINK torque-language-server.exe torque-language-server.exe.pdb
FAILED: torque-language-server.exe torque-language-server.exe.pdb
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /OUT:./torque-language-server.exe /PDB:./torque-language-server.exe.pdb @./torque-language-server.exe.rsp
lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory
[208/2990] LINK torque.exe torque.exe.pdb
FAILED: torque.exe torque.exe.pdb
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\lib\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:..\..\..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /OUT:./torque.exe /PDB:./torque.exe.pdb @./torque.exe.rsp
lld-link: error: could not open 'obj/v8_wrappers.lib': no such file or directory
[215/2990] CXX obj/test/unittests/cppgc_unittests_sources/member-unittest.obj
ninja: build stopped: subcommand failed.

c:\Dev\my\v8\depot_tools\v8\v8>ninja -C out.gn/x64.release
dividebylife commented 3 years ago

I'm running into as well. What's weird is that v8_wrapper appears to be just a header file. I don't think it would even generate a lib file.

meiry commented 3 years ago

@dividebylife need to try to compile older version to test if this happen too

dividebylife commented 3 years ago

I was able to build by just removing the #include lines for v8_wrapper. But the libs that were generated could not be linked on windows. It's possible that "libs not linking on windows" is a separate problem, though.

maxshugar commented 3 years ago

I'm experiencing the exact same issue on windows 10 - x64. Any ideas on how this could be resolved?

dividebylife commented 3 years ago

I'm experiencing the exact same issue on windows 10 - x64. Any ideas on how this could be resolved? No idea if this will help you since the instructions are possibly specific to UnrealJS's fork of v8, but these are the instructions I followed to ultimately get a successful statically linked build with an older version of v8: https://github.com/ncsoft/Unreal.js/wiki/V8

meiry commented 3 years ago

@dividebylife so if its works when your app is in DEBUG and v8 in release i don't think it is problem, the only problem is to check if it works with the newest v8 version

meiry commented 3 years ago

some tried it ? still having failure with the latest v8 build ( i didn't pull the 7.7.299.9999)

C:\Dev\my\v8\depot_tools\v8>cd v8

C:\Dev\my\v8\depot_tools\v8\v8>gn gen out/x64.release -args="v8_use_external_startup_data=false v8_use_snapshot=false v8_enable_i18n_support=false is_debug=false v8_static_library=true is_clang=false"
WARNING at the command-line "--args":1:52: Build argument has no effect.
v8_use_external_startup_data=false v8_use_snapshot=false v8_enable_i18n_support=false is_debug=false v8_static_library=true is_clang=false
                                                   ^----
The variable "v8_use_snapshot" was set as a build argument
but never appeared in a declare_args() block in any buildfile.

To view all possible args, run "gn args --list <out_dir>"

The build continued as if that argument was unspecified.

Done. Made 162 targets from 85 files in 14494ms
C:\Dev\my\v8\depot_tools\v8\v8>ninja -C out/x64.release v8 v8_libbase v8_libplatform v8_libsampler
ninja: Entering directory `out/x64.release'
[120/1206] LINK bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
FAILED: bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
C:/Dev/my/v8/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./bytecode_builtins_list_generator.exe /PDB:./bytecode_builtins_list_generator.exe.pdb @./bytecode_builtins_list_generator.exe.rsp
LINK : fatal error LNK1181: cannot open input file 'obj\v8_wrappers.lib'

Now I'm noticing they are using a modified version of v8 https://github.com/ncsoft/v8 which is not good at all for general use .

caoccao commented 3 years ago

I managed to work around that. The key is src/base/platform/wrappers.h is a header-only file that MSVC doesn't treat fairly. So the hack is simple: let's force MSVC to accept it by creating a dummy .cc file.

Step 1: Create src\base\platform\wrappers.cc with the following line.

#include "src/base/platform/wrappers.h"

Step 2: Update out.gn\x64.release\obj\v8_wrappers.ninja with the following lines.

+build obj/v8_wrappers.obj: cxx ../../src/base/platform/wrappers.cc

-build obj/v8_wrappers.lib: alink
+build obj/v8_wrappers.lib: alink obj/v8_wrappers.obj

Step 3: Build v8_wrappers.

ninja -C out.gn/x64.release v8_wrappers

ninja: Entering directory `out.gn/x64.release'
[2/2] LIB obj/v8_wrappers.lib

Voilà, c'est très bien.

Nytelife26 commented 3 years ago

Shouldn't this ticket be opened under the main v8 project, not v8.dev?

caoccao commented 3 years ago

I have open sourced the step-by-step with patch script for building Windows version. It works for v8.9 and v9.0. Also, I have prepared pre-built V8 for both Linux and Windows.

Good luck!