puerts / backend-v8

43 stars 44 forks source link

v8 11.8.172支持linux的ue #16

Open chexiongsheng opened 1 month ago

chexiongsheng commented 1 month ago

主要有两个问题: 1、链接的是libstdc++,但ue链接的是libc++,9.4、8.4都没这问题,但10.6以上都是链接libstdc++; 2、11.8用clang 17编译,链接到ue会报Undefined symbols "std::1::libcpp_verbose_abort(char const*, ...)

chexiongsheng commented 1 month ago

对于1,原以为降级到9.4用的clang(通过DEPS修改)能解决,实际上并不能,包括把sysroot也降级了也不行,不知道为何9.4编译就是libc++,最后面通过加入-stdlib=libc++显式指定,但又带来新问题,会找不到c++的头文件,切换到系统的clang++也一样,最终找到是-no-canonical-prefixes编译参数所致,该参数google也搜索不到。 对于2,降级clang可以解决。

最终形成方案1: 1、使用系统的clang 14(编辑参数加上:use_sysroot=false use_glib=false clang_base_path=\"/usr\");由于没有v8定制的plugin,所以加上 simple_template_names=false clang_use_chrome_plugins=false ; 2、由于降级clang 14,需要去掉构建文件中不支持的编译选项:-Wno-deprecated-builtins、-Wno-deprecated-non-prototype 3、由于ue用的是c++17,稳妥起见,也改为使用c++17编译

chexiongsheng commented 1 month ago

方案2思路是还使用clang 17(不过得改为用系统的,而不是v8自己下载的),并且通过-D_LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT=1解决符号问题:

1、config/compiler/build.gn 加入:-stdlib=libc++ -D_LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT=1 2、

if [ "$VERSION" == "11.8.172" ]; then 
    echo "============ intall clang-17"
    sudo apt update
    sudo apt install -y wget gnupg lsb-release software-properties-common
    wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
    sudo add-apt-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-17 main"
    sudo apt update
    sudo apt install -y clang-17 libc++-17-dev libc++abi-17-dev
    ln -s /usr/lib/llvm-17 ~/customclang
fi

export LD_LIBRARY_PATH=$(HOME)/lib:$LD_LIBRARY_PATH
gn gen out.gn/x64.release --args="is_debug=false v8_enable_i18n_support=false v8_use_snapshot=true v8_use_external_startup_data=false v8_static_library=true strip_debug_info=true symbol_level=0 libcxx_abi_unstable=false v8_enable_pointer_compression=true v8_enable_sandbox=false use_custom_libcxx=false is_clang=true clang_use_chrome_plugins=false use_sysroot=false use_glib=false clang_base_path=\"$(HOME)/customclang\""