tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

moz.configure (38923B)


      1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
      2 # vim: set filetype=python:
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 
      8 @depends(build_project)
      9 def js_standalone(build_project):
     10     if build_project == "js":
     11         return True
     12 
     13 
     14 # Debug (see Bug 939505)
     15 # ==============================================================
     16 set_define("JS_DEBUG", True, when=moz_debug)
     17 
     18 
     19 # Branding
     20 # ==============================================================
     21 option(
     22     "--with-app-name",
     23     env="MOZ_APP_NAME",
     24     nargs=1,
     25     help="Used for e.g. the binary program file name. If not set, "
     26     "defaults to a lowercase form of MOZ_APP_BASENAME",
     27 )
     28 
     29 
     30 @depends("--with-app-name", js_standalone, moz_app_basename)
     31 def moz_app_name(value, js_standalone, moz_app_basename):
     32     if value:
     33         return value[0]
     34     if js_standalone:
     35         return "js"
     36     return moz_app_basename.lower()
     37 
     38 
     39 set_config("MOZ_APP_NAME", moz_app_name)
     40 
     41 include("../build/moz.configure/nspr.configure", when="--enable-compile-environment")
     42 include("../build/moz.configure/rust.configure", when="--enable-compile-environment")
     43 include("../build/moz.configure/bindgen.configure", when="--enable-compile-environment")
     44 
     45 set_config("JS_STANDALONE", js_standalone)
     46 set_define("JS_STANDALONE", js_standalone)
     47 option(
     48     "--enable-js-shell", default=js_standalone, help="{Build|Do not build} the JS shell"
     49 )
     50 
     51 
     52 @depends("--enable-js-shell")
     53 def js_disable_shell(value):
     54     if not value:
     55         return True
     56 
     57 
     58 set_config("JS_DISABLE_SHELL", js_disable_shell)
     59 
     60 set_define("JS_64BIT", depends(target)(lambda t: t.bitness == 64 or None))
     61 
     62 set_define("JS_PUNBOX64", depends(target)(lambda t: t.bitness == 64 or None))
     63 set_define("JS_NUNBOX32", depends(target)(lambda t: t.bitness == 32 or None))
     64 
     65 
     66 # SpiderMonkey as a shared library, and how its symbols are exported
     67 # ==================================================================
     68 option(
     69     "--disable-shared-js",
     70     when=js_standalone,
     71     help="{Create|Do not create} a shared library",
     72 )
     73 
     74 option(
     75     "--disable-export-js",
     76     when=js_standalone,
     77     help="{Mark|Do not mark} JS symbols as DLL exported/visible",
     78 )
     79 
     80 
     81 @depends("--disable-shared-js", "--disable-export-js", when=js_standalone)
     82 def shared_js(shared_js, export_js):
     83     if shared_js:
     84         if not export_js:
     85             die("Must export JS symbols when building a shared library.")
     86         return True
     87 
     88 
     89 set_config("JS_SHARED_LIBRARY", shared_js)
     90 
     91 
     92 @depends(shared_js, "--disable-export-js", when=js_standalone)
     93 def exportable_js_api(shared_js, export_js):
     94     if not shared_js and export_js:
     95         return True
     96 
     97 
     98 set_define("STATIC_EXPORTABLE_JS_API", exportable_js_api)
     99 
    100 
    101 @depends(shared_js, exportable_js_api)
    102 def static_js_api(shared_js, export_js):
    103     if not shared_js and not export_js:
    104         return True
    105 
    106 
    107 set_define("STATIC_JS_API", static_js_api)
    108 
    109 
    110 @depends(shared_js)
    111 def static_js(value):
    112     if not value:
    113         return True
    114 
    115 
    116 set_define("MOZ_STATIC_JS", static_js)
    117 
    118 # Enable decorators
    119 # ===================================================
    120 option(
    121     "--enable-decorators",
    122     default=False,
    123     help="Enable experimental JS Decorators support",
    124 )
    125 
    126 
    127 @depends("--enable-decorators")
    128 def enable_decorators(value):
    129     if value:
    130         return True
    131 
    132 
    133 set_config("ENABLE_DECORATORS", enable_decorators)
    134 set_define("ENABLE_DECORATORS", enable_decorators)
    135 
    136 # Enable explicit resource management
    137 # ===================================================
    138 option(
    139     "--disable-explicit-resource-management",
    140     default=True,
    141     help="{Enable|Disable} explicit resource management",
    142 )
    143 
    144 
    145 @depends("--disable-explicit-resource-management")
    146 def enable_explicit_resource_management(value):
    147     if value:
    148         return True
    149 
    150 
    151 set_config("ENABLE_EXPLICIT_RESOURCE_MANAGEMENT", enable_explicit_resource_management)
    152 set_define("ENABLE_EXPLICIT_RESOURCE_MANAGEMENT", enable_explicit_resource_management)
    153 
    154 
    155 # Portable Baseline Intepreter
    156 # =======================================================
    157 option(
    158     "--enable-portable-baseline-interp",
    159     default=False,
    160     help="{Enable|Disable} the portable baseline interpreter",
    161 )
    162 set_define(
    163     "ENABLE_PORTABLE_BASELINE_INTERP",
    164     depends_if("--enable-portable-baseline-interp")(lambda _: True),
    165 )
    166 set_config(
    167     "ENABLE_PORTABLE_BASELINE_INTERP",
    168     depends_if("--enable-portable-baseline-interp")(lambda _: True),
    169 )
    170 
    171 # Option to always force PBL tier.
    172 option(
    173     "--enable-portable-baseline-interp-force",
    174     default=False,
    175     help="{Enable|Disable} forcing use of the portable baseline interpreter",
    176 )
    177 
    178 set_define(
    179     "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
    180     depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
    181 )
    182 set_config(
    183     "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
    184     depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
    185 )
    186 
    187 # Enable ahead-of-time-known preloaded IC bodies.
    188 option(
    189     "--enable-aot-ics",
    190     default=False,
    191     help="{Enable|Disable} including ahead-of-time corpus of CacheIR IC bodies",
    192 )
    193 
    194 set_define(
    195     "ENABLE_JS_AOT_ICS",
    196     depends_if("--enable-aot-ics")(lambda _: True),
    197 )
    198 set_config(
    199     "ENABLE_JS_AOT_ICS",
    200     depends_if("--enable-aot-ics")(lambda _: True),
    201 )
    202 
    203 # Force-on the option for AOT ICs.
    204 option(
    205     "--enable-aot-ics-force",
    206     default=False,
    207     help="{Enable|Disable} forcing the AOT ICs option on without additional configuration",
    208 )
    209 
    210 set_define(
    211     "ENABLE_JS_AOT_ICS_FORCE",
    212     depends_if("--enable-aot-ics-force")(lambda _: True),
    213 )
    214 set_config(
    215     "ENABLE_JS_AOT_ICS_FORCE",
    216     depends_if("--enable-aot-ics-force")(lambda _: True),
    217 )
    218 
    219 # Enforce AOT ICs (testing only): abort if a new IC (not in AOT corpus) is encountered.
    220 option(
    221     "--enable-aot-ics-enforce",
    222     default=False,
    223     help="{Enable|Disable} enforcing that only AOT IC corpus is used, crashing otherwise (TEST ONLY)",
    224 )
    225 
    226 set_define(
    227     "ENABLE_JS_AOT_ICS_ENFORCE",
    228     depends_if("--enable-aot-ics-enforce")(lambda _: True),
    229 )
    230 set_config(
    231     "ENABLE_JS_AOT_ICS_ENFORCE",
    232     depends_if("--enable-aot-ics-enforce")(lambda _: True),
    233 )
    234 
    235 
    236 # JIT support
    237 # =======================================================
    238 @depends(target, "--enable-portable-baseline-interp")
    239 def jit_default(target, enable_portable_baseline_interp):
    240     if enable_portable_baseline_interp:
    241         return False
    242     if target.cpu in (
    243         "x86",
    244         "x86_64",
    245         "arm",
    246         "aarch64",
    247         "mips64",
    248         "loongarch64",
    249         "riscv64",
    250     ):
    251         return True
    252     return False
    253 
    254 
    255 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
    256 
    257 
    258 @deprecated_option("--enable-ion")
    259 def report_deprecated(value):
    260     if value:
    261         die("--enable-ion is deprecated, use --enable-jit instead")
    262     else:
    263         die("--disable-ion is deprecated, use --disable-jit instead")
    264 
    265 
    266 # JIT code simulator for cross compiles
    267 # =======================================================
    268 option(
    269     "--enable-simulator",
    270     choices=("arm", "arm64", "mips64", "loong64", "riscv64"),
    271     nargs=1,
    272     help="Enable a JIT code simulator for the specified architecture",
    273 )
    274 
    275 
    276 @depends("--enable-jit", "--enable-simulator", target)
    277 def simulator(jit_enabled, simulator_enabled, target):
    278     if not jit_enabled or not simulator_enabled:
    279         return
    280 
    281     sim_cpu = simulator_enabled[0]
    282 
    283     if sim_cpu in ("arm"):
    284         if target.cpu != "x86":
    285             die("The %s simulator only works on x86." % sim_cpu)
    286 
    287     if sim_cpu in ("arm64", "mips64", "loong64", "riscv64"):
    288         if target.cpu != "x86_64" and target.cpu != "aarch64":
    289             die("The %s simulator only works on x86-64 or arm64." % sim_cpu)
    290 
    291     return namespace(**{sim_cpu: True})
    292 
    293 
    294 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
    295 set_config("JS_SIMULATOR_ARM", simulator.arm)
    296 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
    297 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
    298 set_config("JS_SIMULATOR_LOONG64", simulator.loong64)
    299 set_config("JS_SIMULATOR_RISCV64", simulator.riscv64)
    300 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
    301 set_define("JS_SIMULATOR_ARM", simulator.arm)
    302 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
    303 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
    304 set_define("JS_SIMULATOR_LOONG64", simulator.loong64)
    305 set_define("JS_SIMULATOR_RISCV64", simulator.riscv64)
    306 
    307 
    308 @depends("--enable-jit", simulator, target)
    309 def jit_codegen(jit_enabled, simulator, target):
    310     if not jit_enabled:
    311         return namespace(none=True)
    312 
    313     if simulator:
    314         return simulator
    315 
    316     if target.cpu == "aarch64":
    317         return namespace(arm64=True)
    318     elif target.cpu == "x86_64":
    319         return namespace(x64=True)
    320     elif target.cpu == "loongarch64":
    321         return namespace(loong64=True)
    322     elif target.cpu == "riscv64":
    323         return namespace(riscv64=True)
    324 
    325     return namespace(**{str(target.cpu): True})
    326 
    327 
    328 set_config("JS_CODEGEN_NONE", jit_codegen.none)
    329 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
    330 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
    331 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
    332 set_config("JS_CODEGEN_LOONG64", jit_codegen.loong64)
    333 set_config("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
    334 set_config("JS_CODEGEN_X86", jit_codegen.x86)
    335 set_config("JS_CODEGEN_X64", jit_codegen.x64)
    336 set_config("JS_CODEGEN_WASM32", jit_codegen.wasm32)
    337 
    338 set_define("JS_CODEGEN_NONE", jit_codegen.none)
    339 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
    340 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
    341 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
    342 set_define("JS_CODEGEN_LOONG64", jit_codegen.loong64)
    343 set_define("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
    344 set_define("JS_CODEGEN_X86", jit_codegen.x86)
    345 set_define("JS_CODEGEN_X64", jit_codegen.x64)
    346 set_define("JS_CODEGEN_WASM32", jit_codegen.wasm32)
    347 
    348 
    349 # Profiling
    350 # =======================================================
    351 option(
    352     "--enable-instruments",
    353     env="MOZ_INSTRUMENTS",
    354     help="Enable instruments remote profiling",
    355 )
    356 
    357 
    358 @depends("--enable-instruments", target)
    359 def instruments(value, target):
    360     if value and target.os != "OSX":
    361         die("--enable-instruments cannot be used when targeting %s", target.os)
    362     if value:
    363         return True
    364 
    365 
    366 set_config("MOZ_INSTRUMENTS", instruments)
    367 set_define("MOZ_INSTRUMENTS", instruments)
    368 
    369 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
    370 
    371 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
    372 
    373 
    374 @depends("--enable-callgrind")
    375 def callgrind(value):
    376     if value:
    377         return True
    378 
    379 
    380 set_define("MOZ_CALLGRIND", callgrind)
    381 imply_option("--enable-profiling", callgrind)
    382 
    383 
    384 @depends(milestone)
    385 def enable_profiling(milestone):
    386     return milestone.is_nightly
    387 
    388 
    389 option(
    390     "--enable-profiling",
    391     env="MOZ_PROFILING",
    392     default=enable_profiling,
    393     help="{Set|Do not set} compile flags necessary for using sampling "
    394     "profilers (e.g. shark, perf)",
    395 )
    396 
    397 
    398 @depends("--enable-profiling")
    399 def profiling(value):
    400     if value:
    401         return True
    402 
    403 
    404 with only_when("--enable-compile-environment"):
    405     imply_option("--enable-frame-pointers", True, when=profiling)
    406 
    407 
    408 @depends(profiling, target)
    409 def imply_vtune(value, target):
    410     ok_cpu = target.cpu in ["x86", "x86_64"]
    411     ok_kernel = target.kernel == "WINNT" or (
    412         target.kernel == "Linux" and target.os == "GNU"
    413     )
    414 
    415     if value and ok_cpu and ok_kernel:
    416         return True
    417 
    418 
    419 set_config("MOZ_PROFILING", profiling)
    420 set_define("MOZ_PROFILING", profiling)
    421 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
    422 
    423 
    424 @depends(milestone)
    425 def enable_execution_tracing(milestone):
    426     return milestone.is_nightly
    427 
    428 
    429 option(
    430     "--enable-execution-tracing",
    431     env="MOZ_EXECUTION_TRACING",
    432     default=enable_execution_tracing,
    433     help="{Set|Do not set} compile flags necessary for running the JS "
    434     "execution tracer",
    435 )
    436 
    437 
    438 @depends("--enable-execution-tracing")
    439 def execution_tracing(value):
    440     if value:
    441         return True
    442 
    443 
    444 set_config("MOZ_EXECUTION_TRACING", execution_tracing)
    445 set_define("MOZ_EXECUTION_TRACING", execution_tracing)
    446 
    447 
    448 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
    449 
    450 
    451 @depends("--enable-vtune")
    452 def vtune(value):
    453     if value:
    454         return True
    455 
    456 
    457 set_config("MOZ_VTUNE", vtune)
    458 set_define("MOZ_VTUNE", vtune)
    459 
    460 
    461 option(
    462     "--enable-gc-probes",
    463     env="JS_GC_PROBES",
    464     help="Turn on probes for allocation and finalization",
    465 )
    466 
    467 
    468 @depends("--enable-gc-probes")
    469 def gc_probes(value):
    470     if value:
    471         return True
    472 
    473 
    474 set_define("JS_GC_PROBES", gc_probes)
    475 
    476 
    477 option(
    478     "--enable-gczeal",
    479     default=depends(when=moz_debug)(lambda: True),
    480     help="{Enable|Disable} zealous GCing",
    481 )
    482 
    483 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
    484 
    485 
    486 # Enable breakpoint for artificial OOMs
    487 # =======================================================
    488 option(
    489     "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
    490 )
    491 
    492 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
    493 
    494 
    495 # Enable perf jitdump integration for nightly.
    496 # The following must be true for jitdump to be enabled:
    497 #   (a) --disable-jitdump was not provided.
    498 #   (b) target is Linux or Mac
    499 #   (c) milestone is a nightly build
    500 # =======================================================
    501 option(
    502     "--enable-jitdump",
    503     default=milestone.is_nightly,
    504     help="{Enable|Disable} perf jitdump integration",
    505 )
    506 
    507 
    508 @depends("--enable-jitdump", target)
    509 def ion_perf(enable_jitdump, target):
    510     is_linux_or_mac = target.kernel == "Linux" or (
    511         target.kernel == "Darwin" and target.os == "OSX"
    512     )
    513     if enable_jitdump and is_linux_or_mac:
    514         return True
    515 
    516 
    517 set_define("JS_ION_PERF", ion_perf)
    518 
    519 
    520 option(
    521     "--enable-jitspew",
    522     default=depends(when=moz_debug)(lambda: True),
    523     help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
    524 )
    525 
    526 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
    527 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
    528 
    529 # Also enable the structured spewer
    530 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
    531 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
    532 
    533 
    534 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
    535 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
    536     if not jit_enabled:
    537         return
    538 
    539     if simulator and (debug or spew):
    540         if getattr(simulator, "arm", None):
    541             return True
    542 
    543     if target.cpu == "arm" and (debug or spew):
    544         return True
    545 
    546 
    547 set_config("JS_DISASM_ARM", jit_disasm_arm)
    548 set_define("JS_DISASM_ARM", jit_disasm_arm)
    549 
    550 
    551 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
    552 def jit_disasm_riscv(jit_enabled, spew, simulator, target, debug):
    553     if not jit_enabled:
    554         return
    555 
    556     if simulator and (debug or spew):
    557         if getattr(simulator, "riscv64", None):
    558             return True
    559 
    560     if target.cpu == "riscv64" and (debug or spew):
    561         return True
    562 
    563 
    564 set_config("JS_DISASM_RISCV64", jit_disasm_riscv)
    565 set_define("JS_DISASM_RISCV64", jit_disasm_riscv)
    566 
    567 
    568 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
    569 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
    570     if not jit_enabled:
    571         return
    572 
    573     if simulator and (debug or spew):
    574         if getattr(simulator, "arm64", None):
    575             return True
    576 
    577     if target.cpu == "aarch64" and (debug or spew):
    578         return True
    579 
    580 
    581 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
    582 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
    583 
    584 # When enabled, masm will generate assumeUnreachable calls that act as
    585 # assertions in the generated code. This option is worth disabling when you
    586 # have to track mutated values through the generated code, to avoid constantly
    587 # dumping registers on and off the stack.
    588 option(
    589     "--enable-masm-verbose",
    590     default=depends(when=moz_debug)(lambda: True),
    591     help="{Enable|Disable} MacroAssembler verbosity of generated code",
    592 )
    593 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
    594 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
    595 
    596 # Architecture feature flags
    597 # =======================================================
    598 
    599 
    600 @depends(target)
    601 def has_apple_fast_wx(target):
    602     return target.kernel == "Darwin" and target.cpu == "aarch64"
    603 
    604 
    605 # On Apple Silicon macOS we use MAP_JIT with pthread_jit_write_protect_np to
    606 # implement JIT code write protection, while on iOS we use MAP_JIT with
    607 # be_memory_inline_jit_restrict_*.
    608 set_define("JS_USE_APPLE_FAST_WX", True, when=has_apple_fast_wx)
    609 
    610 
    611 # CTypes
    612 # =======================================================
    613 @depends(js_standalone)
    614 def ctypes_default(js_standalone):
    615     return not js_standalone
    616 
    617 
    618 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
    619 
    620 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
    621 
    622 set_config("BUILD_CTYPES", build_ctypes)
    623 set_define("BUILD_CTYPES", build_ctypes)
    624 
    625 set_config("JS_HAS_CTYPES", build_ctypes)
    626 set_define("JS_HAS_CTYPES", build_ctypes)
    627 
    628 
    629 @depends("--enable-ctypes", "--enable-compile-environment")
    630 def ctypes_and_compile_environment(ctypes, compile_environment):
    631     return ctypes and compile_environment
    632 
    633 
    634 include("ffi.configure", when=ctypes_and_compile_environment)
    635 
    636 # SIMD acceleration for encoding_rs
    637 # ==============================================================
    638 
    639 option(
    640     "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code"
    641 )
    642 
    643 
    644 @depends("--enable-rust-simd", target)
    645 def rust_simd(value, target):
    646     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
    647     # been properly set up outside aarch64, armv7, x86 and x86_64.
    648     if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
    649         return True
    650 
    651 
    652 set_config("MOZ_RUST_SIMD", rust_simd)
    653 set_define("MOZ_RUST_SIMD", rust_simd)
    654 
    655 # Telemetry to measure compile time and generated-code runtime
    656 # ============================================================
    657 
    658 option(
    659     "--enable-spidermonkey-telemetry",
    660     default=milestone.is_nightly,
    661     help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
    662 )
    663 
    664 set_define(
    665     "ENABLE_SPIDERMONKEY_TELEMETRY",
    666     depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
    667 )
    668 
    669 # Support for debugging code generated by wasm backends
    670 # =====================================================
    671 
    672 option(
    673     "--enable-wasm-codegen-debug",
    674     default=depends(when=moz_debug)(lambda: True),
    675     help="{Enable|Disable} debugging for wasm codegen",
    676 )
    677 
    678 set_config(
    679     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
    680 )
    681 set_define(
    682     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
    683 )
    684 
    685 # WebAssembly feature flags
    686 # ==================================================
    687 
    688 option(
    689     "--wasm-no-experimental",
    690     default=False,
    691     help="Force disable all wasm experimental features for testing",
    692 )
    693 
    694 
    695 # Support for JS PI spec.
    696 # ===========================
    697 
    698 
    699 @depends(
    700     "--enable-jit",
    701     "--enable-simulator",
    702     target,
    703 )
    704 def default_wasm_jspi(
    705     jit_enabled,
    706     simulator,
    707     target,
    708 ):
    709     if not jit_enabled:
    710         return
    711 
    712     if simulator:
    713         return simulator[0] in ("arm64", "arm", "loong64", "mips64", "riscv64")
    714 
    715     if target.cpu in (
    716         "x86_64",
    717         "x86",
    718         "aarch64",
    719         "arm",
    720         "loongarch64",
    721         "mips64",
    722         "riscv64",
    723     ):
    724         return True
    725 
    726 
    727 option(
    728     "--enable-wasm-jspi",
    729     default=default_wasm_jspi,
    730     help="{Enable|Disable} WebAssembly JS PI",
    731 )
    732 
    733 
    734 @depends(
    735     "--enable-wasm-jspi",
    736     "--enable-jit",
    737     "--enable-simulator",
    738     "--wasm-no-experimental",
    739     target,
    740 )
    741 def wasm_jspi(value, jit_enabled, simulator, no_experimental, target):
    742     if no_experimental or not value:
    743         return
    744 
    745     if not jit_enabled:
    746         die("--enable-wasm-jspi requires --enable-jit")
    747 
    748     if simulator and simulator[0] not in (
    749         "arm64",
    750         "arm",
    751         "loong64",
    752         "mips64",
    753         "riscv64",
    754     ):
    755         die(
    756             "--enable-wasm-jspi is only supported for arm64/arm/loong64/mips64/riscv64 simulators"
    757         )
    758 
    759     if target.cpu in (
    760         "x86_64",
    761         "x86",
    762         "aarch64",
    763         "arm",
    764         "loongarch64",
    765         "mips64",
    766         "riscv64",
    767     ):
    768         return True
    769 
    770     die(
    771         "--enable-wasm-jspi only possible when targeting the x86_64/x86/arm64/arm/loongarch64/mips64/riscv64 jits"
    772     )
    773 
    774 
    775 set_config("ENABLE_WASM_JSPI", wasm_jspi)
    776 set_define("ENABLE_WASM_JSPI", wasm_jspi)
    777 
    778 # Support for WebAssembly shared memory and atomics.
    779 #
    780 # This affects the JS shell only.
    781 # =====================================================
    782 
    783 option(
    784     "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
    785 )
    786 
    787 
    788 @depends("--disable-shared-memory")
    789 def enable_shared_memory(value):
    790     if value:
    791         return True
    792 
    793 
    794 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
    795 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
    796 
    797 # Support for WebAssembly SIMD
    798 # =====================================================
    799 
    800 
    801 @depends("--enable-jit", "--enable-simulator", target)
    802 def default_wasm_simd(jit_enabled, simulator, target):
    803     if not jit_enabled:
    804         return
    805 
    806     if simulator and (simulator[0] != "arm64"):
    807         return
    808 
    809     if target.cpu in ("x86_64", "x86", "aarch64"):
    810         return True
    811 
    812 
    813 option(
    814     "--enable-wasm-simd",
    815     default=default_wasm_simd,
    816     help="{Enable|Disable} WebAssembly SIMD",
    817 )
    818 
    819 
    820 @depends(
    821     "--enable-wasm-simd",
    822     "--enable-jit",
    823     "--enable-simulator",
    824     target,
    825     "--wasm-no-experimental",
    826 )
    827 def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
    828     if no_experimental or not value:
    829         return
    830 
    831     if not jit_enabled:
    832         die("--enable-wasm-simd requires --enable-jit")
    833 
    834     if simulator and (simulator[0] != "arm64"):
    835         die("--enable-wasm-simd is not supported for simulators, except arm64")
    836 
    837     if target.cpu in ("x86_64", "x86", "aarch64"):
    838         return True
    839 
    840     die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
    841 
    842 
    843 set_config("ENABLE_WASM_SIMD", wasm_simd)
    844 set_define("ENABLE_WASM_SIMD", wasm_simd)
    845 
    846 # Whether to check for field changes in WebAssembly serialization
    847 #
    848 # See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
    849 # for more background.
    850 # =====================================================================
    851 
    852 
    853 @depends(
    854     target,
    855     c_compiler,
    856     moz_debug,
    857     milestone,
    858     "--wasm-no-experimental",
    859 )
    860 def wasm_verify_serialization_for_size(
    861     target, c_compiler, debug, milestone, no_experimental
    862 ):
    863     if (
    864         debug == True
    865         and target.kernel == "Linux"
    866         and target.cpu == "x86_64"
    867         and c_compiler
    868         and c_compiler.type == "clang"
    869         and milestone.is_nightly
    870         and not no_experimental
    871     ):
    872         return True
    873     return
    874 
    875 
    876 set_define(
    877     "ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
    878 )
    879 
    880 # Support for Intel AVX instruction.
    881 #
    882 # AVX is exclusively used in WebAssembly SIMD instructions at the moment:
    883 # set direct dependency on "--enable-wasm-simd".
    884 # =====================================================
    885 
    886 
    887 @depends("--enable-wasm-simd", "--enable-simulator", target)
    888 def default_wasm_avx(wasm_simd_enabled, simulator, target):
    889     if not wasm_simd_enabled:
    890         return
    891 
    892     if simulator:
    893         return
    894 
    895     if target.cpu in ("x86_64", "x86"):
    896         return True
    897 
    898 
    899 option(
    900     "--enable-wasm-avx",
    901     default=default_wasm_avx,
    902     help="{Enable|Disable} AVX support for WebAssembly SIMD",
    903 )
    904 
    905 
    906 @depends(
    907     "--enable-wasm-avx",
    908     "--enable-wasm-simd",
    909     "--enable-simulator",
    910     target,
    911     "--wasm-no-experimental",
    912 )
    913 def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
    914     if no_experimental or not value:
    915         return
    916 
    917     if not wasm_simd_enabled:
    918         die("--enable-wasm-avx requires --enable-wasm-simd")
    919 
    920     if simulator:
    921         die("--enable-wasm-avx is not supported for simulators")
    922 
    923     if target.cpu in ("x86_64", "x86"):
    924         return True
    925 
    926     die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
    927 
    928 
    929 set_config("ENABLE_WASM_AVX", wasm_avx)
    930 set_define("ENABLE_WASM_AVX", wasm_avx)
    931 
    932 # Support for WebAssembly relaxed SIMD
    933 # =====================================================
    934 
    935 
    936 @depends("--enable-wasm-simd")
    937 def default_wasm_relaxed_simd(wasm_simd):
    938     if wasm_simd:
    939         return True
    940 
    941 
    942 option(
    943     "--enable-wasm-relaxed-simd",
    944     default=default_wasm_relaxed_simd,
    945     help="{Enable|Disable} WebAssembly relaxed SIMD",
    946 )
    947 
    948 
    949 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd")
    950 def wasm_relaxed_simd(value, wasm_simd):
    951     if not value:
    952         return
    953 
    954     if not wasm_simd:
    955         die("relaxed SIMD requires SIMD")
    956 
    957     return True
    958 
    959 
    960 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
    961 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
    962 
    963 # Support for WebAssembly intgemm private intrinsics
    964 # =====================================================
    965 
    966 
    967 @depends(target)
    968 def default_wasm_moz_intgemm(target):
    969     return target.cpu in ("x86", "x86_64", "aarch64")
    970 
    971 
    972 option(
    973     "--enable-wasm-moz-intgemm",
    974     default=default_wasm_moz_intgemm,
    975     help="{Enable|Disable} WebAssembly intgemm private intrinsics",
    976 )
    977 
    978 
    979 @depends("--enable-wasm-moz-intgemm", "--wasm-no-experimental")
    980 def wasm_moz_intgemm(value, no_experimental):
    981     if no_experimental:
    982         return
    983 
    984     if value:
    985         return True
    986 
    987 
    988 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
    989 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
    990 
    991 
    992 # Support for WebAssembly memory control.
    993 # ===========================
    994 
    995 
    996 @depends(milestone.is_nightly)
    997 def default_wasm_memory_control(is_nightly):
    998     if is_nightly:
    999         return True
   1000 
   1001 
   1002 option(
   1003     "--enable-wasm-memory-control",
   1004     default=default_wasm_memory_control,
   1005     help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
   1006 )
   1007 
   1008 
   1009 @depends("--enable-wasm-memory-control", "--wasm-no-experimental")
   1010 def wasm_memory_control(value, no_experimental):
   1011     if no_experimental or not value:
   1012         return
   1013 
   1014     return True
   1015 
   1016 
   1017 set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
   1018 set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
   1019 
   1020 
   1021 # Support for WebAssembly Branch-hinting.
   1022 # ===========================
   1023 
   1024 
   1025 option(
   1026     "--disable-wasm-branch-hinting",
   1027     default=True,
   1028     help="{Enable|Disable} WebAssembly branch hinting",
   1029 )
   1030 
   1031 set_config(
   1032     "ENABLE_WASM_BRANCH_HINTING",
   1033     depends_if("--enable-wasm-branch-hinting")(lambda x: True),
   1034 )
   1035 set_define(
   1036     "ENABLE_WASM_BRANCH_HINTING",
   1037     depends_if("--enable-wasm-branch-hinting")(lambda x: True),
   1038 )
   1039 
   1040 
   1041 # Support for WebAssembly Custom Page Sizes
   1042 # =====================================================
   1043 
   1044 
   1045 @depends(milestone.is_nightly, "--enable-simulator", target)
   1046 def default_wasm_custom_page_sizes(is_nightly, simulator, target):
   1047     if simulator and (simulator[0] != "arm64"):
   1048         return
   1049 
   1050     if is_nightly and target.cpu in ("x86_64", "x86", "aarch64"):
   1051         return True
   1052 
   1053 
   1054 option(
   1055     "--enable-wasm-custom-page-sizes",
   1056     default=default_wasm_custom_page_sizes,
   1057     help="{Enable|Disable} WebAssembly Custom Page Sizes",
   1058 )
   1059 
   1060 
   1061 @depends(
   1062     "--enable-wasm-custom-page-sizes",
   1063     "--enable-simulator",
   1064     target,
   1065     "--wasm-no-experimental",
   1066 )
   1067 def wasm_custom_page_sizes(value, simulator, target, no_experimental):
   1068     if no_experimental or not value:
   1069         return
   1070 
   1071     if simulator and (simulator[0] != "arm64"):
   1072         return
   1073 
   1074     if target.cpu in ("x86_64", "x86", "aarch64"):
   1075         return True
   1076 
   1077     die(
   1078         "--enable-wasm-custom-page-sizes only possible when targeting the x86_64/x86/arm64 jits"
   1079     )
   1080 
   1081 
   1082 set_config("ENABLE_WASM_CUSTOM_PAGE_SIZES", wasm_custom_page_sizes)
   1083 set_define("ENABLE_WASM_CUSTOM_PAGE_SIZES", wasm_custom_page_sizes)
   1084 
   1085 
   1086 # Support for readline
   1087 # =====================================================
   1088 
   1089 
   1090 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
   1091 def editline(js_shell, is_windows, compile_environment, target):
   1092     return js_shell and not is_windows and compile_environment and (target.os != "WASI")
   1093 
   1094 
   1095 option(
   1096     "--enable-readline", help="Link js shell to system readline library", when=editline
   1097 )
   1098 
   1099 has_readline = check_symbol(
   1100     "readline",
   1101     flags=["-lreadline"],
   1102     when="--enable-readline",
   1103     onerror=lambda: die("No system readline library found"),
   1104 )
   1105 
   1106 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
   1107 
   1108 
   1109 @depends("--enable-readline", editline, when=editline)
   1110 def bundled_editline(readline, editline):
   1111     return editline and not readline
   1112 
   1113 
   1114 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
   1115 
   1116 set_define("EDITLINE", True, when=editline)
   1117 
   1118 
   1119 # JIT observers
   1120 # =============
   1121 
   1122 option(
   1123     "--with-jitreport-granularity",
   1124     default="3",
   1125     choices=("0", "1", "2", "3"),
   1126     help="Default granularity at which to report JIT code to external tools "
   1127     "(0 - no info, 1 - code ranges for while functions only, "
   1128     "2 - per-line information, 3 - per-op information)",
   1129 )
   1130 
   1131 set_define(
   1132     "JS_DEFAULT_JITREPORT_GRANULARITY",
   1133     depends_if("--with-jitreport-granularity")(lambda value: value[0]),
   1134 )
   1135 
   1136 
   1137 # ECMAScript Internationalization API Support (uses ICU)
   1138 # ======================================================
   1139 system_lib_option(
   1140     "--with-system-icu",
   1141     help="Use system ICU",
   1142     when=use_pkg_config,
   1143 )
   1144 
   1145 
   1146 @depends("--with-system-icu", when=use_pkg_config)
   1147 def enable_system_icu_option(enable_system_icu):
   1148     return enable_system_icu
   1149 
   1150 
   1151 system_icu = pkg_check_modules(
   1152     "MOZ_ICU", "icu-uc icu-i18n >= 78.1", when="--with-system-icu"
   1153 )
   1154 
   1155 
   1156 @depends(enable_system_icu_option)
   1157 def in_tree_icu(system_icu):
   1158     return not system_icu
   1159 
   1160 
   1161 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
   1162 # for use for bindgen through the mozbuild crate.
   1163 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
   1164 
   1165 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
   1166 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
   1167 
   1168 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
   1169 
   1170 
   1171 @depends("--with-intl-api", js_standalone)
   1172 def check_intl_api(enabled, js_standalone):
   1173     if not enabled and not js_standalone:
   1174         die("--without-intl-api is not supported")
   1175 
   1176 
   1177 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
   1178 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
   1179 
   1180 option("--disable-icu4x", help="Disable using ICU4X")
   1181 
   1182 
   1183 @depends("--enable-icu4x", "--with-intl-api")
   1184 def check_icu4x(enabled, intl_enabled):
   1185     if not enabled and intl_enabled:
   1186         die("Can't use --disable-icu4x with --with-intl-api")
   1187 
   1188 
   1189 set_config("MOZ_ICU4X", True, when="--enable-icu4x")
   1190 set_define("MOZ_ICU4X", True, when="--enable-icu4x")
   1191 
   1192 
   1193 @depends(build_environment, when="--with-intl-api")
   1194 @imports(_from="__builtin__", _import="open")
   1195 @imports(_from="__builtin__", _import="ValueError")
   1196 def icu_version(build_env):
   1197     path = os.path.join(
   1198         build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
   1199     )
   1200     with open(path, encoding="utf-8") as fh:
   1201         for line in fh:
   1202             if line.startswith("#define"):
   1203                 define = line.split(None, 3)
   1204                 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
   1205                     try:
   1206                         return str(int(define[2]))
   1207                     except ValueError:
   1208                         pass
   1209     die("Cannot determine ICU version number from uvernum.h header file")
   1210 
   1211 
   1212 set_config("MOZ_ICU_VERSION", icu_version)
   1213 
   1214 # Source files that use ICU should have control over which parts of the ICU
   1215 # namespace they want to use.
   1216 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
   1217 
   1218 # We build ICU as a static library.
   1219 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
   1220 
   1221 
   1222 # Initial support for WebAssembly JS-API Type Reflections
   1223 # =======================================================
   1224 
   1225 
   1226 @depends(milestone.is_nightly)
   1227 def default_wasm_type_reflections(is_nightly):
   1228     return is_nightly
   1229 
   1230 
   1231 option(
   1232     "--enable-wasm-type-reflections",
   1233     default=default_wasm_type_reflections,
   1234     help="{Enable|Disable} type reflection in WASM JS-API",
   1235 )
   1236 
   1237 set_config(
   1238     "ENABLE_WASM_TYPE_REFLECTIONS",
   1239     depends_if("--enable-wasm-type-reflections")(lambda x: True),
   1240 )
   1241 set_define(
   1242     "ENABLE_WASM_TYPE_REFLECTIONS",
   1243     depends_if("--enable-wasm-type-reflections")(lambda x: True),
   1244 )
   1245 
   1246 # Support for resizable ArrayBuffer in Wasm
   1247 # =========================================
   1248 
   1249 
   1250 option(
   1251     "--disable-wasm-resizable-arraybuffer",
   1252     default=True,
   1253     help="{Enable|Disable} resizable ArrayBuffer in WASM",
   1254 )
   1255 
   1256 set_config(
   1257     "ENABLE_WASM_RESIZABLE_ARRAYBUFFER",
   1258     depends_if("--enable-wasm-resizable-arraybuffer")(lambda x: True),
   1259 )
   1260 set_define(
   1261     "ENABLE_WASM_RESIZABLE_ARRAYBUFFER",
   1262     depends_if("--enable-wasm-resizable-arraybuffer")(lambda x: True),
   1263 )
   1264 
   1265 # Wasi configuration
   1266 # ===================================================
   1267 
   1268 
   1269 @depends(target.os)
   1270 def is_wasi_target(os):
   1271     return os == "WASI"
   1272 
   1273 
   1274 set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
   1275 set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
   1276 
   1277 
   1278 @depends(milestone.version)
   1279 def js_version(version):
   1280     return Version(version)
   1281 
   1282 
   1283 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
   1284 set_define("MOZJS_MAJOR_VERSION", js_version.major)
   1285 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
   1286 set_define("MOZJS_MINOR_VERSION", js_version.minor)
   1287 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
   1288 set_config(
   1289     "MOZJS_ALPHA",
   1290     depends(js_version)(
   1291         lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
   1292     ),
   1293 )
   1294 
   1295 # Some platforms have HeapReg, some don't
   1296 # =====================================================
   1297 
   1298 # The ARM simulator runs on x86 and might be excluded by the first test,
   1299 # so we special-case it.
   1300 
   1301 
   1302 @depends("--enable-simulator", target)
   1303 def wasm_has_heapreg(simulator, target):
   1304     if target.cpu != "x86":
   1305         return True
   1306 
   1307     if simulator and simulator[0] == "arm":
   1308         return True
   1309 
   1310 
   1311 set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
   1312 
   1313 # Check for tm_zone, tm_gmtoff in struct tm
   1314 # ===================================================
   1315 with only_when(compile_environment):
   1316     set_define(
   1317         "HAVE_TM_ZONE_TM_GMTOFF",
   1318         c_compiler.try_compile(
   1319             includes=["time.h"],
   1320             body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
   1321             check_msg="for tm_zone and tm_gmtoff in struct tm",
   1322         ),
   1323     )
   1324 
   1325 
   1326 # Optimization flags
   1327 # ==============================================================
   1328 @depends(
   1329     target,
   1330     c_compiler,
   1331     configured_moz_optimize_flags,
   1332     when="--enable-compile-environment",
   1333 )
   1334 @imports(_from="mozshellutil", _import="split")
   1335 def moz_js_optimize_flags(target, compiler, configured_moz_optimize_flags):
   1336     if configured_moz_optimize_flags:
   1337         return configured_moz_optimize_flags
   1338 
   1339     if target.kernel in ("Darwin", "Linux"):
   1340         flags = ["-O3"]
   1341         if target.os == "Android" and compiler.type == "gcc":
   1342             flags += ["-fno-reorder-functions"]
   1343         return flags
   1344     elif target.kernel == "WINNT":
   1345         return ["-O2"]
   1346     else:
   1347         return ["-O"]
   1348 
   1349 
   1350 set_config("MOZ_JS_OPTIMIZE_FLAGS", moz_js_optimize_flags, when=~js_build)
   1351 set_config("MOZ_OPTIMIZE_FLAGS", moz_js_optimize_flags, when=js_build)
   1352 
   1353 
   1354 # link executables against mozglue
   1355 # ==============================================================
   1356 @depends(
   1357     target_is_android | target_is_windows | target_is_darwin,
   1358     js_standalone & ~depends(when="--enable-jemalloc")(True),
   1359 )
   1360 def moz_glue_in_program(is_excluded_target, is_js_without_jemalloc):
   1361     return not is_excluded_target and not is_js_without_jemalloc
   1362 
   1363 
   1364 set_define("MOZ_GLUE_IN_PROGRAM", True, when=moz_glue_in_program)
   1365 set_config("MOZ_GLUE_IN_PROGRAM", True, when=moz_glue_in_program)
   1366 
   1367 
   1368 # JavaScript shell
   1369 # ==============================================================
   1370 @depends(milestone.symbolversion, js_standalone)
   1371 def js_library_name(symbolversion, js_standalone):
   1372     if js_standalone:
   1373         return f"mozjs-{symbolversion}"
   1374     else:
   1375         return "mozjs"
   1376 
   1377 
   1378 set_config("JS_LIBRARY_NAME", js_library_name)
   1379 
   1380 
   1381 @depends(nspr_config.libs, nspr_pkg.libs, instruments)
   1382 def js_config_libs(nspr_libs, nspr_pkg_libs, instruments):
   1383     libs = []
   1384     if nspr_libs:
   1385         libs += nspr_libs
   1386     if nspr_pkg_libs:
   1387         libs += nspr_pkg_libs
   1388     if instruments:
   1389         libs += ["-framework", "CoreFoundation"]
   1390     return libs
   1391 
   1392 
   1393 set_config("JS_CONFIG_LIBS", js_config_libs)
   1394 
   1395 
   1396 @depends(js_library_name, c_compiler, "--libdir", when=compile_environment)
   1397 def js_config_moz_js_libs(js_library_name, compiler, libdir):
   1398     if compiler.type == "clang-cl":
   1399         return [f"{libdir[0]}/{js_library_name}.lib"]
   1400     else:
   1401         return [f"-L{libdir[0]}", f"-l{js_library_name}"]
   1402 
   1403 
   1404 set_config("JS_CONFIG_MOZ_JS_LIBS", js_config_moz_js_libs)
   1405 
   1406 #
   1407 # Checks for library functions
   1408 # ==============================================================
   1409 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
   1410     set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
   1411     set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
   1412     set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
   1413     set_define("HAVE_GETTID", check_symbol("gettid"))
   1414     set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
   1415     set_define("HAVE_SYSCALL", check_symbol("syscall"))
   1416     set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
   1417     set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
   1418     set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
   1419 
   1420     set_config(
   1421         "HAVE_LANGINFO_CODESET",
   1422         try_link(
   1423             includes=["langinfo.h"],
   1424             body="char* cs = nl_langinfo(CODESET);",
   1425             check_msg="for nl_langinfo and CODESET",
   1426             when=building_with_gnu_compatible_cc,
   1427         ),
   1428     )
   1429 
   1430     @depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
   1431     def demangle_symbols(cxa_demangle, moz_debug, dmd):
   1432         # Demangle only for debug or DMD builds
   1433         if cxa_demangle and (moz_debug or dmd):
   1434             return True
   1435 
   1436     set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
   1437 
   1438     set_define("HAVE__UNWIND_BACKTRACE", True, when=have_unwind)
   1439 
   1440 with only_when(compile_environment):
   1441     set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
   1442     set_define("HAVE_LOCALECONV", check_symbol("localeconv"))