Fix compile of test programs on archs that use arch_flags at runtime
authorJens Axboe <axboe@fb.com>
Thu, 10 Mar 2016 15:09:41 +0000 (08:09 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 10 Mar 2016 15:09:41 +0000 (08:09 -0700)
SuperH compile currently fails with:

gettime.o: In function fio_gettime':
/home/thomas/projets/buildroot/output/build/fio-fio-2.7/gettime.c:163: undefined reference to arch_flags'
gettime.o: In function utime_since_now':
/home/thomas/projets/buildroot/output/build/fio-fio-2.7/gettime.c:164: undefined reference to arch_flags'
gettime.o: In function mtime_since_now':
/home/thomas/projets/buildroot/output/build/fio-fio-2.7/gettime.c:164: undefined reference to arch_flags'
gettime.o: In function time_since_now':
/home/thomas/projets/buildroot/output/build/fio-fio-2.7/gettime.c:164: undefined reference to arch_flags'
mutex.o: In function fio_mutex_up':
/home/thomas/projets/buildroot/output/build/fio-fio-2.7/mutex.c:189: undefined reference to arch_flags'
collect2: error: ld returned 1 exit status
Makefile:375: recipe for target 't/stest' failed
make[2]: *** [t/stest] Error 1
make[2]: *** Waiting for unfinished jobs....

Fix that by ensuring we have a stub arch.o with the necessary arch flags
for the standalone test programs.

Signed-off-by: Jens Axboe <axboe@fb.com>
Makefile
t/arch.c [new file with mode: 0644]
t/dedupe.c
t/lfsr-test.c
t/stest.c

index 6b4c9dbf084d01ea07cc3bfde696af3610f02324..a2502dcd5adf3e9b51cba6c3891d03f6698c3065 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -191,7 +191,7 @@ endif
 -include $(OBJS:.o=.d)
 
 T_SMALLOC_OBJS = t/stest.o
-T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o
+T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o t/arch.o
 T_SMALLOC_PROGS = t/stest
 
 T_IEEE_OBJS = t/ieee754.o
@@ -208,7 +208,7 @@ T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
 T_AXMAP_PROGS = t/axmap
 
 T_LFSR_TEST_OBJS = t/lfsr-test.o
-T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o
+T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o t/arch.o
 T_LFSR_TEST_PROGS = t/lfsr-test
 
 T_GEN_RAND_OBJS = t/gen-rand.o
@@ -223,7 +223,7 @@ endif
 
 T_DEDUPE_OBJS = t/dedupe.o
 T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
-               lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
+               lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o t/arch.o \
                crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
 T_DEDUPE_PROGS = t/fio-dedupe
 
diff --git a/t/arch.c b/t/arch.c
new file mode 100644 (file)
index 0000000..befb7c7
--- /dev/null
+++ b/t/arch.c
@@ -0,0 +1,5 @@
+#include "../arch/arch.h"
+
+unsigned long arch_flags = 0;
+int tsc_reliable;
+int arch_random;
index 3a66820f236ca9ada7db4b72d839e495fa9129b1..7856da1a14865e2aaa07e9fea3b9580c9ecee4c6 100644 (file)
@@ -537,6 +537,7 @@ int main(int argc, char *argv[])
        uint64_t nextents = 0, nchunks = 0;
        int c, ret;
 
+       arch_init(argv);
        debug_init();
 
        while ((c = getopt(argc, argv, "b:t:d:o:c:p:B:")) != -1) {
index 4352b89f3319959ab55c8e90d15e3878717b432e..bad5097271723ba68e50cf488cbfd3d6d329e608 100644 (file)
@@ -38,6 +38,8 @@ int main(int argc, char *argv[])
        void *v = NULL, *v_start;
        double total, mean;
 
+       arch_init(argv);
+
        /* Read arguments */
        switch (argc) {
                case 5: if (strncmp(argv[4], "verify", 7) == 0)
index fb51989521ec951c308a578c205c77597d145d59..0e0d8b0b4785998546f437fb336a2038ec34ce41 100644 (file)
--- a/t/stest.c
+++ b/t/stest.c
@@ -4,6 +4,7 @@
 
 #include "../smalloc.h"
 #include "../flist.h"
+#include "../arch/arch.h"
 #include "debug.h"
 
 #define MAGIC1 0xa9b1c8d2
@@ -69,6 +70,7 @@ static int do_specific_alloc(unsigned long size)
 
 int main(int argc, char *argv[])
 {
+       arch_init(argv);
        sinit();
        debug_init();