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

"make build_c" fails on MacOS 10.12.6 with "undeclared identifier 'clock_nanosleep'" #13

Open
korpiq opened this issue Dec 25, 2018 · 3 comments · May be fixed by #22
Open

"make build_c" fails on MacOS 10.12.6 with "undeclared identifier 'clock_nanosleep'" #13

korpiq opened this issue Dec 25, 2018 · 3 comments · May be fixed by #22
Assignees

Comments

@korpiq
Copy link

korpiq commented Dec 25, 2018

Build fails with database.cpp:221:16: error: use of undeclared identifier 'clock_nanosleep'.

make build_c:

Generating man pages...
mkdir -p files//usr/share/man/man1
sed -e "s:__VERSION__:Version 0.8r2:" man/_ash_log.1 \
	  | sed -e "s:__DATE__:2018-01-03:" \
	  | gzip -9 -c > ./files/usr/share/man/man1/_ash_log.1.gz
sed -e "s:__VERSION__:Version 0.8r2:" man/ash_query.1 \
	  | sed -e "s:__DATE__:2018-01-03:" \
	  | gzip -9 -c > ./files/usr/share/man/man1/ash_query.1.gz
cp -af ./files/usr/share/man/man1/_ash_log.1.gz ./files/usr/share/man/man1/_ash_log.py.1.gz
cp -af ./files/usr/share/man/man1/ash_query.1.gz ./files/usr/share/man/man1/ash_query.py.1.gz
chmod 644 ./files/usr/share/man/man1/*ash*.1.gz
mkdir -p files//usr/local/bin
mkdir -p files//usr/local/etc/advanced-shell-history
mkdir -p files//usr/local/lib/advanced_shell_history/sh
chmod 755 files//usr/local/lib/advanced_shell_history/sh files//usr/local/etc/advanced-shell-history
cp shell/* files//usr/local/lib/advanced_shell_history/sh
cp config queries files//usr/local/etc/advanced-shell-history

Compiling source code...
gcc -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=0 -c sqlite3.c
sqlite3.c:15855:17: warning: 'OSAtomicCompareAndSwapPtrBarrier' is deprecated: first deprecated in macOS 10.12 - Use
      atomic_compare_exchange_strong() from <stdatomic.h> instead [-Wdeprecated-declarations]
      success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone, 
                ^
/usr/include/libkern/OSAtomicDeprecated.h:547:6: note: 'OSAtomicCompareAndSwapPtrBarrier' has been explicitly marked
      deprecated here
bool    OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
        ^
1 warning generated.
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o _ash_log.o _ash_log.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o command.o command.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o config.o config.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o database.o database.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
database.cpp:221:16: error: use of undeclared identifier 'clock_nanosleep'
    int rval = clock_nanosleep(CLOCK_MONOTONIC, 0, &to_sleep, &remaining);
               ^
1 error generated.
make[1]: *** [database.o] Error 1
make: *** [build_c] Error 2

g++ --version:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
@mesopelagique
Copy link

mesopelagique commented Apr 18, 2020

I try to compile it on macOS
To make it compile (not work)

  • I comment the clock_nanosleep (could be an if def of some var, and an alternative code must be written)
  • I remove -ansi and -lrt flag in makeFile
  • I use an alternative code for cwd
#ifdef _GNU_SOURCE
  char * c = get_current_dir_name();
#else
  char * c = (char *) malloc(PATH_MAX * sizeof(char));
  getcwd(c, PATH_MAX);
#endif

@alanmiller
Copy link

Thanks Eric Marchand I made those 3 changes and it compiles & works for me on MacOS Ventura. osx-ventura.patch

Then I added to my ~/.zshrc

source /usr/local/etc/advanced-shell-history/config
export ASH_CFG_SYSTEM_QUERY_FILE
source /usr/local/lib/advanced_shell_history/sh/zsh

I also had to copy /usr/local/etc/advanced-shell-history/queries to ~/.ash/queries

[ ~/source/advanced-shell-history| main !3 ] 
> ash_query  -q  RCWD |grep build_c |tail -2
        2023-01-19 17:39:02    ash_query  -q  RCWD |grep build_c
        2023-01-19 17:39:25    history|grep build_c
[ ~/source/advanced-shell-history|  main !3 ]                                                      
> history  |grep build_c |tail -2
11039  2023-01-19 17:39  history|grep build_c
11047  2023-01-19 17:46  ash_query  -q  RCWD |grep build_c |tail -2

@barabo
Copy link
Owner

barabo commented Jan 20, 2023

I'll take the patch and test it out. FWIW - PR's are always welcome, but if it works I'll merge it myself. Thanks @alanmiller!

barabo pushed a commit that referenced this issue Jan 22, 2023
@barabo barabo linked a pull request Jan 22, 2023 that will close this issue
@barabo barabo self-assigned this Jan 22, 2023
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

Successfully merging a pull request may close this issue.

4 participants