Skip to content

Conversation

@penberg
Copy link

@penberg penberg commented Dec 20, 2024

No description provided.

Fixes the following build failure:

```
penberg@turing:~/src/penberg/limbo-eval/Mobibench/shell$ make
gcc -o mobibench mobibench.c sqlite3.c -lpthread -ldl -DNDEBUG=1 -DHAVE_USLEEP=1 -DSQLITE_HAVE_ISNAN -DSQLITE_THREADSAFE=2 -DSQLITE_TEMP_STORE=3 -DSQLITE_POWERSAFE_OVERWRITE=1 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_DEFAULT_AUTOVACUUM=1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_BACKWARDS -DSQLITE_ENABLE_FTS4 -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_COMPILEOPTION_DIAGS -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_FILE_PERMISSIONS=0666 -DUSE_PREAD64 --static
mobibench.c: In function ‘get_current_utime’:
mobibench.c:1667:9: error: implicit declaration of function ‘gettimeofday’; did you mean ‘SYS_gettimeofday’? [-Wimplicit-function-declaration]
 1667 |         gettimeofday(&current,NULL);
      |         ^~~~~~~~~~~~
      |         SYS_gettimeofday
make: *** [Makefile:40: all] Error 1
```
The 64-bit variants of stat functions (stat, lstat, and fstat) are
deprecated in modern glibc. The recommended way to use large file
support is to specify _FILE_OFFSET_BITS with 64 bits, which makes the
stat functions use appropriate types for parameters.

This fixes the following build failures:

```
gcc -o mobibench mobibench.c sqlite3.c -lpthread -ldl -DNDEBUG=1 -DHAVE_USLEEP=1 -DSQLITE_HAVE_ISNAN -DSQLITE_THREADSAFE=2 -DSQLITE_TEMP_STORE=3 -DSQLITE_POWERSAFE_OVERWRITE=1 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_DEFAULT_AUTOVACUUM=1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_BACKWARDS -DSQLITE_ENABLE_FTS4 -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_COMPILEOPTION_DIAGS -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_FILE_PERMISSIONS=0666 -DUSE_PREAD64 --static
mobibench.c: In function ‘do_script’:
mobibench.c:1915:23: error: implicit declaration of function ‘stat64’; did you mean ‘stat’? [-Wimplicit-function-declaration]
 1915 |                 ret = stat64(replay_pathname,  &stat_buf);
      |                       ^~~~~~
      |                       stat
mobibench.c:1926:23: error: implicit declaration of function ‘lstat64’; did you mean ‘lstat’? [-Wimplicit-function-declaration]
 1926 |                 ret = lstat64(replay_pathname,  &stat_buf);
      |                       ^~~~~~~
      |                       lstat
mobibench.c:1938:31: error: implicit declaration of function ‘fstat64’; did you mean ‘fstatat’? [-Wimplicit-function-declaration]
 1938 |                         ret = fstat64(fd_new,  &stat_buf);
      |                               ^~~~~~~
      |                               fstatat
make: *** [Makefile:40: all] Error 1
```

Note that another option would have been to define _LARGEFILE64_SOURCE,
which makes the 64-bit variants visible again. However, that does not
build because we pass incompatible types as arguments, so I decided to
just do this instead.
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 this pull request may close these issues.

1 participant