# V8Study.x86 **Repository Path**: mirrors_pengwei1024/V8Study.x86 ## Basic Information - **Project Name**: V8Study.x86 - **Description**: V8Study.x86 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-31 - **Last Updated**: 2026-03-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # V8Study.x86 MAC下编译和运行 V8的例子, v8版本: version=9.1.0 (candidate) ### V8编译脚本 args.gn ``` is_debug = false target_cpu = "x64" use_custom_libcxx=false is_component_build = false is_clang = true use_lld = false v8_static_library = true v8_monolithic = true v8_use_external_startup_data = false v8_enable_testtrue_features = false v8_enable_i18n_support = false treat_warnings_as_errors = false symbol_level = 1 ``` ## 静态库 本项目提供了两种静态库,都是 X64架构,例如 `lib/v8/platform/mac`下 - libv8_monolith.a 是独立包含全部的静态库,没有开启 v8_use_external_startup_data - snapshot 文件夹是 开启v8_use_external_startup_data && 关闭 v8_monolithic 后的产物,开启了这个就不支持 v8_monolithic属性, 迷之操作~ ## 遇到的坑 #### 运行时找不到 zlib, 报错如下: ``` "_Cr_z_adler32_simd_", referenced from: _Cr_z_adler32_z in libchrome_zlib.a(adler32.o) "_Cr_z_crc32_sse42_simd_", referenced from: _Cr_z_crc32_z in libchrome_zlib.a(crc32.o) "_Cr_z_crc_fold_512to32", referenced from: _Cr_z_crc_finalize in libchrome_zlib.a(crc32.o) "_Cr_z_crc_fold_copy", referenced from: _Cr_z_copy_with_crc in libchrome_zlib.a(crc32.o) "_Cr_z_crc_fold_init", referenced from: _Cr_z_crc_reset in libchrome_zlib.a(crc32.o) ``` 可以看到 third_party/zlib/zconf.h 里面说的 ```c++ /* * This library is also built as a part of AOSP, which does not need to include * chromeconf.h. This config does not want chromeconf.h, so it can set this * macro to opt out. While this works today, there's no guarantee that building * zlib outside of Chromium keeps working in the future. */ #if !defined(CHROMIUM_ZLIB_NO_CHROMECONF) /* This include does prefixing as below, but with an updated set of names. Also * sets up export macros in component builds. */ #include "chromeconf.h" #endif ``` `chromeconf.h` 里面把 zlib 的函数都加了一个前缀 `Cr_z_`, 导致运行时找不到函数,我是通过增加`CHROMIUM_ZLIB_NO_CHROMECONF`宏定义绕过了这个问题 #### 卡死在 CreateBlob 方法,不成功也不报错 通过打日志发现是卡在 api.cc ```c++ isolate->heap()->CollectAllAvailableGarbage( i::GarbageCollectionReason::kSnapshotCreator); ``` 没办法,把 api.cc 里面的这行代码注释掉就可以运行成功