Zygo / bees

Best-Effort Extent-Same, a btrfs dedupe agent
GNU General Public License v3.0
630 stars 57 forks source link

Unable to compile - multiple errors #227

Closed AnrDaemon closed 2 years ago

AnrDaemon commented 2 years ago
# make
make PREFIX=/usr LIBEXEC_PREFIX=/usr/lib/bees ETC_PREFIX=/etc TAG="v0.7" -C lib
make[1]: Entering directory '/root/build/bees/bees/lib'
Makefile:45: depends.mk: No such file or directory
g++ -Wall -Wextra -Werror -O3 -I../include -D_FILE_OFFSET_BITS=64 -std=c++11 -Wold-style-cast  -M -MF .depends/extentwalker.dep -MT extentwalker.o extentwalker.cc
In file included from ../include/crucible/fs.h:11:0,
                 from extentwalker.cc:5:
../include/crucible/btrfs.h:18:30: fatal error: linux/btrfs_tree.h: No such file or directory
compilation terminated.
Makefile:35: recipe for target '.depends/extentwalker.dep' failed
make[1]: *** [.depends/extentwalker.dep] Error 1
make[1]: Leaving directory '/root/build/bees/bees/lib'
Makefile:34: recipe for target 'lib' failed
make: *** [lib] Error 2

Ubuntu 16.04, kernel 4.19.248

c++ --version

c++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609

Zygo commented 2 years ago

You need to install linux libc headers (in linux-libc-dev matching your kernel) to get linux/btrfs_tree.h.

AnrDaemon commented 2 years ago

I have full kernel headers installed, but it's not there, apparently? I have only Ubuntu's own version linux-libc-dev 4.4.0-210.242
Where can I find it?

AnrDaemon commented 2 years ago

Kernel is from https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.248/amd64/

Zygo commented 2 years ago

If it isn't in the linux-headers package, then you can use any version of linux-libc-dev after 4.7, ideally 4.19 or later.

AnrDaemon commented 2 years ago
# find / -xdev -type f -iname 'btrfs_tree.h'
/usr/src/linux-headers-4.15.0-140/include/uapi/linux/btrfs_tree.h
/usr/src/linux-headers-4.15.0-142/include/uapi/linux/btrfs_tree.h
/usr/src/linux-headers-4.19.248-0419248/include/uapi/linux/btrfs_tree.h

# head /usr/src/linux-headers-4.19.248-0419248/include/uapi/linux/btrfs_tree.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _BTRFS_CTREE_H_
#define _BTRFS_CTREE_H_

#include <linux/btrfs.h>
#include <linux/types.h>

/*
 * This header contains the structure definitions and constants used
 * by file system objects that can be retrieved using

Double checked. It's there. What next? Any way to debug it?

Zygo commented 2 years ago

It will need to be located at /usr/include/linux/btrfs_tree.h. Try dpkg -S /usr/include/linux/btrfs.h and then find a newer version of the package listed.

AnrDaemon commented 2 years ago

Doesn't make much sense. It is a kernel header. Look in kernel sources?

AnrDaemon commented 2 years ago

(And yes, it IS there.)

Zygo commented 2 years ago

It's a uapi header, so it's technically the portion of libc userspace headers that is supplied from the kernel, and not part of either libc or kernel header packages. On the Venn diagram of libc and kernel headers, it's the part of the circles that intersect.

Normally you can use any version of linux-libc-dev that's within a few years old; however, yours is from kernel 4.4. It's more than 6 years old. btrfs_tree.h was introduced in kernel 4.7, 3 months after Ubuntu 16.04 was released.

The kernel-headers packages will contain a copy of this header, but it will not be installed at the correct path to build applications. The kernel-headers packages are for building kernel modules, and include a lot of non-userspace headers as well as the uapi headers. You can manually add -I/usr/src/.../include/uapi to CCFLAGS in makeflags if you just want to work around this issue without upgrading thelinux-libc-dev package.

http://us.archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_4.15.0-189.200_amd64.deb looks like the closest match to what you already have installed.

Once you resolve that issue, I expect you'll have some new problem due to the age of your C++ compiler.

AnrDaemon commented 2 years ago

From reading into your installation instructions, Ubuntu 16.04 is supported. Took the libs from https://packages.debian.org/buster/linux-libc-dev

Compiled, looks okay. make.log

But… you don't really need uuidparse, do you? You do not make case conversion on argument, do not support absence of dashes and presence of brackets. You already have the

if [ ! -b "/dev/disk/by-uuid/$UUID" ]; then
    ERRO "Missing disk: /dev/disk/by-uuid/$UUID"
fi

test. What's more? It's one more dependency you force upon the user without necessity. The essence of that function could be easily replaced by

uuid_valid(){
    test ${#1} = 36
}
AnrDaemon commented 2 years ago

Ok, there's multiple small issues with current daemon script. I'll prepare MR.

AnrDaemon commented 2 years ago

BTW, it's fun to watch bees working. I'm already down from 230 to 217 gig available. :) Wonder what's next. Judging from the log, it is trying to de-deduplicate snapshot with VirtualBox disk images against the subvolume it was created from. Pure fun.