-
Notifications
You must be signed in to change notification settings - Fork 66
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
Non-portable generated code for size_t
#258
Comments
I just came here for the same thing. I'm not particularly familiar with clang, but I think you'd want to look at https://github.com/RosettaCommons/binder/blob/67a9fe429698d752dc336122995f838bdeb7f92d/source/function.cpp#LL245C5-L245C5. |
Thanks for the pointer! I'll try to craft something around that function...
sure, the same happen for examples for |
@jlblancoc unfortunately in general this is expected behavior and right now i could not offer you any workarounds for solving it. For my main project i have to give on idea of generating binding on one platform and compiling it on the other due to this issue. In short: this issue is due to how LLVM/Clang inner handling of the types is implemented, after function is parsed it types reported in "resolved" form so all information about typedefs is lost. It has been a while when there was last time i checked on this issue. I will take another look in case newer LLVM versions allows to extract original type info but I think chances of this are slim.
-- this conversion is happened inside LLVM/Clang layer so this is not something in our control.
-- similar ideas was considered in the past. Problem with this approach is that we have no way to determine which type instances of |
@jlblancoc , i just took a fresh look at the code and new API docs and i think there might be a way to get original type information! Let me play with this and i will get back to you. |
Thanks, it would be great! In the meanwhile I tried with tricks redefining |
@jlblancoc - it turned out that general solution for this issue might require a bit more research. So for now i found a decent workaround that we can use but it will require listing all |
Sergey, this is definitively awesome, thanks! 👏👏 Sure, I'll try it and expand in a PR after testing... Cheers |
PS: it would add a certain performance loss, but if you prefer it, I could also add an optional set of types loadable from the config file, in addition to the standard std types I will add. |
-- that would be great, PR adding this functionality will be welcome! Re possible performance hit: - i would not worry about this. We can make sure that static std::set<string> standard_names;
if( standard_names.empty() ) {
standard_names.insert( {"std::size_t"} );
<add names from config options here>
} |
See related discussion: RosettaCommons/binder#258
@lyskov After your fix, all But now, the same problem remains in the auto-generated wrappers I'll try to take a look at binder code to see where those wrappers are generated, but you would probably have it already in your head and provide a faster fix (?). |
-- right! Binding code generation for member functions will needs to be updated as will. - I will looks this up soon! |
OK, i just pushed the patch, - @jlblancoc please see if it works for you! Thanks, |
Thanks for the quick fix @lyskov ! I tested it and indeed it seems to have worked well. I'm waiting for packages to be built in armhf to fully confirm it works now... |
My package still have one remaining error for armhf but it's a too particular problem in my API... binder made the grade here too, thanks!! 💯 |
I found one more edge case:
got converted into:
Note the replacement of uint64_t to unsigned long, as it was before...
gives the correct uint64_t:
Maybe related to string matching in types? For now I'll drop the "const" on my side, but it's not expected ideal behavior... |
Thank you for detailed examples @jlblancoc ! Let me think about this for a bit. Clearly more general solution is needed here. I have a few ideas to try and experiment and will post here if/when i have something better then the current code. |
For the records, I "solved" this in my project via a mass generation of wrapping code via binder, then applying hand-written patches to the problematic parts. Not ideal, but it's really hard to handle all these usages of variable-size types in a portable way. PS: Link to relevant "hacky" parts in my project, I hope it can help others: |
Problem
Generates code replacing
size_t
withunsigned long
. Which is OK... until you try to build the generated sources in another platform (e.g. armhf, etc.) wheresize_t
becomes something else, so the generated pattern code doesn't match anymore the original C++ API and fails to build. A solution might be re-running binder for each architecture, but I would like to avoid it.Questions
size_t
and such converted into their underlying types?If you give me some pointers, I would be glad to attempt to implement it and PR.
The text was updated successfully, but these errors were encountered: