r-lib / later

Schedule an R function or formula to run after a specified period of time.
https://r-lib.github.io/later
Other
141 stars 28 forks source link

Termux on Chromebook: undeclared identifier 'timespec_get' #126

Open ChiWPak opened 4 years ago

ChiWPak commented 4 years ago

I'm facing a similar problem as Issue #115 installing on Termux on a Chromebook. The suggested fixes (edit Makeconf) don't seem to be working when even installing the latest dev version remotes::install_github('r-lib/later').

checking for file ‘/data/data/com.termux/files/usr/tmp/RtmpiFGt8B/remotes163e5ce1d43e/r-lib-later-1f7de58/DESCRIPTION’ ... OK
* preparing ‘later’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* running ‘cleanup’
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘later_1.0.0.9004.tar.gz’
* installing *source* package ‘later’ ...
** using staged installation
Running configure script
-latomic linker flag needed.
** libs
clang++ -std=gnu++17 -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I"/data/data/com.termux/files/usr/lib/R/library/Rcpp/include" -I"/data/data/com.termux/files/usr/lib/R/library/BH/include" -I/data/data/com.termux/files/usr/include  -fpic  -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb  -D__ISO_C_VISIBLE=2011 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++17 -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I"/data/data/com.termux/files/usr/lib/R/library/Rcpp/include" -I"/data/data/com.termux/files/usr/lib/R/library/BH/include" -I/data/data/com.termux/files/usr/include  -fpic  -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb  -D__ISO_C_VISIBLE=2011 -c callback_registry.cpp -o callback_registry.o
clang++ -std=gnu++17 -I"/data/data/com.termux/files/usr/lib/R/include" -DNDEBUG -pthread -DSTRICT_R_HEADERS -I"/data/data/com.termux/files/usr/lib/R/library/Rcpp/include" -I"/data/data/com.termux/files/usr/lib/R/library/BH/include" -I/data/data/com.termux/files/usr/include  -fpic  -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb  -D__ISO_C_VISIBLE=2011 -c debug.cpp -o debug.o
In file included from callback_registry.cpp:5:
In file included from ./callback_registry.h:11:
./threadutils.h:119:9: error: use of undeclared identifier 'timespec_get'; did you mean 'timespec'?
    if (timespec_get(&ts, TIME_UTC) != TIME_UTC) {
        ^
/data/data/com.termux/files/usr/include/linux/time.h:24:8: note: 'timespec' declared here
struct timespec {
       ^
1 error generated.
make: *** [/data/data/com.termux/files/usr/lib/R/etc/Makeconf:177: callback_registry.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for package ‘later’

Here's what my ./include/linux/time.h looks like

/****************************************************************************
 ****************************************************************************
 ***
 ***   This header was automatically generated from a Linux kernel header
 ***   of the same name, to make information necessary for userspace to
 ***   call into the kernel available to libc.  It contains only constants,
 ***   structures, and macros generated from the original header, and thus,
 ***   contains no copyrightable information.
 ***
 ***   To edit the content of this header, modify the corresponding
 ***   source file (e.g. under external/kernel-headers/original/) then
 ***   run bionic/libc/kernel/tools/update_all.py
 ***
 ***   Any manual change here will be lost the next time this script will
 ***   be run. You've been warned!
 ***
 ****************************************************************************
 ****************************************************************************/
#ifndef _UAPI_LINUX_TIME_H
#define _UAPI_LINUX_TIME_H
#include <linux/types.h>
#ifndef _STRUCT_TIMESPEC
#define _STRUCT_TIMESPEC
struct timespec {
  __kernel_time_t tv_sec;
  long tv_nsec;
};
#endif
struct timeval {
  __kernel_time_t tv_sec;
  __kernel_suseconds_t tv_usec;
};
struct timezone {
  int tz_minuteswest;
  int tz_dsttime;
};
#define ITIMER_REAL 0
#define ITIMER_VIRTUAL 1
#define ITIMER_PROF 2
struct itimerspec {
  struct timespec it_interval;
  struct timespec it_value;
};
struct itimerval {
  struct timeval it_interval;
  struct timeval it_value;
};
#ifndef __kernel_timespec
struct __kernel_timespec {
  __kernel_time64_t tv_sec;
  long long tv_nsec;
};
#endif
#ifndef __kernel_itimerspec
struct __kernel_itimerspec {
  struct __kernel_timespec it_interval;
  struct __kernel_timespec it_value;
};
#endif
struct __kernel_old_timeval {
  __kernel_long_t tv_sec;
  __kernel_long_t tv_usec;
};
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
#define CLOCK_PROCESS_CPUTIME_ID 2
#define CLOCK_THREAD_CPUTIME_ID 3
#define CLOCK_MONOTONIC_RAW 4
#define CLOCK_REALTIME_COARSE 5
#define CLOCK_MONOTONIC_COARSE 6
#define CLOCK_BOOTTIME 7
#define CLOCK_REALTIME_ALARM 8
#define CLOCK_BOOTTIME_ALARM 9
#define CLOCK_SGI_CYCLE 10
#define CLOCK_TAI 11
#define MAX_CLOCKS 16
#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC)
#define CLOCKS_MONO CLOCK_MONOTONIC
#define TIMER_ABSTIME 0x01
#endif

I'll update with a Docker file once I can figure it out

jcheng5 commented 4 years ago

FWIW... It looks like the libc for termux comes from Bionic, and the Android 9.0 version doesn't have timespec_get (but does have clock_gettime) while Android 10.0 does have timespec_get.

jcheng5 commented 4 years ago

R itself goes through some trouble to normalize different clock functions across platforms: https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/main/times.c#L23-L137

danieldjewell commented 4 years ago

@jcheng5 Just added a commit that should address this - see the commit and PR #129 for more info