markfasheh / duperemove

Tools for deduping file systems
GNU General Public License v2.0
689 stars 75 forks source link

Failed build on musl #310

Closed meator closed 9 months ago

meator commented 9 months ago

duperemove currently doesn't compile on musl.

make output ``` cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o duperemove.o duperemove.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o hash-tree.o hash-tree.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o results-tree.o results-tree.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o rbtree.o rbtree.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o dedupe.o dedupe.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o filerec.o filerec.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o btrfs-util.o btrfs-util.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o util.o util.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o memstats.o memstats.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o file_scan.o file_scan.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o find_dupes.o find_dupes.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o run_dedupe.o run_dedupe.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o csum.o csum.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o dbfile.o dbfile.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o list_sort.o list_sort.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o debug.o debug.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o opt.o opt.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -c -o csum-xxhash.o csum-xxhash.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o btrfs-extent-same btrfs-extent-same.c cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -Wl,-z,relro -Wl,-z,now -Wl,--as-needed show-shared-extents.c rbtree.o util.o debug.o filerec.o -o show-shared-extents -Wl,--as-needed -latomic -lm -lglib-2.0 -lsqlite3 cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -Wl,-z,relro -Wl,-z,now -Wl,--as-needed duperemove.o hash-tree.o results-tree.o rbtree.o dedupe.o filerec.o btrfs-util.o util.o memstats.o file_scan.o find_dupes.o run_dedupe.o csum.o dbfile.o list_sort.o debug.o opt.o csum-xxhash.o -o duperemove -Wl,--as-needed -latomic -lm -lglib-2.0 -lsqlite3 cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -Wl,-z,relro -Wl,-z,now -Wl,--as-needed csum-xxhash.o rbtree.o hash-tree.o filerec.o util.o opt.o results-tree.o csum.o dbfile.o list_sort.o debug.o file_scan.o btrfs-util.o hashstats.c -o hashstats -Wl,--as-needed -latomic -lm -lglib-2.0 -lsqlite3 cc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -ffile-prefix-map=/builddir/duperemove-0.13=. -O2 --std=gnu2x -D_FILE_OFFSET_BITS=64 -DVERSTRING=\"0.13\" -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -rdynamic -DIS_RELEASE=1 -Wl,-z,relro -Wl,-z,now -Wl,--as-needed csum-xxhash.o util.o csum.o debug.o -o csum-test csum-test.c -Wl,--as-needed -latomic -lm -lglib-2.0 -lsqlite3 In file included from hashstats.c:25: dbfile.h:27:9: error: unknown type name 'dev_t' 27 | dev_t onefs_dev; | ^~~~~ make: *** [Makefile:128: hashstats] Error 1 make: *** Waiting for unfinished jobs.... ```

This is caused by the missing header <sys/types.h> which provides the definition for the dev_t type.

The following patch fixed the issue for me:

--- a/dbfile.h
+++ b/dbfile.h
@@ -7,6 +7,8 @@
 #include <stdbool.h>
 #include "util.h"

+#include <sys/types.h>
+
 struct filerec;
 struct block_csum;
 struct extent_csum;

I didn't make a PR because I don't know the codebase much and I'm quite busy now. Hope this helps.