rust-lang / rust-lang/rustc_codegen_gcc

ICE inlining failed in call to ‘always_inline’ function body not available

Open
#828 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
1.2k
Forks
105
Avg merge
8h 20m
Merged PRs (30d)
14

Description

snippet:

//@compile-flags: --edition=2024 -Zcodegen-backend=gcc -Clink-dead-code=true
//@run-rustfix

#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::let_underscore_untyped)]
#![allow(clippy::missing_docs_in_private_items)]
#![allow(clippy::map_identity)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::unnecessary_wraps)]
#![feature(result_flattening)]

fn main() {
    // mapping to Option on Iterator
    fn option_id(x: i8) -> Option<i8> {
        Some(x)
    }
    let option_id_ref: fn(i8) -> Option<i8> = option_id;
    let option_id_closure = |x| Some(x);
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();

    // mapping to Iterator on Iterator
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();

    // mapping to Option on Option
    let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();

    // mapping to Result on Result
    let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();

    issue8734();
    issue8878();
}

fn issue8734() {
    let _ = [0u8, 1, 2, 3]
        .into_iter()
        .map(|n| match n {
            1 => [n
                .saturating_add(1)
                .saturating_add(1)
                .saturating_add(1)
                .saturating_add(1)
                .saturating_add(1)
                .saturating_add(1)
                .saturating_add(1)
                .saturating_add(1)],
            n => [n],
        })
        .flatten();
}

#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again
#[rustfmt::skip] // whitespace is important for this one
fn issue8878() {
    std::collections::HashMap::<u32, u32>::new()
        .get(&0)
        .map(|_| {
// we need some newlines
// so that the span is big enough
// for a split output of the diagnostic
            Some("")
 // whitespace beforehand is important as well
        })
        .flatten();
}

Version information

rustc 1.95.0-nightly (d222ddc4d 2026-01-23)
binary: rustc
commit-hash: d222ddc4d90743dfc1e53b610be8fc9d95893d2c
commit-date: 2026-01-23
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024 -Zcodegen-backend=gcc -Clink-dead-code=true

Program output

warning: the feature `result_flattening` has been stable since 1.89.0 and no longer requires an attribute to enable
 --> /tmp/icemaker_global_tempdir.DCV30WOGYWbd/rustc_testrunner_tmpdir_reporting.t6FVbqkY94un/mvce.rs:9:12
  |
9 | #![feature(result_flattening)]
  |            ^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default

libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs1U_NtNtCs8mkrhYlWyjl_4core9core_arch4simdNtB6_5i8x163newCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: note: : called from here
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_RNvMs4_NtCs8mkrhYlWyjl_4core3numh14saturating_addCs3e1qynuMko5_4mvce’: function body not available
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/icemaker_global_tempdir.DCV30WOGYWbd/rustc_testrunner_tmpdir_reporting.t6FVbqkY94un/rustcTWZgik/symbols.o" "<3 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/icemaker_global_tempdir.DCV30WOGYWbd/rustc_testrunner_tmpdir_reporting.t6FVbqkY94un/rustcTWZgik/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "outputfile" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: cannot open outputfile.mvce.2593c9541c790827-cgu.0.rcgu.o: No such file or directory
          rust-lld: error: cannot open outputfile.mvce.2593c9541c790827-cgu.1.rcgu.o: No such file or directory
          collect2: error: ld returned 1 exit status
          

error: aborting due to 1 previous error; 1 warning emitted


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducer in map_flatten_fixable.rs and run the reported rustc command using the gcc codegen backend and link-dead-code option. Trace the ICE and linker errors around compilation of the provided map/flatten cases. Done means the reproducer compiles and links without the inlining or missing object-file failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.