Skip to content

Commit 27371fa

Browse files
authored
Fix Windows --nano build: include entry declaration header in extension TU (#134)
On Windows, --nano runs in nano-policy mode (nanoMode=false, nanoPolicyMode=true) using the WINDOWS_DLL backend. RINIT then emits a direct C++ call to php_main() instead of relying on ZendVM eval, but the extension translation unit never included the entry function's declaration header, so the php_main() prototype was missing and MSVC failed with C3861. genExtensionIncludeHeaderFiles() only added declaration headers for stub files and attribute-factory owners, never the entry's source file. Include the entry function's declaration header when nano-policy mode is active so php_main() is visible where RINIT references it. Verified: a minimal --nano program now compiles, links and runs on Windows (previously failed at extension-<target>.cc with 'php_main': identifier not found).
1 parent 8b33cad commit 27371fa

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/Translator.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,20 @@ private function genExtensionIncludeHeaderFiles(): string
35353535
$declarationHeaders[] = $header;
35363536
}
35373537
}
3538+
// Nano policy mode (Windows, the WINDOWS_DLL backend) emits a direct
3539+
// php_main() call inside RINIT instead of relying on ZendVM eval, so
3540+
// the entry function's declaration header — which carries the
3541+
// php_main() prototype — must be visible to this translation unit.
3542+
// True Nano mode keeps php_main() encapsulated inside the separate
3543+
// nano-entry translation unit, so only the policy path needs this.
3544+
if ($this->isNanoPolicyMode() && $this->hasFunction(self::ENTRY_FUNCTION)) {
3545+
$entryHeader = $this->declarationHeaderFiles[
3546+
$this->getFunction(self::ENTRY_FUNCTION)->sourceFile
3547+
] ?? null;
3548+
if ($entryHeader !== null && !in_array($entryHeader, $declarationHeaders, true)) {
3549+
$declarationHeaders[] = $entryHeader;
3550+
}
3551+
}
35383552
}
35393553

35403554
return $this->renderIncludeHeaderFiles([

0 commit comments

Comments
 (0)