Skip to content

Fix Windows 3.14 pyexpat/elementtree duplicate-symbol link failure - #339

Merged
dwoz merged 2 commits into
mainfrom
fix/expat-2.9.0-xcs-main
Oct 30, 2026
Merged

dwoz merged 2 commits into
mainfrom
fix/expat-2.9.0-xcs-main

Conversation

@dwoz

@dwoz dwoz commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The earlier xcs.c fix (ee60b8c, landed in 0.22.28/0.22.29) appends #include \"xcs.c\" to Modules/expat/xmlparse.c whenever the dropped-in expat tarball ships xcs.c, on the assumption that Python's build system only compiles xmlparse.c/xmlrole.c/xmltok.c. That holds for setup.py-era Linux/macOS and for Python 3.10–3.13's PCbuild/pyexpat.vcxproj, but not for 3.14.9: its PCbuild/pyexpat.vcxproj and _elementtree.vcxproj already list xcs.c as ClCompile entries.
  • Result on Windows 3.14 (amd64 + x86) in CI: LNK2005 / LNK1169 on _elementtree.pyd and pyexpat.pyd — xcslen/xcscmp/xcsncmp are defined twice (once in xcs.obj, once in xmlparse.obj).
  • Fix: on Windows, gate the include on PCbuild/pyexpat.vcxproj not already listing expat\xcs.c. Pre-3.14 Windows and Linux/macOS behavior is unchanged.

Observed in https://github.com/saltstack/relenv/actions/runs/39711252360 (Python Windows (3.14, amd64) + Python Windows (3.14, x86)).

Test plan

  • CI: Python Windows (3.14, amd64) and Python Windows (3.14, x86) turn green
  • CI: Python Windows (3.10–3.13, amd64/x86) stay green (regression check — these rely on the include)
  • CI: Linux/macOS 3.14 stay green (untouched)

dwoz added 2 commits October 24, 2026 14:03
The earlier fix on this branch appended `#include "xcs.c"` to xmlparse.c
whenever the dropped-in expat tarball shipped xcs.c, on the assumption
that Python's build system only compiles xmlparse.c/xmlrole.c/xmltok.c.
That assumption holds for the setup.py-era Linux/macOS builds and for
Python 3.10-3.13's PCbuild/pyexpat.vcxproj, but not for 3.14.9: its
PCbuild/pyexpat.vcxproj and _elementtree.vcxproj already list xcs.c as
ClCompile entries. The relenv-added include then defined xcslen/xcscmp/
xcsncmp twice -- once in xcs.obj (CPython's build), once in xmlparse.obj
(our include) -- and the Windows link failed with LNK2005/LNK1169 on
_elementtree.pyd and pyexpat.pyd.

Gate the include on PCbuild/pyexpat.vcxproj not already listing xcs.c.
Pre-3.14 Windows and Linux/macOS behavior is unchanged.
@dwoz
dwoz merged commit a5429ad into main Oct 30, 2026
122 of 124 checks 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.

1 participant