Skip to content

Fix MSVC duplicate symbol errors for PrimitiveDistance#237

Merged
zfergus merged 1 commit into
mainfrom
fix/msvc-duplicate-symbols
May 26, 2026
Merged

Fix MSVC duplicate symbol errors for PrimitiveDistance#237
zfergus merged 1 commit into
mainfrom
fix/msvc-duplicate-symbols

Conversation

@zfergus
Copy link
Copy Markdown
Member

@zfergus zfergus commented May 26, 2026

Description

Add explicit specialization declarations in primitive_distance.hpp for the seven methods that have optimized definitions in primitive_distance.cpp (compute_closest_direction_hessian for Edge3/Edge3, Point2/Point2, Point3/Point3; compute_mollifier_gradient and compute_mollifier_hessian for Edge3/Edge3 and Face/Point3). Without these declarations, MSVC instantiates the inline primary template body in every including translation unit, producing duplicate symbol linker errors. GCC/Clang handle this via COMDAT merging; MSVC does not.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

…alizations

Add explicit specialization declarations in primitive_distance.hpp for the
seven methods that have optimized definitions in primitive_distance.cpp
(compute_closest_direction_hessian for Edge3/Edge3, Point2/Point2, Point3/Point3;
compute_mollifier_gradient and compute_mollifier_hessian for Edge3/Edge3 and
Face/Point3). Without these declarations, MSVC instantiates the inline primary
template body in every including translation unit, producing duplicate symbol
linker errors. GCC/Clang handle this via COMDAT merging; MSVC does not.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 26, 2026 15:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses MSVC linker duplicate-symbol errors for PrimitiveDistance by ensuring certain optimized member-function specializations (defined in primitive_distance.cpp) are declared in the header so other translation units don’t implicitly instantiate the primary inline definitions.

Changes:

  • Added explicit specialization declarations for 7 optimized PrimitiveDistance<...> member functions.
  • Guarded the declarations with #ifndef IPC_TOOLKIT_DEBUG_AUTODIFF to match the existing conditional compilation of the optimized definitions in primitive_distance.cpp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.49%. Comparing base (bca8846) to head (4a432d7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   95.75%   96.49%   +0.73%     
==========================================
  Files         163      163              
  Lines       16650    16649       -1     
  Branches      920      921       +1     
==========================================
+ Hits        15944    16066     +122     
+ Misses        706      583     -123     
Flag Coverage Δ
unittests 96.49% <ø> (+0.73%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zfergus zfergus merged commit a510337 into main May 26, 2026
22 checks passed
@zfergus zfergus deleted the fix/msvc-duplicate-symbols branch May 26, 2026 16:53
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