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

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 this issue Dec 10, 2020 · 10 comments

Comments

@meiry
Copy link

meiry commented Dec 10, 2020

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
Copy link

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
Copy link
Author

meiry commented Dec 23, 2020

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

@dividebylife
Copy link

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
Copy link

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

@dividebylife
Copy link

dividebylife commented Jan 4, 2021

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

  • The instructions suggested replacing :static_crt with :dynamic_crt, but this only works for release mode. Basically, you just want it to always use /MD, which I accomplished by adding an "unreal_crt" section that uses /MD.
  • Then to fix the CSA_ASSERT_ARGS macro, apply the suggested changes from v8/v8@695c40f08ea.
  • Edit the v8\build\config\BUILD.gn file, remove the _DEBUG define from the "debug" configuration section (this idea came from how UE4 solves this). (This step was only necessary because of how UE4 builds work - they always use the Release CRT even in debug builds...which for V8, means just not defining _DEBUG in debug builds).

@meiry
Copy link
Author

meiry commented Jan 4, 2021

@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
Copy link
Author

meiry commented Jan 9, 2021

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
Copy link

caoccao commented Feb 12, 2021

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
Copy link

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

@caoccao
Copy link

caoccao commented Apr 26, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants