Skip to content

Commit f8ac1ae

Browse files
committed
Emit _fltused on uefi targets as a short-term workaround
1 parent 22bc9e1 commit f8ac1ae

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/libcore/num/float.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// HACK(https://github.com/rust-lang/rust/issues/62785): uefi targets need special LLVM support
2+
// unless we emit the _fltused
3+
#[cfg(target_os = "uefi")]
4+
#[no_mangle]
5+
#[used]
6+
static _fltused: i32 = 0;

src/libcore/num/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ pub mod dec2flt;
213213
pub mod bignum;
214214
pub mod diy_float;
215215

216+
mod float;
216217
mod wrapping;
217218

218219
macro_rules! usize_isize_to_xe_bytes_doc {

src/test/ui/uefi-float.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// build-pass
2+
// https://github.com/rust-lang/rust/issues/62785
3+
4+
#![no_std]
5+
#![no_main]
6+
use core::fmt::{Write,Error};
7+
8+
struct Dummy;
9+
10+
impl Write for Dummy {
11+
fn write_str(&mut self, _s: &str) -> Result<(), Error>{
12+
Ok(())
13+
}
14+
}
15+
16+
#[no_mangle]
17+
pub extern "C" fn efi_main() -> i32 {
18+
write!(Dummy,"Hello, world!").unwrap();
19+
0
20+
}
21+
22+
#[panic_handler]
23+
fn panic(_info: &core::panic::PanicInfo) -> ! {
24+
loop{}
25+
}

src/tools/tidy/src/pal.rs

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const EXCEPTION_PATHS: &[&str] = &[
4444
// target_os to tell targets with different LLVM-versions appart
4545
// (e.g. `wasm32-unknown-emscripten` vs `wasm32-unknown-unknown`):
4646
"src/libcore/hint.rs",
47+
// HACK(https://github.com/rust-lang/rust/issues/62785): uefi targets need special LLVM support
48+
// unless we emit the _fltused
49+
"src/libcore/num/float.rs",
4750
"src/libstd/sys/", // Platform-specific code for std lives here.
4851
// This has the trailing slash so that sys_common is not excepted.
4952
"src/libstd/os", // Platform-specific public interfaces

0 commit comments

Comments
 (0)