Repository: pyodide/pyodide

Issue:
`pywasmcross` does not proxy `strip`
## 🐛 Bug

Calls to the `strip` executable invoke the GNU implementation rather than `emstrip`

## Proposed Fix

Shim `strip` in addition to `c++` etc.

### Environment

- Pyodide Version<!-- (e.g. 1.8.1) -->: 0.21.0
- Browser version<!-- (e.g. Chrome 95.0.4638.54) -->: NA
- Any other relevant information:

<!-- If you are building Pyodide by yourself, please also include these information: -->

<!--
- Commit hash of Pyodide git repository:
- Build environment<!--(e.g. Ubuntu 18.04, pyodide/pyodide-env:19 docker)- ->:
-->



Discussion:
This is probably a reasonable idea. Could you provide a bit more information on what you were doing when this problem came up?
Hi @hoodmane! Apologies for not including a reproducer. I'm working on generating a WASM module for https://github.com/scikit-hep/awkward/, and I've found that symbols are being stripped as part of the build process, which I think is coming from pybind11's `pybind11_add_module`.

Resolving patch:
diff --git a/pyodide-build/pyodide_build/pywasmcross.py b/pyodide-build/pyodide_build/pywasmcross.py
--- a/pyodide-build/pyodide_build/pywasmcross.py
+++ b/pyodide-build/pyodide_build/pywasmcross.py
@@ -17,7 +17,7 @@
 
 INVOKED_PATH = Path(INVOKED_PATH_STR)
 
-SYMLINKS = {"cc", "c++", "ld", "ar", "gcc", "gfortran", "cargo"}
+SYMLINKS = {"cc", "c++", "ld", "ar", "gcc", "ranlib", "strip", "gfortran", "cargo"}
 IS_COMPILER_INVOCATION = INVOKED_PATH.name in SYMLINKS
 
 if IS_COMPILER_INVOCATION:
@@ -547,6 +547,12 @@ def handle_command_generate_args(
         # distutils doesn't use the c++ compiler when compiling c++ <sigh>
         if any(arg.endswith((".cpp", ".cc")) for arg in line):
             new_args = ["em++"]
+    elif cmd == "ranlib":
+        line[0] = "emranlib"
+        return line
+    elif cmd == "strip":
+        line[0] = "emstrip"
+        return line
     else:
         return line
 


Test patch:
diff --git a/pyodide-build/pyodide_build/tests/test_pywasmcross.py b/pyodide-build/pyodide_build/tests/test_pywasmcross.py
--- a/pyodide-build/pyodide_build/tests/test_pywasmcross.py
+++ b/pyodide-build/pyodide_build/tests/test_pywasmcross.py
@@ -45,13 +45,16 @@ def _inner(line, *pargs):
 def generate_args(line: str, args: Any, is_link_cmd: bool = False) -> str:
     splitline = line.split()
     res = handle_command_generate_args(splitline, args, is_link_cmd)
-    for arg in [
-        "-Werror=implicit-function-declaration",
-        "-Werror=mismatched-parameter-types",
-        "-Werror=return-type",
-    ]:
-        assert arg in res
-        res.remove(arg)
+
+    if res[0] in ("emcc", "em++"):
+        for arg in [
+            "-Werror=implicit-function-declaration",
+            "-Werror=mismatched-parameter-types",
+            "-Werror=return-type",
+        ]:
+            assert arg in res
+            res.remove(arg)
+
     if "-c" in splitline:
         include_index = res.index("python/include")
         del res[include_index]
@@ -70,7 +73,20 @@ def test_handle_command():
         "echo",
         "wasm32-emscripten",
     ]
-    assert generate_args("gcc test.c", args) == "emcc test.c"
+
+    proxied_commands = {
+        "cc": "emcc",
+        "c++": "em++",
+        "gcc": "emcc",
+        "ld": "emcc",
+        "ar": "emar",
+        "ranlib": "emranlib",
+        "strip": "emstrip",
+    }
+
+    for cmd, proxied_cmd in proxied_commands.items():
+        assert generate_args(cmd, args) == proxied_cmd
+
     assert (
         generate_args("gcc -c test.o -o test.so", args, True)
         == "emcc -c test.o -o test.so"