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

Time::HiRes is missing clock_gettime() #103

Closed
stefanalt opened this issue Jan 5, 2021 · 2 comments
Closed

Time::HiRes is missing clock_gettime() #103

stefanalt opened this issue Jan 5, 2021 · 2 comments

Comments

@stefanalt
Copy link

stefanalt commented Jan 5, 2021

I cross build with buildroot for an X86-linux-glibc
platform. Perl 5.30.3, Perl-Cross 1.3.4, but the problem also occurs with older versions. I need clock_gettime to be able to use CLOCK_MONOTONIC.
The built HiRes.so does not request clock_getttime() symbol. Hi-res time() is working properly. It looks like this:

nm perl-5.30.3/lib/auto/Time/HiRes/HiRes.so | grep clock_gettime
0000000000002909 t XS_Time__HiRes_clock_gettime

But should look like this:

nm perl-5.30.3/lib/auto/Time/HiRes/HiRes.so | grep clock_gettime
0000000000001e46 t XS_Time__HiRes_clock_gettime
                 U clock_gettime@@GLIBC_2.2.5

My investigation so far:

perl-5.30.3/dist/Time-HiRes/xdefine is missing: -DTIME_HIRES_CLOCK_GETTIME

In dist/Time-HiRes/Makefile.PL

    print "Looking for clock_gettime()... ";
    my $has_clock_gettime;
    my $has_clock_gettime_emulation;
    if (exists $Config{d_clock_gettime}) {
        $has_clock_gettime++ if $Config{d_clock_gettime}; # Unlikely...
    } elsif (has_clock_xxx('gettime')) {
        $has_clock_gettime++;
        $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME';
    } ...

Seems the first if() is triggered by a pre-set $Config ? If I modify to if( 0 and ....), then Makefile.PL properly detects
clock_gettime() and finally builds the .so file correctly.

However, for this to work TIME_HIRES_DONT_RUN_PROBES=1 must be in the ENV.

Or is there a better solution to this.

@arsv
Copy link
Owner

arsv commented Jan 6, 2021

The problem there is that Makefile.PL wants to build and run tests to figure out what's supported, which is a no-go for cross builds. So instead top-level configure does a quick compile-only test for clock_gettime and sets $Config{d_clock_gettime} = 'define' to suppress testing in Time::HiRes Makefile.PL and force it to build clock_gettime support. That "unlikely" case is exactly what's supposed to happen during cross builds.

Something clearly isn't working as intended though. It's not building clock_gettime support for me either even though d_clock_gettime gets set correctly. Looking into this.

@arsv
Copy link
Owner

arsv commented Jan 9, 2021

Should be fixed now.

@arsv arsv closed this as completed Jan 21, 2021
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

2 participants