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

Fix "non-trivial designated initializers not supported" errors #117

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

stanhu
Copy link
Collaborator

@stanhu stanhu commented Nov 22, 2023

With g++ v7.3.1 (used with Amazon Linux 2), compiling the extension would fail with these errors:

compiling re2.cc
re2.cc:176:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
re2.cc:221:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
re2.cc:251:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
re2.cc:1610:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^

This appears to be happening because the parent and data fields in rb_data_type_struct were omitted.

According to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55606, this issue was fixed in GCC 8.

With g++ v7.3.1 (used with Amazon Linux 2), compiling the extension
would fail with these errors:

```
compiling re2.cc
re2.cc:176:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
re2.cc:221:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
re2.cc:251:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
re2.cc:1610:1: sorry, unimplemented: non-trivial designated initializers not
supported
 };
 ^
```

This appears to be happening because the `parent` and `data` fields
in `rb_data_type_struct` were omitted.
@stanhu stanhu requested a review from mudge November 22, 2023 04:01
@mudge
Copy link
Owner

mudge commented Nov 22, 2023

Thanks for raising this, @stanhu. Am I right in thinking support for designated initialisers in C++ is a bit uncertain? Would we instead be better using the more "boring" form with only ordered expressions ala https://github.com/ruby/ruby/blob/60e19a0b5fc9c067ee88751192dc56da618f5060/weakmap.c#L151-L160?

For reference, here are the two versions of rb_data_type_t we need to support:

As support for designated initializers in C++ is unclear, use purely
positional initializers for rb_data_type_t structs to improve
compatibility.
@mudge
Copy link
Owner

mudge commented Nov 22, 2023

@stanhu I've pushed a commit to switch away from designated initializers: can you please test this and let me know if it works with g++ 7.3.1?

Copy link
Owner

@mudge mudge left a comment

Choose a reason for hiding this comment

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

I managed to reproduce this using the gcc:7.3 Docker image and confirm switching away from designated initializers fixes this for both Ruby 2.6 and Ruby 2.7+.

@mudge mudge merged commit 97da8f6 into mudge:main Nov 22, 2023
111 checks passed
@stanhu
Copy link
Collaborator Author

stanhu commented Nov 22, 2023

Sounds good, thanks!

@mudge
Copy link
Owner

mudge commented Nov 22, 2023

I've now published 2.4.3 to fix this. Please let me know if there are any other issues!

@mudge
Copy link
Owner

mudge commented Nov 22, 2023

@byroot this issue and the two potential fixes (see the two commits) may be of interest to you if you’re trying to convert other C++ extensions from Data to TypedData.

@byroot
Copy link
Contributor

byroot commented Nov 22, 2023

Thanks for the ping, this is good to know. But hopefully there isn't too many of those around 😄

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.

3 participants