Skip to content

php: ZEND_API was never defined, and cfghdr-sweep for the class - #723

Merged
staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd
Nov 5, 2026
Merged

staalmannen merged 1 commit into
mainfrom
claude/upgrade-ape-c-library-mmZGd

Conversation

@staalmannen

Copy link
Copy Markdown
Owner

TSRM/TSRM.c compiled -- the first object of the port -- and Zend/Optimizer/block_pass.c then answered, from zend_map_ptr.h:82, not a function' / not a parameter: zend_map_ptr_reset' / syntax error, last name: ZEND_API'. That is ZEND_API void zend_map_ptr_reset(void);' with ZEND_API an undefined identifier, and every ZEND_API in php is that shape, so the first file to declare anything would have failed whichever it was.

The cause is a blind spot in how the config.h was written. autoheader emits only #undef NAME'; anything spelled #define' in a .h.in is text copied straight through. php_config.h.in:7-15 copies three -- ZEND_API, ZEND_DLEXPORT, ZEND_DLIMPORT -- under an `#if defined(GNUC)' whose #else arm makes all three empty. Reading the generated config as a list of capabilities, which is the method used here, does not show them. The prologue is copied verbatim now, guard included, since that guard is already right for kencc.

21 names were missing in all, and the check that shows them is a diff of the two name sets: sys/lib/tests/cfghdr-sweep.py. It gates on a template #define the answered file does not carry, and reports without gating both an unanswered #undef (php's template asks 696 questions and 474 are deliberately silent) and a name the answered file invents, since only the author can tell an addition from a typo.

It found one of each on its first run. PHP_OS_FAMILY was mine and was a collision: main/php.h:38-51 computes it and ends in an unconditional #else "Unknown", so php.h would have redefined it with a different string. Plan 9 defines none of BSD, linux or the rest, so php answers "Unknown", which is true. And five names in clisp's hand-answered config, which builds and runs, so they are recorded rather than acted on -- which is why clisp is not in the gating list.

Its own control caught two faults in two runs: the include guard is a #define like any other and was being demanded of the answered file, and a name the template both #defines in a dead arm and #undefs elsewhere is a question rather than verbatim text -- clisp's WORDS_BIGENDIAN, which dropped the count from 6 to 5.

The other 18 are _GNU_SOURCE and its family, _STDC_WANT* and two Linux headers, left out deliberately: APE's feature macros are the three the mkfile already passes.

Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs

TSRM/TSRM.c compiled -- the first object of the port -- and
Zend/Optimizer/block_pass.c then answered, from zend_map_ptr.h:82,
`not a function' / `not a parameter: zend_map_ptr_reset' /
`syntax error, last name: ZEND_API'.  That is
`ZEND_API void zend_map_ptr_reset(void);' with ZEND_API an undefined
identifier, and every ZEND_API in php is that shape, so the first
file to declare anything would have failed whichever it was.

The cause is a blind spot in how the config.h was written.
autoheader emits only `#undef NAME'; anything spelled `#define' in a
.h.in is text copied straight through.  php_config.h.in:7-15 copies
three -- ZEND_API, ZEND_DLEXPORT, ZEND_DLIMPORT -- under an
`#if defined(__GNUC__)' whose #else arm makes all three empty.
Reading the generated config as a list of capabilities, which is the
method used here, does not show them.  The prologue is copied
verbatim now, guard included, since that guard is already right for
kencc.

21 names were missing in all, and the check that shows them is a
diff of the two name sets: sys/lib/tests/cfghdr-sweep.py.  It gates
on a template #define the answered file does not carry, and reports
without gating both an unanswered #undef (php's template asks 696
questions and 474 are deliberately silent) and a name the answered
file invents, since only the author can tell an addition from a typo.

It found one of each on its first run.  PHP_OS_FAMILY was mine and
was a collision: main/php.h:38-51 computes it and ends in an
unconditional #else "Unknown", so php.h would have redefined it with
a different string.  Plan 9 defines none of BSD, __linux__ or the
rest, so php answers "Unknown", which is true.  And five names in
clisp's hand-answered config, which builds and runs, so they are
recorded rather than acted on -- which is why clisp is not in the
gating list.

Its own control caught two faults in two runs: the include guard is
a #define like any other and was being demanded of the answered file,
and a name the template both #defines in a dead arm and #undefs
elsewhere is a question rather than verbatim text -- clisp's
WORDS_BIGENDIAN, which dropped the count from 6 to 5.

The other 18 are _GNU_SOURCE and its family, __STDC_WANT_* and two
Linux headers, left out deliberately: APE's feature macros are the
three the mkfile already passes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
@staalmannen
staalmannen merged commit ed986bc into main Nov 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants