Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using CXX-Modules: error: no matching function for call to 'make_tag' while trying rfl::json::write() (and error: recursive lazy load) #193

Open
Urfoex opened this issue Sep 18, 2024 · 2 comments

Comments

@Urfoex
Copy link
Collaborator

Urfoex commented Sep 18, 2024

Been trying to move BooleanColumnView.hpp, FloatColumnOrFloatColumnView.hpp and StringColumnOrStringColumnView.hpp into a module.

Sample code: modules.tar.gz


Compiling with Clang 18.1.8 gives:

/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_tagged_union.hpp:198:24: error: no matching function for call to 'make_tag'
  198 |       const auto tag = internal::make_tag<_discriminator, T>(_val);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_tagged_union.hpp:185:26: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, rfl::TaggedUnion<internal::StringLiteral<10>{{"operator_"}}, commands::FloatColumnOrFloatColumnView::FloatArangeOp, commands::FloatColumnOrFloatColumnView::FloatAsTSOp, commands::FloatColumnOrFloatColumnView::FloatBinaryOp, commands::FloatColumnOrFloatColumnView::FloatConstOp, commands::FloatColumnOrFloatColumnView
::FloatFromBooleanOp, commands::FloatColumnOrFloatColumnView::FloatFromStringOp, commands::FloatColumnOrFloatColumnView::FloatRandomOp, commands::FloatColumnOrFloatColumnView::FloatRowidOp, commands::FloatColumnOrFloatColumnView::FloatSubselectionOp, commands::FloatColumnOrFloatColumnView::FloatUnaryOp, commands::FloatColumnOrFloatColumnView::FloatUpdateOp, commands::FloatColumnOrFloatColumnView::FloatColumnOp, commands::FloatColumnOrFloatColumnView::FloatWithSubrolesOp, commands::FloatColumnOrFloatColumnView::FloatWithUnitOp>, rfl::Pr
ocessors<>>::wrap_if_necessary<commands::FloatColumnOrFloatColumnView::FloatArangeOp>' requested here
  185 |     const auto wrapped = wrap_if_necessary<T>(_val);
      |                          ^
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_tagged_union.hpp:68:7: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, rfl::TaggedUnion<internal::StringLiteral<10>{{"operator_"}}, commands::FloatColumnOrFloatColumnView::FloatArangeOp, commands::FloatColumnOrFloatColumnView::FloatAsTSOp, commands::FloatColumnOrFloatColumnView::FloatBinaryOp, commands::FloatColumnOrFloatColumnView::FloatConstOp, commands::FloatColumnOrFloatColumnView::
FloatFromBooleanOp, commands::FloatColumnOrFloatColumnView::FloatFromStringOp, commands::FloatColumnOrFloatColumnView::FloatRandomOp, commands::FloatColumnOrFloatColumnView::FloatRowidOp, commands::FloatColumnOrFloatColumnView::FloatSubselectionOp, commands::FloatColumnOrFloatColumnView::FloatUnaryOp, commands::FloatColumnOrFloatColumnView::FloatUpdateOp, commands::FloatColumnOrFloatColumnView::FloatColumnOp, commands::FloatColumnOrFloatColumnView::FloatWithSubrolesOp, commands::FloatColumnOrFloatColumnView::FloatWithUnitOp>, rfl::Proc
essors<>>::write_wrapped<commands::FloatColumnOrFloatColumnView::FloatArangeOp, rfl::parsing::Parent<rfl::json::Writer>::Root>' requested here
   68 |       write_wrapped(_w, _val, _parent);
      |       ^
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_default.hpp:78:55: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, rfl::TaggedUnion<internal::StringLiteral<10>{{"operator_"}}, commands::FloatColumnOrFloatColumnView::FloatArangeOp, commands::FloatColumnOrFloatColumnView::FloatAsTSOp, commands::FloatColumnOrFloatColumnView::FloatBinaryOp, commands::FloatColumnOrFloatColumnView::FloatConstOp, commands::FloatColumnOrFloatColumnView::Floa
tFromBooleanOp, commands::FloatColumnOrFloatColumnView::FloatFromStringOp, commands::FloatColumnOrFloatColumnView::FloatRandomOp, commands::FloatColumnOrFloatColumnView::FloatRowidOp, commands::FloatColumnOrFloatColumnView::FloatSubselectionOp, commands::FloatColumnOrFloatColumnView::FloatUnaryOp, commands::FloatColumnOrFloatColumnView::FloatUpdateOp, commands::FloatColumnOrFloatColumnView::FloatColumnOp, commands::FloatColumnOrFloatColumnView::FloatWithSubrolesOp, commands::FloatColumnOrFloatColumnView::FloatWithUnitOp>, rfl::Processo
rs<>>::write<rfl::parsing::Parent<rfl::json::Writer>::Root>' requested here
   78 |         Parser<R, W, ReflectionType, ProcessorsType>::write(_w, r, _parent);
      |                                                       ^
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/write.hpp:30:33: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, commands::FloatColumnOrFloatColumnView, rfl::Processors<>>::write<rfl::parsing::Parent<rfl::json::Writer>::Root>' requested here
   30 |   Parser<T, Processors<Ps...>>::write(w, _obj, typename ParentType::Root{});
      |                                 ^
/home/manuel/Projects/experiments/modules/main.cpp:39:16: note: in instantiation of function template specialization 'rfl::json::write<commands::FloatColumnOrFloatColumnView>' requested here
   39 |     rfl::json::write(floatColumnOrFloatColumnView);
      |                ^
In file included from /home/manuel/Projects/experiments/modules/main.cpp:3:
In file included from /home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/write.hpp:16:
In file included from /home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/Parser.hpp:4:
In file included from /home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser.hpp:23:
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_tagged_union.hpp:185:26: error: no matching function for call to 'wrap_if_necessary'
  185 |     const auto wrapped = wrap_if_necessary<T>(_val);
      |                          ^~~~~~~~~~~~~~~~~~~~
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_tagged_union.hpp:68:7: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, rfl::TaggedUnion<internal::StringLiteral<10>{{"operator_"}}, commands::FloatColumnOrFloatColumnView::FloatArangeOp, commands::FloatColumnOrFloatColumnView::FloatAsTSOp, commands::FloatColumnOrFloatColumnView::FloatBinaryOp, commands::FloatColumnOrFloatColumnView::FloatConstOp, commands::FloatColumnOrFloatColumnView::
FloatFromBooleanOp, commands::FloatColumnOrFloatColumnView::FloatFromStringOp, commands::FloatColumnOrFloatColumnView::FloatRandomOp, commands::FloatColumnOrFloatColumnView::FloatRowidOp, commands::FloatColumnOrFloatColumnView::FloatSubselectionOp, commands::FloatColumnOrFloatColumnView::FloatUnaryOp, commands::FloatColumnOrFloatColumnView::FloatUpdateOp, commands::FloatColumnOrFloatColumnView::FloatColumnOp, commands::FloatColumnOrFloatColumnView::FloatWithSubrolesOp, commands::FloatColumnOrFloatColumnView::FloatWithUnitOp>, rfl::Proc
essors<>>::write_wrapped<commands::FloatColumnOrFloatColumnView::FloatConstOp, rfl::parsing::Parent<rfl::json::Writer>::Root>' requested here
   68 |       write_wrapped(_w, _val, _parent);
      |       ^
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_default.hpp:78:55: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, rfl::TaggedUnion<internal::StringLiteral<10>{{"operator_"}}, commands::FloatColumnOrFloatColumnView::FloatArangeOp, commands::FloatColumnOrFloatColumnView::FloatAsTSOp, commands::FloatColumnOrFloatColumnView::FloatBinaryOp, commands::FloatColumnOrFloatColumnView::FloatConstOp, commands::FloatColumnOrFloatColumnView::Floa
tFromBooleanOp, commands::FloatColumnOrFloatColumnView::FloatFromStringOp, commands::FloatColumnOrFloatColumnView::FloatRandomOp, commands::FloatColumnOrFloatColumnView::FloatRowidOp, commands::FloatColumnOrFloatColumnView::FloatSubselectionOp, commands::FloatColumnOrFloatColumnView::FloatUnaryOp, commands::FloatColumnOrFloatColumnView::FloatUpdateOp, commands::FloatColumnOrFloatColumnView::FloatColumnOp, commands::FloatColumnOrFloatColumnView::FloatWithSubrolesOp, commands::FloatColumnOrFloatColumnView::FloatWithUnitOp>, rfl::Processo
rs<>>::write<rfl::parsing::Parent<rfl::json::Writer>::Root>' requested here
   78 |         Parser<R, W, ReflectionType, ProcessorsType>::write(_w, r, _parent);
      |                                                       ^
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/write.hpp:30:33: note: in instantiation of function template specialization 'rfl::parsing::Parser<rfl::json::Reader, rfl::json::Writer, commands::FloatColumnOrFloatColumnView, rfl::Processors<>>::write<rfl::parsing::Parent<rfl::json::Writer>::Root>' requested here
   30 |   Parser<T, Processors<Ps...>>::write(w, _obj, typename ParentType::Root{});
      |                                 ^
/home/manuel/Projects/experiments/modules/main.cpp:39:16: note: in instantiation of function template specialization 'rfl::json::write<commands::FloatColumnOrFloatColumnView>' requested here
   39 |     rfl::json::write(floatColumnOrFloatColumnView);
      |                ^
/home/manuel/.conan2/p/b/refleff5a34aa1639b/p/include/rfl/json/../parsing/Parser_tagged_union.hpp:193:15: note: candidate template ignored: substitution failure [with T = commands::FloatColumnOrFloatColumnView::FloatConstOp]
  193 |   static auto wrap_if_necessary(const T& _val) noexcept {
      |               ^

clang.log

This is related to rfl::json::write(floatColumnOrFloatColumnView);
Without this, it compiles and runs.


Compiling with GCC 14.2.0 gives:

commands.ColumnOrColumnView:StringColumnOrStringColumnView: note: unable to represent further imported source locations
/home/manuel/Projects/experiments/modules/BooleanColumnView.ixx:26:78: error: recursive lazy load
   26 |         rfl::Literal<"and", "bool_equal_to", "bool_not_equal_to", "or", "xor">;
      |                                                                              ^
/home/manuel/Projects/experiments/modules/BooleanColumnView.ixx:26:78: fatal error: failed to load pendings for ‘rfl::internal::StringLiteral’

gcc.log

This is not specific to rfl::Literal, I also see it e.g. with rfl::Ref
Not sure, if it is something missing in GCC, or something fixable in rfl.

@GregTheMadMonk
Copy link
Contributor

I've attempted to port an older version of rfl to build as a module in this commit. The problem is that some functions are marked static, and static functions are not exported from modules. You need to either replace it manually, like I did, or maybe rfl devs should replace static functions in headers with inline ones...

About the GCC issue - no idea. Try to fix Clang, maybe GCC will start working too :)

@Urfoex
Copy link
Collaborator Author

Urfoex commented Dec 3, 2024

I have a working sample with clang 18 and 19
reflectcpp-modules.tar.gz

It just needs the static be gone from https://github.com/getml/reflect-cpp/blob/main/include/rfl/internal/variant/is_alternative_type.hpp#L11

Then it compiles and runs.

$ ./build_clang/modules 
Module1: {"ts":{},"literal":"Literal","tuple":["tuple"],"tagged_union":{"tagged_union":"Simple"},"variant":{}}
Module2: {"tuple":["tuple"],"result":"result","literal":"Literal","ts":{}}

Basically: You can't export entities with internal linkage.
And static functions are in that category:
https://vector-of-bool.github.io/2019/03/31/modules-2.html

With the adjustment, it works for this small example.
There might be other places, where a change is needed, for a bigger project, using more features of reflect-cpp.

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

No branches or pull requests

2 participants