axboe / fio

Flexible I/O Tester
GNU General Public License v2.0
5.29k stars 1.26k forks source link

Fio doesn't compile on Android #1701

Closed Takashiidobe closed 10 months ago

Takashiidobe commented 10 months ago

Please acknowledge the following before creating a ticket

Description of the bug:

fio doesn't compile on android, due to a duplicate definition error.

Environment:

Android Termux, on a Samsung S10, Android 12.

$ uname -a

Linux localhost 4.14.190-25741239-abG973USQU9IWG2 #2 SMP PREEMPT Fri Jul 7 17:11:29 KST 2023 aarch64 Android

fio version: current master, 9f9340

Reproduction steps

To reproduce, on an android phone I ran make.

I got these logs:

Running configure ...
Operating system              Android
CPU                           arm64
Big endian                    no
Compiler                      gcc
Cross compile                 no

Static build                  no
Wordsize                      64
zlib                          yes
fcntl(F_FULLFSYNC)            no
Linux AIO support             yes
Linux AIO support rw flags    yes
POSIX AIO support             no
POSIX AIO support needs -lrt  no
POSIX AIO fsync               no
POSIX pshared support         yes
pthread_condattr_setclock()   yes
pthread_sigmask()             yes
pthread_getaffinity_np()      no
Solaris AIO support           no
__sync_fetch_and_add          yes
__sync_synchronize            yes
__sync_val_compare_and_swap   yes
libverbs                      no
rdmacm                        no
librpma                       no
libprotobuf_c                 no
asprintf()                    yes
vasprintf()                   yes
Linux fallocate               yes
POSIX fadvise                 yes
POSIX fallocate               yes
sched_setaffinity(3 arg)      yes
sched_setaffinity(2 arg)      no
clock_gettime                 yes
CLOCK_MONOTONIC               yes
clockid_t                     yes
gettimeofday                  yes
fdatasync                     yes
pipe()                        yes
pipe2()                       yes
pread()                       yes
sync_file_range               no
ASharedMemory_create          no
EXT4 move extent              no
Linux splice(2)               yes
libnuma                       no
strsep                        yes
strcasestr                    yes
strlcat                       yes
getopt_long_only()            yes
inet_aton                     yes
socklen_t                     yes
__thread                      yes
RUSAGE_THREAD                 yes
SCHED_IDLE                    yes
TCP_NODELAY                   yes
Net engine window_size        yes
TCP_MAXSEG                    yes
RLIMIT_MEMLOCK                yes
pwritev/preadv                yes
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                           yes
libpmem                       no
libpmem1_5                    no
libpmem2                      no
PMDK dev-dax engine           no
PMDK libpmem engine           no
DDN's Infinite Memory Engine  no
iscsi engine                  no
NBD engine                    no
DAOS File System (dfs) Engine no
NFS engine                    no
lex/yacc for arithmetic       no
getmntent                     yes
getmntinfo                    no
Static Assert                 yes
bool                          yes
strndup                       yes
Valgrind headers              no
Zoned block device support    yes
Zoned block device capacity   yes
libzbc engine                 no
xnvme engine                  no
libblkio engine               no
march_armv8_a_crc_crypto      yes
cuda                          no
libcufile                     no
Build march=native            yes
CUnit                         no
__kernel_rwf_t                yes
-Wimplicit-fallthrough=2      yes
-Wno-stringop-truncation      no
MADV_HUGEPAGE                 yes
gettid                        yes
statx(2)/libc                 no
statx(2)/syscall              yes
Windows PDB generation        no
timerfd_create                yes
Lib-based ioengines dynamic   no
TCMalloc support              no
seed_buckets                  4
FIO_VERSION = fio-3.36-40-g9f934
    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/crct10dif_common.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
    CC log.o
    CC time.o
    CC filesetup.o
    CC eta.o
    CC verify.o
    CC memory.o
    CC io_u.o
    CC parse.o
    CC fio_sem.o
    CC rwlock.o
    CC pshared.o
    CC options.o
    CC smalloc.o
    CC filehash.o
    CC profile.o
    CC debug.o
    CC engines/cpu.o
    CC engines/mmap.o
    CC engines/sync.o
    CC engines/null.o
    CC engines/net.o
    CC engines/ftruncate.o
    CC engines/fileoperations.o
    CC engines/exec.o
    CC server.o
    CC client.o
    CC iolog.o
    CC backend.o
    CC libfio.o
    CC flow.o
    CC cconv.o
    CC gettime-thread.o
    CC helpers.o
    CC json.o
    CC idletime.o
    CC td_error.o
    CC profiles/tiobench.o
    CC profiles/act.o
    CC io_u_queue.o
    CC filelock.o
    CC workqueue.o
    CC rate-submit.o
    CC optgroup.o
    CC helper_thread.o
    CC steadystate.o
    CC zone-dist.o
    CC zbd.o
    CC dedupe.o
    CC fdp.o
    CC engines/falloc.o
    CC engines/splice.o
    CC oslib/asprintf.o
    CC oslib/statx.o
    CC engines/mtd.o
    CC oslib/libmtd.o
    CC oslib/libmtd_legacy.o
    CC diskutil.o
    CC fifo.o
    CC blktrace.o
    CC cgroup.o
    CC trim.o
    CC oslib/linux-dev-lookup.o
    CC engines/io_uring.o
In file included from engines/io_uring.c:29:
engines/nvme.h:18:8: error: redefinition of 'nvme_uring_cmd'
   18 | struct nvme_uring_cmd {
      |        ^
/data/data/com.termux/files/usr/include/linux/nvme_ioctl.h:80:8: note: previous definition is here
   80 | struct nvme_uring_cmd {
      |        ^
1 error generated.
make: *** [Makefile:526: engines/io_uring.o] Error 1

To fix the error, I commented out the definition of nvme_uring_cmd with this patch:

diff --git a/engines/nvme.h b/engines/nvme.h
index 792b35d8..b05730f4 100644
--- a/engines/nvme.h
+++ b/engines/nvme.h
@@ -15,6 +15,7 @@
  * support, use the local version to prevent compilation issues.
  */
 #ifndef CONFIG_NVME_URING_CMD
+/*
 struct nvme_uring_cmd {
    __u8    opcode;
    __u8    flags;
@@ -35,6 +36,7 @@ struct nvme_uring_cmd {
    __u32   timeout_ms;
    __u32   rsvd2;
 };
+*/

 #define NVME_URING_CMD_IO  _IOWR('N', 0x80, struct nvme_uring_cmd)
 #define NVME_URING_CMD_IO_VEC  _IOWR('N', 0x81, struct nvme_uring_cmd)

which fixed the issue.

The program that configure tries to compile to check for nvme_uring_cmd support actually works:

#include <linux/nvme_ioctl.h>

int main() {
  return sizeof(struct nvme_uring_cmd);
}
$ ./a.out
$ echo $status
72

it returns 72, so it's odd that it believes that my device doesn't already include nvme_uring_cmd.

axboe commented 10 months ago

Can you include the config.log output for the nvme_uring_cmd part?

axboe commented 10 months ago

Actually, I wonder if you just need:

diff --git a/configure b/configure
index 420d97dbe64a..f86fcf77df6c 100755
--- a/configure
+++ b/configure
@@ -2656,7 +2656,7 @@ if test "$libzbc" != "no" ; then
 fi
 print_config "libzbc engine" "$libzbc"

-if test "$targetos" = "Linux" ; then
+if test "$targetos" = "Linux" || test "$targetos" = "Android"; then
 ##########################################
 # Check NVME_URING_CMD support
 cat > $TMPC << EOF
Takashiidobe commented 10 months ago

I've pulled current master and confirmed that fio now builds. Thank you!