fio
fio copied to clipboard
Fails to compile on Solaris 11.4
I'm trying to compile fio-master on Solaris 11.4 and it fails with an error - too many arguments to function 'ctime_r'. See configure and gmake output below:
Operating system SunOS
CPU sparc64
Big endian yes
Compiler gcc
Cross compile no
Static build no
Wordsize 64
zlib yes
Linux AIO support no
POSIX AIO support yes
POSIX AIO support needs -lrt no
POSIX AIO fsync yes
POSIX pshared support yes
Solaris AIO support yes
__sync_fetch_and_add yes
__sync_synchronize yes
__sync_val_compare_and_swap yes
libverbs yes
rdmacm yes
asprintf() yes
vasprintf() yes
Linux fallocate no
POSIX fadvise yes
POSIX fallocate yes
sched_setaffinity(3 arg) no
sched_setaffinity(2 arg) no
clock_gettime yes
CLOCK_MONOTONIC yes
CLOCK_MONOTONIC_RAW no
CLOCK_MONOTONIC_PRECISE no
clockid_t yes
gettimeofday yes
fdatasync yes
sync_file_range no
EXT4 move extent no
Linux splice(2) no
GUASI no
libnuma no
strsep yes
strcasestr yes
strlcat yes
getopt_long_only() yes
inet_aton yes
socklen_t yes
__thread yes
RUSAGE_THREAD no
SCHED_IDLE no
TCP_NODELAY yes
Net engine window_size yes
TCP_MAXSEG yes
RLIMIT_MEMLOCK no
pwritev/preadv no
pwritev2/preadv2 no
IPv6 helpers yes
http engine yes
Rados engine no
Rados Block Device engine no
setvbuf yes
Gluster API engine no
s390_z196_facilities no
HDFS engine no
MTD no
libpmem no
libpmemblk no
PMDK pmemblk engine no
PMDK dev-dax engine no
PMDK libpmem engine no
DDN's Infinite Memory Engine no
lex/yacc for arithmetic no
getmntent no
getmntinfo no
Static Assert yes
bool yes
strndup yes
Valgrind headers no
Zoned block device support no
march_armv8_a_crc_crypto no
cuda no
mkdir(a, b) yes
Build march=native no
CUnit no
root@# gmake
FIO_VERSION = fio-3.12
CC crc/crc16.o
CC crc/crc32.o
CC crc/crc32c-arm64.o
CC crc/crc32c-intel.o
CC crc/crc32c.o
CC crc/crc64.o
CC crc/crc7.o
CC crc/fnv.o
CC crc/md5.o
CC crc/murmur3.o
CC crc/sha1.o
CC crc/sha256.o
CC crc/sha3.o
CC crc/sha512.o
CC crc/test.o
CC crc/xxhash.o
CC lib/axmap.o
CC lib/bloom.o
CC lib/flist_sort.o
CC lib/gauss.o
CC lib/getrusage.o
CC lib/hweight.o
CC lib/ieee754.o
CC lib/lfsr.o
CC lib/memalign.o
CC lib/memcpy.o
CC lib/mountcheck.o
CC lib/num2str.o
CC lib/output_buffer.o
CC lib/pattern.o
CC lib/prio_tree.o
CC lib/rand.o
CC lib/rbtree.o
CC lib/strntol.o
CC lib/zipf.o
CC gettime.o
CC ioengines.o
CC init.o
CC stat.o
In file included from os/os.h:46:0,
from thread_options.h:5,
from fio.h:18,
from stat.c:7:
stat.c: In function 'show_thread_status_normal':
os/os-solaris.h:46:33: error: too many arguments to function 'ctime_r'
#define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
^
stat.c:793:2: note: in expansion of macro 'os_ctime_r'
os_ctime_r((const time_t *) &time_p, time_buf, sizeof(time_buf));
^~~~~~~~~~
In file included from /usr/include/sys/time.h:448:0,
from /usr/include/sys/select.h:27,
from /usr/include/sys/types.h:665,
from /usr/include/string.h:15,
from stat.c:2:
/usr/include/time.h:265:14: note: declared here
extern char *ctime_r(const time_t *, char *);
^~~~~~~
In file included from os/os.h:46:0,
from thread_options.h:5,
from fio.h:18,
from stat.c:7:
stat.c: In function '__show_run_stats':
os/os-solaris.h:46:33: error: too many arguments to function 'ctime_r'
#define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
^
stat.c:1910:3: note: in expansion of macro 'os_ctime_r'
os_ctime_r(&tv_sec, time_buf, sizeof(time_buf));
^~~~~~~~~~
In file included from /usr/include/sys/time.h:448:0,
from /usr/include/sys/select.h:27,
from /usr/include/sys/types.h:665,
from /usr/include/string.h:15,
from stat.c:2:
/usr/include/time.h:265:14: note: declared here
extern char *ctime_r(const time_t *, char *);
^~~~~~~
gmake: *** [Makefile:359: stat.o] Error 1
Any idea what the issue might be?
Would be interesting what your compiler flags are, CFLAGS/CXXFLAGS/GPPFLAGS. /usr/include/time.h knows about the three argument ctime_r but only when specific defines are set.
@hulbs9nw Looking at https://docs.oracle.com/cd/E36784_01/html/E36874/ctime-r-3c.html and it says the ctime_r
protype is the following:
char *ctime_r(const time_t *clock, char *buf, int buflen);
but your message is saying it is
/usr/include/time.h:265:14: note: declared here
extern char *ctime_r(const time_t *, char *);
^~~~~~~
Looking at https://github.com/openzfs/openzfs/blob/master/usr/src/lib/libc/port/gen/ctime_r.c shows this:
/*
* POSIX.1c Draft-6 version of the function ctime_r.
* It was implemented by Solaris 2.3.
*/
char *
ctime_r(const time_t *t, char *buffer, int buflen)
[...]
/*
* POSIX.1c standard version of the function ctime_r.
* User gets it via static ctime_r from the header file.
*/
char *
__posix_ctime_r(const time_t *t, char *buffer)
{
further https://bugs.freedesktop.org/show_bug.cgi?id=15463 has some discussion too. It looks like Solaris is in POSIX compatibility mode for ctime_r
so it is only taking two arguments.
The fix will be something like changing
#define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
to
#define os_ctime_r(x, y, z) ctime_r((x), (y))
but there is a question as to why hasn't this appeared before? I admit these days I can only get hold of things like Illumos so maybe people aren't running fio on Solaris any more...
After ./configure I removed from Makefile CFLAGS the '-std=gnu99' string and compile is successful. Platform: Solaris 11.3 X86 gcc 4.9.4 (from sfe.opencsw.org) CFLAGS="-xO4 -xspace -m32 -xarch=pentium_pro -i -mr -xregs=no%frameptr" CXXFLAGS="-xO4 -xspace -m32 -xarch=pentium_pro -i -mr -xregs=no%frameptr" Result:
file fio .fio: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked, interpreter /usr/lib/ld.so.1, not stripped ./fio No job(s) defined fio-3.12 ./fio [options] [job options] <job file(s)> [...]
Thanks for the responses,
I tried removing -std=gnu99 from the Makefile but the compilation still fails with the same error.
With regards seeing the compiler flags, is this enough?
DEBUGFLAGS = -DFIO_INC_DEBUG CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS) OPTFLAGS= -g -ffast-math CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR) LIBS += -lm $(EXTLIBS) PROGS = fio SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio tools/fiologparser.py tools/hist/fiologparser_hist.py tools/fio_jsonplus_clat2csv)
ifndef CONFIG_FIO_NO_OPT CFLAGS += -O3 -D_POSIX_PTHREAD_SEMANTICS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 endif ifdef CONFIG_BUILD_NATIVE CFLAGS += -march=native endif
ifdef CONFIG_GFIO PROGS += gfio endif
I still see CFLAGS = -std=gnu99 in your copy of the Makefile. ./configure puts it into Makefile, again and again. Is this your steps when compiling? ./configure vim Makefile # remove all occurences of "-std=gnu99", write file gmake V=2
Sorry I sent you the wrong copy/paste. Same outcome:
gcc -o stat.o -Wwrite-strings -Wall -Wdeclaration-after-statement -g -ffast-math -D_GNU_SOURCE -include config-host.h -D_REENTRANT -I. -I. -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DBITS_PER_LONG=64 -DFIO_VERSION='"fio-3.12"' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL -DFIO_INC_DEBUG -D__EXTENSIONS__ -c stat.c In file included from os/os.h:46:0, from thread_options.h:5, from fio.h:18, from stat.c:7: stat.c: In function 'show_thread_status_normal': os/os-solaris.h:46:33: error: too many arguments to function 'ctime_r' #define os_ctime_r(x, y, z) ctime_r((x), (y), (z)) ^ stat.c:793:2: note: in expansion of macro 'os_ctime_r' os_ctime_r((const time_t *) &time_p, time_buf, sizeof(time_buf)); ^~~~~~~~~~ In file included from /usr/include/sys/time.h:448:0, from /usr/include/sys/select.h:27, from /usr/include/sys/types.h:665, from /usr/include/string.h:15, from stat.c:2: /usr/include/time.h:265:14: note: declared here extern char *ctime_r(const time_t *, char *); ^~~~~~~ In file included from os/os.h:46:0, from thread_options.h:5, from fio.h:18, from stat.c:7: stat.c: In function '__show_run_stats': os/os-solaris.h:46:33: error: too many arguments to function 'ctime_r' #define os_ctime_r(x, y, z) ctime_r((x), (y), (z)) ^ stat.c:1910:3: note: in expansion of macro 'os_ctime_r' os_ctime_r(&tv_sec, time_buf, sizeof(time_buf)); ^~~~~~~~~~ In file included from /usr/include/sys/time.h:448:0, from /usr/include/sys/select.h:27, from /usr/include/sys/types.h:665, from /usr/include/string.h:15, from stat.c:2: /usr/include/time.h:265:14: note: declared here extern char *ctime_r(const time_t *, char *); ^~~~~~~ gmake: *** [Makefile:359: stat.o] Error 1
@hulbs9nw can you re-checkout your repo to (making it pristine), edit os/os-solaris.h
and change
#define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
to
#define os_ctime_r(x, y, z) ctime_r((x), (y))
then in the root folder run
gmake clean
gmake
And tell us where you get to?
It's compiled successfully
fio: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped
I've not tried running any jobs yet, will try that next.
Sitsofe, probably add a configure test for this.
@axboe good point.
I would more prefer removing the enforced setting -std=gnu99 from Makefile:
grep gnu99 * Makefile:CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR) This looks like enforcing old standards. And this is the root why compiling on Solaris fails.
Solaris can use both, the two and three argument call to crime_r and has an #ifdef in /usr/include/time.h https://github.com/illumos/illumos-gate/usr/src/head/time.h Lines 204...285
The headers in Solaris 2.3 through 11.3 follow an early draft of the POSIX Threads standard by default, which had 3 arguments to ctime_r().
The headers in Solaris 11.4 and later default to the final version of the POSIX Threads standard, which has only 2 arguments to ctime_r().
To get the standard POSIX version on any release, #define _POSIX_PTHREAD_SEMANTICS
.
To get the old draft version on Solaris 11.4, #define __USE_DRAFT6_PROTOTYPES__
.
This is documented in the Standard Compilation Environment section of What's New in Solaris 11.4.
@alanc - thank you for explaining this!
@jperkin I've spotted you fixing up fio builds for Illumos elsewhere... Would it be possible for you to test what happens if _POSIX_PTHREAD_SEMANTICS
is defined in https://github.com/axboe/fio/blob/84106576cefbbd9f5dfa5ee33b245f77938d0269/configure#L312 and the lines defining a three parameter ctime_r
are removed from https://github.com/axboe/fio/blob/84106576cefbbd9f5dfa5ee33b245f77938d0269/os/os-solaris.h#L46-L47 ?