https://bz.apache.org/bugzilla/show_bug.cgi?id=69953
Bug ID: 69953
Summary: 2.4.66 Build regression: Header shadowing and
undeclared identifiers in listen.c and exports.c on
modern LLVM/Clang.
Product: Apache httpd-2
Version: 2.4.66
Hardware: PC
OS: Mac OS X 10.1
Status: NEW
Severity: normal
Priority: P2
Component: Build
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Building HTTPD 2.4.66 on Darwin fails when an existing installation of an older
version (e.g., 2.4.62) is present in the target include prefix. The build
system's INCLUDES priority causes the compiler to "shadow" new source headers
with old installed headers, leading to multiple "undeclared identifier" errors
for macros and enums introduced or refactored in 2.4.66.
Removing the include files from the prior version 2.4.62 of Apache removed the
issues/errors in configure. I tried installing 2.4.63, 2.4.64, 2.4.65 and
2.4.66 - the only one I could install was 2.4.62 since its headers matched what
was in source.
Environment:
MacOS Sonoma (Darwin 23.6.0) on arm64 (Apple Silicon M3)
Compiler: LLVM/Clang version 21.1.8 (Target: arm64-apple-darwin23.6.0)
Incremental upgrade from 2.4.62 to 2.4.66 using a persistent install prefix.
I have a isolated prefix setup for installing apache for development which I
have been maintaining and updating for years on MacOS/Centos, partly based on
linux from scratch, so it's not reliant on the overall OS, which gives me a
setup much like xampp, which I can install on AWS systems. I use bash scripts
to run config script that store my download/configure/make install process.
Pretty sure this same issue is in apple's clang, but I only figured out what is
going on after I started moving to llvm, I got stuck at not being able to
update past 2.4.62 a while back, and looking back it was probably this issue.
Same issue with apr via srclib, and using apr/apr-util which are installed
prior in source. Note that I did extensive hacking of the source code, trying
to get it to ignore the errors
Issue 1: server/listen.c - Missing Macros
The compiler fails to resolve DEFAULT_TCP_DEFER_ACCEPT because it loads the
2.4.62 version of ap_listen.h from the system include path instead of the
2.4.66 version in the source tree.
Error: use of undeclared identifier 'DEFAULT_TCP_DEFER_ACCEPT'
Impact: Prevents compilation of core listener logic on non-Linux platforms
where this macro should default to 0.
Issue 2: ap_stat_check Visibility in exports.c
New symbols added to the bottom of httpd.h (specifically ap_stat_check) are not
consistently resolved during the make_exports phase on Darwin. Due to the
strictness of Clang 21+, this triggers a hard failure.
Error: call to undeclared function 'ap_stat_check'; ISO C99 and later do not
support implicit function declarations.
Issue 3: APR Entropy Regression (AH00141)
APR's configure logic on Darwin incorrectly attempts to use an EGD-compatible
daemon for entropy instead of the native arc4random_buf or /dev/urandom. If
--with-egd is triggered (or incorrectly guessed by buildconf), the server fails
at runtime.
Error: AH00141: Could not initialize random number generator (Status: 2 /
ENOENT)
Verification: Verified that /dev/urandom is healthy; failure is due to APR
hunting for a non-existent EGD socket.
Steps to Reproduce:
Install Apache 2.4.62 to a custom prefix, assuming on Darwin.
Extract 2.4.66 source and run ./configure using the same prefix.
Run make. The compiler will pick up old headers from the prefix before
searching the source include/ directory.
Proposed Fixes:
Include Priority: Update Makefile.in to ensure ${top_srcdir}/include always
takes precedence over user-provided -I prefix paths.
Darwin Shims: Provide explicit fallbacks for DEFAULT_TCP_DEFER_ACCEPT in
ap_listen.h when TCP_DEFER_ACCEPT is not defined by the OS.
A version in the headers, might be a way to ensure the configure has the
correct headers, and throw an error if there is a mismatch. I was also very
hard to figure out which header files are apache, there isn't a single prefix
or folder - it was only because I installed 2.4.62 to do a compare and diff
with 2.4.66, that I new which was which based on date.
APR Entropy: Update apr/configure.in to prioritize arc4random_buf on Darwin and
skip EGD checks. ( This EGD parameter was leftover from my using the same
config for both aws linux and this macos, a more clear warning about using
--egd would have been helpful as well. )
Some evidence for what I was seeing.
This is some of my make log output showing the include order.
/Users/.../diverge/tools/bin/clang \
-isysroot /Applications/Xcode.app/Contents/.../MacOSX.sdk \
-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK \
-I/Users/.../diverge/include/openssl \
-I/Users/.../diverge/include \ <-- [SHADOW SOURCE: Old 2.4.62 headers here]
-I. -I/Users/.../bld/httpd-2.4.66/include \
-I/Users/.../src/httpd-2.4.66/os/unix \
-I/Users/.../src/httpd-2.4.66/include \ <-- [ACTUAL SOURCE: New 2.4.66
headers here]
...
-c /Users/.../src/httpd-2.4.66/server/listen.c
/Users/.../src/httpd-2.4.66/server/listen.c:951:31: error: use of undeclared
identifier 'DEFAULT_TCP_DEFER_ACCEPT'
951 | ap_listentcpdeferaccept = DEFAULT_TCP_DEFER_ACCEPT;
The error log showing LLVM 21 strictly enforcing prototypes.
/Users/.../src/httpd-2.4.66/server/core.c:5520:23: error: call to undeclared
function 'ap_stat_check';
ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
5520 | apr_status_t rv = ap_stat_check(r->filename, r->pool);
| ^
APR log showing wrong entrophy source, this caused it to install, but when run
it throws error.
checking for sys/random.h... yes
checking for getrandom... no
checking for arc4random_buf... yes <-- [CORRECT SOURCE DETECTED]
checking for entropy source... EGD-compatible daemon <-- [WRONG SOURCE CHOSEN]
This shows the symbol in the right spot, showing the shadowing, since the
header being used was from 2.4.62.
# Grep of the fresh 2.4.66 httpd.h
$ grep -n "ap_stat_check" include/httpd.h
2711: AP_DECLARE(apr_status_t) ap_stat_check(const char *path, apr_pool_t
*pool);
Once I removed all the headers in the prefix/include folder, httpd.h, ap_*,
os.h, and some other odd files which I knew were just installed by the older
apache, the various issues stopped.
Then running the make for 2.4.66 all the "undeclared identifier" and "implicit
declaration" errors vanished. The compiler was forced to use the 2.4.66 headers
from the source directory. This allowed DEFAULT_TCP_DEFER_ACCEPT,
CONN_STATE_PROCESSING, and ap_stat_check to be correctly resolved.
The HTTPD 2.4.66 Makefile incorrectly allows the user-provided prefix -I flags
to shadow the core source headers. While a "clean" machine (no previous Apache
install) builds successfully, any developer or system performing an in-place
upgrade with a persistent prefix will encounter these hard failures.
By manually 'sidelining' (moving) the existing Apache headers (ap_*.h, httpd.h,
os.h, mod_*.h, util_*.h) from the install prefix (/Users/.../diverge/include)
to a temporary backup directory, the HTTPD 2.4.66 build completed without a
single manual code patch. This confirms that the 2.4.66 Makefile incorrectly
allows the user-provided -I prefix paths to take precedence over the internal
source includes.
On modern, strict toolchains (LLVM/Clang 21+), this 'Header Shadowing' is a
fatal build regression. The compiler attempts to use 2.4.66 .c logic with
2.4.62 .h definitions, leading to the undeclared identifiers and structural
mismatches documented above.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]