Skip to content

Instantly share code, notes, and snippets.

@diabloneo
Created February 23, 2022 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diabloneo/ae77439a0304d1f61c2ed436ed38e1ec to your computer and use it in GitHub Desktop.
Save diabloneo/ae77439a0304d1f61c2ed436ed38e1ec to your computer and use it in GitHub Desktop.
Build kernel-ark 5.15 with mock config centos-stream+epel8-x86_64 failed

I tried to build kernel 5.15 for Rocky Linux 8 with mock. But I failed on tools/iio

The error is gcc can not find the correct headers:

~/build/BUILD/kernel-5.15.19-0.test/linux-5.15.19-0.test.el8.x86_64
~/build/BUILD/kernel-5.15.19-0.test/linux-5.15.19-0.test.el8.x86_64/tools/iio ~/build/BUILD/kernel-5.15.19-0.test/linux-5.15.19-0.test.el8.x86_64
+ popd
+ pushd tools/iio/
+ /usr/bin/make -s 'HOSTCFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'HOSTLDFLAGS=-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'LDFLAGS=-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' -s
iio_utils.c: In function 'iioutils_break_up_name':
iio_utils.c:65:8: warning: implicit declaration of function 'asprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]
  ret = asprintf(generic_name, "%s_%s", prefix, working);
        ^~~~~~~~
        vsprintf
iio_event_monitor.c:59:3: error: 'IIO_POSITIONRELATIVE' undeclared here (not in a function); did you mean 'IIO_HUMIDITYRELATIVE'?
  [IIO_POSITIONRELATIVE] = "positionrelative",
   ^~~~~~~~~~~~~~~~~~~~
   IIO_HUMIDITYRELATIVE
...
make[1]: *** [/builddir/build/BUILD/kernel-5.15.19-0.test/linux-5.15.19-0.test.el8.x86_64/tools/build/Makefile.build:97: iio_event_monitor.o] Error 1
make: *** [Makefile:48: iio_event_monitor-in.o] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.M9tfqw (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.M9tfqw (%build)

The environment is a x86_64 Virtual Machine installed with a Rocky Linux 8.5 and all necessary packages for kernel build.

I use kernel-ark project to build the kernel packages: https://gitlab.com/cki-project/kernel-ark/-/tree/fedora-5.15, and I built it with mock and mock-core-configs.

The procedure:

$ cd kernel-ark
$ make dist-configs
$ make dist-srpm
$ mock -r centos-stream+epel-8-x86_64 --init
$ mock -r centos-stream+epel-8-x86_64 --no-clean redhat/rpm/SRPMS/kernel-5.15.19-0.test.el8.src.rpm

This will failed with the message as above.

The interesting thing is the build procedure of same code will succeed with fedora-35-x86_64 mock config:

$ mock -r redora-35-x86_64 --no-clean redhat/rpm/SRPMS/kernel-5.15.19-0.test.el8.src.rpm

Any body has clues?

FYI: I modified the redhat/kernel.spec.template to build tools/iio early, so the problem can be debugged easier. The patch is

[root@kernel kernel-ark]# git diff
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index f6d440767964..506930bd9536 100755
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -2155,6 +2155,9 @@ mkdir -p $RPM_BUILD_ROOT%{_libexecdir}

 cd linux-%{KVERREL}

+pushd tools/iio
+%{make} CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{?make_opts}
+popd

 %if %{with_debug}
 BuildKernel %make_target %kernel_image %{_use_vdso} debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment