Skip to content

"error: linking with cc failed: exit code: 1" regression in release build with const generics #73298

Closed
@is8ac

Description

@is8ac

Const generics and release mode and Hc128Rng::seed_from_u64 and rustc 1.45.0-nightly (4bd32c9 2020-05-29) or later cause cc linking error.

To avoid the error, do any of:

  • use rustc 1.45.0-nightly (a74d186 2020-05-14) or earlier
  • remove the #![feature(const_generics)]
  • remove the Hc128Rng::seed_from_u64(42) line
  • compile in debug mode

I'm guessing that Hc128Rng::seed_from_u64 is not the only thing that will trigger this, but I have not been able to find any other examples.

Source code

#![feature(const_generics)]
use rand::SeedableRng;
use rand_hc::Hc128Rng;

fn main() {
    let _ = Hc128Rng::seed_from_u64(42);
}

Dependancies

rand = "0.7.3"
rand_hc = "0.2.0"

Error:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.cc_err_demo.5gfojped-cgu.0.rcgu.o" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.cc_err_demo.5gfojped-cgu.1.rcgu.o" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.cc_err_demo.5gfojped-cgu.2.rcgu.o" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.cc_err_demo.5gfojped-cgu.3.rcgu.o" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.cc_err_demo.5gfojped-cgu.4.rcgu.o" "-o" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.3rdszsq7ibbmb3tn.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps" "-L" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/librand_hc-a144c651cd5437de.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/librand-bec2ad1f072a8aa0.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/librand_chacha-542ae1a91c9af789.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/libppv_lite86-6c3f11be887055bf.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/librand_core-2e34a4d1d07e0522.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/libgetrandom-f56bf65617cc4079.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/liblibc-dc8395e94d7842f0.rlib" "/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/libcfg_if-bd1d23d91bf28674.rlib" "-Wl,--start-group" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-0df9faf88e74ed3b.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f9e6a5fb2e2e8cbc.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-05b3477ba39b37d9.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-fd43f1008ae3de7b.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-c69fd8a874cc6882.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-4f9ba7dc6471f5d2.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-a3adee158d70a602.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-36aa33d5b51fea85.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-8ffb67928670fecf.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-95ea48ddc44a311b.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4f5122dbbdcc70ab.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-68f423c59dc48a40.rlib" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-54580c7798bf2225.rlib" "-Wl,--end-group" "/home/isaac/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-e805fea8b8005cb4.rlib" "-Wl,-Bdynamic" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-ldl" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-ldl" "-lutil"
  = note: /usr/bin/ld: /home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4.cc_err_demo.5gfojped-cgu.4.rcgu.o: in function `cc_err_demo::main':
          cc_err_demo.5gfojped-cgu.4:(.text._ZN11cc_err_demo4main17h83b85daad37728b4E+0x27): undefined reference to `core::array::<impl core::convert::AsMut<[T]> for [T; N]>::as_mut'
          /usr/bin/ld: /home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/cc_err_demo-949370c0c3e7c5b4: hidden symbol `_ZN4core5array92_$LT$impl$u20$core..convert..AsMut$LT$$u5b$T$u5d$$GT$$u20$for$u20$$u5b$T$u3b$$u20$N$u5d$$GT$6as_mut17h6128af6739856507E' isn't defined
          /usr/bin/ld: final link failed: bad value
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error; 1 warning emitted

error: could not compile `cc_err_demo`.

Caused by:
  process didn't exit successfully: `rustc --crate-name cc_err_demo --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C metadata=949370c0c3e7c5b4 -C extra-filename=-949370c0c3e7c5b4 --out-dir /home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps -L dependency=/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps --extern rand=/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/librand-bec2ad1f072a8aa0.rlib --extern rand_hc=/home/isaac/go/src/github.com/is8ac/cc_err_demo/target/release/deps/librand_hc-a144c651cd5437de.rlib` (exit code: 1)

Version

rustc 1.46.0-nightly (feb3536eb 2020-06-09)
binary: rustc
commit-hash: feb3536eba10c2e4585d066629598f03d5ddc7c6
commit-date: 2020-06-09
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions