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

Improve gRPC patchfile handling #47

Closed
wants to merge 3 commits into from
Closed

Conversation

ffoulkes
Copy link
Contributor

@ffoulkes ffoulkes commented Nov 19, 2023

  • Define a "patchfile" property in the components file. Update components.py to support it.

  • Provide three ways to determine the gRPC patch file:

    • Explicitly specified by the GRPC_PATCHFILE cmake variable (per the "patchfile" component property). This allows the patch file to be independent of the gRPC version number.

    • Implicitly derived from the GRPC_VERSION cmake variable (per the "version" component property). This provides backward compatibility with the current mechanism.

    • Implicitly specified by a grpc-current.patch.in symlink in the patches folder. This allows an outside process to apply the patch without knowing the gRPC version.

  • Refactor patchfile handling into two functions:

    • define_grpc_patch_file(), which selects the template file to use.
    • define_grpc_patch_clause(), which generates the patchfile from the template and defines the patch clause.
  • Make the path to the patch file explicitly relative to the top-level directory (CMAKE_SOURCE_DIR) rather than implicitly relative to grpc.cmake. This mitigates the "patch file not found" error in the MEV build.

  • If we are unable to apply to apply the gRPC patch, the worst outcome is that the RUNPATH of the gRPC plugins won't be updated, and the user will have to set LD_LIBRARY_PATH. This is (a) suboptimal rather than fatal, and (b) moot because this version of the Stratum dependencies breaks RPATH anyway. Make the messages WARNINGs rather than FATAL_ERRORs.

  • Correct the version number in the header comment of the gRPC v1.59.2 patch file.

@ffoulkes ffoulkes requested a review from 5abeel November 19, 2023 22:44
@ffoulkes ffoulkes added cmake Affects CMake build system medium effort Moderate effort required labels Nov 19, 2023
@ffoulkes ffoulkes force-pushed the grpc-patch-property branch 2 times, most recently from 9730967 to fd28b29 Compare November 30, 2023 23:41
@ffoulkes ffoulkes force-pushed the grpc-patch-property branch from fd28b29 to 36441d5 Compare December 4, 2023 21:20
@ffoulkes ffoulkes changed the title Overhaul gRPC patchfile handling Improve gRPC patchfile handling Dec 11, 2023
@ffoulkes ffoulkes requested a review from 5abeel January 4, 2024 19:08
Copy link
Collaborator

@5abeel 5abeel left a comment

Choose a reason for hiding this comment

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

LGTM

@ffoulkes ffoulkes force-pushed the grpc-patch-property branch from 36441d5 to 604425a Compare January 9, 2024 17:38
Copy link
Contributor

@nupuruttarwar nupuruttarwar left a comment

Choose a reason for hiding this comment

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

Do we plan to update the scripts for building dependencies to include the option of specifying GRPC_PATCHFILE ? Also, add documentation that it should be available in cmake/patches directory and on how to do it when building using cmake cmdline?

@ffoulkes
Copy link
Contributor Author

ffoulkes commented Jan 29, 2024

Do we plan to update the scripts for building dependencies to include the option of specifying GRPC_PATCHFILE ? Also, add documentation that it should be available in cmake/patches directory and on how to do it when building using cmake cmdline?

No. GRPC_PATCHFILE is a static mechanism, not a dynamic mechanism. The maintainer defines the patchfile component property in components.json and then uses the components.py script to update deps.cmake. The patch step then uses the specified filename instead of deriving one from the gRPC version.

As I noted in my response to Sabeel, this variable is not intended to be set from the command line. It's a component property, like version (which cmake references as GRPC_VERSION).

- Define a "patchfile" property in the components file.
  Update components.py to support it.

- Provide three ways to determine the gRPC patch file:

  1. Explicitly specified by the GRPC_PATCHFILE cmake variable
     (per the "patchfile" component property). This allows the
     patchfile to be independent of the gRPC version number.

  2. Implicitly derived from the GRPC_VERSION cmake variable
     (per the "version" component property). This provides
     backward compatibility with the current mechanism.

  3. Implicitly specified by a grpc-current.patch.in` symlink
     in the `patches` folder. This allows an outside process to
     apply the current patch without knowing the gRPC version.

- Make a failure to find the patch file a non-fatal error.

Signed-off-by: Derek G Foster <[email protected]>
- Modify define_grpc_patch_clause() to return an empty string if
  define_grpc_patch_file() returns an empty string.

- Improve internal documentation.

Signed-off-by: Derek G Foster <[email protected]>
@ffoulkes ffoulkes force-pushed the grpc-patch-property branch from bdf5f05 to 312677f Compare March 23, 2024 23:12
@ffoulkes
Copy link
Contributor Author

ffoulkes commented Apr 16, 2024

Also, add documentation that it should be available in cmake/patches directory and on how to do it when building using cmake cmdline?

@nupuruttarwar - Rereading your comment, I realized that I didn't really address your second question.

The existing documentation is in How to create a gRPC patch file.

To define GRPC_PATCHFILE, you add add a defines clause to the grpc entry in components.json:

    "grpc": {
        "name": "grpc",
        "url": "https://github.com/google/grpc.git",
        "sha": "883e5f76976b86afee87415dc67bde58d9b295a4",
        "tag": "v1.59.2",
        "version": "1.59.2",
        "defines": {
            "PATCHFILE": "custom.patch"
        }
    },

Then run components.py to update the deps.cmake file:

./scripts/components.py -o cmake/deps.cmake

Which produces the following:

set(GRPC_GIT_URL "https://github.com/google/grpc.git")
set(GRPC_GIT_TAG "883e5f76976b86afee87415dc67bde58d9b295a4") # v1.59.2
set(GRPC_VERSION "1.59.2")
set(GRPC_PATCHFILE "custom.patch")

I implemented the defines clause as general replacement for RECENT_PKGS and other ad hoc ways of handling special cases (especially in Protobuf, which has always been a problem child). See protobuf.cmake for examples of past and current workarounds.

We need documentation on components.json and the generator script. When time permits...

@ffoulkes ffoulkes closed this Jan 24, 2025
@ffoulkes ffoulkes deleted the grpc-patch-property branch January 24, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Affects CMake build system medium effort Moderate effort required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants