From 4c0b872d8c555ded957e19f55b52d637427532f6 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 21 Dec 2024 04:31:01 +0530 Subject: [PATCH] Use Emscripten's `llvm-readobj` by default (#73) Co-authored-by: Joe Marshall Co-authored-by: Hood Chatham --- pyodide_build/pywasmcross.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pyodide_build/pywasmcross.py b/pyodide_build/pywasmcross.py index 76ee51b..e3c54e6 100755 --- a/pyodide_build/pywasmcross.py +++ b/pyodide_build/pywasmcross.py @@ -339,12 +339,21 @@ def _calculate_object_exports_readobj_parse(output: str) -> list[str]: def calculate_object_exports_readobj(objects: list[str]) -> list[str] | None: import shutil - readobj_path = shutil.which("llvm-readobj") + # This works for bootstrapped Emscripten via GitHub sources. + # llvm-readobj might not be available this way with Homebrew + # or conda-forge distributions of Emscripten. + which_emcc = shutil.which("emcc") + assert which_emcc + emcc = Path(which_emcc) + readobj = (emcc / "../../bin/llvm-readobj").resolve() + if readobj.exists(): + readobj_path = str(readobj) + else: + readobj_path = shutil.which("llvm-readobj") if not readobj_path: - which_emcc = shutil.which("emcc") - assert which_emcc - emcc = Path(which_emcc) - readobj_path = str((emcc / "../../bin/llvm-readobj").resolve()) + print("Failed to find llvm-readobj, quitting", file=sys.stdout) + sys.exit(1) + args = [ readobj_path, "--section-details",