Lines Matching +full:wasm32 +full:- +full:unknown +full:- +full:emscripten
4 $ ./Tools/wasm/wasm_builder.py emscripten-browser build repl
5 $ ./Tools/wasm/wasm_builder.py emscripten-node-dl build test
8 Primary build targets are "emscripten-node-dl" (NodeJS, dynamic linking),
9 "emscripten-browser", and "wasi".
11 Emscripten builds require a recent Emscripten SDK. The tools looks for an
16 and falls back to /opt/wasi-sdk.
21 ./Tools/wasm/wasm_builder.py --clean build build
55 # path to WASI-SDK root
56 WASI_SDK_PATH = pathlib.Path(os.environ.get("WASI_SDK_PATH", "/opt/wasi-sdk"))
58 # path to Emscripten SDK config file.
59 # auto-detect's EMSDK in /opt/emsdk without ". emsdk_env.sh".
60 EM_CONFIG = pathlib.Path(os.environ.setdefault("EM_CONFIG", "/opt/emsdk/.emscripten"))
63 (3, 1, 14): "https://github.com/emscripten-core/emscripten/issues/17338",
64 (3, 1, 16): "https://github.com/emscripten-core/emscripten/issues/17393",
65 (3, 1, 20): "https://github.com/emscripten-core/emscripten/issues/17720",
73 run "make clean -C '{SRCDIR}'".
77 Builds require a C compiler (gcc, clang), make, pkg-config, and development
80 Debian/Ubuntu: sudo apt install build-essential git curl pkg-config zlib1g-dev
81 Fedora/CentOS: sudo dnf install gcc make git-core curl pkgconfig zlib-devel
85 wasm32-emscripten builds need Emscripten SDK. Please follow instructions at
86 https://emscripten.org/docs/getting_started/downloads.html how to install
87 Emscripten and how to activate the SDK with "emsdk_env.sh".
89 git clone https://github.com/emscripten-core/emsdk.git /path/to/emsdk
97 wasm32-wasi builds need WASI SDK. Please fetch the latest SDK from
98 https://github.com/WebAssembly/wasi-sdk/releases and install it to
99 "/opt/wasi-sdk". Alternatively you can install the SDK in a different location
105 wasm32-wasi tests require wasmtime on PATH. Please follow instructions at
112 ) -> Tuple[pathlib.PurePath, pathlib.PurePath]:
115 The ".emscripten" config file is a Python snippet that uses "EM_CONFIG"
116 environment variable. EMSCRIPTEN_ROOT is the "upstream/emscripten"
121 with open(emconfig, encoding="utf-8") as f:
134 def read_python_version(configure: pathlib.Path = CONFIGURE) -> str:
141 with configure.open(encoding="utf-8") as f:
171 """Platform-specific settings
173 - CONFIG_SITE override
174 - configure wrapper (e.g. emconfigure)
175 - make wrapper (e.g. emmake)
176 - additional environment variables
177 - check function to verify SDK
191 def getenv(self, profile: "BuildProfile") -> dict:
211 # skip pkg-config check on macOS
212 if not shutil.which("pkg-config"):
213 raise MissingDependency("pkg-config", INSTALL_NATIVE)
217 subprocess.check_call(["pkg-config", "--exists", devel])
239 raise MissingDependency("Emscripten SDK EM_CONFIG", INSTALL_EMSDK)
241 emconfigure = EMSCRIPTEN.configure_wrapper
245 version_txt = EMSCRIPTEN_ROOT / "emscripten-version.txt"
250 if version.endswith("-git"):
251 # git / upstream / tot-upstream installation
252 version = version[:-4]
257 f"Emscripten SDK {version} in '{EMSCRIPTEN_ROOT}' is older than "
266 f"Emscripten SDK {version} in '{EMSCRIPTEN_ROOT}' has known "
278 EMSCRIPTEN = Platform( variable
279 "emscripten",
281 config_site=WASMTOOLS / "config.site-wasm32-emscripten",
287 # workaround for https://github.com/emscripten-core/emscripten/issues/17635
297 wasm_ld = WASI_SDK_PATH / "bin" / "wasm-ld"
309 config_site=WASMTOOLS / "config.site-wasm32-wasi",
310 configure_wrapper=WASMTOOLS / "wasi-env",
319 "--env PYTHONPATH=/{relbuilddir}/build/lib.wasi-wasm32-{version}:/Lib "
320 "--mapdir /::{srcdir} --"
331 wasm32_emscripten = "wasm32-unknown-emscripten"
332 wasm64_emscripten = "wasm64-unknown-emscripten"
333 wasm32_wasi = "wasm32-unknown-wasi"
334 wasm64_wasi = "wasm64-unknown-wasi"
339 def platform(self) -> Platform:
341 return EMSCRIPTEN
348 def is_emscripten(self) -> bool:
353 def is_wasi(self) -> bool:
357 def get_extra_paths(self) -> Iterable[pathlib.PurePath]:
358 """Host-specific os.environ["PATH"] entries.
360 Emscripten's Node version 14.x works well for wasm32-emscripten.
361 wasm64-emscripten requires more recent v8 version, e.g. node 16.x.
374 def emport_args(self) -> List[str]:
375 """Host-specific port args (Emscripten)."""
378 return ["-sMEMORY64=1"]
380 return ["-sMEMORY64=0"]
385 def embuilder_args(self) -> List[str]:
386 """Host-specific embuilder args (Emscripten)."""
389 return ["--wasm64"]
395 """Emscripten-specific targets (--with-emscripten-target)"""
398 browser_debug = "browser-debug"
400 node_debug = "node-debug"
408 def emport_args(self) -> List[str]:
409 """Target-specific port args."""
412 # some libs come in debug and non-debug builds
413 return ["-O0"]
415 return ["-O2"]
437 default_testopts: str = "-j2"
440 def is_browser(self) -> bool:
445 def builddir(self) -> pathlib.Path:
450 def python_cmd(self) -> pathlib.Path:
455 def makefile(self) -> pathlib.Path:
460 def configure_cmd(self) -> List[str]:
465 cmd = [configure, "-C"]
470 cmd.append(f"--host={self.host.value}")
471 cmd.append(f"--build={Host.build.value}")
475 cmd.append(f"--with-emscripten-target={self.target.value}")
480 cmd.append(f"--{opt}-wasm-dynamic-linking")
485 cmd.append(f"--{opt}-wasm-pthreads")
488 cmd.append(f"--with-build-python={BUILD.python_cmd}")
496 def make_cmd(self) -> List[str]:
504 def getenv(self) -> dict:
507 env.setdefault("MAKEFLAGS", f"-j{os.cpu_count()}")
581 "--eval", f"run: all; $(HOSTRUNNER) ./$(PYTHON) {shlex.join(args)}", "run"
591 "--bind",
593 "--port",
624 """Pre-build emscripten ports."""
632 embuilder_cmd.append("--force")
641 ports_cmd.append("-sMAIN_MODULE")
642 embuilder_cmd.append("--pic")
645 # Trigger multi-threaded build.
646 ports_cmd.append("-sUSE_PTHREADS")
648 # Pre-build libbz2, libsqlite3, libz, and some system libs.
649 ports_cmd.extend(["-sUSE_ZLIB", "-sUSE_BZIP2", "-sUSE_SQLITE3"])
650 # Multi-threaded sqlite3 has different suffix
652 ["build", "bzip2", "sqlite3-mt" if self.pthreads else "sqlite3", "zlib"]
657 with tempfile.TemporaryDirectory(suffix="-py-emport") as tmpdir:
665 "-o",
680 # wasm32-emscripten
682 "emscripten-browser",
689 "emscripten-browser-debug",
696 "emscripten-node-dl",
703 "emscripten-node-dl-debug",
710 "emscripten-node-pthreads",
717 "emscripten-node-pthreads-debug",
723 # Emscripten build with both pthreads and dynamic linking is crashing.
725 "emscripten-node-dl-pthreads-debug",
732 # wasm64-emscripten (requires Emscripten >= 3.1.21)
734 "wasm64-emscripten-node-debug",
742 # wasm32-wasi
750 # "wasm64-wasi",
765 "--clean",
766 "-c",
772 "--verbose",
773 "-v",
779 "--silent",
785 "--testopts",
788 "--testopts='-v test_os'."
813 emports="build Emscripten port with embuilder (only Emscripten)",
839 cm_args = ("--silent",) if args.silent else ()
858 # auto-build
862 logger.info("Auto-building 'build' Python.")
870 # build Emscripten ports with embuilder