Fix cross-compilation issues w/ custom toolchain#2797
Merged
DL6ER merged 6 commits intopi-hole:developmentfrom Mar 6, 2026
Merged
Fix cross-compilation issues w/ custom toolchain#2797DL6ER merged 6 commits intopi-hole:developmentfrom
DL6ER merged 6 commits intopi-hole:developmentfrom
Conversation
Most cross-compilation tools terminate the build, when they encounter unsafe (e.g. absolute) paths in include directives, because that might leak host components into the target. Buildroot fails with: i586-buildroot-linux-uclibc-gcc: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/local/include' Remove offending path snippet to correspond with all other include definitions in Pi-hole/FTL. Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
If sys/random.h cannot be found, the build terminates with this error:
pihole-ftl-6.5/src/config/password.c: In function ‘get_secure_randomness’:
pihole-ftl-6.5/src/config/password.c:100:52: error: ‘GRND_NONBLOCK’ undeclared (first use in this function); did you mean ‘SOCK_NONBLOCK’?
100 | result = getrandom(buffer, length, GRND_NONBLOCK);
| ^~~~~~~~~~~~~
| SOCK_NONBLOCK
Add the missing definition of GRND_NONBLOCK in daemon.h.
Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
The __GLIBC__ version check causes problems with uClibc, because this library also defines these variables, but the numbering is not consistent with GNU libc. This prevents the inclusion of sys/random.h in a uClibc toolchain, even if the file is present Instead let CMake detect sys/random.h and control header inclusion with a preprocessor symbol. Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
The __GLIBC__ logic to detect stack backtracing capability fails for
uClibc, because uClibc also defines these symbols, but backtrace
functionality is optional.
pihole-ftl-6.5/src/signals.c:13:10: fatal error: execinfo.h: No such file or directory
13 | #include <execinfo.h>
| ^~~~~~~~~~~~
Instead of adding unreadable preprocessor exceptions, have CMake detect
execinfo.h and use a appropriate preprocessor symbol.
Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
Building with a custom toolchain (GCC 15, uClibc, kernel headers 5.10)
fails in netlink.c with errors like these:
pihole-ftl-6.5/src/tools/netlink_consts.h:40:11: error: ‘ARPHRD_MCTP’ undeclared here (not in a function); did you mean ‘ARPHRD_FCPP’?
40 | { ARPHRD_MCTP, "mctp" },
| ^~~~~~~~~~~
| ARPHRD_FCPP
pihole-ftl-6.5/src/tools/netlink_consts.h:148:11: error: ‘RTPROT_OPENR’ undeclared here (not in a function); did you mean ‘RTPROT_OSPF’?
148 | { RTPROT_OPENR, "openr" },
| ^~~~~~~~~~~~
| RTPROT_OSPF
Bracket undeclared symbols with precompiler directives.
Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
Building with a custom toolchain (GCC 15, uClibc, kernel headers 5.10)
fails in netlink.c with errors like these:
pihole-ftl-6.5/src/signals.c:214:30: error: ‘BUS_MCEERR_AR’ undeclared (first use in this function)
214 | case BUS_MCEERR_AR: log_info(" with code: BUS_MCEERR_AR (Hardware memory error: action required)"); break;
| ^~~~~~~~~~~~~
pihole-ftl-6.5/src/signals.c:214:30: note: each undeclared identifier is reported only once for each function it appears in
pihole-ftl-6.5/src/signals.c:215:30: error: ‘BUS_MCEERR_AO’ undeclared (first use in this function)
215 | case BUS_MCEERR_AO: log_info(" with code: BUS_MCEERR_AO (Hardware memory error: action optional)"); break;
| ^~~~~~~~~~~~~
Bracket undeclared symbols with precompiler directives.
Signed-off-by: Andreas Ziegler <15275159+aeolio@users.noreply.github.com>
DL6ER
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR aim to accomplish?:
Trying to build Pi-hole inside a Buildroot build environment, I ran into a few issues. Most are related to the custom toolchain used (i586 /GCC 15 /uClibc /kernel headers 5.10 /binutils 2.45.1).
I have not squashed my commits, because I think they are easier to read and review if left separate.
I stole one change shamelessly from #2762 (it was also in my backlog, but @rehsack showed that the additional path could be omitted).
4afe481
Absolute include in path in webserver/civetweb/CMakeLists.txt prevents cross-compilation.
edfb685
The getrandom() fallback has not been used for some time and needed fixing.
3408d23 and 3e3f635
The
__GLIBC__macro is also used by uClibc, but the version information is outdated. This notoriously causes problems also in other projects.e3a3b6e and 1fa09a8
Precompiler symbols missing in the toolchain, some related to uClibc, most to the kernel version. Linux 5.10 is a LTS version, and will be supported for another 10 years by the CIP project.
How does this PR accomplish the above?:
A number of precompiler checks were introduced for missing symbols. Unless self explanatory, they were commented in the prevalent style.
The most significant change is the insertion of logic in CMakelists.txt to detect optional include files (sys/random.h, execinfo.h). This allows replacing of unreadable and often problematic C library detection code with monotonic symbols generated by CMake.
Link documentation PRs if any are needed to support this PR:
(No change in functionality)
By submitting this pull request, I confirm the following:
git rebase)