Fix BUILD_SHARED_LIBS=ON#690
Closed
simonmar wants to merge 1 commit into
Closed
Conversation
Building with shared libs is broken, because there's a circular
dependency between thrifttype and thriftanyrep.
The dependency of thrifttype on thriftanyrep is currently missing, which
leads to link errors, but adding the dependency causes a Cmake error due
to the circular dependency.
The patch makes 3 changes to fbthrift's thrift/lib/cpp2/CMakeLists.txt:
1. Merges any_rep generated sources into thrifttype — adds ${any_rep-cpp2-SOURCES} and its
bypass_source_check to the thrifttype library. This puts AnyStruct/SemiAnyStruct symbols directly in
libthrifttype.so, resolving the undefined references.
2. Replaces thriftanyrep with a thin stub — uses file(WRITE ...) to create an empty source file and
builds thriftanyrep as a minimal shared library that links PUBLIC thrifttype. This preserves
libthriftanyrep.so on disk so the Haskell FFI (thrift-cpp-channel.cabal links -lthriftanyrep) keeps
working.
3. Adds thriftanyrep to the set_target_properties VERSION list — so it gets a proper soname like
the other libraries when BUILD_SHARED_LIBS=ON.
Contributor
Contributor
meta-codesync Bot
pushed a commit
to facebook/hhvm
that referenced
this pull request
Mar 13, 2026
Summary:
Building with shared libs is broken, because there's a circular dependency between thrifttype and thriftanyrep.
The dependency of thrifttype on thriftanyrep is currently missing, which leads to link errors, but adding the dependency causes a Cmake error due to the circular dependency.
The patch makes 3 changes to fbthrift's thrift/lib/cpp2/CMakeLists.txt:
1. Merges any_rep generated sources into thrifttype — adds ${any_rep-cpp2-SOURCES} and its bypass_source_check to the thrifttype library. This puts AnyStruct/SemiAnyStruct symbols directly in
libthrifttype.so, resolving the undefined references.
2. Replaces thriftanyrep with a thin stub — uses file(WRITE ...) to create an empty source file and builds thriftanyrep as a minimal shared library that links PUBLIC thrifttype. This preserves libthriftanyrep.so on disk so the Haskell FFI (thrift-cpp-channel.cabal links -lthriftanyrep) keeps working.
3. Adds thriftanyrep to the set_target_properties VERSION list — so it gets a proper soname like the other libraries when BUILD_SHARED_LIBS=ON.
X-link: facebook/fbthrift#690
Reviewed By: Mizuchi
Differential Revision: D96487232
Pulled By: iahs
fbshipit-source-id: 88530afa568f227d5aea022fdf6ee133dcfc9906
meta-codesync Bot
pushed a commit
that referenced
this pull request
Mar 17, 2026
Summary: Followup to #690, that PR inadvertently added a circular dependency between the thrifttype and thriftanyrep libraries, which means the `BUILD_SHARED_LIBS=ON` build still fails. This should fix it. Tested with a PR on the hsthrift repo: facebookincubator/hsthrift#174 Pull Request resolved: #692 Reviewed By: Mizuchi Differential Revision: D96944523 Pulled By: iahs fbshipit-source-id: ecb75e972d7d074eff1f44c29ba0960ca8416970
meta-codesync Bot
pushed a commit
to facebook/hhvm
that referenced
this pull request
Mar 17, 2026
Summary: Followup to facebook/fbthrift#690, that PR inadvertently added a circular dependency between the thrifttype and thriftanyrep libraries, which means the `BUILD_SHARED_LIBS=ON` build still fails. This should fix it. Tested with a PR on the hsthrift repo: facebookincubator/hsthrift#174 X-link: facebook/fbthrift#692 Reviewed By: Mizuchi Differential Revision: D96944523 Pulled By: iahs fbshipit-source-id: ecb75e972d7d074eff1f44c29ba0960ca8416970
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.
Building with shared libs is broken, because there's a circular dependency between thrifttype and thriftanyrep.
The dependency of thrifttype on thriftanyrep is currently missing, which leads to link errors, but adding the dependency causes a Cmake error due to the circular dependency.
The patch makes 3 changes to fbthrift's thrift/lib/cpp2/CMakeLists.txt:
libthrifttype.so, resolving the undefined references.