Beispiel #1
0
def compile(**kwargs):
    print("[START] - compile")
    
    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.MOZILLA_CENTRAL_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    if not os.path.isdir(util.abspath_join(mozdir, "browser")):
        util.hg_clone(conf.MOZILLA_CENTRAL_URL, mozdir, conf.MOZILLA_CENTRAL_TAG)
    print("Using mozilla-central js/src directory: '%s'" % js_src_dir)
    
    if kwargs.get('clean', False):
        try:
            shutil.rmtree(js_src_dir)
        except OSError:
            pass
        
        util.run_command(["hg", "revert", "js/src"], cwd=mozdir)
    
    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)
    
    emconfigure = get_emconfigure_path()
    
    configure_line = [emconfigure,
                      "./configure",
                      "--disable-methodjit",
                      "--disable-monoic",
                      "--disable-polyic",
                      "--disable-tracejit",
                      "--disable-methodjit-spew",
                      "--disable-tests",
                      "--disable-debug",
                      "--disable-optimize"
                      ]
    
    makefile_path = util.abspath_join(js_src_dir, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=js_src_dir)
    
    filter_file(makefile_path, compile_filters.makefile_filters)
    
    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)
    
    MacroAssemblerX86Common_h_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path, compile_filters.MacroAssemblerX86Common_filters)
    
    MacroAssemblerX86Common_cpp_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path, compile_filters.MacroAssemblerX86Common_cpp_filters)
    
    expandlibs_config_path = util.abspath_join(js_src_dir, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path, compile_filters.expandlibs_config_filters)
    
    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)
    
    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)
    
    platform_h_path = util.abspath_join(js_src_dir, "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)
    
    pcre_exec_cpp_path = util.abspath_join(js_src_dir, "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)
    
    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)
    
    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)
    
    js_shell_bc_out = util.abspath_join(js_src_dir, "./shell/js")
    libjs_static_out = util.abspath_join(js_src_dir, "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    
    if not make_success:
        util.run_command(["make", "-C", "config"], cwd=js_src_dir)
        util.run_command(["make", "jsautocfg.h"], cwd=js_src_dir)
        
        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)
        jsautocfg_h_path = util.abspath_join(js_src_dir, "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)
        
        jsconfig_h_path = util.abspath_join(js_src_dir, "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)
        
        jsconfdefs_h_path = util.abspath_join(js_src_dir, "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)
        
        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)
        
        util.run_command(["make"], cwd=js_src_dir, added_env={"EMCC_DEBUG": "1"})
    
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)
    
    o_files = subprocess.check_output([get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=js_src_dir)
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(js_src_dir, "./shell/js.o")
    jsheaptools_o = util.abspath_join(js_src_dir, "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(js_src_dir, "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(js_src_dir, "./shell/jsworkers.o")
    util.run_command([get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out, jsheaptools_o, jsoptparse_o, jsworkers_o])
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll, js_combined_bc])
    
    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)
    
    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" % (float(os.path.getsize(js_combined_ll)) / 1024 / 1024,))
    
    print("[DONE] - compile")
Beispiel #2
0
def compile(**kwargs):
    print("[START] - compile")
    
    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    spidermonkey_build_path = util.abspath_join(js_src_dir, "results_js")
    print("Using SpiderMonkey js/src directory: '%s'" % js_src_dir)

    # clean up the spidermonkey folder   
    if os.path.exists(spidermonkey_build_path):
        shutil.rmtree(spidermonkey_build_path)
    os.makedirs(spidermonkey_build_path)
    #util.run_command(["hg", "revert"], cwd=mozdir)    
    #os.remove(util.abspath_join(js_src_dir, "configure"))
    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)
    
    emconfigure = get_emconfigure_path()
    
    configure_line = [emconfigure,
                      "../configure",
                      "--disable-methodjit",
                      "--disable-monoic",
                      "--disable-polyic",
                      "--disable-tracejit",
                      "--disable-methodjit-spew",
                      "--disable-tests",
                      "--disable-debug",
                      "--disable-optimize"
                      ]
    
    os.environ['EMCC_LLVM_TARGET'] = 'i386-pc-linux-gnu' # Avoid vaarg type issues in Emscripten

    makefile_path = util.abspath_join(spidermonkey_build_path, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=spidermonkey_build_path)
    
    filter_file(makefile_path, compile_filters.makefile_filters)
    
    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)
    
    MacroAssemblerX86Common_h_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path, compile_filters.MacroAssemblerX86Common_filters)
    
    MacroAssemblerX86Common_cpp_path = util.abspath_join(js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path, compile_filters.MacroAssemblerX86Common_cpp_filters)
    
    ExecutableAllocator_h_path = util.abspath_join(js_src_dir, "./assembler/jit/ExecutableAllocator.h")
    filter_file(ExecutableAllocator_h_path, compile_filters.ExecutableAllocator_filters)
    
    expandlibs_config_path = util.abspath_join(spidermonkey_build_path, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path, compile_filters.expandlibs_config_filters)
    
    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)
    
    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)
    
    platform_h_path = util.abspath_join(js_src_dir, "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)
    
    pcre_exec_cpp_path = util.abspath_join(js_src_dir, "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)
    
    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)
    
    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)
    
    js_shell_bc_out = util.abspath_join(spidermonkey_build_path, "./shell/js")
    libjs_static_out = util.abspath_join(spidermonkey_build_path, "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    
    if not make_success:
        js_dist_path = util.abspath_join(spidermonkey_build_path, "dist")
        if not os.path.exists(js_dist_path):
            os.makedirs(js_dist_path)
        js_bin_path = util.abspath_join(js_dist_path, "bin")
        if not os.path.islink(js_bin_path):
            os.symlink(util.abspath_join(get_native_spidermonkey_exes_path(), "dist/bin"), js_bin_path)

        util.run_command(["make", "-C", "config"], cwd=spidermonkey_build_path)
        util.run_command(["make", "jsautocfg.h"], cwd=spidermonkey_build_path)

        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)

        jsautocfg_h_path = util.abspath_join(spidermonkey_build_path, "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)
        
        jsconfig_h_path = util.abspath_join(spidermonkey_build_path, "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)
        
        jsconfdefs_h_path = util.abspath_join(spidermonkey_build_path, "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)
        
        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)
        
        build_args = ['make']
        opt_level = kwargs['O']
        if opt_level != 0:
	    build_args.extend(['-j7'])
        util.run_command(build_args, cwd=spidermonkey_build_path, added_env={"EMCC_DEBUG": "1"})
    
    make_success = os.path.exists(libjs_static_out) and os.path.exists(js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)
    
    o_files = subprocess.check_output([get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=spidermonkey_build_path)
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(spidermonkey_build_path, "./shell/js.o")
    jsheaptools_o = util.abspath_join(spidermonkey_build_path, "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(spidermonkey_build_path, "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(spidermonkey_build_path, "./shell/jsworkers.o")
    util.run_command([get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out, jsheaptools_o, jsoptparse_o, jsworkers_o])
    util.run_command([get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll, js_combined_bc])
    
    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)
    
    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" % (float(os.path.getsize(js_combined_ll)) / 1024 / 1024,))
    
    print("[DONE] - compile")
Beispiel #3
0
def compile(**kwargs):
    print("[START] - compile")

    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.MOZILLA_CENTRAL_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    if not os.path.isdir(util.abspath_join(mozdir, "browser")):
        util.hg_clone(conf.MOZILLA_CENTRAL_URL, mozdir,
                      conf.MOZILLA_CENTRAL_TAG)
    print("Using mozilla-central js/src directory: '%s'" % js_src_dir)

    if kwargs.get('clean', False):
        try:
            shutil.rmtree(js_src_dir)
        except OSError:
            pass

        util.run_command(["hg", "revert", "js/src"], cwd=mozdir)

    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)

    emconfigure = get_emconfigure_path()

    configure_line = [
        emconfigure, "./configure", "--disable-methodjit", "--disable-monoic",
        "--disable-polyic", "--disable-tracejit", "--disable-methodjit-spew",
        "--disable-tests", "--disable-debug", "--disable-optimize"
    ]

    makefile_path = util.abspath_join(js_src_dir, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=js_src_dir)

    filter_file(makefile_path, compile_filters.makefile_filters)

    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)

    MacroAssemblerX86Common_h_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path,
                compile_filters.MacroAssemblerX86Common_filters)

    MacroAssemblerX86Common_cpp_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path,
                compile_filters.MacroAssemblerX86Common_cpp_filters)

    expandlibs_config_path = util.abspath_join(
        js_src_dir, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path,
                compile_filters.expandlibs_config_filters)

    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)

    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)

    platform_h_path = util.abspath_join(js_src_dir,
                                        "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)

    pcre_exec_cpp_path = util.abspath_join(js_src_dir,
                                           "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)

    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)

    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)

    js_shell_bc_out = util.abspath_join(js_src_dir, "./shell/js")
    libjs_static_out = util.abspath_join(js_src_dir, "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)

    if not make_success:
        util.run_command(["make", "-C", "config"], cwd=js_src_dir)
        util.run_command(["make", "jsautocfg.h"], cwd=js_src_dir)

        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)
        jsautocfg_h_path = util.abspath_join(js_src_dir, "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)

        jsconfig_h_path = util.abspath_join(js_src_dir, "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)

        jsconfdefs_h_path = util.abspath_join(js_src_dir, "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)

        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)

        util.run_command(["make"],
                         cwd=js_src_dir,
                         added_env={"EMCC_DEBUG": "1"})

    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)

    o_files = subprocess.check_output(
        [get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=js_src_dir)
    util.run_command(
        [get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(js_src_dir, "./shell/js.o")
    jsheaptools_o = util.abspath_join(js_src_dir, "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(js_src_dir, "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(js_src_dir, "./shell/jsworkers.o")
    util.run_command([
        get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out,
        jsheaptools_o, jsoptparse_o, jsworkers_o
    ])
    util.run_command([
        get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll,
        js_combined_bc
    ])

    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)

    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" %
          (float(os.path.getsize(js_combined_ll)) / 1024 / 1024, ))

    print("[DONE] - compile")
Beispiel #4
0
def compile(**kwargs):
    print("[START] - compile")

    mozdir = util.abspath_join(BUILD_DIR_ABS, conf.SPIDERMONKEY_DIR)
    js_src_dir = util.abspath_join(mozdir, "js/src")
    spidermonkey_build_path = util.abspath_join(js_src_dir, "results_js")
    print("Using SpiderMonkey js/src directory: '%s'" % js_src_dir)

    # clean up the spidermonkey folder
    if os.path.exists(spidermonkey_build_path):
        shutil.rmtree(spidermonkey_build_path)
    os.makedirs(spidermonkey_build_path)
    #util.run_command(["hg", "revert"], cwd=mozdir)
    #os.remove(util.abspath_join(js_src_dir, "configure"))
    if not util.is_exe(util.abspath_join(js_src_dir, "./configure")):
        util.run_command(["autoreconf2.13"], cwd=js_src_dir)

    emconfigure = get_emconfigure_path()

    configure_line = [
        emconfigure, "../configure", "--disable-methodjit", "--disable-monoic",
        "--disable-polyic", "--disable-tracejit", "--disable-methodjit-spew",
        "--disable-tests", "--disable-debug", "--disable-optimize"
    ]

    os.environ[
        'EMCC_LLVM_TARGET'] = 'i386-pc-linux-gnu'  # Avoid vaarg type issues in Emscripten

    makefile_path = util.abspath_join(spidermonkey_build_path, "./Makefile")
    if not os.path.isfile(makefile_path):
        util.run_command(configure_line, cwd=spidermonkey_build_path)

    filter_file(makefile_path, compile_filters.makefile_filters)

    jsapi_h_path = util.abspath_join(js_src_dir, "./jsapi.h")
    filter_file(jsapi_h_path, compile_filters.jsapi_filters)

    MacroAssemblerX86Common_h_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.h")
    filter_file(MacroAssemblerX86Common_h_path,
                compile_filters.MacroAssemblerX86Common_filters)

    MacroAssemblerX86Common_cpp_path = util.abspath_join(
        js_src_dir, "./assembler/assembler/MacroAssemblerX86Common.cpp")
    filter_file(MacroAssemblerX86Common_cpp_path,
                compile_filters.MacroAssemblerX86Common_cpp_filters)

    ExecutableAllocator_h_path = util.abspath_join(
        js_src_dir, "./assembler/jit/ExecutableAllocator.h")
    filter_file(ExecutableAllocator_h_path,
                compile_filters.ExecutableAllocator_filters)

    expandlibs_config_path = util.abspath_join(
        spidermonkey_build_path, "./config/expandlibs_config.py")
    filter_file(expandlibs_config_path,
                compile_filters.expandlibs_config_filters)

    jsgcchunk_cpp_path = util.abspath_join(js_src_dir, "./jsgcchunk.cpp")
    filter_file(jsgcchunk_cpp_path, compile_filters.jsgchunk_cpp_filters)

    jsinfer_cpp_path = util.abspath_join(js_src_dir, "./jsinfer.cpp")
    filter_file(jsinfer_cpp_path, compile_filters.jsinfer_cpp_filters)

    platform_h_path = util.abspath_join(js_src_dir,
                                        "./assembler/wtf/Platform.h")
    filter_file(platform_h_path, compile_filters.platform_h_filters)

    pcre_exec_cpp_path = util.abspath_join(js_src_dir,
                                           "./yarr/pcre/pcre_exec.cpp")
    filter_file(pcre_exec_cpp_path, compile_filters.pcre_exec_cpp_filters)

    jsval_h_path = util.abspath_join(js_src_dir, "./jsval.h")
    filter_file(jsval_h_path, compile_filters.jsval_h_filters)

    jsinterp_cpp_path = util.abspath_join(js_src_dir, "./jsinterp.cpp")
    filter_file(jsinterp_cpp_path, compile_filters.jsinterp_cpp_filters)

    js_shell_bc_out = util.abspath_join(spidermonkey_build_path, "./shell/js")
    libjs_static_out = util.abspath_join(spidermonkey_build_path,
                                         "./libjs_static.a")
    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)

    if not make_success:
        js_dist_path = util.abspath_join(spidermonkey_build_path, "dist")
        if not os.path.exists(js_dist_path):
            os.makedirs(js_dist_path)
        js_bin_path = util.abspath_join(js_dist_path, "bin")
        if not os.path.islink(js_bin_path):
            os.symlink(
                util.abspath_join(get_native_spidermonkey_exes_path(),
                                  "dist/bin"), js_bin_path)

        util.run_command(["make", "-C", "config"], cwd=spidermonkey_build_path)
        util.run_command(["make", "jsautocfg.h"], cwd=spidermonkey_build_path)

        jscpucfg_h_path = util.abspath_join(js_src_dir, "./jscpucfg.h")
        filter_file(jscpucfg_h_path, compile_filters.jscpucfg_filters)

        jsautocfg_h_path = util.abspath_join(spidermonkey_build_path,
                                             "./jsautocfg.h")
        filter_file(jsautocfg_h_path, compile_filters.jscpucfg_filters)

        jsconfig_h_path = util.abspath_join(spidermonkey_build_path,
                                            "./js-config.h")
        filter_file(jsconfig_h_path, compile_filters.jsconfig_filters)

        jsconfdefs_h_path = util.abspath_join(spidermonkey_build_path,
                                              "./js-confdefs.h")
        filter_file(jsconfdefs_h_path, compile_filters.jsconfdefs_filters)

        jstypes_h_path = util.abspath_join(js_src_dir, "./jstypes.h")
        filter_file(jstypes_h_path, compile_filters.jstypes_h_filters)

        build_args = ['make']
        opt_level = kwargs['O']
        if opt_level != 0:
            build_args.extend(['-j7'])
        util.run_command(build_args,
                         cwd=spidermonkey_build_path,
                         added_env={"EMCC_DEBUG": "1"})

    make_success = os.path.exists(libjs_static_out) and os.path.exists(
        js_shell_bc_out)
    if not make_success:
        sys.stderr.write("Failed to build spidermonkey. Exiting.\n")
        sys.exit(1)

    o_files = subprocess.check_output(
        [get_llvm_ar_path(), 't', libjs_static_out]).strip().split("\n")

    js_combined_bc = util.abspath_join(BUILD_DIR_ABS, "./js_combined.bc")
    js_combined_ll = util.abspath_join(BUILD_DIR_ABS, "./js_combined.ll")
    libjs_ll = util.abspath_join(BUILD_DIR_ABS, "./libjs.ll")
    libjs_bc = util.abspath_join(BUILD_DIR_ABS, "./libjs.bc")

    command = [get_llvm_link_path(), '-o', libjs_bc]
    command.extend(o_files)
    util.run_command(command, cwd=spidermonkey_build_path)
    util.run_command(
        [get_llvm_dis_path(), '-show-annotations', '-o', libjs_ll, libjs_bc])

    js_shell_o_out = util.abspath_join(spidermonkey_build_path, "./shell/js.o")
    jsheaptools_o = util.abspath_join(spidermonkey_build_path,
                                      "./shell/jsheaptools.o")
    jsoptparse_o = util.abspath_join(spidermonkey_build_path,
                                     "./shell/jsoptparse.o")
    jsworkers_o = util.abspath_join(spidermonkey_build_path,
                                    "./shell/jsworkers.o")
    util.run_command([
        get_llvm_link_path(), '-o', js_combined_bc, libjs_bc, js_shell_o_out,
        jsheaptools_o, jsoptparse_o, jsworkers_o
    ])
    util.run_command([
        get_llvm_dis_path(), '-show-annotations', '-o', js_combined_ll,
        js_combined_bc
    ])

    if not os.path.isfile(js_combined_ll):
        sys.stderr.write("Failed to build combined LLVM file.\n")
        sys.exit(1)

    print("Built LLVM file:\n -- %s" % js_combined_ll)
    print(" -- %g MB" %
          (float(os.path.getsize(js_combined_ll)) / 1024 / 1024, ))

    print("[DONE] - compile")