Skip to content

Problem when working with Time Stamp Counter (TSC) #1493

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
dimbtp opened this issue Jun 2, 2024 · 2 comments
Closed

Problem when working with Time Stamp Counter (TSC) #1493

dimbtp opened this issue Jun 2, 2024 · 2 comments
Labels
A-core-arch Area: Necessary for full core::arch support C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@dimbtp
Copy link

dimbtp commented Jun 2, 2024

Description

I am testing quanta, a high-speed timing library. Also tried another similar project minstant. They both utilize Time Stamp Counter (TSC).

Following code can pass compile, but will fail to run.

fn main() {
    println!("{:?}", quanta::Instant::now());
    // println!("{}", minstant::is_tsc_available());
}

error message: trap at Instance { def: Item(DefId(2:14264 ~ core[0e1d]::core_arch::x86::rdtsc::_rdtsc)), args: [] } (_ZN4core9core_arch3x865rdtsc6_rdtsc17h93aafcf1ca958dbeE): llvm.x86.rdtsc.

If I compile it without cranelift enabled, then everything is OK.

More information

readelf -p .comment target/debug/main

String dump of section '.comment':
  [     0]  rustc version 1.80.0-nightly (bdbbb6c6a 2024-05-26)
  [    34]  mold 2.31.0 (compatible with GNU ld)
  [    59]  GCC: (GNU) 13.2.1 20240316 (Red Hat 13.2.1-7)
  [    87]  rustc version 1.80.0-nightly (bdbbb6c6a 2024-05-26) with cranelift 0.107.0
  [    d2]  GCC: (GNU) 13.3.1 20240522 (Red Hat 13.3.1-1)

Operating System: Fedora 39 container
Host Kernel: 6.1.91

@bjorn3 bjorn3 added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-core-arch Area: Necessary for full core::arch support labels Jun 2, 2024
@bjorn3 bjorn3 closed this as completed in 8f1d41e Jun 2, 2024
@bjorn3
Copy link
Member

bjorn3 commented Jun 2, 2024

Thanks for reporting this. I've implemented the _rdtsc vendor intrinsic.

@dimbtp
Copy link
Author

dimbtp commented Jun 2, 2024

Thanks for your work.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-core-arch Area: Necessary for full core::arch support C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants