Comments (5)
I think this is how the disassembly was produced:
$ cargo new --bin app && cd $_
$ edit src/main.rs && cat $_
#![feature(compiler_builtins_lib)]
#![feature(lang_items)]
#![no_main]
#![no_std]
extern crate compiler_builtins;
use core::ptr;
#[no_mangle]
pub fn _start() -> ! {
let x = unsafe {
ptr::read_volatile(0x0 as *const u32)
};
let y = x * (48000000 / 1000000) / 3;
loop {}
}
#[lang = "panic_fmt"]
#[no_mangle]
fn panic_fmt() {}
#[no_mangle]
pub fn __aeabi_unwind_cpp_pr0() {}
$ xargo rustc --target thumbv6m-none-eabi -- -C link-arg=-nostartfiles
from compiler-builtins.
@japaric correct. For completeness here's the full function.
pub fn udelay(us: u32) {
if us == 0 {
return;
}
let n = us * (48_000_000 / 1_000_000) / 3;
unsafe {
asm!("1:
subs $0, #1
bne 1b
" :: "r" (n));
}
}
from compiler-builtins.
I had a look at the LLVM IR on playground and it seems that rustc
calls the intrinsic @llvm.umul.with.overflow.i32
for all the normal multiplications in __muldi3
here in debug mode. That instrinic calls __aeabi_lmul
as @seeday spotted which calls __muldi3
and hence the infinite recursion. Replacing the normal multiplications with wrapping_mul
should solve the problem I believe.
from compiler-builtins.
@parched Hi, thanks for taking the time to look at this! Do you happen to have a rough patch idea for that? I am unfortunately not yet deep enough into the compiler-rt code but am facing the same issue.
Thanks in advance!
from compiler-builtins.
@parched Wow, thanks for the fast patch. I can confirm this works for me and stops the infinite recursion from happening.
from compiler-builtins.
Related Issues (20)
- AEABI division function linking problems (again) HOT 2
- duplicated intrinsic implementations linked into libstd HOT 4
- libm directory is missing from 0.1.97 crates.io release HOT 2
- wrong define of 128-bit related functions like `__multi3` and `__floatuntidf` on `csky` HOT 4
- The `USE_NATIVE_FULL_ITERATIONS` codepath in `div64` is broken
- Several functions perform out-of-bounds memory accesses (which is UB) HOT 16
- undefined reference to `memcpy`, undefined reference to `memset` HOT 1
- `__extenddftf2` is found to be missing at runtime when using the WASI SDK to build Rust crates' C code HOT 1
- Getting C-defined intrinsics into a project that uses the stable compiler doesn't work because of all the `#![feature]` checks HOT 2
- Unable to find long double symbols on `aarch64-apple-darwin` HOT 4
- Adding feature to port `libm` for any target HOT 3
- Unable to use static macOS libraries in Unreal Engine projects HOT 2
- Regression: build failure on i686-pc-windows-gnu due to multiple definition of `_alloca` HOT 15
- Undefined reference to __chkstk, __alloca when building target i686-unknown-uefi
- aarch64 windows build failure HOT 1
- `aarch64-linux` `multf3` symbol has incorrect rounding HOT 1
- Unable to `-Zbuild-std` because std depends on `compiler-builtins` without the `no-f16-f128` features HOT 4
- Rounding error in `__mulsf3` HOT 6
- Inconsistent truncation of -0.0 HOT 6
- powerpc64le truncation failure HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler-builtins.