rust 如何解决WSL上的“ld terminated with signal 9 [Killed]”?

dauxcl2d  于 2023-10-20  发布在  其他
关注(0)|答案(1)|浏览(313)

以下是我在WSL失败之前完成的步骤:

**注意:**使用Python 3.11和rustc 1.74.0-nightly

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

日志非常冗长,下面是最新的几行日志:

  1. 🍹 Building a mixed python/rust project
  2. 🔗 Found pyo3 bindings with abi3 support for Python 3.8
  3. 🐍 Not using a specific python interpreter
  4. Ignoring adbc_driver_sqlite: markers 'extra == "adbc"' don't match your environment
  5. Ignoring cloudpickle: markers 'extra == "cloudpickle"' don't match your environment
  6. Ignoring connectorx: markers 'extra == "connectorx"' don't match your environment
  7. Ignoring deltalake: markers 'extra == "deltalake"' don't match your environment
  8. Ignoring fsspec: markers 'extra == "fsspec"' don't match your environment
  9. Ignoring gevent: markers 'extra == "gevent"' don't match your environment
  10. Ignoring matplotlib: markers 'extra == "matplotlib"' don't match your environment
  11. Ignoring numpy: markers 'extra == "numpy"' don't match your environment
  12. Ignoring openpyxl: markers 'extra == "openpyxl"' don't match your environment
  13. Ignoring pyarrow: markers 'extra == "pandas"' don't match your environment
  14. Ignoring pandas: markers 'extra == "pandas"' don't match your environment
  15. Ignoring pyarrow: markers 'extra == "pyarrow"' don't match your environment
  16. Ignoring pydantic: markers 'extra == "pydantic"' don't match your environment
  17. Ignoring pyiceberg: markers 'extra == "pyiceberg"' don't match your environment
  18. Ignoring pyxlsb: markers 'extra == "pyxlsb"' don't match your environment
  19. Ignoring sqlalchemy: markers 'extra == "sqlalchemy"' don't match your environment
  20. Ignoring pandas: markers 'extra == "sqlalchemy"' don't match your environment
  21. Ignoring backports.zoneinfo: markers 'python_version < "3.9" and extra == "timezone"' don't match your environment
  22. Ignoring tzdata: markers 'platform_system == "Windows" and extra == "timezone"' don't match your environment
  23. Ignoring xlsx2csv: markers 'extra == "xlsx2csv"' don't match your environment
  24. Ignoring xlsxwriter: markers 'extra == "xlsxwriter"' don't match your environment
  25. Ignoring polars: markers 'extra == "all"' don't match your environment
  26. Compiling py-polars v0.19.6 (/home/user/projects/polars/py-polars)
  27. error: linking with `cc` failed: exit status: 1
  28. |
  29. = 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:/
  30. ....
  31. "-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"
  32. = note: collect2: fatal error: ld terminated with signal 9 [Killed]
  33. compilation terminated.
  34. error: could not compile `py-polars` (lib) due to previous error
  35. 💥 maturin failed
  36. Caused by: Failed to build a native library through cargo
  37. 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"`
  38. make: *** [Makefile:23: build] Error 1

有关操作系统的更多细节,我在Windows 11上使用WSL(ubuntu 20.04)。

u5i3ibmn

u5i3ibmn1#

正如@kmdreko所建议的那样,这是一个内存不足的问题。
我需要深入研究WSL允许的默认最大RAM,我发现它默认为Windows总内存的50%或8 GB。
我的电脑只有8 GB的RAM可用,所以在WSL上我默认没有超过4GB的RAM。
我通过在Windows Home文件夹(C:\Users\<UserName>)中创建.wslconfig文件并向其中写入以下内容来修复此问题:

  1. [wsl2]
  2. memory=7GB

然后,make test命令成功完成。

相关问题