Skip to content

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

@dimbtp

Description

@dimbtp

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

Activity

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-core-archArea: Necessary for full core::arch support
on Jun 2, 2024
bjorn3

bjorn3 commented on Jun 2, 2024

@bjorn3
Member

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

dimbtp

dimbtp commented on Jun 2, 2024

@dimbtp
Author

Thanks for your work.

added a commit that references this issue on Jun 2, 2024
8f1d41e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-core-archArea: Necessary for full core::arch supportC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dimbtp@bjorn3

        Issue actions

          Problem when working with `Time Stamp Counter (TSC)` · Issue #1493 · rust-lang/rustc_codegen_cranelift