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

Add curl.cmake dependency for cpr #7853

Closed
wants to merge 4 commits into from

Conversation

liujiayi771
Copy link
Contributor

@liujiayi771 liujiayi771 commented Dec 4, 2023

Add a curl.cmake dependency in CMake/resolve_dependency_modules, so that
we would be able to specify VELOX_CURL_URL to a local path to enable offline
build.

Copy link

netlify bot commented Dec 4, 2023

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 79cedd0
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/656e0eb452b91b00096246f5

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 4, 2023
@liujiayi771
Copy link
Contributor Author

liujiayi771 commented Dec 4, 2023

@duanmeng Can we add a curl.cmake dependency for cpr offline build?

@@ -20,6 +20,9 @@ set(VELOX_CPR_SOURCE_URL
"https://github.com/libcpr/cpr/archive/refs/tags/${VELOX_CPR_VERSION}.tar.gz"
)

set(curl_SOURCE BUNDLED)
resolve_dependency(curl)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this disable the curl installation in cpr?
https://github.com/libcpr/cpr/blob/master/CMakeLists.txt#L174

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you can refer to the sentence "the first such call will control how that dependency will be made available" in this link.

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 think it's enough to use FetchContent_Declare to define VELOX_CURL_SOURCE_URL without calling FetchContent_MakeAvailable, because cpr's CMakeLists.txt defines many CURL compilation parameters. Our purpose is just to define the CURL source URL, and the compilation triggering is still done by cpr calling FetchContent_MakeAvailable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a log in the cmake of cpr, and it will always be printed out. I just removed FetchContent_MakeAvailable in curl.cmake, so the compilation process is triggered by cpr with the correct compilation parameters. The role of curl.cmake in Velox is simply to define the source URL of curl through FetchContent_Declare.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still using the built-in curl, but now we can specify the source URL and version of curl.

@duanmeng
Copy link
Collaborator

duanmeng commented Dec 4, 2023

@duanmeng Can we add a curl.cmake dependency for cpr offline build?

@liujiayi771 LGTM.

@assignUser Hi Jacob, what do you think, could you please help take a look?

@assignUser
Copy link
Collaborator

From the other pr:

Adding a custom curl version is likely to lead to conflicts with host openssl/curl but you can give it a try ^^

Alternatively you could manually pass -DCPR_USE_SYSTEM_CURL=ON to the build if you don't want to use it.

@assignUser
Copy link
Collaborator

I'll have to review in-depth later but like this it seems like nothing is using the build curl version.

@liujiayi771
Copy link
Contributor Author

liujiayi771 commented Dec 4, 2023

@assignUser The operating system may have installed a version of curl that is incompatible with Velox. The purpose of this modification is to support configuring the source URL for curl. I still want to use the corresponding version of curl with cpr, and this modification can enable support for specifying a URL for curl to a local file, allowing for the compilation of curl in offline environments. Otherwise, in an environment without internet access, it would not be possible to download the specified curl source link in cpr CMakeLists.txt.

@liujiayi771
Copy link
Contributor Author

liujiayi771 commented Dec 4, 2023

According to #4325, we can use export VELOX_CURL_URL=/path/to/local/curl-8.4.0.tar.xz to specify the path of the local curl source package, eliminating the need to download the source package from the internet.

Copy link
Collaborator

@assignUser assignUser left a comment

Choose a reason for hiding this comment

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

I misunderstood your intention earlier but it is clear now. Great job using fc_declares 'cached' nature, very clever!

Looking at the ci logs cpr seems to use the version set here (8.4.0). @liujiayi771 have you confirmed that using a tar.gz works as intended as well?

A minor comment, lgtm.

@@ -20,6 +20,9 @@ set(VELOX_CPR_SOURCE_URL
"https://github.com/libcpr/cpr/archive/refs/tags/${VELOX_CPR_VERSION}.tar.gz"
)

set(curl_SOURCE BUNDLED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 placing that in the cpr file! could you add a comment explaining what this does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@duanmeng
Copy link
Collaborator

duanmeng commented Dec 4, 2023

@kgpai Hi Krishna, could you help review and merge this PR? Thanks.

@duanmeng duanmeng requested a review from kgpai December 4, 2023 17:02
@liujiayi771
Copy link
Contributor Author

have you confirmed that using a tar.gz works as intended as well?

@assignUser Yes. If I set VELOX_CURL_URL=/path/to/curl-8.3.0.tar.gz, I can see in the cpr building logs that the version of curl has changed to 8.3.0.
image

@@ -20,6 +20,11 @@ set(VELOX_CPR_SOURCE_URL
"https://github.com/libcpr/cpr/archive/refs/tags/${VELOX_CPR_VERSION}.tar.gz"
)

# Add the dependency for curl, so that we can define the source URL
# for curl in curl.cmake.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# for curl in curl.cmake.
# for curl in curl.cmake. This will override the curl version declared by cpr.

just a little tweak

@liujiayi771
Copy link
Contributor Author

@mbasmanova @kgpai Could you help review?

@mbasmanova
Copy link
Contributor

@kgpai Krishna, would you help review this PR?

Copy link
Contributor

@kgpai kgpai left a comment

Choose a reason for hiding this comment

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

Looks good.

One question for @assignUser this shouldnt happen with condafication where we would be easily be able to set curl version along with cpr version, without having to build them together like this , right ?

@facebook-github-bot
Copy link
Contributor

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kgpai merged this pull request in b908e77.

@assignUser
Copy link
Collaborator

@kgpai Yes, cpr can either use a system version of curl of download a custom one (which this PR let's us influence without having to patch cpr), with conda we would make it use the system version that we installed via conda.

Copy link

Conbench analyzed the 1 benchmark run on commit b908e779.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

facebook-github-bot pushed a commit that referenced this pull request Jan 9, 2024
Summary:
After #7853, compiling cpr still takes up a significant amount of time because cpr try fetch and compile ZLIB, which breaks offline build. However, ZLIB has already been found by find_package(ZLIB, REQUIRED), let's avoid recompile ZLIB when compiling curl for cpr.

https://github.com/libcpr/cpr/blob/51915127d9b4b9f75965b239a5cd7a765722d1df/CMakeLists.txt#L202-L209

Pull Request resolved: #8257

Reviewed By: xiaoxmeng

Differential Revision: D52631339

Pulled By: kgpai

fbshipit-source-id: 57a435a6f550f9fa08e685d2805b5aceea61e480
liujiayi771 pushed a commit to liujiayi771/velox that referenced this pull request Jan 16, 2024
Summary:
After facebookincubator#7853, compiling cpr still takes up a significant amount of time because cpr try fetch and compile ZLIB, which breaks offline build. However, ZLIB has already been found by find_package(ZLIB, REQUIRED), let's avoid recompile ZLIB when compiling curl for cpr.

https://github.com/libcpr/cpr/blob/51915127d9b4b9f75965b239a5cd7a765722d1df/CMakeLists.txt#L202-L209

Pull Request resolved: facebookincubator#8257

Reviewed By: xiaoxmeng

Differential Revision: D52631339

Pulled By: kgpai

fbshipit-source-id: 57a435a6f550f9fa08e685d2805b5aceea61e480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants