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

LNK2001: unresolved external symbol _fltused #4

Open
netaneld122 opened this issue Feb 22, 2020 · 3 comments
Open

LNK2001: unresolved external symbol _fltused #4

netaneld122 opened this issue Feb 22, 2020 · 3 comments

Comments

@netaneld122
Copy link

netaneld122 commented Feb 22, 2020

When using rustc 1.43.0-nightly (e02974078 2020-02-18) and running cargo xbuild --target x86_64-kernel-windows-msvc.json on a new clone of master, I get the following linker error:

LNK2001: unresolved external symbol _fltused
= note: LINK : warning LNK4216: Exported entry point DriverEntry
         Creating object D:\dev\rust\win_driver_example\target\x86_64-kernel-windows-msvc\debug\deps\win_driver_example.dll.exp
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.12.rcgu.o) : error LNK2001: unresolved external symbol _fltused        
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.4.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.14.rcgu.o) : error LNK2001: unresolved external symbol _fltused        
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.1.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.13.rcgu.o) : error LNK2001: unresolved external symbol _fltused        
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.2.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.9.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcore-7339924e45ccdcb4.rlib(core-7339924e45ccdcb4.core.e6t8h8ow-cgu.12.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcore-7339924e45ccdcb4.rlib(core-7339924e45ccdcb4.core.e6t8h8ow-cgu.3.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.15.rcgu.o) : error LNK2001: unresolved external symbol _fltused        
      libcompiler_builtins-a5dc3a27f854a583.rlib(compiler_builtins-a5dc3a27f854a583.compiler_builtins.2hb76v1n-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcore-7339924e45ccdcb4.rlib(core-7339924e45ccdcb4.core.e6t8h8ow-cgu.7.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcore-7339924e45ccdcb4.rlib(core-7339924e45ccdcb4.core.e6t8h8ow-cgu.14.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcore-7339924e45ccdcb4.rlib(core-7339924e45ccdcb4.core.e6t8h8ow-cgu.6.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      libcore-7339924e45ccdcb4.rlib(core-7339924e45ccdcb4.core.e6t8h8ow-cgu.5.rcgu.o) : error LNK2001: unresolved external symbol _fltused
      D:\dev\rust\win_driver_example\target\x86_64-kernel-windows-msvc\debug\deps\win_driver_example.sys : fatal error LNK1120: 1 unresolved externals

 error: aborting due to previous error

It looks like I'm experiencing the same problem demonstrated here, which I guess is an LLVM/Rust-core issue that uses floating point calculations - which aren't allowed when running in the Windows Kernel.
I'm fairly new to Rust and therefore not sure how to handle this properly.

As demonstrated in the link I managed to work around the error by adding the following snippet to my lib.rs:

#[used]
#[no_mangle]
static _fltused: i32 = 0;
@harryfei
Copy link
Contributor

Thanks. Will fix it in the repository.

@netaneld122
Copy link
Author

I believe that using the hack I described above is not safe, since the usage of MMX\SSE instructions might actually cause corruptions in certain conditions when running in the Kernel.
Defining _fltused will not do it in the long run.

@AtomicGamer9523
Copy link

Seems to be more related to this, and is referenced here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants