build(cmake): fail loudly when the readline library is found but its headers are missing#483
Merged
Conversation
…headers are missing FindReadline set HAVE_LIBREADLINE from a check_function_exists(readline) that a bare runtime library -- or libedit's readline() compatibility symbol -- also satisfies, while the header probes look only for <readline.h> / <readline/readline.h>. On a box with the library but no development headers (e.g. Alpine with libedit-dev but no readline-dev), config.h carried HAVE_LIBREADLINE with no header macro, and ExternalConnector.cpp -- which gates its rl_* block on HAVE_LIBREADLINE alone -- failed deep in the build with "rl_compentry_func_t does not name a type" and friends (amule-project#481). Require a usable header too: when the library is found but neither header is, stop at configure time with a message naming the missing package (Alpine readline-dev / Debian libreadline-dev / Fedora readline-devel / Homebrew readline) instead of a confusing mid-build error.
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.
Summary
Fixes the confusing Alpine build failure reported in #481:
Root cause
cmake/FindReadline.cmakesetsHAVE_LIBREADLINEfrom acheck_function_exists(readline)that linksreadline/edit/editline. That succeeds not only with GNU readline but also with libedit (which exports areadline()compatibility symbol), or with a barelibreadline.soruntime and no-devheaders installed. The header probes, however, look only for<readline.h>/<readline/readline.h>.So on a box with the library but not the matching development headers — Alpine with
libedit-devbut noreadline-devis the common trigger —config.hends up withHAVE_LIBREADLINEbut no header macro.src/ExternalConnector.cppgates itsrl_*block onHAVE_LIBREADLINEalone while including the header underHAVE_READLINE_READLINE_H/HAVE_READLINE_H, so therl_*symbols are used undeclared and the build dies deep in compilation.Fix
Require a usable header, not just the library. When the library is found but neither header is, stop at configure time with a message naming the missing package, instead of a confusing mid-build error:
Validation
libedit-dev, noreadline-dev): configure now stops with the message above; afterapk add readline-dev→HAVE_LIBREADLINE=1, header found,Configuring done.amulecmdbuilds.Refs #481