Repository navigation
fix(openswath): resolve duplicate TLS init symbol on macOS clang - #9223
Conversation
`PickerPoolShared g_picker_pool_shared` was declared `inline thread_local` at namespace scope in MRMTransitionGroupPicker.h. Because the type has a non-trivial constructor (vector members), the compiler must emit a thread-local initialization wrapper. macOS Mach-O / clang does not always emit that wrapper as weak/COMDAT for `inline thread_local`, so every TU that transitively included the header (MRMFeatureFinderScoring.cpp, OpenSwathWorkflow.cpp, ...) defined its own copy and the linker rejected the duplicates on arm64. Switch to the standard pattern: an `extern thread_local` declaration in the header and a single definition in MRMTransitionGroupPicker.cpp. One TU emits the init wrapper, semantics are unchanged (one instance per thread, lazy init on first access), no callsite changes. Fixes #9222 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThe change replaces a namespace-scope Changes
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h`:
- Around line 74-78: Add the OPENMS_DLLAPI export macro to the header
declaration of the thread-local shared pool: change the header's declaration of
g_picker_pool_shared to use "extern OPENMS_DLLAPI thread_local PickerPoolShared
g_picker_pool_shared" so downstream consumers (e.g., pickTransitionGroup and
computeQuality_) can import the symbol from the DLL; leave the definition in
MRMTransitionGroupPicker.cpp as just "thread_local PickerPoolShared
g_picker_pool_shared" (no OPENMS_DLLAPI) to keep a single definition.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3487f42e-be13-4662-b130-fe27f655015f
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.hsrc/openms/source/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.cpp
The previous commit moved `g_picker_pool_shared` to a single TU definition, but `-fvisibility=hidden` keeps the symbol out of libOpenMS's dynamic symbol table. The header has inline template member functions (`pickTransitionGroup`, `computeQuality_`) that reference the variable, so any consumer that instantiates them in its own translation unit (TOPP tools like `src/topp/MRMTransitionGroupPicker.cpp`, class tests like `MRMTransitionGroupPicker_test.cpp`) emits an external relocation that the linker cannot resolve from libOpenMS. Annotate the declaration and definition with OPENMS_DLLAPI so the symbol and its TLS init wrapper are exported with default visibility. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Pushed follow-up: |
`extern OPENMS_DLLAPI thread_local` resolved the macOS dup-symbol and the Linux hidden-visibility issue, but MSVC still failed with LNK2019 when linking the TOPP MRMTransitionGroupPicker tool: MSVC does not reliably support `__declspec(dllexport)` on `thread_local` variables of a non-trivial type. Replace the namespace-scope variable with a function-local `thread_local static` returned by an inline accessor. Function-local statics are single-instance per program by language guarantee and don't need a DLL export annotation, so this works uniformly on macOS clang, Linux gcc/clang, and MSVC. Updated the six callsites in the header to use `g_picker_pool_shared()` and verified `MRMTransitionGroupPicker_test` plus the four TOPP tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Pushed Replaced the namespace-scope |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h (1)
80-80: Optional: rename to follow lowerCamelCase now that it's a function.The
g_prefix and snake_case made sense when this was a namespace-scope global variable. As a function (effectively the only API for the pool),pickerPoolShared()(or similar) would align with the OpenMS "Methods must use lowerCamelCase" convention used elsewhere in this very file (e.g.,areaBackgroundLevel(),findWidestPeakIndices). Skip if the small callsite churn isn't worth it.As per coding guidelines: "Methods must use lowerCamelCase".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h` at line 80, Rename the function g_picker_pool_shared() to follow lowerCamelCase (suggested name: pickerPoolShared()) and update its declaration and definition (the inline function returning PickerPoolShared&) along with all callsites; ensure you replace exact symbol g_picker_pool_shared with pickerPoolShared in headers and sources, update any forward declarations or includes that reference it, and run the build/tests to confirm no linkage or API breakages — keep the return type (PickerPoolShared&) and behavior unchanged to avoid semantic changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h`:
- Around line 74-84: Add a Doxygen comment with an `@brief` for the public
accessor g_picker_pool_shared() describing its purpose (returns the per-thread
PickerPoolShared instance used by the MRMTransitionGroupPicker pool system) and
keep the existing rationale comment as detailed remarks if desired; place the
comment immediately above the inline PickerPoolShared& g_picker_pool_shared()
function and reference the function name and the PickerPoolShared type in the
doc block so it satisfies the header's public API documentation guidelines.
---
Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h`:
- Line 80: Rename the function g_picker_pool_shared() to follow lowerCamelCase
(suggested name: pickerPoolShared()) and update its declaration and definition
(the inline function returning PickerPoolShared&) along with all callsites;
ensure you replace exact symbol g_picker_pool_shared with pickerPoolShared in
headers and sources, update any forward declarations or includes that reference
it, and run the build/tests to confirm no linkage or API breakages — keep the
return type (PickerPoolShared&) and behavior unchanged to avoid semantic
changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1599d62e-98ab-4250-886e-e258dd8f975f
📒 Files selected for processing (1)
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h
| // Per-thread instance of the shared pools. Wrapped in a function so the | ||
| // function-local `thread_local static` is the single point of definition | ||
| // across all translation units / DLLs and we don't have to deal with | ||
| // platform-specific behavior of namespace-scope `inline thread_local` | ||
| // (duplicate TLS init wrapper on macOS clang) or `extern thread_local` | ||
| // exported from a DLL (MSVC LNK2019 on TOPP-tool consumers). | ||
| inline PickerPoolShared& g_picker_pool_shared() | ||
| { | ||
| thread_local PickerPoolShared instance; | ||
| return instance; | ||
| } |
There was a problem hiding this comment.
Add a Doxygen @brief for the new public accessor.
The header sits under src/openms/include/OpenMS/... and the accessor is part of the public API of this header. The comment block explains rationale well but lacks the required @brief tag.
📝 Proposed doc tweak
- // Per-thread instance of the shared pools. Wrapped in a function so the
- // function-local `thread_local static` is the single point of definition
- // across all translation units / DLLs and we don't have to deal with
- // platform-specific behavior of namespace-scope `inline thread_local`
- // (duplicate TLS init wrapper on macOS clang) or `extern thread_local`
- // exported from a DLL (MSVC LNK2019 on TOPP-tool consumers).
+ /**
+ `@brief` Accessor for the per-thread shared pool used by MRMTransitionGroupPicker.
+
+ Wrapped in an inline function so the function-local `thread_local` instance
+ is the single point of definition across all translation units / DLLs.
+ This avoids platform-specific issues with namespace-scope
+ `inline thread_local` (duplicate TLS init wrapper on macOS clang) and
+ `extern thread_local` exported from a DLL (MSVC LNK2019 on TOPP-tool
+ consumers).
+
+ `@return` Reference to the calling thread's `PickerPoolShared` instance.
+ */
inline PickerPoolShared& g_picker_pool_shared()As per coding guidelines: src/openms/include/OpenMS/**/*.h — "Add Doxygen comments for new public methods and classes" and "Always use @brief for class and method documentation".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h`
around lines 74 - 84, Add a Doxygen comment with an `@brief` for the public
accessor g_picker_pool_shared() describing its purpose (returns the per-thread
PickerPoolShared instance used by the MRMTransitionGroupPicker pool system) and
keep the existing rationale comment as detailed remarks if desired; place the
comment immediately above the inline PickerPoolShared& g_picker_pool_shared()
function and reference the function name and the PickerPoolShared type in the
doc block so it satisfies the header's public API documentation guidelines.
Add missing entries for: - #9221: pyOpenMS standalone/cibuildwheel Arrow 24.x CMake fix - #9218: PercolatorAdapter in-process Percolator rescoring backend - #9224: ProSE/FragmentIndex SNES X/B/Z mother truncation fix - #9223: OpenSwathWorkflow macOS arm64 duplicate TLS symbol fix Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Add missing CHANGELOG entries for 4 recent code PRs that were not yet documented: - #9218: feat(Percolator) in-process backend — new OpenMS::Percolator class (vendored Percolator 3.08 + TRON solver) and PercolatorAdapter -use_subprocess flag; entries added under OpenMS Library Added and TOPP tools PercolatorAdapter sections. - #9221: fix(cmake) Arrow 24.x in pyOpenMS standalone build — the cibuildwheel CMakeLists.txt version pin now dropped like #9196; entry added under Dependencies. - #9223: fix(openswath) duplicate TLS init symbol on macOS arm64/clang — g_picker_pool_shared moved from inline thread_local in header to a single .cpp definition; entry added under OpenSwathWorkflow. - #9224: fix(FragmentIndex) SNES mothers truncated at X/B/Z residues — proteins with ambiguous residues split into unambiguous spans for SNES indexing; entry added under ProSE. Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: timosachsenberg <[email protected]>
Summary
duplicate symbol 'thread-local initialization routine for OpenMS::g_picker_pool_shared'on macOS arm64 introduced by (osw): Speed up OpenSwathWorkflow for Large Libraries #9190.PickerPoolShared g_picker_pool_sharedwas declaredinline thread_localat namespace scope inMRMTransitionGroupPicker.h. The type has a non-trivial constructor (vector members), so the compiler must emit a thread-local initialization wrapper. macOS Mach-O / clang does not always emit that wrapper as weak/COMDAT forinline thread_local, so every translation unit including the header (MRMFeatureFinderScoring.cpp,OpenSwathWorkflow.cpp, …) defined its own copy and the linker rejected the duplicates.extern thread_localdeclaration in the header, single definition inMRMTransitionGroupPicker.cpp. One TU emits the init wrapper, semantics unchanged (one instance per thread, lazy init on first access), no callsite changes.Test plan
cmake --build OpenMS-build --target OpenMS→[100%] Built target OpenMS🤖 Generated with Claude Code
Summary by CodeRabbit