Skip to content

Conversation

@ultimatile
Copy link
Contributor

@ultimatile ultimatile commented Sep 19, 2025

I encountered a build failure in my environment (macOS on Apple Silicon with Homebrew).
The functions intrusive_ptr_add_ref and intrusive_ptr_release didn't match Boost’s expected signatures (see the reference), so the unqualified calls were not found by ADL.
They now follow

void intrusive_ptr_add_ref(T* p);
void intrusive_ptr_release(T* p);

Forward declarations for Storage_base are also added so these functions are found by ADL.
This resolves the build in my environment.

The coupling the intrusive_ptr_base code to the concrete Storage_base type isn't ideal.
If you have a cleaner way to decouple this, I'm happy to revise.

@IvanaGyro
Copy link
Collaborator

What and which version of compiler did you use? Could you also provide the error messages from the compiler?

@codecov
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 28.05%. Comparing base (7910138) to head (3227027).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
include/intrusive_ptr_base.hpp 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #678   +/-   ##
=======================================
  Coverage   28.05%   28.05%           
=======================================
  Files         215      215           
  Lines       43948    43950    +2     
  Branches    16805    16805           
=======================================
+ Hits        12328    12331    +3     
  Misses      29617    29617           
+ Partials     2003     2002    -1     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ultimatile
Copy link
Contributor Author

My build commands are module load llvm libomp openblas && uv build (for LLVM Clang v21.1.1) and module load libomp openblas && uv build (for Apple Clang v17.0.0.17000013)

module commands just set CPPFLAGS and LDFLAGS like CPPFLAGS="-I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/libomp/include"

I attached log messages for both cases:
llvmclang_log.txt
appleclang_log.txt

@IvanaGyro
Copy link
Collaborator

IvanaGyro commented Sep 19, 2025

Why those functions cannot be found by ADL? instrusive_ptr_base<Storage_base> is just the base class of Storage_base. And why this problem only happens for Storage_base, not for other classes using instrusive_ptr_base.

@ultimatile
Copy link
Contributor Author

I’m not entirely sure. Here’s a brief description; I’ll investigate this tomorrow.

The class Storage_base is defined in Storage.hpp:

class Storage_base : public intrusive_ptr_base<Storage_base> {

In Scalar.hpp, boost::intrusive_ptr<Storage_base> is used with only a forward declaration of class Storage_base;:

struct Sproxy {
boost::intrusive_ptr<Storage_base> _insimpl;

At that point, only a forward declaration of Storage_base is available, so the hidden friend overloads are not declared in this translation unit and ADL has no candidates. Providing the explicit declaration of intrusive_ptr_add_ref(Storage_base*)/intrusive_ptr_release(Storage_base*) in the translation unit resolves the lookup.

In the other cases, the class definitions are in the same translation unit, so this problem does not occur.

@ultimatile
Copy link
Contributor Author

I moved the forward declarations intrusive_ptr_add_ref(Storage_base*) and intrusive_ptr_release(Storage_base*) to include/backend/Scalar.hpp, where they are needed.

The build succeeded after this change, which supports my understanding.

@IvanaGyro
Copy link
Collaborator

Maybe we also don't need to change the signature in intrusive_ptr_base.hpp? Is the final solution of this problem moving class Storage_base to a new header file?

@ultimatile
Copy link
Contributor Author

I tried building with the original function signatures and the forward declarations to the include/backend/Scalar.hpp:

void intrusive_ptr_add_ref(intrusive_ptr_base<Storage_base> const *);
void intrusive_ptr_release(intrusive_ptr_base<Storage_base> const *);

The ADL succeeded, but the type conversion failed; the error message is

/Users/ultimatile/.cache/uv/sdists-v9/.tmp2gxEZ5/cytnx-1.0.0/include/backend/Scalar.hpp:21:8: note: candidate function not viable: cannot convert argument of incomplete type 'cytnx::Storage_base *' to 'const intrusive_ptr_base<Storage_base> *' for 1st argument
   21 |   void intrusive_ptr_add_ref(intrusive_ptr_base<Storage_base> const*);
      |        ^                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I believe my current modification is the smallest one that resolves the build error.

As you've pointed out, a complete solution would likely involve introducing a new header file and re-organizing dependencies.

@IvanaGyro IvanaGyro merged commit 1e307ad into Cytnx-dev:master Oct 7, 2025
7 checks passed
@ultimatile ultimatile deleted the name-resolve-intrusive_ptr branch October 24, 2025 08:08
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