Fix undefined symbol error around SharedCtor() - #8827
Merged
Conversation
Contributor
Author
|
NB: the same problem applies to SharedDtor() though it is not broken in our case. |
Collaborator
|
@georgthegreat Would you mind running |
Apparently, protocolbuffers#8532 was incorrect if applied to 3.17.x branch. 3.17.x changed code generation to mark `SharedCtor()` and `SharedDtor()` as inline in .pb.cc. It looks like we have a compile-time undefined behavior in C++ now. As cppreference.com [says](https://en.cppreference.com/w/cpp/language/inline): _The definition of an inline function <...> must be reachable in the translation unit where it is accessed (not necessarily before the point of access)._ As protobuf allows custom plugins to generate custom code, there is no limitation on where SharedCtor couble be possible referenced from. In our case we have SharedCtor invoked from corresponding `.pb.h` code, thus triggering: ``` ld: error: undefined symbol: package::Message::SharedCtor()` >>> referenced by file.pb.h:$$$$ ``` If this patch is not applicable, I can take a look into changing the code generation, but doing this will be harder then removing _inline_.
georgthegreat
commented
Jul 20, 2021
Contributor
Author
|
@deannagarcia, @acozzette, can we proceed with merging of this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apparently, #8532 was incorrect if applied to 3.17.x branch.
3.17.x changed code generation to mark
SharedCtor()andSharedDtor()as inline in .pb.cc.It looks like we have a compile-time undefined behavior in C++ now. As cppreference.com says:
The definition of an inline function <...> must be reachable in the translation unit where it is accessed (not necessarily before the point of access).
As protobuf allows custom plugins to generate custom code, there is no limitation on where SharedCtor couble be possible referenced from. In our case we have SharedCtor invoked from corresponding
.pb.hcode, thus triggering:If this patch is not applicable, I can take a look into changing the code generation, but doing this will be harder than removing inline.