Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure fails to find zfs.h on Ubuntu without --prefix=/usr #107

Open
Hi-Angel opened this issue Jul 7, 2020 · 6 comments
Open

configure fails to find zfs.h on Ubuntu without --prefix=/usr #107

Hi-Angel opened this issue Jul 7, 2020 · 6 comments

Comments

@Hi-Angel
Copy link

Hi-Angel commented Jul 7, 2020

This is a basically a copy of #90. OP closed their report due to finding a workaround, however the problem per se remains.

Steps to reproduce

Run the following commands:

sudo apt install --yes --no-install-recommends gcc gcc-multilib libzfslinux-dev 

cd ~
git clone https://github.com/freenas/py-libzfs
cd ~/py-libzfs

./configure

Expected

configure passes successfully.

Actual

checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed

-----------------------------------
   RUNNING TESTS ON zfs.h HEADER
-----------------------------------
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for sys/types.h... (cached) yes
checking for sys/fs/zfs.h... no
configure: error: A working zfs header is required
@Hi-Angel
Copy link
Author

Hi-Angel commented Jul 7, 2020

Okay, I did a quick stab at fixing this. Beforehand, the solution is to run pkg-config --cflags libzfs to infer CFLAGS.

A workaround mentioned in #90 was to set --prefix. I figured, when it's set, this branch that changes CFLAGS gets executed, so some modifications around it required.

Unfortunately I have no idea why is there even a branch matching libzfs.h specifically, nor I have any guess what the variable $zof means. All of that requires further digging and I'm out of time I could dedicate to this problem. Hopefully it will help someone.

@Hi-Angel
Copy link
Author

Hi-Angel commented Jul 7, 2020

To future readers: there are further bugs in build system: if you apply the workaround with prefix, make still gonna fail with make: /usr/local/bin/python2.7: Command not found. But what's notable in this output is that apparently the bindings this project provides are for old and unmaintained python 2. So using py-libzfs is not future proof.

I've heard 0.8.x ZFS versins provide some python bindings of their own, so I think this is the way forward. For older versions apparently one have to fallback to parsing zfs commands output manually.

@mcdonc
Copy link

mcdonc commented Aug 10, 2020

@Hi-Angel FWIW, this is just a bug, I just tested it on Py 3.7 and it appears to work fine after modifying the Makefile to point at a py 3 venv. Probably rather than a configure script and a Makefile, the project could use setuptools-ish processes for building the extensions, just a matter of missing roundtuits likely.

@ghost
Copy link

ghost commented Aug 12, 2020

But what's notable in this output is that apparently the bindings this project provides are for old and unmaintained python 2. So using py-libzfs is not future proof.

You can build py-libzfs for whatever Python version you like. We are targeting 3.8 at the moment, but you can use make PYTHON=python3.7 for example to build for Python 3.7, or whatever version you have installed. Defaulting to 2.7 is probably just an oversight.

Unfortunately I have no idea why is there even a branch matching libzfs.h specifically, nor I have any guess what the variable $zof means. All of that requires further digging and I'm out of time I could dedicate to this problem. Hopefully it will help someone.

The reason for this complexity is twofold: partly that libzfs is not supposed to be a public interface in ZFS, it's an internal private library that has an unstable and unclean API; and on top of that there are several different ZFS implementations on different platforms that put headers in different places, require different build flags, and have different function signatures within libzfs. $zof is referring to https://github.com/zfsonfreebsd/ZoF

@Hi-Angel
Copy link
Author

I see, thanks

there are several different ZFS implementations on different platforms that put headers in different places, require different build flags

Doesn't pkg-config cover this?

@ghost
Copy link

ghost commented Aug 12, 2020

No, there are a few configurations where ZFS isn't a package at all, it's part of the FreeBSD base system. There is no pkg-config in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants