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

fs/zfs/icp/illumos-crypto.c:37:10: fatal error: sys/crypto/impl.h: No such file or directory - Linux v5.6 and ZFS v0.8.4 #10379

Closed
tsjk opened this issue May 27, 2020 · 17 comments
Labels
Type: Building Indicates an issue related to building binaries

Comments

@tsjk
Copy link

tsjk commented May 27, 2020

System information

Type Version/Name
Distribution Name Gentoo
Distribution Version N/A
Linux Kernel v5.6.13
Architecture AMD64
ZFS Version v0.8.4
SPL Version N/A

I get the following error during compilation:

fs/zfs/icp/illumos-crypto.c:37:10: fatal error: sys/crypto/impl.h: No such file or directory
   37 | #include <sys/crypto/impl.h>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [scripts/Makefile.build:267: fs/zfs/icp/illumos-crypto.o] Error 1
make[2]: *** [scripts/Makefile.build:505: fs/zfs/icp] Error 2
make[1]: *** [scripts/Makefile.build:505: fs/zfs] Error 2
make: *** [Makefile:1684: fs] Error 2
make: *** Waiting for unfinished jobs....

ZFS v0.8.3 w/ Linux v5.5 worked, with the same procedure I've used quite a while (the version is new however, duh!):

KERNEL_VERSION='linux-5.6_p7-pf'; ZFS_VERSION='0.8.4'; \
eselect kernel set "${KERNEL_VERSION}" && \
( cd "/usr/src/linux" && yes "" | make LD="ld.bfd" oldconfig && \
  make LD="ld.bfd" prepare scripts modules_prepare ) && \
env EXTRA_ECONF='--enable-linux-builtin' \
  ebuild /usr/portage/sys-fs/zfs-kmod/zfs-kmod-${ZFS_VERSION}.ebuild clean configure && \
( cd "/tmp/portage/sys-fs/zfs-kmod-${ZFS_VERSION}/work/zfs-${ZFS_VERSION}" && \
  ./copy-builtin /usr/src/linux )

After that I carry on with compilation:

KERNEL_VERSION='linux-5.6_p7-pf'; ZFS_VERSION='0.8.4'; \
emerge -1qv ~sys-fs/zfs-${ZFS_VERSION} && eselect kernel set "${KERNEL_VERSION}" && \
( cd /usr/src/linux && make LD="ld.bfd" clean && make LD="ld.bfd" oldconfig && \
  make LD="ld.bfd" prepare scripts modules_prepare && make LD="ld.bfd" vmlinux bzImage )

Should something be done differently?

And, it is true I have no /usr/include/sys/crypto/impl.h. But there is a /usr/src/linux-5.6_p7-pf/fs/zfs/icp/include/sys/crypto/impl.h (which is amongst the kernel sources I'm trying to compile.)

@tsjk
Copy link
Author

tsjk commented May 27, 2020

I just tried to recompile v5.5.13 with ZFS v0.8.4, which also failed. In addition, I recompiled .5.5.13 with ZFS v0.8.3 just now to indicate that nothing else is broken, and that executed successfully.

@tsjk tsjk changed the title fs/zfs/icp/illumos-crypto.c:37:10: fatal error: sys/crypto/impl.h: No such file or directory - Linux v5.6 and ZFS 0.8.4 fs/zfs/icp/illumos-crypto.c:37:10: fatal error: sys/crypto/impl.h: No such file or directory - Linux v5.6 and ZFS v0.8.4 May 27, 2020
@behlendorf behlendorf added the Type: Building Indicates an issue related to building binaries label May 27, 2020
@tsjk
Copy link
Author

tsjk commented May 30, 2020

Adding the make parameters

KBUILD_AFLAGS_KERNEL="-I./fs/zfs/icp/include" \
  KBUILD_CFLAGS_KERNEL="-I./fs/zfs/icp/include"

seems to work this around - it then compiles, and I'm running the new kernel, with functioning ZFS pools (including the rootfs one). Some of my Makefiles in the kernel source directory must be off somehow. I still think that this is a breakage in ZFS, but it might be something that the Gentoo ebuild does wrong.

@gcs-github
Copy link

I've run into a similar problem. It seems that in 0.8.3, the generated Makefile under fs/zfs/icp would contain include flags relative to the current kernel source directory, while 0.8.4 embeds a full path.

For example:

  • 0.8.3's fs/zfs/icp/Makefile contains : asflags-y := -I$(src)/include
  • 0.8.4's contains asflags-y := -I/var/tmp/portage/sys-fs/zfs-0.8.4-r1/work/zfs-0.8.4/module/icp/include (or whatever path constructed from what was passed to ./configure's --with-linux or --with-linux-obj parameters).

I think this is ZFS's mistake: relying on a path relative to the current kernel source directory in generated Makefiles is the right approach, as it should be possible to move a kernel source tree from one place to another and still be able to build the zfs kernel builtin. This is a regression.

@AttilaFueloep
Copy link
Contributor

Commit 65635c3 changed this, maybe @nivedita76 can comment?

@nivedita76
Copy link
Contributor

That was to work around a problem when kernel build dir != kernel source dir. The original issue #9988 has some more details.

Is the tmp directory where the zfs source was unpacked getting deleted before you build your kernel? I use the builtin setup on gentoo, but I don't use the ebuild, I just manually checkout the source from git and build.

I think a better solution than what I had earlier suggested, at least for in-kernel build, might be to use
-I$(srctree)/$(src)/include
That should also fix the earlier issue.

However, I am not sure how that will impact DKMS builds.

@nivedita76
Copy link
Contributor

cd "${KSRC}"
scripts/config --file "${KCFG}" -d ZFS
make -j${NJOBS} O="${KOBJ}" prepare
cd "${ZSRC}"
sh ./autogen.sh
./configure --with-config=kernel --enable-linux-builtin --with-linux="${KSRC}" --with-linux-obj="${KOBJ}"
./copy-builtin "${KSRC}"
cd "${KSRC}"
scripts/config --file "${KCFG}" -e ZFS
make -j${NJOBS} O="${KOBJ}"

This is how I build it, with appropriate defines for KSRC/KOBJ/KCFG/ZSRC/NJOBS.

@gcs-github
Copy link

Is the tmp directory where the zfs source was unpacked getting deleted before you build your kernel?

Yes. It'd be the case with an ebuild, but it's also the case for any setup in which you'd configure in some place, and build in another. Kernel source directories are always self-contained and portable. I don't think ZFS should break these assumptions.

My specific use case for this is generating a ZFS-builtin patch that can automatically be applied to any kernel within a kernel series over its lifetime: a patch generated from diff'ing a vanilla 5.x.y kernel source and a 5.x.y-with-builtin-zfs one can later be applied to vanilla sources 5.x.y+1, 5.x.y+2 ... 5.x.N with minimal effort. To top it all off, you can do that through in-house ebuilds, which is my case as well, which means I can technically hit this problem twice in one go. 😉

@nivedita76
Copy link
Contributor

Does this patch work for you?
includefix.txt

Outside of icp, the rest of the include dirs actually seem to get overridden by copy-builtin creating fs/zfs/Kbuild (to reference $(srctree), top of kernel source), though the original Makefile in module/Makefile.in uses abs_top_srcdir.

For consistency, it might be better to just include the icp include directory as well in copy-builtin?

@gcs-github
Copy link

gcs-github commented May 31, 2020

The patch you posted @nivedita76 seems to work for me. Thanks!

After your comment, I checked my generated zfs patch, and indeed, the original temporary build dir (the one from which ./configure is run) is referenced in generated Makefiles, mostly to feed variables such as abs_builddir, abs_srcdir, abs_top_builddir, abs_top_srcdir, as well as include directories in ZFS_MODULE_CFLAGS.

While I haven't noticed any build-time or runtime breakage from this, this would seem brittle. Maybe an experienced ZFS contributor should chime in, both on this and on your proposed inclusion of icp in ./copy-builtin.

@AttilaFueloep
Copy link
Contributor

Maybe an experienced ZFS contributor should chime in, both on this and on your proposed inclusion of icp in ./copy-builtin.

I agree, maybe @behlendorf can shed some light on this?

@behlendorf
Copy link
Contributor

I think adding the icp include directory to the ./copy-builtin script would be the best way to resolve this. That would be most consistent with the way it's handled by the rest of the build system. It would be great if someone could open a PR for this.

@nivedita76
Copy link
Contributor

There's another issue with @gcs-github's workflow in master. Commit bced7e3 moved out everything from the spl directory into os/linux/spl, and now has a stub Makefile that includes a reference to the zfs repository.

i.e. module/spl/Makefile.in includes @abs_top_build_dir@/module/os/linux/spl/Makefile

So if the zfs source directory is gone, builtin still doesn't work. Is there a reason we still have the module/spl directory rather than directly using module/os/linux/spl?

@nivedita76
Copy link
Contributor

@behlendorf I can send a PR for the copy-builtin change for now, but it's not a complete fix for master due to the issue in previous comment.

@behlendorf
Copy link
Contributor

@nivedita76 I'm not seeing the other issue, could you be more specific.

@nivedita76
Copy link
Contributor

@behlendorf , if you configure using --enable-linux-builtin, do copy-builtin and then move/delete the ZFS source directory, the kernel can't be built. This is what @gcs-github is trying to achieve, i.e. eliminate dependency on the ZFS tree once the configured sources have been copied into the kernel directory. My commit to the icp include dir is one issue, but there are more issues beyond that which prevent it.

This is because fs/zfs/spl/Makefile tries to include os/linux/spl/Makefile from the ZFS directory rather than the copy that's in the kernel tree. Same thing for fs/zfs/zfs/Makefile which includes os/linux/zfs/Makefile.

@nivedita76
Copy link
Contributor

Basically if you take the recipe in #10379 (comment), and insert mv "${ZSRC}" "${ZSRC}.bak" after the copy-builtin command. It breaks on the icp include issue and the two Makefile includes. Adding the right include directory in the top-level Kbuild file and fixing the directory for the two Makefile includes to use the kernel source directory instead makes the build work. I need to think of a clean way to fix them without breaking the modular build.

@nivedita76 nivedita76 mentioned this issue Jun 7, 2020
12 tasks
behlendorf pushed a commit that referenced this issue Jun 10, 2020
cmd/zpool and lib/libzutil Makefile's use -I., which won't work with a
VPATH build. Replace it with -I$(srcdir) instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10379
Closes #10421
@behlendorf
Copy link
Contributor

The fix for this was merged. Thanks for the patch @nivedita76.

BrainSlayer pushed a commit to BrainSlayer/zfs that referenced this issue Jun 10, 2020
The linux module can be built either as an external module, or compiled
into the kernel, using copy-builtin. The source and build directories
are slightly different between the two cases, and currently, compiling
into the kernel still refers to some files from the configured ZFS
source tree, instead of the copies inside the kernel source tree. There
is also duplication between copy-builtin, which creates a Kbuild file to
build ZFS inside the kernel tree, and the top-level module/Makefile.in.

Fix this by moving the list of modules and the CFLAGS settings into a
new module/Kbuild.in, which will be used by the kernel kbuild
infrastructure, and using KBUILD_EXTMOD to distinguish the two cases
within the Makefiles, in order to choose appropriate include
directories etc.

Module CFLAGS setting is simplified by using subdir-ccflags-y (available
since 2.6.30) to set them in the top-level Kbuild instead of each
individual module. The disabling of -Wunused-but-set-variable is removed
from the lua and zfs modules. The variable that the Makefile uses is
actually not defined, so this has no effect; and the warning has long
been disabled by the kernel Makefile itself.

The target_cpu definition in module/{zfs,zcommon} is removed as it was
replaced by use of CONFIG_SPARC64 in
  commit 70835c5 ("Unify target_cpu handling")

os/linux/{spl,zfs} are removed from obj-m, as they are not modules in
themselves, but are included by the Makefile in the spl and zfs module
directories. The vestigial Makefiles in os and os/linux are removed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10379
Closes openzfs#10421
BrainSlayer pushed a commit to BrainSlayer/zfs that referenced this issue Jun 10, 2020
cmd/zpool and lib/libzutil Makefile's use -I., which won't work with a
VPATH build. Replace it with -I$(srcdir) instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10379
Closes openzfs#10421
lundman referenced this issue in openzfsonosx/openzfs Jun 12, 2020
The linux module can be built either as an external module, or compiled
into the kernel, using copy-builtin. The source and build directories
are slightly different between the two cases, and currently, compiling
into the kernel still refers to some files from the configured ZFS
source tree, instead of the copies inside the kernel source tree. There
is also duplication between copy-builtin, which creates a Kbuild file to
build ZFS inside the kernel tree, and the top-level module/Makefile.in.

Fix this by moving the list of modules and the CFLAGS settings into a
new module/Kbuild.in, which will be used by the kernel kbuild
infrastructure, and using KBUILD_EXTMOD to distinguish the two cases
within the Makefiles, in order to choose appropriate include
directories etc.

Module CFLAGS setting is simplified by using subdir-ccflags-y (available
since 2.6.30) to set them in the top-level Kbuild instead of each
individual module. The disabling of -Wunused-but-set-variable is removed
from the lua and zfs modules. The variable that the Makefile uses is
actually not defined, so this has no effect; and the warning has long
been disabled by the kernel Makefile itself.

The target_cpu definition in module/{zfs,zcommon} is removed as it was
replaced by use of CONFIG_SPARC64 in
  commit 70835c5 ("Unify target_cpu handling")

os/linux/{spl,zfs} are removed from obj-m, as they are not modules in
themselves, but are included by the Makefile in the spl and zfs module
directories. The vestigial Makefiles in os and os/linux are removed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10379
Closes #10421
lundman referenced this issue in openzfsonosx/openzfs Jun 12, 2020
cmd/zpool and lib/libzutil Makefile's use -I., which won't work with a
VPATH build. Replace it with -I$(srcdir) instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10379
Closes #10421
jsai20 pushed a commit to jsai20/zfs that referenced this issue Mar 30, 2021
The linux module can be built either as an external module, or compiled
into the kernel, using copy-builtin. The source and build directories
are slightly different between the two cases, and currently, compiling
into the kernel still refers to some files from the configured ZFS
source tree, instead of the copies inside the kernel source tree. There
is also duplication between copy-builtin, which creates a Kbuild file to
build ZFS inside the kernel tree, and the top-level module/Makefile.in.

Fix this by moving the list of modules and the CFLAGS settings into a
new module/Kbuild.in, which will be used by the kernel kbuild
infrastructure, and using KBUILD_EXTMOD to distinguish the two cases
within the Makefiles, in order to choose appropriate include
directories etc.

Module CFLAGS setting is simplified by using subdir-ccflags-y (available
since 2.6.30) to set them in the top-level Kbuild instead of each
individual module. The disabling of -Wunused-but-set-variable is removed
from the lua and zfs modules. The variable that the Makefile uses is
actually not defined, so this has no effect; and the warning has long
been disabled by the kernel Makefile itself.

The target_cpu definition in module/{zfs,zcommon} is removed as it was
replaced by use of CONFIG_SPARC64 in
  commit 70835c5 ("Unify target_cpu handling")

os/linux/{spl,zfs} are removed from obj-m, as they are not modules in
themselves, but are included by the Makefile in the spl and zfs module
directories. The vestigial Makefiles in os and os/linux are removed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10379
Closes openzfs#10421
jsai20 pushed a commit to jsai20/zfs that referenced this issue Mar 30, 2021
cmd/zpool and lib/libzutil Makefile's use -I., which won't work with a
VPATH build. Replace it with -I$(srcdir) instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10379
Closes openzfs#10421
sempervictus pushed a commit to sempervictus/zfs that referenced this issue May 31, 2021
The linux module can be built either as an external module, or compiled
into the kernel, using copy-builtin. The source and build directories
are slightly different between the two cases, and currently, compiling
into the kernel still refers to some files from the configured ZFS
source tree, instead of the copies inside the kernel source tree. There
is also duplication between copy-builtin, which creates a Kbuild file to
build ZFS inside the kernel tree, and the top-level module/Makefile.in.

Fix this by moving the list of modules and the CFLAGS settings into a
new module/Kbuild.in, which will be used by the kernel kbuild
infrastructure, and using KBUILD_EXTMOD to distinguish the two cases
within the Makefiles, in order to choose appropriate include
directories etc.

Module CFLAGS setting is simplified by using subdir-ccflags-y (available
since 2.6.30) to set them in the top-level Kbuild instead of each
individual module. The disabling of -Wunused-but-set-variable is removed
from the lua and zfs modules. The variable that the Makefile uses is
actually not defined, so this has no effect; and the warning has long
been disabled by the kernel Makefile itself.

The target_cpu definition in module/{zfs,zcommon} is removed as it was
replaced by use of CONFIG_SPARC64 in
  commit 70835c5 ("Unify target_cpu handling")

os/linux/{spl,zfs} are removed from obj-m, as they are not modules in
themselves, but are included by the Makefile in the spl and zfs module
directories. The vestigial Makefiles in os and os/linux are removed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10379
Closes openzfs#10421
sempervictus pushed a commit to sempervictus/zfs that referenced this issue May 31, 2021
cmd/zpool and lib/libzutil Makefile's use -I., which won't work with a
VPATH build. Replace it with -I$(srcdir) instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes openzfs#10379
Closes openzfs#10421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Building Indicates an issue related to building binaries
Projects
None yet
Development

No branches or pull requests

5 participants