Search code examples
rustwindows-subsystem-for-linuxrust-polars

How to resolve "ld terminated with signal 9 [Killed]" on WSL?


Here are the steps I completed before failure on WSL:

Note: using Python 3.11 and rustc 1.74.0-nightly

git clone [email protected]:<username>/polars.git
cd polars
rustup toolchain install nightly --component miri
cd py-polars
make test

The log is quite verbose, and here is the latest lines of log:

🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
🐍 Not using a specific python interpreter
Ignoring adbc_driver_sqlite: markers 'extra == "adbc"' don't match your environment
Ignoring cloudpickle: markers 'extra == "cloudpickle"' don't match your environment
Ignoring connectorx: markers 'extra == "connectorx"' don't match your environment
Ignoring deltalake: markers 'extra == "deltalake"' don't match your environment
Ignoring fsspec: markers 'extra == "fsspec"' don't match your environment
Ignoring gevent: markers 'extra == "gevent"' don't match your environment
Ignoring matplotlib: markers 'extra == "matplotlib"' don't match your environment
Ignoring numpy: markers 'extra == "numpy"' don't match your environment
Ignoring openpyxl: markers 'extra == "openpyxl"' don't match your environment
Ignoring pyarrow: markers 'extra == "pandas"' don't match your environment
Ignoring pandas: markers 'extra == "pandas"' don't match your environment
Ignoring pyarrow: markers 'extra == "pyarrow"' don't match your environment
Ignoring pydantic: markers 'extra == "pydantic"' don't match your environment
Ignoring pyiceberg: markers 'extra == "pyiceberg"' don't match your environment
Ignoring pyxlsb: markers 'extra == "pyxlsb"' don't match your environment
Ignoring sqlalchemy: markers 'extra == "sqlalchemy"' don't match your environment
Ignoring pandas: markers 'extra == "sqlalchemy"' don't match your environment
Ignoring backports.zoneinfo: markers 'python_version < "3.9" and extra == "timezone"' don't match your environment
Ignoring tzdata: markers 'platform_system == "Windows" and extra == "timezone"' don't match your environment
Ignoring xlsx2csv: markers 'extra == "xlsx2csv"' don't match your environment
Ignoring xlsxwriter: markers 'extra == "xlsxwriter"' don't match your environment
Ignoring polars: markers 'extra == "all"' don't match your environment
   Compiling py-polars v0.19.6 (/home/user/projects/polars/py-polars)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/user/.rustup/toolchains/nightly-2023-08-26-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/user/projects/polars/.venv/bin:/home/user/.pyenv/plugins/pyenv-virtualenv/shims:/home/user/.pyenv/shims:/
....
"-Wl,-Bdynamic" "-ldl" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/user/.rustup/toolchains/nightly-2023-08-26-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/user/projects/polars/py-polars/target/debug/deps/libpolars.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: collect2: fatal error: ld terminated with signal 9 [Killed]
          compilation terminated.


error: could not compile `py-polars` (lib) due to previous error
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/home/user/projects/polars/.venv/bin/python" PYTHON_SYS_EXECUTABLE="/home/user/projects/polars/.venv/bin/python" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/user/projects/polars/py-polars/Cargo.toml" "--lib"`
make: *** [Makefile:23: build] Error 1

For more details on the OS, I'm using WSL (ubuntu 20.04) on Windows 11.


Solution

  • As suggested by @kmdreko, it was an out of memory issue

    I needed to dig into the default max RAM allowed on WSL, and I found it's by default 50% of total memory on Windows or 8GB.

    My PC only has 8GB RAM available, so on WSL I was not getting more than 4GB RAM by default.

    I fixed this issue by creating a .wslconfig file in my Windows Home folder (C:\Users\<UserName>) and writing the following to it:

    [wsl2]
    memory=7GB
    

    Then, the make test command completed successfully.