简体   繁体   English

从源代码构建 V8

[英]Building V8 from source

Recently I've tried to build V8 JavaScript engine from source using gm with the help of the documentation , in order to use d8 locally;最近我尝试在文档的帮助下使用gm从源代码构建 V8 JavaScript 引擎,以便在本地使用d8 but when I run gm x64.release command, It raises below exception.但是当我运行gm x64.release命令时,它引发以下异常。

# mkdir -p out/x64.release
# echo > out/x64.release/args.gn << EOF
is_component_build = false
is_debug = false
target_cpu = "x64"
use_goma = false
goma_dir = "None"
v8_enable_backtrace = true
v8_enable_disassembler = true
v8_enable_object_print = true
v8_enable_verify_heap = true
EOF
# gn gen out/x64.release
Done. Made 144 targets from 87 files in 443ms
# autoninja -C out/x64.release d8
b'\x1b[31m[E2020-03-07T11:11:53.973835+03:30 10007 0 annotate.go:241]\x1b[0m original error: no such package\r\n\x1b[31m[E2020-03-07T11:11:53.973974+03:30 10007 0 annotate.go:241]\x1b[0m \r\n\x1b[31m[E2020-03-07T11:11:53.974037+03:30 10007 0 annotate.go:241]\x1b[0m goroutine 28:\r\n'b'\x1b[31m[E2020-03-07T11:11:53.974094+03:30 10007 0 annotate.go:241]\x1b[0m #0 go.chromium.org/luci/cipd/client/cipd/client.go:1690 - cipd.(*clientImpl).humanErr()\r\n\x1b[31m[E2020-03-07T11:11:53.974155+03:30 10007 0 annotate.go:241]\x1b[0m #1 go.chromium.org/luci/cipd/client/cipd/client.go:744 - cipd.(*clientImpl).ResolveVersion()\r\n\x1b[31m[E2020-03-07T11:11:53.974226+03:30 10007 0 annotate.go:241]\x1b[0m #2 go.chromium.org/luci/cipd/client/cipd/resolver.go:176 - cipd.(*Resolver).resolveVersion.func1()\r\n\x1b[31m[E2020-03-07T11:1'b'1:53.974284+03:30 10007 0 annotate.go:241]\x1b[0m #3 go.chromium.org/luci/common/sync/promise/promise.go:84 - promise.(*Promise).runGen()\r\n\x1b[31m[E2020-03-07T11:11:53.974339+03:30 10007 0 annotate.go:241]\x1b[0m #4 runtime/asm_amd64.s:1357 - runtime.goexit()\r\n\x1b[31m[E2020-03-07T11:11:53.974416+03:30 10007 0 annotate.go:241]\x1b[0m \r\n\x1b[31m[E2020-03-07T11:11:53.974463+03:30 10007 0 annotate.go:241]\x1b[0m goroutine 27:\r\n\x1b[31m[E2020-03-07T11:11:53.974520+03:30 10007 0 annotate.go:241]\x1b[0m From frame 0 to 0, the following wr'b'appers were found:\r\n\x1b[31m[E2020-03-07T11:11:53.974571+03:30 10007 0 annotate.go:241]\x1b[0m   internal reason: MultiError 1/1: following first non-nil error.\r\n\x1b[31m[E2020-03-07T11:11:53.974626+03:30 10007 0 annotate.go:241]\x1b[0m \r\n'b'\x1b[31m[E2020-03-07T11:11:53.974678+03:30 10007 0 annotate.go:241]\x1b[0m #0 go.chromium.org/luci/cipd/client/cipd/ensure/file.go:255 - ensure.(*File).Resolve.func1.1()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.974732+03:30 10007 0 annotate.go:241]\x1b[0m   reason: failed to resolve infra/python/wheels/psutil/linux-amd64_cp32_abi3@version:5.6.2 (line 0)\r\n'b'\x1b[31m[E2020-03-07T11:11:53.974787+03:30 10007 0 annotate.go:241]\x1b[0m \r\n\x1b[31m[E2020-03-07T11:11:53.974840+03:30 10007 0 annotate.go:241]\x1b[0m #1 go.chromium.org/luci/common/sync/parallel/runner.go:51 - parallel.(*WorkItem).execute()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.974894+03:30 10007 0 annotate.go:241]\x1b[0m #2 go.chromium.org/luci/common/sync/parallel/runner.go:149 - parallel.(*Runner).dispatchLoopBody.func2()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.974975+03:30 10007 0 annotate.go:241]\x1b[0m #3 runtime/asm_amd64.s:1357 - runtime.goexit()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975032+03:30 10007 0 annotate.go:241]\x1b[0m \r\n'b'\x1b[31m[E2020-03-07T11:11:53.975083+03:30 10007 0 annotate.go:241]\x1b[0m goroutine 1:\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975134+03:30 10007 0 annotate.go:241]\x1b[0m #0 go.chromium.org/luci/vpython/venv/config.go:183 - venv.(*Config).makeEnv()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975188+03:30 10007 0 annotate.go:241]\x1b[0m   reason: failed to resolve packages\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975250+03:30 10007 0 annotate.go:241]\x1b[0m \r\n'b'\x1b[31m[E2020-03-07T11:11:53.975305+03:30 10007 0 annotate.go:241]\x1b[0m #1 go.chromium.org/luci/vpython/venv/venv.go:163 - venv.With()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975364+03:30 10007 0 annotate.go:241]\x1b[0m #2 go.chromium.org/luci/vpython/run.go:62 - vpython.Run()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975416+03:30 10007 0 annotate.go:241]\x1b[0m #3 go.chromium.org/luci/vpython/application/application.go:320 - application.(*application).mainImpl()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975470+03:30 10007 0 annotate.go:241]\x1b[0m #4 go.chromium.org/luci/vpython/application/application.go:406 - application.(*Config).Main.func1()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975522+03:30 10007 0 annotate.go:241]\x1b[0m #5 go.chromium.org/luci/vpython/application/support.go:46 - application.run()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975762+03:30 10007 0 annotate.go:241]\x1b[0m #6 go.chromium.org/luci/vpython/application/application.go:405 - application.(*Config).Main()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975834+03:30 10007 0 annotate.go:241]\x1b[0m #7 vpython/main.go:106 - main.mainImpl()\r\n\x1b[31m[E2020-03-07T11:11:53.975884+03:30 10007 0 annotate.go:241]\x1b[0m #8 vpython/main.go:112 - main.main()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975937+03:30 10007 0 annotate.go:241]\x1b[0m #9 runtime/proc.go:203 - runtime.main()\r\n'b'\x1b[31m[E2020-03-07T11:11:53.975997+03:30 10007 0 annotate.go:241]\x1b[0m #10 runtime/asm_amd64.s:1357 - runtime.goexit()\r\n'Traceback (most recent call last):
  File "tools/dev/gm.py", line 420, in <module>
    sys.exit(Main(sys.argv))
  File "tools/dev/gm.py", line 409, in Main
    return_code += configs[c].Build()
  File "tools/dev/gm.py", line 282, in Build
    (path, targets))
  File "tools/dev/gm.py", line 190, in _CallWithOutput
    return p.returncode, "".join(output)
TypeError: sequence item 0: expected str instance, bytes found

It is worth mentioning I'm using Ubuntu 18.04 as my operating system.值得一提的是,我使用 Ubuntu 18.04 作为我的操作系统。 I don't know what's wrong with it and how can I solve it!我不知道它有什么问题,我该如何解决!

Any response would be appreciated...任何回应将不胜感激...

Edit : When I run the command using python2 (I mean python2 tools/dev/gm.py x64.release ), it causes some other issues like below编辑:当我使用python2运行命令时(我的意思是python2 tools/dev/gm.py x64.release ),它会导致一些其他问题,如下所示

# autoninja -C out/x64.release d8
[E2020-03-08T06:20:51.767248+03:30 14549 0 annotate.go:241] original error: no such package
[E2020-03-08T06:20:51.767304+03:30 14549 0 annotate.go:241] 
[E2020-03-08T06:20:51.767335+03:30 14549 0 annotate.go:241] goroutine 50:
[E2020-03-08T06:20:51.767361+03:30 14549 0 annotate.go:241] #0 go.chromium.org/luci/cipd/client/cipd/client.go:1690 - cipd.(*clientImpl).humanErr()
[E2020-03-08T06:20:51.767395+03:30 14549 0 annotate.go:241] #1 go.chromium.org/luci/cipd/client/cipd/client.go:744 - cipd.(*clientImpl).ResolveVersion()
[E2020-03-08T06:20:51.767426+03:30 14549 0 annotate.go:241] #2 go.chromium.org/luci/cipd/client/cipd/resolver.go:176 - cipd.(*Resolver).resolveVersion.func1()
[E2020-03-08T06:20:51.767457+03:30 14549 0 annotate.go:241] #3 go.chromium.org/luci/common/sync/promise/promise.go:84 - promise.(*Promise).runGen()
[E2020-03-08T06:20:51.767488+03:30 14549 0 annotate.go:241] #4 runtime/asm_amd64.s:1357 - runtime.goexit()
[E2020-03-08T06:20:51.767517+03:30 14549 0 annotate.go:241] 
[E2020-03-08T06:20:51.767542+03:30 14549 0 annotate.go:241] goroutine 49:
[E2020-03-08T06:20:51.767569+03:30 14549 0 annotate.go:241] From frame 0 to 0, the following wrappers were found:
[E2020-03-08T06:20:51.767596+03:30 14549 0 annotate.go:241]   internal reason: MultiError 1/1: following first non-nil error.
[E2020-03-08T06:20:51.767624+03:30 14549 0 annotate.go:241] 
[E2020-03-08T06:20:51.767649+03:30 14549 0 annotate.go:241] #0 go.chromium.org/luci/cipd/client/cipd/ensure/file.go:255 - ensure.(*File).Resolve.func1.1()
[E2020-03-08T06:20:51.767680+03:30 14549 0 annotate.go:241]   reason: failed to resolve infra/python/wheels/psutil/linux-amd64_cp32_abi3@version:5.6.2 (line 0)
[E2020-03-08T06:20:51.767711+03:30 14549 0 annotate.go:241] 
[E2020-03-08T06:20:51.767736+03:30 14549 0 annotate.go:241] #1 go.chromium.org/luci/common/sync/parallel/runner.go:51 - parallel.(*WorkItem).execute()
[E2020-03-08T06:20:51.767767+03:30 14549 0 annotate.go:241] #2 go.chromium.org/luci/common/sync/parallel/runner.go:149 - parallel.(*Runner).dispatchLoopBody.func2()
[E2020-03-08T06:20:51.767795+03:30 14549 0 annotate.go:241] #3 runtime/asm_amd64.s:1357 - runtime.goexit()
[E2020-03-08T06:20:51.767821+03:30 14549 0 annotate.go:241] 
[E2020-03-08T06:20:51.767852+03:30 14549 0 annotate.go:241] goroutine 1:
[E2020-03-08T06:20:51.767884+03:30 14549 0 annotate.go:241] #0 go.chromium.org/luci/vpython/venv/config.go:183 - venv.(*Config).makeEnv()
[E2020-03-08T06:20:51.767918+03:30 14549 0 annotate.go:241]   reason: failed to resolve packages
[E2020-03-08T06:20:51.767947+03:30 14549 0 annotate.go:241] 
[E2020-03-08T06:20:51.767968+03:30 14549 0 annotate.go:241] #1 go.chromium.org/luci/vpython/venv/venv.go:163 - venv.With()
[E2020-03-08T06:20:51.767994+03:30 14549 0 annotate.go:241] #2 go.chromium.org/luci/vpython/run.go:62 - vpython.Run()
[E2020-03-08T06:20:51.768022+03:30 14549 0 annotate.go:241] #3 go.chromium.org/luci/vpython/application/application.go:320 - application.(*application).mainImpl()
[E2020-03-08T06:20:51.768047+03:30 14549 0 annotate.go:241] #4 go.chromium.org/luci/vpython/application/application.go:406 - application.(*Config).Main.func1()
[E2020-03-08T06:20:51.768074+03:30 14549 0 annotate.go:241] #5 go.chromium.org/luci/vpython/application/support.go:46 - application.run()
[E2020-03-08T06:20:51.768108+03:30 14549 0 annotate.go:241] #6 go.chromium.org/luci/vpython/application/application.go:405 - application.(*Config).Main()
[E2020-03-08T06:20:51.768147+03:30 14549 0 annotate.go:241] #7 vpython/main.go:106 - main.mainImpl()
[E2020-03-08T06:20:51.768176+03:30 14549 0 annotate.go:241] #8 vpython/main.go:112 - main.main()
[E2020-03-08T06:20:51.768207+03:30 14549 0 annotate.go:241] #9 runtime/proc.go:203 - runtime.main()
[E2020-03-08T06:20:51.768241+03:30 14549 0 annotate.go:241] #10 runtime/asm_amd64.s:1357 - runtime.goexit()

gm.py needs a minor fix to be compatible with Python 3. I have a patch lying around somewhere, but haven't yet gotten around to getting it landed... gm.py需要一个小修复才能与 Python 3 兼容。我在某个地方有一个补丁,但还没有让它登陆......

In the meantime, you can run it in Python 2 manually:同时,您可以在 Python 2 中手动运行它:

python2 tools/dev/gm.py

If you have no python2 command, then you'll have to install the corresponding package for your distribution.如果您没有python2命令,那么您必须为您的发行版安装相应的包。

As far as I realized, building V8 is not compatible with Python 3 yet and there were lots of issues when I tried building it using Python 3. Finally I changed the default version of Python in my OS (Ubuntu 18.04) to Python 2 and It worked like a charm.据我所知,构建 V8 还与 Python 3 不兼容,当我尝试使用 Python 3 构建它时出现了很多问题。最后我将我的操作系统 (Ubuntu 18.04) 中 Python 的默认版本更改为 Python 2 和它像魅力一样工作。

At first I set the Python 2 as an alternative for Python:起初我将 Python 2 设置为 Python 的替代品:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1

Then I selected python2 as a default version of Python using the below command:然后我使用以下命令选择python2作为 Python 的默认版本:

sudo update-alternatives --config python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM