Unable to build with cargo 1.75 in Ubuntu 24.04 apt package
Describe the bug
If we use apt install cargo and build Zenoh in Ubuntu 24.04, we will run into the following error messages
Compiling zenoh-link-quic v1.2.1 (/zenoh/io/zenoh-links/zenoh-link-quic)
Compiling zenoh-plugin-storage-manager v1.2.1 (/zenoh/plugins/zenoh-plugin-storage-manager)
Compiling zenoh-ext v1.2.1 (/zenoh/zenoh-ext)
Compiling zenoh-ext-examples v1.2.1 (/zenoh/zenoh-ext/examples)
Compiling zenoh-shm v1.2.1 (/zenoh/commons/zenoh-shm)
error: could not compile `zenoh` (lib test)
Caused by:
process didn't exit successfully: `rustc --crate-name zenoh --edition=2021 zenoh/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=158 --emit=dep-info,link -C opt-level=3 -C lto=fat -C codegen-units=1 --allow=unexpected_cfgs --test --cfg 'feature="auth_pubkey"' --cfg 'feature="auth_usrpwd"' --cfg 'feature="default"' --cfg 'feature="internal"' --cfg 'feature="internal_config"' --cfg 'feature="plugins"' --cfg 'feature="runtime_plugins"' --cfg 'feature="transport_compression"' --cfg 'feature="transport_multilink"' --cfg 'feature="transport_quic"' --cfg 'feature="transport_tcp"' --cfg 'feature="transport_tls"' --cfg 'feature="transport_udp"' --cfg 'feature="transport_unixsock-stream"' --cfg 'feature="transport_ws"' --cfg 'feature="unstable"' -C metadata=f0ce4c1447320e08 -C extra-filename=-f0ce4c1447320e08 --out-dir /zenoh/target/release/deps -L dependency=/zenoh/target/release/deps --extern ahash=/zenoh/target/release/deps/libahash-42499b8a38c6c14c.rlib --extern async_trait=/zenoh/target/release/deps/libasync_trait-19f4ace7de609d06.so --extern bytes=/zenoh/target/release/deps/libbytes-b49f2968938aaa03.rlib --extern flume=/zenoh/target/release/deps/libflume-f8de40b81640a1d6.rlib --extern futures=/zenoh/target/release/deps/libfutures-8585102b7164caac.rlib --extern git_version=/zenoh/target/release/deps/libgit_version-afb3c545aa60a6e0.rlib --extern itertools=/zenoh/target/release/deps/libitertools-165bbf172ec5f94e.rlib --extern json5=/zenoh/target/release/deps/libjson5-692f1a53ec18a8c9.rlib --extern lazy_static=/zenoh/target/release/deps/liblazy_static-4d9d1683db0920f7.rlib --extern once_cell=/zenoh/target/release/deps/libonce_cell-09f653b603f35fb3.rlib --extern paste=/zenoh/target/release/deps/libpaste-912ae926039989d9.so --extern petgraph=/zenoh/target/release/deps/libpetgraph-10105e6a183861b5.rlib --extern phf=/zenoh/target/release/deps/libphf-edd48c78a8d30af1.rlib --extern rand=/zenoh/target/release/deps/librand-63951c6f79ae4877.rlib --extern ref_cast=/zenoh/target/release/deps/libref_cast-3a89995cc18bc86e.rlib --extern serde=/zenoh/target/release/deps/libserde-07e853bcc823fe5b.rlib --extern serde_json=/zenoh/target/release/deps/libserde_json-467fc4c0f710511e.rlib --extern socket2=/zenoh/target/release/deps/libsocket2-c8c84cf030c4480b.rlib --extern tokio=/zenoh/target/release/deps/libtokio-ea6617290b9cdf67.rlib --extern tokio_util=/zenoh/target/release/deps/libtokio_util-4d712e65802952e2.rlib --extern tracing=/zenoh/target/release/deps/libtracing-214f4740ec094ae9.rlib --extern uhlc=/zenoh/target/release/deps/libuhlc-155f97fee482172d.rlib --extern vec_map=/zenoh/target/release/deps/libvec_map-b6f3a83e9decec00.rlib --extern zenoh_buffers=/zenoh/target/release/deps/libzenoh_buffers-52039e9614b52764.rlib --extern zenoh_codec=/zenoh/target/release/deps/libzenoh_codec-b47d3409b6dcd56a.rlib --extern zenoh_collections=/zenoh/target/release/deps/libzenoh_collections-d2d4f7b46de5bdcc.rlib --extern zenoh_config=/zenoh/target/release/deps/libzenoh_config-e97c52c017f03602.rlib --extern zenoh_core=/zenoh/target/release/deps/libzenoh_core-27eb646a832230aa.rlib --extern zenoh_keyexpr=/zenoh/target/release/deps/libzenoh_keyexpr-c27bad8273be0553.rlib --extern zenoh_link=/zenoh/target/release/deps/libzenoh_link-9f3840df11a5c756.rlib --extern zenoh_macros=/zenoh/target/release/deps/libzenoh_macros-9dec872d54e82a75.so --extern zenoh_plugin_trait=/zenoh/target/release/deps/libzenoh_plugin_trait-afa1a82769891833.rlib --extern zenoh_protocol=/zenoh/target/release/deps/libzenoh_protocol-e989ba2720155716.rlib --extern zenoh_result=/zenoh/target/release/deps/libzenoh_result-12a21700f6685d2b.rlib --extern zenoh_runtime=/zenoh/target/release/deps/libzenoh_runtime-c1e2aafbc3f4f16f.rlib --extern zenoh_sync=/zenoh/target/release/deps/libzenoh_sync-98dcd22e2d0cde3c.rlib --extern zenoh_task=/zenoh/target/release/deps/libzenoh_task-a6ee31f9da791613.rlib --extern zenoh_transport=/zenoh/target/release/deps/libzenoh_transport-bd37e074d1b5a4a4.rlib --extern zenoh_util=/zenoh/target/release/deps/libzenoh_util-04ac90dd445f11da.rlib -L native=/zenoh/target/release/build/ring-57590b4b9c2dd97f/out` (signal: 9, SIGKILL: kill)
warning: build failed, waiting for other jobs to finish...
To reproduce
- Run a clean container:
docker run --rm -it ubuntu:24.04 bash - Install cargo:
apt update && apt install cargo - Download the code and build:
cargo build --release --all-targets
System info
- Platform: Ubuntu 24.04 docker container
I faced this issue once, but I never reproduced it again later... Even restart with a clean docker.
This is an OOM issue, see the compiler getting killed by SIGKILL
I can compile it with the cargo installed by rustup. Using cargo build --release -all-targets
Not sure about the difference between apt and rustup installation
- Version installed by
rustup
root@2a7dd2c7d055:/zenoh# rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)
- Version installed by
apt
root@5f990baa01ff:/# rustc --version
rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball)
The compiler are the same commit...
This is an OOM issue, see the compiler getting killed by SIGKILL
If the complier really gets killed due to OOM, then maybe the container that you run the build in does not have enough memory available for building zenoh?
After observing the memory usage, this is indeed related to OOM. I think we can suggest users to limit the build job number if the memory is not enough.
For example, cargo build --release --all-targets --jobs=N