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

Replace autotools with CMake + fbcode_builder #449

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

mszabo-wikia
Copy link
Contributor

@mszabo-wikia mszabo-wikia commented Jul 29, 2024

Part of the difficulty in building mcrouter as a third party stems from the fact that it uses an autotools-based build system. While other Meta OSS projects have adopted fbcode_builder to make it easier to build a project with all required dependencies, this tool was primarily written with CMake in mind and unfortunately wouldn't work with mcrouter's build system without making mcrouter-specific accommodations (e.g. explicitly passing in the Thrift compiler path and so on).

So, introduce a CMake-based build system for mcrouter and wire it up with fbcode_builder. This also allows for the tests (which had been nonfunctional in the autotools build for years) to be run in OSS CI via CMake/CTest, after some fixes for the GH Actions environment and disabling Meta-specific functionality in an OSS context. There are no changes to non-test/build files apart from the elimination of the generated config.h.

Use globbing extensively for generating source file lists in CMake files. While this may be a controversial approach, I think in this specific case the benefits outweigh the drawbacks, since this project doesn't use CMake internally so globbing can reduce the amount of times the OSS build needs to be fixed after the fact because a new source file wasn't added to it.

To assist reviewing, I've attempted to break this change into reasonable commits. The very first commit simply adds a vendored copy of fbcode_builder from a recent Folly checkout, hence the large diff size. I've not yet removed autotools paraphernalia to reduce the amount of changes in this PR—that can be done as a followup.

@mszabo-wikia
Copy link
Contributor Author

mszabo-wikia commented Jul 29, 2024

Please let me know if you find this approach feasible—I'm not a CMake expert.

For actually applying these changes tofbcode_builder, I assume some internal work will need to be done on the Meta side. (edit: I've submitted an appropriate Folly PR to do this)

cpp_include "mcrouter/lib/carbon/example/gen/HelloGoodbyeMessages.h"

namespace cpp2 hellogoodbye.thrift
namespace py3 hellogoodbye.thrift

service HelloGoodbye extends fb303.FacebookService {
service HelloGoodbye {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugly, but installing fb303 via fbcode_builder still doesn't help the Thrift compiler find fb303 IDLs. Since this is a test/example service, perhaps this is okay.

@@ -87,6 +87,8 @@ void TestServerOnRequest::onRequest(
processReply(std::move(ctx), Reply(carbon::Result::NOTFOUND));
} else if (req.key_ref()->fullKey() == "shutdown") {
shutdownLock_.post();
// TODO
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've observed a race condition in several tests in AsyncMcClientTestSync, e.g. qosClass, where the test would hang on shutdown without this, with the test thread waiting on the ->shutdown call, the server thread waiting on ->join and event loop threads still selecting, so I added this as a workaround since I wasn't able to find the exact cause of the race.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some things I've tried to attempt to resolve this:

  • reordering the shutdownLock_ post,
  • introducing another synchronization barrier between the call to shutdown and join on the mock server main thread,
  • changing the worker loop to use loopOnce over loop and check isShutdown on each loop iteration, like some of the other mock servers do.

@@ -256,7 +255,7 @@ def ensure_connected(self):
while True:
try:
res = self.thrift_client.mcVersion()
if res == Result.OK:
if res == carbon.carbon_result.thrift_types.Result.OK:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While this could be generated from the Carbon IDLs, createThriftTestClient isn't implemented in the OSS version of mcrouter_config.py, so it seems better to "hide" the Meta-specific bits instead.

@mszabo-wikia mszabo-wikia force-pushed the introduce-cmake branch 4 times, most recently from 90964da to 92cb3bd Compare July 31, 2024 14:13
mszabo-wikia added a commit to mszabo-wikia/folly that referenced this pull request Jul 31, 2024
https://github.com/facebook/mcrouter currently uses a legacy
autotools-based build system, which forces third parties to rely on a
collection of scripts hosted in the repository to build it with all
required dependencies. This is brittle and has lead to many issue
reports with build issues.

In facebook/mcrouter#449, I've prepared a
working CMake-based build system for mcrouter that could replace the
legacy autotools setup. This patch adds the necessary manifests for
mcrouter and its ragel dependency so that fbcode_builder itself will be
setup for the repo without the PR having to do it.
Comment on lines +68 to +88
include_directories(.)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not super sure about this, but this seems like the best way to support the current #include style.

@mszabo-wikia mszabo-wikia force-pushed the introduce-cmake branch 2 times, most recently from aa59940 to 74f2de6 Compare August 20, 2024 11:53
facebook-github-bot pushed a commit to facebook/proxygen that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/fb303 that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/folly that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

Pull Request resolved: #2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebookexperimental/edencommon that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/mvfst that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/fboss that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/openr that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebookexperimental/moxygen that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
facebook-github-bot pushed a commit to facebook/watchman that referenced this pull request Aug 20, 2024
Summary:
X-link: facebookincubator/zstrong#944

https://github.com/facebook/mcrouter currently uses a legacy autotools-based build system, which forces third parties to rely on a collection of scripts hosted in the repository to build it with all required dependencies. This is brittle and has lead to many issue reports about build problems.

In facebook/mcrouter#449, I've prepared a working CMake-based build system for mcrouter that could replace the legacy autotools setup. This patch adds the necessary manifests for mcrouter and its ragel dependency so that fbcode_builder itself will be setup for the repo without having to do it in the PR.

X-link: facebook/folly#2268

Reviewed By: yfeldblum

Differential Revision: D60537337

Pulled By: Orvid

fbshipit-source-id: ed73693d4af93acc3b8e996a7c61d0090075949f
@mszabo-wikia
Copy link
Contributor Author

Note: this is blocked on fbcode_builder actually being wired up with the mcrouter repo. facebook/folly#2282 aims to do that but it's itself stalled.

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

Successfully merging this pull request may close these issues.

2 participants