【问题标题】:Building SpiderMonkey for Windows为 Windows 构建 SpiderMonkey
【发布时间】:2021-08-03 12:31:08
【问题描述】:

我正在尝试为 Windows 构建 SpiderMonkey(32 位)。按照here的回答,我执行了here的说明

我用于构建的命令行是:

PATH=$PATH:"/c/Program Files/LLVM/bin/" JS_STANDALONE=1 ../configure.in --enable-nspr-build --disable-jemalloc --disable-js-shell --disable-tests --target=i686-pc-mingw32 --host=i686-pc-mingw32 --with-libclang-path="C:/Program Files/LLVM/bin"

但是,我遇到了各种链接器错误,其中 SpiderMonkey 找不到 Rust 编码函数,例如:

lld-link: error: undefined symbol: _encoding_mem_convert_latin1_to_utf8_partial
referenced by c:\firefox_90_0\js\src\vm\CharacterEncoding.cpp:109 
..\Unified_cpp_js_src17.obj:(unsigned int __cdecl JS::DeflateStringToUTF8Buffer(class 
JSLinearString *, class mozilla::Span<char, 4294967295>))

查看 SpiderMonkey 配置文件(Cargo.toml 文件)后,在我看来,在编译期间 SpiderMonkey 应该使用 Rust 绑定构建 jsrust.lib。但实际上这并没有发生,我得到了链接器错误。有什么想法吗?

【问题讨论】:

    标签: c++ rust spidermonkey


    【解决方案1】:

    是的,你是对的,在编译 SpiderMonkey mach/mozbuild 期间构建 jsrust.lib 并将其链接到生成的 dll/js-shell 可执行文件中。

    此外,就我而言,构建 jsrust.lib 也缺少 bcrypt 导入。

    通过对源应用以下补丁可以轻松解决此问题, 这使得 mozbuild 能够遍历到 js/rust 目录,并修复了上述缺失的导入。 (在 esr91 及以上测试):

    --- a/js/src/moz.build
    +++ b/js/src/moz.build
    @@ -7,6 +7,10 @@
     include("js-config.mozbuild")
     include("js-cxxflags.mozbuild")
    
    +if CONFIG["JS_STANDALONE"]:
    +    DIRS += ["rust"]
    +    include("js-standalone.mozbuild")
    +
     # Directory metadata
     component_engine = ("Core", "JavaScript Engine")
     component_gc = ("Core", "JavaScript: GC")
    @@ -51,10 +55,7 @@ if CONFIG["ENABLE_WASM_CRANELIFT"]:
         CONFIGURE_SUBST_FILES += ["rust/extra-bindgen-flags"]
    
     if not CONFIG["JS_DISABLE_SHELL"]:
    -    DIRS += [
    -        "rust",
    -        "shell",
    -    ]
    +    DIRS += ["shell"]
    
         TEST_DIRS += [
             "gdb",
    --- a/js/src/rust/moz.build
    +++ b/js/src/rust/moz.build
    @@ -37,4 +37,5 @@ elif CONFIG["OS_ARCH"] == "WINNT":
             "shell32",
             "userenv",
             "ws2_32",
    +        "bcrypt"
         ]
    

    (该补丁可作为 gist 与经过测试的 mozbuild 配置一起使用,该配置构建一个 32 位 .dll,此处:https://gist.github.com/razielanarki/a890f21a037312a46450e244beeba983

    【讨论】:

      猜你喜欢
      • 2020-03-10
      • 2019-09-24
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多