Repository navigation
Conversation
|
92db8a8 to
eb73406
Compare
itk_png_mangle.h.in predates libpng 1.6.54, so nine exported symbols keep their upstream names: png_fixed_ITU, png_handle_chunk, png_resolve_file_gamma, png_set_rgb_coefficients, png_write_cICP, png_write_cLLI_fixed, png_write_mDCV_fixed, png_XYZ_from_xy and png_xy_from_XYZ. A static build linking both itkpng and VTK's vtkpng then fails with LNK2005; a shared build hides the duplicate behind the DLL boundary. The seven ARM NEON filter-row entries carry the leading underscore of the Mach-O symbol, so they define a token that never appears in the sources. pngpriv.h spells them without it.
eb73406 to
03d3c79
Compare
|
Reproduced the Environment: MSVC 19.38.33145 (VS 2022, toolset 14.38), Ninja, Release x64, static ( Symbol-level before/afterBuilt the
A byte-order diff of the full symbol sets shows exactly 9 removed and exactly 9 added — a clean 1:1 rename to LNK2005 reproductionThe VTK version matters, and 9.3.1 cannot reproduce this. VTK 9.3.1 vendors libpng 1.6.37, which does not contain these functions at all, and its VTK Forcing both archives into one link: Before (ITK After (this PR) — exit 0, 0 × LNK2005, executable produced. Identical link command; only Caveat on the
|
|
Follow-up: I have now reproduced the failure through Configuration: static ITK + static VTK Before — ITK
|
6fe98c6
into
InsightSoftwareConsortium:main
COMP: Mangle libpng ARM NEON filter-row symbols (backport #6821 to release-5.4)
Problem
Three static Windows nightlies fail with 10 build errors each —
Windows11-VS2022-Static-Release,Windows11-VS2022-Static-DebugTBB,Windows11-VS2019-Static-ReleaseTBB— all from one root cause:Root cause
Not a VTK problem, and not new upstream behavior.
itkpngis supposed to rename every exported symbolthrough
itk_png_mangle.h.in, so that a program may link it alongside another libpng. That header isregenerated by hand from
nmoutput; the recipe is documented in its own comment block. It was not re-runwhen
UpdateFromUpstream.shmoved the pin tov1.6.54.libpng 1.6.54 exports nine functions the header predates:
These are exactly the nine
LNK2005names. Shared builds resolve the duplicate at the DLL boundary, whichis why only the static Windows configurations fail — the leak itself is present on every platform.
A second, independent defect surfaced while measuring the first. Seven ARM NEON entries read:
The leading underscore is Mach-O symbol decoration, not part of the C identifier —
pngpriv.h:1529declares
png_read_filter_row_up_neon. The recipe was last run on macOS without stripping the decoration,so these defines name a token that appears nowhere in the sources and have never applied. All seven
functions export unmangled from every ARM build.
Fix
Add the nine missing defines and replace the seven decorated NEON entries with the identifiers as spelled
in
pngpriv.h. No source file changes; the fix is entirely in the rename table.png_fixed_ITUis also a function-like macro atpngpriv.h:818, guarded byPNG_FIXED_POINT_MACRO_SUPPORTED. That macro is not enabled in ITK'spnglibconf.h, andpng_fixed— thesame dual macro/function shape — has been mangled all along, so the object-like define is safe here.
Verification
Built the
itkpngtarget and inspected the static archive, on macOS/arm64, Apple clang, Release,against
mainat 2bdb783:png_*symbols exportedmainThe 16 are the 9 new libpng symbols plus the 7 NEON functions.
pre-commit run --all-filespasses.Scope of verification: macOS/arm64 exercises the NEON half directly and proves the rename table itself.
The
LNK2005symptom needs a static Windows build linking bothitkpngandvtkpng, which was not runhere; the Windows static dashboards are the appropriate regression check before merging.
AI assistance
LNK2005failures, and separately found the seven decorated ARM NEONentries by diffing
nmoutput against the mangle header