Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

armv7 exhausts memory on stage0 librustc w/ debuginfo #45854

Open
cuviper opened this issue Nov 8, 2017 · 6 comments
Open

armv7 exhausts memory on stage0 librustc w/ debuginfo #45854

cuviper opened this issue Nov 8, 2017 · 6 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. E-help-wanted Call for participation: Help is requested to fix this issue. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cuviper
Copy link
Member

cuviper commented Nov 8, 2017

I'm having trouble natively compiling rustc armv7-unknown-linux-gnueabihf with --enable-debuginfo, on both the beta and master branches. I haven't seen this on any stable release before. To reproduce the issue, I'm running on Fedora 26 armv7hl, using all default options apart from enabling debuginfo.

Building stage0 compiler artifacts (armv7-unknown-linux-gnueabihf -> armv7-unknown-linux-gnueabihf)
[...]
   Compiling rustc v0.0.0 (file:///home/jistone/rust-beta/src/librustc)
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
error: Could not compile `rustc`.

Caused by:
  process didn't exit successfully: `/home/jistone/rust-beta/build/bootstrap/debug/rustc --crate-name rustc src/librustc/lib.rs [...]` (signal: 6, SIGABRT: process abort signal)

I guess that C++ exception is probably LLVM running out of memory. This excerpt is from beta sources -- on master it also errors, but without the exception info, instead a SIGSEGV. I doubt that difference is very significant, just bad luck for who failed to allocate memory.

In either case, when I watch progress in htop, the process grows right up to 3GB virt size and then dies. That's the limit of the 32-bit user address space, of course. The resident size was just a little over 2GB at that time, so something is holding wasted memory here. It could be jemalloc, or could be extra capacity in vec/map/etc. -- I'm not sure how to tell.

My workaround for now is to use --enable-debuginfo-only-std.

(And FWIW, 32-bit i686 is not having this problem for me.)

@kennytm kennytm added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state labels Nov 8, 2017
@cuviper
Copy link
Member Author

cuviper commented Jan 8, 2018

Firefox appears to be hitting this now too, while compiling gkrust:
https://bugzilla.redhat.com/show_bug.cgi?id=1523912

@glaubitz
Copy link
Contributor

This also affects mips and mipsel on Debian which prevents us from bootstrapping the Rust compiler for these architectures. Disabling debug symbols doesn't help unfortunately, unlike on armel and armhf.

Both 32-bit MIPS architectures have unfortunately a memory limit of 2 GiB virtual address space per process.

@wzssyqa
Copy link
Contributor

wzssyqa commented Sep 1, 2018

On Debian, for some packages, we use a gcc option: --param ggc-min-expand=10 on mips/mipsel.

Does llvm have some similiar options?

@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 21, 2018
doc22940 pushed a commit to doc22940/free-desktop-sdk that referenced this issue Nov 18, 2019
Work-around for memory exhaustion on arm found on issue:
rust-lang/rust#45854
@pnkfelix
Copy link
Member

pnkfelix commented Sep 19, 2022

Visiting for wg-debugging triage

Its been so long since this issue was touched, we should have someone go and confirm that it still reproduces. I'm adding E-help-wanted to reflect that.

@rustbot label: E-help-wanted

@rustbot rustbot added the E-help-wanted Call for participation: Help is requested to fix this issue. label Sep 19, 2022
@cuviper
Copy link
Member Author

cuviper commented Sep 19, 2022

I just ran a scratch build on Fedora 35 with full debuginfo enabled, and the 32-bit targets still failed.

Here's i686 (i686-unknown-linux-gnu):
https://koji.fedoraproject.org/koji/taskinfo?taskID=92194813

error[E0786]: found invalid metadata files for crate `rustc_driver`
  --> src/librustdoc/lib.rs:41:1
   |
41 | extern crate rustc_driver;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: failed to mmap file '/builddir/build/BUILD/rustc-1.64.0-src/build/i686-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib/librustc_driver-995e686975e44b6b.so': Cannot allocate memory (os error 12)
For more information about this error, try `rustc --explain E0786`.
error: could not compile `rustdoc` due to previous error

Here's armv7hl (armv7-unknown-linux-gnueabihf):
https://koji.fedoraproject.org/koji/taskinfo?taskID=92194812

   Compiling rustdoc v0.0.0 (/builddir/build/BUILD/rustc-1.64.0-src/src/librustdoc)
error[E0786]: found invalid metadata files for crate `rustc_monomorphize` which `rustc_driver` depends on
  --> src/librustdoc/lib.rs:41:1
   |
41 | extern crate rustc_driver;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: failed to mmap file '/builddir/build/BUILD/rustc-1.64.0-src/build/armv7-unknown-linux-gnueabihf/stage1/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_monomorphize-5bd38fc25e73bfbd.rlib': Cannot allocate memory (os error 12)
error[E0786]: found invalid metadata files for crate `rustc_monomorphize` which `rustc_interface` depends on
  --> src/librustdoc/lib.rs:49:1
   |
49 | extern crate rustc_interface;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: failed to mmap file '/builddir/build/BUILD/rustc-1.64.0-src/build/armv7-unknown-linux-gnueabihf/stage1/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_monomorphize-5bd38fc25e73bfbd.rlib': Cannot allocate memory (os error 12)
error[E0786]: found invalid metadata files for crate `askama_derive` which `askama` depends on
  --> src/librustdoc/html/layout.rs:10:5
   |
10 | use askama::Template;
   |     ^^^^^^
   |
   = note: failed to mmap file '/builddir/build/BUILD/rustc-1.64.0-src/build/armv7-unknown-linux-gnueabihf/stage1-tools/release/deps/libaskama_derive-20ded99bdf04465e.so': Cannot allocate memory (os error 12)
error[E0786]: found invalid metadata files for crate `askama_derive` which `askama` depends on
  --> src/librustdoc/html/render/print_item.rs:38:5
   |
38 | use askama::Template;
   |     ^^^^^^
   |
   = note: failed to mmap file '/builddir/build/BUILD/rustc-1.64.0-src/build/armv7-unknown-linux-gnueabihf/stage1-tools/release/deps/libaskama_derive-20ded99bdf04465e.so': Cannot allocate memory (os error 12)
error: cannot determine resolution for the derive macro `Template`
  --> src/librustdoc/html/layout.rs:42:10
   |
42 | #[derive(Template)]
   |          ^^^^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports
error: cannot find attribute `template` in this scope
  --> src/librustdoc/html/layout.rs:43:3
   |
43 | #[template(path = "page.html")]
   |   ^^^^^^^^
error: cannot determine resolution for the derive macro `Template`
  --> src/librustdoc/html/render/print_item.rs:52:10
   |
52 | #[derive(Template)]
   |          ^^^^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports
error: cannot find attribute `template` in this scope
  --> src/librustdoc/html/render/print_item.rs:53:3
   |
53 | #[template(path = "print_item.html")]
   |   ^^^^^^^^
memory allocation of 2097152 bytes failed
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `rustdoc` due to 8 previous errors

(Note, the build version is the as-yet-unreleased 1.64 only because I was already doing release prep...)

@mirabilos
Copy link

According to https://salsa.debian.org/rust-team/rust/-/blob/debian/sid/debian/rules?ref_type=heads#L238 this is still a problem on many architectures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. E-help-wanted Call for participation: Help is requested to fix this issue. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants