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

Undefined symbol _fltused when compiling to x86_64-unknown-uefi #62785

Closed
IsaacWoods opened this issue Jul 18, 2019 · 18 comments · Fixed by rust-lang/compiler-builtins#317
Closed
Assignees
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc O-x86_64 Target: x86-64 processors (like x86_64-*) P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@IsaacWoods
Copy link
Contributor

Recent nightlies give the following linker error when trying to compile with the x86_64-unknown-uefi target:

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "link" "/NOLOGO" "/NXCOMPAT" "/nodefaultlib" "/entry:efi_main" "/subsystem:efi_applic
ation" "/LIBPATH:/home/isaac/Documents/pebble/bootloader/target/sysroot/lib/rustlib/x86_64-unknown-uefi/lib" "/home/
isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17p
m2976-cgu.0.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb38
8c983ab7c215.bootloader.17pm2976-cgu.1.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/r
elease/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.10.rcgu.o" "/home/isaac/Documents/pebble/bootloader/
target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.11.rcgu.o" "/home/isaac/
Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-
cgu.12.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983
ab7c215.bootloader.17pm2976-cgu.13.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/relea
se/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.14.rcgu.o" "/home/isaac/Documents/pebble/bootloader/targ
et/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.15.rcgu.o" "/home/isaac/Docu
ments/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.
2.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c2
15.bootloader.17pm2976-cgu.3.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/dep
s/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.4.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_
64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.5.rcgu.o" "/home/isaac/Documents/pe
bble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.6.rcgu.o
" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.bootl
oader.17pm2976-cgu.7.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/bootlo
ader-cb388c983ab7c215.bootloader.17pm2976-cgu.8.rcgu.o" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unkno
wn-uefi/release/deps/bootloader-cb388c983ab7c215.bootloader.17pm2976-cgu.9.rcgu.o" "/OUT:/home/isaac/Documents/pebbl
e/bootloader/target/x86_64-unknown-uefi/release/deps/bootloader-cb388c983ab7c215.efi" "/OPT:REF,ICF" "/DEBUG" "/LIBP
ATH:/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps" "/LIBPATH:/home/isaac/Documents
/pebble/bootloader/target/release/deps" "/LIBPATH:/home/isaac/Documents/pebble/bootloader/target/sysroot/lib/rustlib
/x86_64-unknown-uefi/lib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/libx86_64
-e73f78284a1860d7.rlib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/libbitflags
-094ae181fdaa32fd.rlib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/libmer-507c
9f2f8b4d808b.rlib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/libscroll-363628
fffd45fc02.rlib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/libbit_field-0de0b
ae1c29c3197.rlib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/liblog-7dddffb9af
6bf12e.rlib" "/home/isaac/Documents/pebble/bootloader/target/x86_64-unknown-uefi/release/deps/libcfg_if-6874da1a7a9e
b04a.rlib" "/home/isaac/Documents/pebble/bootloader/target/sysroot/lib/rustlib/x86_64-unknown-uefi/lib/librustc_std_
workspace_core-34dfaa25be8aa12b.rlib" "/home/isaac/Documents/pebble/bootloader/target/sysroot/lib/rustlib/x86_64-unk
nown-uefi/lib/libcore-6847ba0a79455c40.rlib" "/home/isaac/Documents/pebble/bootloader/target/sysroot/lib/rustlib/x86
_64-unknown-uefi/lib/libcompiler_builtins-0eac2e6da53df529.rlib"
  = note: rust-lld: error: undefined symbol: _fltused
          >>> referenced by libcore-6847ba0a79455c40.rlib(core-6847ba0a79455c40.core.e2k58cht-cgu.12.rcgu.o)
          >>> referenced by libcore-6847ba0a79455c40.rlib(core-6847ba0a79455c40.core.e2k58cht-cgu.15.rcgu.o)
          >>> referenced by libcore-6847ba0a79455c40.rlib(core-6847ba0a79455c40.core.e2k58cht-cgu.5.rcgu.o)
          >>> referenced by libcore-6847ba0a79455c40.rlib(core-6847ba0a79455c40.core.e2k58cht-cgu.6.rcgu.o)
          >>> referenced by libcore-6847ba0a79455c40.rlib(core-6847ba0a79455c40.core.e2k58cht-cgu.3.rcgu.o)
          >>> referenced by libcore-6847ba0a79455c40.rlib(core-6847ba0a79455c40.core.e2k58cht-cgu.10.rcgu.o)
          >>> referenced by libcompiler_builtins-0eac2e6da53df529.rlib(compiler_builtins-0eac2e6da53df529.compiler_b
uiltins.6cufwy9q-cgu.0.rcgu.o)

My guess at likely causes is this commit to compiler-builtins. The project itself does not use any floating-point operations so I'm surprised that any code that refers to this symbol is included in the final executable.

I'm not sure what the best fix for this would be (assuming this isn't intended behaviour), but adding this somewhere in the project works in the meantime:

#[used]
#[no_mangle]
pub static _fltused: i32 = 0;
@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-x86_64 Target: x86-64 processors (like x86_64-*) regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 18, 2019
@nikomatsakis nikomatsakis added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jul 25, 2019
@nikomatsakis
Copy link
Contributor

Update from compiler-team:

Marking as high priority but the most obvious next step would be to bisect this and validate which PR caused the problem. The cargo-bisect-rustc tool could be very helpful here.

cc @varkor, since the commit cited above was from them, though it's not clear to me if that is the true cause

@nikomatsakis nikomatsakis added the P-high High priority label Jul 25, 2019
@jonas-schievink jonas-schievink added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Aug 15, 2019
@pnkfelix
Copy link
Member

triage: Assigning to self to at least handle the bisection, since this seems like it fell off our radar over past month+

@pnkfelix pnkfelix self-assigned this Sep 12, 2019
@oli-obk oli-obk assigned oli-obk and unassigned pnkfelix Sep 12, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Sep 12, 2019

I'll bisect tomorrow. I need to learn the bisection ropes anyway for sth else.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Sep 12, 2019

It seems like the first step is to reproduce the problem at all! I guess maybe I need to do some research into how this works, but I was not able to install the x86_64-unknown-uefi toolchain:

> rustup target install x86_64-unknown-uefi
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not contain component 'rust-std' for target 'x86_64-unknown-uefi'

I was also not able to build a project, even a #![no_std] one, due to not having the standard library available. Not sure what the steps are? Maybe @IsaacWoods could post a few more details as to what steps to take to reproduce the problem? (Or a link to their project?)

@joshtriplett
Copy link
Member

At the moment, the uefi target requires cargo xbuild as it doesn't have a pre-built libcore.

@jyao1, can you take a look at this?

@12101111
Copy link
Contributor

#![no_std]
#![no_main]

#[no_mangle]
pub extern "C" fn efi_main() -> f32 {
    2.0*3.0
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop{}
}

This isn't a valid UEFI application, but it will triger this link error.
We can build it using cargo xbuild or using cargo build -Z build-std=core In recent nightly,

@12101111
Copy link
Contributor

modify cargo-bisect-rustc to download rust-src: rust-lang/cargo-bisect-rustc#35

Run:env RUST_SRC_REPO=~/rust/ cargo-bisect-rustc --test-dir=./ --with-src -v --prompt --start=4b65a86ebace8600c8e269e8bfe3365cdc460e68 --end=bc2e84ca0939b73fcf1768209044432f6a15c2e5 -- xbuild

Result:
searched toolchains 4b65a86 through bc2e84c
regression in 38798c6

The problem is in #62592

@12101111
Copy link
Contributor

All commits related to symbol _fltused is
rust-lang/llvm-project@2c36240
rust-lang/llvm-project@5cf6665
rust-lang/llvm-project@c20a576
One comment is:

// Define _fltused, since we're not linking against the MS C runtime, but use
// floats.
extern "C" int _fltused = 0;

If I understand correctly, rust with target x86_64-unknown-uefi don't link to msvcrt, but use msvc ABI, so symbol _fltused should provided by libcore when target is x86_64-unknown-uefi.

@joshtriplett
Copy link
Member

@12101111 Thanks for the analysis!

It sounds like _fltused serves as a marker to make sure people don't use floating-point without initialization. I don't think core should be using floating point internally; shouldn't we only emit a reference to _fltused if the program uses floating-point? (Your example used f32 as the return type of efi_main; if you drop that, does the build still fail?)

@12101111
Copy link
Contributor

12101111 commented Sep 13, 2019

This code don't use floating point and build successfully.

#![no_std]
#![no_main]

#[no_mangle]
pub extern "C" fn efi_main() -> i32 {
    0
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop{}
}

But core::fmt does use floating point.
This code don't build:

#![no_std]
#![no_main]
use core::fmt::{Write,Error};

struct Dummy;

impl Write for Dummy {
    fn write_str(&mut self, _s: &str) -> Result<(), Error>{
        Ok(())
    }
}

#[no_mangle]
pub extern "C" fn efi_main() -> i32 {
    write!(Dummy,"Hello, world!").unwrap();
    0
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop{}
}

Edit: lto can remore some floating point usage in libcore.
without lto:

  = note: rust-lld: error: undefined symbol: _fltused
          >>> referenced by libcore-387d67bcba869bf3.rlib(core-387d67bcba869bf3.core.eqirtc3x-cgu.12.rcgu.o)
          >>> referenced by libcore-387d67bcba869bf3.rlib(core-387d67bcba869bf3.core.eqirtc3x-cgu.15.rcgu.o)
          >>> referenced by libcore-387d67bcba869bf3.rlib(core-387d67bcba869bf3.core.eqirtc3x-cgu.5.rcgu.o)
          >>> referenced by libcore-387d67bcba869bf3.rlib(core-387d67bcba869bf3.core.eqirtc3x-cgu.3.rcgu.o)
          >>> referenced by libcore-387d67bcba869bf3.rlib(core-387d67bcba869bf3.core.eqirtc3x-cgu.6.rcgu.o)
          >>> referenced by libcore-387d67bcba869bf3.rlib(core-387d67bcba869bf3.core.eqirtc3x-cgu.10.rcgu.o)
          >>> referenced by libcompiler_builtins-637c246e97e0523a.rlib(compiler_builtins-637c246e97e0523a.compiler_builtins.1b68nlie-cgu.0.rcgu.o)

with lto=true: build successfully.

In another big project, without lto:

= note: rust-lld: error: undefined symbol: _fltused
          >>> referenced by libcore-f5b7a77eb654a8d8.rlib(core-f5b7a77eb654a8d8.core.em6utcdz-cgu.12.rcgu.o)
          >>> referenced by libcore-f5b7a77eb654a8d8.rlib(core-f5b7a77eb654a8d8.core.em6utcdz-cgu.4.rcgu.o)
          >>> referenced by libcore-f5b7a77eb654a8d8.rlib(core-f5b7a77eb654a8d8.core.em6utcdz-cgu.5.rcgu.o)
          >>> referenced by libcore-f5b7a77eb654a8d8.rlib(core-f5b7a77eb654a8d8.core.em6utcdz-cgu.6.rcgu.o)
          >>> referenced by libcompiler_builtins-a3650b8e38116036.rlib(compiler_builtins-a3650b8e38116036.compiler_builtins.6dh2mb61-cgu.15.rcgu.o)
          >>> referenced by libcore-f5b7a77eb654a8d8.rlib(core-f5b7a77eb654a8d8.core.em6utcdz-cgu.3.rcgu.o)
          >>> referenced by libcore-f5b7a77eb654a8d8.rlib(core-f5b7a77eb654a8d8.core.em6utcdz-cgu.10.rcgu.o)
          >>> referenced by libcompiler_builtins-a3650b8e38116036.rlib(compiler_builtins-a3650b8e38116036.compiler_builtins.6dh2mb61-cgu.1.rcgu.o)
          >>> referenced by libcompiler_builtins-a3650b8e38116036.rlib(compiler_builtins-a3650b8e38116036.compiler_builtins.6dh2mb61-cgu.0.rcgu.o)

with lto=true:

  = note: rust-lld: error: undefined symbol: _fltused
          >>> referenced by libcompiler_builtins-a3650b8e38116036.rlib(compiler_builtins-a3650b8e38116036.compiler_builtins.6dh2mb61-cgu.15.rcgu.o)
          >>> referenced by libcompiler_builtins-a3650b8e38116036.rlib(compiler_builtins-a3650b8e38116036.compiler_builtins.6dh2mb61-cgu.1.rcgu.o)

@jyao1
Copy link
Contributor

jyao1 commented Sep 13, 2019

It is caused by LLVM fixing emission of _fltused for MSVC.
Reference: https://reviews.llvm.org/D56548

The current UEFI BIOS (EDKII - written in C) meets similar issue when it is built with LLVM10.
The solution in UEFI BIOS is to define _fltused symbol in the UEFI base library code.

@jyao1
Copy link
Contributor

jyao1 commented Sep 13, 2019

https://reviews.llvm.org/D56548 changed the policy to generate _fltused symbol - "It should be emitted when any floating-point operations (including calls) are present in the object, not just when calls to printf/scanf with floating point args are made."

To resolve the x86_64-unknown-uefi issue, we may have below possible options:

  1. Let LLVM not generate _fltused.
    1.1) Add option to force LLVM not to generate _fltused in MSVC, because we use MSVC tool chain only but not link MSVC library. It seems need update in LLVM project. The benefit is that we can use LLVM MSVC to build other embedded project with NODEFAULTLIB option.
    1.2) Use non-MSVC target for UEFI. Not sure if GNU is an option. The default X64 calling convention between MSVC and GNU is different. Not sure if it is configurable.
    1.3) Write UEFI RUST program carefully to avoid _fltused. That is very hard. Even simple core::fmt::{write}, *.as_ptr(), or core::ptr::write_bytes() will generate _fltused. Not a practical option.

  2. Add _fltused symbol.
    2.1) Add target_os specific symbol in rust. (rust repo such as libcore, or compiler-builtins repo.). But I am not sure how to expose it for uefi specific target_os. [cfg(all(target_os = “uefi”))] seems not work because we still use linux or windows toolchain, to build uefi target.
    2.2) Add UEFI Intrinsic lib as standalone crate. That seems an easy option. The good thing is that it is extensible, if there are other compiler intrinsics needed in the future. But it may bring some confusing because the intrinsic is not really for UEFI, but for all embedded project without default lib.
    2.3) Add symbol in each UEFI rust program, if it does not link to UEFI instrinsic lib.

@joshtriplett
Copy link
Member

Ah, it seems unfortunate that using a format function triggers this even if not trying to format floats. (Though the LTO results seem encouraging.) In that case, yeah, I would suggest adding the LLVM option long-term, and until then, I think it makes sense to just define this in core internally.

target_os should work given that you use the uefi target; it defines the target OS as "uefi". (Also, you can just do so for x86_64.)

@oli-obk
Copy link
Contributor

oli-obk commented Oct 2, 2019

I opened #64990 with the _fltused symbol added to libcore

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 2, 2019
Pkgsrc changes:
 * Adapt to the move of the implementation of random numbers.
 * Remove patch which is no longer relevant (Signals.inc)
 * Cross-build currently fails due to the still unresolved
   rust-lang/rust#62558, so bootstrap
   kits for 1.38.0 have to be built natively, and will follow shortly.
 * Bump bootstrap requirements to 1.37.0 except for armv7-unknown-netbsd-eabihf
   which I've neither managed to cross-build nor build natively.

Upstream changes:

Version 1.38.0 (2019-09-26)
==========================

Language
--------
- [The `#[global_allocator]` attribute can now be used in submodules.][62735]
- [The `#[deprecated]` attribute can now be used on macros.][62042]

Compiler
--------
- [Added pipelined compilation support to `rustc`.][62766] This will
  improve compilation times in some cases. For further information please refer
  to the [_"Evaluating pipelined rustc compilation"_][pipeline-internals]
  thread.
- [Added tier 3\* support for the `aarch64-uwp-windows-msvc`,
  `i686-uwp-windows-gnu`, `i686-uwp-windows-msvc`, `x86_64-uwp-windows-gnu`,
  and `x86_64-uwp-windows-msvc` targets.][60260]
- [Added tier 3 support for the `armv7-unknown-linux-gnueabi` and
  `armv7-unknown-linux-musleabi` targets.][63107]
- [Added tier 3 support for the `hexagon-unknown-linux-musl` target.][62814]
- [Added tier 3 support for the `riscv32i-unknown-none-elf` target.][62784]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
---------
- [`ascii::EscapeDefault` now implements `Clone` and `Display`.][63421]
- [Derive macros for prelude traits (e.g. `Clone`, `Debug`, `Hash`) are now
  available at the same path as the trait.][63056] (e.g. The `Clone` derive
  macro is available at `std::clone::Clone`). This also makes all built-in
  macros available in `std`/`core` root. e.g. `std::include_bytes!`.
- [`str::Chars` now implements `Debug`.][63000]
- [`slice::{concat, connect, join}` now accepts `&[T]` in addition to
   `&T`.][62528]
- [`*const T` and `*mut T` now implement `marker::Unpin`.][62583]
- [`Arc<[T]>` and `Rc<[T]>` now implement `FromIterator<T>`.][61953]
- [Added euclidean remainder and division operations (`div_euclid`,
  `rem_euclid`) to all numeric primitives.][61884] Additionally `checked`,
  `overflowing`, and `wrapping` versions are available for all
  integer primitives.
- [`thread::AccessError` now implements `Clone`, `Copy`, `Eq`, `Error`, and
  `PartialEq`.][61491]
- [`iter::{StepBy, Peekable, Take}` now implement `DoubleEndedIterator`.][61457]

Stabilized APIs
---------------
- [`<*const T>::cast`]
- [`<*mut T>::cast`]
- [`Duration::as_secs_f32`]
- [`Duration::as_secs_f64`]
- [`Duration::div_duration_f32`]
- [`Duration::div_duration_f64`]
- [`Duration::div_f32`]
- [`Duration::div_f64`]
- [`Duration::from_secs_f32`]
- [`Duration::from_secs_f64`]
- [`Duration::mul_f32`]
- [`Duration::mul_f64`]
- [`any::type_name`]

Cargo
-----
- [Added pipelined compilation support to `cargo`.][cargo/7143]
- [You can now pass the `--features` option multiple times to enable
  multiple features.][cargo/7084]

Misc
----
- [`rustc` will now warn about some incorrect uses of
  `mem::{uninitialized, zeroed}` that are known to cause undefined
  behaviour.][63346]

Compatibility Notes
-------------------
- Unfortunately the [`x86_64-unknown-uefi` platform can not be built][62785]
  with rustc 1.39.0.
- The [`armv7-unknown-linux-gnueabihf` platform is also known to have
  issues][62896] for certain crates such as libc.

[60260]: rust-lang/rust#60260
[61457]: rust-lang/rust#61457
[61491]: rust-lang/rust#61491
[61884]: rust-lang/rust#61884
[61953]: rust-lang/rust#61953
[62042]: rust-lang/rust#62042
[62528]: rust-lang/rust#62528
[62583]: rust-lang/rust#62583
[62735]: rust-lang/rust#62735
[62766]: rust-lang/rust#62766
[62784]: rust-lang/rust#62784
[62785]: rust-lang/rust#62785
[62814]: rust-lang/rust#62814
[62896]: rust-lang/rust#62896
[63000]: rust-lang/rust#63000
[63056]: rust-lang/rust#63056
[63107]: rust-lang/rust#63107
[63346]: rust-lang/rust#63346
[63421]: rust-lang/rust#63421
[cargo/7084]: rust-lang/cargo#7084
[cargo/7143]: rust-lang/cargo#7143
[`<*const T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`<*mut T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f32
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f64
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f32
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f64
[`Duration::div_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f32
[`Duration::div_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f64
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f32
[`Duration::from_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f64
[`Duration::mul_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f32
[`Duration::mul_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f64
[`any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html
[forge-platform-support]: https://forge.rust-lang.org/platform-support.html
[pipeline-internals]: https://internals.rust-lang.org/t/evaluating-pipelined-rustc-compilation/10199
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 18, 2019
Pkgsrc changes:
 * Adapt to the move of the implementation of random numbers.
 * Remove patch which is no longer relevant (Signals.inc)
 * Cross-build currently fails due to the still unresolved
   rust-lang/rust#62558, so bootstrap
   kits for 1.38.0 have to be built natively, and will follow shortly.
 * Bump bootstrap requirements to 1.37.0 except for armv7-unknown-netbsd-eabihf
   which I've neither managed to cross-build nor build natively.

Upstream changes:

Version 1.38.0 (2019-09-26)
==========================

Language
--------
- [The `#[global_allocator]` attribute can now be used in submodules.][62735]
- [The `#[deprecated]` attribute can now be used on macros.][62042]

Compiler
--------
- [Added pipelined compilation support to `rustc`.][62766] This will
  improve compilation times in some cases. For further information please refer
  to the [_"Evaluating pipelined rustc compilation"_][pipeline-internals]
  thread.
- [Added tier 3\* support for the `aarch64-uwp-windows-msvc`,
  `i686-uwp-windows-gnu`, `i686-uwp-windows-msvc`, `x86_64-uwp-windows-gnu`,
  and `x86_64-uwp-windows-msvc` targets.][60260]
- [Added tier 3 support for the `armv7-unknown-linux-gnueabi` and
  `armv7-unknown-linux-musleabi` targets.][63107]
- [Added tier 3 support for the `hexagon-unknown-linux-musl` target.][62814]
- [Added tier 3 support for the `riscv32i-unknown-none-elf` target.][62784]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
---------
- [`ascii::EscapeDefault` now implements `Clone` and `Display`.][63421]
- [Derive macros for prelude traits (e.g. `Clone`, `Debug`, `Hash`) are now
  available at the same path as the trait.][63056] (e.g. The `Clone` derive
  macro is available at `std::clone::Clone`). This also makes all built-in
  macros available in `std`/`core` root. e.g. `std::include_bytes!`.
- [`str::Chars` now implements `Debug`.][63000]
- [`slice::{concat, connect, join}` now accepts `&[T]` in addition to
   `&T`.][62528]
- [`*const T` and `*mut T` now implement `marker::Unpin`.][62583]
- [`Arc<[T]>` and `Rc<[T]>` now implement `FromIterator<T>`.][61953]
- [Added euclidean remainder and division operations (`div_euclid`,
  `rem_euclid`) to all numeric primitives.][61884] Additionally `checked`,
  `overflowing`, and `wrapping` versions are available for all
  integer primitives.
- [`thread::AccessError` now implements `Clone`, `Copy`, `Eq`, `Error`, and
  `PartialEq`.][61491]
- [`iter::{StepBy, Peekable, Take}` now implement `DoubleEndedIterator`.][61457]

Stabilized APIs
---------------
- [`<*const T>::cast`]
- [`<*mut T>::cast`]
- [`Duration::as_secs_f32`]
- [`Duration::as_secs_f64`]
- [`Duration::div_duration_f32`]
- [`Duration::div_duration_f64`]
- [`Duration::div_f32`]
- [`Duration::div_f64`]
- [`Duration::from_secs_f32`]
- [`Duration::from_secs_f64`]
- [`Duration::mul_f32`]
- [`Duration::mul_f64`]
- [`any::type_name`]

Cargo
-----
- [Added pipelined compilation support to `cargo`.][cargo/7143]
- [You can now pass the `--features` option multiple times to enable
  multiple features.][cargo/7084]

Misc
----
- [`rustc` will now warn about some incorrect uses of
  `mem::{uninitialized, zeroed}` that are known to cause undefined
  behaviour.][63346]

Compatibility Notes
-------------------
- Unfortunately the [`x86_64-unknown-uefi` platform can not be built][62785]
  with rustc 1.39.0.
- The [`armv7-unknown-linux-gnueabihf` platform is also known to have
  issues][62896] for certain crates such as libc.

[60260]: rust-lang/rust#60260
[61457]: rust-lang/rust#61457
[61491]: rust-lang/rust#61491
[61884]: rust-lang/rust#61884
[61953]: rust-lang/rust#61953
[62042]: rust-lang/rust#62042
[62528]: rust-lang/rust#62528
[62583]: rust-lang/rust#62583
[62735]: rust-lang/rust#62735
[62766]: rust-lang/rust#62766
[62784]: rust-lang/rust#62784
[62785]: rust-lang/rust#62785
[62814]: rust-lang/rust#62814
[62896]: rust-lang/rust#62896
[63000]: rust-lang/rust#63000
[63056]: rust-lang/rust#63056
[63107]: rust-lang/rust#63107
[63346]: rust-lang/rust#63346
[63421]: rust-lang/rust#63421
[cargo/7084]: rust-lang/cargo#7084
[cargo/7143]: rust-lang/cargo#7143
[`<*const T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`<*mut T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f32
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f64
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f32
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f64
[`Duration::div_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f32
[`Duration::div_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f64
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f32
[`Duration::from_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f64
[`Duration::mul_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f32
[`Duration::mul_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f64
[`any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html
[forge-platform-support]: https://forge.rust-lang.org/platform-support.html
[pipeline-internals]: https://internals.rust-lang.org/t/evaluating-pipelined-rustc-compilation/10199
josephlr added a commit to josephlr/rust-hypervisor-firmware that referenced this issue Nov 5, 2019
- Makes the binary smaller
- Prevents size regression when updating to new toolchain
- Avoids bugs like: rust-lang/rust#62785

Signed-off-by: Joe Richey <[email protected]>
rbradford pushed a commit to cloud-hypervisor/rust-hypervisor-firmware that referenced this issue Nov 6, 2019
- Makes the binary smaller
- Prevents size regression when updating to new toolchain
- Avoids bugs like: rust-lang/rust#62785

Signed-off-by: Joe Richey <[email protected]>
@GabrielMajeri
Copy link
Contributor

Hello! This issue seems to have reappeared.

See, for example, this GitHub Actions job:

 = note: rust-lld: error: undefined symbol: _fltused
          >>> referenced by libuefi-ec1f12a68e3f8ed4.rlib(uefi-ec1f12a68e3f8ed4.5e0gotzcag6bbxy0.rcgu.o)
          >>> referenced by libcore-b9012135222c57c8.rlib(core-b9012135222c57c8.core.eba108b8-cgu.12.rcgu.o)
          >>> referenced by libcore-b9012135222c57c8.rlib(core-b9012135222c57c8.core.eba108b8-cgu.13.rcgu.o)
          

error: could not compile `uefi-test-runner` due to previous error
Error: command failed: exit status: 101

We've made no changes to the code, the CI simply downloaded the latest nightly. The errors seem to have started with rustc 1.64.0-nightly (62b272d25 2022-07-21).

@nicholasbishop
Copy link
Contributor

I think this is now re-fixed fortunately :)

This regressed in ceeb5ad, and I think #99676 fixed it. The latest nightly no longer has this error.

@AtomicGamer9523
Copy link

I have encountered this issue when compiling on x86_64-pc-windows-msvc:

libcompiler_builtins-9b73ba83da15270d.rlib(compiler_builtins-9b73ba83da15270d.compiler_builtins.da72492743c67d66-cgu.1.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcompiler_builtins-9b73ba83da15270d.rlib(compiler_builtins-9b73ba83da15270d.compiler_builtins.da72492743c67d66-cgu.4.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcompiler_builtins-9b73ba83da15270d.rlib(compiler_builtins-9b73ba83da15270d.compiler_builtins.da72492743c67d66-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcompiler_builtins-9b73ba83da15270d.rlib(compiler_builtins-9b73ba83da15270d.compiler_builtins.da72492743c67d66-cgu.3.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.08.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.15.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.12.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcompiler_builtins-9b73ba83da15270d.rlib(compiler_builtins-9b73ba83da15270d.compiler_builtins.da72492743c67d66-cgu.2.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.11.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.14.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.09.rcgu.o) : error LNK2001: unresolved external symbol _fltused
libcore-f63b72dfc4a1ee75.rlib(core-f63b72dfc4a1ee75.core.40809e373ed9bf76-cgu.10.rcgu.o) : error LNK2001: unresolved external symbol _fltused

@ChrisDenton
Copy link
Member

Please open a new issue, ideally with a reproducible example if you're able.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc O-x86_64 Target: x86-64 processors (like x86_64-*) P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet