Skip to content

Fix the transport target dependency for static linking#675

Closed
kou wants to merge 1 commit into
facebook:mainfrom
kou:cmake-transport-dependency
Closed

Fix the transport target dependency for static linking#675
kou wants to merge 1 commit into
facebook:mainfrom
kou:cmake-transport-dependency

Conversation

@kou

@kou kou commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

libtransport uses
apache::thrift::rocket::CompressionAlgorithmSelector::fromTTransform() in thrift/lib/cpp/transport/THeader.cpp:

buf = rocket::CompressionManager().uncompressBuffer(
std::move(buf),
rocket::CompressionAlgorithmSelector::fromTTransform(*it));

So libthriftcpp2.a must be linked after libtransport.a.

Note that we don't need it for shared linking. Because libthriftcpp2.so already has libtransport.so dependency.

@meta-cla meta-cla Bot added the CLA Signed label Sep 28, 2025
@kou

kou commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

FYI: I found this problem in facebookincubator/velox#14942 .

@kou

kou commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

Hmm... This works on local but doesn't work on Velox CI...

@kou kou force-pushed the cmake-transport-dependency branch from f711145 to e2ef1fd Compare September 29, 2025 04:49
`libtransport` uses
`apache::thrift::rocket::CompressionAlgorithmSelector::fromTTransform()`
in `thrift/lib/cpp/transport/THeader.cpp`:

https://github.com/facebook/fbthrift/blob/531d08e0f9af1c17e9cb7fd49ab037a779aee376/thrift/lib/cpp/transport/THeader.cpp#L569-L571

So the `transport` target must depends on the `thriftcpp2` target.
@kou kou force-pushed the cmake-transport-dependency branch from e2ef1fd to 71e51fe Compare September 29, 2025 05:04
@kou kou changed the title Fix the transport target dependency Sep 29, 2025
@majetideepak

Copy link
Copy Markdown

@kou is this ready for merge?

@kou

kou commented Sep 30, 2025

Copy link
Copy Markdown
Contributor Author

Yes. The build failure problem on Velox CI was caused by Velox side configuration. (This patch wasn't applied correctly.)

This PR fixes the link problem found by Velox CI.

# and libtransport.so are cyclic dependencies and libthriftcpp2.so
# has libtransport.so dependency. We can't link to
# libthriftcpp2.so from libtransport.so. It's not allowed.
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:$<INSTALL_INTERFACE:FBThrift::thriftcpp2>>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why INSTALL_INTERFACE and not BUILD_INTERFACE?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because this is for FBThrift users who use find_package(FBThrift) such as Velox.

BUILD_INTERFACE is for FBThrift itself (and FBThrift users who bundle FBThrift by FetchContent https://cmake.org/cmake/help/latest/module/FetchContent.html ).

INSTALL_INTERFACE is for FBThrift users who use FBThrift by find_package(FBThrift).

Related CMake documentation: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#export-and-install-expressions

@meta-codesync

meta-codesync Bot commented Oct 6, 2025

Copy link
Copy Markdown
Contributor

@vitaut has imported this pull request. If you are a Meta employee, you can view this in D84010685.

@vitaut vitaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Overall looks good but I have one question inline.

meta-codesync Bot pushed a commit to facebook/hhvm that referenced this pull request Oct 7, 2025
Summary:
`libtransport` uses
`apache::thrift::rocket::CompressionAlgorithmSelector::fromTTransform()` in `thrift/lib/cpp/transport/THeader.cpp`:

https://github.com/facebook/fbthrift/blob/531d08e0f9af1c17e9cb7fd49ab037a779aee376/thrift/lib/cpp/transport/THeader.cpp#L569-L571

So `libthriftcpp2.a` must be linked after `libtransport.a`.

Note that we don't need it for shared linking. Because `libthriftcpp2.so` already has `libtransport.so` dependency.

X-link: facebook/fbthrift#675

Reviewed By: yfeldblum

Differential Revision: D84010685

Pulled By: vitaut

fbshipit-source-id: 2d4a6698451abf335812a280861b20c904e895fe
@meta-codesync meta-codesync Bot closed this in c28b806 Oct 7, 2025
@meta-codesync

meta-codesync Bot commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

@vitaut merged this pull request in c28b806.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants