diff --git a/AGENTS.md b/AGENTS.md index ee5fc75ed82..1905d950a9a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,6 +30,42 @@ extension GCC accepts. A C99 feature may be used only under in `include/ap_config.h`, with a C89 fallback in the `#else` branch; see `include/http_log.h`. +## APR and APR-util versions + +httpd builds against APR 1.x plus APR-util 1.x, and against APR 2.x +(APR trunk), which has APR-util merged into it. Code conditional on an +APR-util feature must come out right for both. + +Include `apu_version.h` unconditionally before testing +`APU_MAJOR_VERSION` or `APU_MINOR_VERSION`. APR 2.x ships that header +too, defining the `APU_*_VERSION` macros to the `APR_*_VERSION` ones, so +one test covers both: + +```c +#include "apu_version.h" + +#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7) +/* APR-util 1.7 API */ +#else +/* fallback */ +#endif +``` + +Do not wrap the include in `#if !APR_VERSION_AT_LEAST(2,0,0)` or +`#if APR_MAJOR_VERSION < 2`, as some existing code does. Without the +header an undefined `APU_MAJOR_VERSION` evaluates to 0 in `#if`, so +under APR 2.x the test is silently false and the fallback is compiled. + +Mind the minimum versions too. `configure` on trunk requires APR 1.6 +and APR-util 1.6; on 2.4.x it requires only APR 1.4 and APR-util 1.3. +Trunk code which is a candidate for backport must therefore either keep +to the APIs of those older versions, or put anything newer under a +version test with a fallback, or the backport will need rewriting. + +Either branch may never have been compiled locally, so build against +both an APR-util older than the version tested for and APR trunk when +touching such code, or say which was not built. + ## Building A git checkout has no `configure` script; generate it with `buildconf`, diff --git a/configure.in b/configure.in index 048a88c6733..83ecde05fdc 100644 --- a/configure.in +++ b/configure.in @@ -423,12 +423,12 @@ AC_USE_SYSTEM_EXTENSIONS # Ensure that satisfactory versions of apr and apr-util are # found if external copies are configured. if test "${apr_found}" = "yes"; then - # Require at least APR 1.3.x otherwise fail - APACHE_CHECK_APxVER([apr], 1, 3) + # Require at least APR 1.6.x otherwise fail + APACHE_CHECK_APxVER([apr], 1, 6) fi if test "${apu_found}" = "yes"; then - # Require at least APR-util 1.3.x otherwise fail + # Require at least APR-util 1.6.x otherwise fail if test "${apr_found}" = "yes"; then # we need to add the APR includes to CPPFLAGS apu_ckver_CPPFLAGS="$CPPFLAGS" diff --git a/modules/aaa/mod_authn_dbm.c b/modules/aaa/mod_authn_dbm.c index e4f965ab8ff..a81b79d0e29 100644 --- a/modules/aaa/mod_authn_dbm.c +++ b/modules/aaa/mod_authn_dbm.c @@ -38,10 +38,7 @@ #include "mod_auth.h" -#include "apr_version.h" -#if !APR_VERSION_AT_LEAST(2,0,0) #include "apu_version.h" -#endif static APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authn_cache_store = NULL; #define AUTHN_CACHE_STORE(r,user,realm,data) \ diff --git a/modules/aaa/mod_authz_dbm.c b/modules/aaa/mod_authz_dbm.c index f11de6897e6..249ac4ee6dc 100644 --- a/modules/aaa/mod_authz_dbm.c +++ b/modules/aaa/mod_authz_dbm.c @@ -20,10 +20,7 @@ #include "apr_dbm.h" #include "apr_md5.h" -#include "apr_version.h" -#if !APR_VERSION_AT_LEAST(2,0,0) #include "apu_version.h" -#endif #include "httpd.h" #include "http_config.h" diff --git a/modules/cache/mod_socache_dbm.c b/modules/cache/mod_socache_dbm.c index 055163a9aa7..c57c8876f2f 100644 --- a/modules/cache/mod_socache_dbm.c +++ b/modules/cache/mod_socache_dbm.c @@ -28,10 +28,7 @@ #define APR_WANT_STRFUNC #include "apr_want.h" #include "apr_dbm.h" -#include "apr_version.h" -#if !APR_VERSION_AT_LEAST(2,0,0) #include "apu_version.h" -#endif #if APR_HAVE_UNISTD_H #include diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 9891545238c..d3ffd72f340 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -55,10 +55,7 @@ #include "apr_dbm.h" #include "apr_dbd.h" -#include "apr_version.h" -#if !APR_VERSION_AT_LEAST(2,0,0) #include "apu_version.h" -#endif #include "mod_dbd.h" diff --git a/modules/proxy/mod_proxy_express.c b/modules/proxy/mod_proxy_express.c index 5d458c4a1c4..1bd9492b6f5 100644 --- a/modules/proxy/mod_proxy_express.c +++ b/modules/proxy/mod_proxy_express.c @@ -19,10 +19,7 @@ module AP_MODULE_DECLARE_DATA proxy_express_module; -#include "apr_version.h" -#if !APR_VERSION_AT_LEAST(2,0,0) #include "apu_version.h" -#endif static int proxy_available = 0;