asterisk / dahdi-linux

This is the official dahdi-linux repository. All issues and PR should be raised here.
GNU General Public License v2.0
47 stars 69 forks source link

In Rocky Linux 9.2 got "Fatal error: stdbool.h: No such file or directory" #36

Open rodolfojcj opened 11 months ago

rodolfojcj commented 11 months ago

When using the DAHDI linux complete 3.2.0 tar.gz file, trying to compile on Rocky Linux 9.2 fails with error messages like these:

make all
make -C linux all
make[1]: Entering directory '/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux'
make -C drivers/dahdi/firmware firmware-loaders
make[2]: Entering directory '/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi/firmware'
make[2]: Leaving directory '/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi/firmware'
make -C /lib/modules/5.14.0-284.25.1.el9_2.x86_64/build M=/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi DAHDI_INCLUDE=/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/include DAHDI_MODULES_EXTRA=" " HOTPLUG_FIRMWARE=yes modules DAHDI_BUILD_ALL=m
make[2]: Entering directory '/usr/src/kernels/5.14.0-284.25.1.el9_2.x86_64'
  CC [M] /usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi/wct4xxp/base.o
/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi/wct4xxp/base.c:49:10: fatal error: stdbool.h: No such file or directory
   49 | #include <stdbool.h>
      | ^~~~~~~~~~~
compilation terminated.
make[4]: *** [scripts/Makefile.build:321: /usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi/wct4xxp/base.o] Error 1
make[3]: *** [scripts/Makefile.build:607: /usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi/wct4xxp] Error 2
make[2]: *** [Makefile:1923: /usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux/drivers/dahdi] Error 2
make[2]: Leaving directory '/usr/src/kernels/5.14.0-284.25.1.el9_2.x86_64'
make[1]: *** [Makefile:74: modules] Error 2
make[1]: Leaving directory '/usr/src/dahdi-linux-complete-3.2.0+3.2.0/linux'
make: *** [Makefile:9: all] Error 2
'make all' failed with 512.

The running Linux kernel version looks like this:

Linux localhost.localdomain 5.14.0-284.25.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 2 14:53:30 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
InterLinked1 commented 11 months ago

Don't use the tarballs, those are all woefully obsolete and not up to date.

I'd recommend either installing from Git (master branch), and if that still doesn't work, you could try installing using PhreakScript: https://github.com/InterLinked1/phreakscript

rodolfojcj commented 11 months ago

I have the hypothesis that Red Hat backported some Linux kernel changes from upstream version 5.16 to its long supported RHEL 5.14 version, which means that it has some functionalities of 5.16, like not including the stdbool.h file when compiling Linux kernel modules, but the DAHDI 3.2.0+3.2.0 building process "thinks" that the running kernel is 5.14 and will insist in using stdbool.h.

That hypothesis is based on these:

From them I found this Rocky Linux 9.0, 9.1 and 9.2 kernel-devel packages:

  https://download.rockylinux.org/vault/rocky/9.0/devel/x86_64/os/Packages/k/kernel-devel-5.14.0-70.30.1.el9_0.x86_64.rpm
  https://download.rockylinux.org/vault/rocky/9.1/devel/x86_64/os/Packages/k/kernel-devel-5.14.0-162.23.1.el9_1.x86_64.rpm
  https://dl.rockylinux.org/pub/rocky/9/devel/x86_64/os/Packages/k/kernel-devel-5.14.0-284.25.1.el9_2.x86_64.rpm # this is 9.2 as of August 2023

I reviewed their contents, observing that for RL 9.0 its file /usr/src/kernels/5.14.0-70.30.1.el9_0.x86_64/Makefile does not have the Linux kernel change mentioned before, but RL 9.1 file /usr/src/kernels/5.14.0-162.23.1.el9_1.x86_64/Makefile and RL 9.2 file /usr/src/kernels/5.14.0-284.25.1.el9_2.x86_64/Makefile have it. Given this difference, I pressume that compiling DAHDI 3.2.0 on RL 9.0 will not give the stdbool.h related error.

InterLinked1 commented 11 months ago

I have the hypothesis that Red Hat backported some Linux kernel changes from upstream version 5.16 to its long supported RHEL 5.14 version, which means that it has some functionalities of 5.16, like not including the stdbool.h file when compiling Linux kernel modules, but the DAHDI 3.2.0+3.2.0 building process "thinks" that the running kernel is 5.14 and will insist in using stdbool.h.

This was already fixed for 5.16+ kernels[1], I just don't think there's a tarball that includes this change, hence my previous comment.

The check is simply #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) so it'd be odd if anything funky was going on.

[1] https://github.com/asterisk/dahdi-linux/commit/ca23e736942c53a621dad1bbb57dc4c966d6a84a

rodolfojcj commented 11 months ago

The attached file dahdi-linux-issue-36-fix-24sept2023.zip has a possible fix to this issue.

I tested it with:

In all those cases the compilation is successful.

Thanks in advance for any developer of this project that may review and possibly apply this fix for the master branch.