Open
Description
If I drop this code into a src/main.rs
:
#[no_mangle]
fn i128tof32(i: u128) -> f32 {
i as _
}
#[no_mangle]
fn i128tof64(i: u128) -> f64 {
i as _
}
#[no_mangle]
fn f32toi128(i: f32) -> i128 {
i as _
}
#[no_mangle]
fn f64toi128(i: f64) -> i128 {
i as _
}
Then try to compile with
RUSTFLAGS="-Coverflow-checks=yes -Cembed-bitcode=yes -Clto=fat" cargo +nightly r --release -Zbuild-std --target=x86_64-unknown-linux-gnu
I get this pile of linker errors:
= note: /usr/bin/ld: /tmp/scratch/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-dbbd29384eda2292.rlib(compiler_builtins-dbbd29384eda2292.compiler_builtins.76a90f18db901457-cgu.1.rcgu.o): in function `compiler_builtins::float::conv::__floatuntisf':
compiler_builtins.76a90f18db901457-cgu.1:(.text._ZN17compiler_builtins5float4conv13__floatuntisf17hfc1a50ce7fce74e8E+0xa4): undefined reference to `core::panicking::panic'
/usr/bin/ld: /tmp/scratch/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-dbbd29384eda2292.rlib(compiler_builtins-dbbd29384eda2292.compiler_builtins.76a90f18db901457-cgu.1.rcgu.o): in function `compiler_builtins::float::conv::__floatuntidf':
compiler_builtins.76a90f18db901457-cgu.1:(.text._ZN17compiler_builtins5float4conv13__floatuntidf17h52065f1075830490E+0xa1): undefined reference to `core::panicking::panic'
/usr/bin/ld: /tmp/scratch/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-dbbd29384eda2292.rlib(compiler_builtins-dbbd29384eda2292.compiler_builtins.76a90f18db901457-cgu.1.rcgu.o): in function `compiler_builtins::float::conv::__floattisf':
compiler_builtins.76a90f18db901457-cgu.1:(.text._ZN17compiler_builtins5float4conv11__floattisf17hb01f6c3fe609b91dE+0xc6): undefined reference to `core::panicking::panic'
/usr/bin/ld: /tmp/scratch/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-dbbd29384eda2292.rlib(compiler_builtins-dbbd29384eda2292.compiler_builtins.76a90f18db901457-cgu.1.rcgu.o): in function `compiler_builtins::float::conv::__floattidf':
compiler_builtins.76a90f18db901457-cgu.1:(.text._ZN17compiler_builtins5float4conv11__floattidf17h80c8820ef68b8afeE+0xc5): undefined reference to `core::panicking::panic'
/usr/bin/ld: /tmp/scratch/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-dbbd29384eda2292.rlib(compiler_builtins-dbbd29384eda2292.compiler_builtins.76a90f18db901457-cgu.1.rcgu.o): in function `compiler_builtins::float::conv::__fixsfti':
compiler_builtins.76a90f18db901457-cgu.1:(.text._ZN17compiler_builtins5float4conv9__fixsfti17hfbc031ecb7549268E+0xb1): undefined reference to `core::panicking::panic'
/usr/bin/ld: /tmp/scratch/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-dbbd29384eda2292.rlib(compiler_builtins-dbbd29384eda2292.compiler_builtins.76a90f18db901457-cgu.1.rcgu.o):compiler_builtins.76a90f18db901457-cgu.1:(.text._ZN17compiler_builtins5float4conv9__fixdfti17h76053a313caec3efE+0xcc): more undefined references to `core::panicking::panic' follow
I looked at a few of the functions in question into alive2 and it seems sure that eliminating the overflow check is correct: https://alive2.llvm.org/ce/z/e68yAu
I don't really know why this manages to link without LTO. There's one panic path in many of the compiler-builtins functions with or without LTO, the linker error just only surfaces with LTO enabled.
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: An issue highlighting optimization opportunities or PRs implementing suchIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to performance of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.Issue expected to be fixed by the next major LLVM upgrade, or backported fixes