【ubuntu2204】error: linking with `cc` failed: exit status: 1

$ cargo run

error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL=”C” PATH=”/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/ubuntu/.local/bin:/home/ubuntu/.cargo/bin:/usr/local/sbin:
//

“-nodefaultlibs”
= note: some arguments are omitted. use `–verbose` to show all linker arguments
= note: collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.

最後に、「collect2: fatal error: ld terminated with signal 9 [Killed]」と表示されていますが、これが、メモリ不足のエラーの模様
https://stackoverflow.com/questions/46259776/collect2-fatal-error-ld-terminated-with-signal-9-killed

swapファイルを作成すると、エラーが消えます。
$ sudo fallocate -l 1G /swapfile
$ ls -lh /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ sudo swapon –show
$ free -h