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

Termux on Chromebook: undeclared identifier 'timespec_get' #126

Open
ChiWPak opened this issue May 16, 2020 · 3 comments
Open

Termux on Chromebook: undeclared identifier 'timespec_get' #126

ChiWPak opened this issue May 16, 2020 · 3 comments

Comments

@ChiWPak
Copy link

ChiWPak commented May 16, 2020

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
Copy link
Member

jcheng5 commented May 17, 2020

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
Copy link
Member

jcheng5 commented May 17, 2020

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 added a commit to danieldjewell/later that referenced this issue Jun 13, 2020
timespec_get is not available on Android's Bionic libc -- e.g. in
sys/time.h ... This was raised as an issue in
tinycthread/tinycthread#47 and this fix is based on @mcclure's commit
mcclure/lovr@c322ce2
 ... see also android/ndk#864
@danieldjewell
Copy link

danieldjewell commented Jun 13, 2020

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

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

3 participants