Skip to content

start using CMake to fetch + build more dependencies - #15796

Merged
kevinushey merged 14 commits into
mainfrom
feature/update-hunspell
Mar 18, 2025
Merged

kevinushey merged 14 commits into
mainfrom
feature/update-hunspell

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Addresses #15792.

Approach

Start using CMake tools for checking out + building dependencies, and use that to pull in and build Hunspell.

Automated Tests

N/A

QA Notes

N/A

Documentation

N/A

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

@cpisz-posit

cpisz-posit commented Mar 17, 2025 •

Copy link
Copy Markdown
Contributor

Perhaps, I am new naive, but why "fetch source and build" rather than "fetch already built?"

Certainly, fetching and building is one step better than putting third party source in a repo, but not building third party source at all is even better than that. https://github.com/ChristopherPisz/HelloWorldCpp

https://conan.io/center/recipes/hunspell?version=1.7.2
https://conan.io/center/recipes/fmt
etc.

For anything not up on a public repo, not available in a particular OS+arch+version combination, or that we have to patch, or do ourselves, we can always create our own pkgmgr repository that can be pulled from. https://docs.conan.io/2/tutorial/conan_repositories.html

@kevinushey

Copy link
Copy Markdown
Collaborator Author

Perhaps, I am new naive, but why "fetch source and build" rather than "fetch already built?"

Definitely a good question. I haven't actually evaluated whether we could use Conan, but my instincts here were:

  • I suspect the Linux binaries provided by Conan might not support some of the older platforms we support,
  • We might need to patch certain third-party dependencies that we build, and so would need to build from sources anyhow,
  • It's another repository that we risk seeing as inaccessible / spotty during builds.

FWIW, I think we could obviate the cost of rebuilding 3rd-party dependencies by getting those baked into the Docker images we use for builds as well.

If we did use a C++ package manager, we might want to evaluate vcpkg as well.

@cpisz-posit

Copy link
Copy Markdown
Contributor

Perhaps, I am new naive, but why "fetch source and build" rather than "fetch already built?"

Definitely a good question. I haven't actually evaluated whether we could use Conan, but my instincts here were:

  • I suspect the Linux binaries provided by Conan might not support some of the older platforms we support,

The Conan recipes allow you to specify OS, arch, version, ABI, all that jazz.
If a built binary doesn't exist, we can always build one, put it in our own publicly accessible artifact repo or the central and never require another dev to build third party source again.

Installing conan is also quite easy
pip install conan can go in any Dockerfile

The simplicity of the cmake in the "hello world" I linked demonstrates how all you really need to do is list what you want and the version in the conanfile.txt file. It only uses gtest in that example but should give the idea. I am also a fan of the cmake presets way of doing things.

  • We might need to patch certain third-party dependencies that we build, and so would need to build from sources anyhow,
  • It's another repository that we risk seeing as inaccessible / spotty during builds.

Same scenario, host our own, or even put it up on the central repo depending on licensing and whatnot.
I think having a repo that is inaccessible/spotty can be a non-issue. Pretty sure you can even put your own up on AWS with redundancy for pennies, if you wanted to.

FWIW, I think we could obviate the cost of rebuilding 3rd-party dependencies by getting those baked into the Docker images we use for builds as well.

Baking into docker images would be good, but is there potential pain when changes need to be made after no one put eyes on how it got in there and was hooked up after years?

With conan, it's all handled for you and all you have to worry about is your user profile settings (OS, version, compiler, ABI stuff) , and the simple textile list of dep names and versions.

If we did use a C++ package manager, we might want to evaluate vcpkg as well.

I have already done some months of work with conan and vcpkg. I'm no expert, but I was able to get a project or two going. vcpkg was built from the ground up to still vendor source, and it had a heck of a lot of bad packages that exploded in their central repo when I tried it in a past company. Do not recommend. Conan is far superior.

......
Anywho, just wanted to throw that out there. Any step farther away from putting source in our own repo is good.

I try to sell people on Conan whenever I can. I don't think we have a dedicated devops team to pitch it to, so I like to mention it any time third party deps come up :P

@kevinushey

kevinushey commented Mar 17, 2025 •

Copy link
Copy Markdown
Collaborator Author

How should conan profiles be handled? Are these something we would generate and use from CMake (seems like https://github.com/conan-io/cmake-conan/blob/develop2/conan_provider.cmake is a tool that tries to automate some of this)? Or do they need to be pre-populated and pre-generated by hand?

FWIW, the default profile created by conan profile detect gave me a profile for which I couldn't install some dependencies, e.g. conan install . gave me

Requirements
    fmt/11.1.4#1fb24f082fabe20d28606d615ba93dfb:89687ba72ceb54fd19cb96c9451c949a2443e39d - Missing
    gsl-lite/0.42.0#1a0c9f187d3435370fd9752437abb768:da39a3ee5e6b4b0d3255bfef95601890afd80709#4a09d5e566c765ecbec4b387bcecdf54 - Download (conancenter)
    hunspell/1.7.2#57490b2e9619b4efb317be0e60f1e35c:ed653c826af74fd523c736168d9debe9ed4c0d6f - Missing
    tl-expected/1.1.0#beaea6a1c8d4e2ec7985524fbe8967fd:da39a3ee5e6b4b0d3255bfef95601890afd80709#8009cbea1e813f9f9258a2f49dc12c81 - Download (conancenter)
    yaml-cpp/0.8.0#720ad361689101a838b2c703a49e9c26:ed653c826af74fd523c736168d9debe9ed4c0d6f - Missing
ERROR: Missing binary: fmt/11.1.4:89687ba72ceb54fd19cb96c9451c949a2443e39d
ERROR: Missing binary: hunspell/1.7.2:ed653c826af74fd523c736168d9debe9ed4c0d6f
ERROR: Missing binary: yaml-cpp/0.8.0:ed653c826af74fd523c736168d9debe9ed4c0d6f

and this came down to the computed compiler version being "too new" compared to the binaries currently available.

I'm sort of inclined to keep this PR as-is for now, and re-evaluate Conan separately in the future.

@cpisz-posit

Copy link
Copy Markdown
Contributor

How should conan profiles be handled? Are these something we would generate and use from CMake (seems like https://github.com/conan-io/cmake-conan/blob/develop2/conan_provider.cmake is a tool that tries to automate some of this)? Or do they need to be pre-populated and pre-generated by hand?

FWIW, the default profile created by conan profile detect gave me a profile for which I couldn't install some dependencies, e.g. conan install . gave me

Requirements
    fmt/11.1.4#1fb24f082fabe20d28606d615ba93dfb:89687ba72ceb54fd19cb96c9451c949a2443e39d - Missing
    gsl-lite/0.42.0#1a0c9f187d3435370fd9752437abb768:da39a3ee5e6b4b0d3255bfef95601890afd80709#4a09d5e566c765ecbec4b387bcecdf54 - Download (conancenter)
    hunspell/1.7.2#57490b2e9619b4efb317be0e60f1e35c:ed653c826af74fd523c736168d9debe9ed4c0d6f - Missing
    tl-expected/1.1.0#beaea6a1c8d4e2ec7985524fbe8967fd:da39a3ee5e6b4b0d3255bfef95601890afd80709#8009cbea1e813f9f9258a2f49dc12c81 - Download (conancenter)
    yaml-cpp/0.8.0#720ad361689101a838b2c703a49e9c26:ed653c826af74fd523c736168d9debe9ed4c0d6f - Missing
ERROR: Missing binary: fmt/11.1.4:89687ba72ceb54fd19cb96c9451c949a2443e39d
ERROR: Missing binary: hunspell/1.7.2:ed653c826af74fd523c736168d9debe9ed4c0d6f
ERROR: Missing binary: yaml-cpp/0.8.0:ed653c826af74fd523c736168d9debe9ed4c0d6f

and this came down to the computed compiler version being "too new" compared to the binaries currently available.

I'm sort of inclined to keep this PR as-is for now, and re-evaluate Conan separately in the future.

I don't have the ins and outs of the current pipeline down pat yet, but I'd think you'd set up profiles when the container is setup in the docker files. That's what I did.

For example, when I make an ubuntu x64 jammy container, I include in the docker file the conan profile that tells it deb, x64, gcc, gcc version 11, etc.

Oh, I was def not implying to throw away or replace the work in this PR. I def think Conan should be evaluated in at least few demo run-throughs before locking in on doing the bigger effort. I'd be happy to help make some demos, as time allows, if we have a list of some of the dependencies, their versions, target OS, compiler version.

As you are seeing, a binary might not always be avail for the combination of settings and when that is the case, we have to build it once ourselves, make the recipe, and either upload it to central or put it in out own artifact repo. However, it is well worth the work, because everyone else need not ever build it again. Compiling from source is A LOT of hours and cpu cycles on dev boxes and build machine over time.

When I had set it up in the past, I had devops set up an instance of https://jfrog.com/artifactory/

@kevinushey
kevinushey marked this pull request as ready for review March 18, 2025 17:07
Comment thread cmake/compiler.cmake
Comment on lines +46 to +47
# assume sources are utf-8
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This seemed to be required for the {fmt} update.

@kevinushey
kevinushey marked this pull request as draft March 18, 2025 17:33
@kevinushey
kevinushey requested a review from gtritchie March 18, 2025 20:56
@kevinushey
kevinushey marked this pull request as ready for review March 18, 2025 20:56

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@kevinushey
kevinushey merged commit 2e6c95d into main Mar 18, 2025
@kevinushey
kevinushey deleted the feature/update-hunspell branch March 18, 2025 21:20
@gtritchie gtritchie added this to the Mariposa Orchid milestone Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants